diff options
author | Yi Kong <yikong@google.com> | 2019-02-27 14:18:37 -0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2019-02-27 14:18:37 -0800 |
commit | 29dfe9f54543ec877d3f9f299b3cac73d35ea9c5 (patch) | |
tree | a95aa6447380781b99b78b6caa9e4ce74b669ebb | |
parent | 191c55a174f750af708e546c4d769941833e3c0a (diff) | |
parent | e518cdac15e208277e0563ab4582d69074732390 (diff) | |
download | openmp_llvm-llvm-r353983.tar.gz |
Merge e518cda for LLVM update to 353983HEADmastermainllvm-r353983
Change-Id: Ibfd1e984fc06fcc23d37ac47905503e14261dd5d
206 files changed, 3357 insertions, 1974 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 2183e8e..9907566 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,241 @@ ============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== The software contained in this directory tree is dual licensed under both the University of Illinois "BSD-Like" license and the MIT license. As a user of @@ -14,7 +251,7 @@ software contained in this directory tree is included below. University of Illinois/NCSA Open Source License -Copyright (c) 1997-2018 Intel Corporation +Copyright (c) 1997-2019 Intel Corporation All rights reserved. @@ -51,7 +288,7 @@ SOFTWARE. ============================================================================== -Copyright (c) 1997-2018 Intel Corporation +Copyright (c) 1997-2019 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -122,53 +359,3 @@ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ============================================================================== - -ARM Limited - -Software Grant License Agreement ("Agreement") - -Except for the license granted herein to you, ARM Limited ("ARM") reserves all -right, title, and interest in and to the Software (defined below). - -Definition - -"Software" means the code and documentation as well as any original work of -authorship, including any modifications or additions to an existing work, that -is intentionally submitted by ARM to llvm.org (http://llvm.org) ("LLVM") for -inclusion in, or documentation of, any of the products owned or managed by LLVM -(the "Work"). For the purposes of this definition, "submitted" means any form of -electronic, verbal, or written communication sent to LLVM or its -representatives, including but not limited to communication on electronic -mailing lists, source code control systems, and issue tracking systems that are -managed by, or on behalf of, LLVM for the purpose of discussing and improving -the Work, but excluding communication that is conspicuously marked otherwise. - -1. Grant of Copyright License. Subject to the terms and conditions of this - Agreement, ARM hereby grants to you and to recipients of the Software - distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, - royalty-free, irrevocable copyright license to reproduce, prepare derivative - works of, publicly display, publicly perform, sublicense, and distribute the - Software and such derivative works. - -2. Grant of Patent License. Subject to the terms and conditions of this - Agreement, ARM hereby grants you and to recipients of the Software - distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, - royalty-free, irrevocable (except as stated in this section) patent license - to make, have made, use, offer to sell, sell, import, and otherwise transfer - the Work, where such license applies only to those patent claims licensable - by ARM that are necessarily infringed by ARM's Software alone or by - combination of the Software with the Work to which such Software was - submitted. If any entity institutes patent litigation against ARM or any - other entity (including a cross-claim or counterclaim in a lawsuit) alleging - that ARM's Software, or the Work to which ARM has contributed constitutes - direct or contributory patent infringement, then any patent licenses granted - to that entity under this Agreement for the Software or Work shall terminate - as of the date such litigation is filed. - -Unless required by applicable law or agreed to in writing, the software is -provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -either express or implied, including, without limitation, any warranties or -conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -PARTICULAR PURPOSE. - -============================================================================== diff --git a/cmake/OpenMPTesting.cmake b/cmake/OpenMPTesting.cmake index fc19bf7..8dd8823 100644 --- a/cmake/OpenMPTesting.cmake +++ b/cmake/OpenMPTesting.cmake @@ -99,7 +99,7 @@ if (${OPENMP_STANDALONE_BUILD}) # project is built which is too late for detecting the compiler... file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler) execute_process( - COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR}/DetectTestCompiler + COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${CMAKE_CURRENT_LIST_DIR}/DetectTestCompiler -DCMAKE_C_COMPILER=${OPENMP_TEST_C_COMPILER} -DCMAKE_CXX_COMPILER=${OPENMP_TEST_CXX_COMPILER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DetectTestCompiler diff --git a/libomptarget/CMakeLists.txt b/libomptarget/CMakeLists.txt index 7c57edd..9bbb5e6 100644 --- a/libomptarget/CMakeLists.txt +++ b/libomptarget/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake index 71a6a5e..dbf8c38 100644 --- a/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +++ b/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # @@ -112,6 +111,9 @@ mark_as_advanced( ################################################################################ # Looking for CUDA... ################################################################################ +if (CUDA_TOOLKIT_ROOT_DIR) + set(LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET TRUE) +endif() find_package(CUDA QUIET) set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND}) @@ -158,3 +160,33 @@ find_package_handle_standard_args( LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES) mark_as_advanced(LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES) + +################################################################################ +# Looking for CUDA libdevice subdirectory +# +# Special case for Debian/Ubuntu to have nvidia-cuda-toolkit work +# out of the box. More info on http://bugs.debian.org/882505 +################################################################################ + +set(LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR nvvm/libdevice) + +# Don't alter CUDA_TOOLKIT_ROOT_DIR if the user specified it, if a value was +# already cached for it, or if it already has libdevice. Otherwise, on +# Debian/Ubuntu, look where the nvidia-cuda-toolkit package normally installs +# libdevice. +if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND + NOT EXISTS + "${CUDA_TOOLKIT_ROOT_DIR}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}") + find_program(LSB_RELEASE lsb_release) + if (LSB_RELEASE) + execute_process(COMMAND ${LSB_RELEASE} -is + OUTPUT_VARIABLE LSB_RELEASE_ID + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(candidate_dir /usr/lib/cuda) + if ((LSB_RELEASE_ID STREQUAL "Debian" OR LSB_RELEASE_ID STREQUAL "Ubuntu") + AND EXISTS "${candidate_dir}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}") + set(CUDA_TOOLKIT_ROOT_DIR "${candidate_dir}" CACHE PATH + "Toolkit location." FORCE) + endif() + endif() +endif() diff --git a/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake b/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake index 5c69340..f03567a 100644 --- a/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake +++ b/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/libomptarget/cmake/Modules/LibomptargetUtils.cmake b/libomptarget/cmake/Modules/LibomptargetUtils.cmake index d964903..7339cc0 100644 --- a/libomptarget/cmake/Modules/LibomptargetUtils.cmake +++ b/libomptarget/cmake/Modules/LibomptargetUtils.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/libomptarget/deviceRTLs/CMakeLists.txt b/libomptarget/deviceRTLs/CMakeLists.txt index 7c75387..9723fb8 100644 --- a/libomptarget/deviceRTLs/CMakeLists.txt +++ b/libomptarget/deviceRTLs/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/deviceRTLs/nvptx/CMakeLists.txt b/libomptarget/deviceRTLs/nvptx/CMakeLists.txt index 1af0679..c20339c 100644 --- a/libomptarget/deviceRTLs/nvptx/CMakeLists.txt +++ b/libomptarget/deviceRTLs/nvptx/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/deviceRTLs/nvptx/src/cancel.cu b/libomptarget/deviceRTLs/nvptx/src/cancel.cu index 9f92e2d..93fc5da 100644 --- a/libomptarget/deviceRTLs/nvptx/src/cancel.cu +++ b/libomptarget/deviceRTLs/nvptx/src/cancel.cu @@ -1,9 +1,8 @@ //===------ cancel.cu - NVPTX OpenMP cancel interface ------------ CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/deviceRTLs/nvptx/src/critical.cu b/libomptarget/deviceRTLs/nvptx/src/critical.cu index 9bf2a30..2eb94f5 100644 --- a/libomptarget/deviceRTLs/nvptx/src/critical.cu +++ b/libomptarget/deviceRTLs/nvptx/src/critical.cu @@ -1,9 +1,8 @@ //===------ critical.cu - NVPTX OpenMP critical ------------------ CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu b/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu index f69daa1..50b8654 100644 --- a/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu +++ b/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu @@ -1,9 +1,8 @@ //===----- data_sharing.cu - NVPTX OpenMP debug utilities -------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -13,42 +12,26 @@ #include "omptarget-nvptx.h" #include <stdio.h> -// Number of threads in the CUDA block. -__device__ static unsigned getNumThreads() { return blockDim.x; } -// Thread ID in the CUDA block -__device__ static unsigned getThreadId() { return threadIdx.x; } // Warp ID in the CUDA block -__device__ static unsigned getWarpId() { return threadIdx.x / WARPSIZE; } +INLINE static unsigned getWarpId() { return threadIdx.x / WARPSIZE; } // Lane ID in the CUDA warp. -__device__ static unsigned getLaneId() { return threadIdx.x % WARPSIZE; } - -// The CUDA thread ID of the master thread. -__device__ static unsigned getMasterThreadId() { - unsigned Mask = WARPSIZE - 1; - return (getNumThreads() - 1) & (~Mask); -} - -// Find the active threads in the warp - return a mask whose n-th bit is set if -// the n-th thread in the warp is active. -__device__ static unsigned getActiveThreadsMask() { - return __BALLOT_SYNC(0xFFFFFFFF, true); -} +INLINE static unsigned getLaneId() { return threadIdx.x % WARPSIZE; } // Return true if this is the first active thread in the warp. -__device__ static bool IsWarpMasterActiveThread() { - unsigned long long Mask = getActiveThreadsMask(); - unsigned long long ShNum = WARPSIZE - (getThreadId() % WARPSIZE); +INLINE static bool IsWarpMasterActiveThread() { + unsigned long long Mask = __ACTIVEMASK(); + unsigned long long ShNum = WARPSIZE - (GetThreadIdInBlock() % WARPSIZE); unsigned long long Sh = Mask << ShNum; // Truncate Sh to the 32 lower bits return (unsigned)Sh == 0; } // Return true if this is the master thread. -__device__ static bool IsMasterThread() { - return !isSPMDMode() && getMasterThreadId() == getThreadId(); +INLINE static bool IsMasterThread(bool isSPMDExecutionMode) { + return !isSPMDExecutionMode && GetMasterThreadID() == GetThreadIdInBlock(); } /// Return the provided size aligned to the size of a pointer. -__device__ static size_t AlignVal(size_t Val) { +INLINE static size_t AlignVal(size_t Val) { const size_t Align = (size_t)sizeof(void *); if (Val & (Align - 1)) { Val += Align; @@ -88,7 +71,8 @@ __kmpc_initialize_data_sharing_environment(__kmpc_data_sharing_slot *rootS, omptarget_nvptx_TeamDescr *teamDescr = &omptarget_nvptx_threadPrivateContext->TeamContext(); - __kmpc_data_sharing_slot *RootS = teamDescr->RootS(WID, IsMasterThread()); + __kmpc_data_sharing_slot *RootS = + teamDescr->RootS(WID, IsMasterThread(isSPMDMode())); DataSharingState.SlotPtr[WID] = RootS; DataSharingState.StackPtr[WID] = (void *)&RootS->Data[0]; @@ -127,7 +111,7 @@ EXTERN void *__kmpc_data_sharing_environment_begin( (unsigned long long)SharingDefaultDataSize); unsigned WID = getWarpId(); - unsigned CurActiveThreads = getActiveThreadsMask(); + unsigned CurActiveThreads = __ACTIVEMASK(); __kmpc_data_sharing_slot *&SlotP = DataSharingState.SlotPtr[WID]; void *&StackP = DataSharingState.StackPtr[WID]; @@ -253,8 +237,9 @@ EXTERN void __kmpc_data_sharing_environment_end( // The master thread cleans the saved slot, because this is an environment // only for the master. - __kmpc_data_sharing_slot *S = - IsMasterThread() ? *SavedSharedSlot : DataSharingState.SlotPtr[WID]; + __kmpc_data_sharing_slot *S = IsMasterThread(isSPMDMode()) + ? *SavedSharedSlot + : DataSharingState.SlotPtr[WID]; if (S->Next) { free(S->Next); @@ -266,7 +251,7 @@ EXTERN void __kmpc_data_sharing_environment_end( return; } - int32_t CurActive = getActiveThreadsMask(); + int32_t CurActive = __ACTIVEMASK(); // Only the warp master can restore the stack and frame information, and only // if there are no other threads left behind in this environment (i.e. the @@ -339,7 +324,7 @@ __kmpc_get_data_sharing_environment_frame(int32_t SourceThreadID, // Runtime functions for trunk data sharing scheme. //////////////////////////////////////////////////////////////////////////////// -INLINE void data_sharing_init_stack_common() { +INLINE static void data_sharing_init_stack_common() { ASSERT0(LT_FUSSY, isRuntimeInitialized(), "Runtime must be initialized."); omptarget_nvptx_TeamDescr *teamDescr = &omptarget_nvptx_threadPrivateContext->TeamContext(); @@ -378,11 +363,11 @@ EXTERN void __kmpc_data_sharing_init_stack_spmd() { __threadfence_block(); } -INLINE void* data_sharing_push_stack_common(size_t PushSize) { +INLINE static void* data_sharing_push_stack_common(size_t PushSize) { ASSERT0(LT_FUSSY, isRuntimeInitialized(), "Expected initialized runtime."); // Only warp active master threads manage the stack. - bool IsWarpMaster = (getThreadId() % WARPSIZE) == 0; + bool IsWarpMaster = (GetThreadIdInBlock() % WARPSIZE) == 0; // Add worst-case padding to DataSize so that future stack allocations are // correctly aligned. @@ -390,8 +375,9 @@ INLINE void* data_sharing_push_stack_common(size_t PushSize) { PushSize = (PushSize + (Alignment - 1)) / Alignment * Alignment; // Frame pointer must be visible to all workers in the same warp. - unsigned WID = getWarpId(); - void *volatile &FrameP = DataSharingState.FramePtr[WID]; + const unsigned WID = getWarpId(); + void *FrameP = 0; + int32_t CurActive = __ACTIVEMASK(); if (IsWarpMaster) { // SlotP will point to either the shared memory slot or an existing @@ -434,23 +420,25 @@ INLINE void* data_sharing_push_stack_common(size_t PushSize) { // The stack pointer always points to the next free stack frame. StackP = &NewSlot->Data[0] + PushSize; // The frame pointer always points to the beginning of the frame. - FrameP = &NewSlot->Data[0]; + FrameP = DataSharingState.FramePtr[WID] = &NewSlot->Data[0]; } else { // Add the data chunk to the current slot. The frame pointer is set to // point to the start of the new frame held in StackP. - FrameP = StackP; + FrameP = DataSharingState.FramePtr[WID] = StackP; // Reset stack pointer to the requested address. StackP = (void *)RequestedEndAddress; } - } else { - while (!FrameP); } + // Get address from lane 0. + ((int *)&FrameP)[0] = __SHFL_SYNC(CurActive, ((int *)&FrameP)[0], 0); + if (sizeof(FrameP) == 8) + ((int *)&FrameP)[1] = __SHFL_SYNC(CurActive, ((int *)&FrameP)[1], 0); return FrameP; } -EXTERN void* __kmpc_data_sharing_coalesced_push_stack(size_t DataSize, - int16_t UseSharedMemory) { +EXTERN void *__kmpc_data_sharing_coalesced_push_stack(size_t DataSize, + int16_t UseSharedMemory) { return data_sharing_push_stack_common(DataSize); } @@ -461,16 +449,17 @@ EXTERN void* __kmpc_data_sharing_coalesced_push_stack(size_t DataSize, // By default the globalized variables are stored in global memory. If the // UseSharedMemory is set to true, the runtime will attempt to use shared memory // as long as the size requested fits the pre-allocated size. -EXTERN void* __kmpc_data_sharing_push_stack(size_t DataSize, - int16_t UseSharedMemory) { +EXTERN void *__kmpc_data_sharing_push_stack(size_t DataSize, + int16_t UseSharedMemory) { // Compute the total memory footprint of the requested data. // The master thread requires a stack only for itself. A worker // thread (which at this point is a warp master) will require // space for the variables of each thread in the warp, // i.e. one DataSize chunk per warp lane. // TODO: change WARPSIZE to the number of active threads in the warp. - size_t PushSize = (isRuntimeUninitialized() || IsMasterThread()) ? - DataSize : WARPSIZE * DataSize; + size_t PushSize = (isRuntimeUninitialized() || IsMasterThread(isSPMDMode())) + ? DataSize + : WARPSIZE * DataSize; // Compute the start address of the frame of each thread in the warp. uintptr_t FrameStartAddress = @@ -489,7 +478,7 @@ EXTERN void __kmpc_data_sharing_pop_stack(void *FrameStart) { __threadfence_block(); - if (getThreadId() % WARPSIZE == 0) { + if (GetThreadIdInBlock() % WARPSIZE == 0) { unsigned WID = getWarpId(); // Current slot @@ -550,38 +539,42 @@ EXTERN void __kmpc_get_shared_variables(void ***GlobalArgs) { // manage statically allocated global memory. This memory is allocated by the // compiler and used to correctly implement globalization of the variables in // target, teams and distribute regions. -EXTERN void __kmpc_get_team_static_memory(const void *buf, size_t size, +EXTERN void __kmpc_get_team_static_memory(int16_t isSPMDExecutionMode, + const void *buf, size_t size, int16_t is_shared, const void **frame) { if (is_shared) { *frame = buf; return; } - if (isSPMDMode()) { + if (isSPMDExecutionMode) { if (GetThreadIdInBlock() == 0) { *frame = omptarget_nvptx_simpleMemoryManager.Acquire(buf, size); } - __syncthreads(); + // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. + __SYNCTHREADS(); return; } - ASSERT0(LT_FUSSY, GetThreadIdInBlock() == getMasterThreadId(), + ASSERT0(LT_FUSSY, GetThreadIdInBlock() == GetMasterThreadID(), "Must be called only in the target master thread."); *frame = omptarget_nvptx_simpleMemoryManager.Acquire(buf, size); __threadfence(); } -EXTERN void __kmpc_restore_team_static_memory(int16_t is_shared) { +EXTERN void __kmpc_restore_team_static_memory(int16_t isSPMDExecutionMode, + int16_t is_shared) { if (is_shared) return; - if (isSPMDMode()) { - __syncthreads(); + if (isSPMDExecutionMode) { + // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. + __SYNCTHREADS(); if (GetThreadIdInBlock() == 0) { omptarget_nvptx_simpleMemoryManager.Release(); } return; } __threadfence(); - ASSERT0(LT_FUSSY, GetThreadIdInBlock() == getMasterThreadId(), + ASSERT0(LT_FUSSY, GetThreadIdInBlock() == GetMasterThreadID(), "Must be called only in the target master thread."); omptarget_nvptx_simpleMemoryManager.Release(); } diff --git a/libomptarget/deviceRTLs/nvptx/src/debug.h b/libomptarget/deviceRTLs/nvptx/src/debug.h index 8577c8f..f2fcc1d 100644 --- a/libomptarget/deviceRTLs/nvptx/src/debug.h +++ b/libomptarget/deviceRTLs/nvptx/src/debug.h @@ -1,9 +1,8 @@ //===------------- debug.h - NVPTX OpenMP debug macros ----------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -130,7 +129,7 @@ #include "option.h" template <typename... Arguments> -static NOINLINE void log(const char *fmt, Arguments... parameters) { +NOINLINE static void log(const char *fmt, Arguments... parameters) { printf(fmt, (int)blockIdx.x, (int)threadIdx.x, (int)(threadIdx.x / WARPSIZE), (int)(threadIdx.x & 0x1F), parameters...); } @@ -138,6 +137,18 @@ static NOINLINE void log(const char *fmt, Arguments... parameters) { #endif #if OMPTARGET_NVPTX_TEST #include <assert.h> + +template <typename... Arguments> +NOINLINE static void check(bool cond, const char *fmt, + Arguments... parameters) { + if (!cond) + printf(fmt, (int)blockIdx.x, (int)threadIdx.x, + (int)(threadIdx.x / WARPSIZE), (int)(threadIdx.x & 0x1F), + parameters...); + assert(cond); +} + +NOINLINE static void check(bool cond) { assert(cond); } #endif // set flags that are tested (inclusion properties) @@ -207,13 +218,13 @@ static NOINLINE void log(const char *fmt, Arguments... parameters) { #define ASSERT0(_flag, _cond, _str) \ { \ if (TON(_flag)) { \ - assert(_cond); \ + check(_cond); \ } \ } #define ASSERT(_flag, _cond, _str, _args...) \ { \ if (TON(_flag)) { \ - assert(_cond); \ + check(_cond); \ } \ } @@ -222,16 +233,15 @@ static NOINLINE void log(const char *fmt, Arguments... parameters) { #define TON(_flag) ((OMPTARGET_NVPTX_TEST) & (_flag)) #define ASSERT0(_flag, _cond, _str) \ { \ - if (TON(_flag) && !(_cond)) { \ - log("<b %3d, t %4d, w %2d, l %2d> ASSERT: " _str "\n"); \ - assert(_cond); \ + if (TON(_flag)) { \ + check((_cond), "<b %3d, t %4d, w %2d, l %2d> ASSERT: " _str "\n"); \ } \ } #define ASSERT(_flag, _cond, _str, _args...) \ { \ - if (TON(_flag) && !(_cond)) { \ - log("<b %3d, t %4d, w %2d, l %d2> ASSERT: " _str "\n", _args); \ - assert(_cond); \ + if (TON(_flag)) { \ + check((_cond), "<b %3d, t %4d, w %2d, l %d2> ASSERT: " _str "\n", \ + _args); \ } \ } diff --git a/libomptarget/deviceRTLs/nvptx/src/interface.h b/libomptarget/deviceRTLs/nvptx/src/interface.h index 2c2beae..8af9dba 100644 --- a/libomptarget/deviceRTLs/nvptx/src/interface.h +++ b/libomptarget/deviceRTLs/nvptx/src/interface.h @@ -1,9 +1,8 @@ //===------- interface.h - NVPTX OpenMP interface definitions ---- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -395,9 +394,13 @@ EXTERN void __kmpc_reduce_conditional_lastprivate(kmp_Ident *loc, // reduction EXTERN void __kmpc_nvptx_end_reduce(int32_t global_tid); EXTERN void __kmpc_nvptx_end_reduce_nowait(int32_t global_tid); -EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait( +EXTERN __attribute__((deprecated)) int32_t __kmpc_nvptx_parallel_reduce_nowait( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); +EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_v2( + kmp_Ident *loc, int32_t global_tid, int32_t num_vars, size_t reduce_size, + void *reduce_data, kmp_ShuffleReductFctPtr shflFct, + kmp_InterWarpCopyFctPtr cpyFct); EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_spmd( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); @@ -550,9 +553,11 @@ __kmpc_get_data_sharing_environment_frame(int32_t SourceThreadID, // SPMD execution mode interrogation function. EXTERN int8_t __kmpc_is_spmd_exec_mode(); -EXTERN void __kmpc_get_team_static_memory(const void *buf, size_t size, +EXTERN void __kmpc_get_team_static_memory(int16_t isSPMDExecutionMode, + const void *buf, size_t size, int16_t is_shared, const void **res); -EXTERN void __kmpc_restore_team_static_memory(int16_t is_shared); +EXTERN void __kmpc_restore_team_static_memory(int16_t isSPMDExecutionMode, + int16_t is_shared); #endif diff --git a/libomptarget/deviceRTLs/nvptx/src/libcall.cu b/libomptarget/deviceRTLs/nvptx/src/libcall.cu index 91b270c..bf33c2a 100644 --- a/libomptarget/deviceRTLs/nvptx/src/libcall.cu +++ b/libomptarget/deviceRTLs/nvptx/src/libcall.cu @@ -1,9 +1,8 @@ //===------------ libcall.cu - NVPTX OpenMP user calls ----------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -39,14 +38,17 @@ EXTERN void omp_set_num_threads(int num) { if (num <= 0) { WARNING0(LW_INPUT, "expected positive num; ignore\n"); } else { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(/*isSPMDExecutionMode=*/false); currTaskDescr->NThreads() = num; } } EXTERN int omp_get_num_threads(void) { - int tid = GetLogicalThreadIdInBlock(); - int rc = GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()); + bool isSPMDExecutionMode = isSPMDMode(); + int tid = GetLogicalThreadIdInBlock(isSPMDExecutionMode); + int rc = + GetNumberOfOmpThreads(tid, isSPMDExecutionMode, isRuntimeUninitialized()); PRINT(LD_IO, "call omp_get_num_threads() return %d\n", rc); return rc; } @@ -58,7 +60,8 @@ EXTERN int omp_get_max_threads(void) { // We're already in parallel region. return 1; // default is 1 thread avail } - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); int rc = 1; // default is 1 thread avail if (!currTaskDescr->InParallelRegion()) { // Not currently in a parallel region, return what was set. @@ -76,21 +79,23 @@ EXTERN int omp_get_thread_limit(void) { return 0; // default is 0 } // per contention group.. meaning threads in current team - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); int rc = currTaskDescr->ThreadLimit(); PRINT(LD_IO, "call omp_get_thread_limit() return %d\n", rc); return rc; } EXTERN int omp_get_thread_num() { - int tid = GetLogicalThreadIdInBlock(); - int rc = GetOmpThreadId(tid, isSPMDMode(), isRuntimeUninitialized()); + bool isSPMDExecutionMode = isSPMDMode(); + int tid = GetLogicalThreadIdInBlock(isSPMDExecutionMode); + int rc = GetOmpThreadId(tid, isSPMDExecutionMode, isRuntimeUninitialized()); PRINT(LD_IO, "call omp_get_thread_num() returns %d\n", rc); return rc; } EXTERN int omp_get_num_procs(void) { - int rc = GetNumberOfProcsInDevice(); + int rc = GetNumberOfProcsInDevice(isSPMDMode()); PRINT(LD_IO, "call omp_get_num_procs() returns %d\n", rc); return rc; } @@ -102,7 +107,8 @@ EXTERN int omp_in_parallel(void) { "Expected SPMD mode only with uninitialized runtime."); rc = 1; // SPMD mode is always in parallel. } else { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); if (currTaskDescr->InParallelRegion()) { rc = 1; } @@ -158,10 +164,11 @@ EXTERN int omp_get_level(void) { if (isRuntimeUninitialized()) { ASSERT0(LT_FUSSY, isSPMDMode(), "Expected SPMD mode only with uninitialized runtime."); - return omptarget_nvptx_simpleThreadPrivateContext->GetParallelLevel(); + return parallelLevel; } int level = 0; - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); ASSERT0(LT_FUSSY, currTaskDescr, "do not expect fct to be called in a non-active thread"); do { @@ -181,7 +188,8 @@ EXTERN int omp_get_active_level(void) { return 1; } int level = 0; // no active level parallelism - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); ASSERT0(LT_FUSSY, currTaskDescr, "do not expect fct to be called in a non-active thread"); do { @@ -208,7 +216,8 @@ EXTERN int omp_get_ancestor_thread_num(int level) { } else if (level > 0) { int totLevel = omp_get_level(); if (level <= totLevel) { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); int steps = totLevel - level; PRINT(LD_IO, "backtrack %d steps\n", steps); ASSERT0(LT_FUSSY, currTaskDescr, @@ -259,7 +268,8 @@ EXTERN int omp_get_team_size(int level) { } else if (level > 0) { int totLevel = omp_get_level(); if (level <= totLevel) { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); int steps = totLevel - level; ASSERT0(LT_FUSSY, currTaskDescr, "do not expect fct to be called in a non-active thread"); @@ -288,7 +298,8 @@ EXTERN void omp_get_schedule(omp_sched_t *kind, int *modifier) { *kind = omp_sched_static; *modifier = 1; } else { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); *kind = currTaskDescr->GetRuntimeSched(); *modifier = currTaskDescr->RuntimeChunkSize(); } @@ -305,7 +316,8 @@ EXTERN void omp_set_schedule(omp_sched_t kind, int modifier) { return; } if (kind >= omp_sched_static && kind < omp_sched_auto) { - omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(); + omptarget_nvptx_TaskDescr *currTaskDescr = + getMyTopTaskDescriptor(isSPMDMode()); currTaskDescr->SetRuntimeSched(kind); currTaskDescr->RuntimeChunkSize() = modifier; PRINT(LD_IOD, "omp_set_schedule did set sched %d & modif %" PRIu64 "\n", diff --git a/libomptarget/deviceRTLs/nvptx/src/loop.cu b/libomptarget/deviceRTLs/nvptx/src/loop.cu index c100be5..7422d3c 100644 --- a/libomptarget/deviceRTLs/nvptx/src/loop.cu +++ b/libomptarget/deviceRTLs/nvptx/src/loop.cu @@ -1,9 +1,8 @@ //===------------ loop.cu - NVPTX OpenMP loop constructs --------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -101,7 +100,7 @@ public: // When IsRuntimeUninitialized is true, we assume that the caller is // in an L0 parallel region and that all worker threads participate. - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(IsSPMDExecutionMode); // Assume we are in teams region or that we use a single block // per target region @@ -208,7 +207,7 @@ public: ST chunk) { ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Expected non-SPMD mode + initialized runtime."); - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(tid); T tnum = currTaskDescr->ThreadsInTeam(); T tripCount = ub - lb + 1; // +1 because ub is inclusive @@ -352,18 +351,18 @@ public: omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), (unsigned long long)omptarget_nvptx_threadPrivateContext->Stride( tid)); - } else if (schedule == kmp_sched_dynamic || schedule == kmp_sched_guided) { - __kmpc_barrier(loc, threadId); - // save sched state - int teamId = GetOmpTeamId(); + // save data omptarget_nvptx_threadPrivateContext->ScheduleType(tid) = schedule; - if (GetThreadIdInBlock() == 0) { - if (chunk < 1) - chunk = 1; - omptarget_nvptx_threadPrivateContext->Chunk(teamId) = chunk; - omptarget_nvptx_threadPrivateContext->LoopUpperBound(teamId) = ub; - omptarget_nvptx_threadPrivateContext->NextLowerBound(teamId) = lb; + if (chunk < 1) + chunk = 1; + omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; + omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid) = ub; + omptarget_nvptx_threadPrivateContext->NextLowerBound(tid) = lb; + __kmpc_barrier(loc, threadId); + if (tid == 0) { + omptarget_nvptx_threadPrivateContext->Cnt() = 0; + __threadfence_block(); } __kmpc_barrier(loc, threadId); PRINT(LD_LOOP, @@ -371,21 +370,45 @@ public: ", chunk %" PRIu64 "\n", (int)tnum, (unsigned long long) - omptarget_nvptx_threadPrivateContext->NextLowerBound(teamId), - omptarget_nvptx_threadPrivateContext->LoopUpperBound(teamId), - omptarget_nvptx_threadPrivateContext->Chunk(teamId)); + omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), + omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), + omptarget_nvptx_threadPrivateContext->Chunk(tid)); } } //////////////////////////////////////////////////////////////////////////////// // Support for dispatch next + INLINE static int64_t Shuffle(unsigned active, int64_t val, int leader) { + int lo, hi; + asm volatile("mov.b64 {%0,%1}, %2;" : "=r"(lo), "=r"(hi) : "l"(val)); + hi = __SHFL_SYNC(active, hi, leader); + lo = __SHFL_SYNC(active, lo, leader); + asm volatile("mov.b64 %0, {%1,%2};" : "=l"(val) : "r"(lo), "r"(hi)); + return val; + } + + INLINE static uint64_t NextIter() { + unsigned int active = __ACTIVEMASK(); + int leader = __ffs(active) - 1; + int change = __popc(active); + unsigned lane_mask_lt; + asm("mov.u32 %0, %%lanemask_lt;" : "=r"(lane_mask_lt)); + unsigned int rank = __popc(active & lane_mask_lt); + uint64_t warp_res; + if (rank == 0) { + warp_res = atomicAdd( + (unsigned long long *)&omptarget_nvptx_threadPrivateContext->Cnt(), + change); + } + warp_res = Shuffle(active, warp_res, leader); + return warp_res + rank; + } + INLINE static int DynamicNextChunk(T &lb, T &ub, T chunkSize, - int64_t &loopLowerBound, - T loopUpperBound) { - // calculate lower bound for all lanes in the warp - lb = atomicAdd((unsigned long long *)&loopLowerBound, - (unsigned long long)chunkSize); + T loopLowerBound, T loopUpperBound) { + T N = NextIter(); + lb = loopLowerBound + N * chunkSize; ub = lb + chunkSize - 1; // Clang uses i <= ub // 3 result cases: @@ -414,20 +437,17 @@ public: return FINISHED; } - // On Pascal, with inlining of the runtime into the user application, - // this code deadlocks. This is probably because different threads - // in a warp cannot make independent progress. - NOINLINE static int dispatch_next(int32_t gtid, int32_t *plast, T *plower, - T *pupper, ST *pstride) { - ASSERT0(LT_FUSSY, isRuntimeInitialized(), + INLINE static int dispatch_next(kmp_Ident *loc, int32_t gtid, int32_t *plast, + T *plower, T *pupper, ST *pstride) { + ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Expected non-SPMD mode + initialized runtime."); // ID of a thread in its own warp // automatically selects thread or warp ID based on selected implementation - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); ASSERT0(LT_FUSSY, - gtid < GetNumberOfOmpThreads(tid, isSPMDMode(), - isRuntimeUninitialized()), + gtid < GetNumberOfOmpThreads(tid, checkSPMDMode(loc), + checkRuntimeUninitialized(loc)), "current thread is not needed here; error"); // retrieve schedule kmp_sched_t schedule = @@ -464,11 +484,10 @@ public: schedule == kmp_sched_dynamic || schedule == kmp_sched_guided, "bad sched"); T myLb, myUb; - int teamId = GetOmpTeamId(); int finished = DynamicNextChunk( - myLb, myUb, omptarget_nvptx_threadPrivateContext->Chunk(teamId), - omptarget_nvptx_threadPrivateContext->NextLowerBound(teamId), - omptarget_nvptx_threadPrivateContext->LoopUpperBound(teamId)); + myLb, myUb, omptarget_nvptx_threadPrivateContext->Chunk(tid), + omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), + omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid)); if (finished == FINISHED) return DISPATCH_FINISHED; @@ -540,7 +559,7 @@ EXTERN int __kmpc_dispatch_next_4(kmp_Ident *loc, int32_t tid, int32_t *p_last, int32_t *p_lb, int32_t *p_ub, int32_t *p_st) { PRINT0(LD_IO, "call kmpc_dispatch_next_4\n"); return omptarget_nvptx_LoopSupport<int32_t, int32_t>::dispatch_next( - tid, p_last, p_lb, p_ub, p_st); + loc, tid, p_last, p_lb, p_ub, p_st); } EXTERN int __kmpc_dispatch_next_4u(kmp_Ident *loc, int32_t tid, @@ -548,14 +567,14 @@ EXTERN int __kmpc_dispatch_next_4u(kmp_Ident *loc, int32_t tid, uint32_t *p_ub, int32_t *p_st) { PRINT0(LD_IO, "call kmpc_dispatch_next_4u\n"); return omptarget_nvptx_LoopSupport<uint32_t, int32_t>::dispatch_next( - tid, p_last, p_lb, p_ub, p_st); + loc, tid, p_last, p_lb, p_ub, p_st); } EXTERN int __kmpc_dispatch_next_8(kmp_Ident *loc, int32_t tid, int32_t *p_last, int64_t *p_lb, int64_t *p_ub, int64_t *p_st) { PRINT0(LD_IO, "call kmpc_dispatch_next_8\n"); return omptarget_nvptx_LoopSupport<int64_t, int64_t>::dispatch_next( - tid, p_last, p_lb, p_ub, p_st); + loc, tid, p_last, p_lb, p_ub, p_st); } EXTERN int __kmpc_dispatch_next_8u(kmp_Ident *loc, int32_t tid, @@ -563,7 +582,7 @@ EXTERN int __kmpc_dispatch_next_8u(kmp_Ident *loc, int32_t tid, uint64_t *p_ub, int64_t *p_st) { PRINT0(LD_IO, "call kmpc_dispatch_next_8u\n"); return omptarget_nvptx_LoopSupport<uint64_t, int64_t>::dispatch_next( - tid, p_last, p_lb, p_ub, p_st); + loc, tid, p_last, p_lb, p_ub, p_st); } // fini @@ -756,7 +775,7 @@ EXTERN void __kmpc_reduce_conditional_lastprivate(kmp_Ident *loc, int32_t gtid, "Expected non-SPMD mode + initialized runtime."); omptarget_nvptx_TeamDescr &teamDescr = getMyTeamDescriptor(); - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); uint32_t NumThreads = GetNumberOfOmpThreads(tid, checkSPMDMode(loc), checkRuntimeUninitialized(loc)); uint64_t *Buffer = teamDescr.getLastprivateIterBuffer(); diff --git a/libomptarget/deviceRTLs/nvptx/src/omp_data.cu b/libomptarget/deviceRTLs/nvptx/src/omp_data.cu index 35f94ac..27666ae 100644 --- a/libomptarget/deviceRTLs/nvptx/src/omp_data.cu +++ b/libomptarget/deviceRTLs/nvptx/src/omp_data.cu @@ -1,9 +1,8 @@ //===------------ omp_data.cu - NVPTX OpenMP GPU objects --------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -27,22 +26,17 @@ __device__ omptarget_nvptx_Queue<omptarget_nvptx_ThreadPrivateContext, OMP_STATE_COUNT> omptarget_nvptx_device_State[MAX_SM]; -__device__ omptarget_nvptx_Queue<omptarget_nvptx_SimpleThreadPrivateContext, - OMP_STATE_COUNT> - omptarget_nvptx_device_simpleState[MAX_SM]; - __device__ omptarget_nvptx_SimpleMemoryManager omptarget_nvptx_simpleMemoryManager; __device__ __shared__ uint32_t usedMemIdx; __device__ __shared__ uint32_t usedSlotIdx; +__device__ __shared__ uint8_t parallelLevel; + // Pointer to this team's OpenMP state object __device__ __shared__ omptarget_nvptx_ThreadPrivateContext *omptarget_nvptx_threadPrivateContext; -__device__ __shared__ omptarget_nvptx_SimpleThreadPrivateContext - *omptarget_nvptx_simpleThreadPrivateContext; - //////////////////////////////////////////////////////////////////////////////// // The team master sets the outlined parallel function in this variable to // communicate with the workers. Since it is in shared memory, there is one diff --git a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu index b0b1290..b69a3be 100644 --- a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu +++ b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu @@ -1,9 +1,8 @@ //===--- omptarget-nvptx.cu - NVPTX OpenMP GPU initialization ---- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -21,15 +20,11 @@ extern __device__ omptarget_nvptx_Queue<omptarget_nvptx_ThreadPrivateContext, OMP_STATE_COUNT> omptarget_nvptx_device_State[MAX_SM]; -extern __device__ omptarget_nvptx_Queue< - omptarget_nvptx_SimpleThreadPrivateContext, OMP_STATE_COUNT> - omptarget_nvptx_device_simpleState[MAX_SM]; - //////////////////////////////////////////////////////////////////////////////// // init entry points //////////////////////////////////////////////////////////////////////////////// -INLINE unsigned smid() { +INLINE static unsigned smid() { unsigned id; asm("mov.u32 %0, %%smid;" : "=r"(id)); return id; @@ -61,12 +56,12 @@ EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) { omptarget_nvptx_device_State[slot].Dequeue(); // init thread private - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(/*isSPMDExecutionMode=*/false); omptarget_nvptx_threadPrivateContext->InitThreadPrivateContext(threadId); // init team context omptarget_nvptx_TeamDescr &currTeamDescr = getMyTeamDescriptor(); - currTeamDescr.InitTeamDescr(); + currTeamDescr.InitTeamDescr(/*isSPMDExecutionMode=*/false); // this thread will start execution... has to update its task ICV // to point to the level zero task ICV. That ICV was init in // InitTeamDescr() @@ -81,6 +76,7 @@ EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) { } EXTERN void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized) { + PRINT0(LD_IO, "call to __kmpc_kernel_deinit\n"); ASSERT0(LT_FUSSY, IsOMPRuntimeInitialized, "Generic always requires initialized runtime."); // Enqueue omp state object for use by another team. @@ -99,13 +95,10 @@ EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime, // If OMP runtime is not required don't initialize OMP state. setExecutionParameters(Spmd, RuntimeUninitialized); if (GetThreadIdInBlock() == 0) { - int slot = smid() % MAX_SM; - usedSlotIdx = slot; - omptarget_nvptx_simpleThreadPrivateContext = - omptarget_nvptx_device_simpleState[slot].Dequeue(); + parallelLevel = 0; + usedSlotIdx = smid() % MAX_SM; } - __syncthreads(); - omptarget_nvptx_simpleThreadPrivateContext->Init(); + __SYNCTHREADS(); return; } setExecutionParameters(Spmd, RuntimeInitialized); @@ -126,9 +119,10 @@ EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime, omptarget_nvptx_TeamDescr &currTeamDescr = getMyTeamDescriptor(); omptarget_nvptx_WorkDescr &workDescr = getMyWorkDescriptor(); // init team context - currTeamDescr.InitTeamDescr(); + currTeamDescr.InitTeamDescr(/*isSPMDExecutionMode=*/true); } - __syncthreads(); + // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. + __SYNCTHREADS(); omptarget_nvptx_TeamDescr &currTeamDescr = getMyTeamDescriptor(); omptarget_nvptx_WorkDescr &workDescr = getMyWorkDescriptor(); @@ -169,17 +163,12 @@ EXTERN __attribute__((deprecated)) void __kmpc_spmd_kernel_deinit() { EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime) { // We're not going to pop the task descr stack of each thread since // there are no more parallel regions in SPMD mode. - __syncthreads(); - int threadId = GetThreadIdInBlock(); - if (!RequiresOMPRuntime) { - if (threadId == 0) { - // Enqueue omp state object for use by another team. - int slot = usedSlotIdx; - omptarget_nvptx_device_simpleState[slot].Enqueue( - omptarget_nvptx_simpleThreadPrivateContext); - } + if (!RequiresOMPRuntime) return; - } + + // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. + __SYNCTHREADS(); + int threadId = GetThreadIdInBlock(); if (threadId == 0) { // Enqueue omp state object for use by another team. int slot = usedSlotIdx; @@ -190,5 +179,6 @@ EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime) { // Return true if the current target region is executed in SPMD mode. EXTERN int8_t __kmpc_is_spmd_exec_mode() { + PRINT0(LD_IO | LD_PAR, "call to __kmpc_is_spmd_exec_mode\n"); return isSPMDMode(); } diff --git a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h index b63feae..d178b57 100644 --- a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h +++ b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h @@ -1,9 +1,8 @@ //===---- omptarget-nvptx.h - NVPTX OpenMP GPU initialization ---- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -53,16 +52,17 @@ #define __SHFL_SYNC(mask, var, srcLane) __shfl_sync((mask), (var), (srcLane)) #define __SHFL_DOWN_SYNC(mask, var, delta, width) \ __shfl_down_sync((mask), (var), (delta), (width)) -#define __BALLOT_SYNC(mask, predicate) __ballot_sync((mask), (predicate)) #define __ACTIVEMASK() __activemask() #else #define __SHFL_SYNC(mask, var, srcLane) __shfl((var), (srcLane)) #define __SHFL_DOWN_SYNC(mask, var, delta, width) \ __shfl_down((var), (delta), (width)) -#define __BALLOT_SYNC(mask, predicate) __ballot((predicate)) #define __ACTIVEMASK() __ballot(1) #endif +#define __SYNCTHREADS_N(n) asm volatile("bar.sync %0;" : : "r"(n) : "memory"); +#define __SYNCTHREADS() __SYNCTHREADS_N(0) + // arguments needed for L0 parallelism only. class omptarget_nvptx_SharedArgs { public: @@ -90,7 +90,7 @@ public: } } // Called by all threads. - INLINE void **GetArgs() { return args; }; + INLINE void **GetArgs() const { return args; }; private: // buffer of pre-allocated arguments. void *buffer[MAX_SHARED_ARGS]; @@ -101,7 +101,8 @@ private: uint32_t nArgs; }; -extern __device__ __shared__ omptarget_nvptx_SharedArgs omptarget_nvptx_globalArgs; +extern __device__ __shared__ omptarget_nvptx_SharedArgs + omptarget_nvptx_globalArgs; // Data sharing related quantities, need to match what is used in the compiler. enum DATA_SHARING_SIZES { @@ -152,28 +153,28 @@ extern __device__ __shared__ DataSharingStateTy DataSharingState; class omptarget_nvptx_TaskDescr { public: // methods for flags - INLINE omp_sched_t GetRuntimeSched(); + INLINE omp_sched_t GetRuntimeSched() const; INLINE void SetRuntimeSched(omp_sched_t sched); - INLINE int InParallelRegion() { return items.flags & TaskDescr_InPar; } - INLINE int InL2OrHigherParallelRegion() { + INLINE int InParallelRegion() const { return items.flags & TaskDescr_InPar; } + INLINE int InL2OrHigherParallelRegion() const { return items.flags & TaskDescr_InParL2P; } - INLINE int IsParallelConstruct() { + INLINE int IsParallelConstruct() const { return items.flags & TaskDescr_IsParConstr; } - INLINE int IsTaskConstruct() { return !IsParallelConstruct(); } + INLINE int IsTaskConstruct() const { return !IsParallelConstruct(); } // methods for other fields INLINE uint16_t &NThreads() { return items.nthreads; } INLINE uint16_t &ThreadLimit() { return items.threadlimit; } INLINE uint16_t &ThreadId() { return items.threadId; } INLINE uint16_t &ThreadsInTeam() { return items.threadsInTeam; } INLINE uint64_t &RuntimeChunkSize() { return items.runtimeChunkSize; } - INLINE omptarget_nvptx_TaskDescr *GetPrevTaskDescr() { return prev; } + INLINE omptarget_nvptx_TaskDescr *GetPrevTaskDescr() const { return prev; } INLINE void SetPrevTaskDescr(omptarget_nvptx_TaskDescr *taskDescr) { prev = taskDescr; } // init & copy - INLINE void InitLevelZeroTaskDescr(); + INLINE void InitLevelZeroTaskDescr(bool isSPMDExecutionMode); INLINE void InitLevelOneTaskDescr(uint16_t tnum, omptarget_nvptx_TaskDescr *parentTaskDescr); INLINE void Copy(omptarget_nvptx_TaskDescr *sourceTaskDescr); @@ -254,7 +255,7 @@ public: INLINE uint64_t *getLastprivateIterBuffer() { return &lastprivateIterBuffer; } // init - INLINE void InitTeamDescr(); + INLINE void InitTeamDescr(bool isSPMDExecutionMode); INLINE __kmpc_data_sharing_slot *RootS(int wid, bool IsMasterThread) { // If this is invoked by the master thread of the master warp then intialize @@ -323,7 +324,7 @@ public: omptarget_nvptx_TaskDescr *taskICV) { topTaskDescr[tid] = taskICV; } - INLINE omptarget_nvptx_TaskDescr *GetTopLevelTaskDescr(int tid); + INLINE omptarget_nvptx_TaskDescr *GetTopLevelTaskDescr(int tid) const; // parallel INLINE uint16_t &NumThreadsForNextParallel(int tid) { return nextRegion.tnum[tid]; @@ -342,6 +343,7 @@ public: INLINE omptarget_nvptx_TeamDescr &TeamContext() { return teamContext; } INLINE void InitThreadPrivateContext(int tid); + INLINE uint64_t &Cnt() { return cnt; } private: // team context for this team @@ -364,6 +366,7 @@ private: // state for dispatch with dyn/guided OR static (never use both at a time) int64_t nextLowerBound[MAX_THREADS_PER_TEAM]; int64_t stride[MAX_THREADS_PER_TEAM]; + uint64_t cnt; }; /// Device envrionment data @@ -378,7 +381,7 @@ private: volatile unsigned keys[OMP_STATE_COUNT]; } MemData[MAX_SM]; - INLINE uint32_t hash(unsigned key) const { + INLINE static uint32_t hash(unsigned key) { return key & (OMP_STATE_COUNT - 1); } @@ -387,39 +390,6 @@ public: INLINE const void *Acquire(const void *buf, size_t size); }; -class omptarget_nvptx_SimpleThreadPrivateContext { - uint16_t par_level[MAX_THREADS_PER_TEAM]; - -public: - INLINE void Init() { - ASSERT0(LT_FUSSY, isSPMDMode() && isRuntimeUninitialized(), - "Expected SPMD + uninitialized runtime modes."); - par_level[GetThreadIdInBlock()] = 0; - } - INLINE void IncParLevel() { - ASSERT0(LT_FUSSY, isSPMDMode() && isRuntimeUninitialized(), - "Expected SPMD + uninitialized runtime modes."); - ++par_level[GetThreadIdInBlock()]; - } - INLINE void DecParLevel() { - ASSERT0(LT_FUSSY, isSPMDMode() && isRuntimeUninitialized(), - "Expected SPMD + uninitialized runtime modes."); - ASSERT0(LT_FUSSY, par_level[GetThreadIdInBlock()] > 0, - "Expected parallel level >0."); - --par_level[GetThreadIdInBlock()]; - } - INLINE bool InL2OrHigherParallelRegion() const { - ASSERT0(LT_FUSSY, isSPMDMode() && isRuntimeUninitialized(), - "Expected SPMD + uninitialized runtime modes."); - return par_level[GetThreadIdInBlock()] > 0; - } - INLINE uint16_t GetParallelLevel() const { - ASSERT0(LT_FUSSY, isSPMDMode() && isRuntimeUninitialized(), - "Expected SPMD + uninitialized runtime modes."); - return par_level[GetThreadIdInBlock()] + 1; - } -}; - //////////////////////////////////////////////////////////////////////////////// // global device envrionment //////////////////////////////////////////////////////////////////////////////// @@ -436,10 +406,9 @@ extern __device__ omptarget_nvptx_SimpleMemoryManager omptarget_nvptx_simpleMemoryManager; extern __device__ __shared__ uint32_t usedMemIdx; extern __device__ __shared__ uint32_t usedSlotIdx; +extern __device__ __shared__ uint8_t parallelLevel; extern __device__ __shared__ omptarget_nvptx_ThreadPrivateContext *omptarget_nvptx_threadPrivateContext; -extern __device__ __shared__ omptarget_nvptx_SimpleThreadPrivateContext - *omptarget_nvptx_simpleThreadPrivateContext; extern __device__ __shared__ uint32_t execution_param; extern __device__ __shared__ void *ReductionScratchpadPtr; @@ -459,7 +428,8 @@ extern volatile __device__ __shared__ omptarget_nvptx_WorkFn INLINE omptarget_nvptx_TeamDescr &getMyTeamDescriptor(); INLINE omptarget_nvptx_WorkDescr &getMyWorkDescriptor(); -INLINE omptarget_nvptx_TaskDescr *getMyTopTaskDescriptor(); +INLINE omptarget_nvptx_TaskDescr * +getMyTopTaskDescriptor(bool isSPMDExecutionMode); INLINE omptarget_nvptx_TaskDescr *getMyTopTaskDescriptor(int globalThreadId); //////////////////////////////////////////////////////////////////////////////// diff --git a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptxi.h b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptxi.h index f325601..17e96ee 100644 --- a/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptxi.h +++ b/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptxi.h @@ -1,9 +1,8 @@ //===---- omptarget-nvptxi.h - NVPTX OpenMP GPU initialization --- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -16,7 +15,7 @@ // Task Descriptor //////////////////////////////////////////////////////////////////////////////// -INLINE omp_sched_t omptarget_nvptx_TaskDescr::GetRuntimeSched() { +INLINE omp_sched_t omptarget_nvptx_TaskDescr::GetRuntimeSched() const { // sched starts from 1..4; encode it as 0..3; so add 1 here uint8_t rc = (items.flags & TaskDescr_SchedMask) + 1; return (omp_sched_t)rc; @@ -31,7 +30,8 @@ INLINE void omptarget_nvptx_TaskDescr::SetRuntimeSched(omp_sched_t sched) { items.flags |= val; } -INLINE void omptarget_nvptx_TaskDescr::InitLevelZeroTaskDescr() { +INLINE void +omptarget_nvptx_TaskDescr::InitLevelZeroTaskDescr(bool isSPMDExecutionMode) { // slow method // flag: // default sched is static, @@ -39,7 +39,7 @@ INLINE void omptarget_nvptx_TaskDescr::InitLevelZeroTaskDescr() { // not in parallel items.flags = 0; - items.nthreads = GetNumberOfProcsInTeam(); + items.nthreads = GetNumberOfProcsInTeam(isSPMDExecutionMode); ; // threads: whatever was alloc by kernel items.threadId = 0; // is master items.threadsInTeam = 1; // sequential @@ -154,7 +154,7 @@ INLINE void omptarget_nvptx_TaskDescr::RestoreLoopData() const { //////////////////////////////////////////////////////////////////////////////// INLINE omptarget_nvptx_TaskDescr * -omptarget_nvptx_ThreadPrivateContext::GetTopLevelTaskDescr(int tid) { +omptarget_nvptx_ThreadPrivateContext::GetTopLevelTaskDescr(int tid) const { ASSERT0( LT_FUSSY, tid < MAX_THREADS_PER_TEAM, "Getting top level, tid is larger than allocated data structure size"); @@ -177,8 +177,8 @@ omptarget_nvptx_ThreadPrivateContext::InitThreadPrivateContext(int tid) { // Team Descriptor //////////////////////////////////////////////////////////////////////////////// -INLINE void omptarget_nvptx_TeamDescr::InitTeamDescr() { - levelZeroTaskDescr.InitLevelZeroTaskDescr(); +INLINE void omptarget_nvptx_TeamDescr::InitTeamDescr(bool isSPMDExecutionMode) { + levelZeroTaskDescr.InitLevelZeroTaskDescr(isSPMDExecutionMode); } //////////////////////////////////////////////////////////////////////////////// @@ -199,8 +199,9 @@ INLINE omptarget_nvptx_TaskDescr *getMyTopTaskDescriptor(int threadId) { return omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId); } -INLINE omptarget_nvptx_TaskDescr *getMyTopTaskDescriptor() { - return getMyTopTaskDescriptor(GetLogicalThreadIdInBlock()); +INLINE omptarget_nvptx_TaskDescr * +getMyTopTaskDescriptor(bool isSPMDExecutionMode) { + return getMyTopTaskDescriptor(GetLogicalThreadIdInBlock(isSPMDExecutionMode)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/libomptarget/deviceRTLs/nvptx/src/option.h b/libomptarget/deviceRTLs/nvptx/src/option.h index 37ab818..a6f4040 100644 --- a/libomptarget/deviceRTLs/nvptx/src/option.h +++ b/libomptarget/deviceRTLs/nvptx/src/option.h @@ -1,9 +1,8 @@ //===------------ option.h - NVPTX OpenMP GPU options ------------ CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/deviceRTLs/nvptx/src/parallel.cu b/libomptarget/deviceRTLs/nvptx/src/parallel.cu index fbcbeab..8f3943d 100644 --- a/libomptarget/deviceRTLs/nvptx/src/parallel.cu +++ b/libomptarget/deviceRTLs/nvptx/src/parallel.cu @@ -1,9 +1,8 @@ //===---- parallel.cu - NVPTX OpenMP parallel implementation ----- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -57,7 +56,7 @@ EXTERN bool __kmpc_kernel_convergent_simd(void *buffer, uint32_t Mask, asm("mov.u32 %0, %%lanemask_lt;" : "=r"(lanemask_lt)); *LaneId = __popc(ConvergentMask & lanemask_lt); - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); int sourceThreadId = (threadId & ~(WARPSIZE - 1)) + *LaneSource; ConvergentSimdJob *job = (ConvergentSimdJob *)buffer; @@ -101,7 +100,7 @@ EXTERN bool __kmpc_kernel_convergent_simd(void *buffer, uint32_t Mask, EXTERN void __kmpc_kernel_end_convergent_simd(void *buffer) { PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_end_convergent_parallel\n"); // pop stack - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); ConvergentSimdJob *job = (ConvergentSimdJob *)buffer; omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(threadId) = job->slimForNextSimd; @@ -131,7 +130,7 @@ EXTERN bool __kmpc_kernel_convergent_parallel(void *buffer, uint32_t Mask, asm("mov.u32 %0, %%lanemask_lt;" : "=r"(lanemask_lt)); uint32_t OmpId = __popc(ConvergentMask & lanemask_lt); - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); int sourceThreadId = (threadId & ~(WARPSIZE - 1)) + *LaneSource; ConvergentParallelJob *job = (ConvergentParallelJob *)buffer; @@ -181,7 +180,7 @@ EXTERN bool __kmpc_kernel_convergent_parallel(void *buffer, uint32_t Mask, EXTERN void __kmpc_kernel_end_convergent_parallel(void *buffer) { PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_end_convergent_parallel\n"); // pop stack - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); ConvergentParallelJob *job = (ConvergentParallelJob *)buffer; omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr( threadId, job->convHeadTaskDescr); @@ -193,7 +192,7 @@ EXTERN void __kmpc_kernel_end_convergent_parallel(void *buffer) { // support for parallel that goes parallel (1 static level only) //////////////////////////////////////////////////////////////////////////////// -static INLINE uint16_t determineNumberOfThreads(uint16_t NumThreadsClause, +INLINE static uint16_t determineNumberOfThreads(uint16_t NumThreadsClause, uint16_t NThreadsICV, uint16_t ThreadLimit) { uint16_t ThreadsRequested = NThreadsICV; @@ -236,7 +235,7 @@ EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, // This routine is only called by the team master. The team master is // the first thread of the last warp. It always has the logical thread // id of 0 (since it is a shadow for the first worker thread). - int threadId = 0; + const int threadId = 0; omptarget_nvptx_TaskDescr *currTaskDescr = omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId); ASSERT0(LT_FUSSY, currTaskDescr, "expected a top task descr"); @@ -284,8 +283,10 @@ EXTERN bool __kmpc_kernel_parallel(void **WorkFn, *WorkFn = omptarget_nvptx_workFn; // If this is the termination signal from the master, quit early. - if (!*WorkFn) + if (!*WorkFn) { + PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_parallel finished\n"); return false; + } // Only the worker threads call this routine and the master warp // never arrives here. Therefore, use the nvptx thread id. @@ -338,12 +339,16 @@ EXTERN void __kmpc_serialized_parallel(kmp_Ident *loc, uint32_t global_tid) { if (checkRuntimeUninitialized(loc)) { ASSERT0(LT_FUSSY, checkSPMDMode(loc), "Expected SPMD mode with uninitialized runtime."); - omptarget_nvptx_simpleThreadPrivateContext->IncParLevel(); + __SYNCTHREADS(); + if (GetThreadIdInBlock() == 0) + ++parallelLevel; + __SYNCTHREADS(); + return; } // assume this is only called for nested parallel - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); // unlike actual parallel, threads in the same team do not share // the workTaskDescr in this case and num threads is fixed to 1 @@ -377,12 +382,15 @@ EXTERN void __kmpc_end_serialized_parallel(kmp_Ident *loc, if (checkRuntimeUninitialized(loc)) { ASSERT0(LT_FUSSY, checkSPMDMode(loc), "Expected SPMD mode with uninitialized runtime."); - omptarget_nvptx_simpleThreadPrivateContext->DecParLevel(); + __SYNCTHREADS(); + if (GetThreadIdInBlock() == 0) + --parallelLevel; + __SYNCTHREADS(); return; } // pop stack - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(threadId); // set new top omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr( @@ -399,10 +407,10 @@ EXTERN uint16_t __kmpc_parallel_level(kmp_Ident *loc, uint32_t global_tid) { if (checkRuntimeUninitialized(loc)) { ASSERT0(LT_FUSSY, checkSPMDMode(loc), "Expected SPMD mode with uninitialized runtime."); - return omptarget_nvptx_simpleThreadPrivateContext->GetParallelLevel(); + return parallelLevel; } - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *currTaskDescr = omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId); if (currTaskDescr->InL2OrHigherParallelRegion()) @@ -418,7 +426,7 @@ EXTERN uint16_t __kmpc_parallel_level(kmp_Ident *loc, uint32_t global_tid) { // it's cheap to recalculate this value so we never use the result // of this call. EXTERN int32_t __kmpc_global_thread_num(kmp_Ident *loc) { - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); return GetOmpThreadId(tid, checkSPMDMode(loc), checkRuntimeUninitialized(loc)); } @@ -431,7 +439,7 @@ EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t tid, int32_t num_threads) { PRINT(LD_IO, "call kmpc_push_num_threads %d\n", num_threads); ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Runtime must be initialized."); - tid = GetLogicalThreadIdInBlock(); + tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(tid) = num_threads; } @@ -440,7 +448,7 @@ EXTERN void __kmpc_push_simd_limit(kmp_Ident *loc, int32_t tid, int32_t simd_limit) { PRINT(LD_IO, "call kmpc_push_simd_limit %d\n", (int)simd_limit); ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Runtime must be initialized."); - tid = GetLogicalThreadIdInBlock(); + tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(tid) = simd_limit; } diff --git a/libomptarget/deviceRTLs/nvptx/src/reduction.cu b/libomptarget/deviceRTLs/nvptx/src/reduction.cu index c0d22df..88f4558 100644 --- a/libomptarget/deviceRTLs/nvptx/src/reduction.cu +++ b/libomptarget/deviceRTLs/nvptx/src/reduction.cu @@ -1,10 +1,9 @@ //===---- reduction.cu - NVPTX OpenMP reduction implementation ---- CUDA //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -20,8 +19,10 @@ // may eventually remove this EXTERN int32_t __gpu_block_reduce() { - int tid = GetLogicalThreadIdInBlock(); - int nt = GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()); + bool isSPMDExecutionMode = isSPMDMode(); + int tid = GetLogicalThreadIdInBlock(isSPMDExecutionMode); + int nt = + GetNumberOfOmpThreads(tid, isSPMDExecutionMode, isRuntimeUninitialized()); if (nt != blockDim.x) return 0; unsigned tnum = __ACTIVEMASK(); @@ -35,7 +36,7 @@ int32_t __kmpc_reduce_gpu(kmp_Ident *loc, int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, void *reduce_array_size, kmp_ReductFctPtr *reductFct, kmp_CriticalName *lck) { - int threadId = GetLogicalThreadIdInBlock(); + int threadId = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *currTaskDescr = getMyTopTaskDescriptor(threadId); int numthread; if (currTaskDescr->IsParallelConstruct()) { @@ -84,7 +85,7 @@ EXTERN int64_t __kmpc_shuffle_int64(int64_t val, int16_t delta, int16_t size) { return val; } -static INLINE void gpu_regular_warp_reduce(void *reduce_data, +INLINE static void gpu_regular_warp_reduce(void *reduce_data, kmp_ShuffleReductFctPtr shflFct) { for (uint32_t mask = WARPSIZE / 2; mask > 0; mask /= 2) { shflFct(reduce_data, /*LaneId - not used= */ 0, @@ -92,7 +93,7 @@ static INLINE void gpu_regular_warp_reduce(void *reduce_data, } } -static INLINE void gpu_irregular_warp_reduce(void *reduce_data, +INLINE static void gpu_irregular_warp_reduce(void *reduce_data, kmp_ShuffleReductFctPtr shflFct, uint32_t size, uint32_t tid) { uint32_t curr_size; @@ -106,18 +107,18 @@ static INLINE void gpu_irregular_warp_reduce(void *reduce_data, } } -static INLINE uint32_t +INLINE static uint32_t gpu_irregular_simd_reduce(void *reduce_data, kmp_ShuffleReductFctPtr shflFct) { uint32_t lanemask_lt; uint32_t lanemask_gt; uint32_t size, remote_id, physical_lane_id; physical_lane_id = GetThreadIdInBlock() % WARPSIZE; asm("mov.u32 %0, %%lanemask_lt;" : "=r"(lanemask_lt)); - uint32_t Liveness = __BALLOT_SYNC(0xFFFFFFFF, true); + uint32_t Liveness = __ACTIVEMASK(); uint32_t logical_lane_id = __popc(Liveness & lanemask_lt) * 2; asm("mov.u32 %0, %%lanemask_gt;" : "=r"(lanemask_gt)); do { - Liveness = __BALLOT_SYNC(0xFFFFFFFF, true); + Liveness = __ACTIVEMASK(); remote_id = __ffs(Liveness & lanemask_gt); size = __popc(Liveness); logical_lane_id /= 2; @@ -132,7 +133,7 @@ int32_t __kmpc_nvptx_simd_reduce_nowait(int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { - uint32_t Liveness = __BALLOT_SYNC(0xFFFFFFFF, true); + uint32_t Liveness = __ACTIVEMASK(); if (Liveness == 0xffffffff) { gpu_regular_warp_reduce(reduce_data, shflFct); return GetThreadIdInBlock() % WARPSIZE == @@ -144,13 +145,11 @@ int32_t __kmpc_nvptx_simd_reduce_nowait(int32_t global_tid, int32_t num_vars, } INLINE -int32_t nvptx_parallel_reduce_nowait(int32_t global_tid, int32_t num_vars, - size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, - kmp_InterWarpCopyFctPtr cpyFct, - bool isSPMDExecutionMode, - bool isRuntimeUninitialized) { - uint32_t BlockThreadId = GetLogicalThreadIdInBlock(); +static int32_t nvptx_parallel_reduce_nowait( + int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, + kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, + bool isSPMDExecutionMode, bool isRuntimeUninitialized) { + uint32_t BlockThreadId = GetLogicalThreadIdInBlock(isSPMDExecutionMode); uint32_t NumThreads = GetNumberOfOmpThreads( BlockThreadId, isSPMDExecutionMode, isRuntimeUninitialized); if (NumThreads == 1) @@ -193,12 +192,10 @@ int32_t nvptx_parallel_reduce_nowait(int32_t global_tid, int32_t num_vars, if (WarpId == 0) gpu_irregular_warp_reduce(reduce_data, shflFct, WarpsNeeded, BlockThreadId); - - return BlockThreadId == 0; } return BlockThreadId == 0; #else - uint32_t Liveness = __BALLOT_SYNC(0xFFFFFFFF, true); + uint32_t Liveness = __ACTIVEMASK(); if (Liveness == 0xffffffff) // Full warp gpu_regular_warp_reduce(reduce_data, shflFct); else if (!(Liveness & (Liveness + 1))) // Partial warp but contiguous lanes @@ -236,8 +233,7 @@ int32_t nvptx_parallel_reduce_nowait(int32_t global_tid, int32_t num_vars, #endif // __CUDA_ARCH__ >= 700 } -EXTERN -int32_t __kmpc_nvptx_parallel_reduce_nowait( +EXTERN __attribute__((deprecated)) int32_t __kmpc_nvptx_parallel_reduce_nowait( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { return nvptx_parallel_reduce_nowait( @@ -247,6 +243,16 @@ int32_t __kmpc_nvptx_parallel_reduce_nowait( } EXTERN +int32_t __kmpc_nvptx_parallel_reduce_nowait_v2( + kmp_Ident *loc, int32_t global_tid, int32_t num_vars, size_t reduce_size, + void *reduce_data, kmp_ShuffleReductFctPtr shflFct, + kmp_InterWarpCopyFctPtr cpyFct) { + return nvptx_parallel_reduce_nowait( + global_tid, num_vars, reduce_size, reduce_data, shflFct, cpyFct, + checkSPMDMode(loc), checkRuntimeUninitialized(loc)); +} + +EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_spmd( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { @@ -267,12 +273,12 @@ int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_generic( } INLINE -int32_t nvptx_teams_reduce_nowait( +static int32_t nvptx_teams_reduce_nowait( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, kmp_CopyToScratchpadFctPtr scratchFct, kmp_LoadReduceFctPtr ldFct, bool isSPMDExecutionMode, bool isRuntimeUninitialized) { - uint32_t ThreadId = GetLogicalThreadIdInBlock(); + uint32_t ThreadId = GetLogicalThreadIdInBlock(isSPMDExecutionMode); // In non-generic mode all workers participate in the teams reduction. // In generic mode only the team master participates in the teams // reduction because the workers are waiting for parallel work. @@ -367,7 +373,7 @@ int32_t nvptx_teams_reduce_nowait( ldFct(reduce_data, scratchpad, i, NumTeams, /*Load and reduce*/ 1); // Reduce across warps to the warp master. - uint32_t Liveness = __BALLOT_SYNC(0xFFFFFFFF, true); + uint32_t Liveness = __ACTIVEMASK(); if (Liveness == 0xffffffff) // Full warp gpu_regular_warp_reduce(reduce_data, shflFct); else // Partial warp but contiguous lanes diff --git a/libomptarget/deviceRTLs/nvptx/src/state-queue.h b/libomptarget/deviceRTLs/nvptx/src/state-queue.h index accb1f7..9d7576b 100644 --- a/libomptarget/deviceRTLs/nvptx/src/state-queue.h +++ b/libomptarget/deviceRTLs/nvptx/src/state-queue.h @@ -1,9 +1,8 @@ //===--------- statequeue.h - NVPTX OpenMP GPU State Queue ------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -35,14 +34,14 @@ private: static const uint32_t MAX_ID = (1u << 31) / SIZE / 2; INLINE uint32_t ENQUEUE_TICKET(); INLINE uint32_t DEQUEUE_TICKET(); - INLINE uint32_t ID(uint32_t ticket); + INLINE static uint32_t ID(uint32_t ticket); INLINE bool IsServing(uint32_t slot, uint32_t id); INLINE void PushElement(uint32_t slot, ElementType *element); INLINE ElementType *PopElement(uint32_t slot); INLINE void DoneServing(uint32_t slot, uint32_t id); public: - INLINE omptarget_nvptx_Queue(){}; + INLINE omptarget_nvptx_Queue() {} INLINE void Enqueue(ElementType *element); INLINE ElementType *Dequeue(); }; diff --git a/libomptarget/deviceRTLs/nvptx/src/state-queuei.h b/libomptarget/deviceRTLs/nvptx/src/state-queuei.h index c9ffd54..3c3be11 100644 --- a/libomptarget/deviceRTLs/nvptx/src/state-queuei.h +++ b/libomptarget/deviceRTLs/nvptx/src/state-queuei.h @@ -1,9 +1,8 @@ //===------- state-queue.cu - NVPTX OpenMP GPU State Queue ------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -30,7 +29,8 @@ INLINE uint32_t omptarget_nvptx_Queue<ElementType, SIZE>::DEQUEUE_TICKET() { } template <typename ElementType, uint32_t SIZE> -INLINE uint32_t omptarget_nvptx_Queue<ElementType, SIZE>::ID(uint32_t ticket) { +INLINE uint32_t +omptarget_nvptx_Queue<ElementType, SIZE>::ID(uint32_t ticket) { return (ticket / SIZE) * 2; } diff --git a/libomptarget/deviceRTLs/nvptx/src/support.h b/libomptarget/deviceRTLs/nvptx/src/support.h index 44298f4..5d4b403 100644 --- a/libomptarget/deviceRTLs/nvptx/src/support.h +++ b/libomptarget/deviceRTLs/nvptx/src/support.h @@ -1,9 +1,8 @@ //===--------- support.h - NVPTX OpenMP support functions -------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -43,7 +42,7 @@ INLINE int GetNumberOfBlocksInKernel(); INLINE int GetNumberOfThreadsInBlock(); // get global ids to locate tread/team info (constant regardless of OMP) -INLINE int GetLogicalThreadIdInBlock(); +INLINE int GetLogicalThreadIdInBlock(bool isSPMDExecutionMode); INLINE int GetMasterThreadID(); INLINE int GetNumberOfWorkersInTeam(); @@ -59,8 +58,8 @@ GetNumberOfOmpThreads(int threadId, bool isSPMDExecutionMode, INLINE int GetNumberOfOmpTeams(); // omp_num_teams // get OpenMP number of procs -INLINE int GetNumberOfProcsInTeam(); -INLINE int GetNumberOfProcsInDevice(); +INLINE int GetNumberOfProcsInTeam(bool isSPMDExecutionMode); +INLINE int GetNumberOfProcsInDevice(bool isSPMDExecutionMode); // masters INLINE int IsTeamMaster(int ompThreadId); diff --git a/libomptarget/deviceRTLs/nvptx/src/supporti.h b/libomptarget/deviceRTLs/nvptx/src/supporti.h index e2ea2d1..2052c17 100644 --- a/libomptarget/deviceRTLs/nvptx/src/supporti.h +++ b/libomptarget/deviceRTLs/nvptx/src/supporti.h @@ -1,9 +1,8 @@ //===--------- supporti.h - NVPTX OpenMP support functions ------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -130,11 +129,11 @@ INLINE int GetNumberOfWorkersInTeam() { return GetMasterThreadID(); } // or a serial region by the master. If the master (whose CUDA thread // id is GetMasterThreadID()) calls this routine, we return 0 because // it is a shadow for the first worker. -INLINE int GetLogicalThreadIdInBlock() { +INLINE int GetLogicalThreadIdInBlock(bool isSPMDExecutionMode) { // Implemented using control flow (predication) instead of with a modulo // operation. int tid = GetThreadIdInBlock(); - if (isGenericMode() && tid >= GetMasterThreadID()) + if (!isSPMDExecutionMode && tid >= GetMasterThreadID()) return 0; else return tid; @@ -155,8 +154,7 @@ INLINE int GetOmpThreadId(int threadId, bool isSPMDExecutionMode, ASSERT0(LT_FUSSY, isSPMDExecutionMode, "Uninitialized runtime with non-SPMD mode."); // For level 2 parallelism all parallel regions are executed sequentially. - if (omptarget_nvptx_simpleThreadPrivateContext - ->InL2OrHigherParallelRegion()) + if (parallelLevel > 0) rc = 0; else rc = GetThreadIdInBlock(); @@ -177,8 +175,7 @@ INLINE int GetNumberOfOmpThreads(int threadId, bool isSPMDExecutionMode, ASSERT0(LT_FUSSY, isSPMDExecutionMode, "Uninitialized runtime with non-SPMD mode."); // For level 2 parallelism all parallel regions are executed sequentially. - if (omptarget_nvptx_simpleThreadPrivateContext - ->InL2OrHigherParallelRegion()) + if (parallelLevel > 0) rc = 1; else rc = GetNumberOfThreadsInBlock(); @@ -214,13 +211,15 @@ INLINE int IsTeamMaster(int ompThreadId) { return (ompThreadId == 0); } // get OpenMP number of procs // Get the number of processors in the device. -INLINE int GetNumberOfProcsInDevice() { - if (isGenericMode()) +INLINE int GetNumberOfProcsInDevice(bool isSPMDExecutionMode) { + if (!isSPMDExecutionMode) return GetNumberOfWorkersInTeam(); return GetNumberOfThreadsInBlock(); } -INLINE int GetNumberOfProcsInTeam() { return GetNumberOfProcsInDevice(); } +INLINE int GetNumberOfProcsInTeam(bool isSPMDExecutionMode) { + return GetNumberOfProcsInDevice(isSPMDExecutionMode); +} //////////////////////////////////////////////////////////////////////////////// // Memory @@ -238,8 +237,8 @@ INLINE unsigned long PadBytes(unsigned long size, INLINE void *SafeMalloc(size_t size, const char *msg) // check if success { void *ptr = malloc(size); - PRINT(LD_MEM, "malloc data of size %zu for %s: 0x%llx\n", size, msg, - (unsigned long long)ptr); + PRINT(LD_MEM, "malloc data of size %llu for %s: 0x%llx\n", + (unsigned long long)size, msg, (unsigned long long)ptr); return ptr; } diff --git a/libomptarget/deviceRTLs/nvptx/src/sync.cu b/libomptarget/deviceRTLs/nvptx/src/sync.cu index 7cdb7ff..37471c9 100644 --- a/libomptarget/deviceRTLs/nvptx/src/sync.cu +++ b/libomptarget/deviceRTLs/nvptx/src/sync.cu @@ -1,9 +1,8 @@ //===------------ sync.h - NVPTX OpenMP synchronizations --------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -46,7 +45,7 @@ EXTERN void __kmpc_barrier(kmp_Ident *loc_ref, int32_t tid) { "Expected SPMD mode with uninitialized runtime."); __kmpc_barrier_simple_spmd(loc_ref, tid); } else { - tid = GetLogicalThreadIdInBlock(); + tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc_ref)); omptarget_nvptx_TaskDescr *currTaskDescr = omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(tid); int numberOfActiveOMPThreads = GetNumberOfOmpThreads( @@ -74,7 +73,8 @@ EXTERN void __kmpc_barrier(kmp_Ident *loc_ref, int32_t tid) { // parallel region and that all worker threads participate. EXTERN void __kmpc_barrier_simple_spmd(kmp_Ident *loc_ref, int32_t tid) { PRINT0(LD_SYNC, "call kmpc_barrier_simple_spmd\n"); - __syncthreads(); + // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. + __SYNCTHREADS(); PRINT0(LD_SYNC, "completed kmpc_barrier_simple_spmd\n"); } diff --git a/libomptarget/deviceRTLs/nvptx/src/task.cu b/libomptarget/deviceRTLs/nvptx/src/task.cu index 2f47d4b..d618ff1 100644 --- a/libomptarget/deviceRTLs/nvptx/src/task.cu +++ b/libomptarget/deviceRTLs/nvptx/src/task.cu @@ -1,9 +1,8 @@ //===------------- task.h - NVPTX OpenMP tasks support ----------- CUDA -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -96,7 +95,7 @@ EXTERN int32_t __kmpc_omp_task_with_deps(kmp_Ident *loc, uint32_t global_tid, "bad assumptions"); // 2. push new context: update new task descriptor - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *parentTaskDescr = getMyTopTaskDescriptor(tid); newTaskDescr->CopyForExplicitTask(parentTaskDescr); // set new task descriptor as top @@ -135,7 +134,7 @@ EXTERN void __kmpc_omp_task_begin_if0(kmp_Ident *loc, uint32_t global_tid, "bad assumptions"); // 2. push new context: update new task descriptor - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_TaskDescr *parentTaskDescr = getMyTopTaskDescriptor(tid); newTaskDescr->CopyForExplicitTask(parentTaskDescr); // set new task descriptor as top @@ -163,7 +162,7 @@ EXTERN void __kmpc_omp_task_complete_if0(kmp_Ident *loc, uint32_t global_tid, omptarget_nvptx_TaskDescr *parentTaskDescr = newTaskDescr->GetPrevTaskDescr(); // 3... noting to call... is inline // 4. pop context - int tid = GetLogicalThreadIdInBlock(); + int tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr(tid, parentTaskDescr); // 5. free diff --git a/libomptarget/include/omptarget.h b/libomptarget/include/omptarget.h index e92a94b..512ddbf 100644 --- a/libomptarget/include/omptarget.h +++ b/libomptarget/include/omptarget.h @@ -1,9 +1,8 @@ //===-------- omptarget.h - Target independent OpenMP target RTL -- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/include/omptargetplugin.h b/libomptarget/include/omptargetplugin.h index 35fa059..2876bfb 100644 --- a/libomptarget/include/omptargetplugin.h +++ b/libomptarget/include/omptargetplugin.h @@ -1,9 +1,8 @@ //===-- omptargetplugin.h - Target dependent OpenMP Plugin API --*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/plugins/CMakeLists.txt b/libomptarget/plugins/CMakeLists.txt index 8c3d571..f8048ba 100644 --- a/libomptarget/plugins/CMakeLists.txt +++ b/libomptarget/plugins/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/plugins/aarch64/CMakeLists.txt b/libomptarget/plugins/aarch64/CMakeLists.txt index e3a76b9..350a56c 100644 --- a/libomptarget/plugins/aarch64/CMakeLists.txt +++ b/libomptarget/plugins/aarch64/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/plugins/common/elf_common.c b/libomptarget/plugins/common/elf_common.c index dd85575..60e1e4f 100644 --- a/libomptarget/plugins/common/elf_common.c +++ b/libomptarget/plugins/common/elf_common.c @@ -1,9 +1,8 @@ //===-- elf_common.c - Common ELF functionality -------------------*- C -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/plugins/cuda/CMakeLists.txt b/libomptarget/plugins/cuda/CMakeLists.txt index 7210eec..5fab421 100644 --- a/libomptarget/plugins/cuda/CMakeLists.txt +++ b/libomptarget/plugins/cuda/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/plugins/cuda/src/rtl.cpp b/libomptarget/plugins/cuda/src/rtl.cpp index d265a87..fc0c1ec 100644 --- a/libomptarget/plugins/cuda/src/rtl.cpp +++ b/libomptarget/plugins/cuda/src/rtl.cpp @@ -1,9 +1,8 @@ //===----RTLs/cuda/src/rtl.cpp - Target RTLs Implementation ------- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp b/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp index 951710a..4648e51 100644 --- a/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp +++ b/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp @@ -1,9 +1,8 @@ //===-RTLs/generic-64bit/src/rtl.cpp - Target RTLs Implementation - C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/plugins/ppc64/CMakeLists.txt b/libomptarget/plugins/ppc64/CMakeLists.txt index 6849a03..3915196 100644 --- a/libomptarget/plugins/ppc64/CMakeLists.txt +++ b/libomptarget/plugins/ppc64/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/plugins/ppc64le/CMakeLists.txt b/libomptarget/plugins/ppc64le/CMakeLists.txt index 87cefdf..0cfe7c0 100644 --- a/libomptarget/plugins/ppc64le/CMakeLists.txt +++ b/libomptarget/plugins/ppc64le/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/plugins/x86_64/CMakeLists.txt b/libomptarget/plugins/x86_64/CMakeLists.txt index bdd5bba..f61e1e8 100644 --- a/libomptarget/plugins/x86_64/CMakeLists.txt +++ b/libomptarget/plugins/x86_64/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # diff --git a/libomptarget/src/CMakeLists.txt b/libomptarget/src/CMakeLists.txt index be099f3..f30087e 100644 --- a/libomptarget/src/CMakeLists.txt +++ b/libomptarget/src/CMakeLists.txt @@ -1,9 +1,8 @@ ##===----------------------------------------------------------------------===## # -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # ##===----------------------------------------------------------------------===## # @@ -28,4 +27,5 @@ target_link_libraries(omptarget "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports") # Install libomptarget under the lib destination folder. -install(TARGETS omptarget LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") +install(TARGETS omptarget LIBRARY COMPONENT omptarget + DESTINATION "${OPENMP_INSTALL_LIBDIR}") diff --git a/libomptarget/src/api.cpp b/libomptarget/src/api.cpp index 15c1d2c..430425a 100644 --- a/libomptarget/src/api.cpp +++ b/libomptarget/src/api.cpp @@ -1,9 +1,8 @@ //===----------- api.cpp - Target independent OpenMP target RTL -----------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/device.cpp b/libomptarget/src/device.cpp index bac6127..ff99701 100644 --- a/libomptarget/src/device.cpp +++ b/libomptarget/src/device.cpp @@ -1,9 +1,8 @@ //===--------- device.cpp - Target independent OpenMP target RTL ----------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/device.h b/libomptarget/src/device.h index 3c205d6..afd92ac 100644 --- a/libomptarget/src/device.h +++ b/libomptarget/src/device.h @@ -1,9 +1,8 @@ //===----------- device.h - Target independent OpenMP target RTL ----------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/interface.cpp b/libomptarget/src/interface.cpp index 266e085..95a05a5 100644 --- a/libomptarget/src/interface.cpp +++ b/libomptarget/src/interface.cpp @@ -1,9 +1,8 @@ //===-------- interface.cpp - Target independent OpenMP target RTL --------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/omptarget.cpp b/libomptarget/src/omptarget.cpp index a23d82b..8272b4e 100644 --- a/libomptarget/src/omptarget.cpp +++ b/libomptarget/src/omptarget.cpp @@ -1,9 +1,8 @@ //===------ omptarget.cpp - Target independent OpenMP target RTL -- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/private.h b/libomptarget/src/private.h index 3b61295..b48415c 100644 --- a/libomptarget/src/private.h +++ b/libomptarget/src/private.h @@ -1,9 +1,8 @@ //===---------- private.h - Target independent OpenMP target RTL ----------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/rtl.cpp b/libomptarget/src/rtl.cpp index fd46477..d1d882f 100644 --- a/libomptarget/src/rtl.cpp +++ b/libomptarget/src/rtl.cpp @@ -1,9 +1,8 @@ //===----------- rtl.cpp - Target independent OpenMP target RTL -----------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/src/rtl.h b/libomptarget/src/rtl.h index 2533e2c..5778eee 100644 --- a/libomptarget/src/rtl.h +++ b/libomptarget/src/rtl.h @@ -1,9 +1,8 @@ //===------------ rtl.h - Target independent OpenMP target RTL ------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/libomptarget/test/api/omp_get_num_devices.c b/libomptarget/test/api/omp_get_num_devices.c new file mode 100644 index 0000000..d0e84db --- /dev/null +++ b/libomptarget/test/api/omp_get_num_devices.c @@ -0,0 +1,36 @@ +// RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu +// RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu +// RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu +// RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu + +#include <stdio.h> +#include <omp.h> + +int test_omp_get_num_devices() +{ + /* checks that omp_get_num_devices() > 0 */ + int num_devices = omp_get_num_devices(); + printf("num_devices = %d\n", num_devices); + + #pragma omp target + {} + + return (num_devices > 0); +} + +int main() +{ + int i; + int failed=0; + + if (!test_omp_get_num_devices()) { + failed++; + } + if (failed) + printf("FAIL\n"); + else + printf("PASS\n"); + return failed; +} + +// CHECK: PASS diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 447b3cd..088edd4 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompCheckFortranFlag.cmake b/runtime/cmake/LibompCheckFortranFlag.cmake index c37b3ad..21837ef 100644 --- a/runtime/cmake/LibompCheckFortranFlag.cmake +++ b/runtime/cmake/LibompCheckFortranFlag.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompCheckLinkerFlag.cmake b/runtime/cmake/LibompCheckLinkerFlag.cmake index 75a38e3..81ce9b0 100644 --- a/runtime/cmake/LibompCheckLinkerFlag.cmake +++ b/runtime/cmake/LibompCheckLinkerFlag.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompDefinitions.cmake b/runtime/cmake/LibompDefinitions.cmake index c4cfbb9..cc93ad0 100644 --- a/runtime/cmake/LibompDefinitions.cmake +++ b/runtime/cmake/LibompDefinitions.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompExports.cmake b/runtime/cmake/LibompExports.cmake index 1893b9f..e252c62 100644 --- a/runtime/cmake/LibompExports.cmake +++ b/runtime/cmake/LibompExports.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # @@ -57,7 +56,7 @@ add_custom_command(TARGET omp POST_BUILD ) if(${LIBOMP_OMPT_SUPPORT}) add_custom_command(TARGET omp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ompt.h ${LIBOMP_EXPORTS_CMN_DIR} + COMMAND ${CMAKE_COMMAND} -E copy omp-tools.h ${LIBOMP_EXPORTS_CMN_DIR} ) endif() if(${LIBOMP_FORTRAN_MODULES}) diff --git a/runtime/cmake/LibompGetArchitecture.cmake b/runtime/cmake/LibompGetArchitecture.cmake index 536b488..e65cd30 100644 --- a/runtime/cmake/LibompGetArchitecture.cmake +++ b/runtime/cmake/LibompGetArchitecture.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompHandleFlags.cmake b/runtime/cmake/LibompHandleFlags.cmake index 0b829a5..1690b2b 100644 --- a/runtime/cmake/LibompHandleFlags.cmake +++ b/runtime/cmake/LibompHandleFlags.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompMicroTests.cmake b/runtime/cmake/LibompMicroTests.cmake index bdecf7f..38f4486 100644 --- a/runtime/cmake/LibompMicroTests.cmake +++ b/runtime/cmake/LibompMicroTests.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/LibompUtils.cmake b/runtime/cmake/LibompUtils.cmake index f4cfa8c..179c8d0 100644 --- a/runtime/cmake/LibompUtils.cmake +++ b/runtime/cmake/LibompUtils.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/cmake/config-ix.cmake b/runtime/cmake/config-ix.cmake index 019c83c..5404715 100644 --- a/runtime/cmake/config-ix.cmake +++ b/runtime/cmake/config-ix.cmake @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/doc/doxygen/libomp_interface.h b/runtime/doc/doxygen/libomp_interface.h index 7ff2802..1039325 100644 --- a/runtime/doc/doxygen/libomp_interface.h +++ b/runtime/doc/doxygen/libomp_interface.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt index ff922c8..b2403b1 100644 --- a/runtime/src/CMakeLists.txt +++ b/runtime/src/CMakeLists.txt @@ -1,19 +1,18 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # -# Configure omp.h, kmp_config.h and ompt.h if necessary +# Configure omp.h, kmp_config.h and omp-tools.h if necessary configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY) configure_file(kmp_config.h.cmake kmp_config.h @ONLY) if(${LIBOMP_OMPT_SUPPORT}) - configure_file(${LIBOMP_INC_DIR}/ompt.h.var ompt.h @ONLY) + configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY) endif() # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc @@ -325,7 +324,9 @@ install( DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} ) if(${LIBOMP_OMPT_SUPPORT}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ompt.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}) + # install under legacy name ompt.h + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h) endif() if(${LIBOMP_FORTRAN_MODULES}) install(FILES diff --git a/runtime/src/dllexports b/runtime/src/dllexports index 963ac61..c10d216 100644 --- a/runtime/src/dllexports +++ b/runtime/src/dllexports @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # @@ -406,6 +405,7 @@ kmpc_set_disp_num_buffers 267 # USED FOR 4.5 __kmpc_critical_with_hint 270 __kmpc_get_target_offload 271 __kmpc_omp_reg_task_with_affinity 272 + __kmpc_pause_resource 273 %endif %endif @@ -510,9 +510,7 @@ kmp_set_warnings_off 780 omp_is_initial_device 869 omp_set_default_device 879 omp_get_default_device 880 - %ifdef stub - omp_get_num_devices 881 - %endif + omp_get_num_devices 881 %endif # OMP_40 # OpenMP 45 @@ -527,8 +525,8 @@ kmp_set_warnings_off 780 omp_get_place_num 876 omp_get_partition_num_places 877 omp_get_partition_place_nums 878 + omp_get_initial_device 882 %ifdef stub - omp_get_initial_device 882 omp_target_alloc 883 omp_target_free 884 omp_target_is_present 885 @@ -547,6 +545,7 @@ kmp_set_disp_num_buffers 890 omp_get_default_allocator 893 omp_alloc 894 omp_free 895 + omp_get_device_num 896 omp_set_affinity_format 748 omp_get_affinity_format 749 omp_display_affinity 750 @@ -555,6 +554,8 @@ kmp_set_disp_num_buffers 890 ompc_get_affinity_format 753 ompc_display_affinity 754 ompc_capture_affinity 755 + omp_pause_resource 756 + omp_pause_resource_all 757 OMP_NULL_ALLOCATOR DATA omp_default_mem_alloc DATA diff --git a/runtime/src/exports_so.txt b/runtime/src/exports_so.txt index dc9effe..e23fa0c 100644 --- a/runtime/src/exports_so.txt +++ b/runtime/src/exports_so.txt @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/src/extractExternal.cpp b/runtime/src/extractExternal.cpp index ba20373..b3e55b5 100644 --- a/runtime/src/extractExternal.cpp +++ b/runtime/src/extractExternal.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/i18n/en_US.txt b/runtime/src/i18n/en_US.txt index 3e5283e..cf262d9 100644 --- a/runtime/src/i18n/en_US.txt +++ b/runtime/src/i18n/en_US.txt @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/src/include/30/omp.h.var b/runtime/src/include/30/omp.h.var index 10bd890..015ce54 100644 --- a/runtime/src/include/30/omp.h.var +++ b/runtime/src/include/30/omp.h.var @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/include/30/omp_lib.f.var b/runtime/src/include/30/omp_lib.f.var index 298df8d..555c941 100644 --- a/runtime/src/include/30/omp_lib.f.var +++ b/runtime/src/include/30/omp_lib.f.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/30/omp_lib.f90.var b/runtime/src/include/30/omp_lib.f90.var index 63539a1..f355e72 100644 --- a/runtime/src/include/30/omp_lib.f90.var +++ b/runtime/src/include/30/omp_lib.f90.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/30/omp_lib.h.var b/runtime/src/include/30/omp_lib.h.var index 3800602..66e7774 100644 --- a/runtime/src/include/30/omp_lib.h.var +++ b/runtime/src/include/30/omp_lib.h.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/40/omp.h.var b/runtime/src/include/40/omp.h.var index b030dbe..977699d 100644 --- a/runtime/src/include/40/omp.h.var +++ b/runtime/src/include/40/omp.h.var @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/include/40/omp_lib.f.var b/runtime/src/include/40/omp_lib.f.var index 63371d8..132d014 100644 --- a/runtime/src/include/40/omp_lib.f.var +++ b/runtime/src/include/40/omp_lib.f.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/40/omp_lib.f90.var b/runtime/src/include/40/omp_lib.f90.var index 9e5a23a..c790601 100644 --- a/runtime/src/include/40/omp_lib.f90.var +++ b/runtime/src/include/40/omp_lib.f90.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/40/omp_lib.h.var b/runtime/src/include/40/omp_lib.h.var index 7c461a8..af35ceb 100644 --- a/runtime/src/include/40/omp_lib.h.var +++ b/runtime/src/include/40/omp_lib.h.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/45/omp.h.var b/runtime/src/include/45/omp.h.var index e222fff..2a1a10a 100644 --- a/runtime/src/include/45/omp.h.var +++ b/runtime/src/include/45/omp.h.var @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -195,4 +194,3 @@ # endif #endif /* __OMP_H */ - diff --git a/runtime/src/include/45/omp_lib.f.var b/runtime/src/include/45/omp_lib.f.var index 74e6bc3..0123d21 100644 --- a/runtime/src/include/45/omp_lib.f.var +++ b/runtime/src/include/45/omp_lib.f.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! @@ -562,6 +561,7 @@ !dec$ attributes alias:'OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'OMP_GET_INITIAL_DEVICE' :: omp_get_initial_device !dec$ attributes alias:'OMP_GET_MAX_TASK_PRIORITY' :: omp_get_max_task_priority !dec$ attributes alias:'omp_init_lock' :: omp_init_lock @@ -642,6 +642,7 @@ !dec$ attributes alias:'_OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'_OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'_OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'_OMP_GET_INITIAL_DEVICE' :: omp_get_initial_device !dec$ attributes alias:'_OMP_GET_MAX_TASK_PRIORTY' :: omp_get_max_task_priority !dec$ attributes alias:'_omp_init_lock' :: omp_init_lock @@ -725,6 +726,7 @@ !dec$ attributes alias:'omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'omp_get_initial_device_'::omp_get_initial_device !dec$ attributes alias:'omp_get_max_task_priority_'::omp_get_max_task_priority !dec$ attributes alias:'omp_init_lock_'::omp_init_lock @@ -800,10 +802,14 @@ !dec$ attributes alias:'_omp_get_proc_bind_' :: omp_get_proc_bind !dec$ attributes alias:'_omp_get_wtime_'::omp_get_wtime !dec$ attributes alias:'_omp_get_wtick_'::omp_get_wtick +!dec$ attributes alias:'_omp_get_default_device_'::omp_get_default_device +!dec$ attributes alias:'_omp_set_default_device_'::omp_set_default_device +!dec$ attributes alias:'_omp_get_num_devices_'::omp_get_num_devices !dec$ attributes alias:'_omp_get_num_teams_'::omp_get_num_teams !dec$ attributes alias:'_omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'_omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'_omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'_omp_get_initial_device_'::omp_get_initial_device !dec$ attributes alias:'_omp_get_max_task_priorty_'::omp_get_max_task_priority !dec$ attributes alias:'_omp_init_lock_'::omp_init_lock @@ -852,4 +858,3 @@ !dec$ endif end module omp_lib - diff --git a/runtime/src/include/45/omp_lib.f90.var b/runtime/src/include/45/omp_lib.f90.var index b5fc44e..87bb4f0 100644 --- a/runtime/src/include/45/omp_lib.f90.var +++ b/runtime/src/include/45/omp_lib.f90.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! diff --git a/runtime/src/include/45/omp_lib.h.var b/runtime/src/include/45/omp_lib.h.var index 58763b3..f9ded8c 100644 --- a/runtime/src/include/45/omp_lib.h.var +++ b/runtime/src/include/45/omp_lib.h.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! @@ -523,6 +522,7 @@ !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_default_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_set_default_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_is_initial_device +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_initial_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_num_devices !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_num_teams !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_team_num @@ -595,6 +595,7 @@ !$omp declare target(omp_get_default_device ) !$omp declare target(omp_set_default_device ) !$omp declare target(omp_is_initial_device ) +!$omp declare target(omp_get_initial_device ) !$omp declare target(omp_get_num_devices ) !$omp declare target(omp_get_num_teams ) !$omp declare target(omp_get_team_num ) @@ -641,4 +642,3 @@ !$omp declare target(omp_init_nest_lock_with_hint ) !DIR$ ENDIF !DIR$ ENDIF - diff --git a/runtime/src/include/50/omp-tools.h.var b/runtime/src/include/50/omp-tools.h.var new file mode 100644 index 0000000..d04a2b7 --- /dev/null +++ b/runtime/src/include/50/omp-tools.h.var @@ -0,0 +1,1082 @@ +/* + * include/50/omp-tools.h.var + */ + +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __OMPT__ +#define __OMPT__ + +/***************************************************************************** + * system include files + *****************************************************************************/ + +#include <stdint.h> +#include <stddef.h> + +/***************************************************************************** + * iteration macros + *****************************************************************************/ + +#define FOREACH_OMPT_INQUIRY_FN(macro) \ + macro (ompt_enumerate_states) \ + macro (ompt_enumerate_mutex_impls) \ + \ + macro (ompt_set_callback) \ + macro (ompt_get_callback) \ + \ + macro (ompt_get_state) \ + \ + macro (ompt_get_parallel_info) \ + macro (ompt_get_task_info) \ + macro (ompt_get_task_memory) \ + macro (ompt_get_thread_data) \ + macro (ompt_get_unique_id) \ + macro (ompt_finalize_tool) \ + \ + macro(ompt_get_num_procs) \ + macro(ompt_get_num_places) \ + macro(ompt_get_place_proc_ids) \ + macro(ompt_get_place_num) \ + macro(ompt_get_partition_place_nums) \ + macro(ompt_get_proc_id) \ + \ + macro(ompt_get_target_info) \ + macro(ompt_get_num_devices) + +#define FOREACH_OMPT_STATE(macro) \ + \ + /* first available state */ \ + macro (ompt_state_undefined, 0x102) /* undefined thread state */ \ + \ + /* work states (0..15) */ \ + macro (ompt_state_work_serial, 0x000) /* working outside parallel */ \ + macro (ompt_state_work_parallel, 0x001) /* working within parallel */ \ + macro (ompt_state_work_reduction, 0x002) /* performing a reduction */ \ + \ + /* barrier wait states (16..31) */ \ + macro (ompt_state_wait_barrier, 0x010) /* waiting at a barrier */ \ + macro (ompt_state_wait_barrier_implicit_parallel, 0x011) \ + /* implicit barrier at the end of parallel region */\ + macro (ompt_state_wait_barrier_implicit_workshare, 0x012) \ + /* implicit barrier at the end of worksharing */ \ + macro (ompt_state_wait_barrier_implicit, 0x013) /* implicit barrier */ \ + macro (ompt_state_wait_barrier_explicit, 0x014) /* explicit barrier */ \ + \ + /* task wait states (32..63) */ \ + macro (ompt_state_wait_taskwait, 0x020) /* waiting at a taskwait */ \ + macro (ompt_state_wait_taskgroup, 0x021) /* waiting at a taskgroup */ \ + \ + /* mutex wait states (64..127) */ \ + macro (ompt_state_wait_mutex, 0x040) \ + macro (ompt_state_wait_lock, 0x041) /* waiting for lock */ \ + macro (ompt_state_wait_critical, 0x042) /* waiting for critical */ \ + macro (ompt_state_wait_atomic, 0x043) /* waiting for atomic */ \ + macro (ompt_state_wait_ordered, 0x044) /* waiting for ordered */ \ + \ + /* target wait states (128..255) */ \ + macro (ompt_state_wait_target, 0x080) /* waiting for target region */ \ + macro (ompt_state_wait_target_map, 0x081) /* waiting for target data mapping operation */ \ + macro (ompt_state_wait_target_update, 0x082) /* waiting for target update operation */ \ + \ + /* misc (256..511) */ \ + macro (ompt_state_idle, 0x100) /* waiting for work */ \ + macro (ompt_state_overhead, 0x101) /* overhead excluding wait states */ \ + \ + /* implementation-specific states (512..) */ + + +#define FOREACH_KMP_MUTEX_IMPL(macro) \ + macro (kmp_mutex_impl_none, 0) /* unknown implementation */ \ + macro (kmp_mutex_impl_spin, 1) /* based on spin */ \ + macro (kmp_mutex_impl_queuing, 2) /* based on some fair policy */ \ + macro (kmp_mutex_impl_speculative, 3) /* based on HW-supported speculation */ + +#define FOREACH_OMPT_EVENT(macro) \ + \ + /*--- Mandatory Events ---*/ \ + macro (ompt_callback_thread_begin, ompt_callback_thread_begin_t, 1) /* thread begin */ \ + macro (ompt_callback_thread_end, ompt_callback_thread_end_t, 2) /* thread end */ \ + \ + macro (ompt_callback_parallel_begin, ompt_callback_parallel_begin_t, 3) /* parallel begin */ \ + macro (ompt_callback_parallel_end, ompt_callback_parallel_end_t, 4) /* parallel end */ \ + \ + macro (ompt_callback_task_create, ompt_callback_task_create_t, 5) /* task begin */ \ + macro (ompt_callback_task_schedule, ompt_callback_task_schedule_t, 6) /* task schedule */ \ + macro (ompt_callback_implicit_task, ompt_callback_implicit_task_t, 7) /* implicit task */ \ + \ + macro (ompt_callback_target, ompt_callback_target_t, 8) /* target */ \ + macro (ompt_callback_target_data_op, ompt_callback_target_data_op_t, 9) /* target data op */ \ + macro (ompt_callback_target_submit, ompt_callback_target_submit_t, 10) /* target submit */ \ + \ + macro (ompt_callback_control_tool, ompt_callback_control_tool_t, 11) /* control tool */ \ + \ + macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize */ \ + macro (ompt_callback_device_finalize, ompt_callback_device_finalize_t, 13) /* device finalize */ \ + \ + macro (ompt_callback_device_load, ompt_callback_device_load_t, 14) /* device load */ \ + macro (ompt_callback_device_unload, ompt_callback_device_unload_t, 15) /* device unload */ \ + \ + /* Optional Events */ \ + macro (ompt_callback_sync_region_wait, ompt_callback_sync_region_t, 16) /* sync region wait begin or end */ \ + \ + macro (ompt_callback_mutex_released, ompt_callback_mutex_t, 17) /* mutex released */ \ + \ + macro (ompt_callback_dependences, ompt_callback_dependences_t, 18) /* report task dependences */ \ + macro (ompt_callback_task_dependence, ompt_callback_task_dependence_t, 19) /* report task dependence */ \ + \ + macro (ompt_callback_work, ompt_callback_work_t, 20) /* task at work begin or end */ \ + \ + macro (ompt_callback_master, ompt_callback_master_t, 21) /* task at master begin or end */ \ + \ + macro (ompt_callback_target_map, ompt_callback_target_map_t, 22) /* target map */ \ + \ + macro (ompt_callback_sync_region, ompt_callback_sync_region_t, 23) /* sync region begin or end */ \ + \ + macro (ompt_callback_lock_init, ompt_callback_mutex_acquire_t, 24) /* lock init */ \ + macro (ompt_callback_lock_destroy, ompt_callback_mutex_t, 25) /* lock destroy */ \ + \ + macro (ompt_callback_mutex_acquire, ompt_callback_mutex_acquire_t, 26) /* mutex acquire */ \ + macro (ompt_callback_mutex_acquired, ompt_callback_mutex_t, 27) /* mutex acquired */ \ + \ + macro (ompt_callback_nest_lock, ompt_callback_nest_lock_t, 28) /* nest lock */ \ + \ + macro (ompt_callback_flush, ompt_callback_flush_t, 29) /* after executing flush */ \ + \ + macro (ompt_callback_cancel, ompt_callback_cancel_t, 30) /* cancel innermost binding region */ \ + \ + macro (ompt_callback_reduction, ompt_callback_sync_region_t, 31) /* reduction */ \ + \ + macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */ + +/***************************************************************************** + * implementation specific types + *****************************************************************************/ + +typedef enum kmp_mutex_impl_t { +#define kmp_mutex_impl_macro(impl, code) impl = code, + FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro) +#undef kmp_mutex_impl_macro +} kmp_mutex_impl_t; + +/***************************************************************************** + * definitions generated from spec + *****************************************************************************/ + +typedef enum ompt_callbacks_t { + ompt_callback_thread_begin = 1, + ompt_callback_thread_end = 2, + ompt_callback_parallel_begin = 3, + ompt_callback_parallel_end = 4, + ompt_callback_task_create = 5, + ompt_callback_task_schedule = 6, + ompt_callback_implicit_task = 7, + ompt_callback_target = 8, + ompt_callback_target_data_op = 9, + ompt_callback_target_submit = 10, + ompt_callback_control_tool = 11, + ompt_callback_device_initialize = 12, + ompt_callback_device_finalize = 13, + ompt_callback_device_load = 14, + ompt_callback_device_unload = 15, + ompt_callback_sync_region_wait = 16, + ompt_callback_mutex_released = 17, + ompt_callback_dependences = 18, + ompt_callback_task_dependence = 19, + ompt_callback_work = 20, + ompt_callback_master = 21, + ompt_callback_target_map = 22, + ompt_callback_sync_region = 23, + ompt_callback_lock_init = 24, + ompt_callback_lock_destroy = 25, + ompt_callback_mutex_acquire = 26, + ompt_callback_mutex_acquired = 27, + ompt_callback_nest_lock = 28, + ompt_callback_flush = 29, + ompt_callback_cancel = 30, + ompt_callback_reduction = 31, + ompt_callback_dispatch = 32 +} ompt_callbacks_t; + +typedef enum ompt_record_t { + ompt_record_ompt = 1, + ompt_record_native = 2, + ompt_record_invalid = 3 +} ompt_record_t; + +typedef enum ompt_record_native_t { + ompt_record_native_info = 1, + ompt_record_native_event = 2 +} ompt_record_native_t; + +typedef enum ompt_set_result_t { + ompt_set_error = 0, + ompt_set_never = 1, + ompt_set_impossible = 2, + ompt_set_sometimes = 3, + ompt_set_sometimes_paired = 4, + ompt_set_always = 5 +} ompt_set_result_t; + +typedef uint64_t ompt_id_t; + +typedef uint64_t ompt_device_time_t; + +typedef uint64_t ompt_buffer_cursor_t; + +typedef enum ompt_thread_t { + ompt_thread_initial = 1, + ompt_thread_worker = 2, + ompt_thread_other = 3, + ompt_thread_unknown = 4 +} ompt_thread_t; + +typedef enum ompt_scope_endpoint_t { + ompt_scope_begin = 1, + ompt_scope_end = 2 +} ompt_scope_endpoint_t; + +typedef enum ompt_dispatch_t { + ompt_dispatch_iteration = 1, + ompt_dispatch_section = 2 +} ompt_dispatch_t; + +typedef enum ompt_sync_region_t { + ompt_sync_region_barrier = 1, + ompt_sync_region_barrier_implicit = 2, + ompt_sync_region_barrier_explicit = 3, + ompt_sync_region_barrier_implementation = 4, + ompt_sync_region_taskwait = 5, + ompt_sync_region_taskgroup = 6, + ompt_sync_region_reduction = 7 +} ompt_sync_region_t; + +typedef enum ompt_target_data_op_t { + ompt_target_data_alloc = 1, + ompt_target_data_transfer_to_device = 2, + ompt_target_data_transfer_from_device = 3, + ompt_target_data_delete = 4, + ompt_target_data_associate = 5, + ompt_target_data_disassociate = 6 +} ompt_target_data_op_t; + +typedef enum ompt_work_t { + ompt_work_loop = 1, + ompt_work_sections = 2, + ompt_work_single_executor = 3, + ompt_work_single_other = 4, + ompt_work_workshare = 5, + ompt_work_distribute = 6, + ompt_work_taskloop = 7 +} ompt_work_t; + +typedef enum ompt_mutex_t { + ompt_mutex_lock = 1, + ompt_mutex_test_lock = 2, + ompt_mutex_nest_lock = 3, + ompt_mutex_test_nest_lock = 4, + ompt_mutex_critical = 5, + ompt_mutex_atomic = 6, + ompt_mutex_ordered = 7 +} ompt_mutex_t; + +typedef enum ompt_native_mon_flag_t { + ompt_native_data_motion_explicit = 0x01, + ompt_native_data_motion_implicit = 0x02, + ompt_native_kernel_invocation = 0x04, + ompt_native_kernel_execution = 0x08, + ompt_native_driver = 0x10, + ompt_native_runtime = 0x20, + ompt_native_overhead = 0x40, + ompt_native_idleness = 0x80 +} ompt_native_mon_flag_t; + +typedef enum ompt_task_flag_t { + ompt_task_initial = 0x00000001, + ompt_task_implicit = 0x00000002, + ompt_task_explicit = 0x00000004, + ompt_task_target = 0x00000008, + ompt_task_undeferred = 0x08000000, + ompt_task_untied = 0x10000000, + ompt_task_final = 0x20000000, + ompt_task_mergeable = 0x40000000, + ompt_task_merged = 0x80000000 +} ompt_task_flag_t; + +typedef enum ompt_task_status_t { + ompt_task_complete = 1, + ompt_task_yield = 2, + ompt_task_cancel = 3, + ompt_task_detach = 4, + ompt_task_early_fulfill = 5, + ompt_task_late_fulfill = 6, + ompt_task_switch = 7 +} ompt_task_status_t; + +typedef enum ompt_target_t { + ompt_target = 1, + ompt_target_enter_data = 2, + ompt_target_exit_data = 3, + ompt_target_update = 4 +} ompt_target_t; + +typedef enum ompt_parallel_flag_t { + ompt_parallel_invoker_program = 0x00000001, + ompt_parallel_invoker_runtime = 0x00000002, + ompt_parallel_league = 0x40000000, + ompt_parallel_team = 0x80000000 +} ompt_parallel_flag_t; + +typedef enum ompt_target_map_flag_t { + ompt_target_map_flag_to = 0x01, + ompt_target_map_flag_from = 0x02, + ompt_target_map_flag_alloc = 0x04, + ompt_target_map_flag_release = 0x08, + ompt_target_map_flag_delete = 0x10, + ompt_target_map_flag_implicit = 0x20 +} ompt_target_map_flag_t; + +typedef enum ompt_dependence_type_t { + ompt_dependence_type_in = 1, + ompt_dependence_type_out = 2, + ompt_dependence_type_inout = 3, + ompt_dependence_type_mutexinoutset = 4, + ompt_dependence_type_source = 5, + ompt_dependence_type_sink = 6 +} ompt_dependence_type_t; + +typedef enum ompt_cancel_flag_t { + ompt_cancel_parallel = 0x01, + ompt_cancel_sections = 0x02, + ompt_cancel_loop = 0x04, + ompt_cancel_taskgroup = 0x08, + ompt_cancel_activated = 0x10, + ompt_cancel_detected = 0x20, + ompt_cancel_discarded_task = 0x40 +} ompt_cancel_flag_t; + +typedef uint64_t ompt_hwid_t; + +typedef uint64_t ompt_wait_id_t; + +typedef enum ompt_frame_flag_t { + ompt_frame_runtime = 0x00, + ompt_frame_application = 0x01, + ompt_frame_cfa = 0x10, + ompt_frame_framepointer = 0x20, + ompt_frame_stackaddress = 0x30 +} ompt_frame_flag_t; + +typedef enum ompt_state_t { + ompt_state_work_serial = 0x000, + ompt_state_work_parallel = 0x001, + ompt_state_work_reduction = 0x002, + + ompt_state_wait_barrier = 0x010, + ompt_state_wait_barrier_implicit_parallel = 0x011, + ompt_state_wait_barrier_implicit_workshare = 0x012, + ompt_state_wait_barrier_implicit = 0x013, + ompt_state_wait_barrier_explicit = 0x014, + + ompt_state_wait_taskwait = 0x020, + ompt_state_wait_taskgroup = 0x021, + + ompt_state_wait_mutex = 0x040, + ompt_state_wait_lock = 0x041, + ompt_state_wait_critical = 0x042, + ompt_state_wait_atomic = 0x043, + ompt_state_wait_ordered = 0x044, + + ompt_state_wait_target = 0x080, + ompt_state_wait_target_map = 0x081, + ompt_state_wait_target_update = 0x082, + + ompt_state_idle = 0x100, + ompt_state_overhead = 0x101, + ompt_state_undefined = 0x102 +} ompt_state_t; + +typedef uint64_t (*ompt_get_unique_id_t) (void); + +typedef uint64_t ompd_size_t; + +typedef uint64_t ompd_wait_id_t; + +typedef uint64_t ompd_addr_t; +typedef int64_t ompd_word_t; +typedef uint64_t ompd_seg_t; + +typedef uint64_t ompd_device_t; + +typedef uint64_t ompd_thread_id_t; + +typedef enum ompd_scope_t { + ompd_scope_global = 1, + ompd_scope_address_space = 2, + ompd_scope_thread = 3, + ompd_scope_parallel = 4, + ompd_scope_implicit_task = 5, + ompd_scope_task = 6 +} ompd_scope_t; + +typedef uint64_t ompd_icv_id_t; + +typedef enum ompd_rc_t { + ompd_rc_ok = 0, + ompd_rc_unavailable = 1, + ompd_rc_stale_handle = 2, + ompd_rc_bad_input = 3, + ompd_rc_error = 4, + ompd_rc_unsupported = 5, + ompd_rc_needs_state_tracking = 6, + ompd_rc_incompatible = 7, + ompd_rc_device_read_error = 8, + ompd_rc_device_write_error = 9, + ompd_rc_nomem = 10, +} ompd_rc_t; + +typedef void (*ompt_interface_fn_t) (void); + +typedef ompt_interface_fn_t (*ompt_function_lookup_t) ( + const char *interface_function_name +); + +typedef union ompt_data_t { + uint64_t value; + void *ptr; +} ompt_data_t; + +typedef struct ompt_frame_t { + ompt_data_t exit_frame; + ompt_data_t enter_frame; + int exit_frame_flags; + int enter_frame_flags; +} ompt_frame_t; + +typedef void (*ompt_callback_t) (void); + +typedef void ompt_device_t; + +typedef void ompt_buffer_t; + +typedef void (*ompt_callback_buffer_request_t) ( + int device_num, + ompt_buffer_t **buffer, + size_t *bytes +); + +typedef void (*ompt_callback_buffer_complete_t) ( + int device_num, + ompt_buffer_t *buffer, + size_t bytes, + ompt_buffer_cursor_t begin, + int buffer_owned +); + +typedef void (*ompt_finalize_t) ( + ompt_data_t *tool_data +); + +typedef int (*ompt_initialize_t) ( + ompt_function_lookup_t lookup, + int initial_device_num, + ompt_data_t *tool_data +); + +typedef struct ompt_start_tool_result_t { + ompt_initialize_t initialize; + ompt_finalize_t finalize; + ompt_data_t tool_data; +} ompt_start_tool_result_t; + +typedef struct ompt_record_abstract_t { + ompt_record_native_t rclass; + const char *type; + ompt_device_time_t start_time; + ompt_device_time_t end_time; + ompt_hwid_t hwid; +} ompt_record_abstract_t; + +typedef struct ompt_dependence_t { + ompt_data_t variable; + ompt_dependence_type_t dependence_type; +} ompt_dependence_t; + +typedef int (*ompt_enumerate_states_t) ( + int current_state, + int *next_state, + const char **next_state_name +); + +typedef int (*ompt_enumerate_mutex_impls_t) ( + int current_impl, + int *next_impl, + const char **next_impl_name +); + +typedef ompt_set_result_t (*ompt_set_callback_t) ( + ompt_callbacks_t event, + ompt_callback_t callback +); + +typedef int (*ompt_get_callback_t) ( + ompt_callbacks_t event, + ompt_callback_t *callback +); + +typedef ompt_data_t *(*ompt_get_thread_data_t) (void); + +typedef int (*ompt_get_num_procs_t) (void); + +typedef int (*ompt_get_num_places_t) (void); + +typedef int (*ompt_get_place_proc_ids_t) ( + int place_num, + int ids_size, + int *ids +); + +typedef int (*ompt_get_place_num_t) (void); + +typedef int (*ompt_get_partition_place_nums_t) ( + int place_nums_size, + int *place_nums +); + +typedef int (*ompt_get_proc_id_t) (void); + +typedef int (*ompt_get_state_t) ( + ompt_wait_id_t *wait_id +); + +typedef int (*ompt_get_parallel_info_t) ( + int ancestor_level, + ompt_data_t **parallel_data, + int *team_size +); + +typedef int (*ompt_get_task_info_t) ( + int ancestor_level, + int *flags, + ompt_data_t **task_data, + ompt_frame_t **task_frame, + ompt_data_t **parallel_data, + int *thread_num +); + +typedef int (*ompt_get_task_memory_t)( + void **addr, + size_t *size, + int block +); + +typedef int (*ompt_get_target_info_t) ( + uint64_t *device_num, + ompt_id_t *target_id, + ompt_id_t *host_op_id +); + +typedef int (*ompt_get_num_devices_t) (void); + +typedef void (*ompt_finalize_tool_t) (void); + +typedef int (*ompt_get_device_num_procs_t) ( + ompt_device_t *device +); + +typedef ompt_device_time_t (*ompt_get_device_time_t) ( + ompt_device_t *device +); + +typedef double (*ompt_translate_time_t) ( + ompt_device_t *device, + ompt_device_time_t time +); + +typedef ompt_set_result_t (*ompt_set_trace_ompt_t) ( + ompt_device_t *device, + unsigned int enable, + unsigned int etype +); + +typedef ompt_set_result_t (*ompt_set_trace_native_t) ( + ompt_device_t *device, + int enable, + int flags +); + +typedef int (*ompt_start_trace_t) ( + ompt_device_t *device, + ompt_callback_buffer_request_t request, + ompt_callback_buffer_complete_t complete +); + +typedef int (*ompt_pause_trace_t) ( + ompt_device_t *device, + int begin_pause +); + +typedef int (*ompt_flush_trace_t) ( + ompt_device_t *device +); + +typedef int (*ompt_stop_trace_t) ( + ompt_device_t *device +); + +typedef int (*ompt_advance_buffer_cursor_t) ( + ompt_device_t *device, + ompt_buffer_t *buffer, + size_t size, + ompt_buffer_cursor_t current, + ompt_buffer_cursor_t *next +); + +typedef ompt_record_t (*ompt_get_record_type_t) ( + ompt_buffer_t *buffer, + ompt_buffer_cursor_t current +); + +typedef void *(*ompt_get_record_native_t) ( + ompt_buffer_t *buffer, + ompt_buffer_cursor_t current, + ompt_id_t *host_op_id +); + +typedef ompt_record_abstract_t * +(*ompt_get_record_abstract_t) ( + void *native_record +); + +typedef void (*ompt_callback_thread_begin_t) ( + ompt_thread_t thread_type, + ompt_data_t *thread_data +); + +typedef struct ompt_record_thread_begin_t { + ompt_thread_t thread_type; +} ompt_record_thread_begin_t; + +typedef void (*ompt_callback_thread_end_t) ( + ompt_data_t *thread_data +); + +typedef void (*ompt_callback_parallel_begin_t) ( + ompt_data_t *encountering_task_data, + const ompt_frame_t *encountering_task_frame, + ompt_data_t *parallel_data, + unsigned int requested_parallelism, + int flags, + const void *codeptr_ra +); + +typedef struct ompt_record_parallel_begin_t { + ompt_id_t encountering_task_id; + ompt_id_t parallel_id; + unsigned int requested_parallelism; + int flags; + const void *codeptr_ra; +} ompt_record_parallel_begin_t; + +typedef void (*ompt_callback_parallel_end_t) ( + ompt_data_t *parallel_data, + ompt_data_t *encountering_task_data, + int flags, + const void *codeptr_ra +); + +typedef struct ompt_record_parallel_end_t { + ompt_id_t parallel_id; + ompt_id_t encountering_task_id; + int flags; + const void *codeptr_ra; +} ompt_record_parallel_end_t; + +typedef void (*ompt_callback_work_t) ( + ompt_work_t wstype, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + uint64_t count, + const void *codeptr_ra +); + +typedef struct ompt_record_work_t { + ompt_work_t wstype; + ompt_scope_endpoint_t endpoint; + ompt_id_t parallel_id; + ompt_id_t task_id; + uint64_t count; + const void *codeptr_ra; +} ompt_record_work_t; + +typedef void (*ompt_callback_dispatch_t) ( + ompt_data_t *parallel_data, + ompt_data_t *task_data, + ompt_dispatch_t kind, + ompt_data_t instance +); + +typedef struct ompt_record_dispatch_t { + ompt_id_t parallel_id; + ompt_id_t task_id; + ompt_dispatch_t kind; + ompt_data_t instance; +} ompt_record_dispatch_t; + +typedef void (*ompt_callback_task_create_t) ( + ompt_data_t *encountering_task_data, + const ompt_frame_t *encountering_task_frame, + ompt_data_t *new_task_data, + int flags, + int has_dependences, + const void *codeptr_ra +); + +typedef struct ompt_record_task_create_t { + ompt_id_t encountering_task_id; + ompt_id_t new_task_id; + int flags; + int has_dependences; + const void *codeptr_ra; +} ompt_record_task_create_t; + +typedef void (*ompt_callback_dependences_t) ( + ompt_data_t *task_data, + const ompt_dependence_t *deps, + int ndeps +); + +typedef struct ompt_record_dependences_t { + ompt_id_t task_id; + ompt_dependence_t dep; + int ndeps; +} ompt_record_dependences_t; + +typedef void (*ompt_callback_task_dependence_t) ( + ompt_data_t *src_task_data, + ompt_data_t *sink_task_data +); + +typedef struct ompt_record_task_dependence_t { + ompt_id_t src_task_id; + ompt_id_t sink_task_id; +} ompt_record_task_dependence_t; + +typedef void (*ompt_callback_task_schedule_t) ( + ompt_data_t *prior_task_data, + ompt_task_status_t prior_task_status, + ompt_data_t *next_task_data +); + +typedef struct ompt_record_task_schedule_t { + ompt_id_t prior_task_id; + ompt_task_status_t prior_task_status; + ompt_id_t next_task_id; +} ompt_record_task_schedule_t; + +typedef void (*ompt_callback_implicit_task_t) ( + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + unsigned int actual_parallelism, + unsigned int index, + int flags +); + +typedef struct ompt_record_implicit_task_t { + ompt_scope_endpoint_t endpoint; + ompt_id_t parallel_id; + ompt_id_t task_id; + unsigned int actual_parallelism; + unsigned int index; + int flags; +} ompt_record_implicit_task_t; + +typedef void (*ompt_callback_master_t) ( + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra +); + +typedef struct ompt_record_master_t { + ompt_scope_endpoint_t endpoint; + ompt_id_t parallel_id; + ompt_id_t task_id; + const void *codeptr_ra; +} ompt_record_master_t; + +typedef void (*ompt_callback_sync_region_t) ( + ompt_sync_region_t kind, + ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + const void *codeptr_ra +); + +typedef struct ompt_record_sync_region_t { + ompt_sync_region_t kind; + ompt_scope_endpoint_t endpoint; + ompt_id_t parallel_id; + ompt_id_t task_id; + const void *codeptr_ra; +} ompt_record_sync_region_t; + +typedef void (*ompt_callback_mutex_acquire_t) ( + ompt_mutex_t kind, + unsigned int hint, + unsigned int impl, + ompt_wait_id_t wait_id, + const void *codeptr_ra +); + +typedef struct ompt_record_mutex_acquire_t { + ompt_mutex_t kind; + unsigned int hint; + unsigned int impl; + ompt_wait_id_t wait_id; + const void *codeptr_ra; +} ompt_record_mutex_acquire_t; + +typedef void (*ompt_callback_mutex_t) ( + ompt_mutex_t kind, + ompt_wait_id_t wait_id, + const void *codeptr_ra +); + +typedef struct ompt_record_mutex_t { + ompt_mutex_t kind; + ompt_wait_id_t wait_id; + const void *codeptr_ra; +} ompt_record_mutex_t; + +typedef void (*ompt_callback_nest_lock_t) ( + ompt_scope_endpoint_t endpoint, + ompt_wait_id_t wait_id, + const void *codeptr_ra +); + +typedef struct ompt_record_nest_lock_t { + ompt_scope_endpoint_t endpoint; + ompt_wait_id_t wait_id; + const void *codeptr_ra; +} ompt_record_nest_lock_t; + +typedef void (*ompt_callback_flush_t) ( + ompt_data_t *thread_data, + const void *codeptr_ra +); + +typedef struct ompt_record_flush_t { + const void *codeptr_ra; +} ompt_record_flush_t; + +typedef void (*ompt_callback_cancel_t) ( + ompt_data_t *task_data, + int flags, + const void *codeptr_ra +); + +typedef struct ompt_record_cancel_t { + ompt_id_t task_id; + int flags; + const void *codeptr_ra; +} ompt_record_cancel_t; + +typedef void (*ompt_callback_device_initialize_t) ( + int device_num, + const char *type, + ompt_device_t *device, + ompt_function_lookup_t lookup, + const char *documentation +); + +typedef void (*ompt_callback_device_finalize_t) ( + int device_num +); + +typedef void (*ompt_callback_device_load_t) ( + int device_num, + const char *filename, + int64_t offset_in_file, + void *vma_in_file, + size_t bytes, + void *host_addr, + void *device_addr, + uint64_t module_id +); + +typedef void (*ompt_callback_device_unload_t) ( + int device_num, + uint64_t module_id +); + +typedef void (*ompt_callback_target_data_op_t) ( + ompt_id_t target_id, + ompt_id_t host_op_id, + ompt_target_data_op_t optype, + void *src_addr, + int src_device_num, + void *dest_addr, + int dest_device_num, + size_t bytes, + const void *codeptr_ra +); + +typedef struct ompt_record_target_data_op_t { + ompt_id_t host_op_id; + ompt_target_data_op_t optype; + void *src_addr; + int src_device_num; + void *dest_addr; + int dest_device_num; + size_t bytes; + ompt_device_time_t end_time; + const void *codeptr_ra; +} ompt_record_target_data_op_t; + +typedef void (*ompt_callback_target_t) ( + ompt_target_t kind, + ompt_scope_endpoint_t endpoint, + int device_num, + ompt_data_t *task_data, + ompt_id_t target_id, + const void *codeptr_ra +); + +typedef struct ompt_record_target_t { + ompt_target_t kind; + ompt_scope_endpoint_t endpoint; + int device_num; + ompt_id_t task_id; + ompt_id_t target_id; + const void *codeptr_ra; +} ompt_record_target_t; + +typedef void (*ompt_callback_target_map_t) ( + ompt_id_t target_id, + unsigned int nitems, + void **host_addr, + void **device_addr, + size_t *bytes, + unsigned int *mapping_flags, + const void *codeptr_ra +); + +typedef struct ompt_record_target_map_t { + ompt_id_t target_id; + unsigned int nitems; + void **host_addr; + void **device_addr; + size_t *bytes; + unsigned int *mapping_flags; + const void *codeptr_ra; +} ompt_record_target_map_t; + +typedef void (*ompt_callback_target_submit_t) ( + ompt_id_t target_id, + ompt_id_t host_op_id, + unsigned int requested_num_teams +); + +typedef struct ompt_record_target_kernel_t { + ompt_id_t host_op_id; + unsigned int requested_num_teams; + unsigned int granted_num_teams; + ompt_device_time_t end_time; +} ompt_record_target_kernel_t; + +typedef int (*ompt_callback_control_tool_t) ( + uint64_t command, + uint64_t modifier, + void *arg, + const void *codeptr_ra +); + +typedef struct ompt_record_control_tool_t { + uint64_t command; + uint64_t modifier; + const void *codeptr_ra; +} ompt_record_control_tool_t; + +typedef struct ompd_address_t { + ompd_seg_t segment; + ompd_addr_t address; +} ompd_address_t; + +typedef struct ompd_frame_info_t { + ompd_address_t frame_address; + ompd_word_t frame_flag; +} ompd_frame_info_t; + +typedef struct _ompd_aspace_handle ompd_address_space_handle_t; +typedef struct _ompd_thread_handle ompd_thread_handle_t; +typedef struct _ompd_parallel_handle ompd_parallel_handle_t; +typedef struct _ompd_task_handle ompd_task_handle_t; + +typedef struct _ompd_aspace_cont ompd_address_space_context_t; +typedef struct _ompd_thread_cont ompd_thread_context_t; + +typedef struct ompd_device_type_sizes_t { + uint8_t sizeof_char; + uint8_t sizeof_short; + uint8_t sizeof_int; + uint8_t sizeof_long; + uint8_t sizeof_long_long; + uint8_t sizeof_pointer; +} ompd_device_type_sizes_t; + +typedef struct ompt_record_ompt_t { + ompt_callbacks_t type; + ompt_device_time_t time; + ompt_id_t thread_id; + ompt_id_t target_id; + union { + ompt_record_thread_begin_t thread_begin; + ompt_record_parallel_begin_t parallel_begin; + ompt_record_parallel_end_t parallel_end; + ompt_record_work_t work; + ompt_record_dispatch_t dispatch; + ompt_record_task_create_t task_create; + ompt_record_dependences_t dependences; + ompt_record_task_dependence_t task_dependence; + ompt_record_task_schedule_t task_schedule; + ompt_record_implicit_task_t implicit_task; + ompt_record_master_t master; + ompt_record_sync_region_t sync_region; + ompt_record_mutex_acquire_t mutex_acquire; + ompt_record_mutex_t mutex; + ompt_record_nest_lock_t nest_lock; + ompt_record_flush_t flush; + ompt_record_cancel_t cancel; + ompt_record_target_t target; + ompt_record_target_data_op_t target_data_op; + ompt_record_target_map_t target_map; + ompt_record_target_kernel_t target_kernel; + ompt_record_control_tool_t control_tool; + } record; +} ompt_record_ompt_t; + +typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) ( + ompt_buffer_t *buffer, + ompt_buffer_cursor_t current +); + +#define ompt_id_none 0 +#define ompt_data_none {0} +#define ompt_time_none 0 +#define ompt_hwid_none 0 +#define ompt_addr_none ~0 +#define ompt_mutex_impl_none 0 +#define ompt_wait_id_none 0 + +#define ompd_segment_none 0 + +#endif /* __OMPT__ */ diff --git a/runtime/src/include/50/omp.h.var b/runtime/src/include/50/omp.h.var index 81b6c85..11956f0 100644 --- a/runtime/src/include/50/omp.h.var +++ b/runtime/src/include/50/omp.h.var @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -146,6 +145,9 @@ extern int __KAI_KMPC_CONVENTION omp_target_associate_ptr(void *, void *, size_t, size_t, int); extern int __KAI_KMPC_CONVENTION omp_target_disassociate_ptr(void *, int); + /* OpenMP 5.0 */ + extern int __KAI_KMPC_CONVENTION omp_get_device_num (void); + /* kmp API functions */ extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void); extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int); @@ -246,6 +248,15 @@ extern void __KAI_KMPC_CONVENTION omp_display_affinity(char const *); extern size_t __KAI_KMPC_CONVENTION omp_capture_affinity(char *, size_t, char const *); + /* OpenMP 5.0 Pause Resources */ + typedef enum omp_pause_resource_t { + omp_pause_resume = 0, + omp_pause_soft = 1, + omp_pause_hard = 2 + } omp_pause_resource_t; + extern int __KAI_KMPC_CONVENTION omp_pause_resource(omp_pause_resource_t, int); + extern int __KAI_KMPC_CONVENTION omp_pause_resource_all(omp_pause_resource_t); + # undef __KAI_KMPC_CONVENTION # undef __KMP_IMP @@ -260,4 +271,3 @@ # endif #endif /* __OMP_H */ - diff --git a/runtime/src/include/50/omp_lib.f.var b/runtime/src/include/50/omp_lib.f.var index d5a8057..892e98e 100644 --- a/runtime/src/include/50/omp_lib.f.var +++ b/runtime/src/include/50/omp_lib.f.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! @@ -36,6 +35,8 @@ integer, parameter :: omp_control_tool_result_kind = omp_integer_kind integer, parameter :: omp_allocator_kind = int_ptr_kind() + integer, parameter :: omp_pause_resource_kind = omp_integer_kind + end module omp_lib_kinds module omp_lib @@ -83,6 +84,10 @@ integer (kind=omp_allocator_kind), parameter :: omp_pteam_mem_alloc = 7 integer (kind=omp_allocator_kind), parameter :: omp_thread_mem_alloc = 8 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_resume = 0 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_soft = 1 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_hard = 2 + interface ! *** @@ -278,6 +283,24 @@ integer (kind=omp_integer_kind) omp_get_initial_device end function omp_get_initial_device + function omp_get_device_num() + use omp_lib_kinds + integer (kind=omp_integer_kind) omp_get_device_num + end function omp_get_device_num + + function omp_pause_resource(kind, device_num) + use omp_lib_kinds + integer (kind=omp_pause_resource_kind) kind + integer (kind=omp_integer_kind) device_num + integer (kind=omp_integer_kind) omp_pause_resource + end function omp_pause_resource + + function omp_pause_resource_all(kind) + use omp_lib_kinds + integer (kind=omp_pause_resource_kind) kind + integer (kind=omp_integer_kind) omp_pause_resource_all + end function omp_pause_resource_all + subroutine omp_init_lock(svar) !DIR$ IF(__INTEL_COMPILER.GE.1400) !DIR$ attributes known_intrinsic :: omp_init_lock @@ -613,7 +636,12 @@ !dec$ attributes alias:'OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'OMP_GET_INITIAL_DEVICE' :: omp_get_initial_device !dec$ attributes alias:'OMP_GET_MAX_TASK_PRIORITY' :: omp_get_max_task_priority +!dec$ attributes alias:'OMP_GET_DEVICE_NUM' :: omp_get_device_num +!dec$ attributes alias:'OMP_PAUSE_RESOURCE' :: omp_pause_resource +!dec$ attributes alias:'OMP_PAUSE_RESOURCE_ALL' :: omp_pause_resource_all + !dec$ attributes alias:'OMP_CONTROL_TOOL' :: omp_control_tool !dec$ attributes alias:'OMP_SET_AFFINITY_FORMAT' :: omp_set_affinity_format !dec$ attributes alias:'OMP_GET_AFFINITY_FORMAT' :: omp_get_affinity_format @@ -698,7 +726,12 @@ !dec$ attributes alias:'_OMP_GET_TEAM_NUM' :: omp_get_team_num !dec$ attributes alias:'_OMP_GET_CANCELLATION' :: omp_get_cancellation !dec$ attributes alias:'_OMP_IS_INITIAL_DEVICE' :: omp_is_initial_device +!dec$ attributes alias:'_OMP_GET_INITIAL_DEVICE' :: omp_get_initial_device !dec$ attributes alias:'_OMP_GET_MAX_TASK_PRIORTY' :: omp_get_max_task_priority +!dec$ attributes alias:'_OMP_GET_DEVICE_NUM' :: omp_get_device_num +!dec$ attributes alias:'_OMP_PAUSE_RESOURCE' :: omp_pause_resource +!dec$ attributes alias:'_OMP_PAUSE_RESOURCE_ALL' :: omp_pause_resource_all + !dec$ attributes alias:'_OMP_CONTROL_TOOL' :: omp_control_tool !dec$ attributes alias:'_OMP_SET_AFFINITY_FORMAT' :: omp_set_affinity_format !dec$ attributes alias:'_OMP_GET_AFFINITY_FORMAT' :: omp_get_affinity_format @@ -786,7 +819,12 @@ !dec$ attributes alias:'omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'omp_get_initial_device_'::omp_get_initial_device !dec$ attributes alias:'omp_get_max_task_priority_'::omp_get_max_task_priority +!dec$ attributes alias:'omp_get_device_num_'::omp_get_device_num +!dec$ attributes alias:'omp_pause_resource_' :: omp_pause_resource +!dec$ attributes alias:'omp_pause_resource_all_' :: omp_pause_resource_all + !dec$ attributes alias:'omp_set_affinity_format_' :: omp_set_affinity_format !dec$ attributes alias:'omp_get_affinity_format_' :: omp_get_affinity_format !dec$ attributes alias:'omp_display_affinity_' :: omp_display_affinity @@ -866,11 +904,18 @@ !dec$ attributes alias:'_omp_get_proc_bind_' :: omp_get_proc_bind !dec$ attributes alias:'_omp_get_wtime_'::omp_get_wtime !dec$ attributes alias:'_omp_get_wtick_'::omp_get_wtick +!dec$ attributes alias:'_omp_get_default_device_'::omp_get_default_device +!dec$ attributes alias:'_omp_set_default_device_'::omp_set_default_device +!dec$ attributes alias:'_omp_get_num_devices_'::omp_get_num_devices !dec$ attributes alias:'_omp_get_num_teams_'::omp_get_num_teams !dec$ attributes alias:'_omp_get_team_num_'::omp_get_team_num !dec$ attributes alias:'_omp_get_cancellation_'::omp_get_cancellation !dec$ attributes alias:'_omp_is_initial_device_'::omp_is_initial_device +!dec$ attributes alias:'_omp_get_initial_device_'::omp_get_initial_device !dec$ attributes alias:'_omp_get_max_task_priorty_'::omp_get_max_task_priority +!dec$ attributes alias:'_omp_get_device_num_'::omp_get_device_num +!dec$ attributes alias:'_omp_pause_resource_' :: omp_pause_resource +!dec$ attributes alias:'_omp_pause_resource_all_' :: omp_pause_resource_all !dec$ attributes alias:'_omp_init_lock_'::omp_init_lock !dec$ attributes alias:'_omp_init_lock_with_hint_'::omp_init_lock_with_hint @@ -923,4 +968,3 @@ !dec$ endif end module omp_lib - diff --git a/runtime/src/include/50/omp_lib.f90.var b/runtime/src/include/50/omp_lib.f90.var index afc6d67..5d8b12f 100644 --- a/runtime/src/include/50/omp_lib.f90.var +++ b/runtime/src/include/50/omp_lib.f90.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! @@ -33,6 +32,8 @@ integer, parameter :: omp_control_tool_result_kind = omp_integer_kind integer, parameter :: omp_allocator_kind = c_intptr_t + integer, parameter :: omp_pause_resource_kind = omp_integer_kind + end module omp_lib_kinds module omp_lib @@ -97,6 +98,10 @@ integer (kind=omp_allocator_kind), parameter :: omp_pteam_mem_alloc = 7 integer (kind=omp_allocator_kind), parameter :: omp_thread_mem_alloc = 8 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_resume = 0 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_soft = 1 + integer (kind=omp_pause_resource_kind), parameter :: omp_pause_hard = 2 + interface ! *** @@ -294,6 +299,24 @@ integer (kind=omp_integer_kind) omp_get_initial_device end function omp_get_initial_device + function omp_get_device_num() bind(c) + use omp_lib_kinds + integer (kind=omp_integer_kind) omp_get_device_num + end function omp_get_device_num + + function omp_pause_resource(kind, device_num) bind(c) + use omp_lib_kinds + integer (kind=omp_pause_resource_kind), value :: kind + integer (kind=omp_integer_kind), value :: device_num + integer (kind=omp_integer_kind) omp_pause_resource + end function omp_pause_resource + + function omp_pause_resource_all(kind) bind(c) + use omp_lib_kinds + integer (kind=omp_pause_resource_kind), value :: kind + integer (kind=omp_integer_kind) omp_pause_resource_all + end function omp_pause_resource_all + subroutine omp_init_lock(svar) bind(c) !DIR$ IF(__INTEL_COMPILER.GE.1400) !DIR$ attributes known_intrinsic :: omp_init_lock diff --git a/runtime/src/include/50/omp_lib.h.var b/runtime/src/include/50/omp_lib.h.var index 11dbc0a..5bb01ed 100644 --- a/runtime/src/include/50/omp_lib.h.var +++ b/runtime/src/include/50/omp_lib.h.var @@ -3,10 +3,9 @@ ! !//===----------------------------------------------------------------------===// !// -!// The LLVM Compiler Infrastructure -!// -!// This file is dual licensed under the MIT and the University of Illinois Open -!// Source Licenses. See LICENSE.txt for details. +!// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +!// See https://llvm.org/LICENSE.txt for license information. +!// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !// !//===----------------------------------------------------------------------===// ! @@ -41,6 +40,8 @@ parameter(omp_control_tool_result_kind=omp_integer_kind) integer omp_allocator_kind parameter(omp_allocator_kind=int_ptr_kind()) + integer omp_pause_resource_kind + parameter(omp_pause_resource_kind=omp_integer_kind) integer(kind=omp_integer_kind)openmp_version parameter(openmp_version=@LIBOMP_OMP_YEAR_MONTH@) @@ -136,6 +137,12 @@ parameter(omp_pteam_mem_alloc=7) integer(kind=omp_allocator_kind)omp_thread_mem_alloc parameter(omp_thread_mem_alloc=8) + integer(kind=omp_pause_resource_kind)omp_pause_resume + parameter(omp_pause_resume=0) + integer(kind=omp_pause_resource_kind)omp_pause_soft + parameter(omp_pause_soft=1) + integer(kind=omp_pause_resource_kind)omp_pause_hard + parameter(omp_pause_hard=2) interface @@ -327,6 +334,24 @@ integer (kind=omp_integer_kind) omp_get_initial_device end function omp_get_initial_device + function omp_get_device_num() bind(c) + import + integer (kind=omp_integer_kind) omp_get_device_num + end function omp_get_device_num + + function omp_pause_resource(kind, device_num) bind(c) + import + integer (kind=omp_pause_resource_kind), value :: kind + integer (kind=omp_integer_kind), value :: device_num + integer (kind=omp_integer_kind) omp_pause_resource + end function omp_pause_resource + + function omp_pause_resource_all(kind) bind(c) + import + integer (kind=omp_pause_resource_kind), value :: kind + integer (kind=omp_integer_kind) omp_pause_resource_all + end function omp_pause_resource_all + subroutine omp_init_lock(svar) bind(c) !DIR$ IF(__INTEL_COMPILER.GE.1400) !DIR$ attributes known_intrinsic :: omp_init_lock @@ -644,7 +669,11 @@ !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_default_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_set_default_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_is_initial_device +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_initial_device !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_num_devices +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_device_num +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_pause_resource +!DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_pause_resource_all !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_num_teams !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_get_team_num !DIR$ ATTRIBUTES OFFLOAD:MIC :: omp_init_lock @@ -721,7 +750,11 @@ !$omp declare target(omp_get_default_device ) !$omp declare target(omp_set_default_device ) !$omp declare target(omp_is_initial_device ) +!$omp declare target(omp_get_initial_device ) !$omp declare target(omp_get_num_devices ) +!$omp declare target(omp_get_device_num ) +!$omp declare target(omp_pause_resource ) +!$omp declare target(omp_pause_resource_all ) !$omp declare target(omp_get_num_teams ) !$omp declare target(omp_get_team_num ) !$omp declare target(omp_init_lock ) diff --git a/runtime/src/include/50/ompt.h.var b/runtime/src/include/50/ompt.h.var deleted file mode 100644 index 478c6cc..0000000 --- a/runtime/src/include/50/ompt.h.var +++ /dev/null @@ -1,735 +0,0 @@ -/* - * include/50/ompt.h.var - */ - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. -// -//===----------------------------------------------------------------------===// - -#ifndef __OMPT__ -#define __OMPT__ - -/***************************************************************************** - * system include files - *****************************************************************************/ - -#include <stdint.h> -#include <stddef.h> - - - -/***************************************************************************** - * iteration macros - *****************************************************************************/ - -#define FOREACH_OMPT_INQUIRY_FN(macro) \ - macro (ompt_enumerate_states) \ - macro (ompt_enumerate_mutex_impls) \ - \ - macro (ompt_set_callback) \ - macro (ompt_get_callback) \ - \ - macro (ompt_get_state) \ - \ - macro (ompt_get_parallel_info) \ - macro (ompt_get_task_info) \ - macro (ompt_get_task_memory) \ - macro (ompt_get_thread_data) \ - macro (ompt_get_unique_id) \ - macro (ompt_finalize_tool) \ - \ - macro(ompt_get_num_procs) \ - macro(ompt_get_num_places) \ - macro(ompt_get_place_proc_ids) \ - macro(ompt_get_place_num) \ - macro(ompt_get_partition_place_nums) \ - macro(ompt_get_proc_id) \ - \ - macro(ompt_get_target_info) \ - macro(ompt_get_num_devices) - -#define FOREACH_OMPT_STATE(macro) \ - \ - /* first available state */ \ - macro (ompt_state_undefined, 0x102) /* undefined thread state */ \ - \ - /* work states (0..15) */ \ - macro (ompt_state_work_serial, 0x000) /* working outside parallel */ \ - macro (ompt_state_work_parallel, 0x001) /* working within parallel */ \ - macro (ompt_state_work_reduction, 0x002) /* performing a reduction */ \ - \ - /* barrier wait states (16..31) */ \ - macro (ompt_state_wait_barrier, 0x010) /* waiting at a barrier */ \ - macro (ompt_state_wait_barrier_implicit_parallel, 0x011) \ - /* implicit barrier at the end of parallel region */\ - macro (ompt_state_wait_barrier_implicit_workshare, 0x012) \ - /* implicit barrier at the end of worksharing */ \ - macro (ompt_state_wait_barrier_implicit, 0x013) /* implicit barrier */ \ - macro (ompt_state_wait_barrier_explicit, 0x014) /* explicit barrier */ \ - \ - /* task wait states (32..63) */ \ - macro (ompt_state_wait_taskwait, 0x020) /* waiting at a taskwait */ \ - macro (ompt_state_wait_taskgroup, 0x021) /* waiting at a taskgroup */ \ - \ - /* mutex wait states (64..127) */ \ - macro (ompt_state_wait_mutex, 0x040) \ - macro (ompt_state_wait_lock, 0x041) /* waiting for lock */ \ - macro (ompt_state_wait_critical, 0x042) /* waiting for critical */ \ - macro (ompt_state_wait_atomic, 0x043) /* waiting for atomic */ \ - macro (ompt_state_wait_ordered, 0x044) /* waiting for ordered */ \ - \ - /* target wait states (128..255) */ \ - macro (ompt_state_wait_target, 0x080) /* waiting for target region */ \ - macro (ompt_state_wait_target_map, 0x081) /* waiting for target data mapping operation */ \ - macro (ompt_state_wait_target_update, 0x082) /* waiting for target update operation */ \ - \ - /* misc (256..511) */ \ - macro (ompt_state_idle, 0x100) /* waiting for work */ \ - macro (ompt_state_overhead, 0x101) /* overhead excluding wait states */ \ - \ - /* implementation-specific states (512..) */ - - -#define FOREACH_KMP_MUTEX_IMPL(macro) \ - macro (ompt_mutex_impl_none, 0) /* unknown implementation */ \ - macro (kmp_mutex_impl_spin, 1) /* based on spin */ \ - macro (kmp_mutex_impl_queuing, 2) /* based on some fair policy */ \ - macro (kmp_mutex_impl_speculative, 3) /* based on HW-supported speculation */ - -#define FOREACH_OMPT_EVENT(macro) \ - \ - /*--- Mandatory Events ---*/ \ - macro (ompt_callback_thread_begin, ompt_callback_thread_begin_t, 1) /* thread begin */ \ - macro (ompt_callback_thread_end, ompt_callback_thread_end_t, 2) /* thread end */ \ - \ - macro (ompt_callback_parallel_begin, ompt_callback_parallel_begin_t, 3) /* parallel begin */ \ - macro (ompt_callback_parallel_end, ompt_callback_parallel_end_t, 4) /* parallel end */ \ - \ - macro (ompt_callback_task_create, ompt_callback_task_create_t, 5) /* task begin */ \ - macro (ompt_callback_task_schedule, ompt_callback_task_schedule_t, 6) /* task schedule */ \ - macro (ompt_callback_implicit_task, ompt_callback_implicit_task_t, 7) /* implicit task */ \ - \ - macro (ompt_callback_target, ompt_callback_target_t, 8) /* target */ \ - macro (ompt_callback_target_data_op, ompt_callback_target_data_op_t, 9) /* target data op */ \ - macro (ompt_callback_target_submit, ompt_callback_target_submit_t, 10) /* target submit */ \ - \ - macro (ompt_callback_control_tool, ompt_callback_control_tool_t, 11) /* control tool */ \ - \ - macro (ompt_callback_device_initialize, ompt_callback_device_initialize_t, 12) /* device initialize */ \ - macro (ompt_callback_device_finalize, ompt_callback_device_finalize_t, 13) /* device finalize */ \ - \ - macro (ompt_callback_device_load, ompt_callback_device_load_t, 14) /* device load */ \ - macro (ompt_callback_device_unload, ompt_callback_device_unload_t, 15) /* device unload */ \ - \ - /* Optional Events */ \ - macro (ompt_callback_sync_region_wait, ompt_callback_sync_region_t, 16) /* sync region wait begin or end */ \ - \ - macro (ompt_callback_mutex_released, ompt_callback_mutex_t, 17) /* mutex released */ \ - \ - macro (ompt_callback_task_dependences, ompt_callback_task_dependences_t, 18) /* report task dependences */ \ - macro (ompt_callback_task_dependence, ompt_callback_task_dependence_t, 19) /* report task dependence */ \ - \ - macro (ompt_callback_work, ompt_callback_work_t, 20) /* task at work begin or end */ \ - \ - macro (ompt_callback_master, ompt_callback_master_t, 21) /* task at master begin or end */ \ - \ - macro (ompt_callback_target_map, ompt_callback_target_map_t, 22) /* target map */ \ - \ - macro (ompt_callback_sync_region, ompt_callback_sync_region_t, 23) /* sync region begin or end */ \ - \ - macro (ompt_callback_lock_init, ompt_callback_mutex_acquire_t, 24) /* lock init */ \ - macro (ompt_callback_lock_destroy, ompt_callback_mutex_t, 25) /* lock destroy */ \ - \ - macro (ompt_callback_mutex_acquire, ompt_callback_mutex_acquire_t, 26) /* mutex acquire */ \ - macro (ompt_callback_mutex_acquired, ompt_callback_mutex_t, 27) /* mutex acquired */ \ - \ - macro (ompt_callback_nest_lock, ompt_callback_nest_lock_t, 28) /* nest lock */ \ - \ - macro (ompt_callback_flush, ompt_callback_flush_t, 29) /* after executing flush */ \ - \ - macro (ompt_callback_cancel, ompt_callback_cancel_t, 30) /* cancel innermost binding region */ \ - \ - macro (ompt_callback_reduction, ompt_callback_sync_region_t, 31) /* reduction */ \ - \ - macro (ompt_callback_dispatch, ompt_callback_dispatch_t, 32) /* dispatch of work */ - - - -/***************************************************************************** - * data types - *****************************************************************************/ - -/*--------------------- - * identifiers - *---------------------*/ - -typedef uint64_t ompt_id_t; -#define ompt_id_none 0 - -typedef union ompt_data_t { - uint64_t value; /* data initialized by runtime to unique id */ - void *ptr; /* pointer under tool control */ -} ompt_data_t; - -static const ompt_data_t ompt_data_none = {0}; - -typedef uint64_t ompt_wait_id_t; -static const ompt_wait_id_t omp_wait_id_none = 0; - -typedef void ompt_device_t; - - -/*--------------------- - * dependences types - *---------------------*/ - -typedef enum ompt_task_dependence_type_t { - // a two bit field for the dependence type - ompt_task_dependence_type_in = 1, - ompt_task_dependence_type_out = 2, - ompt_task_dependence_type_inout = 3, - ompt_task_dependence_type_mutexinoutset = 4 -} ompt_task_dependence_type_t; - -typedef struct ompt_task_dependence_t { - void *variable_addr; - ompt_task_dependence_type_t dependence_type; -} ompt_task_dependence_t; - - -/***************************************************************************** - * enumerations for thread states and runtime events - *****************************************************************************/ - -/*--------------------- - * runtime states - *---------------------*/ - -typedef enum { -#define ompt_state_macro(state, code) state = code, - FOREACH_OMPT_STATE(ompt_state_macro) -#undef ompt_state_macro -} ompt_state_t; - -typedef enum ompt_frame_flag_t { - ompt_frame_runtime = 0x00, - ompt_frame_application = 0x01, - ompt_frame_cfa = 0x10, - ompt_frame_framepointer = 0x20, - ompt_frame_stackaddress = 0x30 -} ompt_frame_flag_t; - - -/*--------------------- - * runtime events - *---------------------*/ - -typedef enum ompt_callbacks_e{ -#define ompt_event_macro(event, callback, eventid) event = eventid, - FOREACH_OMPT_EVENT(ompt_event_macro) -#undef ompt_event_macro -} ompt_callbacks_t; - - -/*--------------------- - * set callback results - *---------------------*/ -typedef enum ompt_set_result_t { - ompt_set_error = 0, - ompt_set_never = 1, - ompt_set_sometimes = 2, - ompt_set_sometimes_paired = 3, - ompt_set_always = 4 -} ompt_set_result_t; - - -/*---------------------- - * mutex implementations - *----------------------*/ -typedef enum kmp_mutex_impl_t { -#define kmp_mutex_impl_macro(impl, code) impl = code, - FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro) -#undef kmp_mutex_impl_macro -} kmp_mutex_impl_t; - - -/***************************************************************************** - * callback signatures - *****************************************************************************/ - -/* initialization */ -typedef void (*ompt_interface_fn_t)(void); - -typedef ompt_interface_fn_t (*ompt_function_lookup_t)( - const char * /* entry point to look up */ -); - -/* threads */ -typedef enum ompt_thread_t { - ompt_thread_initial = 1, // start the enumeration at 1 - ompt_thread_worker = 2, - ompt_thread_other = 3, - ompt_thread_unknown = 4 -} ompt_thread_t; - -typedef struct ompt_frame_t { - ompt_data_t exit_frame; - ompt_data_t enter_frame; - int exit_frame_flags; - int enter_frame_flags; -} ompt_frame_t; -typedef enum ompt_parallel_flag_t { - ompt_parallel_invoker_program = 0x00000001, /* program invokes master task */ - ompt_parallel_invoker_runtime = 0x00000002, /* runtime invokes master task */ - ompt_parallel_league = 0x40000000, - ompt_parallel_team = 0x80000000 -} ompt_parallel_flag_t; - -typedef void (*ompt_callback_thread_begin_t) ( - ompt_thread_t thread_type, /* type of thread */ - ompt_data_t *thread_data /* data of thread */ -); - -typedef void (*ompt_callback_thread_end_t) ( - ompt_data_t *thread_data /* data of thread */ -); - -typedef void (*ompt_wait_callback_t) ( - ompt_wait_id_t wait_id /* wait data */ -); - -/* parallel and workshares */ -typedef enum ompt_scope_endpoint_t { - ompt_scope_begin = 1, - ompt_scope_end = 2 -} ompt_scope_endpoint_t; - - -/* implicit task */ -typedef void (*ompt_callback_implicit_task_t) ( - ompt_scope_endpoint_t endpoint, /* endpoint of implicit task */ - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *task_data, /* data of implicit task */ - unsigned int actual_parallelism, /* team size */ - unsigned int index /* thread number of calling thread */ -); - -typedef void (*ompt_callback_parallel_begin_t) ( - ompt_data_t *encountering_task_data, /* data of encountering task */ - const ompt_frame_t *encountering_task_frame, /* frame data of encountering task */ - ompt_data_t *parallel_data, /* data of parallel region */ - unsigned int requested_team_size, /* requested number of threads in team */ - int flag, /* flag for additional information */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef void (*ompt_callback_parallel_end_t) ( - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *encountering_task_data, /* data of encountering task */ - int flag, /* flag for additional information */ - const void *codeptr_ra /* return address of runtime call */ -); - -/* tasks */ -typedef enum ompt_task_flag_t { - ompt_task_initial = 0x1, - ompt_task_implicit = 0x2, - ompt_task_explicit = 0x4, - ompt_task_target = 0x8, - ompt_task_undeferred = 0x8000000, - ompt_task_untied = 0x10000000, - ompt_task_final = 0x20000000, - ompt_task_mergeable = 0x40000000, - ompt_task_merged = 0x80000000 -} ompt_task_flag_t; - -typedef enum ompt_task_status_t { - ompt_task_complete = 1, - ompt_task_yield = 2, - ompt_task_cancel = 3, - ompt_task_switch = 4 -} ompt_task_status_t; - -typedef void (*ompt_callback_task_schedule_t) ( - ompt_data_t *prior_task_data, /* data of prior task */ - ompt_task_status_t prior_task_status, /* status of prior task */ - ompt_data_t *next_task_data /* data of next task */ -); - -typedef void (*ompt_callback_task_create_t) ( - ompt_data_t *encountering_task_data, /* data of parent task */ - const ompt_frame_t *encountering_task_frame, /* frame data for parent task */ - ompt_data_t *new_task_data, /* data of created task */ - int flag, /* type of created task */ - int has_dependences, /* created task has dependences */ - const void *codeptr_ra /* return address of runtime call */ -); - -/* task dependences */ -typedef void (*ompt_callback_task_dependences_t) ( - ompt_data_t *task_data, /* data of task */ - const ompt_task_dependence_t *deps, /* dependences of task */ - int ndeps /* dependences count of task */ -); - -typedef void (*ompt_callback_task_dependence_t) ( - ompt_data_t *src_task_data, /* data of source task */ - ompt_data_t *sink_task_data /* data of sink task */ -); - -/* target and device */ -typedef enum ompt_target_t { - ompt_target = 1, - ompt_target_enter_data = 2, - ompt_target_exit_data = 3, - ompt_target_update = 4 -} ompt_target_t; - -typedef void (*ompt_callback_target_t) ( - ompt_target_t kind, - ompt_scope_endpoint_t endpoint, - uint64_t device_num, - ompt_data_t *task_data, - ompt_id_t target_id, - const void *codeptr_ra -); - -typedef enum ompt_target_data_op_t { - ompt_target_data_alloc = 1, - ompt_target_data_transfer_to_dev = 2, - ompt_target_data_transfer_from_dev = 3, - ompt_target_data_delete = 4 -} ompt_target_data_op_t; - -typedef void (*ompt_callback_target_data_op_t) ( - ompt_id_t target_id, - ompt_id_t host_op_id, - ompt_target_data_op_t optype, - void *src_addr, - int src_device_num, - void *dest_addr, - int dest_device_num, - size_t bytes, - const void *codeptr_ra -); - -typedef void (*ompt_callback_target_submit_t) ( - ompt_id_t target_id, - ompt_id_t host_op_id, - unsigned int requested_num_teams -); - -typedef void (*ompt_callback_target_map_t) ( - ompt_id_t target_id, - unsigned int nitems, - void **host_addr, - void **device_addr, - size_t *bytes, - unsigned int *mapping_flags, - const void *codeptr_ra -); - -typedef void (*ompt_callback_device_initialize_t) ( - uint64_t device_num, - const char *type, - ompt_device_t *device, - ompt_function_lookup_t lookup, - const char *documentation -); - -typedef void (*ompt_callback_device_finalize_t) ( - uint64_t device_num -); - -typedef void (*ompt_callback_device_load_t) ( - uint64_t device_num, - const char * filename, - int64_t offset_in_file, - void * vma_in_file, - size_t bytes, - void * host_addr, - void * device_addr, - uint64_t module_id -); - -#define ompt_addr_unknown ((void *) ~0) - -typedef void (*ompt_callback_device_unload_t) ( - uint64_t device_num, - uint64_t module_id -); - -/* control_tool */ -typedef int (*ompt_callback_control_tool_t) ( - uint64_t command, /* command of control call */ - uint64_t modifier, /* modifier of control call */ - void *arg, /* argument of control call */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef enum ompt_mutex_t { - ompt_mutex_lock = 1, - ompt_mutex_nest_lock = 2, - ompt_mutex_critical = 3, - ompt_mutex_atomic = 4, - ompt_mutex_ordered = 5 -} ompt_mutex_t; - -typedef void (*ompt_callback_mutex_acquire_t) ( - ompt_mutex_t kind, /* mutex kind */ - unsigned int hint, /* mutex hint */ - unsigned int impl, /* mutex implementation */ - ompt_wait_id_t wait_id, /* id of object being awaited */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef void (*ompt_callback_mutex_t) ( - ompt_mutex_t kind, /* mutex kind */ - ompt_wait_id_t wait_id, /* id of object being awaited */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef void (*ompt_callback_nest_lock_t) ( - ompt_scope_endpoint_t endpoint, /* endpoint of nested lock */ - ompt_wait_id_t wait_id, /* id of object being awaited */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef void (*ompt_callback_master_t) ( - ompt_scope_endpoint_t endpoint, /* endpoint of master region */ - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *task_data, /* data of task */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef enum ompt_work_t { - ompt_work_loop = 1, - ompt_work_sections = 2, - ompt_work_single_executor = 3, - ompt_work_single_other = 4, - ompt_work_workshare = 5, - ompt_work_distribute = 6, - ompt_work_taskloop = 7 -} ompt_work_t; - -typedef void (*ompt_callback_work_t) ( - ompt_work_t wstype, /* type of work region */ - ompt_scope_endpoint_t endpoint, /* endpoint of work region */ - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *task_data, /* data of task */ - uint64_t count, /* quantity of work */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef enum ompt_sync_region_t { - ompt_sync_region_barrier = 1, - ompt_sync_region_barrier_implicit = 2, - ompt_sync_region_barrier_explicit = 3, - ompt_sync_region_barrier_implementation = 4, - ompt_sync_region_taskwait = 5, - ompt_sync_region_taskgroup = 6, - ompt_sync_region_reduction = 7 -} ompt_sync_region_t; - -typedef void (*ompt_callback_sync_region_t) ( - ompt_sync_region_t kind, /* kind of sync region */ - ompt_scope_endpoint_t endpoint, /* endpoint of sync region */ - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *task_data, /* data of task */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef enum ompt_cancel_flag_t { - ompt_cancel_parallel = 0x01, - ompt_cancel_sections = 0x02, - ompt_cancel_loop = 0x04, - ompt_cancel_taskgroup = 0x08, - ompt_cancel_activated = 0x10, - ompt_cancel_detected = 0x20, - ompt_cancel_discarded_task = 0x40 -} ompt_cancel_flag_t; - -typedef void (*ompt_callback_cancel_t) ( - ompt_data_t *task_data, /* data of task */ - int flags, /* cancel flags */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef void (*ompt_callback_flush_t) ( - ompt_data_t *thread_data, /* data of thread */ - const void *codeptr_ra /* return address of runtime call */ -); - -typedef enum ompt_dispatch_t { - ompt_dispatch_iteration = 1, - ompt_dispatch_section = 2 -} ompt_dispatch_t; - -typedef void (*ompt_callback_dispatch_t) ( - ompt_data_t *parallel_data, - ompt_data_t *task_data, - ompt_dispatch_t kind, - ompt_data_t instance -); - -/**************************************************************************** - * ompt API - ***************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -#define OMPT_API_FNTYPE(fn) fn##_t - -#define OMPT_API_FUNCTION(return_type, fn, args) \ - typedef return_type (*OMPT_API_FNTYPE(fn)) args - - - -/**************************************************************************** - * INQUIRY FUNCTIONS - ***************************************************************************/ - -/* state */ -OMPT_API_FUNCTION(ompt_state_t, ompt_get_state, ( - ompt_wait_id_t *wait_id -)); - -/* thread */ -OMPT_API_FUNCTION(ompt_data_t*, ompt_get_thread_data, (void)); - -/* parallel region */ -OMPT_API_FUNCTION(int, ompt_get_parallel_info, ( - int ancestor_level, - ompt_data_t **parallel_data, - int *team_size -)); - -/* task */ -OMPT_API_FUNCTION(int, ompt_get_task_info, ( - int ancestor_level, - int *type, - ompt_data_t **task_data, - ompt_frame_t **task_frame, - ompt_data_t **parallel_data, - int *thread_num -)); - -OMPT_API_FUNCTION(int, ompt_get_task_memory, ( - void **addr, - size_t *size, - int block -)); - -/* procs */ -OMPT_API_FUNCTION(int, ompt_get_num_procs, (void)); - -/* places */ -OMPT_API_FUNCTION(int, ompt_get_num_places, (void)); - -OMPT_API_FUNCTION(int, ompt_get_place_proc_ids, ( - int place_num, - int ids_size, - int *ids -)); - -OMPT_API_FUNCTION(int, ompt_get_place_num, (void)); - -OMPT_API_FUNCTION(int, ompt_get_partition_place_nums, ( - int place_nums_size, - int *place_nums -)); - -/* proc_id */ -OMPT_API_FUNCTION(int, ompt_get_proc_id, (void)); - - -/**************************************************************************** - * INITIALIZATION FUNCTIONS - ***************************************************************************/ - -OMPT_API_FUNCTION(int, ompt_initialize, ( - ompt_function_lookup_t lookup, - ompt_data_t *tool_data -)); - -OMPT_API_FUNCTION(void, ompt_finalize, ( - ompt_data_t *tool_data -)); - -typedef struct ompt_start_tool_result_t { - ompt_initialize_t initialize; - ompt_finalize_t finalize; - ompt_data_t tool_data; -} ompt_start_tool_result_t; - -/* initialization interface to be defined by tool */ -#ifdef _WIN32 -__declspec(dllexport) -#endif -ompt_start_tool_result_t * ompt_start_tool( - unsigned int omp_version, - const char * runtime_version -); - -typedef void (*ompt_callback_t)(void); - -OMPT_API_FUNCTION(int, ompt_set_callback, ( - ompt_callbacks_t which, - ompt_callback_t callback -)); - -OMPT_API_FUNCTION(int, ompt_get_callback, ( - ompt_callbacks_t which, - ompt_callback_t *callback -)); - - - -/**************************************************************************** - * MISCELLANEOUS FUNCTIONS - ***************************************************************************/ - -/* state enumeration */ -OMPT_API_FUNCTION(int, ompt_enumerate_states, ( - int current_state, - int *next_state, - const char **next_state_name -)); - -/* mutex implementation enumeration */ -OMPT_API_FUNCTION(int, ompt_enumerate_mutex_impls, ( - int current_impl, - int *next_impl, - const char **next_impl_name -)); - -/* get_unique_id */ -OMPT_API_FUNCTION(uint64_t, ompt_get_unique_id, (void)); - -/* finalize tool */ -OMPT_API_FUNCTION(void, ompt_finalize_tool, (void)); - -#ifdef __cplusplus -}; -#endif - -/**************************************************************************** - * TARGET - ***************************************************************************/ - - OMPT_API_FUNCTION(int, ompt_get_target_info, ( - uint64_t *device_num, - ompt_id_t *target_id, - ompt_id_t *host_op_id -)); - - OMPT_API_FUNCTION(int, ompt_get_num_devices, (void)); - -#endif /* __OMPT__ */ diff --git a/runtime/src/kmp.h b/runtime/src/kmp.h index 23bbeb3..5ad992a 100644 --- a/runtime/src/kmp.h +++ b/runtime/src/kmp.h @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -1848,6 +1847,7 @@ typedef struct kmp_internal_control { #endif int nproc; /* internal control for #threads for next parallel region (per thread) */ + int thread_limit; /* internal control for thread-limit-var */ int max_active_levels; /* internal control for max_active_levels */ kmp_r_sched_t sched; /* internal control for runtime schedule {sched,chunk} pair */ @@ -2078,6 +2078,9 @@ typedef struct kmp_local { #define set__nproc(xthread, xval) \ (((xthread)->th.th_current_task->td_icvs.nproc) = (xval)) +#define set__thread_limit(xthread, xval) \ + (((xthread)->th.th_current_task->td_icvs.thread_limit) = (xval)) + #define set__max_active_levels(xthread, xval) \ (((xthread)->th.th_current_task->td_icvs.max_active_levels) = (xval)) @@ -2459,6 +2462,26 @@ typedef struct kmp_teams_size { } kmp_teams_size_t; #endif +// This struct stores a thread that acts as a "root" for a contention +// group. Contention groups are rooted at kmp_root threads, but also at +// each master thread of each team created in the teams construct. +// This struct therefore also stores a thread_limit associated with +// that contention group, and a counter to track the number of threads +// active in that contention group. Each thread has a list of these: CG +// root threads have an entry in their list in which cg_root refers to +// the thread itself, whereas other workers in the CG will have a +// single entry where cg_root is same as the entry containing their CG +// root. When a thread encounters a teams construct, it will add a new +// entry to the front of its list, because it now roots a new CG. +typedef struct kmp_cg_root { + kmp_info_p *cg_root; // "root" thread for a contention group + // The CG root's limit comes from OMP_THREAD_LIMIT for root threads, or + // thread_limit clause for teams masters + kmp_int32 cg_thread_limit; + kmp_int32 cg_nthreads; // Count of active threads in CG rooted at cg_root + struct kmp_cg_root *up; // pointer to higher level CG root in list +} kmp_cg_root_t; + // OpenMP thread data structures typedef struct KMP_ALIGN_CACHE kmp_base_info { @@ -2606,6 +2629,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info { #if KMP_OS_UNIX std::atomic<bool> th_blocking; #endif + kmp_cg_root_t *th_cg_roots; // list of cg_roots associated with this thread } kmp_base_info_t; typedef union KMP_ALIGN_CACHE kmp_info { @@ -2797,7 +2821,6 @@ typedef struct kmp_base_root { kmp_lock_t r_begin_lock; volatile int r_begin; int r_blocktime; /* blocktime for this root and descendants */ - int r_cg_nthreads; // count of active threads in a contention group } kmp_base_root_t; typedef union KMP_ALIGN_CACHE kmp_root { @@ -3160,9 +3183,9 @@ extern kmp_global_t __kmp_global; /* global status */ extern kmp_info_t __kmp_monitor; // For Debugging Support Library -extern std::atomic<kmp_uint32> __kmp_team_counter; +extern std::atomic<kmp_int32> __kmp_team_counter; // For Debugging Support Library -extern std::atomic<kmp_uint32> __kmp_task_counter; +extern std::atomic<kmp_int32> __kmp_task_counter; #if USE_DEBUGGER #define _KMP_GEN_ID(counter) \ @@ -3467,6 +3490,10 @@ extern void __kmp_reap_monitor(kmp_info_t *th); extern void __kmp_reap_worker(kmp_info_t *th); extern void __kmp_terminate_thread(int gtid); +extern int __kmp_try_suspend_mx(kmp_info_t *th); +extern void __kmp_lock_suspend_mx(kmp_info_t *th); +extern void __kmp_unlock_suspend_mx(kmp_info_t *th); + extern void __kmp_suspend_32(int th_gtid, kmp_flag_32 *flag); extern void __kmp_suspend_64(int th_gtid, kmp_flag_64 *flag); extern void __kmp_suspend_oncore(int th_gtid, kmp_flag_oncore *flag); @@ -4000,6 +4027,40 @@ extern kmp_target_offload_kind_t __kmp_target_offload; extern int __kmpc_get_target_offload(); #endif +#if OMP_40_ENABLED +// Constants used in libomptarget +#define KMP_DEVICE_DEFAULT -1 // This is libomptarget's default device. +#define KMP_HOST_DEVICE -10 // This is what it is in libomptarget, go figure. +#define KMP_DEVICE_ALL -11 // This is libomptarget's "all devices". +#endif // OMP_40_ENABLED + +#if OMP_50_ENABLED +// OMP Pause Resource + +// The following enum is used both to set the status in __kmp_pause_status, and +// as the internal equivalent of the externally-visible omp_pause_resource_t. +typedef enum kmp_pause_status_t { + kmp_not_paused = 0, // status is not paused, or, requesting resume + kmp_soft_paused = 1, // status is soft-paused, or, requesting soft pause + kmp_hard_paused = 2 // status is hard-paused, or, requesting hard pause +} kmp_pause_status_t; + +// This stores the pause state of the runtime +extern kmp_pause_status_t __kmp_pause_status; +extern int __kmpc_pause_resource(kmp_pause_status_t level); +extern int __kmp_pause_resource(kmp_pause_status_t level); +// Soft resume sets __kmp_pause_status, and wakes up all threads. +extern void __kmp_resume_if_soft_paused(); +// Hard resume simply resets the status to not paused. Library will appear to +// be uninitialized after hard pause. Let OMP constructs trigger required +// initializations. +static inline void __kmp_resume_if_hard_paused() { + if (__kmp_pause_status == kmp_hard_paused) { + __kmp_pause_status = kmp_not_paused; + } +} +#endif // OMP_50_ENABLED + #ifdef __cplusplus } #endif diff --git a/runtime/src/kmp_affinity.cpp b/runtime/src/kmp_affinity.cpp index 775862e..bfbbdd8 100644 --- a/runtime/src/kmp_affinity.cpp +++ b/runtime/src/kmp_affinity.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -4505,6 +4504,7 @@ static void __kmp_aux_affinity_initialize(void) { KMP_WARNING(AffNoValidProcID); } __kmp_affinity_type = affinity_none; + __kmp_create_affinity_none_places(); return; } break; @@ -4557,11 +4557,9 @@ static void __kmp_aux_affinity_initialize(void) { KMP_WARNING(AffBalancedNotAvail, "KMP_AFFINITY"); } __kmp_affinity_type = affinity_none; + __kmp_create_affinity_none_places(); return; - } else if (__kmp_affinity_uniform_topology()) { - break; - } else { // Non-uniform topology - + } else if (!__kmp_affinity_uniform_topology()) { // Save the depth for further usage __kmp_aff_depth = depth; @@ -4602,8 +4600,9 @@ static void __kmp_aux_affinity_initialize(void) { procarr[core * maxprocpercore + inlastcore] = proc; } - - break; + } + if (__kmp_affinity_compact >= depth) { + __kmp_affinity_compact = depth - 1; } sortAddresses: @@ -4781,6 +4780,11 @@ void __kmp_affinity_set_init_mask(int gtid, int isa_root) { th->th.th_new_place = i; th->th.th_first_place = 0; th->th.th_last_place = __kmp_affinity_num_masks - 1; + } else if (KMP_AFFINITY_NON_PROC_BIND) { + // When using a Non-OMP_PROC_BIND affinity method, + // set all threads' place-partition-var to the entire place list + th->th.th_first_place = 0; + th->th.th_last_place = __kmp_affinity_num_masks - 1; } if (i == KMP_PLACE_ALL) { @@ -4880,7 +4884,7 @@ int __kmp_aux_set_affinity(void **mask) { } gtid = __kmp_entry_gtid(); - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, (kmp_affin_mask_t *)(*mask)); @@ -4950,7 +4954,7 @@ int __kmp_aux_get_affinity(void **mask) { th = __kmp_threads[gtid]; KMP_DEBUG_ASSERT(th->th.th_affin_mask != NULL); - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, th->th.th_affin_mask); @@ -4967,7 +4971,7 @@ int __kmp_aux_get_affinity(void **mask) { #if !KMP_OS_WINDOWS retval = __kmp_get_system_affinity((kmp_affin_mask_t *)(*mask), FALSE); - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, (kmp_affin_mask_t *)(*mask)); @@ -5001,7 +5005,7 @@ int __kmp_aux_set_affinity_mask_proc(int proc, void **mask) { return -1; } - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { int gtid = __kmp_entry_gtid(); char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, @@ -5033,7 +5037,7 @@ int __kmp_aux_unset_affinity_mask_proc(int proc, void **mask) { return -1; } - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { int gtid = __kmp_entry_gtid(); char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, @@ -5065,7 +5069,7 @@ int __kmp_aux_get_affinity_mask_proc(int proc, void **mask) { return -1; } - KA_TRACE(1000, ; { + KA_TRACE(1000, (""); { int gtid = __kmp_entry_gtid(); char buf[KMP_AFFIN_MASK_PRINT_LEN]; __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, diff --git a/runtime/src/kmp_affinity.h b/runtime/src/kmp_affinity.h index e62508a..e4af20d 100644 --- a/runtime/src/kmp_affinity.h +++ b/runtime/src/kmp_affinity.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_alloc.cpp b/runtime/src/kmp_alloc.cpp index ae60fef..1d57e83 100644 --- a/runtime/src/kmp_alloc.cpp +++ b/runtime/src/kmp_alloc.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_atomic.cpp b/runtime/src/kmp_atomic.cpp index 437f158..cd5d8c8 100644 --- a/runtime/src/kmp_atomic.cpp +++ b/runtime/src/kmp_atomic.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_atomic.h b/runtime/src/kmp_atomic.h index 288916c..2f25173 100644 --- a/runtime/src/kmp_atomic.h +++ b/runtime/src/kmp_atomic.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_barrier.cpp b/runtime/src/kmp_barrier.cpp index 79b6bf3..332028f 100644 --- a/runtime/src/kmp_barrier.cpp +++ b/runtime/src/kmp_barrier.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -1910,7 +1909,7 @@ void __kmp_fork_barrier(int gtid, int tid) { #endif if (!KMP_MASTER_TID(ds_tid) && ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( - ompt_scope_end, NULL, task_data, 0, ds_tid); + ompt_scope_end, NULL, task_data, 0, ds_tid, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } } #endif diff --git a/runtime/src/kmp_cancel.cpp b/runtime/src/kmp_cancel.cpp index 5ed9167..23432f3 100644 --- a/runtime/src/kmp_cancel.cpp +++ b/runtime/src/kmp_cancel.cpp @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_config.h.cmake b/runtime/src/kmp_config.h.cmake index c9ebbc0..b4b76a2 100644 --- a/runtime/src/kmp_config.h.cmake +++ b/runtime/src/kmp_config.h.cmake @@ -3,10 +3,9 @@ */ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef KMP_CONFIG_H diff --git a/runtime/src/kmp_csupport.cpp b/runtime/src/kmp_csupport.cpp index 4c62720..455cbe2 100644 --- a/runtime/src/kmp_csupport.cpp +++ b/runtime/src/kmp_csupport.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -426,6 +425,19 @@ void __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, #endif ); + // Pop current CG root off list + KMP_DEBUG_ASSERT(this_thr->th.th_cg_roots); + kmp_cg_root_t *tmp = this_thr->th.th_cg_roots; + this_thr->th.th_cg_roots = tmp->up; + KA_TRACE(100, ("__kmpc_fork_teams: Thread %p popping node %p and moving up" + " to node %p. cg_nthreads was %d\n", + this_thr, tmp, this_thr->th.th_cg_roots, tmp->cg_nthreads)); + __kmp_free(tmp); + // Restore current task's thread_limit from CG root + KMP_DEBUG_ASSERT(this_thr->th.th_cg_roots); + this_thr->th.th_current_task->td_icvs.thread_limit = + this_thr->th.th_cg_roots->cg_thread_limit; + this_thr->th.th_teams_microtask = NULL; this_thr->th.th_teams_level = 0; *(kmp_int64 *)(&this_thr->th.th_teams_size) = 0L; @@ -485,6 +497,10 @@ void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + this_thr = __kmp_threads[global_tid]; serial_team = this_thr->th.th_serial_team; @@ -511,7 +527,7 @@ void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32 global_tid) { if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_end, NULL, OMPT_CUR_TASK_DATA(this_thr), 1, - OMPT_CUR_TASK_INFO(this_thr)->thread_num); + OMPT_CUR_TASK_INFO(this_thr)->thread_num, ompt_task_implicit); } // reset clear the task id only after unlinking the task @@ -696,6 +712,10 @@ void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + if (__kmp_env_consistency_check) { if (loc == 0) { KMP_WARNING(ConstructIdentInvalid); // ??? What does it mean for the user? @@ -744,6 +764,10 @@ kmp_int32 __kmpc_master(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + if (KMP_MASTER_GTID(global_tid)) { KMP_COUNT_BLOCK(OMP_MASTER); KMP_PUSH_PARTITIONED_TIMER(OMP_master); @@ -834,6 +858,10 @@ void __kmpc_ordered(ident_t *loc, kmp_int32 gtid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + #if USE_ITT_BUILD __kmp_itt_ordered_prep(gtid); // TODO: ordered_wait_id @@ -1292,7 +1320,7 @@ __ompt_get_mutex_impl_type(void *user_lock, kmp_indirect_lock_t *ilock = 0) { return kmp_mutex_impl_speculative; #endif default: - return ompt_mutex_impl_none; + return kmp_mutex_impl_none; } ilock = KMP_LOOKUP_I_LOCK(user_lock); } @@ -1316,7 +1344,7 @@ __ompt_get_mutex_impl_type(void *user_lock, kmp_indirect_lock_t *ilock = 0) { case locktag_nested_drdpa: return kmp_mutex_impl_queuing; default: - return ompt_mutex_impl_none; + return kmp_mutex_impl_none; } } #else @@ -1339,7 +1367,7 @@ static kmp_mutex_impl_t __ompt_get_mutex_impl_type() { return kmp_mutex_impl_speculative; #endif default: - return ompt_mutex_impl_none; + return kmp_mutex_impl_none; } } #endif // KMP_USE_DYNAMIC_LOCK @@ -1590,6 +1618,10 @@ kmp_int32 __kmpc_barrier_master(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + if (__kmp_env_consistency_check) __kmp_check_barrier(global_tid, ct_barrier, loc); @@ -1648,6 +1680,10 @@ kmp_int32 __kmpc_barrier_master_nowait(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + if (__kmp_env_consistency_check) { if (loc == 0) { KMP_WARNING(ConstructIdentInvalid); // ??? What does it mean for the user? @@ -3366,6 +3402,10 @@ __kmpc_reduce_nowait(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars, if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + // check correctness of reduce block nesting #if KMP_USE_DYNAMIC_LOCK if (__kmp_env_consistency_check) @@ -3586,6 +3626,10 @@ kmp_int32 __kmpc_reduce(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars, if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + // check correctness of reduce block nesting #if KMP_USE_DYNAMIC_LOCK if (__kmp_env_consistency_check) @@ -4159,6 +4203,13 @@ int __kmpc_get_target_offload(void) { } return __kmp_target_offload; } + +int __kmpc_pause_resource(kmp_pause_status_t level) { + if (!__kmp_init_serial) { + return 1; // Can't pause if runtime is not initialized + } + return __kmp_pause_resource(level); +} #endif // OMP_50_ENABLED // end of file // diff --git a/runtime/src/kmp_debug.cpp b/runtime/src/kmp_debug.cpp index 50d3876..6c397c5 100644 --- a/runtime/src/kmp_debug.cpp +++ b/runtime/src/kmp_debug.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_debug.h b/runtime/src/kmp_debug.h index 29cc15c..08d52cc 100644 --- a/runtime/src/kmp_debug.h +++ b/runtime/src/kmp_debug.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_debugger.cpp b/runtime/src/kmp_debugger.cpp index c02d251..96b879f 100644 --- a/runtime/src/kmp_debugger.cpp +++ b/runtime/src/kmp_debugger.cpp @@ -1,3 +1,5 @@ +#include "kmp_config.h" + #if USE_DEBUGGER /* * kmp_debugger.cpp -- debugger support. @@ -5,10 +7,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_debugger.h b/runtime/src/kmp_debugger.h index 6c747b2..7ec7428 100644 --- a/runtime/src/kmp_debugger.h +++ b/runtime/src/kmp_debugger.h @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_dispatch.cpp b/runtime/src/kmp_dispatch.cpp index 1090e9d..872b96d 100644 --- a/runtime/src/kmp_dispatch.cpp +++ b/runtime/src/kmp_dispatch.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -349,6 +348,7 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid, /* too few iterations: fall-through to kmp_sch_static_balanced */ } // if /* FALL-THROUGH to static balanced */ + KMP_FALLTHROUGH(); } // case #endif case kmp_sch_static_balanced: { @@ -740,6 +740,10 @@ __kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb, if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + #if INCLUDE_SSC_MARKS SSC_MARK_DISPATCH_INIT(); #endif diff --git a/runtime/src/kmp_dispatch.h b/runtime/src/kmp_dispatch.h index 9558071..84603d1 100644 --- a/runtime/src/kmp_dispatch.h +++ b/runtime/src/kmp_dispatch.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_dispatch_hier.h b/runtime/src/kmp_dispatch_hier.h index 8277eaa..48b164e 100644 --- a/runtime/src/kmp_dispatch_hier.h +++ b/runtime/src/kmp_dispatch_hier.h @@ -924,6 +924,10 @@ void __kmp_dispatch_init_hierarchy(ident_t *loc, int n, KMP_DEBUG_ASSERT(new_chunks); if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + th = __kmp_threads[gtid]; team = th->th.th_team; active = !team->t.t_serialized; diff --git a/runtime/src/kmp_environment.cpp b/runtime/src/kmp_environment.cpp index 22c2941..51bc3cf 100644 --- a/runtime/src/kmp_environment.cpp +++ b/runtime/src/kmp_environment.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_environment.h b/runtime/src/kmp_environment.h index 474aa34..76a9672 100644 --- a/runtime/src/kmp_environment.h +++ b/runtime/src/kmp_environment.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_error.cpp b/runtime/src/kmp_error.cpp index 1a708b5..6836567 100644 --- a/runtime/src/kmp_error.cpp +++ b/runtime/src/kmp_error.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_error.h b/runtime/src/kmp_error.h index e1bf817..fe6fd34 100644 --- a/runtime/src/kmp_error.h +++ b/runtime/src/kmp_error.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_ftn_cdecl.cpp b/runtime/src/kmp_ftn_cdecl.cpp index 702fd0d..cf1d429 100644 --- a/runtime/src/kmp_ftn_cdecl.cpp +++ b/runtime/src/kmp_ftn_cdecl.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_ftn_entry.h b/runtime/src/kmp_ftn_entry.h index abf1892..690ac35 100644 --- a/runtime/src/kmp_ftn_entry.h +++ b/runtime/src/kmp_ftn_entry.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -735,11 +734,15 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_THREAD_LIMIT)(void) { #ifdef KMP_STUB return 1; // TO DO: clarify whether it returns 1 or 0? #else + int gtid; + kmp_info_t *thread; if (!__kmp_init_serial) { __kmp_serial_initialize(); } - /* global ICV */ - return __kmp_cg_max_nth; + + gtid = __kmp_entry_gtid(); + thread = __kmp_threads[gtid]; + return thread->th.th_current_task->td_icvs.thread_limit; #endif } @@ -858,9 +861,6 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_PARTITION_NUM_PLACES)(void) { } if (!KMP_AFFINITY_CAPABLE()) return 0; - if (KMP_AFFINITY_NON_PROC_BIND) { - return 1; - } gtid = __kmp_entry_gtid(); thread = __kmp_thread_from_gtid(gtid); first_place = thread->th.th_first_place; @@ -889,10 +889,6 @@ void return; gtid = __kmp_entry_gtid(); thread = __kmp_thread_from_gtid(gtid); - if (KMP_AFFINITY_NON_PROC_BIND) { - place_nums[0] = thread->th.th_current_place; - return; - } first_place = thread->th.th_first_place; last_place = thread->th.th_last_place; if (first_place < 0 || last_place < 0) @@ -944,39 +940,53 @@ void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_DEFAULT_DEVICE)(int KMP_DEREF arg) { #endif } -#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) - -int FTN_STDCALL FTN_GET_NUM_DEVICES(void) { return 0; } - -#endif // KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) - -#if !KMP_OS_LINUX - -int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) { return 1; } - +// Get number of NON-HOST devices. +// libomptarget, if loaded, provides this function in api.cpp. +int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) KMP_WEAK_ATTRIBUTE; +int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) { +#if KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB) + return 0; #else - -// This internal function is used when the entry from the offload library -// is not found. -int _Offload_get_device_number(void) KMP_WEAK_ATTRIBUTE; - -int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) { - if (_Offload_get_device_number) { - return _Offload_get_device_number() == -1; - } else { - return 1; + int (*fptr)(); + if ((*(void **)(&fptr) = dlsym(RTLD_DEFAULT, "_Offload_number_of_devices"))) { + return (*fptr)(); + } else if ((*(void **)(&fptr) = dlsym(RTLD_NEXT, "omp_get_num_devices"))) { + return (*fptr)(); + } else { // liboffload & libomptarget don't exist + return 0; } +#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB) } -#endif // ! KMP_OS_LINUX +// This function always returns true when called on host device. +// Compilier/libomptarget should handle when it is called inside target region. +int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) KMP_WEAK_ATTRIBUTE; +int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) { + return 1; // This is the host +} #endif // OMP_40_ENABLED -#if OMP_45_ENABLED && defined(KMP_STUB) -// OpenMP 4.5 entries for stubs library - -int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) { return -1; } +#if OMP_45_ENABLED +// OpenMP 4.5 entries + +// libomptarget, if loaded, provides this function +int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) KMP_WEAK_ATTRIBUTE; +int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) { +#if KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB) + return KMP_HOST_DEVICE; +#else + int (*fptr)(); + if ((*(void **)(&fptr) = dlsym(RTLD_NEXT, "omp_get_initial_device"))) { + return (*fptr)(); + } else { // liboffload & libomptarget don't exist + return KMP_HOST_DEVICE; + } +#endif +} +#if defined(KMP_STUB) +// Entries for stubs library // As all *target* functions are C-only parameters always passed by value void *FTN_STDCALL FTN_TARGET_ALLOC(size_t size, int device_num) { return 0; } @@ -1007,7 +1017,8 @@ int FTN_STDCALL FTN_TARGET_ASSOCIATE_PTR(void *host_ptr, void *device_ptr, int FTN_STDCALL FTN_TARGET_DISASSOCIATE_PTR(void *host_ptr, int device_num) { return -1; } -#endif // OMP_45_ENABLED && defined(KMP_STUB) +#endif // defined(KMP_STUB) +#endif // OMP_45_ENABLED #ifdef KMP_STUB typedef enum { UNINIT = -1, UNLOCKED, LOCKED } kmp_stub_lock_t; @@ -1318,6 +1329,50 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) { } #endif +#if OMP_50_ENABLED +// This function will be defined in libomptarget. When libomptarget is not +// loaded, we assume we are on the host and return KMP_HOST_DEVICE. +// Compiler/libomptarget will handle this if called inside target. +int FTN_STDCALL FTN_GET_DEVICE_NUM(void) KMP_WEAK_ATTRIBUTE; +int FTN_STDCALL FTN_GET_DEVICE_NUM(void) { return KMP_HOST_DEVICE; } + +// Compiler will ensure that this is only called from host in sequential region +int FTN_STDCALL FTN_PAUSE_RESOURCE(kmp_pause_status_t kind, int device_num) { +#ifdef KMP_STUB + return 1; // just fail +#else + if (device_num == KMP_HOST_DEVICE) + return __kmpc_pause_resource(kind); + else { +#if !KMP_OS_WINDOWS + int (*fptr)(kmp_pause_status_t, int); + if ((*(void **)(&fptr) = dlsym(RTLD_DEFAULT, "tgt_pause_resource"))) + return (*fptr)(kind, device_num); + else +#endif + return 1; // just fail if there is no libomptarget + } +#endif +} + +// Compiler will ensure that this is only called from host in sequential region +int FTN_STDCALL FTN_PAUSE_RESOURCE_ALL(kmp_pause_status_t kind) { +#ifdef KMP_STUB + return 1; // just fail +#else + int fails = 0; +#if !KMP_OS_WINDOWS + int (*fptr)(kmp_pause_status_t, int); + if ((*(void **)(&fptr) = dlsym(RTLD_DEFAULT, "tgt_pause_resource"))) + fails = (*fptr)(kind, KMP_DEVICE_ALL); // pause devices +#endif + fails += __kmpc_pause_resource(kind); // pause host + return fails; +#endif +} + +#endif // OMP_50_ENABLED + // GCC compatibility (versioned symbols) #ifdef KMP_USE_VERSION_SYMBOLS @@ -1401,6 +1456,7 @@ KMP_VERSION_SYMBOL(FTN_GET_CANCELLATION, 40, "OMP_4.0"); KMP_VERSION_SYMBOL(FTN_GET_DEFAULT_DEVICE, 40, "OMP_4.0"); KMP_VERSION_SYMBOL(FTN_SET_DEFAULT_DEVICE, 40, "OMP_4.0"); KMP_VERSION_SYMBOL(FTN_IS_INITIAL_DEVICE, 40, "OMP_4.0"); +KMP_VERSION_SYMBOL(FTN_GET_NUM_DEVICES, 40, "OMP_4.0"); #endif /* OMP_40_ENABLED */ #if OMP_45_ENABLED @@ -1412,10 +1468,14 @@ KMP_VERSION_SYMBOL(FTN_GET_PLACE_PROC_IDS, 45, "OMP_4.5"); KMP_VERSION_SYMBOL(FTN_GET_PLACE_NUM, 45, "OMP_4.5"); KMP_VERSION_SYMBOL(FTN_GET_PARTITION_NUM_PLACES, 45, "OMP_4.5"); KMP_VERSION_SYMBOL(FTN_GET_PARTITION_PLACE_NUMS, 45, "OMP_4.5"); +// KMP_VERSION_SYMBOL(FTN_GET_INITIAL_DEVICE, 45, "OMP_4.5"); #endif #if OMP_50_ENABLED // OMP_5.0 versioned symbols +// KMP_VERSION_SYMBOL(FTN_GET_DEVICE_NUM, 50, "OMP_5.0"); +// KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE, 50, "OMP_5.0"); +// KMP_VERSION_SYMBOL(FTN_PAUSE_RESOURCE_ALL, 50, "OMP_5.0"); #endif #endif // KMP_USE_VERSION_SYMBOLS diff --git a/runtime/src/kmp_ftn_extra.cpp b/runtime/src/kmp_ftn_extra.cpp index ec27dd6..74b3e96 100644 --- a/runtime/src/kmp_ftn_extra.cpp +++ b/runtime/src/kmp_ftn_extra.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_ftn_os.h b/runtime/src/kmp_ftn_os.h index 47188fc..6a6ccb3 100644 --- a/runtime/src/kmp_ftn_os.h +++ b/runtime/src/kmp_ftn_os.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -100,9 +99,7 @@ #define FTN_GET_WTICK omp_get_wtick #if OMP_40_ENABLED -#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) #define FTN_GET_NUM_DEVICES omp_get_num_devices -#endif #define FTN_GET_DEFAULT_DEVICE omp_get_default_device #define FTN_SET_DEFAULT_DEVICE omp_set_default_device #define FTN_IS_INITIAL_DEVICE omp_is_initial_device @@ -121,8 +118,8 @@ #define FTN_GET_PLACE_NUM omp_get_place_num #define FTN_GET_PARTITION_NUM_PLACES omp_get_partition_num_places #define FTN_GET_PARTITION_PLACE_NUMS omp_get_partition_place_nums -#ifdef KMP_STUB #define FTN_GET_INITIAL_DEVICE omp_get_initial_device +#ifdef KMP_STUB #define FTN_TARGET_ALLOC omp_target_alloc #define FTN_TARGET_FREE omp_target_free #define FTN_TARGET_IS_PRESENT omp_target_is_present @@ -139,10 +136,13 @@ #define FTN_GET_DEFAULT_ALLOCATOR omp_get_default_allocator #define FTN_ALLOC omp_alloc #define FTN_FREE omp_free +#define FTN_GET_DEVICE_NUM omp_get_device_num #define FTN_SET_AFFINITY_FORMAT omp_set_affinity_format #define FTN_GET_AFFINITY_FORMAT omp_get_affinity_format #define FTN_DISPLAY_AFFINITY omp_display_affinity #define FTN_CAPTURE_AFFINITY omp_capture_affinity +#define FTN_PAUSE_RESOURCE omp_pause_resource +#define FTN_PAUSE_RESOURCE_ALL omp_pause_resource_all #endif #endif /* KMP_FTN_PLAIN */ @@ -230,9 +230,7 @@ #define FTN_GET_WTICK omp_get_wtick_ #if OMP_40_ENABLED -#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) #define FTN_GET_NUM_DEVICES omp_get_num_devices_ -#endif #define FTN_GET_DEFAULT_DEVICE omp_get_default_device_ #define FTN_SET_DEFAULT_DEVICE omp_set_default_device_ #define FTN_IS_INITIAL_DEVICE omp_is_initial_device_ @@ -251,8 +249,8 @@ #define FTN_GET_PLACE_NUM omp_get_place_num_ #define FTN_GET_PARTITION_NUM_PLACES omp_get_partition_num_places_ #define FTN_GET_PARTITION_PLACE_NUMS omp_get_partition_place_nums_ -#ifdef KMP_STUB #define FTN_GET_INITIAL_DEVICE omp_get_initial_device_ +#ifdef KMP_STUB #define FTN_TARGET_ALLOC omp_target_alloc_ #define FTN_TARGET_FREE omp_target_free_ #define FTN_TARGET_IS_PRESENT omp_target_is_present_ @@ -269,10 +267,13 @@ #define FTN_GET_DEFAULT_ALLOCATOR omp_get_default_allocator_ #define FTN_ALLOC omp_alloc_ #define FTN_FREE omp_free_ +#define FTN_GET_DEVICE_NUM omp_get_device_num_ #define FTN_SET_AFFINITY_FORMAT omp_set_affinity_format_ #define FTN_GET_AFFINITY_FORMAT omp_get_affinity_format_ #define FTN_DISPLAY_AFFINITY omp_display_affinity_ #define FTN_CAPTURE_AFFINITY omp_capture_affinity_ +#define FTN_PAUSE_RESOURCE omp_pause_resource_ +#define FTN_PAUSE_RESOURCE_ALL omp_pause_resource_all_ #endif #endif /* KMP_FTN_APPEND */ @@ -360,9 +361,7 @@ #define FTN_GET_WTICK OMP_GET_WTICK #if OMP_40_ENABLED -#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) #define FTN_GET_NUM_DEVICES OMP_GET_NUM_DEVICES -#endif #define FTN_GET_DEFAULT_DEVICE OMP_GET_DEFAULT_DEVICE #define FTN_SET_DEFAULT_DEVICE OMP_SET_DEFAULT_DEVICE #define FTN_IS_INITIAL_DEVICE OMP_IS_INITIAL_DEVICE @@ -381,8 +380,8 @@ #define FTN_GET_PLACE_NUM OMP_GET_PLACE_NUM #define FTN_GET_PARTITION_NUM_PLACES OMP_GET_PARTITION_NUM_PLACES #define FTN_GET_PARTITION_PLACE_NUMS OMP_GET_PARTITION_PLACE_NUMS -#ifdef KMP_STUB #define FTN_GET_INITIAL_DEVICE OMP_GET_INITIAL_DEVICE +#ifdef KMP_STUB #define FTN_TARGET_ALLOC OMP_TARGET_ALLOC #define FTN_TARGET_FREE OMP_TARGET_FREE #define FTN_TARGET_IS_PRESENT OMP_TARGET_IS_PRESENT @@ -399,10 +398,13 @@ #define FTN_GET_DEFAULT_ALLOCATOR OMP_GET_DEFAULT_ALLOCATOR #define FTN_ALLOC OMP_ALLOC #define FTN_FREE OMP_FREE +#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM #define FTN_SET_AFFINITY_FORMAT OMP_SET_AFFINITY_FORMAT #define FTN_GET_AFFINITY_FORMAT OMP_GET_AFFINITY_FORMAT #define FTN_DISPLAY_AFFINITY OMP_DISPLAY_AFFINITY #define FTN_CAPTURE_AFFINITY OMP_CAPTURE_AFFINITY +#define FTN_PAUSE_RESOURCE OMP_PAUSE_RESOURCE +#define FTN_PAUSE_RESOURCE_ALL OMP_PAUSE_RESOURCE_ALL #endif #endif /* KMP_FTN_UPPER */ @@ -490,9 +492,7 @@ #define FTN_GET_WTICK OMP_GET_WTICK_ #if OMP_40_ENABLED -#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB) #define FTN_GET_NUM_DEVICES OMP_GET_NUM_DEVICES_ -#endif #define FTN_GET_DEFAULT_DEVICE OMP_GET_DEFAULT_DEVICE_ #define FTN_SET_DEFAULT_DEVICE OMP_SET_DEFAULT_DEVICE_ #define FTN_IS_INITIAL_DEVICE OMP_IS_INITIAL_DEVICE_ @@ -511,8 +511,8 @@ #define FTN_GET_PLACE_NUM OMP_GET_PLACE_NUM_ #define FTN_GET_PARTITION_NUM_PLACES OMP_GET_PARTITION_NUM_PLACES_ #define FTN_GET_PARTITION_PLACE_NUMS OMP_GET_PARTITION_PLACE_NUMS_ -#ifdef KMP_STUB #define FTN_GET_INITIAL_DEVICE OMP_GET_INITIAL_DEVICE_ +#ifdef KMP_STUB #define FTN_TARGET_ALLOC OMP_TARGET_ALLOC_ #define FTN_TARGET_FREE OMP_TARGET_FREE_ #define FTN_TARGET_IS_PRESENT OMP_TARGET_IS_PRESENT_ @@ -529,10 +529,13 @@ #define FTN_GET_DEFAULT_ALLOCATOR OMP_GET_DEFAULT_ALLOCATOR_ #define FTN_ALLOC OMP_ALLOC_ #define FTN_FREE OMP_FREE_ +#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM_ #define FTN_SET_AFFINITY_FORMAT OMP_SET_AFFINITY_FORMAT_ #define FTN_GET_AFFINITY_FORMAT OMP_GET_AFFINITY_FORMAT_ #define FTN_DISPLAY_AFFINITY OMP_DISPLAY_AFFINITY_ #define FTN_CAPTURE_AFFINITY OMP_CAPTURE_AFFINITY_ +#define FTN_PAUSE_RESOURCE OMP_PAUSE_RESOURCE_ +#define FTN_PAUSE_RESOURCE_ALL OMP_PAUSE_RESOURCE_ALL_ #endif #endif /* KMP_FTN_UAPPEND */ diff --git a/runtime/src/kmp_ftn_stdcall.cpp b/runtime/src/kmp_ftn_stdcall.cpp index ccf95f4..174c219 100644 --- a/runtime/src/kmp_ftn_stdcall.cpp +++ b/runtime/src/kmp_ftn_stdcall.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_global.cpp b/runtime/src/kmp_global.cpp index ef8a116..ee321d7 100644 --- a/runtime/src/kmp_global.cpp +++ b/runtime/src/kmp_global.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -60,8 +59,8 @@ int __kmp_init_counter = 0; int __kmp_root_counter = 0; int __kmp_version = 0; -std::atomic<kmp_uint32> __kmp_team_counter = ATOMIC_VAR_INIT(0); -std::atomic<kmp_uint32> __kmp_task_counter = ATOMIC_VAR_INIT(0); +std::atomic<kmp_int32> __kmp_team_counter = ATOMIC_VAR_INIT(0); +std::atomic<kmp_int32> __kmp_task_counter = ATOMIC_VAR_INIT(0); unsigned int __kmp_init_wait = KMP_DEFAULT_INIT_WAIT; /* initial number of spin-tests */ @@ -533,5 +532,9 @@ int _You_must_link_with_Microsoft_OpenMP_library = 1; #if OMP_50_ENABLED kmp_target_offload_kind_t __kmp_target_offload = tgt_default; -#endif + +// OMP Pause Resources +kmp_pause_status_t __kmp_pause_status = kmp_not_paused; +#endif // OMP_50_ENABLED + // end of file // diff --git a/runtime/src/kmp_gsupport.cpp b/runtime/src/kmp_gsupport.cpp index 646d75d..104e055 100644 --- a/runtime/src/kmp_gsupport.cpp +++ b/runtime/src/kmp_gsupport.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -120,6 +119,10 @@ int KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_START)(void) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + // 3rd parameter == FALSE prevents kmp_enter_single from pushing a // workshare when USE_CHECKS is defined. We need to avoid the push, // as there is no corresponding GOMP_single_end() call. @@ -168,6 +171,10 @@ void *KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + // If this is the first thread to enter, return NULL. The generated code will // then call GOMP_single_copy_end() for this thread only, with the // copyprivate data pointer as an argument. @@ -400,7 +407,7 @@ static ompt_team_size = __kmp_team_from_gtid(gtid)->t.t_nproc; ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, &(team_info->parallel_data), - &(task_info->task_data), ompt_team_size, __kmp_tid_from_gtid(gtid)); + &(task_info->task_data), ompt_team_size, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? task_info->thread_num = __kmp_tid_from_gtid(gtid); } thr->th.ompt_thread_info.state = ompt_state_work_parallel; diff --git a/runtime/src/kmp_i18n.cpp b/runtime/src/kmp_i18n.cpp index 95daac2..53c4427 100644 --- a/runtime/src/kmp_i18n.cpp +++ b/runtime/src/kmp_i18n.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_i18n.h b/runtime/src/kmp_i18n.h index 56dae22..9d79a21 100644 --- a/runtime/src/kmp_i18n.h +++ b/runtime/src/kmp_i18n.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_import.cpp b/runtime/src/kmp_import.cpp index 8ad7d1d..39d841d 100644 --- a/runtime/src/kmp_import.cpp +++ b/runtime/src/kmp_import.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_io.cpp b/runtime/src/kmp_io.cpp index 24c6e72..4e6ea6a 100644 --- a/runtime/src/kmp_io.cpp +++ b/runtime/src/kmp_io.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_io.h b/runtime/src/kmp_io.h index dac7a42..49afda5 100644 --- a/runtime/src/kmp_io.h +++ b/runtime/src/kmp_io.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_itt.cpp b/runtime/src/kmp_itt.cpp index 820bb59..fa286ec 100644 --- a/runtime/src/kmp_itt.cpp +++ b/runtime/src/kmp_itt.cpp @@ -7,10 +7,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_itt.h b/runtime/src/kmp_itt.h index 2062e01..94719f8 100644 --- a/runtime/src/kmp_itt.h +++ b/runtime/src/kmp_itt.h @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_itt.inl b/runtime/src/kmp_itt.inl index a0789fc..6e37ce0 100644 --- a/runtime/src/kmp_itt.inl +++ b/runtime/src/kmp_itt.inl @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_lock.cpp b/runtime/src/kmp_lock.cpp index 5c2eeed..af91644 100644 --- a/runtime/src/kmp_lock.cpp +++ b/runtime/src/kmp_lock.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -2874,6 +2873,47 @@ static int __kmp_unset_indirect_lock_with_checks(kmp_dyna_lock_t *lock, static int __kmp_test_indirect_lock_with_checks(kmp_dyna_lock_t *lock, kmp_int32); +// Lock function definitions for the union parameter type +#define KMP_FOREACH_LOCK_KIND(m, a) m(ticket, a) m(queuing, a) m(drdpa, a) + +#define expand1(lk, op) \ + static void __kmp_##op##_##lk##_##lock(kmp_user_lock_p lock) { \ + __kmp_##op##_##lk##_##lock(&lock->lk); \ + } +#define expand2(lk, op) \ + static int __kmp_##op##_##lk##_##lock(kmp_user_lock_p lock, \ + kmp_int32 gtid) { \ + return __kmp_##op##_##lk##_##lock(&lock->lk, gtid); \ + } +#define expand3(lk, op) \ + static void __kmp_set_##lk##_##lock_flags(kmp_user_lock_p lock, \ + kmp_lock_flags_t flags) { \ + __kmp_set_##lk##_lock_flags(&lock->lk, flags); \ + } +#define expand4(lk, op) \ + static void __kmp_set_##lk##_##lock_location(kmp_user_lock_p lock, \ + const ident_t *loc) { \ + __kmp_set_##lk##_lock_location(&lock->lk, loc); \ + } + +KMP_FOREACH_LOCK_KIND(expand1, init) +KMP_FOREACH_LOCK_KIND(expand1, init_nested) +KMP_FOREACH_LOCK_KIND(expand1, destroy) +KMP_FOREACH_LOCK_KIND(expand1, destroy_nested) +KMP_FOREACH_LOCK_KIND(expand2, acquire) +KMP_FOREACH_LOCK_KIND(expand2, acquire_nested) +KMP_FOREACH_LOCK_KIND(expand2, release) +KMP_FOREACH_LOCK_KIND(expand2, release_nested) +KMP_FOREACH_LOCK_KIND(expand2, test) +KMP_FOREACH_LOCK_KIND(expand2, test_nested) +KMP_FOREACH_LOCK_KIND(expand3, ) +KMP_FOREACH_LOCK_KIND(expand4, ) + +#undef expand1 +#undef expand2 +#undef expand3 +#undef expand4 + // Jump tables for the indirect lock functions // Only fill in the odd entries, that avoids the need to shift out the low bit diff --git a/runtime/src/kmp_lock.h b/runtime/src/kmp_lock.h index 6a88d7b..8ce500c 100644 --- a/runtime/src/kmp_lock.h +++ b/runtime/src/kmp_lock.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_omp.h b/runtime/src/kmp_omp.h index 8dcb7d2..bd0c698 100644 --- a/runtime/src/kmp_omp.h +++ b/runtime/src/kmp_omp.h @@ -6,10 +6,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_os.h b/runtime/src/kmp_os.h index 3c2426b..a553463 100644 --- a/runtime/src/kmp_os.h +++ b/runtime/src/kmp_os.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,6 +39,14 @@ #define KMP_MEM_CONS_MODEL KMP_MEM_CONS_VOLATILE #endif +#ifndef __has_cpp_attribute +#define __has_cpp_attribute(x) 0 +#endif + +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + /* ------------------------- Compiler recognition ---------------------- */ #define KMP_COMPILER_ICC 0 #define KMP_COMPILER_GCC 0 @@ -297,6 +304,20 @@ extern "C" { #define KMP_CACHE_PREFETCH(ADDR) /* nothing */ +// Define attribute that indicates that the fall through from the previous +// case label is intentional and should not be diagnosed by a compiler +// Code from libcxx/include/__config +// Use a function like macro to imply that it must be followed by a semicolon +#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) +# define KMP_FALLTHROUGH() [[fallthrough]] +#elif __has_cpp_attribute(clang::fallthrough) +# define KMP_FALLTHROUGH() [[clang::fallthrough]] +#elif __has_attribute(fallthough) || __GNUC__ >= 7 +# define KMP_FALLTHROUGH() __attribute__((__fallthrough__)) +#else +# define KMP_FALLTHROUGH() ((void)0) +#endif + // Define attribute that indicates a function does not return #if __cplusplus >= 201103L #define KMP_NORETURN [[noreturn]] diff --git a/runtime/src/kmp_platform.h b/runtime/src/kmp_platform.h index bb23de0..e4f2e06 100644 --- a/runtime/src/kmp_platform.h +++ b/runtime/src/kmp_platform.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_runtime.cpp b/runtime/src/kmp_runtime.cpp index 3dd9ab6..ead122f 100644 --- a/runtime/src/kmp_runtime.cpp +++ b/runtime/src/kmp_runtime.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -752,6 +751,10 @@ int __kmp_enter_single(int gtid, ident_t *id_ref, int push_ws) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + th = __kmp_threads[gtid]; team = th->th.th_team; status = 0; @@ -824,6 +827,7 @@ static int __kmp_reserve_threads(kmp_root_t *root, kmp_team_t *parent_team, int new_nthreads; KMP_DEBUG_ASSERT(__kmp_init_serial); KMP_DEBUG_ASSERT(root && parent_team); + kmp_info_t *this_thr = parent_team->t.t_threads[master_tid]; // If dyn-var is set, dynamically adjust the number of desired threads, // according to the method specified by dynamic_mode. @@ -913,10 +917,12 @@ static int __kmp_reserve_threads(kmp_root_t *root, kmp_team_t *parent_team, } // Respect OMP_THREAD_LIMIT - if (root->r.r_cg_nthreads + new_nthreads - + int cg_nthreads = this_thr->th.th_cg_roots->cg_nthreads; + int max_cg_threads = this_thr->th.th_cg_roots->cg_thread_limit; + if (cg_nthreads + new_nthreads - (root->r.r_active ? 1 : root->r.r_hot_team->t.t_nproc) > - __kmp_cg_max_nth) { - int tl_nthreads = __kmp_cg_max_nth - root->r.r_cg_nthreads + + max_cg_threads) { + int tl_nthreads = max_cg_threads - cg_nthreads + (root->r.r_active ? 1 : root->r.r_hot_team->t.t_nproc); if (tl_nthreads <= 0) { tl_nthreads = 1; @@ -1189,6 +1195,10 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) { if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + this_thr = __kmp_threads[global_tid]; serial_team = this_thr->th.th_serial_team; @@ -1429,7 +1439,7 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) { if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, OMPT_CUR_TEAM_DATA(this_thr), - OMPT_CUR_TASK_DATA(this_thr), 1, __kmp_tid_from_gtid(global_tid)); + OMPT_CUR_TASK_DATA(this_thr), 1, __kmp_tid_from_gtid(global_tid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? OMPT_CUR_TASK_INFO(this_thr) ->thread_num = __kmp_tid_from_gtid(global_tid); } @@ -1492,6 +1502,10 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (!TCR_4(__kmp_init_parallel)) __kmp_parallel_initialize(); +#if OMP_50_ENABLED + __kmp_resume_if_soft_paused(); +#endif + /* setup current data */ master_th = __kmp_threads[gtid]; // AC: potentially unsafe, not in sync with // shutdown @@ -1595,7 +1609,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th), - implicit_task_data, 1, __kmp_tid_from_gtid(gtid)); + implicit_task_data, 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? OMPT_CUR_TASK_INFO(master_th) ->thread_num = __kmp_tid_from_gtid(gtid); } @@ -1625,7 +1639,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_end, NULL, implicit_task_data, 1, - OMPT_CUR_TASK_INFO(master_th)->thread_num); + OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } __ompt_lw_taskteam_unlink(master_th); @@ -1807,7 +1821,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th), - &(task_info->task_data), 1, __kmp_tid_from_gtid(gtid)); + &(task_info->task_data), 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? OMPT_CUR_TASK_INFO(master_th) ->thread_num = __kmp_tid_from_gtid(gtid); } @@ -1837,7 +1851,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_end, NULL, &(task_info->task_data), 1, - OMPT_CUR_TASK_INFO(master_th)->thread_num); + OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } __ompt_lw_taskteam_unlink(master_th); @@ -1908,7 +1922,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th), - implicit_task_data, 1, __kmp_tid_from_gtid(gtid)); + implicit_task_data, 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? OMPT_CUR_TASK_INFO(master_th) ->thread_num = __kmp_tid_from_gtid(gtid); } @@ -1937,7 +1951,7 @@ int __kmp_fork_call(ident_t *loc, int gtid, if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_end, NULL, &(task_info->task_data), 1, - OMPT_CUR_TASK_INFO(master_th)->thread_num); + OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } ompt_parallel_data = *OMPT_CUR_TEAM_DATA(master_th); @@ -2351,7 +2365,6 @@ void __kmp_join_call(ident_t *loc, int gtid kmp_info_t *master_th; kmp_root_t *root; int master_active; - int i; KA_TRACE(20, ("__kmp_join_call: enter T#%d\n", gtid)); @@ -2474,21 +2487,24 @@ void __kmp_join_call(ident_t *loc, int gtid team->t.t_active_level--; KMP_ATOMIC_DEC(&root->r.r_in_parallel); - /* Restore number of threads in the team if needed */ + // Restore number of threads in the team if needed. This code relies on + // the proper adjustment of th_teams_size.nth after the fork in + // __kmp_teams_master on each teams master in the case that + // __kmp_reserve_threads reduced it. if (master_th->th.th_team_nproc < master_th->th.th_teams_size.nth) { int old_num = master_th->th.th_team_nproc; int new_num = master_th->th.th_teams_size.nth; kmp_info_t **other_threads = team->t.t_threads; team->t.t_nproc = new_num; - for (i = 0; i < old_num; ++i) { + for (int i = 0; i < old_num; ++i) { other_threads[i]->th.th_team_nproc = new_num; } // Adjust states of non-used threads of the team - for (i = old_num; i < new_num; ++i) { + for (int i = old_num; i < new_num; ++i) { // Re-initialize thread's barrier data. - int b; + KMP_DEBUG_ASSERT(other_threads[i]); kmp_balign_t *balign = other_threads[i]->th.th_bar; - for (b = 0; b < bs_last_barrier; ++b) { + for (int b = 0; b < bs_last_barrier; ++b) { balign[b].bb.b_arrived = team->t.t_bar[b].b_arrived; KMP_DEBUG_ASSERT(balign[b].bb.wait_flag != KMP_BARRIER_PARENT_FLAG); #if USE_DEBUGGER @@ -2541,7 +2557,7 @@ void __kmp_join_call(ident_t *loc, int gtid int ompt_team_size = team->t.t_nproc; ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_end, NULL, &(task_info->task_data), ompt_team_size, - OMPT_CUR_TASK_INFO(master_th)->thread_num); + OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } task_info->frame.exit_frame = ompt_data_none; @@ -3166,6 +3182,7 @@ static kmp_internal_control_t __kmp_get_global_icvs(void) { __kmp_dflt_team_nth, // int nproc; //internal control for # of threads for // next parallel region (per thread) // (use a max ub on value if __kmp_parallel_initialize not called yet) + __kmp_cg_max_nth, // int thread_limit; __kmp_dflt_max_active_levels, // int max_active_levels; //internal control // for max_active_levels r_sched, // kmp_r_sched_t sched; //internal control for runtime schedule @@ -3209,7 +3226,6 @@ static void __kmp_initialize_root(kmp_root_t *root) { root->r.r_in_parallel = 0; root->r.r_blocktime = __kmp_dflt_blocktime; root->r.r_nested = __kmp_dflt_nested; - root->r.r_cg_nthreads = 1; /* setup the root team for this task */ /* allocate the root team structure */ @@ -3850,6 +3866,16 @@ int __kmp_register_root(int initial_thread) { root_thread->th.th_prev_num_threads = 1; #endif + kmp_cg_root_t *tmp = (kmp_cg_root_t *)__kmp_allocate(sizeof(kmp_cg_root_t)); + tmp->cg_root = root_thread; + tmp->cg_thread_limit = __kmp_cg_max_nth; + tmp->cg_nthreads = 1; + KA_TRACE(100, ("__kmp_register_root: Thread %p created node %p with" + " cg_nthreads init to 1\n", + root_thread, tmp)); + tmp->up = NULL; + root_thread->th.th_cg_roots = tmp; + __kmp_root_counter++; #if OMPT_SUPPORT @@ -3966,7 +3992,11 @@ static int __kmp_reset_root(int gtid, kmp_root_t *root) { TCW_4(__kmp_nth, __kmp_nth - 1); // __kmp_reap_thread will decrement __kmp_all_nth. - root->r.r_cg_nthreads--; + root->r.r_uber_thread->th.th_cg_roots->cg_nthreads--; + KA_TRACE(100, ("__kmp_reset_root: Thread %p decrement cg_nthreads on node %p" + " to %d\n", + root->r.r_uber_thread, root->r.r_uber_thread->th.th_cg_roots, + root->r.r_uber_thread->th.th_cg_roots->cg_nthreads)); __kmp_reap_thread(root->r.r_uber_thread, 1); @@ -4141,6 +4171,22 @@ static void __kmp_initialize_info(kmp_info_t *this_thr, kmp_team_t *team, this_thr->th.th_pri_head = NULL; } + if (this_thr != master && // Master's CG root is initialized elsewhere + this_thr->th.th_cg_roots != master->th.th_cg_roots) { // CG root not set + // Make new thread's CG root same as master's + KMP_DEBUG_ASSERT(master->th.th_cg_roots); + this_thr->th.th_cg_roots = master->th.th_cg_roots; + // Increment new thread's CG root's counter to add the new thread + this_thr->th.th_cg_roots->cg_nthreads++; + KA_TRACE(100, ("__kmp_initialize_info: Thread %p increment cg_nthreads on" + " node %p of thread %p to %d\n", + this_thr, this_thr->th.th_cg_roots, + this_thr->th.th_cg_roots->cg_root, + this_thr->th.th_cg_roots->cg_nthreads)); + this_thr->th.th_current_task->td_icvs.thread_limit = + this_thr->th.th_cg_roots->cg_thread_limit; + } + /* Initialize dynamic dispatch */ { volatile kmp_disp_t *dispatch = this_thr->th.th_dispatch; @@ -4222,7 +4268,6 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team, /* first, try to get one from the thread pool */ if (__kmp_thread_pool) { - new_thr = CCAST(kmp_info_t *, __kmp_thread_pool); __kmp_thread_pool = (volatile kmp_info_t *)new_thr->th.th_next_pool; if (new_thr == __kmp_thread_pool_insert_pt) { @@ -4245,7 +4290,6 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team, KMP_DEBUG_ASSERT(new_thr->th.th_serial_team); TCW_4(__kmp_nth, __kmp_nth + 1); - root->r.r_cg_nthreads++; new_thr->th.th_task_state = 0; new_thr->th.th_task_state_top = 0; @@ -4401,8 +4445,6 @@ kmp_info_t *__kmp_allocate_thread(kmp_root_t *root, kmp_team_t *team, __kmp_all_nth++; __kmp_nth++; - root->r.r_cg_nthreads++; - // if __kmp_adjust_gtid_mode is set, then we use method #1 (sp search) for low // numbers of procs, and method #2 (keyed API call) for higher numbers. if (__kmp_adjust_gtid_mode) { @@ -4954,7 +4996,7 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc, #endif // Optimization to use a "hot" team if (use_hot_team && new_nproc > 1) { - KMP_DEBUG_ASSERT(new_nproc == max_nproc); + KMP_DEBUG_ASSERT(new_nproc <= max_nproc); #if KMP_NESTED_HOT_TEAMS team = hot_teams[level].hot_team; #else @@ -5060,10 +5102,11 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc, __kmp_reinitialize_team(team, new_icvs, root->r.r_uber_thread->th.th_ident); - /* update the remaining threads */ + // Update remaining threads for (f = 0; f < new_nproc; ++f) { team->t.t_threads[f]->th.th_team_nproc = new_nproc; } + // restore the current task state of the master thread: should be the // implicit task KF_TRACE(10, ("__kmp_allocate_team: T#%d, this_thread=%p team=%p\n", 0, @@ -5191,6 +5234,7 @@ __kmp_allocate_team(kmp_root_t *root, int new_nproc, int max_nproc, for (f = 0; f < team->t.t_nproc; ++f) __kmp_initialize_info(team->t.t_threads[f], team, f, __kmp_gtid_from_tid(f, team)); + if (level) { // set th_task_state for new threads in nested hot team // __kmp_initialize_info() no longer zeroes th_task_state, so we should // only need to set the th_task_state for the new threads. th_task_state @@ -5479,8 +5523,8 @@ void __kmp_free_team(kmp_root_t *root, for (tt_idx = 0; tt_idx < 2; ++tt_idx) { kmp_task_team_t *task_team = team->t.t_task_team[tt_idx]; if (task_team != NULL) { - for (f = 0; f < team->t.t_nproc; - ++f) { // Have all threads unref task teams + for (f = 0; f < team->t.t_nproc; ++f) { // threads unref task teams + KMP_DEBUG_ASSERT(team->t.t_threads[f]); team->t.t_threads[f]->th.th_task_team = NULL; } KA_TRACE( @@ -5511,6 +5555,29 @@ void __kmp_free_team(kmp_root_t *root, /* TODO limit size of team pool, call reap_team if pool too large */ team->t.t_next_pool = CCAST(kmp_team_t *, __kmp_team_pool); __kmp_team_pool = (volatile kmp_team_t *)team; + } else { // Check if team was created for the masters in a teams construct + // See if first worker is a CG root + KMP_DEBUG_ASSERT(team->t.t_threads[1] && + team->t.t_threads[1]->th.th_cg_roots); + if (team->t.t_threads[1]->th.th_cg_roots->cg_root == team->t.t_threads[1]) { + // Clean up the CG root nodes on workers so that this team can be re-used + for (f = 1; f < team->t.t_nproc; ++f) { + kmp_info_t *thr = team->t.t_threads[f]; + KMP_DEBUG_ASSERT(thr && thr->th.th_cg_roots && + thr->th.th_cg_roots->cg_root == thr); + // Pop current CG root off list + kmp_cg_root_t *tmp = thr->th.th_cg_roots; + thr->th.th_cg_roots = tmp->up; + KA_TRACE(100, ("__kmp_free_team: Thread %p popping node %p and moving" + " up to node %p. cg_nthreads was %d\n", + thr, tmp, thr->th.th_cg_roots, tmp->cg_nthreads)); + __kmp_free(tmp); + // Restore current task's thread_limit from CG root + if (thr->th.th_cg_roots) + thr->th.th_current_task->td_icvs.thread_limit = + thr->th.th_cg_roots->cg_thread_limit; + } + } } KMP_MB(); @@ -5566,7 +5633,6 @@ kmp_team_t *__kmp_reap_team(kmp_team_t *team) { void __kmp_free_thread(kmp_info_t *this_th) { int gtid; kmp_info_t **scan; - kmp_root_t *root = this_th->th.th_root; KA_TRACE(20, ("__kmp_free_thread: T#%d putting T#%d back on free pool.\n", __kmp_get_gtid(), this_th->th.th_info.ds.ds_gtid)); @@ -5591,6 +5657,26 @@ void __kmp_free_thread(kmp_info_t *this_th) { TCW_PTR(this_th->th.th_root, NULL); TCW_PTR(this_th->th.th_dispatch, NULL); /* NOT NEEDED */ + while (this_th->th.th_cg_roots) { + this_th->th.th_cg_roots->cg_nthreads--; + KA_TRACE(100, ("__kmp_free_thread: Thread %p decrement cg_nthreads on node" + " %p of thread %p to %d\n", + this_th, this_th->th.th_cg_roots, + this_th->th.th_cg_roots->cg_root, + this_th->th.th_cg_roots->cg_nthreads)); + kmp_cg_root_t *tmp = this_th->th.th_cg_roots; + if (tmp->cg_root == this_th) { // Thread is a cg_root + KMP_DEBUG_ASSERT(tmp->cg_nthreads == 0); + KA_TRACE( + 5, ("__kmp_free_thread: Thread %p freeing node %p\n", this_th, tmp)); + this_th->th.th_cg_roots = tmp->up; + __kmp_free(tmp); + } else { // Worker thread + this_th->th.th_cg_roots = NULL; + break; + } + } + /* If the implicit task assigned to this thread can be used by other threads * -> multiple threads can share the data and try to free the task at * __kmp_reap_thread at exit. This duplicate use of the task data can happen @@ -5634,7 +5720,6 @@ void __kmp_free_thread(kmp_info_t *this_th) { __kmp_thread_pool_nth++; TCW_4(__kmp_nth, __kmp_nth - 1); - root->r.r_cg_nthreads--; #ifdef KMP_ADJUST_BLOCKTIME /* Adjust blocktime back to user setting or default if necessary */ @@ -5851,7 +5936,6 @@ static void __kmp_reap_thread(kmp_info_t *thread, int is_root) { gtid = thread->th.th_info.ds.ds_gtid; if (!is_root) { - if (__kmp_dflt_blocktime != KMP_MAX_BLOCKTIME) { /* Assume the threads are at the fork barrier here */ KA_TRACE( @@ -6272,8 +6356,10 @@ void __kmp_internal_end_thread(int gtid_req) { // OM: Removed Linux* OS restriction to fix the crash on OS X* (DPD200239966) // and Windows(DPD200287443) that occurs when using critical sections from // foreign threads. - KA_TRACE(10, ("__kmp_internal_end_thread: exiting T#%d\n", gtid_req)); - return; + if (__kmp_pause_status != kmp_hard_paused) { + KA_TRACE(10, ("__kmp_internal_end_thread: exiting T#%d\n", gtid_req)); + return; + } #endif /* synchronize the termination process */ __kmp_acquire_bootstrap_lock(&__kmp_initz_lock); @@ -6409,6 +6495,7 @@ void __kmp_register_library_startup(void) { // library. Assume the other library is alive. // WARN( ... ); // TODO: Issue a warning. file_name = "unknown library"; + KMP_FALLTHROUGH(); // Attention! Falling to the next case. That's intentional. case 1: { // Neighbor is alive. // Check it is allowed. @@ -6920,6 +7007,10 @@ void __kmp_parallel_initialize(void) { __kmp_do_middle_initialize(); } +#if OMP_50_ENABLED + __kmp_resume_if_hard_paused(); +#endif + /* begin initialization */ KA_TRACE(10, ("__kmp_parallel_initialize: enter\n")); KMP_ASSERT(KMP_UBER_GTID(gtid)); @@ -7041,7 +7132,7 @@ int __kmp_invoke_task_func(int gtid) { ompt_team_size = team->t.t_nproc; ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( ompt_scope_begin, my_parallel_data, my_task_data, ompt_team_size, - __kmp_tid_from_gtid(gtid)); + __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial? OMPT_CUR_TASK_INFO(this_thr)->thread_num = __kmp_tid_from_gtid(gtid); } #endif @@ -7085,6 +7176,19 @@ void __kmp_teams_master(int gtid) { KMP_DEBUG_ASSERT(thr->th.th_set_nproc); KA_TRACE(20, ("__kmp_teams_master: T#%d, Tid %d, microtask %p\n", gtid, __kmp_tid_from_gtid(gtid), thr->th.th_teams_microtask)); + + // This thread is a new CG root. Set up the proper variables. + kmp_cg_root_t *tmp = (kmp_cg_root_t *)__kmp_allocate(sizeof(kmp_cg_root_t)); + tmp->cg_root = thr; // Make thr the CG root + // Init to thread limit that was stored when league masters were forked + tmp->cg_thread_limit = thr->th.th_current_task->td_icvs.thread_limit; + tmp->cg_nthreads = 1; // Init counter to one active thread, this one + KA_TRACE(100, ("__kmp_teams_master: Thread %p created node %p and init" + " cg_threads to 1\n", + thr, tmp)); + tmp->up = thr->th.th_cg_roots; + thr->th.th_cg_roots = tmp; + // Launch league of teams now, but not let workers execute // (they hang on fork barrier until next parallel) #if INCLUDE_SSC_MARKS @@ -7096,7 +7200,9 @@ void __kmp_teams_master(int gtid) { #if INCLUDE_SSC_MARKS SSC_MARK_JOINING(); #endif - + // If the team size was reduced from the limit, set it to the new size + if (thr->th.th_team_nproc < thr->th.th_teams_size.nth) + thr->th.th_teams_size.nth = thr->th.th_team_nproc; // AC: last parameter "1" eliminates join barrier which won't work because // worker threads are in a fork barrier waiting for more parallel regions __kmp_join_call(loc, gtid @@ -7170,10 +7276,14 @@ void __kmp_push_num_teams(ident_t *id, int gtid, int num_teams, num_threads = __kmp_teams_max_nth / num_teams; } } else { + // This thread will be the master of the league masters + // Store new thread limit; old limit is saved in th_cg_roots list + thr->th.th_current_task->td_icvs.thread_limit = num_threads; + if (num_teams * num_threads > __kmp_teams_max_nth) { int new_threads = __kmp_teams_max_nth / num_teams; if (!__kmp_reserve_warn) { // user asked for too many threads - __kmp_reserve_warn = 1; // that conflicts with KMP_TEAMS_THREAD_LIMIT + __kmp_reserve_warn = 1; // conflicts with KMP_TEAMS_THREAD_LIMIT __kmp_msg(kmp_ms_warning, KMP_MSG(CantFormThrTeam, num_threads, new_threads), KMP_HNT(Unset_ALL_THREADS), __kmp_msg_null); @@ -7291,7 +7401,7 @@ void __kmp_internal_join(ident_t *id, int gtid, kmp_team_t *team) { #endif if (!KMP_MASTER_TID(ds_tid) && ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( - ompt_scope_end, NULL, task_data, 0, ds_tid); + ompt_scope_end, NULL, task_data, 0, ds_tid, ompt_task_implicit); // TODO: Can this be ompt_task_initial? } } #endif @@ -8190,3 +8300,82 @@ __kmp_determine_reduction_method( kmp_int32 __kmp_get_reduce_method(void) { return ((__kmp_entry_thread()->th.th_local.packed_reduction_method) >> 8); } + +#if OMP_50_ENABLED + +// Soft pause sets up threads to ignore blocktime and just go to sleep. +// Spin-wait code checks __kmp_pause_status and reacts accordingly. +void __kmp_soft_pause() { __kmp_pause_status = kmp_soft_paused; } + +// Hard pause shuts down the runtime completely. Resume happens naturally when +// OpenMP is used subsequently. +void __kmp_hard_pause() { + __kmp_pause_status = kmp_hard_paused; + __kmp_internal_end_thread(-1); +} + +// Soft resume sets __kmp_pause_status, and wakes up all threads. +void __kmp_resume_if_soft_paused() { + if (__kmp_pause_status == kmp_soft_paused) { + __kmp_pause_status = kmp_not_paused; + + for (int gtid = 1; gtid < __kmp_threads_capacity; ++gtid) { + kmp_info_t *thread = __kmp_threads[gtid]; + if (thread) { // Wake it if sleeping + kmp_flag_64 fl(&thread->th.th_bar[bs_forkjoin_barrier].bb.b_go, thread); + if (fl.is_sleeping()) + fl.resume(gtid); + else if (__kmp_try_suspend_mx(thread)) { // got suspend lock + __kmp_unlock_suspend_mx(thread); // unlock it; it won't sleep + } else { // thread holds the lock and may sleep soon + do { // until either the thread sleeps, or we can get the lock + if (fl.is_sleeping()) { + fl.resume(gtid); + break; + } else if (__kmp_try_suspend_mx(thread)) { + __kmp_unlock_suspend_mx(thread); + break; + } + } while (1); + } + } + } + } +} + +// This function is called via __kmpc_pause_resource. Returns 0 if successful. +// TODO: add warning messages +int __kmp_pause_resource(kmp_pause_status_t level) { + if (level == kmp_not_paused) { // requesting resume + if (__kmp_pause_status == kmp_not_paused) { + // error message about runtime not being paused, so can't resume + return 1; + } else { + KMP_DEBUG_ASSERT(__kmp_pause_status == kmp_soft_paused || + __kmp_pause_status == kmp_hard_paused); + __kmp_pause_status = kmp_not_paused; + return 0; + } + } else if (level == kmp_soft_paused) { // requesting soft pause + if (__kmp_pause_status != kmp_not_paused) { + // error message about already being paused + return 1; + } else { + __kmp_soft_pause(); + return 0; + } + } else if (level == kmp_hard_paused) { // requesting hard pause + if (__kmp_pause_status != kmp_not_paused) { + // error message about already being paused + return 1; + } else { + __kmp_hard_pause(); + return 0; + } + } else { + // error message about invalid level + return 1; + } +} + +#endif // OMP_50_ENABLED diff --git a/runtime/src/kmp_safe_c_api.h b/runtime/src/kmp_safe_c_api.h index d894fe3..f839f73 100644 --- a/runtime/src/kmp_safe_c_api.h +++ b/runtime/src/kmp_safe_c_api.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_sched.cpp b/runtime/src/kmp_sched.cpp index fc8000e..b8b0433 100644 --- a/runtime/src/kmp_sched.cpp +++ b/runtime/src/kmp_sched.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_settings.cpp b/runtime/src/kmp_settings.cpp index 6d049e4..b2e300f 100644 --- a/runtime/src/kmp_settings.cpp +++ b/runtime/src/kmp_settings.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_settings.h b/runtime/src/kmp_settings.h index 338a443..b774dec 100644 --- a/runtime/src/kmp_settings.h +++ b/runtime/src/kmp_settings.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stats.cpp b/runtime/src/kmp_stats.cpp index 2c0eabe..8413036 100644 --- a/runtime/src/kmp_stats.cpp +++ b/runtime/src/kmp_stats.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stats.h b/runtime/src/kmp_stats.h index be94843..c090156 100644 --- a/runtime/src/kmp_stats.h +++ b/runtime/src/kmp_stats.h @@ -7,10 +7,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stats_timing.cpp b/runtime/src/kmp_stats_timing.cpp index 2fcbaab..bdfe68c 100644 --- a/runtime/src/kmp_stats_timing.cpp +++ b/runtime/src/kmp_stats_timing.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stats_timing.h b/runtime/src/kmp_stats_timing.h index 84252ec..f3428b3 100644 --- a/runtime/src/kmp_stats_timing.h +++ b/runtime/src/kmp_stats_timing.h @@ -7,10 +7,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_str.cpp b/runtime/src/kmp_str.cpp index 5338edf..fb748d1 100644 --- a/runtime/src/kmp_str.cpp +++ b/runtime/src/kmp_str.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_str.h b/runtime/src/kmp_str.h index c30255d..09faadb 100644 --- a/runtime/src/kmp_str.h +++ b/runtime/src/kmp_str.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stub.cpp b/runtime/src/kmp_stub.cpp index c1f3bf3..5933553 100644 --- a/runtime/src/kmp_stub.cpp +++ b/runtime/src/kmp_stub.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_stub.h b/runtime/src/kmp_stub.h index 487729f..9407872 100644 --- a/runtime/src/kmp_stub.h +++ b/runtime/src/kmp_stub.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_taskdeps.cpp b/runtime/src/kmp_taskdeps.cpp index 6c810dd..5f2a4c8 100644 --- a/runtime/src/kmp_taskdeps.cpp +++ b/runtime/src/kmp_taskdeps.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -485,43 +484,43 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, #if OMPT_OPTIONAL /* OMPT grab all dependences if requested by the tool */ if (ndeps + ndeps_noalias > 0 && - ompt_enabled.ompt_callback_task_dependences) { + ompt_enabled.ompt_callback_dependences) { kmp_int32 i; new_taskdata->ompt_task_info.ndeps = ndeps + ndeps_noalias; new_taskdata->ompt_task_info.deps = - (ompt_task_dependence_t *)KMP_OMPT_DEPS_ALLOC( - thread, (ndeps + ndeps_noalias) * sizeof(ompt_task_dependence_t)); + (ompt_dependence_t *)KMP_OMPT_DEPS_ALLOC( + thread, (ndeps + ndeps_noalias) * sizeof(ompt_dependence_t)); KMP_ASSERT(new_taskdata->ompt_task_info.deps != NULL); for (i = 0; i < ndeps; i++) { - new_taskdata->ompt_task_info.deps[i].variable_addr = + new_taskdata->ompt_task_info.deps[i].variable.ptr = (void *)dep_list[i].base_addr; if (dep_list[i].flags.in && dep_list[i].flags.out) new_taskdata->ompt_task_info.deps[i].dependence_type = - ompt_task_dependence_type_inout; + ompt_dependence_type_inout; else if (dep_list[i].flags.out) new_taskdata->ompt_task_info.deps[i].dependence_type = - ompt_task_dependence_type_out; + ompt_dependence_type_out; else if (dep_list[i].flags.in) new_taskdata->ompt_task_info.deps[i].dependence_type = - ompt_task_dependence_type_in; + ompt_dependence_type_in; } for (i = 0; i < ndeps_noalias; i++) { - new_taskdata->ompt_task_info.deps[ndeps + i].variable_addr = + new_taskdata->ompt_task_info.deps[ndeps + i].variable.ptr = (void *)noalias_dep_list[i].base_addr; if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out) new_taskdata->ompt_task_info.deps[ndeps + i].dependence_type = - ompt_task_dependence_type_inout; + ompt_dependence_type_inout; else if (noalias_dep_list[i].flags.out) new_taskdata->ompt_task_info.deps[ndeps + i].dependence_type = - ompt_task_dependence_type_out; + ompt_dependence_type_out; else if (noalias_dep_list[i].flags.in) new_taskdata->ompt_task_info.deps[ndeps + i].dependence_type = - ompt_task_dependence_type_in; + ompt_dependence_type_in; } - ompt_callbacks.ompt_callback(ompt_callback_task_dependences)( + ompt_callbacks.ompt_callback(ompt_callback_dependences)( &(new_taskdata->ompt_task_info.task_data), new_taskdata->ompt_task_info.deps, new_taskdata->ompt_task_info.ndeps); /* We can now free the allocated memory for the dependencies */ diff --git a/runtime/src/kmp_taskdeps.h b/runtime/src/kmp_taskdeps.h index 8496884..b5d850a 100644 --- a/runtime/src/kmp_taskdeps.h +++ b/runtime/src/kmp_taskdeps.h @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_tasking.cpp b/runtime/src/kmp_tasking.cpp index 9c61a12..9e8b22a 100644 --- a/runtime/src/kmp_tasking.cpp +++ b/runtime/src/kmp_tasking.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -2839,7 +2838,7 @@ static void __kmp_enable_tasking(kmp_task_team_t *task_team, threads_data = (kmp_thread_data_t *)TCR_PTR(task_team->tt.tt_threads_data); KMP_DEBUG_ASSERT(threads_data != NULL); - if ((__kmp_tasking_mode == tskm_task_teams) && + if (__kmp_tasking_mode == tskm_task_teams && (__kmp_dflt_blocktime != KMP_MAX_BLOCKTIME)) { // Release any threads sleeping at the barrier, so that they can steal // tasks and execute them. In extra barrier mode, tasks do not sleep @@ -4132,7 +4131,7 @@ void __kmp_taskloop_recur(ident_t *loc, int gtid, kmp_task_t *task, @param lb Pointer to loop lower bound in task structure @param ub Pointer to loop upper bound in task structure @param st Loop stride -@param nogroup Flag, 1 if nogroup clause specified, 0 otherwise +@param nogroup Flag, 1 if no taskgroup needs to be added, 0 otherwise @param sched Schedule specified 0/1/2 for none/grainsize/num_tasks @param grainsize Schedule value if specified @param task_dup Tasks duplication routine @@ -4206,6 +4205,7 @@ void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val, case 0: // no schedule clause specified, we can choose the default // let's try to schedule (team_size*10) tasks grainsize = thread->th.th_team_nproc * 10; + KMP_FALLTHROUGH(); case 2: // num_tasks provided if (grainsize > tc) { num_tasks = tc; // too big num_tasks requested, adjust values diff --git a/runtime/src/kmp_taskq.cpp b/runtime/src/kmp_taskq.cpp index 6e8f2d5..2b01174 100644 --- a/runtime/src/kmp_taskq.cpp +++ b/runtime/src/kmp_taskq.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_threadprivate.cpp b/runtime/src/kmp_threadprivate.cpp index d1ca422..87bfff3 100644 --- a/runtime/src/kmp_threadprivate.cpp +++ b/runtime/src/kmp_threadprivate.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_utility.cpp b/runtime/src/kmp_utility.cpp index dc4c714..44a99d0 100644 --- a/runtime/src/kmp_utility.cpp +++ b/runtime/src/kmp_utility.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_version.cpp b/runtime/src/kmp_version.cpp index e138e86..7e035ce 100644 --- a/runtime/src/kmp_version.cpp +++ b/runtime/src/kmp_version.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_version.h b/runtime/src/kmp_version.h index 18a2487..9e726b3 100644 --- a/runtime/src/kmp_version.h +++ b/runtime/src/kmp_version.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_wait_release.cpp b/runtime/src/kmp_wait_release.cpp index 3ebec6b..7d12c74 100644 --- a/runtime/src/kmp_wait_release.cpp +++ b/runtime/src/kmp_wait_release.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_wait_release.h b/runtime/src/kmp_wait_release.h index e2984a8..bea59b3 100644 --- a/runtime/src/kmp_wait_release.h +++ b/runtime/src/kmp_wait_release.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -119,10 +118,10 @@ public: }; #if OMPT_SUPPORT -static inline void __ompt_implicit_task_end(kmp_info_t *this_thr, - ompt_state_t ompt_state, - ompt_data_t *tId, - ompt_data_t *pId) { +OMPT_NOINLINE +static void __ompt_implicit_task_end(kmp_info_t *this_thr, + ompt_state_t ompt_state, + ompt_data_t *tId) { int ds_tid = this_thr->th.th_info.ds.ds_tid; if (ompt_state == ompt_state_wait_barrier_implicit) { this_thr->th.ompt_thread_info.state = ompt_state_overhead; @@ -140,7 +139,7 @@ static inline void __ompt_implicit_task_end(kmp_info_t *this_thr, if (!KMP_MASTER_TID(ds_tid)) { if (ompt_enabled.ompt_callback_implicit_task) { ompt_callbacks.ompt_callback(ompt_callback_implicit_task)( - ompt_scope_end, NULL, tId, 0, ds_tid); + ompt_scope_end, NULL, tId, 0, ds_tid, ompt_task_implicit); } // return to idle state this_thr->th.ompt_thread_info.state = ompt_state_idle; @@ -242,7 +241,6 @@ final_spin=FALSE) */ #if OMPT_SUPPORT ompt_state_t ompt_entry_state; - ompt_data_t *pId = NULL; ompt_data_t *tId; if (ompt_enabled.enabled) { ompt_entry_state = this_thr->th.ompt_thread_info.state; @@ -251,20 +249,17 @@ final_spin=FALSE) ompt_lw_taskteam_t *team = this_thr->th.th_team->t.ompt_serialized_team_info; if (team) { - pId = &(team->ompt_team_info.parallel_data); tId = &(team->ompt_task_info.task_data); } else { - pId = OMPT_CUR_TEAM_DATA(this_thr); tId = OMPT_CUR_TASK_DATA(this_thr); } } else { - pId = NULL; tId = &(this_thr->th.ompt_thread_info.task_data); } - if (final_spin && (__kmp_tasking_mode == tskm_immediate_exec || - this_thr->th.th_task_team == NULL)) { + if (final_spin && (__kmp_tasking_mode == tskm_immediate_exec || + this_thr->th.th_task_team == NULL)) { // implicit task is done. Either no taskqueue, or task-team finished - __ompt_implicit_task_end(this_thr, ompt_entry_state, tId, pId); + __ompt_implicit_task_end(this_thr, ompt_entry_state, tId); } } #endif @@ -272,12 +267,20 @@ final_spin=FALSE) // Setup for waiting KMP_INIT_YIELD(spins); - if (__kmp_dflt_blocktime != KMP_MAX_BLOCKTIME) { + if (__kmp_dflt_blocktime != KMP_MAX_BLOCKTIME +#if OMP_50_ENABLED + || __kmp_pause_status == kmp_soft_paused +#endif + ) { #if KMP_USE_MONITOR // The worker threads cannot rely on the team struct existing at this point. // Use the bt values cached in the thread struct instead. #ifdef KMP_ADJUST_BLOCKTIME - if (__kmp_zero_bt && !this_thr->th.th_team_bt_set) + if ( +#if OMP_50_ENABLED + __kmp_pause_status == kmp_soft_paused || +#endif + (__kmp_zero_bt && !this_thr->th.th_team_bt_set)) // Force immediate suspend if not set by user and more threads than // available procs hibernate = 0; @@ -300,7 +303,13 @@ final_spin=FALSE) th_gtid, __kmp_global.g.g_time.dt.t_value, hibernate, hibernate - __kmp_global.g.g_time.dt.t_value)); #else - hibernate_goal = KMP_NOW() + this_thr->th.th_team_bt_intervals; +#if OMP_50_ENABLED + if (__kmp_pause_status == kmp_soft_paused) { + // Force immediate suspend + hibernate_goal = KMP_NOW(); + } else +#endif + hibernate_goal = KMP_NOW() + this_thr->th.th_team_bt_intervals; poll_count = 0; #endif // KMP_USE_MONITOR } @@ -334,7 +343,7 @@ final_spin=FALSE) #if OMPT_SUPPORT // task-team is done now, other cases should be catched above if (final_spin && ompt_enabled.enabled) - __ompt_implicit_task_end(this_thr, ompt_entry_state, tId, pId); + __ompt_implicit_task_end(this_thr, ompt_entry_state, tId); #endif this_thr->th.th_task_team = NULL; this_thr->th.th_reap_state = KMP_SAFE_TO_REAP; @@ -393,7 +402,11 @@ final_spin=FALSE) #endif // Don't suspend if KMP_BLOCKTIME is set to "infinite" - if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME) + if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME +#if OMP_50_ENABLED + && __kmp_pause_status != kmp_soft_paused +#endif + ) continue; // Don't suspend if there is a likelihood of new tasks being spawned. @@ -409,7 +422,14 @@ final_spin=FALSE) continue; #endif +#if OMP_50_ENABLED + if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME && + __kmp_pause_status != kmp_soft_paused) + continue; +#endif + KF_TRACE(50, ("__kmp_wait_sleep: T#%d suspend time reached\n", th_gtid)); + #if KMP_OS_UNIX if (final_spin) KMP_ATOMIC_ST_REL(&this_thr->th.th_blocking, false); @@ -436,7 +456,7 @@ final_spin=FALSE) if (ompt_enabled.enabled && ompt_exit_state != ompt_state_undefined) { #if OMPT_OPTIONAL if (final_spin) { - __ompt_implicit_task_end(this_thr, ompt_exit_state, tId, pId); + __ompt_implicit_task_end(this_thr, ompt_exit_state, tId); ompt_exit_state = this_thr->th.ompt_thread_info.state; } #endif diff --git a/runtime/src/kmp_wrapper_getpid.h b/runtime/src/kmp_wrapper_getpid.h index 47e2728..774e1a1 100644 --- a/runtime/src/kmp_wrapper_getpid.h +++ b/runtime/src/kmp_wrapper_getpid.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/kmp_wrapper_malloc.h b/runtime/src/kmp_wrapper_malloc.h index c8d2c70..a50387c 100644 --- a/runtime/src/kmp_wrapper_malloc.h +++ b/runtime/src/kmp_wrapper_malloc.h @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/libomp.rc.var b/runtime/src/libomp.rc.var index 32449e2..958cd04 100644 --- a/runtime/src/libomp.rc.var +++ b/runtime/src/libomp.rc.var @@ -3,10 +3,9 @@ // ////===----------------------------------------------------------------------===// //// -//// The LLVM Compiler Infrastructure -//// -//// This file is dual licensed under the MIT and the University of Illinois Open -//// Source Licenses. See LICENSE.txt for details. +//// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +//// See https://llvm.org/LICENSE.txt for license information. +//// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception //// ////===----------------------------------------------------------------------===// // diff --git a/runtime/src/ompt-event-specific.h b/runtime/src/ompt-event-specific.h index 1fb0844..7087152 100644 --- a/runtime/src/ompt-event-specific.h +++ b/runtime/src/ompt-event-specific.h @@ -9,10 +9,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -78,11 +77,11 @@ #define ompt_callback_mutex_released_implemented ompt_event_MAY_ALWAYS_OPTIONAL #if OMP_40_ENABLED -#define ompt_callback_task_dependences_implemented \ +#define ompt_callback_dependences_implemented \ ompt_event_MAY_ALWAYS_OPTIONAL #define ompt_callback_task_dependence_implemented ompt_event_MAY_ALWAYS_OPTIONAL #else -#define ompt_callback_task_dependences_implemented ompt_event_UNIMPLEMENTED +#define ompt_callback_dependences_implemented ompt_event_UNIMPLEMENTED #define ompt_callback_task_dependence_implemented ompt_event_UNIMPLEMENTED #endif /* OMP_40_ENABLED */ diff --git a/runtime/src/ompt-general.cpp b/runtime/src/ompt-general.cpp index 705b452..11a195e 100644 --- a/runtime/src/ompt-general.cpp +++ b/runtime/src/ompt-general.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -327,6 +326,8 @@ void ompt_pre_init() { #endif } +extern "C" int omp_get_initial_device(void); + void ompt_post_init() { //-------------------------------------------------- // Execute the post-initialization logic only once. @@ -343,7 +344,7 @@ void ompt_post_init() { //-------------------------------------------------- if (ompt_start_tool_result) { ompt_enabled.enabled = !!ompt_start_tool_result->initialize( - ompt_fn_lookup, &(ompt_start_tool_result->tool_data)); + ompt_fn_lookup, omp_get_initial_device(), &(ompt_start_tool_result->tool_data)); if (!ompt_enabled.enabled) { // tool not enabled, zero out the bitmap, and done @@ -422,7 +423,7 @@ OMPT_API_ROUTINE int ompt_enumerate_mutex_impls(int current_impl, * callbacks ****************************************************************************/ -OMPT_API_ROUTINE int ompt_set_callback(ompt_callbacks_t which, +OMPT_API_ROUTINE ompt_set_result_t ompt_set_callback(ompt_callbacks_t which, ompt_callback_t callback) { switch (which) { @@ -448,6 +449,9 @@ OMPT_API_ROUTINE int ompt_set_callback(ompt_callbacks_t which, OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which, ompt_callback_t *callback) { + if (!ompt_enabled.enabled) + return ompt_get_callback_failure; + switch (which) { #define ompt_event_macro(event_name, callback_type, event_id) \ @@ -455,7 +459,7 @@ OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which, if (ompt_event_implementation_status(event_name)) { \ ompt_callback_t mycb = \ (ompt_callback_t)ompt_callbacks.ompt_callback(event_name); \ - if (mycb) { \ + if (ompt_enabled.event_name && mycb) { \ *callback = mycb; \ return ompt_get_callback_success; \ } \ @@ -478,12 +482,16 @@ OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which, OMPT_API_ROUTINE int ompt_get_parallel_info(int ancestor_level, ompt_data_t **parallel_data, int *team_size) { + if (!ompt_enabled.enabled) + return 0; return __ompt_get_parallel_info_internal(ancestor_level, parallel_data, team_size); } -OMPT_API_ROUTINE ompt_state_t ompt_get_state(ompt_wait_id_t *wait_id) { - ompt_state_t thread_state = __ompt_get_state_internal(wait_id); +OMPT_API_ROUTINE int ompt_get_state(ompt_wait_id_t *wait_id) { + if (!ompt_enabled.enabled) + return ompt_state_work_serial; + int thread_state = __ompt_get_state_internal(wait_id); if (thread_state == ompt_state_undefined) { thread_state = ompt_state_work_serial; @@ -497,6 +505,8 @@ OMPT_API_ROUTINE ompt_state_t ompt_get_state(ompt_wait_id_t *wait_id) { ****************************************************************************/ OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(void) { + if (!ompt_enabled.enabled) + return NULL; return __ompt_get_thread_data_internal(); } @@ -505,6 +515,8 @@ OMPT_API_ROUTINE int ompt_get_task_info(int ancestor_level, int *type, ompt_frame_t **task_frame, ompt_data_t **parallel_data, int *thread_num) { + if (!ompt_enabled.enabled) + return 0; return __ompt_get_task_info_internal(ancestor_level, type, task_data, task_frame, parallel_data, thread_num); } @@ -579,7 +591,7 @@ OMPT_API_ROUTINE int ompt_get_place_num(void) { #if !KMP_AFFINITY_SUPPORTED return -1; #else - if (__kmp_get_gtid() < 0) + if (!ompt_enabled.enabled || __kmp_get_gtid() < 0) return -1; int gtid; @@ -600,7 +612,7 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size, #if !KMP_AFFINITY_SUPPORTED return 0; #else - if (__kmp_get_gtid() < 0) + if (!ompt_enabled.enabled || __kmp_get_gtid() < 0) return 0; int i, gtid, place_num, first_place, last_place, start, end; @@ -635,7 +647,7 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size, ****************************************************************************/ OMPT_API_ROUTINE int ompt_get_proc_id(void) { - if (__kmp_get_gtid() < 0) + if (!ompt_enabled.enabled || __kmp_get_gtid() < 0) return -1; #if KMP_OS_LINUX return sched_getcpu(); diff --git a/runtime/src/ompt-internal.h b/runtime/src/ompt-internal.h index c6823fc..1636f43 100644 --- a/runtime/src/ompt-internal.h +++ b/runtime/src/ompt-internal.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,7 +14,7 @@ #define __OMPT_INTERNAL_H__ #include "ompt-event-specific.h" -#include "ompt.h" +#include "omp-tools.h" #define OMPT_VERSION 1 @@ -60,7 +59,7 @@ typedef struct { int thread_num; #if OMP_40_ENABLED int ndeps; - ompt_task_dependence_t *deps; + ompt_dependence_t *deps; #endif /* OMP_40_ENABLED */ } ompt_task_info_t; diff --git a/runtime/src/ompt-specific.cpp b/runtime/src/ompt-specific.cpp index cc4f1de..acd2389 100644 --- a/runtime/src/ompt-specific.cpp +++ b/runtime/src/ompt-specific.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -214,7 +213,7 @@ void __ompt_thread_assign_wait_id(void *variable) { ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)variable; } -ompt_state_t __ompt_get_state_internal(ompt_wait_id_t *omp_wait_id) { +int __ompt_get_state_internal(ompt_wait_id_t *omp_wait_id) { kmp_info_t *ti = ompt_get_thread(); if (ti) { diff --git a/runtime/src/ompt-specific.h b/runtime/src/ompt-specific.h index 317580f..25901df 100644 --- a/runtime/src/ompt-specific.h +++ b/runtime/src/ompt-specific.h @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/test-touch.c b/runtime/src/test-touch.c index 6ce529a..71e05e7 100644 --- a/runtime/src/test-touch.c +++ b/runtime/src/test-touch.c @@ -3,10 +3,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/disable_warnings.h b/runtime/src/thirdparty/ittnotify/disable_warnings.h index 301901c..6b06035 100644 --- a/runtime/src/thirdparty/ittnotify/disable_warnings.h +++ b/runtime/src/thirdparty/ittnotify/disable_warnings.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/ittnotify.h b/runtime/src/thirdparty/ittnotify/ittnotify.h index 3581dfa..ed46cd7 100644 --- a/runtime/src/thirdparty/ittnotify/ittnotify.h +++ b/runtime/src/thirdparty/ittnotify/ittnotify.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/ittnotify_config.h b/runtime/src/thirdparty/ittnotify/ittnotify_config.h index 59065f6..cc494cb 100644 --- a/runtime/src/thirdparty/ittnotify/ittnotify_config.h +++ b/runtime/src/thirdparty/ittnotify/ittnotify_config.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/ittnotify_static.c b/runtime/src/thirdparty/ittnotify/ittnotify_static.c index 63e1b0c..a2a73ad 100644 --- a/runtime/src/thirdparty/ittnotify/ittnotify_static.c +++ b/runtime/src/thirdparty/ittnotify/ittnotify_static.c @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/ittnotify_static.h b/runtime/src/thirdparty/ittnotify/ittnotify_static.h index 5ef300f..a202226 100644 --- a/runtime/src/thirdparty/ittnotify/ittnotify_static.h +++ b/runtime/src/thirdparty/ittnotify/ittnotify_static.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/ittnotify_types.h b/runtime/src/thirdparty/ittnotify/ittnotify_types.h index babc50e..8818161 100644 --- a/runtime/src/thirdparty/ittnotify/ittnotify_types.h +++ b/runtime/src/thirdparty/ittnotify/ittnotify_types.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h b/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h index 66e50a8..eae33e0 100644 --- a/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h +++ b/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h @@ -1,10 +1,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/tsan_annotations.cpp b/runtime/src/tsan_annotations.cpp index 2629788..5be17f8 100644 --- a/runtime/src/tsan_annotations.cpp +++ b/runtime/src/tsan_annotations.cpp @@ -5,10 +5,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/tsan_annotations.h b/runtime/src/tsan_annotations.h index 9abbfaf..2b1debb 100644 --- a/runtime/src/tsan_annotations.h +++ b/runtime/src/tsan_annotations.h @@ -6,10 +6,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/z_Linux_asm.S b/runtime/src/z_Linux_asm.S index c9fbc23..b2f9d6e 100644 --- a/runtime/src/z_Linux_asm.S +++ b/runtime/src/z_Linux_asm.S @@ -4,10 +4,9 @@ // ////===----------------------------------------------------------------------===// //// -//// The LLVM Compiler Infrastructure -//// -//// This file is dual licensed under the MIT and the University of Illinois Open -//// Source Licenses. See LICENSE.txt for details. +//// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +//// See https://llvm.org/LICENSE.txt for license information. +//// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception //// ////===----------------------------------------------------------------------===// // diff --git a/runtime/src/z_Linux_util.cpp b/runtime/src/z_Linux_util.cpp index ab9c353..c5362e0 100644 --- a/runtime/src/z_Linux_util.cpp +++ b/runtime/src/z_Linux_util.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -1421,6 +1420,21 @@ void __kmp_suspend_uninitialize_thread(kmp_info_t *th) { } } +// return true if lock obtained, false otherwise +int __kmp_try_suspend_mx(kmp_info_t *th) { + return (pthread_mutex_trylock(&th->th.th_suspend_mx.m_mutex) == 0); +} + +void __kmp_lock_suspend_mx(kmp_info_t *th) { + int status = pthread_mutex_lock(&th->th.th_suspend_mx.m_mutex); + KMP_CHECK_SYSFAIL("pthread_mutex_lock", status); +} + +void __kmp_unlock_suspend_mx(kmp_info_t *th) { + int status = pthread_mutex_unlock(&th->th.th_suspend_mx.m_mutex); + KMP_CHECK_SYSFAIL("pthread_mutex_unlock", status); +} + /* This routine puts the calling thread to sleep after setting the sleep bit for the indicated flag variable to true. */ template <class C> @@ -1444,7 +1458,15 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) { /* TODO: shouldn't this use release semantics to ensure that __kmp_suspend_initialize_thread gets called first? */ old_spin = flag->set_sleeping(); - +#if OMP_50_ENABLED + if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME && + __kmp_pause_status != kmp_soft_paused) { + flag->unset_sleeping(); + status = pthread_mutex_unlock(&th->th.th_suspend_mx.m_mutex); + KMP_CHECK_SYSFAIL("pthread_mutex_unlock", status); + return; + } +#endif KF_TRACE(5, ("__kmp_suspend_template: T#%d set sleep bit for spin(%p)==%x," " was %x\n", th_gtid, flag->get(), flag->load(), old_spin)); diff --git a/runtime/src/z_Windows_NT-586_asm.asm b/runtime/src/z_Windows_NT-586_asm.asm index eace718..7d0e32e 100644 --- a/runtime/src/z_Windows_NT-586_asm.asm +++ b/runtime/src/z_Windows_NT-586_asm.asm @@ -4,10 +4,9 @@ ; ;//===----------------------------------------------------------------------===// ;// -;// The LLVM Compiler Infrastructure -;// -;// This file is dual licensed under the MIT and the University of Illinois Open -;// Source Licenses. See LICENSE.txt for details. +;// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +;// See https://llvm.org/LICENSE.txt for license information. +;// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ;// ;//===----------------------------------------------------------------------===// ; diff --git a/runtime/src/z_Windows_NT-586_util.cpp b/runtime/src/z_Windows_NT-586_util.cpp index 9191c02..b3728a5 100644 --- a/runtime/src/z_Windows_NT-586_util.cpp +++ b/runtime/src/z_Windows_NT-586_util.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/runtime/src/z_Windows_NT_util.cpp b/runtime/src/z_Windows_NT_util.cpp index f3d667f..038ac86 100644 --- a/runtime/src/z_Windows_NT_util.cpp +++ b/runtime/src/z_Windows_NT_util.cpp @@ -4,10 +4,9 @@ //===----------------------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -159,6 +158,10 @@ void __kmp_win32_mutex_lock(kmp_win32_mutex_t *mx) { EnterCriticalSection(&mx->cs); } +int __kmp_win32_mutex_trylock(kmp_win32_mutex_t *mx) { + return TryEnterCriticalSection(&mx->cs); +} + void __kmp_win32_mutex_unlock(kmp_win32_mutex_t *mx) { LeaveCriticalSection(&mx->cs); } @@ -300,6 +303,18 @@ void __kmp_suspend_uninitialize_thread(kmp_info_t *th) { } } +int __kmp_try_suspend_mx(kmp_info_t *th) { + return __kmp_win32_mutex_trylock(&th->th.th_suspend_mx); +} + +void __kmp_lock_suspend_mx(kmp_info_t *th) { + __kmp_win32_mutex_lock(&th->th.th_suspend_mx); +} + +void __kmp_unlock_suspend_mx(kmp_info_t *th) { + __kmp_win32_mutex_unlock(&th->th.th_suspend_mx); +} + /* This routine puts the calling thread to sleep after setting the sleep bit for the indicated flag variable to true. */ template <class C> @@ -321,6 +336,14 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) { /* TODO: shouldn't this use release semantics to ensure that __kmp_suspend_initialize_thread gets called first? */ old_spin = flag->set_sleeping(); +#if OMP_50_ENABLED + if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME && + __kmp_pause_status != kmp_soft_paused) { + flag->unset_sleeping(); + __kmp_win32_mutex_unlock(&th->th.th_suspend_mx); + return; + } +#endif KF_TRACE(5, ("__kmp_suspend_template: T#%d set sleep bit for flag's" " loc(%p)==%d\n", diff --git a/runtime/test/affinity/bug-nested.c b/runtime/test/affinity/bug-nested.c new file mode 100644 index 0000000..a81b5f3 --- /dev/null +++ b/runtime/test/affinity/bug-nested.c @@ -0,0 +1,33 @@ +// RUN: %libomp-compile && env KMP_AFFINITY=compact %libomp-run +// REQUIRES: openmp-4.0 + +#include <stdio.h> +#include <stdint.h> +#include <omp.h> +#include "omp_testsuite.h" + +int test_nested_affinity_bug() { + int a = 0; + omp_set_nested(1); + #pragma omp parallel num_threads(2) shared(a) + { + #pragma omp parallel num_threads(2) shared(a) proc_bind(close) + { + #pragma omp atomic + a++; + } + } + return 1; +} + +int main() { + int i; + int num_failed = 0; + + for (i = 0; i < REPETITIONS; i++) { + if (!test_nested_affinity_bug()) { + num_failed++; + } + } + return num_failed; +} diff --git a/runtime/test/affinity/format/affinity_display.1.c b/runtime/test/affinity/format/affinity_display.1.c index b900c3c..fe357d3 100644 --- a/runtime/test/affinity/format/affinity_display.1.c +++ b/runtime/test/affinity/format/affinity_display.1.c @@ -1,5 +1,5 @@ // RUN: %libomp-compile -// RUN: env OMP_DISPLAY_AFFINITY=TRUE OMP_NUM_THREADS=4 OMP_PLACES='{0,1},{2,3},{4,5},{6,7}' %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: env OMP_DISPLAY_AFFINITY=TRUE OMP_NUM_THREADS=4 OMP_PLACES='{0,1},{2,3},{4,5},{6,7}' %libomp-run | %python %S/check.py -c 'CHECK' %s // Affinity Display examples #include <stdio.h> diff --git a/runtime/test/affinity/format/api.c b/runtime/test/affinity/format/api.c index df6be66..08805e7 100644 --- a/runtime/test/affinity/format/api.c +++ b/runtime/test/affinity/format/api.c @@ -1,5 +1,5 @@ // RUN: %libomp-compile-and-run -// RUN: %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/api2.c b/runtime/test/affinity/format/api2.c index 7b2d700..c32da93 100644 --- a/runtime/test/affinity/format/api2.c +++ b/runtime/test/affinity/format/api2.c @@ -1,5 +1,5 @@ // RUN: %libomp-compile-and-run -// RUN: %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/increase.c b/runtime/test/affinity/format/increase.c index 46d8edb..b3942db 100644 --- a/runtime/test/affinity/format/increase.c +++ b/runtime/test/affinity/format/increase.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/nested.c b/runtime/test/affinity/format/nested.c index 502c1da..2ecc918 100644 --- a/runtime/test/affinity/format/nested.c +++ b/runtime/test/affinity/format/nested.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close %libomp-run | %python %S/check.py -c 'CHECK' %s // REQUIRES: affinity #include <stdio.h> diff --git a/runtime/test/affinity/format/nested2.c b/runtime/test/affinity/format/nested2.c index 3dd4956..4b54912 100644 --- a/runtime/test/affinity/format/nested2.c +++ b/runtime/test/affinity/format/nested2.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close KMP_HOT_TEAMS_MAX_LEVEL=2 %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close KMP_HOT_TEAMS_MAX_LEVEL=2 %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/nested_mixed.c b/runtime/test/affinity/format/nested_mixed.c index a39b4fd..1e4c753 100644 --- a/runtime/test/affinity/format/nested_mixed.c +++ b/runtime/test/affinity/format/nested_mixed.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/nested_serial.c b/runtime/test/affinity/format/nested_serial.c index 87ff2bd..8b84ba6 100644 --- a/runtime/test/affinity/format/nested_serial.c +++ b/runtime/test/affinity/format/nested_serial.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | %python %S/check.py -c 'CHECK' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/proc_bind.c b/runtime/test/affinity/format/proc_bind.c index e88e1aa..765c3ce 100644 --- a/runtime/test/affinity/format/proc_bind.c +++ b/runtime/test/affinity/format/proc_bind.c @@ -1,4 +1,4 @@ -// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES='{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0}' %libomp-run | python %S/check.py -c 'CHECK' %s +// RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES='{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0}' %libomp-run | %python %S/check.py -c 'CHECK' %s // REQUIRES: affinity #include <stdio.h> diff --git a/runtime/test/affinity/format/simple.c b/runtime/test/affinity/format/simple.c index 954aa74..701c207 100644 --- a/runtime/test/affinity/format/simple.c +++ b/runtime/test/affinity/format/simple.c @@ -1,10 +1,10 @@ // RUN: %libomp-compile -// RUN: env OMP_DISPLAY_AFFINITY=false %libomp-run | python %S/check.py -c 'NOTHING' %s -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=1 %libomp-run | python %S/check.py -c 'CHECK' %s -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=2 %libomp-run | python %S/check.py -c 'CHECK-2' %s -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=3 %libomp-run | python %S/check.py -c 'CHECK-3' %s -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=4 %libomp-run | python %S/check.py -c 'CHECK-4' %s -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=8 %libomp-run | python %S/check.py -c 'CHECK-8' %s +// RUN: env OMP_DISPLAY_AFFINITY=false %libomp-run | %python %S/check.py -c 'NOTHING' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=1 %libomp-run | %python %S/check.py -c 'CHECK' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=2 %libomp-run | %python %S/check.py -c 'CHECK-2' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=3 %libomp-run | %python %S/check.py -c 'CHECK-3' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=4 %libomp-run | %python %S/check.py -c 'CHECK-4' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=8 %libomp-run | %python %S/check.py -c 'CHECK-8' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/affinity/format/simple_env.c b/runtime/test/affinity/format/simple_env.c index 7aab1cf..ad0a265 100644 --- a/runtime/test/affinity/format/simple_env.c +++ b/runtime/test/affinity/format/simple_env.c @@ -1,5 +1,5 @@ // RUN: %libomp-compile -// RUN: env OMP_DISPLAY_AFFINITY=true OMP_AFFINITY_FORMAT='TESTER-ENV: tl:%L tn:%n nt:%N' OMP_NUM_THREADS=8 %libomp-run | python %S/check.py -c 'CHECK-8' %s +// RUN: env OMP_DISPLAY_AFFINITY=true OMP_AFFINITY_FORMAT='TESTER-ENV: tl:%L tn:%n nt:%N' OMP_NUM_THREADS=8 %libomp-run | %python %S/check.py -c 'CHECK-8' %s #include <stdio.h> #include <stdlib.h> diff --git a/runtime/test/api/omp_get_num_devices.c b/runtime/test/api/omp_get_num_devices.c new file mode 100644 index 0000000..d534fa3 --- /dev/null +++ b/runtime/test/api/omp_get_num_devices.c @@ -0,0 +1,24 @@ +// RUN: %libomp-compile-and-run +#include <stdio.h> +#include "omp_testsuite.h" + +int test_omp_get_num_devices() +{ + /* checks that omp_get_device_num */ + int num_devices = omp_get_num_devices(); + + return (num_devices == 0); +} + +int main() +{ + int i; + int num_failed=0; + + for(i = 0; i < REPETITIONS; i++) { + if(!test_omp_get_num_devices()) { + num_failed++; + } + } + return num_failed; +} diff --git a/runtime/test/api/omp_pause_resource.c b/runtime/test/api/omp_pause_resource.c new file mode 100644 index 0000000..32c1120 --- /dev/null +++ b/runtime/test/api/omp_pause_resource.c @@ -0,0 +1,58 @@ +// RUN: %libomp-compile-and-run +#include <stdio.h> +#include "omp_testsuite.h" + +int test_omp_pause_resource() { + int fails, nthreads, my_dev; + + fails = 0; + nthreads = 0; + my_dev = omp_get_initial_device(); + +#pragma omp parallel +#pragma omp single + nthreads = omp_get_num_threads(); + + if (omp_pause_resource(omp_pause_soft, my_dev)) + fails++; + +#pragma omp parallel shared(nthreads) +#pragma omp single + nthreads = omp_get_num_threads(); + + if (nthreads == 0) + fails++; + if (omp_pause_resource(omp_pause_hard, my_dev)) + fails++; + nthreads = 0; + +#pragma omp parallel shared(nthreads) +#pragma omp single + nthreads = omp_get_num_threads(); + + if (nthreads == 0) + fails++; + if (omp_pause_resource_all(omp_pause_soft)) + fails++; + nthreads = 0; + +#pragma omp parallel shared(nthreads) +#pragma omp single + nthreads = omp_get_num_threads(); + + if (nthreads == 0) + fails++; + return fails == 0; +} + +int main() { + int i; + int num_failed = 0; + + for (i = 0; i < REPETITIONS; i++) { + if (!test_omp_pause_resource()) { + num_failed++; + } + } + return num_failed; +} diff --git a/runtime/test/lit.cfg b/runtime/test/lit.cfg index 066929e..1d050c4 100644 --- a/runtime/test/lit.cfg +++ b/runtime/test/lit.cfg @@ -124,9 +124,10 @@ config.substitutions.append(("%clangXX", config.test_cxx_compiler)) config.substitutions.append(("%clang", config.test_c_compiler)) config.substitutions.append(("%openmp_flags", config.test_openmp_flags)) config.substitutions.append(("%flags", config.test_flags)) +config.substitutions.append(("%python", '"%s"' % (sys.executable))) if config.has_ompt: - config.substitutions.append(("FileCheck", config.test_filecheck)) + config.substitutions.append(("FileCheck", "tee %%t.out | %s" % config.test_filecheck)) config.substitutions.append(("%sort-threads", "sort -n -s")) if config.operating_system == 'Windows': # No such environment variable on Windows. diff --git a/runtime/test/ompt/callback.h b/runtime/test/ompt/callback.h index 0304cff..a7bd7fe 100755 --- a/runtime/test/ompt/callback.h +++ b/runtime/test/ompt/callback.h @@ -8,7 +8,7 @@ #endif #include <inttypes.h> #include <omp.h> -#include <ompt.h> +#include <omp-tools.h> #include "ompt-signal.h" // Used to detect architecture @@ -23,10 +23,13 @@ static const char* ompt_thread_t_values[] = { static const char* ompt_task_status_t_values[] = { NULL, - "ompt_task_complete", - "ompt_task_yield", - "ompt_task_cancel", - "ompt_task_others" + "ompt_task_complete", // 1 + "ompt_task_yield", // 2 + "ompt_task_cancel", // 3 + "ompt_task_detach", // 4 + "ompt_task_early_fulfill", // 5 + "ompt_task_late_fulfill", // 6 + "ompt_task_switch" // 7 }; static const char* ompt_cancel_flag_t_values[] = { "ompt_cancel_parallel", @@ -439,7 +442,8 @@ on_ompt_callback_implicit_task( ompt_data_t *parallel_data, ompt_data_t *task_data, unsigned int team_size, - unsigned int thread_num) + unsigned int thread_num, + int flags) { switch(endpoint) { @@ -651,9 +655,9 @@ on_ompt_callback_task_schedule( } static void -on_ompt_callback_task_dependences( +on_ompt_callback_dependences( ompt_data_t *task_data, - const ompt_task_dependence_t *deps, + const ompt_dependence_t *deps, int ndeps) { printf("%" PRIu64 ": ompt_event_task_dependences: task_id=%" PRIu64 ", deps=%p, ndeps=%d\n", ompt_get_thread_data()->value, task_data->value, (void *)deps, ndeps); @@ -710,6 +714,7 @@ do{ \ int ompt_initialize( ompt_function_lookup_t lookup, + int initial_device_num, ompt_data_t *tool_data) { ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback"); @@ -747,7 +752,7 @@ int ompt_initialize( register_callback(ompt_callback_parallel_end); register_callback(ompt_callback_task_create); register_callback(ompt_callback_task_schedule); - register_callback(ompt_callback_task_dependences); + register_callback(ompt_callback_dependences); register_callback(ompt_callback_task_dependence); register_callback(ompt_callback_thread_begin); register_callback(ompt_callback_thread_end); @@ -760,6 +765,9 @@ void ompt_finalize(ompt_data_t *tool_data) printf("0: ompt_event_runtime_shutdown\n"); } +#ifdef __cplusplus +extern "C" { +#endif ompt_start_tool_result_t* ompt_start_tool( unsigned int omp_version, const char *runtime_version) @@ -767,3 +775,6 @@ ompt_start_tool_result_t* ompt_start_tool( static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0}; return &ompt_start_tool_result; } +#ifdef __cplusplus +} +#endif diff --git a/runtime/test/ompt/cancel/cancel_taskgroup.c b/runtime/test/ompt/cancel/cancel_taskgroup.c index 803fa97..fce39c9 100644 --- a/runtime/test/ompt/cancel/cancel_taskgroup.c +++ b/runtime/test/ompt/cancel/cancel_taskgroup.c @@ -75,7 +75,7 @@ int main() // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[THIRD_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[CANCEL_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no - // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[PARENT_TASK_ID]], second_task_id=[[CANCEL_TASK_ID]], prior_task_status=ompt_task_others=4 + // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[PARENT_TASK_ID]], second_task_id=[[CANCEL_TASK_ID]], prior_task_status=ompt_task_switch=7 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{0x[0-f]*}} // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[CANCEL_TASK_ID]], second_task_id=[[PARENT_TASK_ID]], prior_task_status=ompt_task_cancel=3 diff --git a/runtime/test/ompt/loadtool/tool_available/tool_available.c b/runtime/test/ompt/loadtool/tool_available/tool_available.c index fbbdadd..25187fd 100644 --- a/runtime/test/ompt/loadtool/tool_available/tool_available.c +++ b/runtime/test/ompt/loadtool/tool_available/tool_available.c @@ -49,7 +49,7 @@ int main() #ifdef TOOL #include <stdio.h> -#include <ompt.h> +#include <omp-tools.h> int ompt_initialize( ompt_function_lookup_t lookup, diff --git a/runtime/test/ompt/loadtool/tool_available_search/tool_available_search.c b/runtime/test/ompt/loadtool/tool_available_search/tool_available_search.c index 0f66488..fedfebe 100644 --- a/runtime/test/ompt/loadtool/tool_available_search/tool_available_search.c +++ b/runtime/test/ompt/loadtool/tool_available_search/tool_available_search.c @@ -18,7 +18,7 @@ #ifdef CODE #include "stdio.h" #include "omp.h" -#include "ompt.h" +#include "omp-tools.h" int main() { @@ -52,7 +52,7 @@ int main() #ifdef TOOL -#include <ompt.h> +#include <omp-tools.h> #include "stdio.h" #ifdef SECOND_TOOL diff --git a/runtime/test/ompt/loadtool/tool_not_available/tool_not_available.c b/runtime/test/ompt/loadtool/tool_not_available/tool_not_available.c index b0d3f2b..ea40468 100644 --- a/runtime/test/ompt/loadtool/tool_not_available/tool_not_available.c +++ b/runtime/test/ompt/loadtool/tool_not_available/tool_not_available.c @@ -28,7 +28,7 @@ #ifdef CODE #include "stdio.h" #include "omp.h" -#include "ompt.h" +#include "omp-tools.h" int main() { @@ -56,7 +56,7 @@ int main() #ifdef TOOL -#include <ompt.h> +#include <omp-tools.h> #include "stdio.h" ompt_start_tool_result_t* ompt_start_tool( diff --git a/runtime/test/ompt/misc/api_calls_without_ompt.c b/runtime/test/ompt/misc/api_calls_without_ompt.c new file mode 100644 index 0000000..e66aecd --- /dev/null +++ b/runtime/test/ompt/misc/api_calls_without_ompt.c @@ -0,0 +1,148 @@ +// RUN: %libomp-compile-and-run | FileCheck %s +// REQUIRES: ompt + +#define _BSD_SOURCE +#define _DEFAULT_SOURCE + +#include <stdio.h> +#include <inttypes.h> +#include <omp.h> +#include <omp-tools.h> + +static ompt_set_callback_t ompt_set_callback; +static ompt_get_callback_t ompt_get_callback; +static ompt_get_state_t ompt_get_state; +static ompt_get_task_info_t ompt_get_task_info; +static ompt_get_thread_data_t ompt_get_thread_data; +static ompt_get_parallel_info_t ompt_get_parallel_info; +static ompt_get_unique_id_t ompt_get_unique_id; +static ompt_get_num_procs_t ompt_get_num_procs; +static ompt_get_num_places_t ompt_get_num_places; +static ompt_get_place_proc_ids_t ompt_get_place_proc_ids; +static ompt_get_place_num_t ompt_get_place_num; +static ompt_get_partition_place_nums_t ompt_get_partition_place_nums; +static ompt_get_proc_id_t ompt_get_proc_id; +static ompt_enumerate_states_t ompt_enumerate_states; +static ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls; + +int main() { + // Call OpenMP API function to force initialization of OMPT. + // (omp_get_thread_num() does not work because it just returns 0 if the + // runtime isn't initialized yet...) + omp_get_num_threads(); + + ompt_data_t *tdata = ompt_get_thread_data(); + uint64_t tvalue = tdata ? tdata->value : 0; + + printf("%" PRIu64 ": ompt_get_num_places()=%d\n", tvalue, + ompt_get_num_places()); + + printf("%" PRIu64 ": ompt_get_place_proc_ids()=%d\n", tvalue, + ompt_get_place_proc_ids(0, 0, NULL)); + + printf("%" PRIu64 ": ompt_get_place_num()=%d\n", tvalue, + ompt_get_place_num()); + + printf("%" PRIu64 ": ompt_get_partition_place_nums()=%d\n", tvalue, + ompt_get_partition_place_nums(0, NULL)); + + printf("%" PRIu64 ": ompt_get_proc_id()=%d\n", tvalue, ompt_get_proc_id()); + + printf("%" PRIu64 ": ompt_get_num_procs()=%d\n", tvalue, + ompt_get_num_procs()); + + ompt_callback_t callback; + printf("%" PRIu64 ": ompt_get_callback()=%d\n", tvalue, + ompt_get_callback(ompt_callback_thread_begin, &callback)); + + printf("%" PRIu64 ": ompt_get_state()=%d\n", tvalue, ompt_get_state(NULL)); + + int state = ompt_state_undefined; + const char *state_name; + printf("%" PRIu64 ": ompt_enumerate_states()=%d\n", tvalue, + ompt_enumerate_states(state, &state, &state_name)); + + int impl = ompt_mutex_impl_none; + const char *impl_name; + printf("%" PRIu64 ": ompt_enumerate_mutex_impls()=%d\n", tvalue, + ompt_enumerate_mutex_impls(impl, &impl, &impl_name)); + + printf("%" PRIu64 ": ompt_get_thread_data()=%p\n", tvalue, + ompt_get_thread_data()); + + printf("%" PRIu64 ": ompt_get_parallel_info()=%d\n", tvalue, + ompt_get_parallel_info(0, NULL, NULL)); + + printf("%" PRIu64 ": ompt_get_task_info()=%d\n", tvalue, + ompt_get_task_info(0, NULL, NULL, NULL, NULL, NULL)); + + // Check if libomp supports the callbacks for this test. + + // CHECK: 0: NULL_POINTER=[[NULL:.*$]] + + // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_get_num_places()={{[0-9]+}} + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids()={{[0-9]+}} + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=-1 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_partition_place_nums()=0 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=-1 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()={{[0-9]+}} + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_callback()=0 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_state()=0 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_states()=1 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_mutex_impls()=1 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_thread_data()=[[NULL]] + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_parallel_info()=0 + + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_task_info()=0 + + return 0; +} + +int ompt_initialize(ompt_function_lookup_t lookup, ompt_data_t *tool_data) { + ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback"); + ompt_get_callback = (ompt_get_callback_t)lookup("ompt_get_callback"); + ompt_get_state = (ompt_get_state_t)lookup("ompt_get_state"); + ompt_get_task_info = (ompt_get_task_info_t)lookup("ompt_get_task_info"); + ompt_get_thread_data = (ompt_get_thread_data_t)lookup("ompt_get_thread_data"); + ompt_get_parallel_info = + (ompt_get_parallel_info_t)lookup("ompt_get_parallel_info"); + ompt_get_unique_id = (ompt_get_unique_id_t)lookup("ompt_get_unique_id"); + + ompt_get_num_procs = (ompt_get_num_procs_t)lookup("ompt_get_num_procs"); + ompt_get_num_places = (ompt_get_num_places_t)lookup("ompt_get_num_places"); + ompt_get_place_proc_ids = + (ompt_get_place_proc_ids_t)lookup("ompt_get_place_proc_ids"); + ompt_get_place_num = (ompt_get_place_num_t)lookup("ompt_get_place_num"); + ompt_get_partition_place_nums = + (ompt_get_partition_place_nums_t)lookup("ompt_get_partition_place_nums"); + ompt_get_proc_id = (ompt_get_proc_id_t)lookup("ompt_get_proc_id"); + ompt_enumerate_states = + (ompt_enumerate_states_t)lookup("ompt_enumerate_states"); + ompt_enumerate_mutex_impls = + (ompt_enumerate_mutex_impls_t)lookup("ompt_enumerate_mutex_impls"); + + printf("0: NULL_POINTER=%p\n", (void *)NULL); + return 0; // no success -> OMPT not enabled +} + +void ompt_finalize(ompt_data_t *tool_data) { + printf("0: ompt_event_runtime_shutdown\n"); +} + +ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version, + const char *runtime_version) { + static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize, + &ompt_finalize, 0}; + return &ompt_start_tool_result; +} diff --git a/runtime/test/ompt/parallel/parallel_if0.c b/runtime/test/ompt/parallel/parallel_if0.c index f5c4454..63d6701 100644 --- a/runtime/test/ompt/parallel/parallel_if0.c +++ b/runtime/test/ompt/parallel/parallel_if0.c @@ -57,7 +57,7 @@ int main() // CHECK: {{^}}[[MASTER_ID]]: task level 2: parallel_id=[[IMPLICIT_PARALLEL_ID]], task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]], reenter_frame={{0x[0-f]+}} // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[NESTED_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[EXPLICIT_TASK_ID:[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[NESTED_IMPLICIT_TASK_ID]], second_task_id=[[EXPLICIT_TASK_ID]], prior_task_status=ompt_task_others=4 + // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[NESTED_IMPLICIT_TASK_ID]], second_task_id=[[EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[EXPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame=[[NULL]] // CHECK: {{^}}[[MASTER_ID]]: task level 1: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame={{0x[0-f]+}} // CHECK: {{^}}[[MASTER_ID]]: task level 2: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame={{0x[0-f]+}} diff --git a/runtime/test/ompt/parallel/serialized.c b/runtime/test/ompt/parallel/serialized.c index e7a9207..2be17dc 100644 --- a/runtime/test/ompt/parallel/serialized.c +++ b/runtime/test/ompt/parallel/serialized.c @@ -57,7 +57,7 @@ int main() // CHECK: {{^}}[[MASTER_ID]]: task level 2: parallel_id=[[IMPLICIT_PARALLEL_ID]], task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]], reenter_frame={{0x[0-f]+}} // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[NESTED_IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[EXPLICIT_TASK_ID:[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[NESTED_IMPLICIT_TASK_ID]], second_task_id=[[EXPLICIT_TASK_ID]], prior_task_status=ompt_task_others=4 + // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[NESTED_IMPLICIT_TASK_ID]], second_task_id=[[EXPLICIT_TASK_ID]], prior_task_status=ompt_task_switch=7 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[EXPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame=[[NULL]] // CHECK: {{^}}[[MASTER_ID]]: task level 1: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame={{0x[0-f]+}} // CHECK: {{^}}[[MASTER_ID]]: task level 2: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]], exit_frame={{0x[0-f]+}}, reenter_frame={{0x[0-f]+}} diff --git a/runtime/test/ompt/synchronization/barrier/implicit_task_data.c b/runtime/test/ompt/synchronization/barrier/implicit_task_data.c index 5cfbe00..c933e89 100644 --- a/runtime/test/ompt/synchronization/barrier/implicit_task_data.c +++ b/runtime/test/ompt/synchronization/barrier/implicit_task_data.c @@ -12,7 +12,7 @@ #include <unistd.h> #include <inttypes.h> #include <omp.h> -#include <ompt.h> +#include <omp-tools.h> static const char* ompt_thread_t_values[] = { NULL, diff --git a/runtime/test/ompt/tasks/taskyield.c b/runtime/test/ompt/tasks/taskyield.c index 56a4697..2dd0fa1 100644 --- a/runtime/test/ompt/tasks/taskyield.c +++ b/runtime/test/ompt/tasks/taskyield.c @@ -51,7 +51,7 @@ int main() // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[IMPLICIT_TASK_ID]], second_task_id=[[MAIN_TASK]], prior_task_status=ompt_task_yield=2 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[MAIN_TASK]], second_task_id=[[IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 - // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[WORKER_TASK]], prior_task_status=ompt_task_others=4 + // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[WORKER_TASK]], prior_task_status=ompt_task_switch=7 // CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[WORKER_TASK]], second_task_id={{[0-9]+}}, prior_task_status=ompt_task_complete=1 diff --git a/runtime/tools/check-depends.pl b/runtime/tools/check-depends.pl index 47e7e5a..168c0cd 100755 --- a/runtime/tools/check-depends.pl +++ b/runtime/tools/check-depends.pl @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/check-execstack.pl b/runtime/tools/check-execstack.pl index cf24742..34f77e1 100755 --- a/runtime/tools/check-execstack.pl +++ b/runtime/tools/check-execstack.pl @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/check-instruction-set.pl b/runtime/tools/check-instruction-set.pl index b505e48..455210c 100755 --- a/runtime/tools/check-instruction-set.pl +++ b/runtime/tools/check-instruction-set.pl @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/generate-def.pl b/runtime/tools/generate-def.pl index f6e4a4c..382e56e 100755 --- a/runtime/tools/generate-def.pl +++ b/runtime/tools/generate-def.pl @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/lib/Build.pm b/runtime/tools/lib/Build.pm index cf67156..a24cf57 100644 --- a/runtime/tools/lib/Build.pm +++ b/runtime/tools/lib/Build.pm @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/lib/LibOMP.pm b/runtime/tools/lib/LibOMP.pm index 012767e..497b926 100644 --- a/runtime/tools/lib/LibOMP.pm +++ b/runtime/tools/lib/LibOMP.pm @@ -1,10 +1,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/lib/Platform.pm b/runtime/tools/lib/Platform.pm index 8fe6359..b0e10a1 100644 --- a/runtime/tools/lib/Platform.pm +++ b/runtime/tools/lib/Platform.pm @@ -12,10 +12,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/lib/Uname.pm b/runtime/tools/lib/Uname.pm index f85e1ee..4a5c332 100644 --- a/runtime/tools/lib/Uname.pm +++ b/runtime/tools/lib/Uname.pm @@ -9,10 +9,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/lib/tools.pm b/runtime/tools/lib/tools.pm index ce5cf44..cbed636 100644 --- a/runtime/tools/lib/tools.pm +++ b/runtime/tools/lib/tools.pm @@ -11,10 +11,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/runtime/tools/message-converter.pl b/runtime/tools/message-converter.pl index e22c928..d72acf0 100755 --- a/runtime/tools/message-converter.pl +++ b/runtime/tools/message-converter.pl @@ -3,10 +3,9 @@ # #//===----------------------------------------------------------------------===// #// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. +#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +#// See https://llvm.org/LICENSE.txt for license information. +#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #// #//===----------------------------------------------------------------------===// # diff --git a/www/index.html b/www/index.html index d8a2571..3d1f977 100644 --- a/www/index.html +++ b/www/index.html @@ -25,8 +25,7 @@ <a href="http://lists.llvm.org/mailman/listinfo/openmp-dev">openmp-dev</a> <a href="http://lists.llvm.org/mailman/listinfo/openmp-commits">openmp-commits</a> <a href="http://llvm.org/bugs/">Bug Reports</a> - <a href="http://llvm.org/svn/llvm-project/openmp/trunk/">Browse SVN</a> - <a href="http://llvm.org/viewvc/llvm-project/openmp/trunk/">Browse ViewVC</a> + <a href="https://github.com/llvm/llvm-project/tree/master/openmp">Browse Sources</a> </div> </div> @@ -154,30 +153,22 @@ <p>To check out the code, use:</p> <ul> - <li><code>svn co http://llvm.org/svn/llvm-project/openmp/trunk openmp</code></li> + <li><code>git clone https://github.com/llvm/llvm-project.git</code></li> </ul> - <p> - Note that for an in-tree build, you should check out openmp to llvm/projects. - </p> - <p>In-tree build:</p> <ul> - <li><code>cd where-you-want-to-live</code></li> - <li>Check out openmp into llvm/projects</li> - <li><code>cd where-you-want-to-build</code></li> + <li><code>cd llvm-project</code></li> <li><code>mkdir build && cd build</code></li> - <li><code>cmake path/to/llvm -DCMAKE_C_COMPILER=<C compiler> -DCMAKE_CXX_COMPILER=<C++ compiler></code></li> + <li><code>cmake ../llvm -DLLVM_ENABLE_PROJECTS=openmp -DCMAKE_C_COMPILER=<C compiler> -DCMAKE_CXX_COMPILER=<C++ compiler></code></li> <li><code>make omp</code></li> </ul> <p>Out-of-tree build:</p> <ul> - <li><code>cd where-you-want-to-live</code></li> - <li>Check out openmp</li> - <li><code>cd where-you-want-to-live/openmp</code></li> - <li><code>mkdir build && cd build</code></li> - <li><code>cmake path/to/openmp -DCMAKE_C_COMPILER=<C compiler> -DCMAKE_CXX_COMPILER=<C++ compiler></code></li> + <li><code>cd llvm-project</code></li> + <li><code>mkdir build-openmp && cd build-openmp</code></li> + <li><code>cmake ../openmp -DCMAKE_C_COMPILER=<C compiler> -DCMAKE_CXX_COMPILER=<C++ compiler></code></li> <li><code>make</code></li> </ul> |