What is exactly needed is only a boolean. Pulling OFFLOAD_SUCCESS/FAIL only adds confusion.
Differential Revision: https://reviews.llvm.org/D109303
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
// 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) {
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.
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) {
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);