}
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) {
// 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
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
}
// 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