Commit Graph

2891 Commits

Author SHA1 Message Date
Johannes Doerfert
e5a3d5ba88 [OpenMP][NFC] Enable more runtime tests and also run them with O3
The test run fine on my AMD GPU machine, we should verify them on others
too and put them into our regular testing. Not testing O1/2/3 is really
bad and not testing all architecturs is similarly problematic.

Differential Revision: https://reviews.llvm.org/D148576
2023-07-31 15:45:53 -07:00
Johannes Doerfert
63684550c4 [OpenMP][NFC] Add offloading tests for the new ompx APIs 2023-07-31 15:45:53 -07:00
Johannes Doerfert
deb0ea3e47 [OpenMP] Add ompx wrappers for __syncthreads
Differential Revision: https://reviews.llvm.org/D156729
2023-07-31 13:44:51 -07:00
Johannes Doerfert
daef6d327a [OpenMP] Introduce ompx.h and 3D wrappers (threadId, threadDim, ...)
The new ompx.h header will give us a place to put extensions. The first
are 3D getters for the common cuda values:
  `{threadId,threadDim,blockId,blockDim}.{x,y,z}`

Differential Revision: https://reviews.llvm.org/D156501
2023-07-31 13:44:51 -07:00
Johannes Doerfert
1f3a28d4e5 [OpenMP][NFC] Reorganize the ompx::mapping layer in the GPU runtime
This change makes the naming more consistent, I hope.
2023-07-31 13:44:51 -07:00
Jonathan Peyton
b34c7d8c8e [OpenMP] Introduce hybrid core attributes to OMP_PLACES and KMP_AFFINITY
* Add KMP_CPU_EQUAL and KMP_CPU_ISEMPTY to affinity mask API

* Add printout of leader to hardware thread dump

* Allow OMP_PLACES to restrict fullMask

This change fixes an issue with the OMP_PLACES=resource(#) syntax.
Before this change, specifying the number of resources did NOT change
the default number of threads created by the runtime. e.g.,
OMP_PLACES=cores(2) would still create __kmp_avail_proc number of
threads. After this change, the fullMask and __kmp_avail_proc are
modified if necessary so that the final place list dictates which
resources are available and how thus, how many threads are created by
default.

* Introduce hybrid core attributes to OMP_PLACES and KMP_AFFINITY

For OMP_PLACES, two new features are added:
  1) OMP_PLACES=cores:<attribute> where <attribute> is either
     intel_atom, intel_core, or eff# where # is 0 - number of core
     efficiencies-1. This syntax also supports the optional (#)
     number selection of resources.
  2) OMP_PLACES=core_types|core_effs where this setting will create
     the number of core_types (or core_effs|core_efficiencies).

For KMP_AFFINITY, the granularity setting is expanded to include two new
keywords: core_type, and core_eff (or core_efficiency). This will set
the granularity to include all cores with a particular core type (or
efficiency). e.g., KMP_AFFINITY=granularity=core_type,compact will
create threads which can float across a single core type.

Differential Revision: https://reviews.llvm.org/D154547
2023-07-31 13:55:32 -05:00
Anton Rydahl
5c0f98cd2a [OpenMP][Docs] Added offloading command line reference to OpenMP FAQ
This command adds an OpenMP offloading specific command line reference. The OpenMP FAQ links to the .rst new file.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D156387
2023-07-29 17:40:28 -07:00
antonrydahl
daf36b54b4 Revert "[OpenMP][Docs] Added offloading command line reference to OpenMP FAQ"
This reverts commit 4166ff6107. I accidentally
pushed an old version of this patch.
2023-07-28 18:28:29 -07:00
Anton Rydahl
b880552dc1 [OpenMP][Docs] Updated the OpenMP documentation about building the OpenMP documentation with Sphinx
When I was trying to improve the OpenMP documentation, I found that the information in `OpenMP/docs/README.md` did not contain up-to-date information about how to build the OpenMP documentation with Sphinx. When I ran `make
docs-openmp-html`, the command failed because there were a few syntax errors in `openmp/docs/design/Runtimes.rst`. This commit fixes the syntax errors and updates the documentation on building the OpenMP documentation.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D156470
2023-07-28 18:04:21 -07:00
antonrydahl
4166ff6107 [OpenMP][Docs] Added offloading command line reference to OpenMP FAQ
I have added a few things to the OpenMP FAQ which I think were missing. Feel free to suggest some changes. Are there missing options in the offloading command line reference? And what do you think about the section "Q: Why is my
build taking a long time"?

