Index: openmp/libomptarget/include/omptarget.h =================================================================== --- openmp/libomptarget/include/omptarget.h +++ openmp/libomptarget/include/omptarget.h @@ -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 { Index: openmp/libomptarget/src/api.cpp =================================================================== --- openmp/libomptarget/src/api.cpp +++ openmp/libomptarget/src/api.cpp @@ -29,8 +29,9 @@ } 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) { Index: openmp/runtime/src/kmp.h =================================================================== --- openmp/runtime/src/kmp.h +++ openmp/runtime/src/kmp.h @@ -3876,7 +3876,6 @@ // 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 Index: openmp/runtime/src/kmp_ftn_entry.h =================================================================== --- openmp/runtime/src/kmp_ftn_entry.h +++ openmp/runtime/src/kmp_ftn_entry.h @@ -966,13 +966,13 @@ 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; + return 0; // omp_get_num_devices() #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; + return 0; // omp_get_num_devices() } #endif } @@ -1319,14 +1319,14 @@ // 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