Skip to content

Commit 85b73d3

Browse files
Merge pull request #80 from shintaro-iwasaki/2.0/upgrade11
Upgrade BOLT to LLVM OpenMP 11
2 parents 1cf40d9 + 85b7a98 commit 85b73d3

File tree

10 files changed

+43
-33
lines changed

10 files changed

+43
-33
lines changed

libomptarget/src/omptarget.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,14 +746,9 @@ int target(int64_t device_id, void *host_ptr, int32_t arg_num,
746746
return OFFLOAD_FAIL;
747747
}
748748
}
749-
} else if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) {
750-
TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBase, sizeof(void *), IsLast,
751-
false, IsHostPtr);
752-
TgtBaseOffset = 0; // no offset for ptrs.
753-
DP("Obtained target argument " DPxMOD " from host pointer " DPxMOD " to "
754-
"object " DPxMOD "\n", DPxPTR(TgtPtrBegin), DPxPTR(HstPtrBase),
755-
DPxPTR(HstPtrBase));
756749
} else {
750+
if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ)
751+
HstPtrBase = *reinterpret_cast<void **>(HstPtrBase);
757752
TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBegin, arg_sizes[i], IsLast,
758753
false, IsHostPtr);
759754
TgtBaseOffset = (intptr_t)HstPtrBase - (intptr_t)HstPtrBegin;

runtime/cmake/LibompExports.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ add_custom_command(TARGET bolt-omp POST_BUILD
8383

8484
# Copy Windows import library into exports/ directory post build
8585
if(WIN32)
86-
get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY bolt-ompimp ARCHIVE_OUTPUT_DIRECTORY)
86+
get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ${LIBOMP_IMP_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY)
8787
if(NOT LIBOMPIMP_OUTPUT_DIRECTORY)
8888
set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
8989
endif()
90-
add_custom_command(TARGET bolt-ompimp POST_BUILD
90+
add_custom_command(TARGET ${LIBOMP_IMP_LIB_TARGET} POST_BUILD
9191
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR}
9292
COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR}
9393
)

runtime/cmake/LibompMicroTests.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# get library location
4141
if(WIN32)
4242
get_target_property(LIBOMP_OUTPUT_DIRECTORY bolt-omp RUNTIME_OUTPUT_DIRECTORY)
43-
get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY bolt-ompimp ARCHIVE_OUTPUT_DIRECTORY)
43+
get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ${LIBOMP_IMP_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY)
4444
if(NOT LIBOMPIMP_OUTPUT_DIRECTORY)
4545
set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
4646
endif()

runtime/src/CMakeLists.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,28 +229,34 @@ if(WIN32)
229229
# the import library is "re-linked" to include kmp_import.cpp which prevents
230230
# linking of both Visual Studio OpenMP and newly built OpenMP
231231
set_source_files_properties(kmp_import.cpp PROPERTIES COMPILE_FLAGS "${LIBOMP_CONFIGURED_CXXFLAGS}")
232-
set(LIBOMP_IMP_LIB_FILE ${LIBBOLT_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
232+
set(LIBOMP_IMP_LIB_FILE ${LIBBOLT_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
233233
set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_LIB_FILE}${CMAKE_STATIC_LIBRARY_SUFFIX})
234234
set_target_properties(bolt-omp PROPERTIES
235235
VERSION ${LIBBOLT_VERSION_MAJOR}.${LIBBOLT_VERSION_MINOR} # uses /version flag
236236
IMPORT_PREFIX "" IMPORT_SUFFIX "" # control generated import library name when building omp
237237
ARCHIVE_OUTPUT_NAME ${LIBOMP_GENERATED_IMP_LIB_FILENAME}
238238
)
239-
# Get generated import library from creating omp
240-
get_target_property(LIBOMP_IMPORT_LIB_DIRECTORY bolt-omp ARCHIVE_OUTPUT_DIRECTORY)
241-
if(LIBOMP_IMPORT_LIB_DIRECTORY)
242-
set(LIBOMP_GENERATED_IMP_LIB ${LIBOMP_IMPORT_LIB_DIRECTORY}/${LIBOMP_GENERATED_IMP_LIB_FILENAME})
239+
240+
if(MSVC)
241+
# Get generated import library from creating omp
242+
get_target_property(LIBOMP_IMPORT_LIB_DIRECTORY bolt-omp ARCHIVE_OUTPUT_DIRECTORY)
243+
if(LIBOMP_IMPORT_LIB_DIRECTORY)
244+
set(LIBOMP_GENERATED_IMP_LIB ${LIBOMP_IMPORT_LIB_DIRECTORY}/${LIBOMP_GENERATED_IMP_LIB_FILENAME})
245+
else()
246+
set(LIBOMP_GENERATED_IMP_LIB ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_GENERATED_IMP_LIB_FILENAME})
247+
endif()
248+
set_source_files_properties(${LIBOMP_GENERATED_IMP_LIB} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
249+
# Create new import library that is just the previously created one + kmp_import.cpp
250+
add_library(bolt-ompimp STATIC ${LIBOMP_GENERATED_IMP_LIB} kmp_import.cpp)
251+
set_target_properties(bolt-ompimp PROPERTIES
252+
PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}"
253+
LINKER_LANGUAGE C
254+
)
255+
add_dependencies(bolt-ompimp bolt-omp) # ensure generated import library is created first
256+
set(LIBOMP_IMP_LIB_TARGET bolt-ompimp)
243257
else()
244-
set(LIBOMP_GENERATED_IMP_LIB ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_GENERATED_IMP_LIB_FILENAME})
258+
set(LIBOMP_IMP_LIB_TARGET bolt-omp)
245259
endif()
246-
set_source_files_properties(${LIBOMP_GENERATED_IMP_LIB} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
247-
# Create new import library that is just the previously created one + kmp_import.cpp
248-
add_library(bolt-ompimp STATIC ${LIBOMP_GENERATED_IMP_LIB} kmp_import.cpp)
249-
set_target_properties(bolt-ompimp PROPERTIES
250-
PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}"
251-
LINKER_LANGUAGE C
252-
)
253-
add_dependencies(bolt-ompimp bolt-omp) # ensure generated import library is created first
254260

