Commit Graph

3231 Commits

Author SHA1 Message Date
Felipe Cabarcas
9b6ea5e8f8
[OpenMP] Improve omp offload profiler (#68016)
Summary:
Adding information to the LIBOMPTARGET profiler runtime kernel and API
calls.

Key changes:
* Adding information to runtime calls for better understanding of how
the application
is executing. For example teams requested by the user, size of memory
transfers.
* Profile timer was changed from 'us' to 'ns', since 'us' was too
coarse-grain
  to register some important details like key kernel duration
* Removed non API or Runtime calls, to reduce complexity of profile for
application
  developers.

---------

Co-authored-by: Felipe Cabarcas <cabarcas@leia.crpl.cis.udel.edu>
Co-authored-by: fel-cab <fel-cab@github.com>
2023-12-22 14:58:11 -05:00
Fabian Mora
12250c4092
Reland [OpenMP][Fix] libomptarget Fortran tests (#76189)
This patch fixes the erroneous multiple-target requirement in Fortran
offloading tests. Additionally, it adds two new variables
(test_flags_clang, test_flags_flang) to lit.cfg so that
compiler-specific flags for Clang and Flang can be specified.

This patch re-lands: #74543. The error was caused by having:
```
config.substitutions.append(("%flags", config.test_flags))
config.substitutions.append(("%flags_clang", config.test_flags_clang))
config.substitutions.append(("%flags_flang", config.test_flags_flang))
```
when instead it has to be:
```
config.substitutions.append(("%flags_clang", config.test_flags_clang))
config.substitutions.append(("%flags_flang", config.test_flags_flang))
config.substitutions.append(("%flags", config.test_flags))
```
because LIT replaces with the first longest sub-string match.
2023-12-21 14:18:36 -08:00
Ethan Luis McDonough
cb3a893436
[OpenMP] Check for gtest when building libomptarget unit tests (#76141)
This patch addresses an issue introduced in pull request #74398. CMake
will attempt to re-build gtest if openmp is enabled as a project (as
opposed to being enabled as a runtime). This patch adds a check that
prevents this from happening.
2023-12-21 04:00:35 -06:00
Joseph Huber
ba192debb4 [Libomptarget][Obvious] Fix typo in attribute lookup
Summary:
These are keys into the AMDGPU target metadata. One of them had a typo
which prevented it from being extracted.
2023-12-20 19:03:35 -06:00
Joseph Huber
f324584ae3
[Libomptarget][NFCI] Remove caching of created ELF files (#76080)
Summary:
We currently keep a cache of created ELF files from the relevant images.
This shouldn't be necessary as the entire ELF interface is generally
trivially constructable and extremely cheap. The cost of constructing
one of these objects is simply a size check and writing a pointer to the
underlying data. Given that, keeping a cache of these images should not
be necessary overall.
2023-12-20 17:13:41 -06:00
Shilei Tian
7e4c6f6cb2
[OpenMP] Reduce the size of heap memory required by the test malloc_parallel.c (#75885)
This patch reduces the size of heap memory required by the test
`malloc_parallel.c` and `malloc.c`. The original size is too large such
that `malloc` returns `nullptr` on many threads, causing illegal
memory access.
2023-12-20 15:03:01 -08:00
Ethan Luis McDonough
3c10e5b2f6
[OpenMP] Add unit tests for nextgen plugins (#74398)
This patch add three GTest unit tests that test plugin read and write
operations. Tests can be compiled with `ninja -C runtimes/runtimes-bins
LibomptUnitTests`.
2023-12-20 14:58:56 -08:00
Joseph Huber
e4f4022b70 [Libomptarget][NFC] Fix linting warnings in the plugins
Summary:
Fix some linting warnings present in the plugins.
2023-12-20 10:07:34 -06:00
Joseph Huber
ac029e02a9
[Libomptarget] Remove __tgt_image_info and use the ELF directly (#75720)
Summary:
This patch reorganizes a lot of the code used to check for compatibility
with the current environment. The main bulk of this patch involves
moving from using a separate `__tgt_image_info` struct (which just
contains a string for the architecture) to instead simply checking this
information from the ELF directly. Checking information in the ELF is
very inexpensive as creating an ELF file is simply writing a base
pointer.

The main desire to do this was to reorganize everything into the ELF
image. We can then do the majority of these checks without first
initializing the plugin. A future patch will move the first ELF checks
to happen without initializing the plugin so we no longer need to
initialize and plugins that don't have needed images.

This patch also adds a lot more sanity checks for whether or not the ELF
is actually compatible. Such as if the images have a valid ABI, 64-bit
width, executable, etc.
2023-12-19 20:01:31 -06:00
Joseph Huber
219355d4c0
[Libomptarget] Use scoped atomics in the device runtime (#75834)
Summary:
A recent patch allowed us to easily replace GNU atomics with scoped
variants that make use of the backend's handling for more permissive
scopes. The default is full "system" scope, that means the atomic
operation must be consistent with operations that may happen on the
host's memory. This is generally only required for processes that are
communicating with something via global fine-grained memory. This patch
uses these atomics to make everything device scoped, as nothing in the
OpenMP runtime should depend on the host.

This is only provided as a very new clang extension but the DeviceRTL is
only compiled with clang so it is always available.
2023-12-19 14:30:34 -06:00
Carlos Eduardo Seo
dcd7c8b7c9
[OpenMP][AArch64] Workaround for ompt/synchronization tests (#75848)
ompt/synchronization/[masked.c | master.c] tests fail due to a wrong
offset being calculated for the possible return addreses. PR #65936
fixes this for Darwin and the same has to be done for Linux.

Updates #69627
2023-12-19 19:26:23 +01:00
Fabian Mora
ac82c8b925
Revert "[OpenMP][Fix] libomptarget Fortran tests" (#75953)
Reverts llvm/llvm-project#74543
2023-12-19 12:11:08 -05:00
Gheorghe-Teodor Bercea
65909177e3
[OpenMP][libomptarget][Fix] Disable test on NVIDIA platforms (#75949)
The tests doesn't seem to work for NVIDIA so disabling it for now.
2023-12-19 11:58:10 -05:00
Fabian Mora
49efb082cc
[OpenMP][Fix] libomptarget Fortran tests (#74543)
This patch fixes the erroneous multiple-target requirement in Fortran
offloading tests. Additionally, it adds two new variables
(`test_flags_clang`, `test_flags_flang`) to `lit.cfg` so that
compiler-specific flags for Clang and Flang can be specified.
2023-12-19 11:35:14 -05:00
Shilei Tian
3768039913
[OpenMP] Directly use user's grid and block size in kernel language mode (#70612)
In kernel language mode, use user's grid and blocks size directly. No
validity
check, which means if user's values are too large, the launch will fail,
similar
to what CUDA and HIP are doing right now.
2023-12-18 12:26:18 -05:00
Joseph Huber
913622d012
[Libomptarget] Remove remaining global constructors in plugins (#75814)
Summary:
This patch fixes the remaining global constructor in the plguins after
addressing the ones in the JIT interface. This struct was mistakenly
using global constructors as not all the members were being initialized
properly. This was almost certainly being optimized out because it's
trivial, but would still be present in debug builds and prevented us
from compiling with `-Werror=global-constructors`. We will want to do
that once offloading is moved to a runtimes only build.
2023-12-18 11:01:02 -06:00
Joseph Huber
1580877555
[Libomptarget] Remove bitcode image map used for JIT processing (#75672)
Summary:
Libomptarget supports JIT by treating an LLVM-IR file as a regular input
image. The handling here used a global map to keep track of triples once
it was parsed. This was done to same time, however this created a global
constructor as well as an extra mutex to handle it. This patch removes
the use of this map.

Instead, we simply use the file magic to perform a quick check if the
input image is valid bitcode. If not, we then create a lazy module. This
should roughly equivalent to the old handling that create an IR symbol
table. Here we can prevent the module from materializing everything but
the single triple metadata we read in later.
2023-12-18 09:28:06 -06:00
Gheorghe-Teodor Bercea
cd1038a46a
[OpenMP][libomptarget][Fix]Require presence of libomptarget-debug for newly added test (#75807)
Require presence of libomptarget-debug fixes https://github.com/llvm/llvm-project/pull/75642
2023-12-18 10:07:52 -05:00
Gheorghe-Teodor Bercea
4ef6587715
[Clang][OpenMP] Fix mapping of structs to device (#75642)
Fix mapping of structs to device.

The following example fails:

```
#include <stdio.h>
#include <stdlib.h>

struct Descriptor {
  int *datum;
  long int x;
  int xi;
  long int arr[1][30];
};

int main() {
  Descriptor dat = Descriptor();
  dat.datum = (int *)malloc(sizeof(int)*10);
  dat.xi = 3;
  dat.arr[0][0] = 1;

  #pragma omp target enter data map(to: dat.datum[:10]) map(to: dat)

  #pragma omp target
  {
    dat.xi = 4;
    dat.datum[dat.arr[0][0]] = dat.xi;
  }

  #pragma omp target exit data map(from: dat)

 return 0;
}
```

This is a rework of the previous attempt:
https://github.com/llvm/llvm-project/pull/72410
2023-12-18 09:47:59 -05:00
Kazu Hirata
b8f89b84bc Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 15:02:17 -08:00
Shilei Tian
a4d1d5f5b5 [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-12-15 15:12:33 -05:00
dhruvachak
e4de6a602f
[OpenMP] [OMPT] A pointer to HostOpId should be passed in EMI callbacks. (#75574)
With this change, TargetRegionOpId is no more used and hence deleted.
2023-12-15 12:07:42 -08:00
Shilei Tian
54b54d63ca
[OpenMP] Fix compile error caused by #74397 (#75419)
This patch fixed the following compile error caused by #74397.

```
openmp/libomptarget/src/PluginManager.cpp: In static member function ‘static llvm::Expected<std::unique_ptr<PluginAdaptorTy> >
PluginAdaptorTy::create(const string&)’:
openmp/libomptarget/src/PluginManager.cpp:50:10: error: could not convert ‘PluginAdaptor’ from ‘std::unique_ptr<PluginAdaptorTy
>’ to ‘llvm::Expected<std::unique_ptr<PluginAdaptorTy> >’
   return PluginAdaptor;                                                                                                                                                                    ^~~~~~~~~~~~~
```
2023-12-15 08:15:52 -05:00
Andrew Brown
68ea91dd8b
[openmp][wasm] Allow compiling OpenMP to WebAssembly (#71297)
This change allows building the static OpenMP runtime, `libomp.a`, as
WebAssembly. It builds on the work done in [D142593] but goes further in
several ways:
 - it makes the OpenMP CMake files more WebAssembly-aware
- it conditions much more code (or code that had been refactored since
[D142593]) for `KMP_ARCH_WASM` and `KMP_OS_WASI`
- it fixes a Clang crash due to unimplemented common symbols in
WebAssembly

The commit messages have more details. Please understand this PR as a
start, not the completed work, for WebAssembly support in OpenMP.
Getting the tests running somehow would be a good next step, e.g.; but
what is contained here works, at least with recent versions of
[wasi-sdk] and engines that support [wasi-threads]. I suspect the same
is true for Emscripten and browsers, but I have not tested that
workflow.

[D142593]: https://reviews.llvm.org/D142593
[wasi-sdk]: https://github.com/WebAssembly/wasi-sdk
[wasi-threads]: https://github.com/WebAssembly/wasi-threads

---------

Co-authored-by: Atanas Atanasov <atanas.atanasov@intel.com>
2023-12-14 13:48:01 -06:00
Joseph Huber
0ab663d202
[Libomptarget] Move ELF symbol extraction to the ELF utility (#74717)
Summary:
We shouldn't have the format specific ELF handling in the generic plugin
manager. This patch moves that out of the implementation and into the
ELF utilities. This patch changes the SHT_NOBITS case to be a hard
error, which should be correct as the existing use already seemed to
return an error if the result was a null pointer.

This also uses a `const_cast`, which is bad practice. However,
rebuilding the `constness` of all of this would be a massive overhaul,
and this matches the previous behaviour (We would take a pointer to the
image that is most likely read-only in the ELF).
2023-12-14 11:04:13 -06:00
Johannes Doerfert
fe6f137e48
[OpenMP][NFC] Move mapping related code into OpenMP/Mapping.cpp (#75239)
DeviceTy provides an abstraction for "middle-level" operations that can
be done with a offload device. Mapping was tied into it but is not
strictly necessary. Other languages do not track mapping, and even
OpenMP can be used completely without mapping. This simply moves the
relevant code into the OpenMP/Mapping.cpp as part of a new class
MappingInfoTy. Each device still has one, but it does not clutter the
device.cpp anymore.
2023-12-12 12:49:46 -08:00
Johannes Doerfert
5dd1fc7008 [OpenMP][NFC] Improve profiling for the offload runtime 2023-12-11 17:30:35 -08:00
Johannes Doerfert
2ada7bb68b [OpenMP][NFCI] Remove effectively unused mutex
The only use was already guarded by a different lock in the caller of
loadBinary.
2023-12-11 17:30:35 -08:00
Johannes Doerfert
f0ccaeecd2 [OpenMP][NFC] Move rtl.cpp to OffloadRTL.cpp 2023-12-11 17:30:35 -08:00
Johannes Doerfert
cee6918d87 [OpenMP][NFC] Move api.cpp to OpenMP/API.cpp 2023-12-11 17:30:34 -08:00
Johannes Doerfert
12cbccc312
[OpenMP] Add extra flags to libomptarget and plugin builds (#74520) 2023-12-11 10:41:50 -08:00
Brad Smith
8b5af3139c
[OpenMP] Change check for OS to check for defined for a macro (#75012)
Check for the existence of the macro instead of checking for Solaris.
illumos has this macro in sys/time.h.

/export/home/brad/llvm-brad/openmp/runtime/src/z_Linux_util.cpp:77:9: warning: 'TIMEVAL_TO_TIMESPEC' macro redefined [-Wmacro-redefined]
   77 | #define TIMEVAL_TO_TIMESPEC(tv, ts)                                            \
      |         ^
/usr/include/sys/time.h:424:9: note: previous definition is here
  424 | #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
      |         ^
2023-12-11 09:54:24 -05:00
Gheorghe-Teodor Bercea
5fc76e6b6d
[OpenMP][Fix] Fix test initialization (#74801)
Fix test initialization
2023-12-07 22:20:32 -05:00
Gheorghe-Teodor Bercea
1216a31cae
Revert "[OpenMP][Fix] Fix test array initialization. (#74799)" (#74800)
This reverts commit d413681344.
2023-12-07 22:14:12 -05:00
Gheorghe-Teodor Bercea
d413681344
[OpenMP][Fix] Fix test array initialization. (#74799)
Fix test array initialization.
2023-12-07 22:09:08 -05:00
jyu2-git
8e8bff3397
Fix test. (#74745)
Just add
// REQUIRES: libomptarget-debug

So that test will not run with release compiler.
2023-12-07 10:45:59 -08:00
jyu2-git
0113722d82
[OpenMP] Fix runtime problem due to wrong map size. (#74692)
Currently we are missing set up-boundary address for FinalArraySection
as highests elements in partial struct data.

Currently for:
\#pragma omp target map(D.a) map(D.b[:2])
The size is:
  %a = getelementptr inbounds %struct.DataTy, ptr %D, i32 0, i32 0
  %b = getelementptr inbounds %struct.DataTy, ptr %D, i32 0, i32 1
  %arrayidx = getelementptr inbounds [2 x float], ptr %b, i64 0, i64 0
  %2 = getelementptr float, ptr %arrayidx, i32 1
  %3 = ptrtoint ptr %2 to i64
  %4 = ptrtoint ptr %a to i64
  %5 = sub i64 %3, %4
%6 = sdiv exact i64 %5, ptrtoint (ptr getelementptr (i8, ptr null, i32
1) to i64)

Where %2 is wrong for (D.b[:2]) is pointer to first element of array
section. It should pointe to last element of array section.
  
The fix is to emit the pointer to the last element of array section and
use this pointer as the highest element in partial struct data.

After change IR:
  %a = getelementptr inbounds %struct.DataTy, ptr %D, i32 0, i32 0
  %b = getelementptr inbounds %struct.DataTy, ptr %D, i32 0, i32 1
  %arrayidx = getelementptr inbounds [2 x float], ptr %b, i64 0, i64 0
  %b1 = getelementptr inbounds %struct.DataTy, ptr %D, i32 0, i32 1
  %arrayidx2 = getelementptr inbounds [2 x float], ptr %b1, i64 0, i64 1
  %1 = getelementptr float, ptr %arrayidx2, i32 1
  %2 = ptrtoint ptr %1 to i64
  %3 = ptrtoint ptr %a to i64
  %4 = sub i64 %2, %3
%5 = sdiv exact i64 %4, ptrtoint (ptr getelementptr (i8, ptr null, i32
1) to i64)
2023-12-07 09:38:56 -08:00
Joseph Huber
52fe16a47e [Libomptarget][Obvious] Fix incorrect if-else in CMake for destination
Summary:
This was added in a previous patch to update how we export the static
library used for OpenMP offloading. By mistake this if-else was using
the output incorrectly.

Fixes https://github.com/llvm/llvm-project/issues/74079
2023-12-07 08:27:38 -06:00
Johannes Doerfert
13b8826508
Revert " [OpenMP][NFC] Remove DelayedBinDesc" (#74679)
Reverts llvm/llvm-project#74360

As I wrote in the analysis of #74360:

Since
bc4e0c048a
we will not add PluginAdaptors into the container of all plugin adaptors
before the plugin is not ready. The error is thereby gone. When and old
HSA loads other libraries they can call register_image but that will
simply not register the image with the plugin we are currently
initializing. That seems like reasonable behavior, thought it is good to
keep in mind if we ever want a kernel library (@jhuber6 @mjklemm). We
can still have a standalone kernel library though or load it late after
all plugins are setup (which seems reasonable).

I did not expect one our tests actually doing exactly what this will not
allow anymore, at least when you use rocm <5.5.0. Need to figure out if
we want this behavior (for rocm <5.5.0).
2023-12-06 16:04:23 -08:00
Johannes Doerfert
62b11e1b16 [OpenMP][NFC] Actually use a string in the error message 2023-12-06 15:06:21 -08:00
Johannes Doerfert
0ace6ee73a
[OpenMP][FIX] Ensure we do not read outside the device image (#74669)
Before we expected all symbols in the device image to be backed up with
data that we could read. However, uninitialized values are not. We now
check for this case and avoid reading random memory.

This also replaces the correct readGlobalFromImage call with a
isSymbolInImage check after
https://github.com/llvm/llvm-project/pull/74550 picked the wrong one.

Fixes: https://github.com/llvm/llvm-project/issues/74582
2023-12-06 14:57:57 -08:00
Johannes Doerfert
dcbb1968a8 [OpenMP][FIX] Use unique library name to avoid clashes with other tests
We probably should use a temporary name, but having stable names helps
debugging.
2023-12-06 14:50:28 -08:00
Johannes Doerfert
d552ce2638
[OpenMP][NFC] Remove DelayedBinDesc (#74360)
Remove `DelayedBinDesc` as it is not necessary since
bc4e0c048a.
See
https://github.com/llvm/llvm-project/pull/74360#issuecomment-1843603736
for details.
2023-12-06 14:48:23 -08:00
Johannes Doerfert
2a1bcf1f38
[OpenMP] Allow to specify what plugins to look for (#74538)
By default we now only look for the plugins we build, but the user can
overwrite that with `LIBOMPTARGET_PLUGINS_TO_LOAD="cuda,amdgpu,x86_64"`
2023-12-06 14:16:02 -08:00
Joseph Huber
6f3bd3a2f6
[Libomptarget] Add a utility function for checking existence of symbols (#74550)
Summary:
There are now a few cases that check if a symbol is present before
continuing, effectively making them optional features if present in the
image. This was done in at least three locations and required an ugly
operation to consume the error. This patch makes a utility function to
handle that instead.
2023-12-06 07:41:27 -06:00
JP Lehr
a65363d989 [OpenMP] Disable offloading/barrier_fence test
Unblock build bot, while investigating. Issue is tracked under llvm
https://github.com/llvm/llvm-project/issues/74582
2023-12-06 04:32:48 -06:00
Johannes Doerfert
20da662656 [OpenMP][FIX] Fixup test that doesn't work with lit's env substitute 2023-12-05 16:32:19 -08:00
Johannes Doerfert
68db7aef74
[OpenMP] Reorganize the initialization of PluginAdaptorTy (#74397)
This introduces checked errors into the creation and initialization of
`PluginAdaptorTy`. We also allow the adaptor to "hide" devices from the
user if the initialization failed. The new organization avoids the
"initOnce" stuff but we still do not eagerly initialize the plugin
devices (I think we should merge `PluginAdaptorTy::initDevices` into
`PluginAdaptorTy::init`)
2023-12-05 16:04:01 -08:00
Johannes Doerfert
9f87509b19
[OpenMP][FIX] Ensure we allow shared libraries without kernels (#74532)
This fixes two bugs and adds a test for them:
- A shared library with declare target functions but without kernels
should not error out due to missing globals.
- Enabling LIBOMPTARGET_INFO=32 should not deadlock in the presence of
indirect declare targets.
2023-12-05 15:25:10 -08:00
Johannes Doerfert
66784dcb3b
[OpenMP] Ensure Devices is accessed exlusively (#74374)
We accessed the `Devices` container most of the time while holding the
RTLsMtx, but not always. Sometimes we used the mutex for the size query,
but then accessed Devices again unguarded. From now we properly
encapsulate the container in a ProtectedObj which ensures exclusive
accesses. We also hide the "isReady" part in the `getDevice` accessor
and use an `llvm::Expected` to allow to return errors.
2023-12-04 17:10:37 -08:00
Sandeep Kosuri
ecc080c07d
[OpenMP] return empty stmt for nothing (#74042)
- `nothing` directive was effecting the `if` block structure which it
should not. So return an empty statement instead of an error statement
while parsing to avoid this.
2023-12-03 13:33:38 +05:30
Johannes Doerfert
27f17837bb [OpenMP][NFC] Remove PluginAdaptorManagerTy 2023-12-01 15:23:17 -08:00
Johannes Doerfert
e469f8474b [OpenMP][FIX] Fixup test 2023-12-01 15:22:51 -08:00
Johannes Doerfert
7169c45efa [OpenMP][NFCI] Organize offload entry logic
This moves the offload entry logic into classes and provides convenient
accessors. No functional change intended but we can now print all
offload entries (and later look them up), tested via
`OMPTARGET_DUMP_OFFLOAD_ENTRIES=<device_no>`.
2023-12-01 15:10:52 -08:00
Johannes Doerfert
b091a887e0
[OpenMP][NFC] Extract device image handling into a class/header (#74129) 2023-12-01 14:59:12 -08:00
Johannes Doerfert
5fe741f08e
[OpenMP] Separate Requirements into a standalone header (#74126)
This is not completely NFC since we now check all 4 requirements and the
test is checking the good and the bad case for combining flags.
2023-12-01 14:47:00 -08:00
Brad Smith
027935d3cd
[OpenMP] Re-enable KMP_HAVE_QUAD on NetBSD 10.0 with GCC 10.5 (#73478) 2023-12-01 16:07:16 -05:00
dhruvachak
ca2d79f9ca
[OpenMP] Add an INFO message for data transfer of kernel launch env. (#74030) 2023-12-01 10:58:23 -08:00
Johannes Doerfert
3530428b8f
[OpenMP][NFC] Extract OffloadPolicy into a helper class (#74029)
OpenMP allows 3 different offload policies, handling of which we want to
encapsulate.
2023-12-01 10:55:18 -08:00
Johannes Doerfert
bc4e0c048a
[OpenMP][NFC] Modernize the plugin handling (#74034)
This basically moves code around again, but this time to provide cleaner
interfaces and remove duplication. PluginAdaptorManagerTy is almost all
gone after this.
2023-12-01 10:36:59 -08:00
Shraiysh
abaeaf3823
[OpenMP][flang] Adding more tests for commonblock with target map (#71146)
This patch addresses the concern about multiple devices and also adds
more tests for `map(to:)`, `map(from:)` and named common blocks.
2023-12-01 10:59:01 -06:00
Jon Chesterfield
f184147706
[amdgpu] Default to 1.0, instead of unspecified, for dynamic hsa (#74098)
The plugin checks the values of HSA_AMD_INTERFACE_VERSION_* so we now
set them to something safe in the header.
2023-12-01 16:37:49 +00:00
Dominik Adamski
85184b4aef
[OpenMP] Fix libomptarget build issue (#74067)
Libomptarget cannot be build because of the recent refactoring
introduced in patch 148dec9fa4 :
[OpenMP][NFC] Separate Envar (environment variable) handling (#73994)

That patch moved handling of environment variables from libomptarget
library. That's why we don't need usage of "llvm::omp::target" namespace
if we handle environment variables.
2023-12-01 13:33:11 +01:00
Johannes Doerfert
51fc8544c7
[OpenMP][NFC] Move mapping related logic into Mapping.h (#74009) 2023-11-30 17:08:41 -08:00
Johannes Doerfert
1035cc7029
[OpenMP][NFC] Encapsulate Devices.size() (#74010) 2023-11-30 16:44:47 -08:00
Johannes Doerfert
b8b2a279d0
[OpenMP][NFC] Encapsulate profiling logic (#74003)
This simply puts the profiling logic into the `Profiler` class and
allows non-RAII profiling via `beginSection` and `endSection`.
2023-11-30 15:52:02 -08:00
Johannes Doerfert
148dec9fa4
[OpenMP][NFC] Separate Envar (environment variable) handling (#73994) 2023-11-30 15:23:34 -08:00
Johannes Doerfert
b80b5f180b
[OpenMP] Replace copy and paste code with instantiation (#73991) 2023-11-30 14:16:34 -08:00
Joseph Huber
0ec4b82cfd
[Libomptarget] Output the DeviceRTL alongside the other libraries (#73705)
Summary:
Currently, the `libomp.so` and `libomptarget.so` are emitted in the
`./lib` build directory generally. This logic is internal to the
`add_llvm_library` function we use to build `libomptarget`. The
DeviceRTl static library however is in the middle of the OpenMP runtime
build, which can vary depending on if this is a runtimes or projects
build. This patch changes this to install the DeviceRTL static library
alongside the other OpenMP libraries so they are easier to find.
2023-11-30 15:48:39 -06:00
Johannes Doerfert
fce4c0acd6
[OpenMP] Start organizing PluginManager, PluginAdaptors (#73875) 2023-11-30 13:47:47 -08:00
Shilei Tian
5f864ba195 Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"
This reverts commit 97e16da450 because it
causes build error on i386 system.
2023-11-30 16:15:54 -05:00
Joseph Huber
8b9a6af450
[OpenMP] Add an 'stddef.h' include to 'omp.h' (#73876)
Summary:
We use `size_t` internally in the omp.h header, which is normally
provided by `stdlib.h` which is already included. Howevever, some cases
when using `-ffreestanding` can result in this not being defined via
`stdlib.h`. This patch simply adds an explicit inclusion of this header,
which is provided by the `clang` resource directory, to resolve this in
all cases.
2023-11-29 18:53:30 -06:00
Johannes Doerfert
2e7f47d4a8
[OpenMP][NFC] Move out plugin API and APITypes into standalone headers (#73868) 2023-11-29 16:04:19 -08:00
Johannes Doerfert
fae233c63f
[OpenMP] Avoid initializing the KernelLaunchEnvironment if possible (#73864)
If we don't have a team reduction we don't need a kernel launch
environment (for now). In that case we can avoid the cost.
2023-11-29 14:49:13 -08:00
Johannes Doerfert
40422bf150
[OpenMP][NFC] Separate OpenMP/OpenACC specific mapping code (#73817)
While this does not really encapsulate the mapping code, it at least
moves most of the declarations out of the way.
2023-11-29 10:29:54 -08:00
Johannes Doerfert
8391bb3f5c
[OpenMP][NFC] Move more declarations out of private.h (#73823) 2023-11-29 09:22:03 -08:00
Johannes Doerfert
b465f94b7c
[OpenMP][NFC] Put ExponentialBackoff in a Utils header (#73816)
"private.h" will go.
2023-11-29 09:10:29 -08:00
Johannes Doerfert
bdecfebce4
[OpenMP][NFC] Rename OmptCallback.cpp into OpenMP/OMPT/Callback.cpp (#73813)
Also revert the ifdef OMPT_SUPPORT order to have the short fallback
first and not after 400 lines.
2023-11-29 08:44:07 -08:00
Johannes Doerfert
fd2d0bf90e
[OpenMP][NFC] Replace unnecessary typedefs (#73815) 2023-11-29 08:40:41 -08:00
Johannes Doerfert
e2299e8d9d
[OpenMP][NFC] Move OMPT headers into OpenMP/OMPT (#73718) 2023-11-29 08:29:41 -08:00
Johannes Doerfert
db96a9c3b7
[OpenMP][NFC] Flatten plugin-nextgen/common folder sturcture (#73725)
For historic reasons we had it setup that there was
`  plugin-nextgen/common/PluginInterface/<sources + headers>`
which is not what we do anywhere else.
Now it looks like the rest:
```
  plugin-nextgen/common/include/<headers>
  plugin-nextgen/common/src/<sources>
```
As part of this, `dlwrap.h` was moved into common/include (as
`DLWrap.h`)
since it is exclusively used by the plugins.
2023-11-29 07:57:01 -08:00
Johannes Doerfert
2cfe7b1b66
[OpenMP][NFC] Extract timescope profile support into its own header (#73727) 2023-11-29 07:54:35 -08:00
Dominik Adamski
d4d88b8499
[OpenMP] New Openmp device RTL functions (#73225)
Add new implementation of workshare loop functions.

These functions will be used by OpenMPIRBuilder to support
handling of OpenMP workshare loops for the target region.

---------

Co-authored-by: Johannes Doerfert <johannes@jdoerfert.de>
2023-11-29 14:25:57 +01:00
Jan Patrick Lehr
3930a0b57a
[OpenMP][libomptarget] Use two SDMA engines (#73633)
Limit the use to two SDMA engines which are optimized for such transfers.
2023-11-29 14:21:44 +01:00
Johannes Doerfert
5d57041d39
[OpenMP][NFC] Move debug declares into CMAKE out of "private.h" (#73732)
Everywhere else we define this in the CMakeLists.txt and "private.h"
needs to go. Rename "Libomptarget" into "omptarget", no benefit from
"lib".
2023-11-28 17:38:49 -08:00
Shilei Tian
97e16da450 [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 19:04:30 -05:00
Shilei Tian
351c3ee5f6 Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"
This reverts commit d46f63553a.
2023-11-28 18:58:47 -05:00
Shilei Tian
d46f63553a [OpenMP] Use simple VLA implementation to replace uses of actual VLA
Use of VLA can cause compile warning that was introduced in D156565. This patch
implements a simple stack/heap-based VLA that can miminc the behavior of an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 18:54:48 -05:00
Johannes Doerfert
d1057014a1
[OpenMP][NFC] Create an "OpenMP" folder in the include folder (#73713)
Not everything in libomptarget (include) is "OpenMP", but some things
most certainly are. This commit moves some code around to start making
this distinction without the intention to change functionality.
2023-11-28 15:41:31 -08:00
Shilei Tian
e7f5d609dd Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA (#71412)"
This reverts commit eaab947a8a because it
causes link error.
2023-11-28 18:34:24 -05:00
Shilei Tian
eaab947a8a
[OpenMP] Use simple VLA implementation to replace uses of actual VLA (#71412)
Use of VLA can cause compile warning that was introduced in D156565.
This patch
implements a simple stack/heap-based VLA that can miminc the behavior of
an
actual VLA and prevent the warning. By default the stack accomodates the
elements. If the number of emelements is greater than N, which by
default is 8,
a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28 18:30:06 -05:00
Johannes Doerfert
7233e42dff
[OpenMP][NFC] Move Environment.h and SourceInfo.h into "Shared" folder (#73703) 2023-11-28 15:10:06 -08:00
Johannes Doerfert
8327f4a851
[OpenMP][NFC] Move Utils.h and Debug.h into a "Shared" include folder (#73701)
Headers used throughout the different runtimes are different from the
internal headers. This is a first step to bring structure in into the
include folder.
2023-11-28 13:44:57 -08:00
Michael Halkenhaeuser
19fa27605c [NFC][docs] Add AMDGPU documentation for LIBOMPTARGET_STACK_SIZE
Add documentation w.r.t. changes by #72606, which allows to set the dynamic
callstack size.
2023-11-28 14:09:42 -05:00
Johannes Doerfert
0783bf1cb3
[OpenMP][NFC] Merge MemoryManager into PluginInterface (#73678)
Similar to #73677, there is no benefit from keeping MemoryManager
seperate; it's tied into the current design. Except the move I also
replaced the getenv call with our Env handling.
2023-11-28 10:17:51 -08:00
Johannes Doerfert
4667dd62ee
[OpenMP][NFC] Merge elf_common into PluginInterface (#73677)
The overhead of a library and 4 files seems high without benefit. This
simply tries to consolidate our structure.
2023-11-28 10:03:25 -08:00
Alex
d6f00654fb
[OpenMP][Runtime][test] Fix ompt task testcase fail randomly (#72337)
Fixed #72231
2023-11-28 14:22:57 +01:00
Johannes Doerfert
e1f911e40c [OpenMP][NFC] Simplify code 2023-11-27 16:02:34 -08:00
Johannes Doerfert
d2636dc390 [OpenMP][NFC] Fix diagnostic warnings 2023-11-27 16:02:34 -08:00
Johannes Doerfert
30fbe73ba9 [OpenMP][NFC] Remove else after return 2023-11-27 16:02:33 -08:00