Differential Revision: https://reviews.llvm.org/D156387
2023-07-28 18:04:21 -07:00
Joseph Huber
141c4e7a94 [OpenMP] Do not always emit unused extern variables
Currently, the precense of the OpenMP target declare metadata requires
that we always codegen a global declaration. This is undesirable in the
case that we could defer or omit this declaration as is common with
unused extern variables. This is important as it allows us, in the
runtime, to rely on static linking semantics to omit unused symbols so
they are not included when the user links it in.

This patch changes the check for always emitting these variables.
Because of this we also need to extend this logic to the generation of
the offloading entries. This has the result of derring the offload entry
generation to the canonical definitoin. So we are effectively assuming
whoever owns the storage for this variable will perform that operation.
This makes an exception for `link` attributes as those require their own
special handling.

Let me know if this is sound in the implementation, I do not have the
largest view of the standards here.

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

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D156368
2023-07-28 11:52:05 -05:00
Kevin Sala
7b2745b424 [OpenMP][libomptarget] Process resources when getting/returning from managers
This patch adds the functionality to process with a lambda the resources
obtained and returned by the resource managers in the plugins. These
processing lambdas are empty for the moment. The idea is to process them
when the resource manager mutex is acquired.

Differential Revision: https://reviews.llvm.org/D156245
2023-07-28 00:37:08 +02:00
Kevin Sala
523ac0fcdf [OpenMP][libomptarget] Retrieve multiple resources from resource managers
This patch extends the plugin resource managers to return more than one resource
per call. The return function is not extended since we do not return more than
one resource anywhere.

Differential Revision: https://reviews.llvm.org/D155629
2023-07-28 00:37:08 +02:00
Kevin Sala
53e4c7c309 [OpenMP][libomptarget] Improving plugin resource managers
This patch improves the resource managers in the plugins by properly handling
the errors. Until now, errors when creating and destroying resources were not
propagated and were directly handled inside the resource managers. Now, all
errors are propagated as in the rest of the plugin infrastructure.

The code is now ready to implement the request/return of multiple resources in
a single getResource/returnResource call.

Differential Revision: https://reviews.llvm.org/D155621
2023-07-28 00:37:08 +02:00
Shilei Tian
10068cd654 [OpenMP] Introduce kernel environment
This patch introduces per kernel environment. Previously, flags such as execution mode are set through global variables with name like `__kernel_name_exec_mode`. They are accessible on the host by reading the corresponding global variable, but not from the device. Besides, some assumptions, such as no nested parallelism, are not per kernel basis, preventing us applying per kernel optimization in the device runtime.

This is a combination and refinement of patch series D116908, D116909, and D116910.

