Commit Graph

2689 Commits

Author SHA1 Message Date
Fangrui Song
555b572e3f Revert D118493 "Set rpath on openmp executables"
This reverts commit 9b9d08111b.
(Accepted by Jon https://reviews.llvm.org/D118493#4178250)

libc++, libc++abi, libunwind, and compiler-rt don't add the extra DT_RUNPATH,
it's strange for OpenMP to diverge.
Some build systems want to handle DT_RUNPATH themselves (e.g.
CMAKE_INSTALL_RPATH). Some distributions (e.g. Fedora) have policies against
DT_RUNPATH and the default DT_RUNPATH for OpenMP is causing trouble.

For users who don't want to specify rpath by themselves,
https://clang.llvm.org/docs/UsersManual.html#configuration-files
can be used to specify the default rpath, e.g.
specify -frtlib-add-rpath or -Wl,-rpath in bin/clang.cfg
2023-03-08 10:18:40 -08:00
Joseph Huber
d23b9fa61d [Libomptarget] Update handling of architectures for DeviceRTL
The support for enabling and disabling certain architectures for the
OpenMP device RTL is different between AMD and Nvidia. This patch
updates the logic to make it common. This supports the `auto` format
more generally via the `nvptx-arch` and `amdgpu-arch` options. (These
are not availible at CMake time without a runtimes build, or another
install somewhere. But that only prevents users from using auto).

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D145513
2023-03-08 11:22:33 -06:00
Shao-Ce SUN
420d2fcac9 [OpenMP][CUDA] Get rid of redundant macro def
Resolve warning of `TARGET_NAME` macro redefinition.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D145307
2023-03-05 02:01:59 +08:00
Mark de Wever
92523a35a8 Revert "[CMake] Bumps minimum version to 3.20.0."
Some build bots have not been updated to the new minimal CMake version.
Reverting for now and ping the buildbot owners.

This reverts commit 44c6b905f8.
2023-03-04 18:28:13 +01:00
Mark de Wever
44c6b905f8 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.

Reviewed By: mehdi_amini, MaskRay, ChuanqiXu, to268, thieta, tschuett, phosek, #libunwind, #libc_vendors, #libc, #libc_abi, sivachandra, philnik, zibi

Differential Revision: https://reviews.llvm.org/D144509
2023-03-04 12:40:57 +01:00
Vadim Paretsky (Intel Americas Inc)
a12953698d This check-in makes the following improvements to the OpenMP Windows build:
Only generate the second def file when necessary (native Windows import
library builds).
Properly clean up .def file artifacts.
Reduce the re-generated import library build artifacts to the minimum.
Refactor the import library related portions of the script for clarity.

Tested with MSVC and MinWG/gcc12.0

Differential Revision:https://reviews.llvm.org/D144419
2023-03-02 15:50:36 -08:00
Joseph Huber
48d5ad93cd [OpenMP][NFC] Clean up Twines and other issues in plugins
Summary:
Tihs patch is mostly NFC to fix some warning currently present in OpenMP
offloading plugins. Specifically this mostly removes the use of Twine
variables in favor of LLVM's small string. Twine variables are prone to
use-after-free and this is a cleaner way to concatenate a string.
2023-03-01 15:03:21 -06:00
Joseph Huber
656378085e [Libomptarget] Fix block and thread limit environment variables not being respected
The next-gen plugins did not properly set the values from
`OMP_NUM_TEAMS` and `OMP_TEAMS_THREAD_LIMIT`. This is because these
maximum values are set by each plugin to its hardware maximum. This
happens *after* the previous initialization. Move it to the correct
place and then add a test.

Fixes https://github.com/llvm/llvm-project/issues/61082

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D145105
2023-03-01 14:12:46 -06:00
JP Lehr
b82ac74f7e [OpenMP][AMDGPU] More detail in AMDGPU kernel launch info
Makes the info that is printed for kernel launches configurable for
different plugins. Adds all machinery to print the detailed launch
info that the current AMD plugin provides and includes e.g. register
spill counts.

The files msgpack.cpp, msgpack.def, and msgpack.h are copied from the old plugin
and are untouched. The contents of UtilitiesHSA.cpp and .h are copied together from
various files from the old plugin. The code was originally written by
Jon Chesterfield. I updated the function and type names visible to the outside, i.e.
in headers, to respect the LLVM conventions.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D144521
2023-02-28 07:41:48 -05:00
Johannes Doerfert
89a8077f3d [OpenMP][FIX] Properly align firstprivate variables
The old code didn't actually align the values, and it added padding even
when none was necessary. This approach will pad entries if necessary
and, similar to the struct case, use the host pointer as guidance.

NOTE: This does still not align them as the host has, but it's unclear
      if the user really should use the alignment bits anyway. For now
      this is a reasonable compromise, only if we have host alignment
      information (explicitly not implicitly via the host pointer), we
      could do it completely right without wasting lots of resources for
      >99% of the cases.

Fixes: https://github.com/llvm/llvm-project/issues/61034
2023-02-27 17:34:46 -08:00
Fangrui Song
46262cab24 [OpenMP] Remove uses of ATOMIC_VAR_INIT
ATOMIC_VAR_INIT has a trivial definition
`#define ATOMIC_VAR_INIT(value) (value)`,
is deprecated in C17/C++20, and will be removed in newer standards in
newer GCC/Clang (e.g. https://reviews.llvm.org/D144196).
2023-02-24 14:47:55 -08:00
Joseph Huber
9b8e4b4f96 [Libomptarget] Remove unused image argument from global handler function
Summary:
A previous patch got rid of the use of this image but forgot to remove
it from this function. Simply remove it as it is unused now.
2023-02-24 07:24:29 -06:00
Shilei Tian
22cd105a66 [OpenMP] Fix the wrong use of fopen
This patch fixes the wrong use of `fopen`.

Fix https://github.com/llvm/llvm-project/issues/60934

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D144601
2023-02-23 19:12:58 -05:00
Joseph Huber
de5d71c289 [Libomptarget] Adjust the info.c test now that printing is common
Summary:
Ever since the change to the new plugins the information messages are
common between the major plugins. This allows us to test the info.c file
generically.
2023-02-23 13:25:27 -06:00
Joseph Huber
dbb6344b26 [Libomptarget] Add the CUDA feature to the packager
Summary:
Internally we need to know the feature that was used to build the CUDA.
This used to be added when the deviceRTL was build via the OpenMP
interface, but ever since it was moved to call the packager explicitly
it was not being added. This causes failured if the user attempts to use
the library without LTO enabled.
2023-02-23 13:25:27 -06:00
Jennifer Yu
1b72a32762 Skip using this[:1] map info for non-member variable.
This fix runtime problem due to generate this[:1] map info for non member
variable.
To fix this check VD, if VD is not null, it is not member from current
or base classes.

Differential Revision: https://reviews.llvm.org/D144616
2023-02-23 09:27:56 -08:00
Nawrin Sultana
ae46cd72aa [OpenMP] Target memory allocator fallback to default when no device available
Differential Revision: https://reviews.llvm.org/D144525
2023-02-22 12:02:02 -06:00
Joseph Huber
37def00806 [OpenMP] Update the bug report link for libomp assertion failures
Currently we still print the old https://bugs.llvm.org/ bugzilla link.
We should update this to the issues pane for the LLVM github.

Reviewed By: tlwilmar

Differential Revision: https://reviews.llvm.org/D144426
2023-02-21 09:43:51 -06:00
Joseph Huber
22d618f543 [libomptarget] Remove unused image from global data movement function
This interface function does not actually need the device image type.
It's unused in the function, so it should be able to be safely removed.
The motivation for this is to facilitate downsteam porting of the
amd-stg-open RPC module into the nextgen plugin so we can delete the old
plugin entirely. For that to work we need to be able to call this
function at kernel-launch time, which doesn't have the image. Also it's
cleaner.

Reviewed By: jplehr

Differential Revision: https://reviews.llvm.org/D144436
2023-02-21 07:09:36 -06:00
Joseph Huber
5d560b6966 [Libomptarget] Implement the host memory allocator with fine grained memory
This patch should enable the "Host" allocation using fine-grained
memory. As far as I understand, this is HSA managed memory that is
availible to the host, but can be accessed by the device as well.
The original patch that introduced these extensions just stipulated that
it's "non-migratable" memory, which is most likely true because it's
managed by the host but accessible by the device. This should work
sufficiently well for what we expect the "host" allocation to do.

Depends on D143771

Reviewed By: kevinsala

Differential Revision: https://reviews.llvm.org/D143775
2023-02-20 08:44:09 -06:00
Joseph Huber
5216a9bfb0 [Libmoptarget] Enable the shared allocator for AMDGPU
Currently, the AMDGPU plugin did not support the `TARGET_ALLOC_SHARED`
allocation kind. We used the fine-grained memory allocator for the
"host" alloc when this is most likely not what is intended. Fine-grained
memory can be accessed by all agents, so it should be considered shared.
This patch removes the use of fine-grained memory for the host
allocator. A later patch will add support for this via the
`hsa_amd_memory_lock` method.

Reviewed By: kevinsala

Differential Revision: https://reviews.llvm.org/D143771
2023-02-20 08:44:08 -06:00
Ye Luo
e2069be83e [OpenMP] Make isDone lightweight without calling synchronize
~TaskAsyncInfoWrapperTy() calls isDone. With synchronize inside isDone, we need to handle the error return from synchronize in the destructor.
The consumers of TaskAsyncInfoWrapperTy, targetDataMapper and targetKernel, both call AsyncInfo.synchronize() before exiting.
For this reason in ~TaskAsyncInfoWrapperTy(), calling synchronize() via isDone() is redundant.
This patch removes synchronize() call inside isDone() and makes it a lightweight check.
__tgt_target_nowait_query needs to call synchronize() before checking isDone().

Differential Revision: https://reviews.llvm.org/D144315
2023-02-17 20:45:43 -06:00
Joseph Huber
5172877bbd [Libomptarget] Check errors when synchronizing the async queue
Summary:
Currently when we synchronize the asynchronous queue for the plugins, we
ignore the return value. This is problematic because we will continue on
like nothing happened if the kernel fails.

Fixes https://github.com/llvm/llvm-project/issues/60814

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D144191
2023-02-16 14:56:09 -06:00
Joseph Huber
48c8e16020 Revert "[Libomptarget] Check errors when synchronizing the async queue"
This reverts commit 861709107b.

Reverting this to reland as it will make it easier to backport.
2023-02-16 14:56:08 -06:00
Joseph Huber
861709107b [Libomptarget] Check errors when synchronizing the async queue
Currently when we synchronize the asynchronous queue for the plugins, we
ignore the return value. This is problematic because we will continue on
like nothing happened if the kernel fails.

Fixes https://github.com/llvm/llvm-project/issues/60814

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D144191
2023-02-16 10:10:21 -06:00
Martin Storsjö
96fcaf0cc0 [openmp] Fix building for mingw targets after import library changes
06d9bf5e64 (https://reviews.llvm.org/D143431)
did a large restructuring of how the import library is created;
previously, a second step to tweak the import library was only
done for MSVC style targets, but after this commit, that logic
was applied for mingw targets too.

Since LIBOMP_GENERATED_IMP_LIB_FILENAME and LIBOMP_IMP_LIB_FILE
are equal on mingw targets (both are "libomp.dll.a", while they
are "libomp.dll.lib" and "libomp.lib" for MSVC targets), this caused
a conflict, with errors like this:

  ninja: error: build.ninja:875: multiple rules generate runtime/src/libomp.dll.a [-w dupbuild=err]

Skip the logic with a second step to recreate the import library
for mingw targets. The MSVC specific logic for this relies on
running the static archiver with CMAKE_LINK_DEF_FILE_FLAG, which
with MS lib.exe (and llvm-lib) ignore the input object files and
just generates an import library - but mingw style tools don't
support this mode of operation. (By attemptinig the same, mingw tools
would generate a static library with the def file as one member.)
With mingw tools, the same can be achieved by invoking the dlltool
executable instead.

Instead of adding alternative logic for invoking dlltool, just skip
the second import library step, since neither GNU nor LLVM mingw
tools actually generate import libraries that link by ordinal - so
there's no need for a second import library.

Differential Revision: https://reviews.llvm.org/D143992
2023-02-15 00:30:30 +02:00
Ye Luo
0d4e55ba69 [OpenMP] Recover non-blocking target nowait disabled by D141232
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D143871
2023-02-14 15:48:38 -06:00
Alexey Bataev
ddde06906b [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop nest.
Need to assign the calculated lower bound back to temp variable,
otherwise incorrect value (upper bound instead of lower bound) might be
used.

Differential Revision: https://reviews.llvm.org/D144015
2023-02-14 10:39:04 -08:00
Vadim Paretsky (Intel Americas Inc)
8c74defcca [OpenMP] Fix extra parenthesis in kmp_os.h
Differential Revision: https://reviews.llvm.org/D143940
2023-02-13 21:43:36 -08:00
Nawrin Sultana
eb0ea28b6a [OpenMP] Add check for target allocator regardless of the availability of libmemkind
Current runtime implementation only checks for target allocator when libmemkind is
not available. This patch adds checks for target allocator regardless of the
presence of libmemkind library.

Differential Revision: https://reviews.llvm.org/D142582
2023-02-13 16:08:22 -06:00
Vadim Paretsky (Intel Americas Inc)
06d9bf5e64 [OpenMP] generate the Windows import library that imports by name rather
than ordinal

This check-in changes the OpenMP build script to generate the Windows
import library that imports by name rather than ordinal to reduce
ordinals order dependency and promote runtime flavors compatibility
going forward. The existing ordinals ordering is preserved to maintain
backward compatibility.

Differential Revision: https://reviews.llvm.org/D143431
2023-02-13 10:30:12 -08:00
Joseph Huber
9f650ae779 [Libomptarget] Remove dependency on the DeviceRTL from the GPU plugins
The GPU plugins have a dependency on the device libraries. Sometimes we
cannot build the device libraries because the user does not have a valid
`clang` to use or it was explicitly disabled. Currently this leads to a
transitive failure because we cannot meet this dependency. This patch
simply removes that dependency.

Fixes https://github.com/llvm/llvm-project/issues/60457

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D143196
2023-02-13 07:01:52 -06:00
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 402981ee25.
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