Commit Graph

2423 Commits

Author SHA1 Message Date
Malhar Jajoo cea951dccd Avoid exporting 80-bit fp functions for architectures other than Intel.
This patch is a partial fix for [[ https://github.com/llvm/llvm-project/issues/56349 | issue ]], due to functions affected by D117473.

Implementation details:
The patch essentially creates a new macro if the architecture is either
intel32 or intel64, since the generate-def.pl cannot process boolean algebra
on macros.

Reviewed By: jlpeyton

Differential Revision: https://reviews.llvm.org/D135795
2022-10-19 15:55:19 +01:00
Joseph Huber 586fc5999b [Libomptarget][NFC] clang-format the libomptarget OpenMP tests
Summary:
Recent changes to clang-format improved the handling of OpenMP pragmas.
Clean up the existing libomptarget tests.
2022-10-19 08:57:27 -05:00
Nawrin Sultana 9f1f1b924f [OpenMP] Add upper limit to TPAUSE exponential backoff time
Differential Revision: https://reviews.llvm.org/D135003
2022-10-17 10:22:11 -05:00
Joseph Huber 1af7541741 [Libomptarget] Fix missing semicolon in exports 2022-10-14 09:02:42 -05:00
Joseph Huber 619dced0fc [Libomptarget] Don't use full names for exported plugin symbols
Summary:
This patch changes the `exports` file to export all `__tgt_rtl`
functions. This is a better option as not each plugin implements all of
these functions, furthermore any new functions added will be
automatically included.
2022-10-14 08:57:57 -05:00
Slava Zakharin 88da0de14f Revert "[Libomp] Do not error on undefined version script symbols"
This reverts commit 096f93e73d.

Revert "[Libomptarget] Make the plugins ingore undefined exported symbols"

This reverts commit 3f62314c23.

Revert "[LLD] Enable --no-undefined-version by default."

This reverts commit 7ec8b0d162.

Three commits are reverted because of the current omp build fail
with GNU ld. See discussion here: https://reviews.llvm.org/rG096f93e73dc3
2022-10-13 14:12:07 -07:00
Joseph Huber 096f93e73d [Libomp] Do not error on undefined version script symbols
Summary:
A recent patch made all of the places we used version scripts in OpenMP
start throwing errors when linking with LLD. This is hopefully the last
one required to get the build bots to pass. This patch simply adds the
`--undefined-version` flag to the places where the version scripts are
used.
2022-10-13 08:45:23 -05:00
Joseph Huber 3f62314c23 [Libomptarget] Make the plugins ingore undefined exported symbols
Summary:
Recent changes made the default behaviour to error when given an
undefined symbol in a version script. A previous patch fixed this for
`libomptarget` by removing the single undefined symbol. However, the
plguins are expected to only define a subset of the availible functions
so we shouldn't treat it as an error. This patch updates the build flags
to work appropriately.
2022-10-13 08:13:03 -05:00
Joseph Huber e801e8f3e7 [Libomptarget] Remove undefined 'omp_get_interop_rc_desc' symbol from exports list
Summary:
A recent patch made undefined symbols in version scripts cause errors by
default. The `omp_get_interop_rc_desc` function is declared but not
defined, so it is undefined in the final link unit. This patch removes
it from the exports list, it should be added back in when actually
defined and used.
2022-10-13 07:41:14 -05:00
Vitaly Buka 74fea6bffe [test][openmp] Relax check for tsan reports count
I see 2 reports time to time.
2022-10-12 16:46:33 -07:00
Joseph Huber 316eaa3008 [OpenMP][Docs] Add documentation for linking OpenMP with CUDA/HIP
Summary:
This patch adds an entry to the FAQ that shows how to link CUDA with
OpenMP.
2022-10-11 13:40:41 -05:00
Joseph Huber 55d043cc06 [OpenMP][Docs] Document multi-architecture binary handling
Summary:
This patch adds some documentation in the FAQ regarding
multi-architecture binary support using the `--offload-arch` flag.
2022-10-11 13:40:41 -05:00
Ye Luo 053e894106 [DeviceRTL] CMake fix using target-level dependency
File-level dependency should not be used on files generated during the build. The next command may execute before the generating command finishes writing the file. Use add_custom_target and use target-level dependency.

Differential Revision: https://reviews.llvm.org/D135630
2022-10-10 21:23:58 -05:00
Shilei Tian 395d261de7 [NFC] Remove trailing white space in openmp/libomptarget/src/CMakeLists.txt 2022-10-07 13:42:31 -04:00
Joseph Huber defe072010 [Libomptarget] Remove debug definitions DeviceRTL's CMake
These debugging definitions are no longer used in the new runtime. The
old runtime has been removed since Clang-14 so we can safely get rid of
these leftover variables.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D135452
2022-10-07 11:31:18 -05:00
Joseph Huber 1bddb0fc23 [Libomptarget] Clean up DeviceRTL CMake and remove unused flags
Summary:
This patch just cleans up the unused flags in the DeviceRTL. These
should no longer be necessary or are redundant. Also add the extract
tool and packager to the check and error message if not found. This will
make it easier to tell if they are not present.
2022-10-07 10:09:48 -05:00
Vignesh Balasubramanian 97bb709013 [OpenMP] [OMPD] Build gdb-plugin code only when python3 development files are available.
gdb-plugin code is a interface between gdb, libompd, gdb and libomp.
Python3 development files are required to build this utility.
This patch will disable the plugin code build when python3 dev files
are not available.

Reviewed By: @mgorny, @aaronpuchert
Differential Revision: https://reviews.llvm.org/D134275
2022-10-07 14:35:56 +05:30
Ye Luo deba92d6c2 [DeviceRTL] Fix a CMake multi-step compilation dependency issue.
caused by 9223315903
2022-10-06 19:07:39 -05:00
Shilei Tian 9dd0476293 [OpenMP][DeviceRTL] Fix build issue 2022-10-06 16:21:51 -04:00
Shilei Tian 32dc48094b [OpenMP][DeviceRTL] Fix an issue that thread array might be corrupted
The shared memory stack in the device runtime assumes no intervined uses.
D135037 breaks the assumption, potentially causing the shared stack corruption.
This patch moves the thread array to heap memory. Since it is already the slow
path, it doesn't matter that much anyway.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D135391
2022-10-06 16:13:33 -04:00
Joseph Huber 9223315903 [DeviceRTL] Allow IsSPMDMode to be optimized out in LTO mode
A previous patch merged the static and bitcode versions of the
deviceRTL. We previously used the static library's separate compilation
to set a special flag that prevented `IsSPMDMode` from being put in the
used list and preventing it from being optimized out. When they were
merged we could no longer do this separate compilation that allowed
users of LTO to get more optimal code.

This patch rearranges the code. The `IsSPMDMode` global is now
transitively used by its inclusion in the changed `__keep_alive`
function. This allows us to then manually delete the `__keep_alive`
function from the module when building the static library via
`llvm-extract`. The result is that the bitcode library correctly will
maintain the needed shared state, while the static library will be able
to internalize it and optimize it out.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D135280
2022-10-05 14:40:01 -05:00
Johannes Doerfert a3a741c0bb [OpenMP][FIX] Update device API to match recent changes 2022-10-05 08:07:38 -07:00
Johannes Doerfert f8ee045c6d [OpenMP] Eliminate the ThreadStates array in favor of indirection
If we have thread states, the program is going to be rather slow. If we
don't, we want to avoid wasting shared memory. This patch introduces a
slight penalty (malloc + indirection) for the slow path and reduces
resource usage for the fast path.

Differential Revision: https://reviews.llvm.org/D135037
2022-10-04 20:27:34 -07:00
Johannes Doerfert b113965073 [OpenMP] Introduce more atomic operations into the runtime
We should use OpenMP atomics but they don't take variable orderings.
Maybe we should expose all of this in the header but that solves only
part of the problem anyway.

Differential Revision: https://reviews.llvm.org/D135036
2022-10-04 20:20:55 -07:00
Johannes Doerfert f85c1f3b7c [OpenMP] Replace __ATOMIC_XYZ with atomic::xyz for style
Also fixes one ordering argument not used.

Differential Revision: https://reviews.llvm.org/D135035
2022-10-04 19:43:30 -07:00
Johannes Doerfert abbc3fa17b [OpenMP] Replace pointer comparison with `isSharedMemPtr` check
The pointer comparison was causing confusion for capture tracking, let's
avoid confusion.

Differential Revision: https://reviews.llvm.org/D135160
2022-10-04 19:24:22 -07:00
Jonathan Peyton f8d081c1a5 [OpenMP][libomp] Allow unused-but-set warnings
Only a few remaining which are taken care of by this patch.

Differential Revision: https://reviews.llvm.org/D133528
2022-10-03 10:24:33 -05:00
Hansang Bae 772fb97c0b [OpenMP] Ignore schedule modifier in static scheduling
The modifier bits in the schedule type is not used/supported in the
static scheduler, so it should be ignored.

Differential Revision: https://reviews.llvm.org/D134983
2022-10-03 08:29:57 -05:00
Dhruva Chakrabarti 667af48179 [OpenMP] [OMPT] [1/8] Create separate categories for host, device, [no]emi events
In preparation for OMPT target changes, create separate categories of events that will be used by OMPT target support.

Split up existing macro FOREACH_OMPT_EVENT into new ones. There is no change to the original macro. Created new macros FOREACH_OMPT_HOST_EVENT, FOREACH_OMPT_DEVICE_EVENT, FOREACH_OMPT_NOEMI_EVENT, FOREACH_OMPT_EMI_EVENT, and a few other sub-categories that can be used as required. One such use is in D123974 which uses events selectively.

Patch from John Mellor-Crummey <johnmc@rice.edu>

Reviewed By: dreachem

Differential Revision: https://reviews.llvm.org/D123429
2022-10-01 00:46:40 +00:00
Vitaly Buka adf4eda004 [test][openmp] Tsan may report more warnings here 2022-09-28 18:53:09 -07:00
Jennifer Yu 30cc712eb6 [Clang][OpenMP] Fix run time crash when use_device_addr is used.
It is data mapping ordering problem.

According omp spec
If one or more map clauses are present, the list item conversions that
are performed for any use_device_ptr or use_device_addr clause occur
after all variables are mapped on entry to the region according to those
map clauses.

The change is to put mapping data for use_device_addr at end of data
mapping array.

Differential Revision: https://reviews.llvm.org/D134556
2022-09-27 11:53:57 -07:00
Dan Palermo db021abf33 [OpenMP][AMDGPU] Enable OpenMP device runtime build for gfx110[0123]
Add OpenMP device runtime build support for the gfx1100, gfx1101,
gfx1102, and gfx1103 targets.

Differential Revision: https://reviews.llvm.org/D134465
2022-09-23 01:49:51 +00:00
Jennifer Yu 48ffd40ba2 [Clang][OpenMP] Codegen generation for has_device_addr claues.
This patch add codegen support for the has_device_addr clause. It use
the same logic of is_device_ptr. But passing &var instead pointer to var
to kernal.

Differential Revision: https://reviews.llvm.org/D134268
2022-09-20 21:12:30 -07:00
Ron Lieberman d5b5289561 revert 684f76643 [Clang][OpenMP] Codegen generation for has_device_addr claues.
breaks amdgpu buildbot
2022-09-20 01:37:27 +00:00
Jennifer Yu a1df13ecd6 Fix test case which is not working for AMDGPU.
This is for the change of
Differential Revision: https://reviews.llvm.org/D134186
2022-09-19 17:07:01 -07:00
Jennifer Yu 684f766431 [Clang][OpenMP] Codegen generation for has_device_addr claues.
Summary: This patch add codegen support for the has_device_addr clause.  It
use the same logic of is_device_ptr.

Differential Revision: https://reviews.llvm.org/D134186
2022-09-19 16:14:57 -07:00
SignKirigami 6772987fc3 [OpenMP] Add LoongArch64 support
GCC, glibc, binutils, and LLVM have added support for LoongArch64.
This patch adds support for LLVM OpenMP following D59880 for RISCV64.

Reviewed By: MaskRay, SixWeining

Differential Revision: https://reviews.llvm.org/D132925
2022-09-19 22:49:15 +00:00
Joseph Huber 292cb114b0 [Libomptarget] Revert changes to AMDGPU plugin destructors
These patches exposed a lot of problems in the AMD toolchain. Rather
than keep it broken we should revert it to its old semi-functional
state. This will prevent us from using device destructors but should
remove some new bugs. In the future this interface should be changed
once these problems are addressed more correctly.

This reverts commit ed0f218115.

This reverts commit 2b7203a359.

Fixes #57536

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D133997
2022-09-16 06:55:51 -05:00
Joseph Huber 4b004a0b83 [Libomptarget] Embed bitcode library in static library instead.
This patch changes the CMake to instead embed the already generated
LLVM-IR bitcode library into an object file to create the static
library. This is different from the previous method which generated them
separately. This will make the build faster and allow us to perform the
same internalization into a single library we do with the bitcode
library.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D133952
2022-09-15 14:05:18 -05:00
Dhruva Chakrabarti 839ac62c50 Revert "[OpenMP] Codegen aggregate for outlined function captures"
This reverts commit 7539e9cf81.
2022-09-15 03:08:46 +00:00
Giorgis Georgakoudis 7539e9cf81 [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert, jhuber6, ABataev

Differential Revision: https://reviews.llvm.org/D102107
2022-09-15 00:54:05 +00:00
Joseph Huber 23bc343855 [Libomptarget] Change device free routines to accept the allocation kind
Previous support for device memory allocators used a single free
routine and did not provide the original kind of the allocation. This is
problematic as some of these memory types required different handling.
Previously this was worked around using a map in runtime to record the
original kind of each pointer. Instead, this patch introduces new free
routines similar to the existing allocation routines. This allows us to
avoid a map traversal every time we free a device pointer.

The only interfaces defined by the standard are `omp_target_alloc` and
`omp_target_free`, these do not take a kind as `omp_alloc` does. The
standard dictates the following:

"The omp_target_alloc routine returns a device pointer that references
the device address of a storage location of size bytes. The storage
location is dynamically allocated in the device data environment of the
device specified by device_num."

Which suggests that these routines only allocate the default device
memory for the kind. So this has been changed to reflect this. This
change is somewhat breaking if users were using `omp_target_free` as
previously shown in the tests.

Reviewed By: JonChesterfield, tianshilei1992

Differential Revision: https://reviews.llvm.org/D133053
2022-09-14 12:14:07 -05:00
Joseph Huber c2acb1e5d3 [Libomptarget][NFC] Remove unused variable 2022-09-09 15:26:02 -05:00
Joseph Huber 86587f2891 [Libomptarget] Fix compiling with asserts using the bitcode library
Sumnmary:
A previous patch introduces an `exports` file which contains all the
symbol names that are not internalized in the bitcode library. This is
done to reduce the size of the bitcode library and only export needed
functions. This export file must contain all the functoins expected to
be called from the device. Since its introduction the `__assert_fail`
function used to be provided but was mistakenly not included. This patch
adds it.

Fixes #57656

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D133594
2022-09-09 15:25:24 -05:00
Joseph Huber 83fcba82cc [Libomptarget] Add proper LLVM libraries now that the AMDGPU plugin uses them
Summary:
The AMDGPU and CUDA plugins now relies on the Object and Support
libraries. This patch adds them explicitly rather than hoping that they
share the symbols loaded from the standard `libomptarget`.
2022-09-09 10:33:26 -05:00
serge-sans-paille 6f2ed8fd3f [OpenMP] Install ompt-multiplex.h alongside omp.h
The default install direction may not be in the compiler search path.

Differential Revision: https://reviews.llvm.org/D133420
2022-09-09 09:42:08 +02:00
Jonathan Peyton e5ac98fa01 [OpenMP][libomp] Cleanup __kmpc_flush() code
Have it be simple KMP_MFENCE() which incorporates x86-specific logic and
reduces to KMP_MB() for other architectures.

Differential Revision: https://reviews.llvm.org/D130928
2022-09-08 16:17:20 -05:00
Joseph Huber 6e8d93e5c2 [Libomptarget] Implement OpenMP 5.2 semantics for device pointers
In OpenMP 5.2, §5.8.6, page 160 line 32-33, when a device pointer
allocated by omp_target_alloc has implicitly been included on a target
construct as a zero-length array, the pointer initialisation should not
find a matching mapped list item, and so should retain its value as a
firstprivate variable. Previously, we would return a null pointer if the
list item was not found. This patch updates the map handling to the
OpenMP 5.2 semantics.

Reviewed By: jdoerfert, ye-luo

Differential Revision: https://reviews.llvm.org/D133447
2022-09-07 17:01:14 -05:00
Joseph Huber 8d2a447bf9 [Libomptarget] Remove leftover ELF header from x86 plugin
Summary:
We removed the linking support for `gelf.h` in a previous patch. This
header was incorrectly leftover causing build problems on some systems.
2022-09-07 13:41:40 -05:00
Joseph Huber 300155911a [Libomptarget] Replace libelf with LLVM's Elf libraries
This patch replaces the dependency on `libelf` with LLVM's ELF support.
With this patch the user no-longer needs to have `libelf` on their
system to build and configure OpenMP offloading. The replacement is
mostly mechanical, with the exception of the hash table support which
was added in D131309.

Depends on D131309

Reviewed By: JonChesterfield, saiislam

Differential Revision: https://reviews.llvm.org/D131401
2022-09-07 12:38:51 -05:00