2657 Commits

Author SHA1 Message Date
Samuel Parker
2a58be4239 [HardwareLoops] NewPM support.
With the NPM, we're now defaulting to preserving LCSSA, so a couple
of tests have changed slightly.

Differential Revision: https://reviews.llvm.org/D140982
2023-02-13 09:46:31 +00:00
Martin Storsjö
89197b59f5 [openmp] Fix building z_Linux_asm.S for armv5t
Don't use the ldrd instruction; that one requires armv5te. Instead
do two separate loads (or only one if OMPT_SUPPORT isn't defined).

This should fix https://github.com/llvm/llvm-project/issues/60370.

Differential Revision: https://reviews.llvm.org/D143683
2023-02-11 00:03:13 +02:00
Terry Wilmarth
8d689e5bfd Fix initialization of th_task_state on each thread on expanding hot teams.
The th_task_state was initialized from the master thread's value, or
from its memo stack, but this causes problems because neither of those
may have the right value at the right time. However, other threads in
the team are guaranteed to have the right values, so we change the
initialize the new threads' th_task_state from the th_task_state of
the last of the older threads in the hot team.

Differential Revision: https://reviews.llvm.org/D142247
Fix #56307.
2023-02-08 17:36:14 -06:00
Jonathan Peyton
4ce32d2f12 [OpenMP][libomp] Remove false positive for memory sanitizer
The memory sanitizer intercepts the memcpy() call but not the direct
assignment of last byte to 0. This leads the sanitizer to believe the
last byte of a string based on the kmp_str_buf_t type is uninitialized.
Hence, the eventual strlen() inside __kmp_env_dump() leads to an
use-of-uninitialized-value warning.

Using strncat() instead gives the sanitizer the information it needs.

Differential Revision: https://reviews.llvm.org/D143401

Fixes #60501
2023-02-07 10:00:34 -06:00
Archibald Elliott
62c7f035b4 [NFC][TargetParser] Remove llvm/ADT/Triple.h
I also ran `git clang-format` to get the headers in the right order for
the new location, which has changed the order of other headers in two
files.
2023-02-07 12:39:46 +00:00
Ron Lieberman
c55d6f169b Revert "[OpenMP][libomp] Remove false positive for memory sanitizer"
breaks amdgpu buildbot

This reverts commit 402981ee25fe135d63226a7de17dbb14c437c71b.
2023-02-06 13:16:37 -06:00
Jonathan Peyton
402981ee25 [OpenMP][libomp] Remove false positive for memory sanitizer
The memory sanitizer intercepts the memcpy() call but not the direct
assignment of last byte to 0. This leads the sanitizer to believe the
last byte of a string based on the kmp_str_buf_t type is uninitialized.
Hence, the eventual strlen() inside __kmp_env_dump() leads to an
use-of-uninitialized-value warning.

Using strncat() instead gives the sanitizer the information it needs.

Differential Revision: https://reviews.llvm.org/D143401

Fixes #60501
2023-02-06 09:30:21 -06:00
Kevin Sala
230d976853 [NFC][OpenMP][libomptarget] Fix format in PluginInterface header 2023-02-06 10:15:50 +01:00
Kevin Sala
6ca034644d [OpenMP][libomptarget] Notify the plugins regarding new mapping/unmappings
The NextGen plugins use the information regarding new mapping/unmappings to
lock/unlock the corresponding host buffer and speed up the host-device memory
transfers involving those buffers. The locking/unlocking is disabled by default
and can be enabled by the LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS envar. The
envar accepts boolean values (on/off) and a special option:
  - off:       Do not lock mapped host buffers (default).
  - on:        Lock mapped host buffers automatically, but do not report lock
               failures if the plugin fails to lock them.
  - mandatory: Lock mapped host buffers automatically and treat locking failures
               in the plugins as fatal errors. This option may be useful for
               debugging purposes.

Differential Revision: https://reviews.llvm.org/D142514
2023-02-06 10:09:35 +01:00
Samuel Thibault
cc72df2b7b [Libomptarget] Add the same to the other AMD plugin
Summary:
The previous patch also needed to apply this to the other AMDGPU plugin,
this will be removed soon but it should be correct while it's here at
least.
2023-02-04 07:46:25 -06:00
Samuel Thibault
71fb11ff34 [Libomptarget] Fix disabling amdgpu on non-Linux.
Previously, on non-Linux, amdgpu would get enabled whatever the CPU architecture.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D143017
2023-02-04 07:45:03 -06:00
Jonathan Peyton
c32022ad26 [OpenMP][libomp] Fix CMake version symbol testing
Do not check for version symbol support if the necessary linker flag is
not supported.

Differential Revision: https://reviews.llvm.org/D143200
2023-02-03 10:52:34 -06:00
Johannes Doerfert
434992c96e [OpenMP][FIX] Do not overalign mapped structures
While we potentially need to align partially mapped structs more than
the first member, we do not need to align past the struct itself. This
prevents us from moving the base pointer past the struct beginning too.

See https://reviews.llvm.org/D142508 for a discussion.

Reviewed By: pavelkopyl, grokos, jhuber6

Differential Revision: https://reviews.llvm.org/D142586
2023-02-03 07:57:16 -06:00
Shilei Tian
2d6adb366e [OpenMP] Guard the code if ITT is not used
`check_loc` is not used if ITT is disabled or debug is off, causing a
compiler warning.

Reviewed By: jlpeyton

Differential Revision: https://reviews.llvm.org/D143004
2023-02-02 22:54:34 -05:00
Joseph Huber
70ff191900 [Libomptarget] Add new enum to the dynamically opened HSA implementation
Summary:
We added a new agent information enum in a previous commit. This was not
added to the dynamic HSA implementation so it failed to compile without
a local HSA install to use.
2023-02-02 15:15:09 -06:00
Joseph Huber
6dd84983d0 [Libomptarget] Improve next-gen AMDGPU plugin error messages
The next-gen plugin properly prints errors. This patch improves the
error messages by including the Node-ID of the GPU that failed as well
as a textual representation of the enumeration values.

Reviewed By: kevinsala

Differential Revision: https://reviews.llvm.org/D143192
2023-02-02 12:55:53 -06:00
Joseph Huber
48560e264c [Libomptarget] Fix the NVPTX Libomptarget test
Summary:
This was broken, we weren't adding these for the NVPTX tests.
2023-02-02 09:46:10 -06:00
Joseph Huber
1bde4ccae6 [Libomptarget] Fix building AMDGPU tests
Summary:
Accidentally deleted this.
2023-01-30 17:56:48 -06:00
Shilei Tian
516ae48170 [OpenMP][NVPTX] Guard the target name macro definition 2023-01-30 14:02:22 -05:00
Joseph Huber
292eca41d9 [Libomptarget] Fix tests after previous patch
Summary:
The previous patch didn't remove these tests correctly.
2023-01-30 07:18:51 -06:00
Joseph Huber
9b1d0ee10c [Libomptarget] Remove unused test targets in libomptaget
Summary:
These don't need to be set.
2023-01-30 06:34:15 -06:00
Shilei Tian
ad95b0e977 [OpenMP][NVPTX] Added __tgt_rtl_launch_kernel in old CUDA plugin
Fix #60248.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D142819
2023-01-28 18:56:07 -05:00
Shilei Tian
544f8c7f39 [OpenMP] Fix stack overflow for test bug54082.c
When `N` is 1024, `int result[N][N]` is obviously large stack that Windows cannot support...

Fix #60326.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142684
2023-01-26 23:45:11 -05:00
Joachim Protze
488d17154b Re-apply "[OpenMP][Archer] Use dlsym rather than weak symbols for TSan annotations"
Explicitly link libdl this time.

Differential Revision: https://reviews.llvm.org/D142378
2023-01-26 15:32:23 +01:00
Joseph Huber
21b1d55c04 [Libomptarget] Add correct relative path for the nexgen plugin
Summary:
I forgot that this file "borrowed" the source from the other file tree.
Fix that.
2023-01-25 14:05:53 -06:00
Joseph Huber
84d0243d21 [Libomptarget] Clean up CUDA plugin CMake files
Clean up this file after changing it in D142568.

Depends on D142568

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142573
2023-01-25 13:58:02 -06:00
Joseph Huber
c568622046 [Libomptarget] Remove find_package(CUDA) as it has been deprecated
Since D137724 and the LLVM 17 release we have updated to CMake version
3.20. This means that `find_package(CUDA)` is officially deprecated and
can be replaced with `find_package(CUDAToolkit)` instead. This patch
does this and also cleans up a bit of the CMake.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142568
2023-01-25 13:58:01 -06:00
Tom Stellard
603c286334 Bump the trunk major version to 17 2023-01-24 22:57:27 -08:00
Shilei Tian
5ba8ecb6cc [Clang][OpenMP] Find the type omp_allocator_handle_t from identifier table
In Clang, in order to determine the type of `omp_allocator_handle_t`, Clang
checks the type of those predefined allocators. The first one it checks is
`omp_null_allocator`. If the language is C, and the system is 64-bit, what Clang
gets is a `int`, instead of an enum of size 8, given the fact how we define
`omp_allocator_handle_t` in `omp.h`.  If the allocator is captured by a region,
let's say a parallel region, the allocator will be privatized. Because Clang deems
`omp_allocator_handle_t` as an `int`, it will first cast the value returned by
the runtime library (for `libomp` it is a `void *`) to `int`, and then in the
outlined function, it casts back to `omp_allocator_handle_t`. This two casts
completely shaves the first 32-bit of the pointer value returned from `libomp`,
and when the private "new" pointer is fed to another runtime function
`__kmpc_allocate()`, it causes segment fault. That is the root cause of PR54082.
I have no idea why `-fno-pic` could hide this bug.

In this patch, we detect `omp_allocator_handle_t` using roughly the same method
as `omp_event_handle_t`, by looking it up into the identifier table.

Fix #54082.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D142297
2023-01-24 22:49:05 -05:00
Shilei Tian
dafebd5b5a [OpenMP] Create a temp file in /tmp if /dev/shm is not accessible
When `libomp` is initialized, it creates a temp file in `/dev/shm` to store
registration flag. Some systems, like Android, don't have `/dev/shm`, then this
feature is disabled by the macro `KMP_USE_SHM`, though most Linux distributions
have that. However, some customized distribution, such as the one reported in
https://github.com/llvm/llvm-project/issues/53955, doesn't support it either.
It causes a core dump. In this patch, if it is the case, we will try to create a
temporary file in `/tmp`, and if it still doesn't make it, then we error out.
Note that we don't consider in this patch if the temporary directory has been
set to `TMPDIR` in this patch. If `/tmp` is not accessible, we error out.

Fix #53955.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142175
2023-01-24 21:45:38 -05:00
Kevin Sala
2a539ee17d [OpenMP][libomptarget] Implement memory lock/unlock API in NextGen plugins
This patch implements the memory lock/unlock API, introduced in patch https://reviews.llvm.org/D139208,
in the NextGen plugins. Locked buffers feature reference counting and we allow certain overlapping. Given
an already locked buffer A, other buffers that are fully contained inside A can be locked again, even if
they are smaller than A. In this case, the reference count of locked buffer A will be incremented. However,
extending an existing locked buffer is not allowed. The original buffer is actually unlocked once all its
users have released the locked buffer and sub-buffers (i.e., the reference counter becomes zero).

Differential Revision: https://reviews.llvm.org/D141227
2023-01-25 00:11:38 +01:00
Joseph Huber
5d1dc9fa04 [OpenMP] Do not link the bitcode OpenMP runtime when targeting AMDGPU.
The AMDGPU target can only emit LLVM-IR, so we can always rely on LTO to
link the static version of the runtime optimally. Using the static
library only has a few advantages. Namely, it avoids several known bugs
and allows us to optimize out more functions. This is legal since the
changes in D142486 and D142484

Depends on D142486 D142484

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142491
2023-01-24 17:01:37 -06:00
Giorgis Georgakoudis
4b88bf5c70 [OpenMP][docs] Update for record-and-replay
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142492
2023-01-24 14:36:37 -08:00
Shilei Tian
7e89420116 [OpenMP] Disable tests that are not supported by GCC if it is used for testing
GCC doesn't support `-fopenmp-version`, causing test failure if the compiler used
for testing is GCC.

GCC's OpenMP 5.2 support is very limited yet. Disable those tests requiring 5.2
feature for GCC as well.

We might want to take a look at all `libomp` tests and mark those tests that
don't support GCC yet.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D142173
2023-01-24 17:00:15 -05:00
Johannes Doerfert
62bc222875 [OpenMP][NFC] Augment release notes 2023-01-24 13:23:15 -08:00
Kevin Sala
9dea83d4af [OpenMP][Doc] Update release notes with NextGen plugins 2023-01-24 22:15:49 +01:00
Guilherme Valarini
7cf63ee80c [OpenMP][Docs] Add non-blocking target nowait environment variables 2023-01-24 16:30:34 -03:00
Shilei Tian
31c95e5a4d [OpenMP][Doc] Update release note for 16 release 2023-01-24 14:04:28 -05:00
Joseph Huber
c9c5a076b3 [OpenMP][Docs] Add some release notes for OpenMP 2023-01-24 12:35:58 -06:00
Slava Zakharin
8743e1e369 Revert "[OpenMP][Archer] Use dlsym rather than weak symbols for TSan annotations"
OpenMP buildbots are failing:
https://lab.llvm.org/buildbot/#/builders/193/builds/25434
https://lab.llvm.org/buildbot/#/builders/193/builds/25420

This reverts commit 7fbf12210007a66f7b62beadc0e5a52561cc0ab3.
2023-01-24 10:17:35 -08:00
Joachim Protze
7fbf122100 [OpenMP][Archer] Use dlsym rather than weak symbols for TSan annotations
This patch fix issues reported for Ubuntu and possibly other platforms:
https://github.com/llvm/llvm-project/issues/45290

The latest comment on this issue points out that using dlsym rather than
the weak symbol approach to call TSan annotation functions fixes the issue
for Ubuntu.

Differential Revision: https://reviews.llvm.org/D142378
2023-01-24 15:14:51 +01:00
Johannes Doerfert
5d9cb20f40 [OpenMP] Run the Attributor as part of the device runtime optimization
This will help us propagate assumptions to call sites, among other
things.
2023-01-23 22:45:47 -08:00
Joseph Huber
2a8c9d7c8a [Libomptarget] Use the nextgen plugins by default.
The next-gen plugins are complete drop-in replacements for the old
versions. We should strive to replace the old ones as quickly as
possible now that we have a viable alternative.

The only test failing is the `prelock.cpp` test as the support has not landed in
the next-gen plugins.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D142399
2023-01-23 17:30:46 -06:00
Scott Linder
25c0ea2a53 [NFC] Consolidate llvm::CodeGenOpt::Level handling
Add free functions llvm::CodeGenOpt::{getLevel,getID,parseLevel} to
provide common implementations for functionality that has been
duplicated in many places across the codebase.

Differential Revision: https://reviews.llvm.org/D141968
2023-01-23 22:50:49 +00:00
Martin Storsjö
c3737a6522 [docs] Add release notes for news in 16.x done by me, or otherwise relating to MinGW targets
Differential Revision: https://reviews.llvm.org/D142346
2023-01-23 22:12:32 +02:00
Joseph Huber
b280e12a3d [Libomptarget][NFC] Address a few warnings in libomptarget
Summary:
Fix a few minor warnings that show up in `libomptarget`.
2023-01-23 08:56:03 -06:00
Joseph Huber
716bae0b48 [Libomptarget] Include "hsa/hsa.h" instead
Summary:
Recently AMD moved the "hsa.h" include to "hsa/hsa.h". This causes
several warning. This patch checks to see if we can include that one
instead. This should hopefully keep things backwards compatible while
silencing the warnings.
2023-01-23 08:56:03 -06:00
Joseph Huber
11908c20cd [Libomptarget][NFC] Silence unknown CUDA version warnings
Summary:
These warnings are very loud considering they get repeated at least 30
times each build. This patch just silences them.
2023-01-23 08:56:03 -06:00
Shilei Tian
693358d787 [OpenMP][DeviceRTL][NFC] Use OMPTgtExecModeFlags from llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h
This patch makes preparation for a series that will enable per-kernel information
used in both host and device runtime. Some variables/enums, such as `OMPTgtExecModeFlags`,
have to be shared by both of them. A new header `OMPDeviceConstants.h` is added,
containing code that will be shared by them. We will introduce more variables soon.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142320
2023-01-22 19:10:54 -05:00
Johannes Doerfert
e68313f100 [OpenMP][FIX] Use thread id not team id for masked section 2023-01-22 15:45:00 -08:00