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 @@ -21,6 +21,18 @@ #include #include +/// return flags of __tgt_target_XXX public APIs +enum __tgt_target_return_t : int { + /// successful offload executed on a target device + OMP_TGT_SUCCESS = 0, + /// offload may not execute on the requested target device + /// this scenario can be caused by the device not available or unsupported + /// as described in the Execution Model in the specifcation + /// this status may not be used for target device execution failure + /// which should be handled internally in libomptarget + OMP_TGT_FAIL = ~0 +}; + //////////////////////////////////////////////////////////////////////////////// /// adds requires flags EXTERN void __tgt_register_requires(int64_t flags) { @@ -284,7 +296,7 @@ DPxPTR(host_ptr), device_id); if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); - return OFFLOAD_FAIL; + return OMP_TGT_FAIL; } if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) @@ -307,7 +319,8 @@ if (rc == OFFLOAD_SUCCESS) rc = AsyncInfo.synchronize(); handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); - return rc; + assert(rc == OFFLOAD_SUCCESS && "__tgt_target_mapper unexpected failure!"); + return OMP_TGT_SUCCESS; } EXTERN int __tgt_target_nowait_mapper( @@ -357,7 +370,7 @@ DPxPTR(host_ptr), device_id); if (checkDeviceAndCtors(device_id, loc)) { DP("Not offloading to device %" PRId64 "\n", device_id); - return OFFLOAD_FAIL; + return OMP_TGT_FAIL; } if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) @@ -380,7 +393,9 @@ if (rc == OFFLOAD_SUCCESS) rc = AsyncInfo.synchronize(); handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); - return rc; + assert(rc == OFFLOAD_SUCCESS && + "__tgt_target_teams_mapper unexpected failure!"); + return OMP_TGT_SUCCESS; } EXTERN int __tgt_target_teams_nowait_mapper(