summaryrefslogtreecommitdiff
path: root/openmp/runtime/src/kmp_gsupport.cpp
AgeCommit message (Collapse)Author
2025-04-01[OpenMP] allow openmp build for sparc (#133239)Petr Sumbera
2024-04-02[OpenMP] arm64_32 port for Apple WatchOS (#87246)nihui
detect `aarch64_32` with compiler defined macro `__ARM64_ARCH_8_32__` reuse ARM `__kmp_unnamed_critical_addr` and add `KMP_PREFIX_UNDERSCORE` macro like AARCH64 reuse AARCH64 `__kmp_invoke_microtask` build log for watchos armv7k + arm64_32 and watchos simulator x86_64 + arm64 https://github.com/nihui/action-protobuf/actions/runs/8520684611/job/23337305030
2024-02-13[OpenMP][AIX]Define struct kmp_base_tas_lock with the order of two members ↵Xing Xue
swapped for big-endian (#79188) The direct lock data structure has bit `0` (the least significant bit) of the first 32-bit word set to `1` to indicate it is a direct lock. On the other hand, the first word (in 32-bit mode) or first two words (in 64-bit mode) of an indirect lock are the address of the entry allocated from the indirect lock table. The runtime checks bit `0` of the first 32-bit word to tell if this is a direct or an indirect lock. This works fine for 32-bit and 64-bit little-endian because its memory layout of a 64-bit address is (`low word`, `high word`). However, this causes problems for big-endian where the memory layout of a 64-bit address is (`high word`, `low word`). If an address of the indirect lock table entry is something like `0x110035300`, i.e., (`0x1`, `0x10035300`), it is treated as a direct lock. This patch defines `struct kmp_base_tas_lock` with the ordering of the two 32-bit members flipped for big-endian PPC64 so that when checking/setting tags in member `poll`, the second word (the low word) is used. This patch also changes places where `poll` is not already explicitly specified for checking/setting tags.
2024-01-08[openmp][AIX]Initial changes for porting to AIX (#76841)Xing Xue
This PR contains initial changes for building and testing libomp on AIX. More changes will follow. - `KMP_OS_AIX` is defined for the AIX platform - `KMP_ARCH_PPC` is defined for 32-bit PPC - `KMP_ARCH_PPC_XCOFF` and `KMP_ARCH_PPC64_XCOFF` are for 32- and 64-bit XCOFF object formats respectively - Assembly file `z_AIX_asm.S` is used for AIX specific assembly code and will be added in a separate PR - The target library is disabled because AIX does not have the device support - OMPT is temporarily disabled
2023-12-15[OpenMP] Use simple VLA implementation to replace uses of actual VLAShilei Tian
Use of VLA can cause compile warning that was introduced in D156565. This patch implements a simple stack/heap-based VLA that can miminc the behavior of an actual VLA and prevent the warning. By default the stack accomodates the elements. If the number of emelements is greater than N, which by default is 8, a heap buffer will be allocated and used to acccomodate the elements.
2023-12-14[openmp][wasm] Allow compiling OpenMP to WebAssembly (#71297)Andrew Brown
This change allows building the static OpenMP runtime, `libomp.a`, as WebAssembly. It builds on the work done in [D142593] but goes further in several ways: - it makes the OpenMP CMake files more WebAssembly-aware - it conditions much more code (or code that had been refactored since [D142593]) for `KMP_ARCH_WASM` and `KMP_OS_WASI` - it fixes a Clang crash due to unimplemented common symbols in WebAssembly The commit messages have more details. Please understand this PR as a start, not the completed work, for WebAssembly support in OpenMP. Getting the tests running somehow would be a good next step, e.g.; but what is contained here works, at least with recent versions of [wasi-sdk] and engines that support [wasi-threads]. I suspect the same is true for Emscripten and browsers, but I have not tested that workflow. [D142593]: https://reviews.llvm.org/D142593 [wasi-sdk]: https://github.com/WebAssembly/wasi-sdk [wasi-threads]: https://github.com/WebAssembly/wasi-threads --------- Co-authored-by: Atanas Atanasov <atanas.atanasov@intel.com>
2023-11-30Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"Shilei Tian
This reverts commit 97e16da450e94c92456fa5a74768ec1b22fe6b63 because it causes build error on i386 system.
2023-11-28[OpenMP] Use simple VLA implementation to replace uses of actual VLAShilei Tian
Use of VLA can cause compile warning that was introduced in D156565. This patch implements a simple stack/heap-based VLA that can miminc the behavior of an actual VLA and prevent the warning. By default the stack accomodates the elements. If the number of emelements is greater than N, which by default is 8, a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA"Shilei Tian
This reverts commit d46f63553ab9ee041884b5306527afefaf00e144.
2023-11-28[OpenMP] Use simple VLA implementation to replace uses of actual VLAShilei Tian
Use of VLA can cause compile warning that was introduced in D156565. This patch implements a simple stack/heap-based VLA that can miminc the behavior of an actual VLA and prevent the warning. By default the stack accomodates the elements. If the number of emelements is greater than N, which by default is 8, a heap buffer will be allocated and used to acccomodate the elements.
2023-11-28Revert "[OpenMP] Use simple VLA implementation to replace uses of actual VLA ↵Shilei Tian
(#71412)" This reverts commit eaab947a8aa39002e8bdaa82be08cbc31e116a11 because it causes link error.
2023-11-28[OpenMP] Use simple VLA implementation to replace uses of actual VLA (#71412)Shilei Tian
Use of VLA can cause compile warning that was introduced in D156565. This patch implements a simple stack/heap-based VLA that can miminc the behavior of an actual VLA and prevent the warning. By default the stack accomodates the elements. If the number of emelements is greater than N, which by default is 8, a heap buffer will be allocated and used to acccomodate the elements.
2021-10-22[OpenMP][OMPT][GOMP] task frame support in KMP_API_NAME_GOMP_PARALLEL_SECTIONSVladimir Inđić
KMP_API_NAME_GOMP_PARALLEL_SECTIONS function was missing the task frame support. This patch introduced a fix responsible to set properly the exit_frame of the innermost implicit task that corresponds to the parallel section construct, as well as the enter_frame of the task that encloses the mentioned implicit task. This patch also introduced a simple test case sections_serialized.c that contains serialized parallel section construct and validates whether the mentioned task frames are set correctly. Differential Revision: https://reviews.llvm.org/D112205
2021-10-20[OpenMP] Add GOMP allocator functionsNawrin Sultana
This patch adds GOMP_alloc and GOMP_free functions of LIBGOMP. Differential revision: https://reviews.llvm.org/D111673
2021-09-27[OpenMP] libomp: Usage of TASK_TIED constant inside kmp_gsupport.cpp@vladaindjic
The minor code refactorization introduces the TASK_TIED constant inside kmp_gsupprot.cpp as a replacement for the literal value 1. The mentioned constant is now used in both kmp_tasking.cpp and kmp_gsupport.cpp files. Differential Revision: https://reviews.llvm.org/D110441
2021-09-15[OpenMP] Add support for GOMP depobjPeyton, Jonathan L
GOMP depobjs are represented as a two intptr_t array. The first element is the base address of the dependency and the second element is the flag indicating the type the depobj represents. Differential Revision: https://reviews.llvm.org/D108790
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-04-16[OpenMP] Implement GOMP task reductionsPeyton, Jonathan L
Implement the remaining GOMP_* functions to support task reductions in taskgroup, parallel, loop, and taskloop constructs. The unused mem argument to many of the work-sharing constructs has to do with the scan() directive/ inscan() modifier. If mem is set, each function will call KMP_FATAL() and tell the user scan/inscan is unsupported. The GOMP reduction implementation is kept separate from our implementation because of how GOMP presents reduction data and computes the reductions. GOMP expects the privatized copies to be present even after a #pragma omp parallel reduction(task:...) region has ended so the data is stored inside GOMP's uintptr_t* data pseudo-structure. This style is tightly coupled with GCC compiler codegen. There also isn't any init(), combiner(), fini() functions in GOMP's codegen so the two implementations were to disparate to try to wrap GOMP's around our own. Differential Revision: https://reviews.llvm.org/D98806
2021-03-05Added API for "masked" construct via two entrypoints: __kmpc_masked,tlwilmar
and __kmpc_end_masked. The "master" construct is deprecated. Changed proc-bind keyword from "master" to "primary". Use of both master construct and master as proc-bind keyword is still allowed, but deprecated. Remove references to "master" in comments and strings, and replace with "primary" or "primary thread". Function names and variables were not touched, nor were references to deprecated master construct. These can be updated over time. No new code should refer to master.
2021-02-20[OpenMP][NFC] clang-format the whole openmp projectShilei Tian
Same script as D95318. Test files are excluded. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D97088
2020-12-31[OpenMP] libomp: Handle implicit conversion warningsTerry Wilmarth
This patch partially prepares the runtime source code to be built with -Wconversion, which should trigger warnings if any implicit conversions can possibly change a value. For builds done with icc or gcc, all such warnings are handled in this patch. clang gives a much longer list of warnings, particularly for sign conversions, which the other compilers don't report. The -Wconversion flag is commented into cmake files, but I'm not going to turn it on. If someone thinks it is important, and wants to fix all the clang warnings, they are welcome to. Types of changes made here involve either improving the consistency of types used so that no conversion is needed, or else performing careful explicit conversions, when we're sure a problem won't arise. Patch is a combination of changes by Terry Wilmarth and Johnny Peyton. Differential Revision: https://reviews.llvm.org/D92942
2020-12-05[OpenMP][OMPT] Fix OMPT return address guard for gomp interfaceJoachim Protze
D91692 missed various locations in kmp_gsupport, where the scope for OMPT_STORE_RETURN_ADDRESS is too narrow, i.e. the scope ends before the OMPT callback is called in some nested function. This patch fixes the scoping issue, so that all OMPT tests pass, when the tests are built with gcc. Differential Revision: https://reviews.llvm.org/D92121
2020-11-25[OpenMP][OMPT] Introduce a guard to handle OMPT return addressJoachim Protze
This is an alternative approach to address inconsistencies pointed out in: D90078 This patch makes sure that the return address is reset, when leaving the scope. In some cases, I had to move the macro out of an if-statement to have it in the right scope, in some cases I added an additional block to restrict the scope. This patch does not handle inconsistencies, which might occur if the return address is still set when we call into the application. Test case (repeated_calls.c) provided by @hbae Differential Revision: https://reviews.llvm.org/D91692
2020-10-01[OpenMP][OMPT] Update OMPT tests for newly added GOMP interface patchesJoachim Protze
This patch updates the expected results for the GOMP interface patches: D87267, D87269, and D87271. The taskwait-depend test is changed to really use taskwait-depend and copied to an task_if0-depend test. To pass the tests, the handling of the return address was fixed. Differential Revision: https://reviews.llvm.org/D87680
2020-09-24[OpenMP] Fix if0 task with dependencies in the runtimePeyton, Jonathan L
The current GOMP interface for serialized tasks does not take into account task dependencies. Add the check and wait for dependencies. Fixes: https://bugs.llvm.org/show_bug.cgi?id=46573 Differential Revision: https://reviews.llvm.org/D87271
2020-09-24[OpenMP] Introduce GOMP taskwait depend in the runtimePeyton, Jonathan L
This change introduces the GOMP_taskwait_depend() function. It implements the OpenMP 5.0 feature of #pragma omp taskwait with depend() clause by wrapping around __kmpc_omp_wait_deps(). Differential Revision: https://reviews.llvm.org/D87269
2020-09-24[OpenMP] Introduce GOMP mutexinoutset in the runtimePeyton, Jonathan L
Encapsulate GOMP task dependencies in separate class and introduce the new mutexinoutset dependency type. This separate class allows future GOMP task APIs easier access to the task dependency functionality and better ability to propagate new dependency types to all existing GOMP task APIs which use task dependencies. Differential Revision: https://reviews.llvm.org/D87267
2020-09-24[OpenMP] Introduce GOMP teams support in runtimePeyton, Jonathan L
Implement GOMP_teams_reg() function which enables GOMP support of the standalone teams construct. The GOMP_parallel* functions were modified to call __kmp_fork_call() unconditionally so that the teams-specific code could be reused within __kmp_fork_call() instead of reproduced inside the GOMP_* functions. Differential Revision: https://reviews.llvm.org/D87167
2020-08-24Move special va_list handling to kmp_os.hDimitry Andric
Instead of copying and pasting the same `#ifdef` expressions in multiple places, define a type and a pair of macros in `kmp_os.h`, to handle whether `va_list` is pointer-like or not: * `kmp_va_list` is the type to use for `__kmp_fork_call()` * `kmp_va_deref()` dereferences a `va_list`, if necessary * `kmp_va_addr_of()` takes the address of a `va_list`, if necessary Also add FreeBSD to the list of OSes that has a non pointer-like va_list. This can now be easily extended to other OSes too. Reviewed By: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D86397
2020-07-06[OpenMP] Add GOMP 5.0 loop entry pointsPeyton, Jonathan L
This patch adds missing GOMP_5.0 loop entry points which incorporate new non-monotonic default into entry point name. Since monotonic schedules are a subset of nonmonotonic, it is acceptable to use monotonic as the implementation. This patch simply has the nonmonotonic (and possibly non-monontonic) versions of the loop entry points as wrappers around the monotonic ones. Differential Revision: https://reviews.llvm.org/D73922
2020-04-04[OpenMP] NFC: Fix trivial typoKazuaki Ishizaki
Differential Revision: https://reviews.llvm.org/D77430
2020-01-07[OpenMP] NFC: Fix trivial typos in commentsKazuaki Ishizaki
Reviewers: jdoerfert, Jim Reviewed By: Jim Subscribers: Jim, mgorny, guansong, jfb, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D72285
2020-01-03[OpenMP] NFC: Fix trivial typos in commentsKelvin Li
Submitted by: kiszk Differential Revision: https://reviews.llvm.org/D72171
2019-08-15[OpenMP] Remove 'unnecessary parentheses'Jonas Hahnfeld
The variables in kmp_lock.cpp are really arrays of function pointers that return void or int, not pointers to functions that return void* or int*. The other changes are only cosmetic. Differential Revision: https://reviews.llvm.org/D65870 llvm-svn: 369002
2019-08-05[OpenMP] Add support for GOMP_*_nonmonotonic_* functionsJonathan Peyton
Patch by Isuru Fernando Differential Revision: https://reviews.llvm.org/D65714 llvm-svn: 367949
2019-07-12[OpenMP] Remove OMP spec versioningJonathan Peyton
Remove all older OMP spec versioning from the runtime and build system. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D64534 llvm-svn: 365963
2019-02-19[OpenMP] Adding GOMP compatible cancellationJonathan Peyton
Remove fatal error messages from the cancellation API for GOMP Add __kmp_barrier_gomp_cancel() to implement cancellation of parallel regions. This new function uses the linear barrier algorithm with a cancellable nonsleepable wait loop. Differential Revision: https://reviews.llvm.org/D57969 llvm-svn: 354367
2019-01-19Update more file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
2019-01-16[OpenMP] Add omp_pause_resource* APIJonathan Peyton
Add omp_pause_resource and omp_pause_resource_all API and enum, plus stub for internal implementation. Implemented callable helper function to do local pause, and added basic functionality for hard and soft pause. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D55078 llvm-svn: 351372
2019-01-15[OMPT] Second chunk of final OMPT 5.0 interface updatesJoachim Protze
The omp-tools.h file is generated from the OpenMP spec to ensure that the interface is implemented as specified. The other changes are necessary to update the interface implementation to the final version as published in 5.0. The omp-tools.h header was previously called ompt.h, currently a copy under this name is installed for legacy tools. Patch partially perpared by @sconvent Reviewers: AndreyChurbanov, hbae, Hahnfeld Reviewed By: hbae Tags: #openmp, #ompt Differential Revision: https://reviews.llvm.org/D55579 llvm-svn: 351197
2018-12-18[OMPT] First chunk of final OMPT 5.0 interface updatesJoachim Protze
This patch updates the implementation of the ompt_frame_t, ompt_wait_id_t and ompt_state_t. The final version of the OpenMP 5.0 spec added the "t" for these types. Furthermore the structure for ompt_frame_t changed and allows to specify that the reenter frame belongs to the runtime. Patch partially prepared by Simon Convent Reviewers: hbae llvm-svn: 349458
2018-08-27[OpenMP][Fix] Ensure comparison between unsigned values.Gheorghe-Teodor Bercea
Summary: Ensure the values being compared are both unsigned. Reviewers: ABataev, Hahnfeld, caomhin, grokos, AndreyChurbanov Reviewed By: AndreyChurbanov Subscribers: AndreyChurbanov, guansong, openmp-commits Differential Revision: https://reviews.llvm.org/D51301 llvm-svn: 340745
2018-08-09[OpenMP] Cleanup codeJonathan Peyton
This patch cleans up unused functions, variables, sign compare issues, and addresses some -Warning flags which are now enabled including -Wcast-qual. Not all the warning flags in LibompHandleFlags.cmake are enabled, but some are with this patch. Some __kmp_gtid_from_* macros in kmp.h are switched to static inline functions which allows us to remove the awkward definition of KMP_DEBUG_ASSERT() and KMP_ASSERT() macros which used the comma operator. This had to be done for the innumerable -Wunused-value warnings related to KMP_DEBUG_ASSERT() Differential Revision: https://reviews.llvm.org/D49105 llvm-svn: 339393
2018-07-30[OpenMP] Implement GOMP doacross compatibilityJonathan Peyton
This change introduces GOMP doacross compatibility. There are 12 new interface functions 6 for long type and 6 for unsigned long long type: GOMP_doacross_post, GOMP_doacross_wait, GOMP_loop_doacross_[schedule]_start where schedule can be static, dynamic, guided, or runtime. These functions just translate the parameters if necessary and send them to the corresponding kmp function. E.g., GOMP_doacross_post() -> __kmpc_doacross_post() For the GOMP_doacross_post function, there is template specialization to account for when long is a four byte vs an eight byte type. If it is a four byte type, then a temporary array has to be created to convert the four byte integers into eight byte integers and then sending that into __kmpc_doacross_post(). Because GOMP_doacross_wait uses varargs, it always needs a temporary array and does not need template specialization. Differential Revision: https://reviews.llvm.org/D49857 llvm-svn: 338280
2018-06-20minor: fixed typo in debug printAndrey Churbanov
llvm-svn: 335138
2018-05-28[OMPT] Rename ompt_frame_t to omp_frame_tJoachim Protze
Rename ompt_frame_t to omp_frame_t, as defined in the spec. Differential Revision: https://reviews.llvm.org/D43568 llvm-svn: 333367
2018-05-07[OMPT] Fix thread_num for implicit_task_end callbacks in nested parallel regionsJoachim Protze
implicit_task_end callbacks in nested parallel regions did not always give the correct thread_num, since the inner parallel region may have already been finalized. Now, the thread_num is stored at the beginning of the implicit task and retrieved at the end, whenever necessary. A testcase was added as well. Differential Revision: https://reviews.llvm.org/D46260 llvm-svn: 331632
2018-04-18[OpenMP] Compilation error fix on const char*Heejin Ahn
Summary: This line (https://github.com/llvm-mirror/openmp/blob/0ed912c7a798f5c4f65f8bb6b492e07fab7f4cea/runtime/src/kmp_gsupport.cpp#L1459) added in D45327 (rL330282) causes a compilation failure. Reviewers: jlpeyton Subscribers: guansong, openmp-commits Differential Revision: https://reviews.llvm.org/D45786 llvm-svn: 330299
2018-04-18Introduce GOMP_taskloop APIJonathan Peyton
This patch introduces GOMP_taskloop to our API. It adds GOMP_4.5 to our version symbols. Being a wrapper around __kmpc_taskloop, the function creates a task with the loop bounds properly nested in the shareds so that the GOMP task thunk will work properly. Also, the firstprivate copy constructors are properly handled using the __kmp_gomp_task_dup() auxiliary function. Currently, only linear spawning of tasks is supported for the GOMP_taskloop interface. Differential Revision: https://reviews.llvm.org/D45327 llvm-svn: 330282
2018-02-17[OMPT] Omissionin in OMPT FormattingJoachim Protze
Applying clang-format to the /runtime/src/ folder Differential Revision: https://reviews.llvm.org/D42169 llvm-svn: 325424