255261
# Create def file to designate exported functions
256262
libomp_get_gdflags(LIBOMP_GDFLAGS) # generate-def.pl flags (Windows only)
@@ -324,7 +330,7 @@ else()
324330
endif()
325331
if(WIN32)
326332
install(TARGETS bolt-omp RUNTIME DESTINATION bin)
327-
install(TARGETS bolt-ompimp ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}")
333+
install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}")
328334
# Create aliases (regular copies) of the library for backwards compatibility
329335
set(LIBOMP_ALIASES "libomp;libiomp5md")
330336
foreach(alias IN LISTS LIBOMP_ALIASES)

runtime/src/kmp_ftn_entry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_DEFAULT_DEVICE)(int KMP_DEREF arg) {
943943

944944
// Get number of NON-HOST devices.
945945
// libomptarget, if loaded, provides this function in api.cpp.
946-
int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) KMP_WEAK_ATTRIBUTE;
946+
int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
947947
int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) {
948948
#if KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
949949
return 0;
@@ -961,13 +961,13 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)(void) {
961961

962962
// This function always returns true when called on host device.
963963
// Compiler/libomptarget should handle when it is called inside target region.
964-
int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) KMP_WEAK_ATTRIBUTE;
964+
int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
965965
int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) {
966966
return 1; // This is the host
967967
}
968968

969969
// libomptarget, if loaded, provides this function
970-
int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) KMP_WEAK_ATTRIBUTE;
970+
int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
971971
int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) {
972972
#if KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
973973
return KMP_HOST_DEVICE;
@@ -1322,7 +1322,7 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) {
13221322
// This function will be defined in libomptarget. When libomptarget is not
13231323
// loaded, we assume we are on the host and return KMP_HOST_DEVICE.
13241324
// Compiler/libomptarget will handle this if called inside target.
1325-
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) KMP_WEAK_ATTRIBUTE;
1325+
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
13261326
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) { return KMP_HOST_DEVICE; }
13271327

13281328
// Compiler will ensure that this is only called from host in sequential region

runtime/src/kmp_lock.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,8 @@ static void __kmp_set_queuing_lock_flags(kmp_queuing_lock_t *lck,
19401940

19411941
#if (KMP_COMPILER_ICC && __INTEL_COMPILER >= 1300) || \
19421942
(KMP_COMPILER_MSVC && _MSC_VER >= 1700) || \
1943-
(KMP_COMPILER_CLANG && KMP_MSVC_COMPAT)
1943+
(KMP_COMPILER_CLANG && (KMP_MSVC_COMPAT || __MINGW32__)) || \
1944+
(KMP_COMPILER_GCC && __MINGW32__)
19441945

19451946
#include <immintrin.h>
19461947
#define SOFT_ABORT_MASK (_XABORT_RETRY | _XABORT_CONFLICT | _XABORT_EXPLICIT)

runtime/src/kmp_os.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,16 @@ extern "C" {
339339
#define KMP_ALIAS(alias_of) __attribute__((alias(alias_of)))
340340
#endif
341341

342+
#if KMP_HAVE_WEAK_ATTRIBUTE && !KMP_DYNAMIC_LIB
343+
#define KMP_WEAK_ATTRIBUTE_EXTERNAL __attribute__((weak))
344+
#else
345+
#define KMP_WEAK_ATTRIBUTE_EXTERNAL /* Nothing */
346+
#endif
347+
342348
#if KMP_HAVE_WEAK_ATTRIBUTE
343-
#define KMP_WEAK_ATTRIBUTE __attribute__((weak))
349+
#define KMP_WEAK_ATTRIBUTE_INTERNAL __attribute__((weak))
344350
#else
345-
#define KMP_WEAK_ATTRIBUTE /* Nothing */
351+
#define KMP_WEAK_ATTRIBUTE_INTERNAL /* Nothing */
346352
#endif
347353

348354
// Define KMP_VERSION_SYMBOL and KMP_EXPAND_NAME

runtime/src/ompt-specific.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define THREAD_LOCAL __thread
2828
#endif
2929

30-
#define OMPT_WEAK_ATTRIBUTE KMP_WEAK_ATTRIBUTE
30+
#define OMPT_WEAK_ATTRIBUTE KMP_WEAK_ATTRIBUTE_INTERNAL
3131

3232
//******************************************************************************
3333
// macros

runtime/test/ompt/tasks/task_early_fulfill.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='3' \
22
// RUN: %libomp-run | %sort-threads | FileCheck %s
3+
// REQUIRES: ompt
34

45
// Checked gcc 10.1 still does not support detach clause on task construct.
56
// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10

runtime/test/ompt/tasks/task_late_fulfill.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='3' \
22
// RUN: %libomp-run | %sort-threads | FileCheck %s
3+
// REQUIRES: ompt
34

45
// Checked gcc 10.1 still does not support detach clause on task construct.
56
// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10

0 commit comments

Comments
 (0)