aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime
AgeCommit message (Collapse)AuthorFilesLines
9 days[OpenMP] Support setting POSIX thread name on *BSD's and Solaris (#106489)Brad Smith3-7/+15
2024-08-15[OpenMP] Add support for pause with omp_pause_stop_tool (#97100)Hansang Bae7-3/+55
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)HighW4y2H3ll3-0/+14
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 Peyton3-1/+118
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-19[Clang][OpenMP] Add interchange directive (#93022)Michael Kruse5-0/+922
Add the interchange directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-07-18[Clang][OpenMP] Add reverse directive (#92916)Michael Kruse5-0/+687
Add the reverse directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf). --------- Co-authored-by: Alexey Bataev <a.bataev@outlook.com>
2024-07-16[OpenMP] Use new OMPT state and sync kinds for barrier events (#95602)Hansang Bae24-507/+443
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)Joachim23-215/+199
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-28[OpenMP] Fix test omp_parallel_num_threads_list.c to require fewer threads. ↵Terry Wilmarth1-14/+14
(#96916) Original test case used too many threads for some environments. This update reduces to a max of 36 threads.
2024-06-24[OpenMP] Add num_threads clause list format and strict modifier support (#85466)Terry Wilmarth6-20/+520
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 Peyton20-5618/+987
* 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 Kruse2-0/+12
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-22[Clang][OpenMP] Enable tile/unroll on iterator- and foreach-loops (#91459)Michael Kruse12-0/+1493
OpenMP loop transformation did not work on a for-loop using an iterator or range-based for-loops. The first reason is that it combined the iterator's type for generated loops with the type of `NumIterations` as generated for any `OMPLoopBasedDirective` which is an integer. Fixed by basing all generated loop variables on `NumIterations`. Second, C++11 range-based for-loops include syntactic sugar that needs to be executed before the loop. This additional code is now added to the construct's Pre-Init lists. Third, C++20 added an initializer statement to range-based for-loops which is also added to the pre-init statement. PreInits used to be a `DeclStmt` which made it difficult to add arbitrary statements from `CXXRangeForStmt`'s syntactic sugar, especially the for-loops init statement which does not need to be a declaration. Change it to be a general `Stmt` that can be a `CompoundStmt` to hold arbitrary Stmts, including DeclStmts. This also avoids the `PointerUnion` workaround used by `checkTransformableLoopNest`. End-to-end tests are added to verify the expected number and order of loop execution and evaluations of expressions (such as iterator dereference). The order and number of evaluations of expressions in canonical loops is explicitly undefined by OpenMP but checked here for clarification and for changes to be noticed.
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-13[Clang][OpenMP][Tile] Allow non-constant tile sizes. (#91345)Michael Kruse3-0/+335
Allow non-constants in the `sizes` clause such as ``` #pragma omp tile sizes(a) for (int i = 0; i < n; ++i) ``` This is permitted since tile was introduced in [OpenMP 5.1](https://www.openmp.org/spec-html/5.1/openmpsu53.html#x78-860002.11.9). It is possible to sneak-in negative numbers at runtime as in ``` int a = -1; #pragma omp tile sizes(a) ``` Even though it is not well-formed, it should still result in every loop iteration to be executed exactly once, an invariant of the tile construct that we should ensure. `ParseOpenMPExprListClause` is extracted-out to be reused by the `permutation` clause of the `interchange` construct. Some care was put into ensuring correct behavior in template contexts.
2024-05-10[OpenMP][AIX] Implement __kmp_get_load_balance() for AIX (#91520)Xing Xue2-12/+80
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 singh2-0/+40
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 Peyton2-0/+3
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 Peyton11-236/+792
* 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-19[OpenMP] Use half of available logical processors for collapse tests (#88319)Xing Xue1-6/+16
The new collapse test cases define `MAX_THREADS` to be 256 and use all available threads/logical processors on the system. This triples the testing time on an AIX machine that has 128 logical processors. This patch changes to use half of available logical processors to avoid over subscribing because there are other libomp tests running at the same time, including 2 other such collapse tests.
2024-04-16[OpenMP][test][AIX] Make 64 the max number of threads for capacity tests in ↵Xing Xue2-12/+28
AIX 32-bit (#88739) This patch makes 64 the max number of threads for 2 capacity tests in AIX 32-bit mode rather than `XFAIL`ing them.
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`).
2024-04-12[OpenMP] Fix re-locking hang found in issue 86684 (#88539)Jonathan Peyton1-6/+6
This was initially reported here (including stacktraces): https://stackoverflow.com/questions/78183545/does-compiling-imagick-with-openmp-enabled-in-freebsd-13-2-cause-sched-yield If `__kmp_register_library_startup()` detects that another instance of the library is present, `__kmp_is_address_mapped()` is eventually called. which uses `kmpc_alloc()` to allocate memory. This function calls `__kmp_entry_thread()` to access the thread-local memory pool, which is a bad idea during initialization. This macro internally calls `__kmp_get_global_thread_id_reg()` which sets the bootstrap lock at the beginning (before calling `__kmp_register_library_startup()`). The fix is to use `KMP_INTERNAL_MALLOC()`/`KMP_INTERNAL_FREE()` instead of `kmpc_malloc()`/`kmpc_free()`. `KMP_INTERNAL_MALLOC` and `KMP_INTERNAL_FREE` do not use any bootstrap locks. They just translate to `malloc()`/`free()` and are meant to be used during library initialization before other library-specific allocators have been initialized. Fixes: #86684
2024-04-10[OpenMP][AIX] Fix test config for AIX (#88272)Xing Xue1-1/+3
This patch fixes the test config so that it works for `tasking/omp50_taskdep_depobj.c` which uses different flags to test with compiler's `omp.h`. * set test environment variable `OBJECT_MODE` to `64` if it is set explicitly to `64` in the AIX environment. `OBJECT_MODE` is default to `32` and is recognized by AIX compilers and toolchain. In this way, we don't need to set `-m64` for all compiler flags for 64-bit mode * add option `-Wl,-bmaxdata` to 32-bit `test_openmp_flags` used by `tasking/omp50_taskdep_depobj.c`
2024-04-09[Libomp] Place generated OpenMP headers into build resource directory (#88007)Joseph Huber1-9/+17
Summary: These headers are a part of the compiler's resource directory once installed. However, they are currently placed in the binary directory temporarily. This makes it more difficult to use the compiler out of the build directory and will cause issues when moving to `liboffload`. This patch changes the logic to write these instead to the copmiler's resource directory inside of the build tree. NOTE: This doesn't change the Fortran headers, I don't know enough about those and it won't use the same directory.