Page MenuHomePhabricator

[OpenMP][Part 1] Reusable OpenMP context/traits handling

Authored by jdoerfert on Dec 23 2019, 1:54 PM.



This is the first of multiple parts to make OpenMP context/trait
handling reusable and generic. This patch was originally part of D71830
but with the unit tests it can be tested independently.

This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.

All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From
these definitions we generate the enum classes TraitSet,
TraitSelector, and TraitProperty as well as conversion and helper
functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}.

The OpenMP context is now an explicit object (see struct OMPContext).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the VariantMatchInfo, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the

Diff Detail

Unit TestsFailed

800 mslibc++.std/containers/sequences/array/array_creation::Unknown Unit Message ("")
Command: ['/usr/bin/clang++', '-o', '/dev/null', '-x', 'c++', '/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/std/containers/sequences/array/array.creation/', '-c', '-v', '-ftemplate-depth=270', '-fsyntax-only', '-Xclang', '-verify', '-Xclang', '-verify-ignore-unexpected=note', '-ferror-limit=1024', '-Werror=thread-safety', '-std=c++2a', '-include', '/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support/nasty_macros.h', '-nostdinc++', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/include', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/projects/libcxx/include/c++build', '-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support', '-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/std/input.output/filesystems/Inputs/static_test_env"', '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/projects/libcxx/test/filesystem/Output/dynamic_env"', '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="/usr/bin/python /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support/"', '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror', '-Wuser-defined-warnings', '-Wshadow', '-Wno-unused-command-line-argument', '-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extensions', '-Wno-user-defined-literals', '-Wno-noexcept-type', '-Wsign-compare', '-Wunused-variable', '-Wunused-parameter', '-Wunreachable-code', '-Wno-error=user-defined-warnings', '-c'] Exit Code: 1 Standard Error:

Event Timeline

jdoerfert created this revision.Dec 23 2019, 1:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 23 2019, 1:54 PM

Unit tests: pass. 60972 tests passed, 0 failed and 726 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

JonChesterfield requested changes to this revision.Jan 13 2020, 6:11 PM

Mostly minor comments. You've got a lot of mileage out of x macros. I really like the unit tests generated from the same .def as the source.

I think there's a bug in isSubset where you're comparing iterators but should be comparing values, not sure why the tests miss that though. Marking as request changes / what I've missed for that line.



I wonder if a size comparison and early return would be profitable here.




Probably warrants a comment that it checks for C0 is a subset of C1. Not sure there's a strong convention on argument order here.

Also a comment that it requires the arrays to have been sorted, assuming an assertion is too expensive


This looks strange - missing dereferences?


srict -> strict


Missmatch => mismatch

This revision now requires changes to proceed.Jan 13 2020, 6:11 PM
jdoerfert updated this revision to Diff 241612.Jan 30 2020, 5:15 PM
jdoerfert marked 6 inline comments as done.

Addressed review comments

Unit tests: fail. 62360 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/

clang-tidy: fail. clang-tidy found 0 errors and 6 warnings. 0 of them are added as review comments below (why?).

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

JonChesterfield accepted this revision.Feb 1 2020, 3:04 AM

Nice use of expensive_checks.

This revision is now accepted and ready to land.Feb 1 2020, 3:04 AM
This revision was automatically updated to reflect the committed changes.
rnk added a subscriber: rnk.Mar 13 2020, 5:00 PM
rnk added inline comments.

I'd suggest that you think about different data structures here. I noticed that this instantiation of SmallSet, which wraps std::set, takes ~20ms, and happens in every file that includes OMPContext.h.

Can you use a BitVector or std::bitset instead?

jdoerfert marked an inline comment as done.Mar 13 2020, 5:42 PM
jdoerfert added inline comments.

TBH, I don't understand why this takes any time at all as it is just a type. Do you mean having std::set in the type is already slow?

I still run test but what do you think of D76170 ?

rnk added inline comments.Mar 14 2020, 8:54 AM

Basically, yes, all the time is spent instantiating std::set<>::insert. This is a set of enumerators, though, which are densely packed integers with some known fixed maximum, so a bit vector seems like a more natural representation.