aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime
AgeCommit message (Collapse)AuthorFilesLines
2 days[OpenMP] Clean-up Fortran testsMichael Kruse4-7/+10
* Use "do" for DO loops, there is no "for" in Fortran and it is always integer * Add -cpp to not rely on file name case * Add "implicit none" safety
5 days[OpenMP][test] .f90 -> .F90Michael Kruse1-0/+1
The test makes use of the preprocessor, which requires a .F90 suffix
5 days[Flang] Add standalone tile support (#160298)Michael Kruse3-0/+144
Add support for the standalone OpenMP tile construct: ```f90 !$omp tile sizes(...) DO i = 1, 100 ... ``` This is complementary to #143715 which added support for the tile construct as part of another loop-associated construct such as worksharing-loop, distribute, etc.
9 days[Clang][OpenMP][LoopTransformations] Implement "#pragma omp fuse" loop ↵Walter J.T.V5-0/+687
transformation directive and "looprange" clause (#139293) This change implements the fuse directive, `#pragma omp fuse`, as specified in the OpenMP 6.0, along with the `looprange` clause in clang. This change also adds minimal stubs so flang keeps compiling (a full implementation in flang of this directive is still pending). --------- Co-authored-by: Roger Ferrer Ibanez <roger.ferrer@bsc.es>
2025-09-20[OpenMP] Allow Fortran tests (#150722)Michael Kruse4-1/+50
In addition to existing C/C++ tests, add Fortran-based tests. Fortran tests will only run if a Fortran compiler is found. The first test is for the unroll construct added in #144785.
2025-09-15[OpenMP] [Tests] Update test broken by #157364 (#158751)Sirraide1-1/+6
Fix another test impacted by #157364. On Windows, `GetComputerNameA()`, which is what this ends up calling, takes an `LPDWORD`, but we were handing it an `int*`; fix this by declaring it as a `DWORD` instead.
2025-08-30[OpenMP] Use Clang resource dir only in bootstrapping build (#156018)Michael Kruse1-4/+5
In an LLVM_ENABLE_PROJECTS=openmp build, the LLVM build tree in which just-built Clang is available, but in contrast to an LLVM_ENABLE_RUNTIMES=openmp build, is not the compiler that openmp is built with (CMAKE_CXX_COMPILER). The latter compiler (which might also be gcc) will not look into the resource directory of just-built Clang, where the OpenMP headers are installed. There may not even be a just-built Clang without LLVM_ENABLE_PROJECTS=clang. We cannot add the OpenMP header output directory to the search path which also include's Clang's internal headers that will conflict with CMAKE_CXX_COMPILER's internal headers. The only choice left is to use what the OpenMP standalone build does: Use CMAKE_CURRENT_BINARY_DIR which is added unconditionally to the header search path to compile openmp itself.
2025-08-28Revert "[OpenMP][clang] 6.0: num_threads strict (part 3: codegen)" (#155809)Robert Imschweiler1-1/+0
Reverts llvm/llvm-project#146405
2025-08-28[OpenMP][clang] 6.0: num_threads strict (part 3: codegen) (#146405)Robert Imschweiler1-0/+1
OpenMP 6.0 12.1.2 specifies the behavior of the strict modifier for the num_threads clause on parallel directives, along with the message and severity clauses. This commit implements necessary codegen changes.
2025-08-27[Flang-RT][OpenMP] Define _GLIBCXX_NO_ASSERTIONS (#155440)Michael Kruse1-0/+1
Since GCC 15.1, libstdc++ enabled assertions/hardening by default in non-optimized (-O0) builds [1]. That is, _GLIBCXX_ASSERTIONS is defined in the libstdc++ headers itself so defining/undefining it on the compiler command line no longer has an effect in non-optimized builds. As the commit message[2] suggests, define _GLIBCXX_NO_ASSERTIONS instead. For libstdc++ headers before 15.1, -U_GLIBCXX_ASSERTIONS still has to be on the command line as well. Defining _GLIBCXX_NO_ASSERTIONS was previously proposed in #152223 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112808 [2] https://github.com/gcc-mirror/gcc/commit/361d230fd7800a7e749aba8ed020f54f5c26d504
2025-08-21Revert "Fix Debug Build Using GCC 15" (#154877)dpalermo1-1/+1
Reverts llvm/llvm-project#152223
2025-08-21Fix Debug Build Using GCC 15 (#152223)Patrick Simmons1-1/+1
Flang currently doesn't build in debug mode on GCC 15 due to missing dynamic libraries in some CMakeLists.txt files, and OpenMP doesn't link in debug mode due to the atomic library pulling in libstdc++ despite an incomplete attempt in the CMakeLists.txt to disable glibcxx assertions. This PR fixes these issues and allows Flang and the OpenMP runtime to build and link on GCC 15 in debug mode. --------- Co-authored-by: ronlieb <ron.lieberman@amd.com>
2025-08-20[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)David Tenty4-7/+7
A CMake change included in CMake 4.0 makes `AIX` into a variable (similar to `APPLE`, etc.) https://gitlab.kitware.com/cmake/cmake/-/commit/ff03db6657c38c8cf992877ea66174c33d0bcb0b However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to `AIX` and `if` auto-expands variable names in CMake. That means you get a double expansion if you write: `if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")` which becomes: `if (AIX MATCHES "AIX")` which is as if you wrote: `if (ON MATCHES "AIX")` You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}", due to policy [CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054) which is on by default in 4.0+. Most of the LLVM CMake already does this, but this PR fixes the remaining cases where we do not.
2025-08-18[OpenMP][Test][NFC] output tool data as hex to improve readibility (#152757)Joachim108-1630/+1827
Using hex format allows to better interpret IDs: the first digits represent the thread number, the last digits represent the ID within a thread The main change is in callback.h: PRIu64 -> PRIx64 The patch also guards RUN/CHECK lines in openmp/runtime/tests/ompt with clang-format on/off comments and clang-formats the directory. --------- Co-authored-by: Kaloyan Ignatov <kaloyan.ignatov@rwth-aachen.de>
2025-08-14[OpenMP] Update printf stmt in kmp_settings.cpp (#152800)CatherineMoore1-2/+2
Remove extraneous argument from printf statement --------- Co-authored-by: Joachim <protze@rz.rwth-aachen.de>
2025-08-06[OFFLOAD][OPENMP] 6.0 compatible interop interface (#143491)Alex Duran4-0/+59
The following patch introduces a new interop interface implementation with the following characteristics: * It supports the new 6.0 prefer_type specification * It supports both explicit objects (from interop constructs) and implicit objects (from variant calls). * Implements a per-thread reuse mechanism for implicit objects to reduce overheads. * It provides a plugin interface that allows selecting the supported interop types, and managing all the backend related interop operations (init, sync, ...). * It enables cooperation with the OpenMP runtime to allow progress on OpenMP synchronizations. * It cleanups some vendor/fr_id mismatchs from the current query routines. * It supports extension to define interop callbacks for library cleanup.
2025-07-26[OpenMP] Update %preload-tool definition on DarwinAiden Grossman1-1/+1
This was updated in some earlier commits but was never updated on Darwin because I was testing locally on Linux and it does not seem like there are any buildbots testing this configuration. Update it since it should be trivial and will definitely be broken otherwise.
2025-07-26[OpenMP] Move tool tests out of individual folders (#150780)Aiden Grossman3-0/+0
I did not realize that these were originally in separate folders to allow for the use of %T. Now that we have switched over to creating dirs using %t, we can move these into a common folder and make things a little bit more clean.
2025-07-26[OpenMP] Fix tool tests 9475ed84909463ad594602dd76583f4ff12efcd0Aiden Grossman1-1/+1
These were still passing because I did not clear all the test artifacts in between so the old ones were still present after updating the test. I forgot to update a lit substitution which failed on clean builds.
2025-07-25[OpenMP] Remove uses of %T from lit tests (#150723)Aiden Grossman3-24/+29
This patch removes all uses of %T from lit tests in OpenMP. %T has been deprecated for years and is not reccomended given it does not create a unique dir per test, allowing for race conditions. Remove uses of %T in OpenMP so we can eventually remove support for it in llvm-lit.
2025-07-26[OpenMP] Fix runtimes default build (#149871)Michael Kruse1-1/+1
The default build of openmp (`cmake -S <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=openmp`) current fails with ``` CMake Error at /home/meinersbur/src/llvm/flangrt/_src/cmake/Modules/GetClangResourceDir.cmake:17 (string): string sub-command REGEX, mode MATCH needs at least 5 arguments total to command. Call Stack (most recent call first): /home/meinersbur/src/llvm/flangrt/_src/openmp/CMakeLists.txt:126 (get_clang_resource_dir) ``` The reason is that because it is not a bootstrapping-build, the clang resource dir that it intends to write files such as `omp-tools.h` into, is unavailable. Using the Clang resource dir for writing files is conceptually broken, as that dir might be located in `/usr/lib/clang/<version>/`. Writing to it is only intended in bootstrapping builds where Clang is built alongside openmp. This patch unifies the identification of being in a bootstrapping built. The same `LLVM_TREE_AVAILABLE` definition is going to be used in #137828. No reason for each runtime to define its own.
2025-07-21[OpenMP] Fixup bugs found during fuzz testing (#143455)Jonathan Peyton13-77/+210
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-07-21[OpenMP] [NFC] Remove KMP_NESTED_HOT_TEAMS macro (#143584)Jonathan Peyton5-126/+52
The feature was introduced back in 2014 and has been on ever since. Leave the feature in place. Removing only the macro.
2025-07-21[OpenMP] Improve performance of ticket lock (x86) (#143557)Jonathan Peyton1-7/+0
Ticket lock has a yield operation (shown below) which degrades performance on larger server machines due to an unconditional pause operation. ``` #define KMP_YIELD(cond) \ { \ KMP_CPU_PAUSE(); \ if ((cond) && (KMP_TRY_YIELD)) \ __kmp_yield(); \ } ```
2025-07-18[OpenMP] [NFC] Remove dead code: building task stack (#143589)Jonathan Peyton2-281/+1
This code hasn't been enabled since the first code changes were introduced. Remove the dead code.
2025-07-08Reland: [OpenMP][clang] 6.0: num_threads strict (part 1: host runtime) (#147532)Robert Imschweiler1-0/+6
OpenMP 6.0 12.1.2 specifies the behavior of the strict modifier for the num_threads clause on parallel directives, along with the message and severity clauses. This commit implements necessary host runtime changes. Reland https://github.com/llvm/llvm-project/pull/146403. After manual testing on a gfx90a machine, I could not reproduce the failing test, which makes it even more likely that the test has just been flaky. (Or at least that it's not an issue related to this patch.)
2025-07-08[OpenMP] OpenMP ThreadSet clause - basic runtime (#144409)Ritanya-B-Bharadwaj1-6/+9
Initial runtime support for threadset clause in task and taskloop directives [Section 14.8 in in OpenMP 6.0 spec] Frontend PR- https://github.com/llvm/llvm-project/pull/135807
2025-07-07Revert "[OpenMP][clang] 6.0: num_threads strict (part 1: host runtime)" ↵Robert Imschweiler1-6/+0
(#147379) Reverts llvm/llvm-project#146403
2025-07-07[OpenMP][clang] 6.0: num_threads strict (part 1: host runtime) (#146403)Robert Imschweiler1-0/+6
OpenMP 6.0 12.1.2 specifies the behavior of the strict modifier for the num_threads clause on parallel directives, along with the message and severity clauses. This commit implements necessary host runtime changes.
2025-07-03Drop timestamp in generated source code (#146822)Bernhard M. Wiedemann1-3/+1
Fixes #72206 This helps reproducible builds of libomp.so -- probably because LLVM's LTO computed a hash of inputs to generate its symbol names. note: if it is desired to keep the timestamp, we could instead use [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/docs/source-date-epoch/) to make it deterministic. This PR was done while working on [reproducible builds for openSUSE](https://en.opensuse.org/openSUSE:Reproducible_Builds).
2025-06-27[OpenMP][test][NFC] Temporarily disabling failing testJoachim Jenke1-1/+4
The test added with PR #145625 fails with certain build configurations of libomp, disabling the test until the issue in the runtime is fixed.
2025-06-25[OpenMP] Fix various alignment issues (#142376)Rainer Orth3-6/+6
When running the `openmp` testsuite on 32-bit SPARC, several tests `FAIL` apparently randomly, but always with the same kind of error: ``` # error: command failed with exit status: -11 ``` The tests die with `SIGBUS`, as can be seen in `truss` output: ``` 26461/1: Incurred fault #5, FLTACCESS %pc = 0x00010EAC 26461/1: siginfo: SIGBUS BUS_ADRALN addr=0x0013D12C 26461/1: Received signal #10, SIGBUS [default] 26461/1: siginfo: SIGBUS BUS_ADRALN addr=0x0013D12C ``` i.e. the code is trying an unaligned access which cannot work on SPARC, a strict-alignment target which enforces natural alignment on access. This explains the apparent randomness of the failures: if the memory happens to be aligned appropriately, the tests work, but fail if not. A `Debug` build reveals much more: - `__kmp_alloc` currently aligns to `sizeof(void *)`, which isn't enough on strict-alignment targets when the data are accessed as types requiring larger alignment. Therefore, this patch increases `alignment` to `SizeQuant`. - 32-bit Solaris/sparc `libc` guarantees 8-byte alignment from `malloc`, so this patch adjusts `SizeQuant` to match. - There's a `SIGBUS` in ``` __kmpc_fork_teams (loc=0x112f8, argc=0, microtask=0x16cc8 <__omp_offloading_ffbc020a_4b1abe_main_l9_debug__.omp_outlined>) at openmp/runtime/src/kmp_csupport.cpp:573 573 *(kmp_int64 *)(&this_thr->th.th_teams_size) = 0L; ``` Casting to a pointer to a type requiring 64-bit alignment when that isn't guaranteed is wrong. Instead, this patch uses `memset` instead. - There's another `SIGBUS` in ``` 0xfef8cb9c in __kmp_taskloop_recur (loc=0x10cb8, gtid=0, task=0x23cd00, lb=0x23cd18, ub=0x23cd20, st=1, ub_glob=499, num_tasks=100, grainsize=5, extras=0, last_chunk=0, tc=500, num_t_min=20, codeptr_ra=0xfef8dbc8 <__kmpc_taskloop(ident_t*, int, kmp_task_t*, int, kmp_uint64*, kmp_uint64*, kmp_int64, int, int, kmp_uint64, void*)+240>, task_dup=0x0) at openmp/runtime/src/kmp_tasking.cpp:5147 5147 p->st = st; ``` `p->st` doesn't currently guarantee the 8-byte alignment required by `kmp_int64 st`. `p` is set in ``` __taskloop_params_t *p = (__taskloop_params_t *)new_task->shareds; ``` but `shareds_offset` is currently aligned to `sizeof(void *)` only. Increasing it to `sizeof(kmp_uint64)` to match its use fixes the `SIGBUS`. With these fixes I get clean `openmp` test results on 32-bit SPARC (both Solaris and Linux), with one unrelated exception. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
2025-06-25 [OpenMP] avoid segv for a lock that has already been destroyed (#145625)Larry Meadows2-0/+42
This can happen in static destructors when called after the runtime is already shutdown (e.g., by ompt_finalize_tool). Even though it is technically an error to call omp_destroy_lock after shutdown, the application doesn't necessarily know that omp_destroy_lock was already called. This is safe becaues all indirect locks are destoryed in __kmp_cleanup_indirect_user_locks so the return value will always be valid or a nullptr, not garbage.
2025-06-13[OpenMP] Remove declaration and usage of __AMDGCN_WAVEFRONT_SIZE (#143761)nicebert1-5/+13
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 Zaizhou1-1/+1
(#142990)
2025-06-11LLVM Buildbot failure on openmp runtime test (#143674)CHANDRA GHALE1-31/+3
Error looks to be missing includes for complex number support in some system. Removing test for now. Relevant PR : [PR-134709](https://github.com/llvm/llvm-project/pull/134709) ``` .---command stderr------------ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:78:42: error: use of undeclared identifier 'I' # | 78 | double _Complex expected = 0.0 + 0.0 * I; # | | ^ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:79:40: error: use of undeclared identifier 'I' # | 79 | double _Complex result = 0.0 + 0.0 * I; # | | ^ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:84:22: error: use of undeclared identifier 'I' # | 84 | arr[i] = i - i * I; # | | ^ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:92:19: error: use of undeclared identifier 'creal' # | 92 | real_sum += creal(arr[i]); # | | ^~~~~ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:93:19: error: use of undeclared identifier 'cimag' # | 93 | imag_sum += cimag(arr[i]); # | | ^~~~~ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:96:36: error: use of undeclared identifier 'I' # | 96 | result = real_sum + imag_sum * I; # | | ^ # | /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/worksharing/for/omp_for_private_reduction.cpp:97:9: error: use of undeclared identifier 'cabs' # | 97 | if (cabs(result - expected) > 1e-6) { # | | ^~~~ # | 7 errors generated. ``` Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-06-11[OpenMP 6.0 ]Codegen for Reduction over private variables with reduction ↵CHANDRA GHALE1-0/+194
clause (#134709) Codegen support for reduction over private variable with reduction clause. Section 7.6.10 in in OpenMP 6.0 spec. - An internal shared copy is initialized with an initializer value. - The shared copy is updated by combining its value with the values from the private copies created by the clause. - Once an encountering thread verifies that all updates are complete, its original list item is updated by merging its value with that of the shared copy and then broadcast to all threads. Sample Test Case from OpenMP 6.0 Example ``` #include <assert.h> #include <omp.h> #define N 10 void do_red(int n, int *v, int &sum_v) { sum_v = 0; // sum_v is private #pragma omp for reduction(original(private),+: sum_v) for (int i = 0; i < n; i++) { sum_v += v[i]; } } int main(void) { int v[N]; for (int i = 0; i < N; i++) v[i] = i; #pragma omp parallel num_threads(4) { int s_v; // s_v is private do_red(N, v, s_v); assert(s_v == 45); } return 0; } ``` Expected Codegen: ``` // A shared global/static variable is introduced for the reduction result. // This variable is initialized (e.g., using memset or a UDR initializer) // e.g., .omp.reduction.internal_private_var // Barrier before any thread performs combination call void @__kmpc_barrier(...) // Initialization block (executed by thread 0) // e.g., call void @llvm.memset.p0.i64(...) or call @udr_initializer(...) call void @__kmpc_critical(...) // Inside critical section: // Load the current value from the shared variable // Load the thread-local private variable's value // Perform the reduction operation // Store the result back to the shared variable call void @__kmpc_end_critical(...) // Barrier after all threads complete their combinations call void @__kmpc_barrier(...) // Broadcast phase: // Load the final result from the shared variable) // Store the final result to the original private variable in each thread // Final barrier after broadcast call void @__kmpc_barrier(...) ``` --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-06-10[OpenMP][test] Support target= in tests (#142380)Rainer Orth2-1/+4
LLVM is moving towards the `target=<target triple RE>` syntax in `XFAIL: ` etc., and I'll need the same in a subsequent patch. This patch adds the necessary infrastructure. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
2025-06-07[OpenMP][cmake] Add SPARC support (#142364)Rainer Orth2-0/+10
This patch adds SPARC infrastructure to the `openmp` `cmake` files, matching what is done for other architectures. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
2025-06-05[OpenMP][cmake] Simplify -m32 handling (#142742)Rainer Orth1-10/+10
Linking `libomp.so` on 32-bit SPARC `FAIL`s with ``` ld: fatal: file projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_asm.S.o: wrong ELF class: ELFCLASS64 ``` This was a 1-stage build with a 64-bit-default `gcc`. Unlike the C++ sources, which were compiled as 32-bit objects due to the use of `-DCMAKE_CXX_FLAGS=-m32`, the assembler sources were not. This patch simplifies passing `-m32`: instead of doing it per architecture, `-m32` is now always passed when the target uses 32-bit pointers and supports the option. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
2025-06-04[OpenMP] Don't use libproc on Solaris (#142379)Rainer Orth2-23/+10
`openmp` currently doesn't compile on 32-bit Solaris: ``` FAILED: projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_util.cpp.o [...] In file included from openmp/runtime/src/z_Linux_util.cpp:78: In file included from /usr/include/libproc.h:25: In file included from /usr/include/gelf.h:10: /usr/include/libelf.h:22:2: error: "large files are not supported by libelf" 22 | #error "large files are not supported by libelf" | ^ In file included from openmp/runtime/src/z_Linux_util.cpp:78: /usr/include/libproc.h:42:2: error: "Cannot use libproc in the large file compilation environment" 42 | #error "Cannot use libproc in the large file compilation environment" | ^ ``` Looking closer, there's no point in using `Pgrab` (the only interface from `<libproc.h>`) at all: the resulting `ps_prochandle_t *` isn't used in the remainder of the code and the original PR #82930 gives no indication why it is deemed necessary/useful. While at it, this patch switches to use `/proc/self/xmap`, matching `compiler-rt`'s `sanitizer_procmaps_solaris.cpp`, and makes some minor formatting fixes. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `i386-pc-solaris2.11`, and `amd64-pc-solaris2.11`.
2025-05-15[OpenMP][test] Define print_possible_return_addresses on SPARC (#138523)Rainer Orth1-0/+8
Parts of the `openmp` testsuite currently don't build on SPARC due to the lack of a `print_possible_return_addresses` definition. This patch provides one. With it, the vast majority of tests `PASS` on Solaris/sparcv9 and, with an additional patch, on Linux/sparc64. The current definition was obtained empirically. Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
2025-05-14[OpenMP] Fix __builtin_return_address calls for SPARC (#138520)Rainer Orth2-4/+6
`libomp` uses `__builtin_return_address` in two places. However, on some targets those calls need to wrapped in `___builtin_extract_return_addr` to get at the actual return address. SPARC is among those targets and the only one where `clang` actually implements this, cf. [[clang][Sparc] Fix __builtin_extract_return_addr etc.](https://reviews.llvm.org/D91607). `compiler-rt` needed the same adjustment, cf. [[sanitizer_common][test] Enable tests on SPARC](https://reviews.llvm.org/D91608). On other targets, this is a no-op. However, there are more targets that have the same issue and `gcc`, unlike `clang`, correctly implements it, so there might be issues when building `libomp` with `gcc`. This patch adds the necessary calls. Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
2025-05-10[OpenMP][test] Adjust tool_available_search.c for Solaris (#138515)Rainer Orth1-3/+3
After PR #138514, only 3 testsuite failures remain on Solaris/amd64. One of them is ``` libomp :: ompt/loadtool/tool_available_search/tool_available_search.c ``` The issue is that the expected message is that emitted by Linux/glibc, while the Solaris message differs: On Linux/x86_64, I get ``` Opening projects/openmp/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so... Failed: projects/openmp/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so: cannot open shared object file: No such file or directory ``` while Solaris/amd64 emits ``` Opening projects/openmp/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so... Failed: ld.so.1: tool_available_search.c.tmp: projects/openmp/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so: open failed: No such file or directory ``` Since the exact wording is obviously an implementation detail, this patch allows for both forms. Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
2025-05-10[OpenMP][test] Make %p 0x prefix optional (#138514)Rainer Orth64-374/+374
Testing `openmp` on Solaris/amd64 shows a large number of failures, all due to the same issue: ``` # .---command stderr------------ # | openmp/runtime/test/ompt/misc/interoperability.cpp:67:16: error: CHECK-SAME: expected string not found in input # | // CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}} # | ^ # | <stdin>:5:101: note: scanning from here # | 281474976710658: ompt_event_parallel_begin: parent_task_id=281474976710659, parent_task_frame.exit=0, parent_task_frame.reenter=7fffbedffe90, parallel_id=281474976710661, requested_team_size=2, codeptr_ra=408b8e, invoker=2 ``` The testsuite expects pointers to be printed with a `0x` prefix when using the `%p` format, while Solaris `libc` just prints them in hex without a prefix. However, this difference is completely benign. ISO C (up to C23, 7.23.6.1) states ``` p The argument shall be a pointer to void or a pointer to a character type. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner. ``` I saw two ways around this: - replace every instance of `%p` with a macro (`KMP_PTR_FMT`, defined as `"%p"` or `"0x%p" as appropriate), or - adjust the testsuite to make the `0x` prefix optional The second route seemed less intrusive and more readable, so that's what this patch does. While large, it's also completely mechanical. Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
2025-05-07[OpenMP] Fix __kmp_unnamed_critical_addr .type setting (#138815)Rainer Orth1-2/+2
PR #138517 broke the Android LLVM builders: ARM doesn't understand the `@object` form. As it turns out, one can use `%object` instead, which does assemble on all targets currently supported by `z_Linux_asm.S`. Tested by rebuilding `libomp.so` on `sparcv9-sun-solaris2.11`.
2025-05-06[OpenMP] Provide __NR_sched_[gs]etaffinity on Linux/sparc64 (#138525)Rainer Orth1-0/+11
`libomp` doesn't currently build on Linux/sparc64 due to lack of `__NR_sched_setaffinity` and `__NR_sched_getaffinity` definitions. This patch provides those. Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
2025-05-06[OpenMP] Provide __kmp_unnamed_critical_addr on SPARC (#138517)Rainer Orth1-4/+6
`libomp.so` currently fails to link on SPARC, both Solaris/sparcv9 and Linux/sparc64: ``` Undefined first referenced symbol in file __kmp_unnamed_critical_addr projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_gsupport.cpp.o ld: fatal: symbol referencing errors ``` This patch provides the necessary definition. While at it, I noticed that on non-x86 targets the symbol wasn't marked as `@object`, which this patch corrects, too. Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
2025-05-06[OpenMP] Use pthread_self for __kmp_gettid on Solaris (#138510)Rainer Orth1-1/+1
Building `openmp` on Solaris/amd64, I get ``` In file included from openmp/runtime/src/kmp_utility.cpp:16: openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings] 47 | #warning No gettid found, use getpid instead | ^ ``` There's no reason to do this: Solaris can use `pthread_self` just as AIX does. Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
2025-05-06[OpenMP] Use TLS for gtid on Solaris (#138508)Rainer Orth1-1/+1
When running the `openmp` testsuite on Solaris/amd64, many tests `FAIL` like ``` # | OMP: Error #11: Stack overflow detected for OpenMP thread #1 ``` In a `Debug` build, I also get ``` # | Assertion failure at kmp_runtime.cpp(203): __kmp_gtid_get_specific() < 0 || __kmp_gtid_get_specific() == i. ``` Further investigation shows that just setting `__kmp_gtid_mode` to 3 massively reduces the number of failures. Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.