606 Commits

Author SHA1 Message Date
Alex Duran
e0182ebd40
[OFFLOAD] Fix issue where host plugin is added twice to the plugin list (#181346) 2026-02-13 12:08:04 +01:00
fineg74
b58a31d3ce
[OFFLOAD] Add support for host offloading device (#177307)
The purpose of this PR is to add support of host as an offloading device
to liboffload. Both OpenMP and sycl support offloading to a host as
their normal workflow and therefore would require such capability from
liboffload library.
2026-02-13 10:27:52 +01:00
Joseph Huber
846e61c0fb [libc] Small change to accept lambda types in rpc::dispatch
Summary:
This change allows lambdas to be used in the RPC dispatching functions.
Just requires an extra function trait to convert a lambda with no
captures into a function pointer. Also rearranged where the `Port` lives
because it looks better no that we may use  a lambda and it's more
consistent with the dispatch usage (putting the client at the start).
2026-02-12 09:18:56 -06:00
Hansang Bae
0deb1b6e05
[Offload] Try to load Level Zero loader with version suffix (#180042)
The default Level Zero loader `libze_loader.so` may not be available on
systems that don't have Level Zero development package. Level Zero
loaders with major version suffix are searched in that case.
2026-02-11 15:13:26 -06:00
Joseph Huber
6d6feb7655
[libc] Add RPC helpers for dispatching functions to the host (#179085)
Summary:
The RPC interface is useful for forwarding functions. This PR adds
helper functions for doing a completely bare forwarding of a function
from the client to the server. This is intended to facilitate
heterogenous libraries that implement host functions on the GPU (like
MPI or Fortran).
2026-02-11 08:13:52 -06:00
Alex Duran
8b9fd4803c
[OFFLOAD] Support host plugin on Windows (#180401)
Changes to make host plugin compile on Windows:
* Change IO code to be portable
* Adjust Makefiles

Allow plugin to work partially when libffi support is not found
dynamically (compilation works fine even on Windows because of the
wrapper support).
2026-02-11 08:54:47 +01:00
Nick Sarnie
6c0ff8d12f
Revert "Reapply [Offload][lit] Link against SPIR-V DeviceRTL if present" (#180743)
Reverts llvm/llvm-project#180231
2026-02-10 14:22:40 +00:00
Alex Duran
e17226e20b
[OFFLOAD] Implement excluding filters for debugging (#180538)
Allow a to define a set of Types that are not shown by default when
doing default debug loggin (e.g., LIBOMPTARGET_DEBUG=All).

Users can enable output of those types of messages by explicitly adding
them to LIBOMPTARGET_DEBUG.

Used to implement: #180545

---------

Co-authored-by: Michael Klemm <michael.klemm@amd.com>
2026-02-10 10:01:52 +01:00
Nick Sarnie
7fcc12c3be
Reapply [Offload][lit] Link against SPIR-V DeviceRTL if present (#180231)
I'll merge this at the same time as some llvm-zorg changes that start
building the DeviceRTL.

We only see one new test passing because everything still fails because
of the issue described in
https://github.com/llvm/llvm-project/pull/178980

Once a fix for that issue is merged we will see many new passes.
2026-02-09 16:52:33 +00:00
Robert Imschweiler
33e3384aa8
[offload] Adapt tests to new PluginInterface quoting [NFC] (#180505)
4096cb6017
removed the quotes around PluginInterface
2026-02-09 07:47:04 -06:00
Nick Sarnie
6844af142e
Revert "[Offload][lit] Link against SPIR-V DeviceRTL if present" (#180211)
Reverts https://github.com/llvm/llvm-project/pull/180030

Need to make changes to buildbot first
2026-02-06 15:05:16 +00:00
Joseph Huber
2f00977fea
[Offload] Make the RPC callbacks private to each running server (#178901)
Summary:
The static object mixes callbacks from different plugins because ever
since we moved to the object library target these are actually shared.
Just make it a member of the base class and make it a pointer set just
to do some basic deduplication.
2026-02-06 08:28:57 -06:00
Alex Duran
4096cb6017
[OFFLOAD] Fix TARGET_NAME in plugins common code (#180151)
Unlike other names is set between quotes which prevents our debug macros
to properly match it.
2026-02-06 14:12:04 +01:00
Nick Sarnie
b985974e75
[Offload][lit] Link against SPIR-V DeviceRTL if present (#180030)
Right now if we run `check-offload` for SPIR-V the DeviceRTL isn't used
because we pass `-nogpulib`.

Don't pass that, but also don't pass `--libomptarget-spirv-bc-path` yet
because the DeviceRTL is brand new so we don't want to error if it's not
present.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-05 22:11:50 +00:00
Yury Plyakhin
ecd1767edb
[offload] Fix DeviceImage to handle OffloadBinary::create returning vector (#180003)
OffloadBinary::create() now returns
`Expected<SmallVector<unique_ptr<OffloadBinary>>>`
instead of a single unique_ptr, to support multiple entries in version 2
format.

Updated DeviceImageTy constructor to extract the first binary from the
returned
vector, with empty check. In this context, only one image per
OffloadBinary is expected.
2026-02-05 12:41:03 -06:00
Joseph Huber
39b328c6f7
[OpenMP] Enable XFAIL OpenMP tests that pass now (#179344)
Summary:
These have been fixed, should be updated
2026-02-03 07:32:24 -06:00
Joseph Huber
c23c6b1940
[Offload] Only issue a warning for building offload on the GPU and return (#179240)
Summary:
Right now this will fail because the GPU architectures will attempt to
build all of `offload` with the GPU, which obviously won't work. In the
future we will proably have some utility library that we will route
through this, but for now just silently return. This is useful because
the documentation states to use this, but it doesn't work right now.
```
-DLLVM_ENABLE_RUNTIMES=offload;openmp
-DLLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa
```

This PR makes this work.
2026-02-02 09:37:57 -06:00
Joseph Huber
1a86c146ae
[Offload] Add a function to register an RPC Server callback (#178774)
Summary:
We provide an RPC server to manage calls initiated by the device to run
on the host. This is very useful for the built-in handling we have,
however there are cases where we would want to extend this
functionality.

Cases like Fortran or MPI would be useful, but we cannot put references
to these in the core offloading runtime. This way, we can provide this
as a library interface that registers custom handlers for whatever code
people want.
2026-01-30 08:03:13 -06: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
Akash Banerjee
7c07cb6542
[MLIR][OpenMP] Fix recursive mapper emission. (#178453)
Recursive types can cause re-entrant mapper emission. The mapper
function is created by OpenMPIRBuilder before the callbacks run, so it
may already exist in the LLVM module even though it is not yet
registered in the ModuleTranslation mapping table. Reuse and register it
to break the recursion. Added offloading test.
2026-01-29 16:38:33 +00:00
puneeth_aditya_5656
ed4aab07ec
[Offload][AMDGPU] Fix olQueryQueue uninitialized output parameter (#178464)
## Summary
- Fix uninitialized output parameter in `olQueryQueue_impl` when
`Queue->AsyncInfo->Queue` is null
- Set `IsQueueWorkCompleted` to `true` when no underlying queue exists
(no pending work)
- Resolves test failure on AMDGPU for
`olQueryQueueTest.SuccessEmptyAsyncQueueCheckResult`

Fixes #178462.

## Test plan
- [x] Fixed
`OffloadAPI/queue.unittests/olQueryQueueTest/SuccessEmptyAsyncQueueCheckResult/AMDGPU_AMD_Radeon_RX_7700_XT_0`
test
- [ ] CI tests pass

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Joseph Huber <huberjn@outlook.com>
2026-01-28 20:49:19 -06:00
Akash Banerjee
c856c3d045
[MLIR][OpenMP] Fix mapper being attached to partial maps. (#178247)
Fix OpenMP mapper lowering by attaching user-defined/default mappers
only to the base parent entry, not combined/segment entries. This
prevents mapper calls with partial sizes. Added relevant tests.
2026-01-28 18:35:03 +00:00
Sladyn
3ddddf7a49
Use reportFatalUsageError in llvm-omp-kernel-replay (#178371)
All error cases in this tool are usage errors (bad user input, missing
files, malformed JSON) rather than internal LLVM bugs, so
`reportFatalUsageError` is the appropriate replacement.
2026-01-28 09:12:03 +00:00
Abhinav Gaba
339f779570
Reland "[OpenMP][Mappers] Fix ref-count tracking for maps inserted by mappers. (#177059)" (#177673)
This reverts commit 5a457837dd988aa01c65820848381a5b99a74c0a.

Includes the test fix from
https://github.com/llvm/llvm-project/pull/177659.

The test had to be updated to exclude a scenario that was failing
with/without the change (involving mapping a struct with a byref member
with a mapper).

-----
**Original PR's description:**

This is a fix for https://github.com/llvm/llvm-project/issues/61636.

Ravi had this implemented downstream before he retired. This PR is a
chery-pick of that.

The test is taken from @jdoerfert's WIP change in

527bf4b129.

The change partially undoes the changes done in
0caf736d7e1d16d1059553fc28dbac31f0b9f788, so @alexey-bataev might need
to take a look.
2026-01-27 15:31:16 -08:00
Hansang Bae
4aaf7ed74b
[Offload] Allow specifying debug level with all debug type (#178213)
This change allows users to specify debug level with `all` debug type.
The effect of `all:<num>` is equivalent to `<num>`.
2026-01-27 16:02:14 -06:00
Akash Banerjee
21b0fdf8ec
[Flan][OpenMP] Implement TODO support for compatible defaultmap types for implicit mappers (#177389)
Make implicit default mapper generation respect defaultmap categories so
unrelated defaultmap clauses no longer suppress mappers for derived
types.
Added related tests.
2026-01-27 14:45:40 +00:00
Abhinav Gaba
c366348ed9
[Clang][OpenMP] Codegen for use_device_ptr(fb_nullify). (4/4) (#173931)
Depends on #173930.

The `FB_NULLIFY` map-type bit is set in addition to `RETURN_PARAM`, for
`use_device_ptr(fb_nullify:p)`.
2026-01-23 12:36:54 -08:00
Abhinav Gaba
5a457837dd
Revert "[OpenMP][Mappers] Fix ref-count tracking for maps inserted by mappers. (#177059)" (#177623)
Reverts llvm/llvm-project#177059 and llvm/llvm-project#177491.

The new test may have an issue.
2026-01-23 12:02:44 -08:00
Abhinav Gaba
7d5622f791
[NFC][OpenMP] Mark new mapper test as XFAIL on intelgpu. (#177491)
Other tests in the directory already do this. The new test was added in
#177059.
2026-01-22 15:33:40 -08:00
Abhinav Gaba
a7b57cf7bb
[OpenMP][Mappers] Fix ref-count tracking for maps inserted by mappers. (#177059)
This is a fix for https://github.com/llvm/llvm-project/issues/61636.

Ravi had this implemented downstream before he retired. This PR is a
chery-pick of that.

The test is taken from @jdoerfert's WIP change in

527bf4b129.

The change partially undoes the changes done in
0caf736d7e1d16d1059553fc28dbac31f0b9f788, so @alexey-bataev might need
to take a look.

---------

Co-authored-by: Ravi Narayanaswamy <ravi.narayanaswamy@intel.com>
Co-authored-by: Johannes Doerfert <johannes@jdoerfert.de>
2026-01-22 15:10:00 -08:00
Alex Duran
ba3548c8b2
[OpenMP][Offload] Remove old DP macro (#177156)
Old usages have been updated so we can remove it now
2026-01-21 15:13:13 +01:00
Abid Qadeer
7a74e7fba3
[flang][OpenMP] Fix mapping of constant arrays. (#176763)
The compiler skips mapping of named constants (parameters) to OpenMP
target regions under the assumption that constants don't need to be
mapped. This assumption is not valid when array is accessed inside with
dynamic index. The problem can be seen with the following code:

```
module fir_lowering_check
  implicit none

    integer, parameter :: dp = selected_real_kind(15, 307)
    real(dp), parameter :: arrays(2) = (/ 0.0, 0.0 /)

contains

subroutine test(hold)

        integer, intent(in) :: hold
        integer :: z
        real(dp) :: temp

        !$omp target teams distribute parallel do
            do z = 1, 2
                  temp = arrays(hold)
            end do
        !$omp end target teams distribute parallel do

    end subroutine test
end module fir_lowering_check

program main
  use fir_lowering_check

  implicit none
    integer :: hold
    hold = 1
    call test(hold)
    print *, "Finished"

end program main
```

It fails with the following error
`'hlfir.designate' op using value defined outside the region`

The fix is to allow mapping of constant arrays and map them as `to`.
2026-01-21 13:40:01 +00:00
Abhinav Gaba
aeed73728e
[NFC][OpenMP][Offload] Add tests for use_device_ptr(fb_preserve/nullify). (3/4) (#173930)
Depends on #170578.

The fallback modifiers are currently part of OpenMP 6.1. 4/8 of the
tests check for the current bad output, with FIXME comments.

3 of these "bad" tests will be fixed with the 4th PR in this stack with
the `fb_nullify` codegen changes.

4th bad test will need a follow-up fix to privatization of byref
`use_device_ptr` operands.

Dependent PR: #173931.
2026-01-20 16:23:47 -08:00
Hansang Bae
85d64d1201
[Offload] Cast to void * in the debug message (#177019)
There are a few places where data types based on character array or
string are printed in the debug message while they do not represent
strings. Such expressions should be casted to `void *` unless they
represent actual strings. Change also includes casting from integral
type to pointer type when appropriate.
2026-01-20 15:44:08 -06:00
fineg74
51e2c82023
[OFFLOAD] Add a check before calling dataExchange (#176853)
Per documentation the call to dataExchange API (move memory block
between different devices) is permitted only if isDataExchangable() call
returned true. While almost all platforms support memory transfer
between different devices, in the case when the transfer is attempted
between devices belonging to different platforms if they are present on
the same machine which can lead to unexpected results. This PR adds a
check if dataExchange can be called and if not uses a workaround by
initiating memory transfer through host.
2026-01-20 11:37:35 -08:00
fineg74
848d736e64
[OFFLOAD] Add asynchronous queue query API for libomptarget migration (#172231)
Add liboffload asynchronous queue query API for libomptarget migration

This PR adds liboffload asynchronous queue query API that needed to make
libomptarget to use liboffload
2026-01-20 10:53:32 -08:00
Nick Sarnie
75cc3cd1e8
[offload][lit] XFAIL failing non-contiguous update tests on Intel (#176955)
The new tests added in https://github.com/llvm/llvm-project/pull/169623
are [failing](https://lab.llvm.org/buildbot/#/builders/225/builds/544)
on the Intel GPU runner, so XFAIL them as with the other tests.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2026-01-20 16:39:25 +00:00
Amit Tiwari
ae1ee0d377
[Offload][Tests] Non-contiguous_update_to_tests (#169623)
PR #144635 enabled non-contiguous updates for both `update from` and
`update to` clauses, but tests for `update to` were missing. This PR
adds those missing tests to ensure coverage.
2026-01-20 12:03:39 +05:30
Michael Kruse
f853880300
[Offload][CI] Convert openmp-offload-amdgpu staging bots to ScriptedBuilder (#174991)
Convert the first AMDGPU buildbots to use the ScriptedBuilder introduced
llvm-zorg. For the motivation, see
https://github.com/llvm/llvm-zorg/pull/648.

Since the production buildbot still needs to be restarted for
ScriptedBuilder to work, only convert the builders that are currently in
staging for now. These are:

 * openmp-offload-amdgpu-runtime
 * openmp-offload-amdgpu-clang-flang

Both of them happen to be OpenMPBuilder.getOpenMPCMakeBuildFactory-based
builders before this change. They also set an environment variable that
the previous ScriptedBuilder did not, so we are adding support.

The corresponding llvm-zorg change is
https://github.com/llvm/llvm-zorg/pull/697.
2026-01-17 22:02:23 +01:00
Alex Duran
c70ce1128d
[OpenMP][Offload] Translate Info types to Debug types when debug enabled (#175599)
Eventually we might want to rework the INFO macro to work like the new
ODBG macro but in the meantime at least translate the Info type to the
correct Debug type instead of just using DP directly (which uses the
default type).
2026-01-15 22:44:54 +01:00
Alex Duran
2a9b30d228
[OpenMP][Offload] Add a buffer layer to debug messaging (#176153)
To reduce interference between threads, instead of writing the
components of a debug message directly to the underlying stream, write
them to a buffer and flush the buffer to the stream when its completed.
2026-01-15 22:41:12 +01:00
Hansang Bae
edd857aad8
[Offload] Remove unnecessary maybe_unused attribute (#175855)
The attribute is not necessary in the new debug messaging.
2026-01-15 14:31:58 -06:00
Abhinav Gaba
3a9e3865b5
[OpenMP][Offload] Add FB_NULLIFY map-type for use_device_ptr(fb_nullify). (1/4) (#169603)
Depends on #174659.

This PR adds a new map-type bit to control the fallback behavior when
when a pointer lookup fails.

For now, this is only meaningful with `RETURN_PARAM`, and can be used
for `need_device_ptr` (for which the default is to use `nullptr` as the
result
when lookup fails), and OpenMP 6.1's `use_device_ptr(fb_nullify)`.

Eventually, this can be extended to work with assumed-size maps on
`target`
constructs, to control what the argument should be set to when lookup
fails (the OpenMP spec does not have a way to control that yet).

Dependent PR: #170578.
2026-01-14 14:39:41 -08:00
Hansang Bae
90b6d33755
[Offload] Small debug message fix in Level Zero plugin (#175958)
Do not include trailing zeros in the device name.
2026-01-14 09:42:19 -06:00
Alex Duran
efad3563ea
[OFFLOAD] Update CUDA and AMD plugins to new debug format (#175787) 2026-01-13 17:53:59 +01:00
Alex Duran
86e114a9b2
Revert "[OFFLOAD] Update CUDA and AMD plugins to new debug format" (#175786)
Reverts llvm/llvm-project#175757
2026-01-13 17:13:46 +01:00
Alex Duran
7c2f49373b
[OFFLOAD] Update CUDA and AMD plugins to new debug format (#175757)
This should be the last step before completely removing the DP macro.
2026-01-13 17:06:35 +01:00
Hansang Bae
13cd7003ad
[NFC][Offload] Rename a function (#175673)
Renamed a function as suggested in #175664.
2026-01-12 19:40:17 -06:00
Hansang Bae
496729fe7e
[Offload] Fix level_zero plugin build (#175664)
Build has been broken when OMPTARGET_DEBUG is undefined.
2026-01-12 16:53:23 -06:00
Hansang Bae
dae3b49cba
[Offload] Update debug message printig in the plugins (#175205)
* Prepare a set of debug types in llvm::offload::debug to be used in
plugin code
* Update debug messages in the plugins
2026-01-12 14:26:43 -06:00