forked from OSchip/llvm-project
[OpenMP][libomptarget] make omp_get_initial_device 5.1 compliant
OpenMP 5.1 defines omp_get_initial_device to return the same value as omp_get_num_devices. Since this change is also 5.0 compliant, no versioning is needed. Differential Revision: https://reviews.llvm.org/D88149
This commit is contained in:
parent
37b2e2b04c
commit
55cff5b288
|
@ -21,7 +21,6 @@
|
|||
#define OFFLOAD_FAIL (~0)
|
||||
|
||||
#define OFFLOAD_DEVICE_DEFAULT -1
|
||||
#define HOST_DEVICE -10
|
||||
|
||||
/// Data attributes for each data reference used in an OpenMP target region.
|
||||
enum tgt_map_type {
|
||||
|
|
|
@ -29,8 +29,9 @@ EXTERN int omp_get_num_devices(void) {
|
|||
}
|
||||
|
||||
EXTERN int omp_get_initial_device(void) {
|
||||
DP("Call to omp_get_initial_device returning %d\n", HOST_DEVICE);
|
||||
return HOST_DEVICE;
|
||||
int hostDevice = omp_get_num_devices();
|
||||
DP("Call to omp_get_initial_device returning %d\n", hostDevice);
|
||||
return hostDevice;
|
||||
}
|
||||
|
||||
EXTERN void *omp_target_alloc(size_t size, int device_num) {
|
||||
|
|
|
@ -3876,7 +3876,6 @@ extern int __kmpc_get_target_offload();
|
|||
|
||||
// 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".
|
||||
|
||||
// OMP Pause Resource
|
||||
|
|
|
@ -966,13 +966,15 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_IS_INITIAL_DEVICE)(void) {
|
|||
int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) KMP_WEAK_ATTRIBUTE_EXTERNAL;
|
||||
int FTN_STDCALL FTN_GET_INITIAL_DEVICE(void) {
|
||||
#if KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
|
||||
return KMP_HOST_DEVICE;
|
||||
// same as omp_get_num_devices()
|
||||
return 0;
|
||||
#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;
|
||||
// same as omp_get_num_devices()
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1319,14 +1321,14 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_MAX_TASK_PRIORITY)(void) {
|
|||
// 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_EXTERNAL;
|
||||
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) { return KMP_HOST_DEVICE; }
|
||||
int FTN_STDCALL FTN_GET_DEVICE_NUM(void) { return FTN_GET_INITIAL_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)
|
||||
if (device_num == FTN_GET_INITIAL_DEVICE())
|
||||
return __kmpc_pause_resource(kind);
|
||||
else {
|
||||
#if !KMP_OS_WINDOWS
|
||||
|
|
Loading…
Reference in New Issue