aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src
AgeCommit message (Collapse)AuthorFilesLines
2023-07-25[OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and after target ↵Michael Halkenhaeuser1-7/+6
launch and data transfer operations Implemented RAII objects, initialized at target entry points, that invoke tool-supplied callbacks. Updated status of target callbacks as implemented. Depends on D127365 Patch from John Mellor-Crummey <johnmc@rice.edu> With contributions from: Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com> Jan-Patrick Lehr <janpatrick.lehr@amd.com> Reviewed By: jdoerfert, dhruvachak, jplehr Differential Revision: https://reviews.llvm.org/D127367
2023-07-25Revert "[OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and ↵Michael Halkenhaeuser1-6/+7
after target launch and data transfer operations" This reverts commit 00ccfcf9a6ee61c56cbe01d1e01b074797465fa4.
2023-07-24[OpenMP] [OMPT] [7/8] Invoke tool-supplied callbacks before and after target ↵Michael Halkenhaeuser1-7/+6
launch and data transfer operations Implemented RAII objects, initialized at target entry points, that invoke tool-supplied callbacks. Updated status of target callbacks as implemented. Depends on D127365 Patch from John Mellor-Crummey <johnmc@rice.edu> With contributions from: Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com> Jan-Patrick Lehr <janpatrick.lehr@amd.com> Reviewed By: jdoerfert, dhruvachak Differential Revision: https://reviews.llvm.org/D127367
2023-07-24[OpenMP] Move KMP_VERSION printout logic to post-serial-initJonathan Peyton2-4/+4
Get the KMP_VERSION printout logic out of environment variable file (kmp_settings.cpp) and move to end of serial initialization where KMP_SETTINGS and OMP_DISPLAY_ENV are. Differential Revision: https://reviews.llvm.org/D154652
2023-07-24[OpenMP] Restore comment accidently deleted in D154650Jonathan Peyton1-0/+1
2023-07-24[OpenMP] Re-use affinity raii class in worker spawningJonathan Peyton3-53/+27
Get rid of explicit mask alloc, getthreadaffinity, set temp affinity, reset to old affinity, dealloc steps in favor of existing kmp_affinity_raii_t to push/pop a temporary affinity. Differential Revision: https://reviews.llvm.org/D154650
2023-07-21[OpenMP] [OMPT] [6/8] Added callback support for target data operations, ↵Michael Halkenhaeuser4-6/+29
target submit, and target regions. This patch adds support for invoking target callbacks but does not yet invoke them. A new structure OmptInterface has been added that tracks thread local states including correlation ids. This structure defines methods that will be called from the device independent target library with information related to a target entry point for which a callback is invoked. These methods in turn use the callback functions maintained by OmptDeviceCallbacksTy to invoke the tool supplied callbacks. Depends on D124652 Patch from John Mellor-Crummey <johnmc@rice.edu> With contributions from: Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com> Differential Revision: https://reviews.llvm.org/D127365
2023-07-11[OpenMP] [OMPT] [amdgpu] [5/8] Implemented device init/fini/load callbacksMichael Halkenhaeuser2-7/+13
Added support in the generic plugin to invoke registered callbacks. Depends on D124070 Patch from John Mellor-Crummey <johnmc@rice.edu> (With contributions from Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>) Differential Revision: https://reviews.llvm.org/D124652
2023-07-10[OpenMP] Fix note section type notation for AArch64Carlos Eduardo Seo1-1/+1
Like Arm, AArch64 also uses "%" instead of "@" for note section types. Differential Revision: https://reviews.llvm.org/D154859
2023-07-07[OpenMP][OMPT] Change OMPT kind for OpenMP test lock functionsJoachim Jenke1-8/+8
The OpenMP specification mentions that omp_test_lock and omp_test_nest_lock dispatch OMPT callbacks with ompt_mutex_test_lock and ompt_mutex_test_nest_lock for their kind respectively. Previously, the values ompt_mutex_lock and ompt_mutex_nest_lock were used. This could cause issues in application relying on the kind to correctly determine lock states. This commit changes the kind to the expected ones. Also update callback.h and OMPT tests to reflect this change. Patch prepared by Thyre Differential Review: https://reviews.llvm.org/D153028 Differential Review: https://reviews.llvm.org/D153031 Differential Review: https://reviews.llvm.org/D153032
2023-07-07[OpenMP] Add OMPT support for omp_all_memory task dependenceJoachim Jenke2-9/+21
omp_all_memory currently has no representation in OMPT. Adding new dependency flags as suggested by omp-lang issue #3007. Differential Revision: https://reviews.llvm.org/D111788
2023-07-06[OpenMP] Ensure socket layer is not first in CPUID topology detectionJonathan Peyton1-1/+5
* Return 0 length topology if socket layer is detected first * Fix DEBUG ASSERT
2023-07-06[OpenMP] Remove gcc-12 warnings from libompJonathan Peyton2-2/+1
2023-07-05[OpenMP] Minor improvement in error msg and fixes few coverity reported issuesNawrin Sultana4-7/+17
Differential Revision: https://reviews.llvm.org/D152289
2023-06-19[OpenMP] Implement printing TDGs to dot filesAdrian Munera4-0/+49
This patch implements the "__kmp_print_tdg_dot" function, that prints a task dependency graph into a dot file containing the tasks and their dependencies. It is activated through a new environment variable "KMP_TDG_DOT" Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D150962
2023-06-14[OpenMP] Fix the issue where `num_threads` still takes effect incorrectlyShilei Tian1-0/+3
This patch fixes the issue that, if we have a compile-time serialized parallel region (such as `if (0)`) with `num_threads`, followed by a regular parallel region, the regular parallel region will pick up the value set in the serialized parallel region incorrectly. The reason is, in the front end, if we can prove a parallel region has to serialized, instead of emitting `__kmpc_fork_call`, the front end directly emits `__kmpc_serialized_parallel`, body, and `__kmpc_end_serialized_parallel`. However, this "optimization" doesn't consider the case where `num_threads` is used such that `__kmpc_push_num_threads` is still emitted. Since we don't reset the value in `__kmpc_serialized_parallel`, it will affect the next parallel region followed by it. Fix #63197. Reviewed By: tlwilmar Differential Revision: https://reviews.llvm.org/D152883
2023-06-05[OpenMP][libomp] Allow white spaces in OMP_TARGET_OFFLOAD valueHansang Bae1-7/+24
Remove heading/trailing white spaces when matching OMP_TARGET_OFFLOAD value. Differential Revision: https://reviews.llvm.org/D149890
2023-05-30[NFC][OpenMP] Remove unused variable `new_iv_saved` in ↵Shilei Tian1-4/+0
`openmp/runtime/src/kmp_collapse.cpp`
2023-05-27Reland "[CMake] Bumps minimum version to 3.20.0.Mark de Wever1-2/+0
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6. Adds the patch by @hans from https://github.com/llvm/llvm-project/issues/62719 This patch fixes the Windows build. d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews D144509 [CMake] Bumps minimum version to 3.20.0. This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. D150532 [OpenMP] Compile assembly files as ASM, not C Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent) when compiling a file which has been set as having the language C. This behaviour change only takes place if "cmake_minimum_required" is set to 3.20 or newer, or if the policy CMP0119 is set to new. Attempting to compile assembly files with "-x c" fails, however this is workarounded in many cases, as OpenMP overrides this with "-x assembler-with-cpp", however this is only added for non-Windows targets. Thus, after increasing cmake_minimum_required to 3.20, this breaks compiling the GNU assembly for Windows targets; the GNU assembly is used for ARM and AArch64 Windows targets when building with Clang. This patch unbreaks that. D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump The build uses other mechanism to select the runtime. Fixes #62719 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D151344
2023-05-24[OpenMP][libomp] Implement KMP_DLSYM_NEXT on WindowsHansang Bae3-5/+40
The interop API routines try to invoke external entries, but we did not have support for KMP_DLSYM_NEXT on Windows. Also added proper guards for STUB build. Differential Revision: https://reviews.llvm.org/D149892
2023-05-23[OpenMP] Insert missing variable update inside loopJonathan Peyton1-0/+1
While loop within task priority code did not have necessary update of variable which could lead to hangs if two threads collided when both attempted to execute the compare_and_exchange. Fixes: https://github.com/llvm/llvm-project/issues/62867 Differential Revision: https://reviews.llvm.org/D151138
2023-05-18[OpenMP] remove usage of std::abs in the new loop collapse support codeVadim Paretsky1-11/+16
On some platforms, std::abs may inadvertently pull in a math library. This patch replaces its use in the new loop collapse code with a no thrills in-situ implementation. Differential Revision: https://reviews.llvm.org/D150882
2023-05-17[OpenMP]Fix trivial build failure in MacOSMats Petersson1-0/+2
MacOS build of LLVM with OpenMP enabled fails with an error that it doesn't know what std::abs is. Fix by including <cmath> so that the relevant function declaration is included. No functional change intended. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D150687
2023-05-17Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Nico Weber1-0/+2
This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c. Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards. Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C" This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559. Also reverts fix attempt "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump" This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
2023-05-16[OpenMP] Compile assembly files as ASM, not CMartin Storsjö1-2/+0
Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent) when compiling a file which has been set as having the language C. This behaviour change only takes place if "cmake_minimum_required" is set to 3.20 or newer, or if the policy CMP0119 is set to new. Attempting to compile assembly files with "-x c" fails, however this is workarounded in many cases, as OpenMP overrides this with "-x assembler-with-cpp", however this is only added for non-Windows targets. Thus, after increasing cmake_minimum_required to 3.20, this breaks compiling the GNU assembly for Windows targets; the GNU assembly is used for ARM and AArch64 Windows targets when building with Clang. This patch unbreaks that. Differential Revision: https://reviews.llvm.org/D150532
2023-05-15[OpenMP] Implement task record and replay mechanismChenle Yu7-7/+670
This patch implements the "task record and replay" mechanism. The idea is to be able to store tasks and their dependencies in the runtime so that we do not pay the cost of task creation and dependency resolution for future executions. The objective is to improve fine-grained task performance, both for those from "omp task" and "taskloop". The entry point of the recording phase is __kmpc_start_record_task, and the end of record is triggered by __kmpc_end_record_task. Tasks encapsulated between a record start and a record end are saved, meaning that the runtime stores their dependencies and structures, referred to as TDG, in order to replay them in subsequent executions. In these TDG replays, we start the execution by scheduling all root tasks (tasks that do not have input dependencies), and there will be no involvement of a hash table to track the dependencies, yet tasks do not need to be created again. At the beginning of __kmpc_start_record_task, we must check if a TDG has already been recorded. If yes, the function returns 0 and starts to replay the TDG by calling __kmp_exec_tdg; if not, we start to record, and the function returns 1. An integer uniquely identifies TDGs. Currently, this identifier needs to be incremented manually in the source code. Still, depending on how this feature would eventually be used in the library, the caller function must do it; also, the caller function needs to implement a mechanism to skip the associated region, according to the return value of __kmpc_start_record_task. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D146642
2023-05-12[OpenMP] remove an erroneous assert on the location argumentVadim Paretsky1-1/+0
The 'loc' argument is optional, and some compilers (e.g. MSVC) do no supply it. Differential Revision: https://reviews.llvm.org/D148393
2023-05-12[OpenMP] Fix GCC build issues and restore "Additional APIs used by the MSVC ↵Vadim Paretsky4-0/+1727
compiler for loop collapse (rectangular and non-rectangular loops)" Fixes a GCC build issue (an instance of unallowed typename keyword) and reworks memory allocation to avoid the use of C++ library based primitives ) in and restores the earlier commit https://reviews.llvm.org/D148393 Differential Revision: https://reviews.llvm.org/D149010
2023-05-06[OpenMP] Make `libomptarget` link against `libomp`Shilei Tian1-2/+9
In `libomptarget` we use a couple of functions from `libomp`, but we didn't link `libomptarget` against `libomp`. That will not work on some platforms such as macOS. A linker error will be encountered because those symbols are not resolved at link time when building `libomptarget`. This patch simply makes `libomptarget` link agains `libomp`, makes it a "user" of `libomp`. I think this will not break the policies between `libomp` and `libomptarget`. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D149617
2023-05-06[NFC][OpenMP] Remove trailing whitespaces in `openmp/runtime/src/CMakeLists.txt`Shilei Tian1-3/+3
2023-05-01[OpenMP] Handle function calls from `libomp` to `libomptarget` correctlyShilei Tian3-3/+26
D132005 introduced function calls from `libomp` to `libomptarget` if offloading is enabled. However, the external function declaration may not always work. For example, it causes a link error on macOS. Currently it is guarded properly by a macro, but in order to get OpenMP target offloading working on macOS, it has to be handled correctly. This patch applies the same idea of how we support target memory extension by using function pointer indirect call for that function. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D149557
2023-05-01Revert "[OpenMP] Handle function calls from `libomp` to `libomptarget` ↵Shilei Tian3-26/+3
correctly" This reverts commit 479e335fc37c06767654141358ea076ac066de11. The assertion at `kmp_tasking.cpp(29)` is triggered.
2023-05-01[OpenMP] Handle function calls from `libomp` to `libomptarget` correctlyShilei Tian3-3/+26
D132005 introduced function calls from `libomp` to `libomptarget` if offloading is enabled. However, the external function declaration may not always work. For example, it causes a link error on macOS. Currently it is guarded properly by a macro, but in order to get OpenMP target offloading working on macOS, it has to be handled correctly. This patch applies the same idea of how we support target memory extension by using function pointer indirect call for that function. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D149557
2023-04-24Revert "[OpenMP] Fix GCC build issues and restore "Additional APIs used by the"Joseph Huber4-1714/+0
This patch caused failures on the OpenMP buildbots as discussed in https://reviews.llvm.org/D149010. We will need to investigate why we are seeing unresolved references to the standard C++ library. This reverts commit 5a15ca7f10bcba55a2f51281b1562cf5095ae015.
2023-04-24[OpenMP] Fix GCC build issues and restore "Additional APIs used by theNatalia Glagoleva4-0/+1714
MSVC compiler for loop collapse (rectangular and non-rectangular loops)" Fixes a GCC build issue (unallowed typename keyword use) in and restores https://reviews.llvm.org/D148393 Differential Revision: https://reviews.llvm.org/D149010
2023-04-21Revert "[OpenMP] Additional APIs used by the MSVC compiler for loop collapse"Slava Zakharin4-1714/+0
This reverts commit 7aa815fc782c5e39aefeec10d9c7c4cea7231975. Buildbots are failing, e.g.: https://lab.llvm.org/buildbot/#/builders/84/builds/36964 https://lab.llvm.org/buildbot/#/builders/193/builds/30096
2023-04-21[OpenMP] Additional APIs used by the MSVC compiler for loop collapseNatalia Glagoleva4-0/+1714
(rectangular and non-rectangular loops) Submitting on behalf of Natalia Glagoleva <natgla@microsoft.com> Differential Revision: https://reviews.llvm.org/D148393
2023-04-21Fix an issue with th_task_state_memo_stack and proxy/helper tasksAlex Duran1-0/+46
When proxy or helper tasks were used in inactive parallel regions, no memo of the th_task_state was stored in the stack, so th_task_state became invalid. This change inserts an item in the memo stack to track these th_task_states. Patch by Alex Duran. Differential Revision: https://reviews.llvm.org/D145736
2023-03-27[OpenMP] Fix an OpenMP Windows build problemVadim Paretsky2-6/+18
When building OpenMP as part of LLVM, CMAKE was generating incorrect location references for OpenMP build's first step's artifacts being used in regenerating its Windows import library in the second step. The fix is to feed a dummy non-buildable, rather than buildable, source to CMAKE to satisfy its source requirements removing the need to reference the first step's artifacts in the second step altogether. Differential Revision:https://reviews.llvm.org/D146894
2023-03-13[OpenMP] remove obsolete symbol defintionsVadim Paretsky4-50/+0
Some globals were used for enforcing certain linking rules in the Intel OpenMP implementation's MSVC compatibility layer and are not applicable to the LLVM implementation (kmp_import.cpp has already been removed from the build). Differential Revision:https://reviews.llvm.org/D145837
2023-03-02This check-in makes the following improvements to the OpenMP Windows build:Vadim Paretsky (Intel Americas Inc)1-43/+27
Only generate the second def file when necessary (native Windows import library builds). Properly clean up .def file artifacts. Reduce the re-generated import library build artifacts to the minimum. Refactor the import library related portions of the script for clarity. Tested with MSVC and MinWG/gcc12.0 Differential Revision:https://reviews.llvm.org/D144419
2023-02-24[OpenMP] Remove uses of ATOMIC_VAR_INITFangrui Song3-11/+7
ATOMIC_VAR_INIT has a trivial definition `#define ATOMIC_VAR_INIT(value) (value)`, is deprecated in C17/C++20, and will be removed in newer standards in newer GCC/Clang (e.g. https://reviews.llvm.org/D144196).
2023-02-23[OpenMP] Fix the wrong use of `fopen`Shilei Tian1-4/+2
This patch fixes the wrong use of `fopen`. Fix https://github.com/llvm/llvm-project/issues/60934 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D144601
2023-02-22[OpenMP] Target memory allocator fallback to default when no device availableNawrin Sultana2-2/+7
Differential Revision: https://reviews.llvm.org/D144525
2023-02-21[OpenMP] Update the bug report link for `libomp` assertion failuresJoseph Huber1-1/+1
Currently we still print the old https://bugs.llvm.org/ bugzilla link. We should update this to the issues pane for the LLVM github. Reviewed By: tlwilmar Differential Revision: https://reviews.llvm.org/D144426
2023-02-15[openmp] Fix building for mingw targets after import library changesMartin Storsjö1-13/+32
06d9bf5e64d472db5485815d9c3f70631064bb25 (https://reviews.llvm.org/D143431) did a large restructuring of how the import library is created; previously, a second step to tweak the import library was only done for MSVC style targets, but after this commit, that logic was applied for mingw targets too. Since LIBOMP_GENERATED_IMP_LIB_FILENAME and LIBOMP_IMP_LIB_FILE are equal on mingw targets (both are "libomp.dll.a", while they are "libomp.dll.lib" and "libomp.lib" for MSVC targets), this caused a conflict, with errors like this: ninja: error: build.ninja:875: multiple rules generate runtime/src/libomp.dll.a [-w dupbuild=err] Skip the logic with a second step to recreate the import library for mingw targets. The MSVC specific logic for this relies on running the static archiver with CMAKE_LINK_DEF_FILE_FLAG, which with MS lib.exe (and llvm-lib) ignore the input object files and just generates an import library - but mingw style tools don't support this mode of operation. (By attemptinig the same, mingw tools would generate a static library with the def file as one member.) With mingw tools, the same can be achieved by invoking the dlltool executable instead. Instead of adding alternative logic for invoking dlltool, just skip the second import library step, since neither GNU nor LLVM mingw tools actually generate import libraries that link by ordinal - so there's no need for a second import library. Differential Revision: https://reviews.llvm.org/D143992
2023-02-13[OpenMP] Fix extra parenthesis in kmp_os.hVadim Paretsky (Intel Americas Inc)1-1/+1
Differential Revision: https://reviews.llvm.org/D143940
2023-02-13[OpenMP] Add check for target allocator regardless of the availability of ↵Nawrin Sultana1-28/+30
libmemkind Current runtime implementation only checks for target allocator when libmemkind is not available. This patch adds checks for target allocator regardless of the presence of libmemkind library. Differential Revision: https://reviews.llvm.org/D142582
2023-02-13[OpenMP] generate the Windows import library that imports by name ratherVadim Paretsky (Intel Americas Inc)1-29/+24
than ordinal This check-in changes the OpenMP build script to generate the Windows import library that imports by name rather than ordinal to reduce ordinals order dependency and promote runtime flavors compatibility going forward. The existing ordinals ordering is preserved to maintain backward compatibility. Differential Revision: https://reviews.llvm.org/D143431
2023-02-11[openmp] Fix building z_Linux_asm.S for armv5tMartin Storsjö1-1/+4
Don't use the ldrd instruction; that one requires armv5te. Instead do two separate loads (or only one if OMPT_SUPPORT isn't defined). This should fix https://github.com/llvm/llvm-project/issues/60370. Differential Revision: https://reviews.llvm.org/D143683