3640 Commits

Author SHA1 Message Date
theRonShark
00aede8f19
Revert "[Clang][OpenMP] Implement Loop splitting #pragma omp split directive " (#190335)
Reverts llvm/llvm-project#183261

15 new lit tests failing in openmp
2026-04-03 12:27:07 +00:00
Amit Tiwari
1972cf64fd
[Clang][OpenMP] Implement Loop splitting #pragma omp split directive (#183261)
OpenMP 6.0 Loop-splitting directive `#pragma omp split` construct with `counts`
clause
2026-04-03 10:42:31 +05:30
Michael Kruse
afb80bddf1
[Runtimes] Introduce variables containing resource dir paths (#177953)
Introduce common infrastructure for runtimes that determines compiler
resource path locations. These variables introduced are:

 * RUNTIMES_OUTPUT_RESOURCE_DIR
 * RUNTIMES_INSTALL_RESOURCE_PATH
 
That contain the location for the compiler resource path (typically
`lib/clang/<version>`) in the build tree and the install tree (the
latter relative to CMAKE_INSTALL_PREFIX).

Additionally, define

 * RUNTIMES_OUTPUT_RESOURCE_LIB_DIR
 * RUNTIMES_INSTALL_RESOURCE_LIB_PATH

as for the location of clang/flang version-locked libraries (typically
`lib${LLVM_LIBDIR_SUFFIX}/<targer-triple>`, but also depends on `APPLE`
and `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR`). This code is moved from
flang-rt and initially becomes its only user.

Refactored out of #171610 as requested
[here](https://github.com/llvm/llvm-project/pull/171610#discussion_r2687382481).

Extracted `get_runtimes_target_libdir_common` from compiler-rt as
requested
[here](https://github.com/llvm/llvm-project/pull/171610#discussion_r2689565634).
 
Added TODO comments to all runtimes as requested
[here](https://github.com/llvm/llvm-project/pull/171610#issuecomment-3789598635).
2026-04-02 10:32:14 +00:00
David Truby
720b8ea893
[openmp] Add support for Arm64X to libomp (#176157)
This patch allows building libomp.dll and libomp.lib as Arm64X binaries
containing both arm64 and arm64ec code and useable from applications
compiled for both architectures.
2026-03-31 16:39:02 +01:00
David Truby
161c53f66e
[openmp] Add support for arm64ec to libomp (#176151)
This patch adds arm64ec support to libomp.
Note that this support isn't entirely usable on Windows hosts as libomp
requires LLVM_PER_TARGET_RUNTIME_DIR=On for to work correctly when
multiple runtimes are built, which is unsupported on Windows. A
following patch will add arm64x support to the build to rectify this.
2026-03-31 13:07:19 +01:00
fineg74
1611a23a5b
[OFFLOAD] Add spirv implementation for named barrier (#180393)
This change adds implementation for named barriers for SPIRV backend.
Since there is no built in API/intrinsics for named barrier in SPIRV,
the implementation loosely follows implementation for AMD
2026-03-27 20:14:09 +01:00
Michael Kruse
8ab7b37e74
[OpenMP][test] Remove %flags-use-compiler-omp-h (#188789)
With the standalone and project builds removed,
`OPENMP_TEST_COMPILER_HAS_OMP_H`/`config.test_compiler_has_omp_h` is set
to constant 1, which causes the `config.omp_header_directory` search
path NOT to be added to `%flags-use-compiler-omp-h`, causing the system
`omp.h` used, or the only test actually using it
(`omp50_taskdep_depobj.c`) failing if that one is not available.

The intention of `OPENMP_TEST_COMPILER_HAS_OMP_H` was to use gcc's
`omp.h` which declares `omp_depend_t` differently than our `omp.h`
(https://reviews.llvm.org/D108790). Using `OPENMP_TEST_C_COMPILER=gcc`
was used to test libomp's GOMP compatibility layer, but testing it is
currently unmaintained and has no buildbot (60 failing tests out of 389
with gcc-13, not including OMPD and OMPT). If updating testing for GOMP,
then gcc's own `omp.h` must be used for all tests: using the GOMP ABI
requires using GOMP's `omp.h`.

Closes: #187879
2026-03-27 10:59:06 +01:00
Joseph Huber
82530154ef
[Offload] Enable multilib building for OpenMP/Offload (#188485)
Summary:
Right now the CMake does not follow the pattern other runtime projects
use. All this does is use the standard subdir to place libraries in a
unique location. This allows, for example, users to configure a debug
version of openmp / offload within the same CMake invocation.

---------

Co-authored-by: Michael Kruse <github@meinersbur.de>
2026-03-26 07:37:22 -05:00
Alex Duran
3e72f02e20
[Offload][OpenMP][libdevice] Make check to enter state machine architecture dependent (#188144)
The genericStateMachine call uses synchronize::thread wich is expected
to be implemented using a workgroup level barrier.
Currently as in some other architectures where if threads in the same
warp as the main thread reach the barrier may cause a race condition
there's a condition that makes some threads not enter the state machine.
But in Intel GPUs all threads must reach the barrier for it to be
completed, otherwise the threads in the state machine never make
progress.

This PR moves the condition into an architecture-dependent config so it
can work correctly for both kinds of hardware.
2026-03-25 16:22:22 +01:00
Joseph Huber
d18a784d41
[compiler-rt] Define GPU specific handling of profiling functions (#185763)
Summary:
The changes in https://www.github.com/llvm/llvm-project/pull/185552
allowed us to
start building the standard `libclang_rt.profile.a` for GPU targets.
This PR expands this by adding an optimized GPU routine for counter
increment and removing the special-case handling of these functions in
the OpenMP runtime.

Vast majority of these functions are boilerplate, but we should be able
to do more interesting things with this in the future, like value or
memory profiling.
2026-03-19 10:51:48 -05:00
Joseph Huber
073d019c45
[OpenMP] Use the standard fences now that they are supported (#187138)
Summary:
We can now use these on NVPTX properly.
2026-03-18 08:42:07 -05:00
Jan André Reuter
1588f08369
[OpenMP][OMPT] Add missing error entry to device tracing record union (#185683)
While `omp-tools.h` already includes the `ompt_record_error_t` struct,
the corresponding union entry was missing from `ompt_record_ompt_t`.
This commit adds the missing entry.

Note that this does not enable any functionality for device tracing
records.
This only aligns the struct with OpenMP v5.1 and newer. OpenMP v5.0 did
not contain the `error` directive.

CC: @jprotze

Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
2026-03-17 10:00:21 +01:00
Chi-Chun, Chen
2ad51ffbfa
[mlir][llvmir][OpenMP] Translate affinity clause in task construct to llvmir (#182223)
Translate affinity entries to LLVMIR by passing affinity information to
createTask (__kmpc_omp_reg_task_with_affinity is created inside
PostOutlineCB).

3/3 in stack for implementing affinity clause with iterator modifier
1/3 #182218
2/3 #182222
3/3 #182223
2026-03-16 10:16:38 -05:00
Kevin Sala Penades
ac71b185c2
[offload] Remove LIBOMPTARGET_SHARED_MEMORY_SIZE envar (#186231)
This commit removes the `LIBOMPTARGET_SHARED_MEMORY_SIZE` envar and
outputs a runtime warning if it is defined. Access to dynamic shared memory
should be obtained through the `dyn_groupprivate` clause (OpenMP 6.1) or
the launch arguments in liboffload kernel launch.
2026-03-12 21:21:29 -07:00
Michael Halkenhäuser
4f2dea8ac7
[OpenMP][OMPT] Remove Threads dependency from omptest link interface (#186183)
Link against Threads using PRIVATE scope, instead of PUBLIC.
Reason: it imposes a transitive dependency on library users.

If Threads could not be found this could cause a link error.
The issue would manifest, if omptest is used via find_package.

Addresses issues with previous PR
https://github.com/llvm/llvm-project/pull/185930
2026-03-12 18:16:36 +01:00
Kelvin Li
9ddf38b008
[OpenMP] Include the cmake policy file (#186031)
This patch is to enforce building shared library archive by default on
AIX as described in CMP0182.
2026-03-12 11:54:11 -04:00
Jan Patrick Lehr
1cd094fb70
Revert "[OpenMP][OMPT] Remove Threads dependency from omptest" (#186111)
Reverts llvm/llvm-project#185930

Breaks various buildbots
2026-03-12 13:51:01 +01:00
Michael Halkenhäuser
5f97e191b3
[OpenMP][OMPT] Remove Threads dependency from omptest (#185930)
Removed link against `Threads`.
Reason: it is potentially problematic and optional.

The issue would manifest, if `omptest` is used via `find_package`.
But `Threads` might not be found and cause a link error.
2026-03-12 13:08:49 +01:00
Kevin Sala Penades
1f583c6dee
[OpenMP][Offload] Add offload runtime support for dyn_groupprivate clause (#152831)
Part 3 adding offload runtime support. See
https://github.com/llvm/llvm-project/pull/152651.

---------

Co-authored-by: Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com>
2026-03-12 01:13:06 -07:00
Robert Imschweiler
fd578f7c5c
[libomp] Fix hwloc include for non-standard paths (#184087)
Fixes https://github.com/llvm/llvm-project/issues/183884

---------

Co-authored-by: Michael Kruse <llvm-project@meinersbur.de>
2026-03-02 18:03:36 +01:00
Michael Kruse
87cbea6cdc
[openmp][cmake][NFCI] Avoid non-eval uses of ${var} (#182267)
When using

    set(var "Example")
    if (${var})

CMake will first resolve the if-argument to

    if (Example)

And what then happens depends on the existance of a variable with the
name "Example":

1. If instead of "Example", a truth constant is used ("TRUE", "FALSE",
   "ON", "OFF", "", "-NOTFOUND" ...), it is prioritized
   (https://cmake.org/cmake/help/latest/command/if.html#constant)

2. If a variable with the name "Example" exists: Use the truthiness of
   its content
   (https://cmake.org/cmake/help/latest/command/if.html#variable)

3. Otherwise, it is false-y

That is, the the result of the conditional does not only depend on the
content of `var`, but also some other variable. This is usually
unintended and leads to problems such as addressed with #154537. The
only case where this is intended is when passing an expression to be
evaluated such as with `pythonize_bool`, `append_if` and
`libomp_append`. In all other cases, using `${var}` without quotes is a
pattern to be avoided.

Remark:
If `${var}` is not one of the values considered a [truthiness
constant](https://cmake.org/cmake/help/latest/command/if.html#constant),
the result of `if (var)` and `if ("${var}")` is different:

* `if (var)` is true-ish
  (https://cmake.org/cmake/help/latest/command/if.html#variable)

* `if ("Example")` and therefore `if ("${var}")` are false-y
  (https://cmake.org/cmake/help/latest/command/if.html#string)

In this PR I am preferring `if (var)` over `if ("${var}")` because has
less clutter, resembles Python's behaviour, and problably what most
users are expecting, even though `if (${var})` in most cases would
evaluate to false-y because a variable does not exist. This ambiguity
does not exist for STREQUAL and MATCHES.
2026-03-02 13:21:36 +01:00
Joachim
d44e417945
[openmp][tests] Fix bug63197.c (#183508)
#183269 tried to fix the test, but the test can still randomly fail. The
OpenMP spec does not prevent the runtime to chose a smaller team size
than returned from omp_max_threads() for the second parallel region.

Using a larger value than `omp_max_threads()` in a `num_threads` clause
is valid OpenMP code. With a correct OpenMP implementation, the
team-size of the second parallel region must still be smaller or equal
the value returned from `omp_max_threads()`.
2026-02-26 17:26:47 +01:00
Nikita Popov
368b884869
[openmp] Fix bug63197.c test with 3 cores (#183269)
This test assumes that the number of available threads is not 3,
otherwise `#pragma omp parallel` and `#pragma omp parallel
num_thread(3)` are naturally going to do the same thing.

Instead use `omp_get_max_threads() - 1` as the number of threads in the
initial `omp parallel num_thread(N)` and then check that the number of
threads does not match the value in the later `omp parallel`.
2026-02-25 15:58:23 +01:00
Martin Storsjö
48a5119d8e
[openmp] Allow testing OpenMP without a full clang build tree (#182470)
Having a build tree with "not" and "FileCheck" is still required, but if
Clang/Flang isn't configured in that build, run the tests with the same
compiler CMake uses. This is how testing worked in the standalone build
configurations that now have been removed.
2026-02-23 23:01:44 +02:00
Michael Kruse
6295b8e763
[OpenMP] Remove standalone build mode (Reapply #149878) (#182022)
This reapplies #149878

Remove all the CMake code for openmp standalone builds. Standalone
builds have been superseded by the runtimes default build (also
sometimes called the standalone runtimes build). The runtimes default
build can be thought of a standalone build with the standalone
boilerplate contained in <llvm-project>/runtimes/CMakeLists.txt. There
is no need for each runtime to contain the same boilerplate code again.

Builds still using the standalone build via
```sh
cmake -S <llvm-project>/openmp ...
```
can switch over to the runtimes default build using
```sh
cmake -S <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=openmp ...
```
Options that were valid for the standalone build are also valid for
default runtimes build, unless handled only in `if
(OPENMP_STANDALONE_BUILD)` regions.

The existence of both, standalone builds and runtime default builds,
easily leads to confusion such as fixed in #149871. A non-standalone
build does not mean that it is built as part of a bootstrapping-build of
LLVM inside the `runtimes/runtimes-bins` directory, nor does it mean
that the compiler is necessarily Clang. Some of the remaining code may
have been written with that assumption. However, the purpose of this
patch is to only remove the standalone build functionality.
2026-02-18 18:11:55 -05:00
Michael Kruse
e07b9d1504 Revert "[OpenMP] Remove standalone build mode (#149878)"
Downstream builds are note sufficiently prepared.

This reverts commit 176928cc1371c23d499b474fa95e076b61f776c4.
2026-02-18 13:52:41 +01:00
Michael Kruse
176928cc13
[OpenMP] Remove standalone build mode (#149878)
Remove all the CMake code for openmp standalone builds. Standalone
builds have been superseded by the runtimes default build (also
sometimes called the standalone runtimes build). The runtimes default
build can be thought of a standalone build with the standalone
boilerplate contained in <llvm-project>/runtimes/CMakeLists.txt. There
is no need for each runtime to contain the same boilerplate code again.

Builds still using the standalone build via
```sh
cmake -S <llvm-project>/openmp ...
```
can switch over to the runtimes default build using
```sh
cmake -S <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=openmp ...
```
Options that were valid for the standalone build are also valid for
default runtimes build, unless handled only in
`if (OPENMP_STANDALONE_BUILD)` regions.

The existence of both, standalone builds and runtime default builds,
easily leads to confusion such as fixed in #149871. A non-standalone
build does not mean that it is built as part of a bootstrapping-build of
LLVM inside the `runtimes/runtimes-bins` directory, nor does it mean
that the compiler is necessarily Clang. Some of the remaining code may
have been written with that assumption. However, the purpose of this
patch is to only remove the standalone build functionality.
2026-02-18 12:00:04 +01:00
Ferran Toda
f560e4cfb1
[MLIR][OpenMP] Add omp.fuse operation (#168898)
This patch is a follow-up from #161213 and adds the omp.fuse loop
transformation for the OpenMP dialect. Used for lowering a `!$omp fuse`
in Flang.

Added Lowering and end2end tests.
2026-02-17 15:34:27 +01:00
Joseph Huber
d85576d368
[libc] Replace RPC 'close()' mechanism with RAII handler (#181690)
Summary:
Closing ports was previously done manually, This makes the protocol more
error prone as unclosed ports will leak and eventually the locks will
run out. I believe the original fear was that the RAII portion would
negatively impact code generation but I have not noticed anything
significant.
2026-02-16 15:14:30 -06:00
Nick Sarnie
b217e5c5a0
[OpenMP][lit] Disable flaky test tasking/issue-94260-2.c (#176452)
The test sporadically fails on Linux. See
https://github.com/llvm/llvm-project/issues/176451 for more info.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-13 17:06:36 +00:00
Nikita Popov
05ea779fcf
[openmp] Remove perl mentions (#181371)
These tests were converted from Perl to Python in #95307, so there is no
perl dependency here anymore. (I omitted an explicit mention of Python
here, as that's a general dependency anyway.)
2026-02-13 15:11:31 +00:00
fineg74
e0293fc7a5
[OFFLOAD] Add support for SPIRV to ompx (#179849)
After adding support to build device RTL for SPIRV, this PR will make an
ompx to use the DeviceRTL API when compiled for SPIRV
2026-02-13 06:55:44 -06:00
Joseph Huber
a969d572c2
[OpenMP] Remove special handling for SPIR-V uinc atomic (#180747)
Summary:
No longer necessary after
https://github.com/llvm/llvm-project/pull/179114
2026-02-10 10:21:16 -06:00
YunQiang Su
74e9bc6cb9
openmp: add atomic to SANITIZER_COMMON_LINK_LIBS for MIPS (#179933)
atomic is needed explicitly for MIPS.
2026-02-06 08:17:56 +08:00
Nick Sarnie
02d8c9c63a
[OpenMP] Stub vprintf on non-NVPTX if no libc (#180025)
The AMDGPU check was added in
https://github.com/llvm/llvm-project/pull/123670 where the reasoning
seems to be that the NVIDIA SDK will provide `vprintf` for the NVPTX
case and AMDGPU was the only other supported target at the time.

SPIR-V also needs this stubbed out, so just check that it's not NVPTX.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-05 22:11:32 +00:00
Michael Kruse
c15853ec3a
[OpenMP] Remove LLVM_ENABLE_PROJECTS=openmp build mode (#176950)
Reapply #152189 and #174963 which were reverted because it broke
publish-sphinx-docs and publish-doxygen-docs.

The build mode has been deprecated in #136314 and was supposed to be
removed in the LLVM 21 release (#136314).

OpenMP currently supports 4 build modes:

 * `cmake <llvm-project>/llvm -DLLVM_ENABLE_PROJECTS=openmp`
 * `cmake <llvm-project>/llvm -DLLVM_ENABLE_RUNTIMES=openmp` (bootstrapping build)
 * `cmake <llvm-project>/openmp` (standalone build)
 * `cmake <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=openmp` (runtimes default/standalone build)

Each build mode increased the maintanance overhead since all build modes
must continue working and user confusion when there do not (see #151117,
#174126, #154117, ...). Let's finally remove it.
2026-01-30 21:05:29 +01:00
Joseph Huber
830236204e
[Offload] Provide a cache file for building OpenMP w/ Flang offloading (#178472)
Summary:
This build is more annoying, enables everything required for this
version of the runtime.
2026-01-29 12:35:42 -06:00
Michael Kruse
dd76d3382c
[OpenMP][docs] Revise building manual (#176175)
Go into more detail on the two non-legacy build modes. 

I decided use create a dedicated document documention the build process.
`index.rst` only keeps the "Getting Started" part. `README.rst` is
vastly outdated with the still valid parts integrated into the new
documentation. `SupportAndFAQ.rst` is unstructured and keeps only the
non-building parts.

The the new building document is written in Meltdown, following the
decision from LLVM.
2026-01-28 14:13:41 +01:00
Joseph Huber
5b98c9be17 [OpenMP] Small fixes after refactoring and adding SPIR-V support 2026-01-27 15:57:21 -06:00
fineg74
8db9774118
[OFFLOAD] Build DeviceRTL with SPIRV backend (#174675)
This PR adds configuration to build DeviceRTL with SPIRV backend. It is
primarily used for level-zero plugin for Intel GPUs

---------

Co-authored-by: Joseph Huber <huberjn@outlook.com>
2026-01-27 00:09:28 +00:00
Joseph Huber
5597903240
[OpenMP] Cleanup synchronization primitives (#177710)
Summary:
These shouldn't be so different after we moved away from variants. It's
much simpler to define this in-line with a single preprocessor
definition. This should be equivalent less a few unnecessary function
definitions with the advantage that SPIR-V now has less work to do.
2026-01-26 14:20:52 -06:00
Joseph Huber
3219f1a5ce [OpenMP] Force initialization of global device environment
Summary:
This causes issues when we omit this, which requires a constructor from
an incompatible address space and bad things happen.
2026-01-22 16:45:49 -06:00
Joseph Huber
d5899ccb6f
[Clang] Rename uinc_wrap and add normal atomic builtin (#177253)
Summary:
The `__scoped_atomic` builtins are supposed to match the standard
GNU-flavored `__atomic` builtins. We added a scoped builtin without a
corresponding standard one before the fork so this should be added in
the release candidate. These were originally added in
https://github.com/llvm/llvm-project/pull/168666

Also, the name `uinc_wrap` does not follow the naming convention. The
GNU atomics use `fetch_xyz` to indicate that the builtin returns the
previous location's value as part of the RMW operation, which these do.
This PR renames it and its uses.
2026-01-22 08:02:45 -06:00
Joseph Huber
f534711729
[OpenMP][NFC] Use uinc atomic builtins for this operation (#177207)
Summary:
We support this now, this is 1-to-1 equivalent and simply prevents us
from needing to do it ourselves.
2026-01-21 11:31:23 -06:00
Michael Kruse
8acf454ed1 Revert "[OpenMP] Remove LLVM_ENABLE_PROJECTS=openmp build mode (#174963)"
This reverts commit f7b5b670c1cf0fe54e59aa0d1f1a11ee66e442ab.

It had broken the publish-doxygen-docs buildbot
2026-01-20 13:00:54 +01:00
Michael Kruse
f7b5b670c1
[OpenMP] Remove LLVM_ENABLE_PROJECTS=openmp build mode (#174963)
Reapply #152189 which was reverted because it broke publish-sphinx-docs.

The build mode has been deprecated in #136314. According to the
deprecation message, it was supposed to be removed in the LLVM 21
release. Each build mode increased the maintanance overhead when
failing, such as in #151117.
2026-01-20 11:55:43 +01:00
Michael Halkenhäuser
696b91aeb7
[OpenMP][omptest] Fix CMake target properties (#176802)
Fix visibility of target properties:
 * INCLUDE_DIRECTORIES
 * COMPILE_DEFINITIONS

implicitly pulled in from `default_gtest`.

Fixes: https://github.com/llvm/llvm-project/pull/159416
2026-01-19 19:09:29 +00:00
Michael Halkenhäuser
d5fea7e4f0
[OpenMP][omptest] Improve CMake and address review comments (#159416)
Avoid explicit ABI breaking check deactivation
Replace whole-archive linking with dedicated build of GoogleTest lib

Addresses remaining post-merge review comments of
https://github.com/llvm/llvm-project/pull/154786
2026-01-19 17:40:32 +00:00
Aaron Ballman
bc550d380c
Nominate Michael Klemm as lead maintainer of OpenMP (#175964)
We discussed this during the OpenMP sync-up call on 1/14 and he's still
actively maintaining this component and would be happy to act as lead
for it.
2026-01-14 15:17:26 +00:00
Austin Jiang
e6cdfb75ac
Fix typos and spelling errors across codebase (#156270)
Corrected various spelling mistakes such as 'occurred', 'receiver',
'initialized', 'length', and others in comments, variable names,
function names, and documentation throughout the project. These
changes improve code readability and maintain consistency in naming
and documentation.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2026-01-13 11:52:46 -05:00