aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src
AgeCommit message (Collapse)AuthorFilesLines
2025-02-04[OpenMP] Make `omp.h` work when compiled with `-ffreestanding` (#125618)Joseph Huber1-1/+7
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.
2025-01-17[openmp] Support CET in z_Linux_asm.S (#123213)Nikita Popov1-0/+12
When libomp is built with -cf-protection, add endbr instructions to the start of functions for Intel CET support.
2024-11-20[OpenMP][Build][Wasm][116552] Fixed build problem when compiling with ↵Christian Oliveros1-2/+8
Emscripten on Windows (#116874)
2024-11-04[OpenMP] Using `SimpleVLA` to handle vla usage in ompt-general.cpp. (#114583)Daniel Chen1-2/+3
The `openmp` runtime failed to build on LoP with LLVM18 on LoP due to the addition of `-Wvla-cxx-extension` as ``` llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] 711 | int tmp_ids[ids_size]; | ^~~~~~~~ llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: note: function parameter 'ids_size' with unknown value cannot be used in a constant expression llvm-project/openmp/runtime/src/ompt-general.cpp:704:65: note: declared here 704 | OMPT_API_ROUTINE int ompt_get_place_proc_ids(int place_num, int ids_size, | ^ 1 error generated. ``` This patch is to ignore the checking against this usage.
2024-11-02[NFC] Simple typo correction. (#114548)c8ef1-1/+1
2024-10-25[OpenMP] Create versioned libgomp softlinks (#112973)Ye Luo1-1/+17
Add libgomp.1.dylib for MacOS and libgomp.so.1 for Linux Linkers on Mac and Linux pick up versioned libgomp dynamic library files. The existing softlinks (libgomp.dylib for MacOS and libgomp.so for Linux) are insufficient. This helps alleviate the issue of mixing libgomp and libomp at runtime.
2024-10-17[OpenMP] Fix missing gtid argument in __kmp_print_tdg_dot function (#111986)Josep Pinot1-2/+3
This patch modifies the signature of the `__kmp_print_tdg_dot` function in `kmp_tasking.cpp` to include the global thread ID (gtid) as an argument. The gtid is now correctly passed to the function. - Updated the function declaration to accept the gtid parameter. - Modified all calls to `__kmp_print_tdg_dot` to pass the correct gtid value. This change addresses issues encountered when compiling with `OMPX_TASKGRAPH` enabled. No functional changes are expected beyond successful compilation.
2024-10-14[openmp] Use core_siblings_list if physical_package_id not available (#111831)Nikita Popov1-29/+71
On powerpc, physical_package_id may not be available. Currently, this causes openmp to fall back to flat topology and various affinity tests fail. Fix this by parsing core_siblings_list to deterimine which cpus belong to the same socket. This matches what the testing code does. The code to parse the CPU list format thankfully already exists. Fixes https://github.com/llvm/llvm-project/issues/111809.
2024-10-08[libomp][AIX] Use SO version "1" for AIX libomp (#111384)Xing Xue1-5/+10
For `libomp` on AIX, we build shared object `libomp.so` first and then archive it into libomp.a. This patch changes to use SO version `1` and name the shared object `libomp.so.1` so that it is consistent with the naming of other shared objects in AIX libraries, e.g., `libc++.so.1` in `libc++.a`. With this change, the change made in commit bde51d9b0d473447ea12fb14924f14ea167eec85 to ensure only `libomp.a` is published on AIX is no longer necessary and is removed.
2024-09-18[libomp][AIX] Ensure only libomp.a is published on AIX (#109016)Xing Xue1-1/+5
For `libomp` on AIX, we build shared object `libomp.so` first and then archive it into `libomp.a`. Due to a CMake for AIX problem, the install step also tries to publish `libomp.so`. While we use a script to build `libomp.a` out-of-tree for Clang and avoided the problem, this chokes the in-tree build for Flang. The issue will be reported to CMake but before a fixed CMake is available, this patch ensures only `libomp.a` is published.
2024-08-31[OpenMP] Support setting POSIX thread name on *BSD's and Solaris (#106489)Brad Smith1-2/+11
2024-08-15[OpenMP] Add support for pause with omp_pause_stop_tool (#97100)Hansang Bae6-3/+11
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-08-15[OpenMP] Miscellaneous small code improvements (#95603)Hansang Bae9-20/+32
Removes a few uninitialized variables, possible resource leaks, and redundant code.
2024-08-13[OpenMP] Rename worker threads for improved debuggability (#102065)HighW4y2H3ll1-0/+7
Rename the worker threads "openmp_worker" --------- Co-authored-by: h2h <h2h@meta.com> Co-authored-by: Matthias Braun <matze@braunis.de>
2024-08-13[OpenMP][AArch64] Fix branch protection in microtasks (#102317)Tulio Magno Quites Machado Filho1-0/+53
Start __kmp_invoke_microtask with PACBTI in order to identify the function as a valid branch target. Before returning, SP is authenticated. Also add the BTI and PAC markers to z_Linux_asm.S. With this patch, libomp.so can now be generated with DT_AARCH64_BTI_PLT when built with -mbranch-protection=standard. The implementation is based on the code available in compiler-rt.
2024-08-11[openmp][runtime] Silence warningsAlexandre Ganea1-1/+2
This fixes several of those when building with MSVC on Windows: ``` [3625/7617] Building CXX object projects\openmp\runtime\src\CMakeFiles\omp.dir\kmp_affinity.cpp.obj C:\src\git\llvm-project\openmp\runtime\src\kmp_affinity.cpp(2637): warning C4062: enumerator 'KMP_HW_UNKNOWN' in switch of enum 'kmp_hw_t' is not handled C:\src\git\llvm-project\openmp\runtime\src\kmp.h(628): note: see declaration of 'kmp_hw_t' ```
2024-08-07[openmp][WebAssembly] Allow openmp to compile and run under emscripten ↵arsnyder163-23/+9
toolchain (#95169) * Separate wasi and emscripten as they have different constraints and abilities * Emscripten mimics Linux/POSIX by statically linking the musl runtime. This allow nearly all KMP_OS_LINUX code paths to work correctly. There are only a few places that need to be adjusted related to dynamic linking (dl_open) * Internally link openmp globals * With CommonLinkage it is needed to emit them in an assembly file, now they are defined and used within each compilation unit * With ExternalLinkage they suffer from duplicate symbols during linking for unnamed globals like reduction/critical * Interestingly this aligns with the TODO comment above this code
2024-07-29[OpenMP] Assign thread ids in the cpuinfo topology method (#91013)Jonathan Peyton1-0/+26
On non-hyperthreaded machines, the thread id is not always explicit in the /proc/cpuinfo file. This patch adds a check to ensure the thread ids are put in.
2024-07-29[OpenMP] Add topology and affinity changes for Meteor Lake (#91012)Jonathan Peyton2-115/+383
These are Intel-specific changes for the CPUID leaf 31 method for detecting machine topology. * Cleanup known levels usage in x2apicid topology algorithm Change to be a constant mask of all Intel topology type values. * Take unknown ids into account when sorting them If a hardware id is unknown, then put further down the hardware thread list so it will take last priority when assigning to threads. * Have sub ids printed out for hardware thread dump * Add caches to topology New` kmp_cache_ids_t` class helps create cache ids which are then put into the topology table after regular topology type ids have been put in. * Allow empty masks in place list creation Have enumeration information and place list generation take into account that certain hardware threads may be lacking certain layers * Allow different procs to have different number of topology levels Accommodates possible situation where CPUID.1F has different depth for different hardware threads. Each hardware thread has a topology description which is just a small set of its topology levels. These descriptions are tracked to see if the topology is uniform or not. * Change regular ids with logical ids Instead of keeping the original sub ids that the x2apicid topology detection algorithm gives, change each id to its logical id which is a number: [0, num_items - 1]. This makes inserting new layers into the topology significantly simpler. * Insert caches into topology This change takes into account that most topologies are uniform and therefore can use the quicker method of inserting caches as equivalent layers into the topology.
2024-07-24[OpenMP][libomp] Fix tasking debug assert (#95823)Jonathan Peyton1-1/+1
The debug assert is meant to check that the index is a valid which means the runtime needs to check against the size of the array instead of the number of threads. A free()-ed thread put back in the thread pool may index into anywhere inside the task team's available array from 0 to tt_max_threads potentially. Fixes: #94260
2024-07-16[OpenMP] Use new OMPT state and sync kinds for barrier events (#95602)Hansang Bae5-31/+66
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-05[openmp] Silence warning when building the x64 Windows LLVM release packageAlexandre Ganea1-1/+3
This fixes: ``` MASM : warning A4018:invalid command-line option : -U_GLIBCXX_ASSERTIONS ```
2024-07-03[OpenMP] Add ompt_start_tool declaration in omp-tools.h (#97099)Hansang Bae1-0/+8
The function ompt_start_tool is a globally-visible C function according to the specification.
2024-07-03[OpenMP][OMPT] Indicate loop schedule for worksharing-loop events (#97429)Joachim4-8/+28
Use more specific values from `ompt_work_t` to allow the tool identify the schedule of a worksharing-loop. With this patch, the runtime will report the schedule chosen by the runtime rather than necessarily the schedule literally requested by the clause. E.g., for guided + just one iteration per thread, the runtime would choose and report static. Fixes issue #63904
2024-07-02[OpenMP] Add missing export for dynamic tracking patch (#97419)Gheorghe-Teodor Bercea1-0/+1
Add missing export for OpenMP non-offloading builds.
2024-07-01[OpenMP] [OMPT] Callback registration should not depend on the device init ↵dhruvachak1-16/+10
callback. (#96371) Even if the device init callback is not registered, a tool should be allowed to register other callbacks.
2024-07-01[OpenMP][offload] Fix dynamic schedule tracking (#97065)Gheorghe-Teodor Bercea2-0/+7
This patch fixes the dynamic schedule tracking.
2024-06-24[OpenMP] Add num_threads clause list format and strict modifier support (#85466)Terry Wilmarth4-20/+205
Add support to the runtime for 6.0 spec features that allow num_threads clause to take a list, and also make use of the strict modifier. Provides new compiler interface functions for these features.
2024-06-20[OpenMP][libomp] Remove Perl in favor of Python (#95307)Jonathan Peyton1-14/+13
* Removes all Perl scripts and modules * Adds Python3 scripts which mimic the behavior of the Perl scripts * Removes Perl from CMake; Adds Python3 requirement to CMake * The check-instruction-set.pl script is Knights Corner specific. The script is removed and not replicated with a corresponding Python3 script. Relevant Discourse: https://discourse.llvm.org/t/error-compiling-clang-with-offloading-support/79223/4 Fixes: https://github.com/llvm/llvm-project/issues/62289
2024-06-04[OpenMP][OMPT] Add missing callbacks for asynchronous target tasks (#93472)Joachim6-15/+29
- The first hidden-helper-thread did not trigger thread-begin - The "detaching" from a target-task when waiting for completion missed to call task-switch - Target tasks identified themself as explicit task Co-authored-by: Kaloyan Ignatov <kaloyan.ignatov@rwth-aachen.de>
2024-06-03Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)" (#94139)Shilei Tian1-8/+60
2024-05-29[OpenMP] Fix multiply installing `libomp.so` (#93685)Joseph Huber1-0/+1
Summary: The `add_llvm_library` interface handles installing the llvm libraries, however we want to do our own handling. Otherwise, this will install into the `./lib` location instead of the `./lib/<target>` one.
2024-05-26Revert "Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)""Shilei Tian1-60/+8
This reverts commit 7b4865582299294455bc816358fd88a9c6e5e0be.
2024-05-26Reapply "[OpenMP][OMPX] Add shfl_down_sync (#93311)"Shilei Tian1-8/+60
This reverts commit 9b31cc71d66064dfaf2afabf4a835211321bb4a0.
2024-05-25[openmp] Revise IDE folder structure (#89750)Michael Kruse1-0/+7
Update the folder titles for targets in the monorepository that have not seen taken care of for some time. These are the folders that targets are organized in Visual Studio and XCode (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE generator. * Ensure that every target is in a folder * Use a folder hierarchy with each LLVM subproject as a top-level folder * Use consistent folder names between subprojects * When using target-creating functions from AddLLVM.cmake, automatically deduce the folder. This reduces the number of `set_property`/`set_target_property`, but are still necessary when `add_custom_target`, `add_executable`, `add_library`, etc. are used. A LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root CMakeLists.txt.
2024-05-24Revert "[OpenMP][OMPX] Add shfl_down_sync (#93311)"Joseph Huber1-60/+8
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 Tian1-8/+8
2024-05-24[OpenMP][OMPX] No default argument for C APIShilei Tian1-1/+1
2024-05-24[OpenMP][OMPX] Add shfl_down_sync (#93311)Shilei Tian1-0/+52
2024-05-24[OpenMP][OMPX] Add ballot_sync (#91297)Shilei Tian1-0/+12
This patch adds the support for `ballot_sync` in ompx.
2024-05-15[OpenMP] Fix intermediate header locations for OpenMPJoseph Huber1-3/+2
Summary: A previous patch moved the code here and accidentally overrwrote the include path that the LSP interface used. This caused incorrect errors when using clangd with the offload project. This patch removes the unnecessary header and makes sure we include the correct folder.
2024-05-10[OpenMP][AIX] Implement __kmp_get_load_balance() for AIX (#91520)Xing Xue1-9/+74
AIX has the `/proc` filesystem where `/proc/<pid>/lwp/<tid>/lwpsinfo` has the thread state in binary, similar to Linux's `/proc/<pid>/task/<tid>/stat` where the state is in ASCII. However, the definition of state info `R` in `lwpsinfo` is `runnable`. In Linux, state `R` means the thread is `running`. Therefore, `lwpsinfo` is not ideal for our purpose of getting the current load of the system. This patch uses `perfstat_cpu()` in AIX system library `libperfstat.a` to obtain the number of threads current running on logical CPUs.
2024-05-09[OpenMP] [Flang] Resolved Issue llvm#76121: Implemented Check for Unhandled ↵chandan singh1-0/+4
Arguments in __kmpc_fork_call_if (#82221) Root cause: Segmentation fault is caused by null pointer dereference inside the __kmpc_fork_call_if function at https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/z_Linux_asm.S#L1186 . __kmpc_fork_call_if is missing case to handle argc=0 . Fix: Added a check inside the __kmp_invoke_microtask function to handle the case when argc is 0. --------- Co-authored-by: Singh <chasingh@amd.com>
2024-05-08[OpenMP] Fix child processes to use affinity_none (#91391)Jonathan Peyton1-0/+2
When a child process is forked with OpenMP already initialized, the child process resets its affinity mask and sets proc-bind-var to false so that the entire original affinity mask is used. This patch corrects an issue with the affinity initialization code setting affinity to compact instead of none for this special case of forked children. The test trying to catch this only testing explicit setting of KMP_AFFINITY=none. Add test run for no KMP_AFFINITY setting. Fixes: #91098
2024-05-07[OpenMP] Fix task state and taskteams for serial teams (#86859)Jonathan Peyton5-236/+191
* Serial teams now use a stack (similar to dispatch buffers) * Serial teams always use `t_task_team[0]` as the task team and the second pointer is a next pointer for the stack `t_task_team[1]` is interpreted as a stack of task teams where each level is a nested level ``` inner serial team outer serial team [ t_task_team[0] ] -> (task_team) [ t_task_team[0] ] -> (task_team) [ next ] ----------------> [ next ] -> ... ``` * Remove the task state memo stack from thread structure. * Instead of a thread-private stack, use team structure to store th_task_state of the primary thread. When coming out of a parallel, restore the primary thread's task state. The new field in the team structure doesn't cause sizeof(team) to change and is in the cache line which is only read/written by the primary thread. Fixes: #50602 Fixes: #69368 Fixes: #69733 Fixes: #79416
2024-05-06[NFC][OpenMP][OMPX] Move `declare variant` upShilei Tian1-1/+4
2024-04-30[OpenMP][AIX] Implement __kmp_is_address_mapped() for AIX (#90516)Xing Xue1-4/+45
This patch implements `__kmp_is_address_mapped()` for AIX by calling `loadquery()` to get the load info of the process and then checking if the address falls within the range of the data segment of one of the loaded modules.
2024-04-26[OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)Xing Xue2-9/+3
This patch changes to use system call `syssmt()` instead of `lpar_get_info()` to get the number of SMTs (logical processors) per physical processor for AIX. `lpar_get_info()` gives the max number of SMTs that the physical processor can support while `syssmt()` returns the number that is currently configured.
2024-04-22[Offload] Move `/openmp/libomptarget` to `/offload` (#75125)Johannes Doerfert1-1/+7
In a nutshell, this moves our libomptarget code to populate the offload subproject. With this commit, users need to enable the new LLVM/Offload subproject as a runtime in their cmake configuration. No further changes are expected for downstream code. Tests and other components still depend on OpenMP and have also not been renamed. The results below are for a build in which OpenMP and Offload are enabled runtimes. In addition to the pure `git mv`, we needed to adjust some CMake files. Nothing is intended to change semantics. ``` ninja check-offload ``` Works with the X86 and AMDGPU offload tests ``` ninja check-openmp ``` Still works but doesn't build offload tests anymore. ``` ls install/lib ``` Shows all expected libraries, incl. - `libomptarget.devicertl.a` - `libomptarget-nvptx-sm_90.bc` - `libomptarget.rtl.amdgpu.so` -> `libomptarget.rtl.amdgpu.so.18git` - `libomptarget.so` -> `libomptarget.so.18git` Fixes: https://github.com/llvm/llvm-project/issues/75124 --------- Co-authored-by: Saiyedul Islam <Saiyedul.Islam@amd.com>
2024-04-16[OpenMP] Use a memory fence before incrementing the dispatch buffer index ↵Xing Xue1-0/+2
(#87995) This patch uses a memory fence in function `__kmp_dispatch_next()` to flush pending memory write invalidates before incrementing the `volatile` variable `buffer_index` to fix intermittent time-outs of OpenMP runtime LIT test cases `env/kmp_set_dispatch_buf.c` and `worksharing/for/kmp_set_dispatch_buf.c`, noting that the same is needed for incrementing `buffer_index` in function `__kmpc_next_section()` (line 2600 of `kmp_dispatch.cpp`).