Fix Windows OpenMP build (#170142)
fixes Windows build issue in https://github.com/llvm/llvm-project/pull/168554
This commit is contained in:
parent
04dd71cb0b
commit
9605666949
5 changed files with 45 additions and 32 deletions
|
|
@ -105,6 +105,8 @@ OMP_4.5 {
|
|||
} OMP_4.0;
|
||||
OMP_5.0 {
|
||||
} OMP_4.5;
|
||||
OMP_6.0 {
|
||||
} OMP_5.0;
|
||||
|
||||
# sets up GCC GOMP_ version dependency chain
|
||||
GOMP_1.0 {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ OMP_4.5 {
|
|||
} OMP_4.0;
|
||||
OMP_5.0 {
|
||||
} OMP_4.5;
|
||||
OMP_6.0 {
|
||||
} OMP_5.0;
|
||||
|
||||
# sets up GCC GOMP_ version dependency chain
|
||||
GOMP_1.0 {
|
||||
|
|
|
|||
|
|
@ -29,36 +29,6 @@ char const __kmp_version_ftncdecl[] =
|
|||
#define FTN_STDCALL /* no stdcall */
|
||||
#include "kmp_ftn_os.h"
|
||||
#include "kmp_ftn_entry.h"
|
||||
|
||||
// FIXME: this is a hack to get the UID functions working for C.
|
||||
// It will be moved and also made available for Fortran in a follow-up patch.
|
||||
extern "C" {
|
||||
const char *FTN_STDCALL omp_get_uid_from_device(int device_num)
|
||||
KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
const char *FTN_STDCALL omp_get_uid_from_device(int device_num) {
|
||||
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
|
||||
return nullptr;
|
||||
#else
|
||||
const char *(*fptr)(int);
|
||||
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))
|
||||
return (*fptr)(device_num);
|
||||
// Returns the same string as used by libomptarget
|
||||
return "HOST";
|
||||
#endif
|
||||
}
|
||||
int FTN_STDCALL omp_get_device_from_uid(const char *device_uid)
|
||||
KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
int FTN_STDCALL omp_get_device_from_uid(const char *device_uid) {
|
||||
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
|
||||
return omp_invalid_device;
|
||||
#else
|
||||
int (*fptr)(const char *);
|
||||
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))
|
||||
return (*fptr)(device_uid);
|
||||
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
"no";
|
||||
#endif /* KMP_FTN_ENTRIES */
|
||||
|
|
|
|||
|
|
@ -1543,13 +1543,40 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
// This function will be defined in libomptarget. When libomptarget is not
|
||||
// loaded, we assume we are on the host and return KMP_HOST_DEVICE.
|
||||
// These functions will be defined in libomptarget. When libomptarget is not
|
||||
// loaded, we assume we are on the host.
|
||||
// Compiler/libomptarget will handle this if called inside target.
|
||||
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) {
|
||||
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
|
||||
}
|
||||
const char *FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_UID_FROM_DEVICE)(int device_num)
|
||||
KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
const char *FTN_STDCALL
|
||||
KMP_EXPAND_NAME(FTN_GET_UID_FROM_DEVICE)(int device_num) {
|
||||
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
|
||||
return nullptr;
|
||||
#else
|
||||
const char *(*fptr)(int);
|
||||
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))
|
||||
return (*fptr)(device_num);
|
||||
// Returns the same string as used by libomptarget
|
||||
return "HOST";
|
||||
#endif
|
||||
}
|
||||
int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_DEVICE_FROM_UID)(const char *device_uid)
|
||||
KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
int FTN_STDCALL
|
||||
KMP_EXPAND_NAME(FTN_GET_DEVICE_FROM_UID)(const char *device_uid) {
|
||||
#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)
|
||||
return omp_invalid_device;
|
||||
#else
|
||||
int (*fptr)(const char *);
|
||||
if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))
|
||||
return (*fptr)(device_uid);
|
||||
return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Compiler will ensure that this is only called from host in sequential region
|
||||
int FTN_STDCALL KMP_EXPAND_NAME(FTN_PAUSE_RESOURCE)(kmp_pause_status_t kind,
|
||||
|
|
@ -1906,6 +1933,10 @@ KMP_VERSION_SYMBOL(FTN_SET_AFFINITY_FORMAT, 50, "OMP_5.0");
|
|||
// KMP_VERSION_SYMBOL(FTN_GET_SUPPORTED_ACTIVE_LEVELS, 50, "OMP_5.0");
|
||||
// KMP_VERSION_SYMBOL(FTN_FULFILL_EVENT, 50, "OMP_5.0");
|
||||
|
||||
// OMP_6.0 versioned symbols
|
||||
KMP_VERSION_SYMBOL(FTN_GET_UID_FROM_DEVICE, 60, "OMP_6.0");
|
||||
KMP_VERSION_SYMBOL(FTN_GET_DEVICE_FROM_UID, 60, "OMP_6.0");
|
||||
|
||||
#endif // KMP_USE_VERSION_SYMBOLS
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@
|
|||
#define FTN_GET_MEMSPACE_NUM_RESOURCES omp_get_memspace_num_resources
|
||||
#define FTN_GET_SUBMEMSPACE omp_get_submemspace
|
||||
#define FTN_GET_DEVICE_NUM omp_get_device_num
|
||||
#define FTN_GET_UID_FROM_DEVICE omp_get_uid_from_device
|
||||
#define FTN_GET_DEVICE_FROM_UID omp_get_device_from_uid
|
||||
#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
|
||||
|
|
@ -289,6 +291,8 @@
|
|||
#define FTN_ALLOC omp_alloc_
|
||||
#define FTN_FREE omp_free_
|
||||
#define FTN_GET_DEVICE_NUM omp_get_device_num_
|
||||
#define FTN_GET_UID_FROM_DEVICE omp_get_uid_from_device_
|
||||
#define FTN_GET_DEVICE_FROM_UID omp_get_device_from_uid_
|
||||
#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_
|
||||
|
|
@ -436,6 +440,8 @@
|
|||
#define FTN_GET_MEMSPACE_NUM_RESOURCES OMP_GET_MEMSPACE_NUM_RESOURCES
|
||||
#define FTN_GET_SUBMEMSPACE OMP_GET_SUBMEMSPACE
|
||||
#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM
|
||||
#define FTN_GET_UID_FROM_DEVICE OMP_GET_UID_FROM_DEVICE
|
||||
#define FTN_GET_DEVICE_FROM_UID OMP_GET_DEVICE_FROM_UID
|
||||
#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
|
||||
|
|
@ -585,6 +591,8 @@
|
|||
#define FTN_ALLOC OMP_ALLOC_
|
||||
#define FTN_FREE OMP_FREE_
|
||||
#define FTN_GET_DEVICE_NUM OMP_GET_DEVICE_NUM_
|
||||
#define FTN_GET_UID_FROM_DEVICE OMP_GET_UID_FROM_DEVICE_
|
||||
#define FTN_GET_DEVICE_FROM_UID OMP_GET_DEVICE_FROM_UID_
|
||||
#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_
|
||||
|
|
|
|||
Loading…
Reference in a new issue