summaryrefslogtreecommitdiff
path: root/openmp/runtime/src/include
AgeCommit message (Collapse)Author
2025-11-18Revert "[OpenMP] Implement omp_get_uid_from_device() / ↵Robert Imschweiler
omp_get_device_from_uid()" (#168547) Reverts llvm/llvm-project#164392 due to fortran issues
2025-11-18[OpenMP] Implement omp_get_uid_from_device() / omp_get_device_from_uid() ↵Robert Imschweiler
(#164392) Use the implementation in libomptarget. If libomptarget is not available, always return the UID / device number of the host / the initial device.
2025-07-21[OpenMP] Fixup bugs found during fuzz testing (#143455)Jonathan Peyton
A lot of these only trip when using sanitizers with the library. * Insert forgotten free()s * Change (-1) << amount to 0xffffffffu as left shifting a negative is UB * Fixup integer parser to return INT_MAX when parsing huge string of digits. e.g., 452523423423423423 returns INT_MAX * Fixup range parsing for affinity mask so integer overflow does not occur * Don't assert when branch bits are 0, instead warn user that is invalid and use the default value. * Fixup kmp_set_defaults() so the C version only uses null terminated strings and the Fortran version uses the string + size version. * Make sure the KMP_ALIGN_ALLOC is power of two, otherwise use CACHE_LINE. * Disallow ability to set KMP_TASKING=1 (task barrier) this doesn't work and hasn't worked for a long time. * Limit KMP_HOT_TEAMS_MAX_LEVEL to 1024, an array is allocated based on this value. * Remove integer values for OMP_PROC_BIND. The specification only allows strings and CSV of strings. * Fix setting KMP_AFFINITY=disabled + OMP_DISPLAY_AFFINITY=TRUE
2025-06-13[OpenMP] Remove declaration and usage of __AMDGCN_WAVEFRONT_SIZE (#143761)nicebert
Removes usage of __AMDGCN_WAVEFRONT_SIZE as compile time constant. --------- Co-authored-by: Shilei Tian <i@tianshilei.me>
2025-06-12[OpenMP][Flang]Fix omp_get_cancellation return type from integer to logical ↵Yang Zaizhou
(#142990)
2025-04-02[OpenMP] 6.0 (TR11) Memory Management Update (#97106)Hansang Bae
TR11 introduced changes to support target memory management in a unified way by defining a series of API routines and additional traits. Host runtime is oblivious to how actual memory resources are mapped when using the new API routines, so it can only support how the composed memory space is maintained, and the offload backend must handle which memory resources are actually used to allocate memory from the memory space. Here is summary of the implementation. * Implemented 12 API routines to get/mainpulate memory space/allocator. * Memory space composed with a list of devices has a state with resource description, and runtime is responsible for maintaining the allocated memory space objects. * Defined interface with offload runtime to access memory resource list, and to redirect calls to omp_alloc/omp_free since it requires backend-specific information. * Value of omp_default_mem_space changed from 0 to 99, and omp_null_mem_space took the value 0 as defined in the language. * New allocator traits were introduced, but how to use them is up to the offload backend. * Added basic tests for the new API routines.
2025-02-04[OpenMP] Make `omp.h` work when compiled with `-ffreestanding` (#125618)Joseph Huber
Summary: Freestanding builds have `stddef.h` and `stdint.h` but not `stdlib.h`. We don't actually use any `stdlib.h` definitions in the OpenMP headers, and some definitions from this header are usable without the OpenMP runtime (allocators) so we should be able to do this. This ignores the include if possible, removing the implicit include would possibly break some applications so it stays here.
2024-08-15[OpenMP] Add support for pause with omp_pause_stop_tool (#97100)Hansang Bae
This patch adds support for pause resource with a new enumerator omp_pause_stop_tool. The expected behavior of this enumerator is * omp_pause_resource: not allowed * omp_pause_resource_all: equivalent to omp_pause_hard
2024-07-16[OpenMP] Use new OMPT state and sync kinds for barrier events (#95602)Hansang Bae
This change makes the runtime use new OMPT state and sync kinds introduced in OpenMP 5.1 in place of the deprecated implicit state and sync kinds. Events from implicit barriers use different enumerators for workshare, parallel, and teams.
2024-07-03[OpenMP] Add ompt_start_tool declaration in omp-tools.h (#97099)Hansang Bae
The function ompt_start_tool is a globally-visible C function according to the specification.
2024-06-03Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)" (#94139)Shilei Tian
2024-05-26Revert "Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)""Shilei Tian
This reverts commit 7b4865582299294455bc816358fd88a9c6e5e0be.
2024-05-26Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)"Shilei Tian
This reverts commit 9b31cc71d66064dfaf2afabf4a835211321bb4a0.
2024-05-24Revert "[OpenMP][OMPX] Add shfl_down_sync (#93311)"Joseph Huber
This reverts commit 098c6dfa8157681699a71fce9e3d94515e66311f. This reverts commit 8c718a3a91df4ab68dc3f1ca3887ea730c9aed84. This reverts commit 4fb02de9d490d0773441aa30124bb4d1272230d3.
2024-05-24[NFC][OpenMP][OMPX] Remove ';' that is outside of a functionShilei Tian
2024-05-24[OpenMP][OMPX] No default argument for C APIShilei Tian
2024-05-24[OpenMP][OMPX] Add shfl_down_sync (#93311)Shilei Tian
2024-05-24[OpenMP][OMPX] Add ballot_sync (#91297)Shilei Tian
This patch adds the support for `ballot_sync` in ompx.
2024-05-06[NFC][OpenMP][OMPX] Move `declare variant` upShilei Tian
2024-03-20[flang][OpenMP] Compile proper `omp_lib.mod` from the `openmp/src/include` ↵Michael Klemm
sources (#80874) This PR changes the build system to use use the sources for the module `omp_lib` and the `omp_lib.h` include file from the `openmp` runtime project and not from a separate copy of these files. This will greatly reduce potential for inconsistencies when adding features to the OpenMP runtime implementation. When the OpenMP subproject is not configured, this PR also disables the corresponding LIT tests with a "REQUIRES" directive at the beginning of the OpenMP test files. --------- Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>
2024-03-18[OpenMP] Add OpenMP extension API to dump mapping tables (#85381)nicebert
This adds an API call ompx_dump_mapping_tables. This allows users to debug the mapping tables and can be especially useful for unified shared memory applications to check if the code behaves in the way it should. The implementation reuses code already present to dump mapping tables (in a debug setting). --------- Co-authored-by: Joseph Huber <huberjn@outlook.com>
2024-02-06[OMPD] Runtime Entry Point functions for OMPD in libomp.so need C linkage as ↵vigbalu
per standard. (#79246) Adding extern "C" to all the entry point functions to make sure that these functions are not mangled.
2024-01-18[OpenMP][omp_lib] Restore compatibility with more restrictive Fortran ↵Paul Osmialowski
compilers (#77780) The most recent changes to `omp_lib.h.var` have re-introduced some compatibility issues that had to be fixed due to the similar changes in the past. Namely: 1. D120707 has removed the "use omp_lib_kinds" statement and replaced it with import 2. D114537 added line continuation to the long lines This patch introduces the same kind of changes in order to restore compatibility with some more restrictive Fortran compilers so their users could still benefit from the LLVM's OpenMP Fortran library.
2023-11-29[OpenMP] Add an 'stddef.h' include to 'omp.h' (#73876)Joseph Huber
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-10-25[OpenMP][Obvious] Fix function prototype when used in C modeJoseph Huber
Summary: The `llvm_omp_target_dynamic_shared_alloc` prototype in `omp.h` accidentally left the void argument unspecified. This created unintended code when called from the C language, causing some `nvlink` failures in certain scenarios.
2023-10-19[libomptarget][OpenMP] Initial implementation of omp_target_memset() and ↵Michael Klemm
omp_target_memset_async() (#68706) Implement a slow-path version of omp_target_memset*() There is a TODO to implement a fast path that uses an on-device kernel instead of the host-based memory fill operation. This may require some additional plumbing to have kernels in libomptarget.so
2023-08-03[OMPX] Change `thread_dim` to `block_dim` and the original `block_dim` to ↵Shilei Tian
`grid_dim` There is no `threadDim` in CUDA. Instead, it is `blockDim`. Then the current `blockDim` is `gridDim` in CUDA. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D157051
2023-07-31[OpenMP] Add ompx wrappers for __syncthreadsJohannes Doerfert
Differential Revision: https://reviews.llvm.org/D156729
2023-07-31[OpenMP] Introduce ompx.h and 3D wrappers (threadId, threadDim, ...)Johannes Doerfert
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-07[OpenMP] Add OMPT support for omp_all_memory task dependenceJoachim Jenke
omp_all_memory currently has no representation in OMPT. Adding new dependency flags as suggested by omp-lang issue #3007. Differential Revision: https://reviews.llvm.org/D111788
2022-10-01[OpenMP] [OMPT] [1/8] Create separate categories for host, device, [no]emi ↵Dhruva Chakrabarti
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-04-07[OpenMP] Add dynamic memory function to omp.h and add documentationJoseph Huber
This patch adds the `llvm_omp_target_dynamic_shared_alloc` function to the `omp.h` header file so users can access it by default. Also changed the name to keep it consistent with the other target allocators. Added some documentation so users know how to use it. Didn't add the interface for Fortran since there's no way to test it right now. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D123246
2022-04-07[OpenMP] Change target memory tests to use allocatorsJoseph Huber
The target allocators have been supported for NVPTX offloading for awhile. The tests should use the allocators instead of calling the functions manually. Also the comments indicating these being a preview should be removed. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D123242
2022-04-06[OpenMP] Add support for ompt_callback_dispatchHansang Bae
This change adds support for ompt_callback_dispatch with the new dispatch chunk type introduced in 5.2. Definitions of the new ompt_work_loop types were also added in the header file. Differential Revision: https://reviews.llvm.org/D122107
2022-03-31[OpenMP][libomp] NFC: Move omp_* functions out of kmp_* sectionJonathan Peyton
2022-03-05[OpenMP] libomp: omp_in_explicit_task() implemented.AndreyChurbanov
Differential Revision: https://reviews.llvm.org/D120671
2022-03-01[Openmp]: Missing import statement in openmp interface for FortranMalhar Jajoo
Essentially removed the "use omp_lib_kinds" statement and replaced it with import to maintain consistency (and avoid compilation error in case the omp_lib_kinds.mod file is not accessible) in header file. The import is required to access entities in host scoping unit. Differential Revision: https://reviews.llvm.org/D120707
2021-12-10[OpenMP] libomp: fix Fortran header: lines exceeded 72-char lengthAndreyChurbanov
Added line continuation to two long lines in Fortran header. Differential Revision: https://reviews.llvm.org/D114537
2021-11-10Revert "[openmp] Add OMPT initialization in libomptarget"Joachim Protze
Reverting initial OMPT for target implementation in favor of a different implementation. This reverts commit 3bc8ce5dd718beef0031bf4b070ac4026e6910d7.
2021-10-11[OpenMP] libomp: add OpenMP 5.1 memory allocation routines.AndreyChurbanov
Aligned allocation routines added. Fortran interfaces added for all allocation routines. Differential Revision: https://reviews.llvm.org/D110923
2021-09-09[OpenMP] Fix line truncation in omp_lib.hHansang Bae
Fixed code that exceeds 72-column. Differential Revision: https://reviews.llvm.org/D109469
2021-08-04[openmp] Add OMPT initialization in libomptargetLechen Yu
When loading libomptarget, the init function in libomptarget/src/rtl.cpp will search for the libomptarget_start_tool function using libdl. libomptarget_start_tool will pass those OMPT callbacks related to target constructs to libomptarget Differential Revision: https://reviews.llvm.org/D99803
2021-06-08[OpenMP][OMPD] Implementation of OMPD debugging library - libompd.Vignesh Balasubramanian
This is the first of seven patches that implements OMPD, a debugging interface to support debugging of OpenMP programs. It contains support code required in "openmp/runtime" for OMPD implementation. Reviewed By: @hbae Differential Revision: https://reviews.llvm.org/D100181
2021-06-01[OpenMP] Define named constants for interop's foreign runtime IDHansang Bae
Also added missing Fortran definitions for interop support. Differential Revision: https://reviews.llvm.org/D102883
2021-04-16[OpenMP] Add omp_target_is_accessible() to header filesHansang Bae
-- Added omp_target_is_accessible to the header files -- Added missing const qualifier to device memory routines Differential Revision: https://reviews.llvm.org/D100420
2021-04-06[OpenMP] Define omp_is_initial_device() variants in omp.hHansang Bae
omp_is_initial_device() is marked as a built-in function in the current compiler, and user code guarded by this call may be optimized away, resulting in undesired behavior in some cases. This patch provides a possible fix for such cases by defining the routine as a variant function and removing it from builtin list. Differential Revision: https://reviews.llvm.org/D99447
2021-03-16[OpenMP] Add runtime interface for OpenMP 5.1 error directiveHansang Bae
The proposed new interface is for supporting `at(execution)` clause in the error directive. Differential Revision: https://reviews.llvm.org/D98448
2021-03-02[OpenMP] Add allocator support for target memoryHansang Bae
This is a preview of allocator support for target memory that depends on the offload runtime API which allocates memory as described below. llvm_omp_target_alloc_host(size_t size, int device_num); -- Returns non-migratable memory owned by host. -- Memory is accessible by host and device(s). llvm_omp_target_alloc_shared(size_t size, int device_num); -- Returns migratable memory owned by host and device. -- Memory is accessible by host and device. llvm_omp_target_alloc_device(size_t size, int device_num); -- Returns memory owned by device. -- Memory is only accessible by device. New memory space and predefined allocator names are -- llvm_omp_target_host_mem_space -- llvm_omp_target_shared_mem_space -- llvm_omp_target_device_mem_space -- llvm_omp_target_host_mem_alloc -- llvm_omp_target_shared_mem_alloc -- llvm_omp_target_device_mem_alloc Differential Revision: https://reviews.llvm.org/D96669
2021-02-25[OpenMP] Fix accidental addition of use omp_lib_kindsPeyton, Jonathan L
Fortran header accidentally had use omp_lib_kinds added inside a subroutine and function. This patch removes the lines.
2021-02-01[OpenMP] libomp: implement nteams-var and teams-thread-limit-var ICVsAndreyChurbanov
The change includes OMP_NUM_TEAMS, OMP_TEAMS_THREAD_LIMIT env variables, omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit routines. Differential Revision: https://reviews.llvm.org/D95003