Depend on D155886.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142569
2023-07-26 13:35:14 -04:00
Michael Halkenhaeuser
1dec417ac4 [OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and after target launch and data transfer operations
Implemented RAII objects, initialized at target entry points, that
invoke tool-supplied callbacks. Updated status of target callbacks as
implemented.

Depends on D127365

Patch from John Mellor-Crummey <johnmc@rice.edu>
With contributions from:
Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>
Jan-Patrick Lehr <janpatrick.lehr@amd.com>

Reviewed By: jdoerfert, dhruvachak, jplehr

Differential Revision: https://reviews.llvm.org/D127367
2023-07-25 08:18:26 -04:00
Tobias Hieta
4706251a31 Clear release notes for 18.x 2023-07-25 13:58:49 +02:00
Michael Halkenhaeuser
cf119df548 Revert "[OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and after target launch and data transfer operations"
This reverts commit 00ccfcf9a6.
2023-07-25 06:22:25 -04:00
Michael Halkenhaeuser
5fa5c39871 [OpenMP] Add OMPT release note
OMPT release note addition for LLVM 17

Differential Revision: https://reviews.llvm.org/D156191
2023-07-24 20:38:04 -04:00
Michael Halkenhaeuser
00ccfcf9a6 [OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and after target launch and data transfer operations
Implemented RAII objects, initialized at target entry points, that
invoke tool-supplied callbacks. Updated status of target callbacks as
implemented.

Depends on D127365

Patch from John Mellor-Crummey <johnmc@rice.edu>
With contributions from:
Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>
Jan-Patrick Lehr <janpatrick.lehr@amd.com>

Reviewed By: jdoerfert, dhruvachak

Differential Revision: https://reviews.llvm.org/D127367
2023-07-24 20:22:06 -04:00
Jonathan Peyton
4e680ae5f2 [OpenMP] Move KMP_VERSION printout logic to post-serial-init
Get the KMP_VERSION printout logic out of environment variable file
(kmp_settings.cpp) and move to end of serial initialization where
KMP_SETTINGS and OMP_DISPLAY_ENV are.

Differential Revision: https://reviews.llvm.org/D154652
2023-07-24 16:02:03 -05:00
Jonathan Peyton
fda297729d [OpenMP] Restore comment accidently deleted in D154650 2023-07-24 16:01:03 -05:00
Jonathan Peyton
1e3bbf76a1 [OpenMP] Re-use affinity raii class in worker spawning
Get rid of explicit mask alloc, getthreadaffinity, set temp affinity,
reset to old affinity, dealloc steps in favor of existing
kmp_affinity_raii_t to push/pop a temporary affinity.

Differential Revision: https://reviews.llvm.org/D154650
2023-07-24 15:58:25 -05:00
Joseph Huber
8db184ae8c [OpenMP] Add a few release notes
Summary:
Release notes
2023-07-24 13:26:44 -05:00
Shilei Tian
6bd74fd65f Revert commits for kernel environment
This reverts commits for kernel environments as they causes issues in AMD BB.
2023-07-23 23:32:31 -04:00
Shilei Tian
c5c8040390 [OpenMP] Introduce kernel environment
This patch introduces per kernel environment. Previously, flags such as execution mode are set through global variables with name like `__kernel_name_exec_mode`. They are accessible on the host by reading the corresponding global variable, but not from the device. Besides, some assumptions, such as no nested parallelism, are not per kernel basis, preventing us applying per kernel optimization in the device runtime.

This is a combination and refinement of patch series D116908, D116909, and D116910.

Depend on D155886.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142569
2023-07-23 18:36:01 -04:00
Shilei Tian
763fdb1ffa [OpenMP][Plugin] Update the global address calculation
Current global address caculation doesn't work for AMDGPU in some cases (https://reviews.llvm.org/D142569#4506212).
The root cause is the `sh_addr` is not substracted when caculating the address.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D155886
2023-07-23 17:41:06 -04:00
Michael Halkenhaeuser
d82eace1c9 [OpenMP][OMPT] Add 'Initialized' flag
We observed some overhead and unnecessary debug output.
This can be alleviated by (re-)introduction of a boolean that indicates, if the
OMPT initialization has been performed.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D155186
2023-07-21 08:19:03 -04:00
Michael Halkenhaeuser
453a75dc52 [OpenMP] [OMPT] [6/8] Added callback support for target data operations, target submit, and target regions.
This patch adds support for invoking target callbacks but does not yet
invoke them. A new structure OmptInterface has been added that tracks
thread local states including correlation ids. This structure defines
methods that will be called from the device independent target library
with information related to a target entry point for which a callback
is invoked. These methods in turn use the callback functions maintained
by OmptDeviceCallbacksTy to invoke the tool supplied callbacks.

Depends on D124652

Patch from John Mellor-Crummey <johnmc@rice.edu>
With contributions from:
Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>

Differential Revision: https://reviews.llvm.org/D127365
2023-07-21 06:24:12 -04:00
Joseph Huber
e537c83975 [libc] Add basic support for calling host functions from the GPU
This patch adds the `rpc_host_call` function as a GPU extension. This is
exported from the `libc` project to use the RPC interface to call a
function pointer via RPC any copying the arguments by-value. The
interface can only support a single void pointer argument much like
pthreads. The function call here is the bare-bones version of what's
required for OpenMP reverse offloading. Full support will require
interfacing with the mapping table, nowait support, etc.

I decided to test this interface in `libomptarget` as that will be the
primary consumer and it would be more difficult to make a test in `libc`
due to the testing infrastructure not really having a concept of the
"host" as it runs directly on the GPU as if it were a CPU target.

Reviewed By: jplehr

Differential Revision: https://reviews.llvm.org/D155003
2023-07-19 10:11:46 -05:00
Johannes Doerfert
f914208c43 [OpenMP][NFCI] Avoid storing non-constant values in ICV
If we store a constant in an ICV it is easier for the optimizer to
propagate it. Since we often use the full block for the thread limit and
the parallel team size, we can instead replace that dynamic value with a
constant that otherwise cannot occur, here 0.
2023-07-18 16:50:50 -07:00
Johannes Doerfert
88a68de14c [OpenMP][NFCI] Split assertion message from assertion expression
We ended up with `llvm.assume(icmp ne ptr as(4) null, as(4) @str)`
because the string in address space 4 was not known to be non-null.
There is no need to create these assumes.
2023-07-18 16:50:50 -07:00
Matt Arsenault
e9725628ba libomptarget: Try to fix dependency tracking for llvm tools 2023-07-18 06:21:33 -04:00
Jay Foad
92542f2a40 [AMDGPU] Add targets gfx1150 and gfx1151
This is the target definition only. Currently they are treated the same
as GFX 11.0.x.

Differential Revision: https://reviews.llvm.org/D155429
2023-07-17 13:06:12 +01:00
Joseph Huber
2dbc532672 [OMPT] Fix use of 'DEBUG_PREFIX' in the OMPT headers
This is the only place that defines  this prefix in a header file and
was thus overriding and redefining other users of it. If we must use it
in a header file, at least repsect its old values.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D155316
2023-07-14 15:58:24 -05:00
Adrian Munera
739164c024 [OpenMP] Build device runtimes for sm_87
Summary:
These were missing from the list of all architectures.

Differential Revision: https://reviews.llvm.org/D155287
2023-07-14 13:49:27 -05:00
Joseph Huber
48da62617e [OpenMP] Add documentation on using the libc in OpenMP
This points users to the `libc` documentation and explains the basics of
how it's used inside the runtime.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D155318
2023-07-14 13:28:29 -05:00
Carlos Eduardo Seo
7d0df44d39 [OpenMP] Disable veccopy tests for AArch64
Like for x86_64-linux-gnu, these need to be disabled for aarch64-linux-gnu.

Differential Revision: https://reviews.llvm.org/D155109
2023-07-12 23:53:14 +00:00
Joseph Huber
1776dc8124 [Libomptarget][Obvious] Fix uninitialized pointer
Summary:
This pointer was not initliazed to null which meant that it would be
erronenously deleted by plugins that were not in use.
2023-07-11 15:41:46 -05:00
Joseph Huber
8a0763f19c [Libomptarget] Remove RPCHandleTy indirection
The 'RPCHandleTy' was intended to capture the intention that a specific
device owns its slot in the RPC server. However, this required creating
a temporary store to hold these pointers. This was causing really weird
spurious failure due to undefined behaviour in the order of library
teardown. For example, the x64 plugin would be torn down, set this to
some invalid memory, and then the CUDA plugin would crash. Rather than
spend the time to fully diagnose this problem I found it pertinent to
simply remove the failure mode.

This patch removes this indirection so now the usage of the RPC server
must always be done with the intended device. This just requires some
extra handling for the AMDGPU indirection where we need to store a
reference to the device.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D154971
2023-07-11 10:54:40 -05:00
Joachim Jenke
81bc7cf609 [OpenMP][NFC] lit: Allow setting default environment variables for test
Add CHECK_OPENMP_ENV environment variable which will be passed to environment
variables for test (make check-* target). This provides a handy way to
exercise various openmp code with different settings during development.

For example, to change default barrier pattern:
```
$ env CHECK_OPENMP_ENV="KMP_FORKJOIN_BARRIER_PATTERN=hier,hier \
KMP_PLAIN_BARRIER_PATTERN=hier,hier \
KMP_REDUCTION_BARRIER_PATTERN=hier,hier" \
ninja check-openmp
```

Even with this, each test can set appropriate environment variables if needed
as before.

Also, this commit adds missing documention about how to run tests in README.

Patch provided by t-msn

Differential Revision: https://reviews.llvm.org/D122645
2023-07-11 15:00:40 +02:00
Michael Halkenhaeuser
142faf56f5 [OpenMP] [OMPT] [amdgpu] [5/8] Implemented device init/fini/load callbacks
Added support in the generic plugin to invoke registered callbacks.

Depends on D124070

Patch from John Mellor-Crummey <johnmc@rice.edu>
(With contributions from Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>)

Differential Revision: https://reviews.llvm.org/D124652
2023-07-11 07:13:22 -04:00
Carlos Eduardo Seo
d9a2b83dcd [OpenMP] Fix note section type notation for AArch64
Like Arm, AArch64 also uses "%" instead of "@" for note section types.

Differential Revision: https://reviews.llvm.org/D154859
2023-07-10 17:21:54 +00:00
Shao-Ce SUN
048423702d [OpenMP] Fix build warnings
```
llvm-project/openmp/libomptarget/src/private.h:260:9: warning: 'DEBUG_PREFIX' macro redefined [-Wmacro-redefined]
#define DEBUG_PREFIX GETNAME(TARGET_NAME)
        ^
llvm-project/openmp/libomptarget/include/ompt_device_callbacks.h:22:9: note: previous definition is here
#define DEBUG_PREFIX "OMPT"
        ^
1 warning generated.
```

```
llvm-project/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:458:14: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
      return std::move(Err);
             ^
llvm-project/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:458:14: note: remove std::move call here
      return std::move(Err);
             ^~~~~~~~~~   ~
llvm-project/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:552:12: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
    return std::move(Err);
           ^
llvm-project/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:552:12: note: remove std::move call here
    return std::move(Err);
           ^~~~~~~~~~   ~
2 warnings generated.
```

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D154787
2023-07-09 22:12:23 +08:00
Elliot Goodrich
a11efd4926 Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.

This is fixing all files missed in b0abd4893f and
39d8e6e22c.

Differential Revision: https://reviews.llvm.org/D154763
2023-07-08 20:06:21 +01:00
Joachim Jenke
820be30ad9 [OpenMP][OMPT] Introduce VERBOSE_INIT in ompt-multiplex.h
OpenMP 5.1 added OMP_TOOL_VERBOSE_INIT. This env variable is
extremely helpful to understand the issue when loading a tool fails
unexpectedly (e.g., errors from dlopen, when the libc available at
runtime is older than libc used at compile time of the tool -> missed
to load the right gcc module).

This patch replicates the verbose init code from libomp watching
out for a different env variable. Similar to
CLIENT_TOOL_LIBRARIES_VAR, a tool can define the name of
the env var by defining CLIENT_TOOL_VERBOSE_INIT_VAR
before including ompt-multiplex.h.
Alternatively, a tool can define OMPT_MULTIPLEX_TOOL_NAME
to specify the tool name which will be the prefix for both
_TOOL_LIBRARIES and _VERBOSE_INIT var.
Finally, if none of the two macros is defined, the header will
print a compiler warning and look at OMP_TOOL_VERBOSE_INIT.

Patch prepared by Semih Burak

Differential Revision: https://reviews.llvm.org/D112809
2023-07-08 17:09:57 +02:00
Joseph Huber
e526a7fc15 [Libomptarget][NFC] Clean up warnings and format 2023-07-07 18:59:26 -05:00
Joseph Huber
b83e29027c [Libomptarget] Fix tests only including the LTO variant
Summary:
These were overriding rather than appending. Fix that.
2023-07-07 16:24:27 -05:00
Martin Storsjö
f105c1dc58 [OpenMP] Remove the workaround of passing "-x assembler-with-cpp" manually
By building the assembly with language ASM now (since
4072c8aee4 and
cbaa3597aa), this shouldn't be
needed any longer.

Differential Revision: https://reviews.llvm.org/D150701
2023-07-07 23:32:27 +03:00
Joseph Huber
338c80516b [Libomptarget] Refine logic for determining if we support RPC
Summary:
Add a requirement for the GPU libc to only be on if its enabled
explicitly. Fix the logic around the pythonification of the variable.
2023-07-07 14:06:58 -05:00