Commit Graph
167 Commits
Author SHA1 Message Date
agozillon 42b563ba12 [Flang][OpenMP][Offload] Modify MapInfoFinalization to handle attach mapping and 6.1's ref_* and attach map keywords (#177715)
This PR is one of four required to implement the attach mapping
semantics in Flang, alongside the ref_ptr/ref_ptee/ref_ptr_ptee map
modifiers and the attach(always/never/auto) modifiers.

This PR is the MapInfoFinalization changes required to support these
features, it mainly deals with applying the correct attach map type and
manipulating the descriptor types maps for base address and descriptor
so that when we specify ref_ptr/ref_ptee we emit one of the two maps and
when we emit ref_ptr_ptee we emit our usual default maps. In all cases
we add the "glue" of an new attach map except in cases where a user has
provided attach never. In cases where we are provided an always, we
apply the always map type to our attach maps.

It's important to note the runtime has a toggle for the auto map
behavior, which will flip the attach behavior to the newer semantics or
the older semantics for backwards compatibility (outside the purview of
this PR but good to mention).
2026-05-15 00:07:41 +00:00
David Pagan 9a3193b1a0 [clang][OpenMP 6.0][CodeGen] Codegen for declare_target 'local' clause (#196431)
Implement code generation for the OpenMP 6.0 declare_target 'local'
clause, which creates device-only variables with per-device static
storage.

A 'local' variable exists in the device image with its static
initializer and is always accessed directly by device code. This is the
same as 'to'/'enter' without unified shared memory, except that no
offload entry is registered.

Using 'device_type(nohost)' with 'local' is not yet supported. Sema
generates a warning and converts it to 'device_type(any)'.

Testing:
- Updated tests:
     clang/test/OpenMP/declare_target_messages.cpp
     clang/test/OpenMP/declare_target_ast_print.cpp
- New tests:
     clang/test/OpenMP/declare_target_local_codegen.cpp
     clang/test/OpenMP/declare_target_local_usm_codegen.cpp
     offload/test/offloading/declare_target_local.cpp
2026-05-11 06:18:44 -07:00
Robert Imschweiler a7b6c02a4e [OpenMP][offload] Add enhanced cross-team reduction test (#195940)
Tests different patterns of OpenMP cross-team reductions, for multiple
data types.
If run with `LIBOMPTARGET_INFO=16`, shows current register spilling due
to dispatch jump chains (which grow for every reduction in the same
translation unit) for indirect function calls in the reduction runtime.
2026-05-06 17:23:35 +02:00
agozillonand@chichunchen 42c326725d [Flang][OpenMP] Fix assert trigger in MapInfoFinalization pass for implicit record member maps (#193851)
The current iteration of the implicit record member mapping segment of
the MapInfoFinalization pass makes the assumption that child maps of
parents are already bound to the targets block arguments, but that is
not the case apon initial lowering from PFT to MLIR. This actually
happens as the end of the MapInfoFinalization pass currently where we
"canonicalize" that all maps are inserted as Block arguments to their
respective targets.

This assumption unfortunately leads to a few cases where we trigger the
assertion, to address this we can impose this canonicalization of map
<-> block arguments as soon as we enter the pass and then once again at
the end of the pass for any new members generated by the
MapInfoFinalization pass. This allows the implicit record member mapping
process to continue unhindered whilst changing very little elsewhere
other than the ordering of block arguments (hence some lit tests
tweaks). The main downside is the extra processing required for running
the "canonialization" twice.

I adopted some tests created by @chichunchen in his version of the fix
to help test for regressions.

Co-authored-by: @chichunchen
2026-05-05 18:41:09 +02:00
Abid Qadeer f3f0830e44 [offload] Update test after ed07c92c96. (#195822)
We now get `a(:n) at dump_map_tables.f90:20:11` so test has been updated
accordingly. This should fix the regression seen after
https://github.com/llvm/llvm-project/pull/195346.
2026-05-05 11:26:20 +01:00
Alex Duran 5e7e097888 [offload] Enable Intel GPU tests and mark CUDA tests unsupported (#194790)
- Remove UNSUPPORTED: intelgpu from 12 passing tests:
  * mapping/data_member_ref.cpp
  * offloading/bug50022.cpp, info.c
* offloading/target_critical_region.cpp, target_depend_nowait.cpp,
target_nowait_target.cpp
  * offloading/strided_update/* (6 tests)
  * unified_shared_memory/close_member.c

- Change CUDA tests from XFAIL to UNSUPPORTED for Intel GPU:
  * offloading/CUDA/basic_launch.cu
  * offloading/CUDA/basic_launch_blocks_and_threads.cu
  * offloading/CUDA/basic_launch_multi_arg.cu
  * offloading/CUDA/launch_tu.cu

- Add Intel GPU configuration section to lit.cfg to disable USM tests by
default
2026-04-29 15:14:20 +02:00
Jan Patrick Lehr ee8ca6b33e Revert "[Flang][OpenMP] Clear close on descriptor members for box parents in USM" (#194568)
Reverts llvm/llvm-project#194287

Buildbot errors in https://lab.llvm.org/buildbot/#/builders/67/builds/3464
local revert fixed the issues.
2026-04-28 11:17:46 +02:00
Kareem ErgawyandComposer 1cb85dd460 [Flang][OpenMP] Clear close on descriptor members for box parents in USM (#194287)
Extend the MapInfoFinalization walk introduced in #185330 so
parent/member close consistency is enforced whenever
unified_shared_memory is in effect, not only when the parent map's
variable is a fir.RecordType. Allocatable (box) roots expand to member
maps the same way as derived-type instances; getDescriptorMapType may
add OMP_MAP_CLOSE to implicit descriptor members while the parent map
does not set close, which led to bad device behavior under
-fopenmp-force-usm with multiple mapped allocatables.

PR stack:
- https://github.com/llvm/llvm-project/pull/194287 (this one)
- https://github.com/llvm/llvm-project/pull/194291

Co-authored-by: Composer (Cursor) <ai@cursor.com>
2026-04-28 05:58:47 +02:00
Kevin Sala Penades 98fe008141 [offload] Un-XFAIL interop-print.c test for nvidia (#194447) 2026-04-27 13:03:10 -07:00
Nick Sarnie 5e451509b6 [offload][lit] Enable ctor_dtor.cpp on Intel GPUs (#194389)
It was fixed with https://github.com/llvm/llvm-project/pull/192725 and
https://github.com/llvm/llvm-project/pull/192730.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-04-27 14:50:52 +00:00
Sergio Afonso fad06a418b [MLIR][OpenMP][OMPIRBuilder] Improve shared memory checks (#161864)
This patch refines checks to decide whether to use device shared memory
or regular stack allocations. In particular, it adds support for
parallel regions residing on standalone target device functions.

The changes are:
- Shared memory is introduced for `omp.target` implicit allocations,
such as those related to privatization and mapping, as long as they are
shared across threads in a nested parallel region.
- Standalone target device functions are interpreted as being part of a
Generic kernel, since the fact that they are present in the module after
filtering means they must be reachable from a target region.
- Prevent allocations whose only shared uses inside of an `omp.parallel`
region are as part of a `private` clause from being moved to device
shared memory.
2026-04-27 13:15:05 +01:00
Sergio Afonso 333f636c9a [OpenMPOpt] Make parallel regions reachable from new DeviceRTL loop functions (#150927)
This patch updates the OpenMP optimization pass to know about the new
DeviceRTL functions for loop constructs.

This change marks these functions as potentially containing parallel
regions, which fixes a current bug with the state machine rewrite
optimization. It previously failed to identify parallel regions located
inside of the callbacks passed to these new DeviceRTL functions, causing
the resulting code to skip executing these parallel regions.

As a result, Generic kernels produced by Flang that contain parallel
regions now work properly.

One known related issue not fixed by this patch is that the presence of
calls to these functions will prevent the SPMD-ization of Generic
kernels by OpenMPOpt. Previously, this was due to assuming there was no
parallel region. This is changed by this patch, but instead we now mark
it temporarily as unsupported in an SPMD context. The reason is that,
without additional changes, code intended for the main thread of the
team located outside of the parallel region would not be guarded
properly, resulting in race conditions and generally invalid behavior.
2026-04-27 13:11:17 +01:00
Alex Duran 7039515e0c [OpenMP] Fix convention of SPIRV outline functions (#192450)
When creating an outline function for device code we're not setting the
right calling convention when the target is SPIRV. This results in the
calls to the function to be removed by the InstCombine pass as it thinks
is not callable.
2026-04-16 22:10:15 +02:00
Alex Duran 14ee89214c [OFFLOAD] Fix interop-print test commands (#191969)
Using %libomptarget-run-generic will fail or run an incorrect binary if
the previous %libomptarget-compile becames ignored because there's no
such device. Switching to use %libomptarget-compile-and-run-* which
doesn't have this issue.

Fixes post-merge issue of #191901
2026-04-14 15:26:20 +02:00
Alex Duran 654da0889b [OFFLOAD][OpenMP][L0] Add Intel strings to interop-print test (#191901) 2026-04-14 00:27:33 +02:00
Alex Duran e0adc50e64 [OFFLOAD][L0] Handle group sizes correctly for multidimensional bare kernels (#191770)
Don't use the L0 heuristics if all the dimensions are specified by the
user code.
2026-04-13 15:37:47 +00:00
Amit Tiwari 7459e10f34 [OpenMP][NFC] Refactor Non-contiguous Update Tests (#190923)
The PR refactors the non-contiguous update tests as raised as a TODO in
one of the comments in the related PR. Prefixed all with
`strided_update`. For offload tests, added a dedicated sub-directory.
2026-04-10 11:43:12 +05:30
Kareem ErgawyandClaude ff071d6165 [flang][DoConcurrent] Map reduction variables as tofrom ByRef for device offloading (#189378)
Scalar reduction variables in `do concurrent reduce(...)` were being
mapped with `implicit ByCopy` when offloaded to device, because
`genMapInfoOpForLiveIn` treated all trivial types uniformly. This caused
the reduction result to be silently dropped — the device-side reduction
would compute the correct value but never write it back to the host.

Fix by detecting reduction variables and forcing `implicit tofrom ByRef`
mapping, matching the behavior of explicit
`!$omp target teams distribute parallel do reduction(...)`.

Co-authored-by: ergawy <kareem.ergawy@amd.com>
Co-authored-by: Claude <noreply@anthropic.com>
Made-with: Cursor

Fixes: https://github.com/ROCm/llvm-project/issues/1844

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-08 07:54:00 +02:00
Nick Sarnie 899a78cbc4 [offload][lit] Disable target_critical_region.cpp on Intel GPU (#189682)
Already disabled on other GPU platforms and sporadically failing on our
builder, so this test seems not be doing too hot.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-03-31 18:54:17 +00:00
Nick Sarnie 38a46a12c4 [offload][lit] Disable tests failing on Intel GPU (#189422)
Fix some tests causing hangs, one fail, and a few XPASSing. We are
seeing new passes/fails because of the named barrier changes being
merged.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-03-30 18:02:34 +00:00
fineg74 563d3f6865 [OFFLOAD] Disable tests that may cause hangs in CI (#189116) 2026-03-27 21:32:25 +00: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
Nick Sarnie 1aefe3b111 [offload][L0] Remove XFAIL from XPASSING test strided_offset_multidim_update.c (#188836)
Passing now I guess

https://lab.llvm.org/buildbot/#/builders/225/builds/4729

```
********************
Unexpectedly Passed Tests (1):
  libomptarget :: spirv64-intel :: offloading/strided_offset_multidim_update.c
```

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-03-26 21:06:22 +00:00
Ivan R. Ivanov 19420c0e77 [OpenMP] Fix non-contiguous array omp target update (#156889)
The existing implementation has three issues which this patch addresses.

1. The last dimension which represents the bytes in the type, has the
wrong stride and count. For example, for a 4 byte int, count=1 and
stride=4. The correct representation here is count=4 and stride=1
because there are 4 bytes (count=4) that we need to copy and we do not
skip any bytes (stride=1).

2. The size of the data copy was computed using the last dimension.
However, this is incorrect in cases where some of the final dimensions
get merged into one. In this case we need to take the combined size of
the merged dimensions, which is (Count * Stride) of the first merged
dimension.

3. The Offset into a dimension was computed as a multiple of its Stride.
However, this Stride which is in bytes, already includes the stride
multiplier given by the user. This means that when the user specified
1:3:2, i.e. elements 1, 3, 5, the runtime incorrectly copied elements 2,
4, 6. Fix this by precomputing at compile time the Offset to be in bytes
by correctly multiplying the offset by the stride of the dimension
without the user-specified multiplier.
2026-03-26 15:55:31 +01:00
Robert Imschweiler bc6a265e3b [offload] Use flang-rt for test feature requirements (#187733) 2026-03-20 18:59:06 +01:00
fineg74andDuran, Alex 2890f9883c [OFFLOAD] Improve handling of synchronization errors in L0 plugin and reenable tests (#186927)
This change improves handling of errors during synchronization in Level
Zero plugin by ensuring cleanup of queues and events in case of an
synchronization error. As a result multiple tests stopped hanging.

---------

Co-authored-by: Duran, Alex <alejandro.duran@intel.com>
2026-03-18 05:50:06 +01:00
Nick Sarnie 1beec14434 [offload][lit] XFAIL new tests failing on intelgpu (#185908)
New tests from https://github.com/llvm/llvm-project/pull/176708 and
https://github.com/llvm/llvm-project/pull/181987 fail on `intelgpu`, I
updated the [GH
issue](https://github.com/llvm/llvm-project/issues/182897).

Example fails
[here](https://lab.llvm.org/buildbot/#/builders/225/builds/3441).

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-03-12 14:37:56 +00:00
Kevin Sala PenadesandKrzysztof Parzyszek 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
Amit Tiwari a15dcd4117 [Clang][OpenMP] Handled NonContig Descriptor DimCount (#181987)
### Issue: Dimension override missing
When variable count expressions were used with stride, the constant
subsection path computed size first. This marked `ArgSizes` with byte
size semantics. Variable expression logic later triggered, but reused
`ArgSizes` assuming "bytes" semantics

`OMPIRBuilder.cpp` didn't handle dimension count for
`OMP_MAP_NON_CONTIG` flag

**Result**: `ArgSizes` wasn't overwritten with dimension count, breaking
non-contiguous mapping.

**Fixes**:

`llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp` - Expression semantics for
non-contiguous.
 stride/count.
Generate 3D descriptor structures with runtime dimensions.
Fix dimension override to use dimension count instead of byte size.

Added testcases to cover stack arrays, heap pointers, struct members,
etc.
2026-03-11 19:39:55 +05:30
Amit Tiwari 14de1bb711 [Clang][OpenMP] Support expression semantics in target update fields with non-contiguous array sections (#176708)
### Issue: Variable stride not recognized as non-contiguous
`CGOpenMPRuntime.cpp` failed to detect `DeclRefExpr`, `MemberExpr`,
`ArraySubscriptExpr` as non-contiguous.

**Fixes**:

`clang/lib/CodeGen/CGOpenMPRuntime.cpp` - Variable stride detection +
dimension count logic
Detect variable stride expressions
(`DeclRefExpr/MemberExpr/ArraySubscriptExpr`) as non-contiguous

Added testcases to cover stack arrays, heap pointers, struct members,
etc., for expression semantics in non-contiguous update.
2026-03-10 19:26:17 +05:30
Kareem Ergawy 0bf9bb5c42 [Flang][OpenMP] Fix close map flag propagation for derived types in USM (#185330)
This fixes a bug in USM mode where the `close` map type modifer was
attached to some `map.info.op`'s corresponding to user-defined type
members while the parent type instance itself is not marked as `close`.

This fix ensures that if a parent record type map does not have the
'close' flag, it is cleared from its members as well, maintaining
consistency.

Gemini was used to create tests. AI generated test code was reviewed
line-by-line by me. Which were derived from a reproducer I was working
with to debug the issue.

Assisted-by: Gemini <gemini@google.com>
2026-03-09 15:55:53 +01:00
Krish Gupta 148b10be8a [flang][OpenMP] Support custom mappers in target update to/from clauses (#169673)
Implement support for the OpenMP `mapper` modifier on `target update` `to` and
`from` clauses in Flang.

Semantic name resolution is extended to bind the mapper symbol for
`OmpClause::To` and `OmpClause::From` via a shared `ResolveMapperModifier`
helper. Lowering is extended in `ClauseProcessor` with a `getMapperIdentifier`
template helper to extract the mapper name for both `map` and `target update`
clauses and forward it to `omp.map_info`.

Fixes #168701.

Reviewed By: TIFitis, kparzysz
Assited By: Copilot( For review and articulations of messages)
2026-03-02 21:59:56 +05:30
Joseph Huber c49460bae7 [flang-rt] Enable more runtime functions for the GPU target (#183649)
Summary:
This enables primarily `stop.cpp` and `descriptor.cpp`. Requires a
little bit of wrangling to get it to compile. Unlike the CUDA build,
this build uses an in-tree libc++ configured for the GPU. This is
configured without thread support, environment, or filesystem, and it is
not POSIX at all. So, no mutexes, pthreads, or get/setenv.

I tested stop, but i don't know if it's actually legal to exit from
OpenMP offloading.
2026-02-27 12:27:39 -06:00
Nick Sarnie 600919ac32 [Offload][clang-linker-wrapper][SPIRV] Tell spirv-link to not optimize out exported symbols (#182930)
`spirv-link` seems to internalize all symbols, which ends up causing the
OpenMP Device Environment global generated by the OMP FE to get
optimized out which causes `liboffload` to run in the wrong
parallelization mode which breaks at least one liboffload lit test.

Pass `--create-library` to tell it not to do that.

```
  --create-library
               Link the binaries into a library, keeping all exported symbols.
```

This fixes the test.

Closes: https://github.com/llvm/llvm-project/issues/182901

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-24 15:10:59 +00:00
Joseph Huber 70b5a1d050 [flang-rt] Add support for formatted I/O on the GPU (#182580)
Summary:
Expands on the previous support to enable formatted output, characters,
and checking basic iostat. We intentionally do not handle cases where
the descriptor is non-null as this is a non-trivial class that cannot
easily be shepherded across the wire.
2026-02-20 14:43:06 -06:00
Joseph Huber 21b3461440 [flang-rt] Implement basic support for I/O from OpenMP GPU Offloading (#181039)
Summary:
This PR provides the minimal support for Fortran I/O coming from a GPU
in OpenMP offloading. We use the same support the `libc` uses for its
printing through the RPC server. The helper functions `rpc::dispatch`
and `rpc::invoke` help make this mostly automatic.

Becaus Fortran I/O is not reentrant, the vast majority of complexity
comes from needing to stitch together calls from the GPU until they can
be executed all at once. This is needed not only because of the
limitations of recursive I/O, but without this the output would all be
interleaved because of the GPU's lock-step execution.

As such, the return values from the intermediate functions are
meaningless, all returning true. The final value is correct however. For
cookies we create a context pointer on the server to chain these
together.

Works on both my AMD and NVIDIA GPUs.
```fortran
program hello_gpu
  implicit none

  !$omp target teams num_teams(1)
  !$omp parallel num_threads(2)
    ! Print strings
    print *, "Hello from GPU"
  !$omp end parallel
  !$omp end target teams

end program hello_gpu
```
```console
> flang hello.f90 -O2 -fopenmp --offload-arch=gfx1030 
> ./a.out 
 Hello from GPU
 Hello from GPU
> flang hello.f90 -O2 -fopenmp --offload-arch=sm_89  
> ./a.out 
 Hello from GPU
 Hello from GPU
```
2026-02-20 07:56:59 -06:00
Nick Sarnie 78ff5b55fd [offload][lit] Enable/disable tests on Level Zero when using DeviceRTL (#182128)
Since we can now build the DeviceRTL with SPIR-V, redo the
`XFAIL/UNSUPPORTED` specifications for the tests we see passing/failing
on the Level Zero backend with the DeviceRTL being used.

The tests marked `UNSUPPORTED` hang or sporadically fail and those are
tracked in https://github.com/llvm/llvm-project/issues/182119.

This change will allow us to enable CI testing with the DeviceRTL.

Here are the full test results with this change applied, running only
the `spirv64-intel` `check-offload` tests:

```
Total Discovered Tests: 453
  Unsupported      : 206 (45.47%)
  Passed           : 141 (31.13%)
  Expectedly Failed: 106 (23.40%)
```

31% is not a bad start.

---------

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-18 21:53:19 +00:00
Robert Imschweiler 33e3384aa8 [offload] Adapt tests to new PluginInterface quoting [NFC] (#180505)
https://github.com/llvm/llvm-project/commit/4096cb60175a3bfdde25dd0cca167416f4f4338e
removed the quotes around PluginInterface
2026-02-09 07:47:04 -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
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
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
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
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
Jan Patrick Lehr 4a8a0593bd [Offload] Fix failing Fortran test w/ line number (#175247)
This test also depends on the line number. Following similar approach as
other with [[@LINE]] macro.
2026-01-09 21:12:28 +00:00
Joseph Huber c722ef4874 [OpenMP] Remove testing LTO variant on CPU targets (#175187)
Summary:
This is only really meaningful for the NVPTX target. Not all build
environments support host LTO and these are redundant tests, just clean
this up and make it run faster.
2026-01-09 10:13:44 -06:00
Kareem Ergawy e82399dac2 [flang][OpenMP] Prevent omp.map.info ops with user-defined mappers from being marked as parial maps (#175133)
The following test was triggering a runtime crash **on the host before
launching the kernel**:
```fortran
program test_omp_target_map_bug_v5
  implicit none
  type nested_type
    real, allocatable :: alloc_field(:)
  end type nested_type

  type nesting_type
    integer :: int_field
    type(nested_type) :: derived_field
  end type nesting_type

  type(nesting_type) :: config

  allocate(config%derived_field%alloc_field(1))

  !$OMP TARGET ENTER DATA MAP(TO:config, config%derived_field%alloc_field)

  !$OMP TARGET
  config%derived_field%alloc_field(1) = 1.0
  !$OMP END TARGET

  deallocate(config%derived_field%alloc_field)
end program test_omp_target_map_bug_v5
```

In particular, the runtime was producing a segmentation fault when the
test is compiled with any optimization level > 0; if you compile with
-O0 the sample ran fine.

After debugging the runtime, it turned out the crash was happening at
the point where the runtime calls the default mapper emitted by the
compiler for `nesting_type; in particular at this point in the runtime:
https://github.com/llvm/llvm-project/blob/c62cd2877cc25a0d708ad22a70c2a57590449c4d/offload/libomptarget/omptarget.cpp#L307.

Bisecting the optimization pipeline using `-mllvm -opt-bisect-limit=N`,
the first pass that triggered the issue on `O1` was the `instcombine`
pass. Debugging this further, the issue narrows down to canonicalizing
`getelementptr` instructions from using struct types (in this case the
`nesting_type` in the sample above) to using addressing bytes (`i8`). In
particular, in `O0`, you would see something like this:
```llvm
define internal void @.omp_mapper._QQFnesting_type_omp_default_mapper(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5) #6 {
entry:
  %6 = udiv exact i64 %3, 56
  %7 = getelementptr %_QFTnesting_type, ptr %2, i64 %6
  ....
}
```

```llvm
define internal void @.omp_mapper._QQFnesting_type_omp_default_mapper(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5) #6 {
entry:
  %6 = getelementptr i8, ptr %2, i64 %3
  ....
}
```

The `udiv exact` instruction emitted by the OMP IR Builder (see:
https://github.com/llvm/llvm-project/blob/c62cd2877cc25a0d708ad22a70c2a57590449c4d/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp#L9154)
allows `instcombine` to assume that `%3` is divisible by the struct size
(here `56`) and, therefore, replaces the result of the division with
direct GEP on `i8` rather than the struct type.

However, the runtime was calling
`@.omp_mapper._QQFnesting_type_omp_default_mapper` not with `56` (the
proper struct size) but with `48`!

Debugging this further, I found that the size of `omp.map.info`
operation to which the default mapper is attached computes the value of
`48` because we set the map to partial (see:
https://github.com/llvm/llvm-project/blob/c62cd2877cc25a0d708ad22a70c2a57590449c4d/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp#L1146
and
https://github.com/llvm/llvm-project/blob/c62cd2877cc25a0d708ad22a70c2a57590449c4d/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp#L4501-L4512).

However, I think this is incorrect since the emitted mapper (and
user-defined mappers in general) are defined on the whole struct type
and should never be marked as partial. Hence, the fix in this PR.
2026-01-09 15:15:10 +01:00
Jan Patrick Lehr 13fb3f3b19 [Offload] Fix line numbers after #174804 (#174932)
The changes in line numbers caused a few CHECK macros to now fail. This
is fixed by this PR.

Build w/ breakages:
https://lab.llvm.org/staging/#/builders/105/builds/39748
2026-01-08 12:08:45 +01:00
Nick Sarnie 26b777444b [offload][lit] XFAIL all failing tests on the Level Zero plugin (#174804)
We finally got our buildbot added (to staging, at least) so we want to
start running L0 tests in CI.
We need `check-offload` to pass though, so XFAIL everything failing.
There's a couple `UNSUPPORTED` as well, those are for sporadic fails.

Also make set the `gpu` and `intelgpu` LIT variables when testing the
`spirv64-intel` triple.

We have no DeviceRTL yet so basically everything fails, but we manage to
get

```
Total Discovered Tests: 432
Unsupported      : 169 (39.12%)
Passed           :  67 (15.51%)
Expectedly Failed: 196 (45.37%)
```

We still don't build the level zero plugin by default and these tests
don't run unless the plugin was built, so this has no effect on most
builds.

---------

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-01-07 19:20:30 +00:00
Nick Sarnie 08a43f854c [offload][lit] Use '%not' instead of 'not' in requires.c (#174506)
Typo exposed by recent `not` behavior change, we need to make sure we're
using the LLVM one.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-01-05 23:31:15 +00:00