aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/OpenMPClause.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-24[OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (#145490)Robert Imschweiler1-0/+5
Implement parsing and semantic analysis support for the optional 'strict' modifier of the num_threads clause. This modifier has been introduced in OpenMP 6.0, section 12.1.2. Note: this is basically 1:1 https://reviews.llvm.org/D138328.
2025-06-23[NFC][Clang][AST] Adopt `llvm::copy` in Clang AST (#145192)Rahul Joshi1-38/+34
2025-06-19[NFC][Clang][AST] Adopt simplified `getTrailingObjects` in AST (#144432)Rahul Joshi1-6/+6
Adopt simplified `getTrailingObjects` API in several places in clag/AST that were missed by earlier changes.
2025-05-13[NFC][Clang] Adopt `TrailingObjects` API to build ArrayRef (#139639)Rahul Joshi1-1/+1
Adopt `getTrailingObjects()` overload that returns an ArrayRef that was added in https://github.com/llvm/llvm-project/pull/138970.
2025-05-09[clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (#139115)Krzysztof Parzyszek1-3/+3
The OpenMP version is stored in language options in ASTContext. If the context is not available, use the fallback version. RFC: https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507
2025-03-21[OpenMP 6.0] Parse/Sema support for reduction over private variable with ↵CHANDRA GHALE1-8/+11
reduction clause. (#129938) Initial Parse/Sema support for reduction over private variable with reduction clause. Section 7.6.10 in in OpenMP 6.0 spec. - list item in a reduction clause can now be private in the enclosing context. - Added support for _original-sharing-modifier_ with reduction clause. --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-03-11[clang] [OpenMP] New OpenMP 6.0 self_maps clause (#129888)Ritanya-B-Bharadwaj1-0/+6
Initial parsing/sema support for self maps in map and requirement clause [Sections 7.9.6 and 10.5.1.6 in OpenMP 6.0 spec]
2025-02-06[clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' ↵David Pagan1-0/+5
(#125933) Add initial parsing/sema support for new assumption clause so clause can be specified. For now, it's ignored, just like the others. Added support for 'no_openmp_construct' to release notes. Testing - Updated appropriate LIT tests. - Testing: check-all
2025-02-05[OpenMP]Initial parsing/sema support for target_device selector set (#118471)Ritanya-B-Bharadwaj1-2/+6
This patch adds initial support for target_device selector set - Section 9.2 (Spec 6.0)
2025-01-13[clang][OpenMP] Add 'align' modifier for 'allocate' clause (#121814)David Pagan1-16/+42
The 'align' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'align' modifier. Added support for align-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all
2024-11-17[AST] Remove unused includes (NFC) (#116549)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-11-05[clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (#114883)David Pagan1-5/+18
The 'allocator' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'allocator' modifier. Added support for allocator-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all - relevant sollve_vv test cases tests/5.2/scope/test_scope_allocate_construct.c
2024-10-09[Clang][OpenMP] Add permutation clause (#92030)Michael Kruse1-0/+27
Add the permutation clause for the interchange directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-09-07[AST] Avoid repeated hash lookups (NFC) (#107709)Kazu Hirata1-7/+3
While I am at it, I'm renaming Cache to UniqueDecls and removing TotalNum in favor of UniqueDecls.size().
2024-08-10[Clang][Sema][OpenMP] Allow `thread_limit` to accept multiple expressions ↵Shilei Tian1-3/+23
(#102715)
2024-08-06[Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (#99732)Shilei Tian1-3/+23
By the OpenMP standard, `num_teams` clause can only accept one expression (for now). In this patch, we extend it to allow to accept multiple expressions when it is used with `target teams ompx_bare` construct. This will allow to launch a multi-dim grid, same as CUDA/HIP.
2024-08-05[OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731)Julian Brown1-0/+78
This is a minimal patch to support parsing for "omp assume" directives. These are meant to be hints to a compiler's optimisers: as such, it is legitimate (if not very useful) to ignore them. The patch builds on top of the existing support for "omp assumes" directives (note spelling!). Unlike the "omp [begin/end] assumes" directives, "omp assume" is associated with a compound statement, i.e. it can appear within a function. The "holds" assumption could (theoretically) be mapped onto the existing builtin "__builtin_assume", though the latter applies to a single point in the program, and the former to a range (i.e. the whole of the associated compound statement). This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests.
2024-01-31[OpenMP] atomic compare weak : Parser & AST support (#79475)SunilKuravinakop1-0/+2
This is a support for " #pragma omp atomic compare weak". It has Parser & AST support for now. --------- Authored-by: Sunil Kuravinakop <kuravina@pe28vega.us.cray.com>
2023-11-26[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+12
Diff Revision: https://reviews.llvm.org/D123235
2023-11-20Revert "[OpenMP] atomic compare fail : Parser & AST support"Krzysztof Parzyszek1-12/+0
This reverts commit edd675ac283909397880f85ba68d0d5f99dc1be2. This breaks clang build where every component is a shared library. The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of libclangBasic.so, uses `getOpenMPClauseName` which isn't: /usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int )': OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam e(llvm::omp::Clause)'
2023-11-20[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+12
Diff Revision: https://reviews.llvm.org/D123235
2023-11-08Revert "[OpenMP] atomic compare fail : Parser & AST support"Mitch Phillips1-12/+0
This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5. Reason: Broke under -Werror. More details in https://reviews.llvm.org/D123235
2023-11-07[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+12
This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now. Reviewed By: tianshilei1992, ABataev Differential Revision: https://reviews.llvm.org/D123235
2023-10-24[OpenMP 5.2] Initial parsing and semantic analysis suppport for 'step' ↵Fazlay Rabbi1-11/+17
modifier on 'linear' clause Reference: (1) OpenMP 5.2 Specification - Seciton 5.4.6 Differential revision: https://reviews.llvm.org/D159546
2023-10-05Introduce the initial support for OpenMP kernel language (#66844)Shilei Tian1-0/+5
This patch starts the support for OpenMP kernel language, basically to write OpenMP target region in SIMT style, similar to kernel languages such as CUDA. What included in this first patch is the `ompx_bare` clause for `target teams` directive. When `ompx_bare` exists, globalization is disabled such that local variables will not be globalized. The runtime init/deinit function calls will not be emitted. That being said, almost all OpenMP executable directives are not supported in the region, such as parallel, task. This patch doesn't include the Sema checks for that, so the use of them is UB. Simple directives, such as atomic, can be used. We provide a set of APIs (for C, they are prefix with `ompx_`; for C++, they are in `ompx` namespace) to get thread id, block id, etc. Please refer to https://tianshilei.me/wp-content/uploads/llvm-hpc-2023.pdf for more details.
2023-09-29Revert "[OpenMP] Introduce the initial support for OpenMP kernel language ↵JP Lehr1-5/+0
(#66844)" This reverts commit e997dca3333823ffe2ea3aea288299f551532dcd.
2023-09-29[OpenMP] Introduce the initial support for OpenMP kernel language (#66844)Shilei Tian1-0/+5
This patch starts the support for OpenMP kernel language, basically to write OpenMP target region in SIMT style, similar to kernel languages such as CUDA. What included in this first patch is the `ompx_bare` clause for `target teams` directive. When `ompx_bare` exists, globalization is disabled such that local variables will not be globalized. The runtime init/deinit function calls will not be emitted. That being said, almost all OpenMP executable directives are not supported in the region, such as parallel, task. This patch doesn't include the Sema checks for that, so the use of them is UB. Simple directives, such as atomic, can be used. We provide a set of APIs (for C, they are prefix with `ompx_`; for C++, they are in `ompx` namespace) to get thread id, block id, etc. For more details, you can refer to https://tianshilei.me/wp-content/uploads/llvm-hpc-2023.pdf.
2023-07-25Reapply "[OpenMP] Add the `ompx_attribute` clause for target directives"Johannes Doerfert1-0/+12
This reverts commit 0d12683046ca75fb08e285f4622f2af5c82609dc and reapplies ef9ec4bbcca2fa4f64df47bc426f1d1c59ea47e2 with an extension to fix the Flang build. Differential Revision: https://reviews.llvm.org/D156184
2023-07-25Revert "[OpenMP] Add the `ompx_attribute` clause for target directives"Aaron Ballman1-12/+0
This reverts commit ef9ec4bbcca2fa4f64df47bc426f1d1c59ea47e2. The changes broke several bots: https://lab.llvm.org/buildbot/#/builders/176/builds/3408 https://lab.llvm.org/buildbot/#/builders/198/builds/4028 https://lab.llvm.org/buildbot/#/builders/197/builds/8491 https://lab.llvm.org/buildbot/#/builders/197/builds/8491
2023-07-24[OpenMP] Add the `ompx_attribute` clause for target directivesJohannes Doerfert1-0/+12
CUDA and HIP have kernel attributes to tune the code generation (in the backend). To reuse this functionality for OpenMP target regions we introduce the `ompx_attribute` clause that takes these kernel attributes and emits code as if they had been attached to the kernel fuction (which is implicitly generated). To limit the impact, we only support three kernel attributes: `amdgpu_waves_per_eu`, for AMDGPU `amdgpu_flat_work_group_size`, for AMDGPU `launch_bounds`, for NVPTX The existing implementations of those attributes are used for error checking and code generation. `ompx_attribute` can be attached to any executable target region and it can hold more than one kernel attribute. Differential Revision: https://reviews.llvm.org/D156184
2023-07-10[OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flagsSergio Afonso1-1/+1
This patch renames the `OpenMPIRBuilderConfig` flags to reduce confusion over their meaning. `IsTargetCodegen` becomes `IsGPU`, whereas `IsEmbedded` becomes `IsTargetDevice`. The `-fopenmp-is-device` compiler option is also renamed to `-fopenmp-is-target-device` and the `omp.is_device` MLIR attribute is renamed to `omp.is_target_device`. Getters and setters of all these renamed properties are also updated accordingly. Many unit tests have been updated to use the new names, but an alias for the `-fopenmp-is-device` option is created so that external programs do not stop working after the name change. `IsGPU` is set when the target triple is AMDGCN or NVIDIA PTX, and it is only valid if `IsTargetDevice` is specified as well. `IsTargetDevice` is set by the `-fopenmp-is-target-device` compiler frontend option, which is only added to the OpenMP device invocation for offloading-enabled programs. Differential Revision: https://reviews.llvm.org/D154591
2023-07-06[OPENMP52] Support Support omp_cur_iteration modifier for doacrossJennifer Yu1-1/+17
clause. This is just syntax to make it easier for the user. It doesn't add any new functionality. for doacross(sink: omp_cur_iteration - 1) Equivalent to doacross(sink: ConterVar - 1, ...) doacross(source: omp_cur_iteration) Equivalent to doacross(source) And restriction is: OMP5.2 p.327 If vector is specified with the omp_cur_iteration keyword and with sink as the dependence-type then it must be omp_cur_iteration - 1. If vector is specified with source as the dependence-type then it must be omp_cur_iteration. Differential Revision: https://reviews.llvm.org/D154556
2023-06-29[OMP5.2] Initial support for doacross clause.Jennifer Yu1-0/+54
2023-01-21[OpenMP] Introduce the `ompx_dyn_cgroup_mem(<N>)` clauseJohannes Doerfert1-0/+9
Dynamic memory allows users to allocate fast shared memory when a kernel is launched. We support a single size for all kernels via the `LIBOMPTARGET_SHARED_MEMORY_SIZE` environment variable but now we can control it per kernel invocation, hence allow computed values. Note: Only the nextgen plugins will allocate memory based on the clause, the old plugins will silently miscompile. Differential Revision: https://reviews.llvm.org/D141233
2023-01-20Add Parse/Sema for iterator for map clause.Doru Bercea1-8/+22
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-2/+2
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-09Move from llvm::makeArrayRef to ArrayRef deduction guides - clang/ partserge-sans-paille1-1/+1
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141139
2022-12-19[OpenMP][NFC] Cleanup clause boilerplateJohannes Doerfert1-3/+3
- Add helper classes to avoid duplicated boilerplate. - Add `final` for classes inheriting from those helpers. - Fix a `struct` vs `class` mismatch. Differential Revision: https://reviews.llvm.org/D140336
2022-12-12[OpenMP] Basic parse and sema support for modifiers in order clauseChi Chun Chen1-2/+6
This patch gives basic parsing and semantic support for "modifiers" of order clause introduced in OpenMP 5.1 ( section 2.11.3 ) Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D127855
2022-11-18[OPENMP5.1] Initial support for message clause.Jennifer Yu1-0/+7
2022-11-18[OpenMP] Initial parsing/sema for 'strict' modifier with 'num_tasks' clauseFazlay Rabbi1-0/+5
This patch gives basic parsing and semantic analysis support for 'strict' modifier with 'num_tasks' clause of 'taskloop' construct introduced in OpenMP 5.1 (section 2.12.2) Differential Revision: https://reviews.llvm.org/D138328
2022-11-17[OpenMP] Initial parsing/sema for 'strict' modifier with 'grainsize' clauseFazlay Rabbi1-0/+5
This patch gives basic parsing and semantic analysis support for 'strict' modifier with 'grainsize' clause of 'taskloop' construct introduced in OpenMP 5.1 (section 2.12.2) Differential Revision: https://reviews.llvm.org/D138217
2022-11-17[OPENMP5.1] Initial support for severity clauseJennifer Yu1-0/+8
Differential Revision:https://reviews.llvm.org/D138227
2022-11-15[OPENMP]Initial support for at clauseJennifer Yu1-0/+7
Error directive is allowed in both declared and executable contexts. The function ActOnOpenMPAtClause is called in both places during the parsers. Adding a param "bool InExContext" to identify context which is used to emit error massage. Differential Revision: https://reviews.llvm.org/D137851
2022-09-03[clang] Qualify auto in range-based for loops (NFC)Kazu Hirata1-1/+1
2022-08-18[OpenMP][NFC] Refactor code for interop parts of 'init' and 'append_args' ↵Mike Rice1-7/+8
clauses The 'init' clause allows an interop-modifier of prefer_type(list) and and interop-types 'target' and 'targetsync'. The 'append_args' clause uses an append-op that also includes interop-types ('target' and 'targetsync') and will allow a prefer_type list in the next OpenMP version. This change adds a helper struct OMPInteropInfo and uses it in the parsing of both the 'init' and 'append_args' clauses. One OMPInteropInfo object represents the info in a single 'init' clause. Since 'append_args' allows a variable number of interop items it will require an array of OMPInteropInfo objects once that is supported. Differential Revision: https://reviews.llvm.org/D132171
2022-05-25Revert "[OpenMP] atomic compare fail : Parser & AST support"Aaron Ballman1-31/+0
This reverts commit 232bf8189ef7d574a468bd5bfd1e84e962f7f16e. It broke the sanitize buildbot: https://lab.llvm.org/buildbot/#/builders/5/builds/24074 It also reproduces on Windows debug builds as a crash.
2022-05-24[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+31
This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D123235
2022-05-24[OpenMP] Add parsing/sema support for omp_all_memory reserved locatorMike Rice1-10/+22
Adds support for the reserved locator 'omp_all_memory' for use in depend clauses with 'out' or 'inout' dependence-types. Differential Revision: https://reviews.llvm.org/D125828