diff --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp --- a/openmp/libomptarget/src/interface.cpp +++ b/openmp/libomptarget/src/interface.cpp @@ -93,7 +93,7 @@ TIMESCOPE_WITH_IDENT(loc); DP("Entering data begin region for device %" PRId64 " with %d mappings\n", device_id, arg_num); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return; } @@ -162,7 +162,7 @@ void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); DP("Entering data end region with %d mappings\n", arg_num); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return; } @@ -226,7 +226,7 @@ void **arg_mappers) { TIMESCOPE_WITH_IDENT(loc); DP("Entering data update with %d mappings\n", arg_num); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return; } @@ -282,7 +282,7 @@ DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 "\n", DPxPTR(host_ptr), device_id); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return OFFLOAD_FAIL; } @@ -355,7 +355,7 @@ DP("Entering target region with entry point " DPxMOD " and device Id %" PRId64 "\n", DPxPTR(host_ptr), device_id); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return OFFLOAD_FAIL; } @@ -429,7 +429,7 @@ EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *loc, int64_t device_id, uint64_t loop_tripcount) { TIMESCOPE_WITH_IDENT(loc); - if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { + if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); return; } diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -270,18 +270,19 @@ // If offload is enabled, ensure that device DeviceID has been initialized, // global ctors have been executed, and global data has been mapped. // +// The return bool indicates if the offload is to the host device // There are three possible results: -// - Return OFFLOAD_SUCCESS if the device is ready for offload. -// - Return OFFLOAD_FAIL without reporting a runtime error if offload is +// - Return false if the taregt device is ready for offload +// - Return true without reporting a runtime error if offload is // disabled, perhaps because the initial device was specified. -// - Report a runtime error and return OFFLOAD_FAIL. +// - Report a runtime error and return true. // // If DeviceID == OFFLOAD_DEVICE_DEFAULT, set DeviceID to the default device. // This step might be skipped if offload is disabled. -int checkDeviceAndCtors(int64_t &DeviceID, ident_t *Loc) { +bool checkDeviceAndCtors(int64_t &DeviceID, ident_t *Loc) { if (isOffloadDisabled()) { DP("Offload is disabled\n"); - return OFFLOAD_FAIL; + return true; } if (DeviceID == OFFLOAD_DEVICE_DEFAULT) { @@ -293,20 +294,20 @@ if (omp_get_num_devices() == 0) { DP("omp_get_num_devices() == 0 but offload is manadatory\n"); handleTargetOutcome(false, Loc); - return OFFLOAD_FAIL; + return true; } if (DeviceID == omp_get_initial_device()) { DP("Device is host (%" PRId64 "), returning as if offload is disabled\n", DeviceID); - return OFFLOAD_FAIL; + return true; } // Is device ready? if (!device_is_ready(DeviceID)) { REPORT("Device %" PRId64 " is not ready.\n", DeviceID); handleTargetOutcome(false, Loc); - return OFFLOAD_FAIL; + return true; } // Get device info. @@ -319,10 +320,10 @@ if (hasPendingGlobals && InitLibrary(Device) != OFFLOAD_SUCCESS) { REPORT("Failed to init globals on device %" PRId64 "\n", DeviceID); handleTargetOutcome(false, Loc); - return OFFLOAD_FAIL; + return true; } - return OFFLOAD_SUCCESS; + return false; } static int32_t getParentIndex(int64_t type) { diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -45,7 +45,7 @@ int IsTeamConstruct, AsyncInfoTy &AsyncInfo); extern void handleTargetOutcome(bool Success, ident_t *Loc); -extern int checkDeviceAndCtors(int64_t &DeviceID, ident_t *Loc); +extern bool checkDeviceAndCtors(int64_t &DeviceID, ident_t *Loc); extern void *targetAllocExplicit(size_t size, int device_num, int kind, const char *name);