[Offload] Debug message update part 1 (#171672)
Update debug messages based on the new method from #170425. Updated the following files. - libomptarget/LegacyAPI.cpp - libomptarget/OpenMP/API.cpp - libomptarget/OpenMP/InteropAPI.cpp
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#ifdef OMPT_SUPPORT
|
||||
using namespace llvm::omp::target::ompt;
|
||||
#endif
|
||||
using namespace llvm::omp::target::debug;
|
||||
|
||||
EXTERN void __tgt_target_data_begin(int64_t DeviceId, int32_t ArgNum,
|
||||
void **ArgsBase, void **Args,
|
||||
@@ -180,7 +181,8 @@ EXTERN int __tgt_target_teams_nowait_mapper(
|
||||
EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *Loc, int64_t DeviceId,
|
||||
uint64_t LoopTripcount) {
|
||||
TIMESCOPE_WITH_IDENT(Loc);
|
||||
DP("WARNING: __kmpc_push_target_tripcount has been deprecated and is a noop");
|
||||
ODBG(ODT_Interface) << "WARNING: " << __func__
|
||||
<< " has been deprecated and is a noop";
|
||||
}
|
||||
|
||||
EXTERN void __kmpc_push_target_tripcount(int64_t DeviceId,
|
||||
|
||||
@@ -39,6 +39,7 @@ EXTERN void ompx_dump_mapping_tables() {
|
||||
#ifdef OMPT_SUPPORT
|
||||
using namespace llvm::omp::target::ompt;
|
||||
#endif
|
||||
using namespace llvm::omp::target::debug;
|
||||
|
||||
using GenericDeviceTy = llvm::omp::target::plugin::GenericDeviceTy;
|
||||
|
||||
@@ -55,7 +56,7 @@ EXTERN int omp_get_num_devices(void) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
size_t NumDevices = PM->getNumDevices();
|
||||
|
||||
DP("Call to omp_get_num_devices returning %zd\n", NumDevices);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning " << NumDevices;
|
||||
|
||||
return NumDevices;
|
||||
}
|
||||
@@ -65,7 +66,7 @@ EXTERN int omp_get_device_num(void) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
int HostDevice = omp_get_initial_device();
|
||||
|
||||
DP("Call to omp_get_device_num returning %d\n", HostDevice);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning " << HostDevice;
|
||||
|
||||
return HostDevice;
|
||||
}
|
||||
@@ -79,12 +80,14 @@ EXTERN int omp_get_device_from_uid(const char *DeviceUid) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
|
||||
if (!DeviceUid) {
|
||||
DP("Call to omp_get_device_from_uid returning omp_invalid_device\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " returning omp_invalid_device";
|
||||
return omp_invalid_device;
|
||||
}
|
||||
if (is_initial_device_uid(DeviceUid)) {
|
||||
DP("Call to omp_get_device_from_uid returning initial device number %d\n",
|
||||
omp_get_initial_device());
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " returning initial device number "
|
||||
<< omp_get_initial_device();
|
||||
return omp_get_initial_device();
|
||||
}
|
||||
|
||||
@@ -99,7 +102,7 @@ EXTERN int omp_get_device_from_uid(const char *DeviceUid) {
|
||||
}
|
||||
}
|
||||
|
||||
DP("Call to omp_get_device_from_uid returning %d\n", DeviceNum);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning " << DeviceNum;
|
||||
return DeviceNum;
|
||||
}
|
||||
|
||||
@@ -108,11 +111,12 @@ EXTERN const char *omp_get_uid_from_device(int DeviceNum) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
|
||||
if (DeviceNum == omp_invalid_device) {
|
||||
DP("Call to omp_get_uid_from_device returning nullptr\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning nullptr";
|
||||
return nullptr;
|
||||
}
|
||||
if (DeviceNum == omp_get_initial_device()) {
|
||||
DP("Call to omp_get_uid_from_device returning initial device UID\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " returning initial device UID";
|
||||
return GenericPluginTy::getHostDeviceUid();
|
||||
}
|
||||
|
||||
@@ -122,7 +126,7 @@ EXTERN const char *omp_get_uid_from_device(int DeviceNum) {
|
||||
|
||||
const char *Uid =
|
||||
DeviceOrErr->RTL->getDevice(DeviceOrErr->RTLDeviceID).getDeviceUid();
|
||||
DP("Call to omp_get_uid_from_device returning %s\n", Uid);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning " << Uid;
|
||||
return Uid;
|
||||
}
|
||||
|
||||
@@ -130,7 +134,7 @@ EXTERN int omp_get_initial_device(void) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
int HostDevice = omp_get_num_devices();
|
||||
DP("Call to omp_get_initial_device returning %d\n", HostDevice);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returning " << HostDevice;
|
||||
return HostDevice;
|
||||
}
|
||||
|
||||
@@ -201,16 +205,17 @@ EXTERN void llvm_omp_target_unlock_mem(void *Ptr, int DeviceNum) {
|
||||
EXTERN int omp_target_is_present(const void *Ptr, int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_is_present for device %d and address " DPxMOD "\n",
|
||||
DeviceNum, DPxPTR(Ptr));
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " for device " << DeviceNum
|
||||
<< " and address " << Ptr;
|
||||
|
||||
if (!Ptr) {
|
||||
DP("Call to omp_target_is_present with NULL ptr, returning false\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " with NULL ptr, returning false";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DeviceNum == omp_get_initial_device()) {
|
||||
DP("Call to omp_target_is_present on host, returning true\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " on host, returning true";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -227,7 +232,7 @@ EXTERN int omp_target_is_present(const void *Ptr, int DeviceNum) {
|
||||
/*UpdateRefCount=*/false,
|
||||
/*UseHoldRefCount=*/false);
|
||||
int Rc = TPR.isPresent();
|
||||
DP("Call to omp_target_is_present returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
@@ -237,17 +242,17 @@ EXTERN int omp_target_is_accessible(const void *Ptr, size_t Size,
|
||||
int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_is_accessible for device %d, address " DPxMOD
|
||||
", size %zu\n",
|
||||
DeviceNum, DPxPTR(Ptr), Size);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " for device " << DeviceNum
|
||||
<< ", address " << Ptr << ", size " << Size;
|
||||
|
||||
if (!Ptr) {
|
||||
DP("Call to omp_target_is_accessible with NULL ptr returning false\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " with NULL ptr returning false";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DeviceNum == omp_get_initial_device() || DeviceNum == -1) {
|
||||
DP("Call to omp_target_is_accessible on host, returning true\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " on host, returning true";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -266,19 +271,19 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
|
||||
";src_dev=" + std::to_string(SrcDevice) +
|
||||
";size=" + std::to_string(Length));
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memcpy, dst device %d, src device %d, "
|
||||
"dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, "
|
||||
"src offset %zu, length %zu\n",
|
||||
DstDevice, SrcDevice, DPxPTR(Dst), DPxPTR(Src), DstOffset, SrcOffset,
|
||||
Length);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", dst device " << DstDevice
|
||||
<< ", src device " << SrcDevice << ", dst addr " << Dst
|
||||
<< ", src addr " << Src << ", dst offset " << DstOffset
|
||||
<< ", src offset " << SrcOffset << ", length " << Length;
|
||||
|
||||
if (!Dst || !Src || Length <= 0) {
|
||||
if (Length == 0) {
|
||||
DP("Call to omp_target_memcpy with zero length, nothing to do\n");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " with zero length, nothing to do";
|
||||
return OFFLOAD_SUCCESS;
|
||||
}
|
||||
|
||||
REPORT("Call to omp_target_memcpy with invalid arguments\n");
|
||||
REPORT() << "Call to " << __func__ << " with invalid arguments";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
@@ -288,12 +293,12 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
|
||||
|
||||
if (SrcDevice == omp_get_initial_device() &&
|
||||
DstDevice == omp_get_initial_device()) {
|
||||
DP("copy from host to host\n");
|
||||
ODBG(ODT_Interface) << "copy from host to host";
|
||||
const void *P = memcpy(DstAddr, SrcAddr, Length);
|
||||
if (P == NULL)
|
||||
Rc = OFFLOAD_FAIL;
|
||||
} else if (SrcDevice == omp_get_initial_device()) {
|
||||
DP("copy from host to device\n");
|
||||
ODBG(ODT_Interface) << "copy from host to device";
|
||||
auto DstDeviceOrErr = PM->getDevice(DstDevice);
|
||||
if (!DstDeviceOrErr)
|
||||
FATAL_MESSAGE(DstDevice, "%s",
|
||||
@@ -301,7 +306,7 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
|
||||
AsyncInfoTy AsyncInfo(*DstDeviceOrErr);
|
||||
Rc = DstDeviceOrErr->submitData(DstAddr, SrcAddr, Length, AsyncInfo);
|
||||
} else if (DstDevice == omp_get_initial_device()) {
|
||||
DP("copy from device to host\n");
|
||||
ODBG(ODT_Interface) << "copy from device to host";
|
||||
auto SrcDeviceOrErr = PM->getDevice(SrcDevice);
|
||||
if (!SrcDeviceOrErr)
|
||||
FATAL_MESSAGE(SrcDevice, "%s",
|
||||
@@ -309,7 +314,7 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
|
||||
AsyncInfoTy AsyncInfo(*SrcDeviceOrErr);
|
||||
Rc = SrcDeviceOrErr->retrieveData(DstAddr, SrcAddr, Length, AsyncInfo);
|
||||
} else {
|
||||
DP("copy from device to device\n");
|
||||
ODBG(ODT_Interface) << "copy from device to device";
|
||||
auto SrcDeviceOrErr = PM->getDevice(SrcDevice);
|
||||
if (!SrcDeviceOrErr)
|
||||
FATAL_MESSAGE(SrcDevice, "%s",
|
||||
@@ -341,7 +346,7 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
|
||||
free(Buffer);
|
||||
}
|
||||
|
||||
DP("omp_target_memcpy returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
@@ -364,12 +369,12 @@ static int libomp_target_memcpy_async_task(int32_t Gtid, kmp_task_t *Task) {
|
||||
Args->DstOffsets, Args->SrcOffsets, Args->DstDimensions,
|
||||
Args->SrcDimensions, Args->DstDevice, Args->SrcDevice);
|
||||
|
||||
DP("omp_target_memcpy_rect returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << " omp_target_memcpy_rect returns " << Rc;
|
||||
} else {
|
||||
Rc = omp_target_memcpy(Args->Dst, Args->Src, Args->Length, Args->DstOffset,
|
||||
Args->SrcOffset, Args->DstDevice, Args->SrcDevice);
|
||||
|
||||
DP("omp_target_memcpy returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << " omp_target_memcpy returns " << Rc;
|
||||
}
|
||||
|
||||
// Release the arguments object
|
||||
@@ -443,8 +448,8 @@ EXTERN void *omp_target_memset(void *Ptr, int ByteVal, size_t NumBytes,
|
||||
int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memset, device %d, device pointer %p, size %zu\n",
|
||||
DeviceNum, Ptr, NumBytes);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", device " << DeviceNum
|
||||
<< ", device pointer " << Ptr << ", size " << NumBytes;
|
||||
|
||||
// Behave as a no-op if N==0 or if Ptr is nullptr (as a useful implementation
|
||||
// of unspecified behavior, see OpenMP spec).
|
||||
@@ -453,7 +458,7 @@ EXTERN void *omp_target_memset(void *Ptr, int ByteVal, size_t NumBytes,
|
||||
}
|
||||
|
||||
if (DeviceNum == omp_get_initial_device()) {
|
||||
DP("filling memory on host via memset");
|
||||
ODBG(ODT_Interface) << "filling memory on host via memset";
|
||||
memset(Ptr, ByteVal, NumBytes); // ignore return value, memset() cannot fail
|
||||
} else {
|
||||
// TODO: replace the omp_target_memset() slow path with the fast path.
|
||||
@@ -473,12 +478,13 @@ EXTERN void *omp_target_memset(void *Ptr, int ByteVal, size_t NumBytes,
|
||||
// If the omp_target_alloc has failed, let's just not do anything.
|
||||
// omp_target_memset does not have any good way to fail, so we
|
||||
// simply avoid a catastrophic failure of the process for now.
|
||||
DP("omp_target_memset failed to fill memory due to error with "
|
||||
"omp_target_alloc");
|
||||
ODBG(ODT_Interface)
|
||||
<< __func__
|
||||
<< " failed to fill memory due to error with omp_target_alloc";
|
||||
}
|
||||
}
|
||||
|
||||
DP("omp_target_memset returns %p\n", Ptr);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Ptr;
|
||||
return Ptr;
|
||||
}
|
||||
|
||||
@@ -486,8 +492,8 @@ EXTERN void *omp_target_memset_async(void *Ptr, int ByteVal, size_t NumBytes,
|
||||
int DeviceNum, int DepObjCount,
|
||||
omp_depend_t *DepObjList) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memset_async, device %d, device pointer %p, size %zu",
|
||||
DeviceNum, Ptr, NumBytes);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", device " << DeviceNum
|
||||
<< ", device pointer " << Ptr << ", size " << NumBytes;
|
||||
|
||||
// Behave as a no-op if N==0 or if Ptr is nullptr (as a useful implementation
|
||||
// of unspecified behavior, see OpenMP spec).
|
||||
@@ -513,11 +519,10 @@ EXTERN int omp_target_memcpy_async(void *Dst, const void *Src, size_t Length,
|
||||
";src_dev=" + std::to_string(SrcDevice) +
|
||||
";size=" + std::to_string(Length));
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memcpy_async, dst device %d, src device %d, "
|
||||
"dst addr " DPxMOD ", src addr " DPxMOD ", dst offset %zu, "
|
||||
"src offset %zu, length %zu\n",
|
||||
DstDevice, SrcDevice, DPxPTR(Dst), DPxPTR(Src), DstOffset, SrcOffset,
|
||||
Length);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", dst device " << DstDevice
|
||||
<< ", src device " << SrcDevice << ", dst addr " << Dst
|
||||
<< ", src addr " << Src << ", dst offset " << DstOffset
|
||||
<< ", src offset " << SrcOffset << ", length " << Length;
|
||||
|
||||
// Check the source and dest address
|
||||
if (Dst == nullptr || Src == nullptr)
|
||||
@@ -531,7 +536,7 @@ EXTERN int omp_target_memcpy_async(void *Dst, const void *Src, size_t Length,
|
||||
int Rc = libomp_helper_task_creation(Args, &libomp_target_memcpy_async_task,
|
||||
DepObjCount, DepObjList);
|
||||
|
||||
DP("omp_target_memcpy_async returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
@@ -542,23 +547,23 @@ omp_target_memcpy_rect(void *Dst, const void *Src, size_t ElementSize,
|
||||
const size_t *DstDimensions, const size_t *SrcDimensions,
|
||||
int DstDevice, int SrcDevice) {
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memcpy_rect, dst device %d, src device %d, "
|
||||
"dst addr " DPxMOD ", src addr " DPxMOD ", dst offsets " DPxMOD ", "
|
||||
"src offsets " DPxMOD ", dst dims " DPxMOD ", src dims " DPxMOD ", "
|
||||
"volume " DPxMOD ", element size %zu, num_dims %d\n",
|
||||
DstDevice, SrcDevice, DPxPTR(Dst), DPxPTR(Src), DPxPTR(DstOffsets),
|
||||
DPxPTR(SrcOffsets), DPxPTR(DstDimensions), DPxPTR(SrcDimensions),
|
||||
DPxPTR(Volume), ElementSize, NumDims);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", dst device " << DstDevice
|
||||
<< ", src device " << SrcDevice << ", dst addr " << Dst
|
||||
<< ", src addr " << Src << ", dst offsets " << DstOffsets
|
||||
<< ", src offsets " << SrcOffsets << ", dst dims "
|
||||
<< DstDimensions << ", src dims " << SrcDimensions
|
||||
<< ", volume " << Volume << ", element size "
|
||||
<< ElementSize << ", num_dims " << NumDims;
|
||||
|
||||
if (!(Dst || Src)) {
|
||||
DP("Call to omp_target_memcpy_rect returns max supported dimensions %d\n",
|
||||
INT_MAX);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " returns max supported dimensions " << INT_MAX;
|
||||
return INT_MAX;
|
||||
}
|
||||
|
||||
if (!Dst || !Src || ElementSize < 1 || NumDims < 1 || !Volume ||
|
||||
!DstOffsets || !SrcOffsets || !DstDimensions || !SrcDimensions) {
|
||||
REPORT("Call to omp_target_memcpy_rect with invalid arguments\n");
|
||||
REPORT() << "Call to " << __func__ << " with invalid arguments";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
@@ -585,13 +590,14 @@ omp_target_memcpy_rect(void *Dst, const void *Src, size_t ElementSize,
|
||||
DstDimensions + 1, SrcDimensions + 1, DstDevice, SrcDevice);
|
||||
|
||||
if (Rc) {
|
||||
DP("Recursive call to omp_target_memcpy_rect returns unsuccessfully\n");
|
||||
ODBG(ODT_Interface)
|
||||
<< "Recursive call to " << __func__ << " returns unsuccessfully";
|
||||
return Rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DP("omp_target_memcpy_rect returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
@@ -605,18 +611,18 @@ EXTERN int omp_target_memcpy_rect_async(
|
||||
";size=" + std::to_string(ElementSize) +
|
||||
";num_dims=" + std::to_string(NumDims));
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_memcpy_rect_async, dst device %d, src device %d, "
|
||||
"dst addr " DPxMOD ", src addr " DPxMOD ", dst offsets " DPxMOD ", "
|
||||
"src offsets " DPxMOD ", dst dims " DPxMOD ", src dims " DPxMOD ", "
|
||||
"volume " DPxMOD ", element size %zu, num_dims %d\n",
|
||||
DstDevice, SrcDevice, DPxPTR(Dst), DPxPTR(Src), DPxPTR(DstOffsets),
|
||||
DPxPTR(SrcOffsets), DPxPTR(DstDimensions), DPxPTR(SrcDimensions),
|
||||
DPxPTR(Volume), ElementSize, NumDims);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << ", dst device " << DstDevice
|
||||
<< ", src device " << SrcDevice << ", dst addr " << Dst
|
||||
<< ", src addr " << Src << ", dst offsets " << DstOffsets
|
||||
<< ", src offsets " << SrcOffsets << ", dst dims "
|
||||
<< DstDimensions << ", src dims " << SrcDimensions
|
||||
<< ", volume " << Volume << ", element size "
|
||||
<< ElementSize << ", num_dims " << NumDims;
|
||||
|
||||
// Need to check this first to not return OFFLOAD_FAIL instead
|
||||
if (!Dst && !Src) {
|
||||
DP("Call to omp_target_memcpy_rect returns max supported dimensions %d\n",
|
||||
INT_MAX);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__
|
||||
<< " returns max supported dimensions " << INT_MAX;
|
||||
return INT_MAX;
|
||||
}
|
||||
|
||||
@@ -633,7 +639,7 @@ EXTERN int omp_target_memcpy_rect_async(
|
||||
int Rc = libomp_helper_task_creation(Args, &libomp_target_memcpy_async_task,
|
||||
DepObjCount, DepObjList);
|
||||
|
||||
DP("omp_target_memcpy_rect_async returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
@@ -642,17 +648,18 @@ EXTERN int omp_target_associate_ptr(const void *HostPtr, const void *DevicePtr,
|
||||
int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_associate_ptr with host_ptr " DPxMOD ", "
|
||||
"device_ptr " DPxMOD ", size %zu, device_offset %zu, device_num %d\n",
|
||||
DPxPTR(HostPtr), DPxPTR(DevicePtr), Size, DeviceOffset, DeviceNum);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with host_ptr " << HostPtr
|
||||
<< ", device_ptr " << DevicePtr << ", size " << Size
|
||||
<< ", device_offset " << DeviceOffset << ", device_num "
|
||||
<< DeviceNum;
|
||||
|
||||
if (!HostPtr || !DevicePtr || Size <= 0) {
|
||||
REPORT("Call to omp_target_associate_ptr with invalid arguments\n");
|
||||
REPORT() << "Call to " << __func__ << " with invalid arguments";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
if (DeviceNum == omp_get_initial_device()) {
|
||||
REPORT("omp_target_associate_ptr: no association possible on the host\n");
|
||||
REPORT() << __func__ << ": no association possible on the host";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
@@ -669,25 +676,23 @@ EXTERN int omp_target_associate_ptr(const void *HostPtr, const void *DevicePtr,
|
||||
|
||||
int Rc = DeviceOrErr->getMappingInfo().associatePtr(
|
||||
const_cast<void *>(HostPtr), const_cast<void *>(DeviceAddr), Size);
|
||||
DP("omp_target_associate_ptr returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
EXTERN int omp_target_disassociate_ptr(const void *HostPtr, int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_target_disassociate_ptr with host_ptr " DPxMOD ", "
|
||||
"device_num %d\n",
|
||||
DPxPTR(HostPtr), DeviceNum);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with host_ptr " << HostPtr
|
||||
<< ", device_num " << DeviceNum;
|
||||
|
||||
if (!HostPtr) {
|
||||
REPORT("Call to omp_target_associate_ptr with invalid host_ptr\n");
|
||||
REPORT() << "Call to " << __func__ << " with invalid host_ptr";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
if (DeviceNum == omp_get_initial_device()) {
|
||||
REPORT(
|
||||
"omp_target_disassociate_ptr: no association possible on the host\n");
|
||||
REPORT() << __func__ << ": no association possible on the host";
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
@@ -702,30 +707,31 @@ EXTERN int omp_target_disassociate_ptr(const void *HostPtr, int DeviceNum) {
|
||||
|
||||
int Rc = DeviceOrErr->getMappingInfo().disassociatePtr(
|
||||
const_cast<void *>(HostPtr));
|
||||
DP("omp_target_disassociate_ptr returns %d\n", Rc);
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << Rc;
|
||||
return Rc;
|
||||
}
|
||||
|
||||
EXTERN void *omp_get_mapped_ptr(const void *Ptr, int DeviceNum) {
|
||||
TIMESCOPE();
|
||||
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
|
||||
DP("Call to omp_get_mapped_ptr with ptr " DPxMOD ", device_num %d.\n",
|
||||
DPxPTR(Ptr), DeviceNum);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with ptr " << Ptr
|
||||
<< ", device_num " << DeviceNum;
|
||||
|
||||
if (!Ptr) {
|
||||
REPORT("Call to omp_get_mapped_ptr with nullptr.\n");
|
||||
REPORT() << "Call to " << __func__ << " with nullptr.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int NumDevices = omp_get_initial_device();
|
||||
if (DeviceNum == NumDevices) {
|
||||
DP("Device %d is initial device, returning Ptr " DPxMOD ".\n", DeviceNum,
|
||||
DPxPTR(Ptr));
|
||||
ODBG(ODT_Interface) << "Device " << DeviceNum
|
||||
<< " is initial device, returning Ptr " << Ptr;
|
||||
return const_cast<void *>(Ptr);
|
||||
}
|
||||
|
||||
if (NumDevices <= DeviceNum) {
|
||||
DP("DeviceNum %d is invalid, returning nullptr.\n", DeviceNum);
|
||||
ODBG(ODT_Interface) << "DeviceNum " << DeviceNum
|
||||
<< " is invalid, returning nullptr.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -738,12 +744,12 @@ EXTERN void *omp_get_mapped_ptr(const void *Ptr, int DeviceNum) {
|
||||
/*UpdateRefCount=*/false,
|
||||
/*UseHoldRefCount=*/false);
|
||||
if (!TPR.isPresent()) {
|
||||
DP("Ptr " DPxMOD "is not present on device %d, returning nullptr.\n",
|
||||
DPxPTR(Ptr), DeviceNum);
|
||||
ODBG(ODT_Interface) << "Ptr " << Ptr
|
||||
<< "is not present on device %d, returning nullptr.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DP("omp_get_mapped_ptr returns " DPxMOD ".\n", DPxPTR(TPR.TargetPointer));
|
||||
ODBG(ODT_Interface) << __func__ << " returns " << TPR.TargetPointer << ".";
|
||||
|
||||
return TPR.TargetPointer;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace llvm::omp::target::debug;
|
||||
|
||||
namespace {
|
||||
omp_interop_rc_t getPropertyErrorType(omp_interop_property_t Property) {
|
||||
switch (Property) {
|
||||
@@ -191,11 +193,11 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
interop_spec_t *Prefers,
|
||||
interop_ctx_t *Ctx, dep_pack_t *Deps) {
|
||||
|
||||
DP("Call to %s with device_num %" PRId64 ", interop type %" PRId32
|
||||
", number of preferred specs %" PRId32 "%s%s\n",
|
||||
__func__, DeviceNum, InteropType, NumPrefers,
|
||||
Ctx->flags.implicit ? " (implicit)" : "",
|
||||
Ctx->flags.nowait ? " (nowait)" : "");
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with device_num "
|
||||
<< DeviceNum << ", interop type " << InteropType
|
||||
<< ", number of preferred specs " << NumPrefers
|
||||
<< (Ctx->flags.implicit ? " (implicit)" : "")
|
||||
<< (Ctx->flags.nowait ? " (nowait)" : "");
|
||||
|
||||
if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED)
|
||||
return omp_interop_none;
|
||||
@@ -208,8 +210,8 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
|
||||
if (InteropType == kmp_interop_type_targetsync) {
|
||||
if (Ctx->flags.nowait)
|
||||
DP("Warning: nowait flag on interop creation not supported yet. "
|
||||
"Ignored\n");
|
||||
ODBG(ODT_Interface) << "Warning: nowait flag on interop creation not "
|
||||
"supported yet. Ignored";
|
||||
if (Deps)
|
||||
__kmpc_omp_wait_deps(LocRef, gtid, Deps->ndeps, Deps->deplist,
|
||||
Deps->ndeps_noalias, Deps->noalias_deplist);
|
||||
@@ -217,9 +219,9 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
|
||||
auto DeviceOrErr = PM->getDevice(DeviceNum);
|
||||
if (!DeviceOrErr) {
|
||||
DP("Couldn't find device %" PRId64
|
||||
" while constructing interop object: %s\n",
|
||||
DeviceNum, toString(DeviceOrErr.takeError()).c_str());
|
||||
ODBG(ODT_Interface) << "Couldn't find device " << DeviceNum
|
||||
<< " while constructing interop object: "
|
||||
<< toString(DeviceOrErr.takeError());
|
||||
return omp_interop_none;
|
||||
}
|
||||
auto &Device = *DeviceOrErr;
|
||||
@@ -227,12 +229,15 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
auto InteropSpec = Device.RTL->select_interop_preference(
|
||||
DeviceNum, InteropType, NumPrefers, Prefers);
|
||||
if (InteropSpec.fr_id == tgt_fr_none) {
|
||||
DP("Interop request not supported by device %" PRId64 "\n", DeviceNum);
|
||||
ODBG(ODT_Interface) << "Interop request not supported by device "
|
||||
<< DeviceNum;
|
||||
return omp_interop_none;
|
||||
}
|
||||
DP("Selected interop preference is fr_id=%s%s impl_attrs=%" PRId64 "\n",
|
||||
getForeignRuntimeIdToStr((tgt_foreign_runtime_id_t)InteropSpec.fr_id),
|
||||
InteropSpec.attrs.inorder ? " inorder" : "", InteropSpec.impl_attrs);
|
||||
ODBG(ODT_Interface) << "Selected interop preference is fr_id="
|
||||
<< getForeignRuntimeIdToStr(
|
||||
(tgt_foreign_runtime_id_t)InteropSpec.fr_id)
|
||||
<< (InteropSpec.attrs.inorder ? " inorder" : "")
|
||||
<< " impl_attrs=" << InteropSpec.impl_attrs;
|
||||
|
||||
if (Ctx->flags.implicit) {
|
||||
// This is a request for an RTL managed interop object.
|
||||
@@ -241,17 +246,17 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
if (iop->isCompatibleWith(InteropType, InteropSpec, DeviceNum, gtid)) {
|
||||
Interop = iop;
|
||||
Interop->markDirty();
|
||||
DP("Reused interop " DPxMOD " from device number %" PRId64
|
||||
" for gtid %" PRId32 "\n",
|
||||
DPxPTR(Interop), DeviceNum, gtid);
|
||||
ODBG(ODT_Interface)
|
||||
<< "Reused interop " << Interop << " from device number "
|
||||
<< DeviceNum << " for gtid " << gtid;
|
||||
return Interop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Interop = Device.RTL->create_interop(DeviceNum, InteropType, &InteropSpec);
|
||||
DP("Created an interop " DPxMOD " from device number %" PRId64 "\n",
|
||||
DPxPTR(Interop), DeviceNum);
|
||||
ODBG(ODT_Interface) << "Created an interop " << Interop
|
||||
<< " from device number " << DeviceNum;
|
||||
|
||||
if (Ctx->flags.implicit) {
|
||||
// register the new implicit interop in the RTL
|
||||
@@ -268,16 +273,17 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
|
||||
int __tgt_interop_use60(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
interop_ctx_t *Ctx, dep_pack_t *Deps) {
|
||||
bool Nowait = Ctx->flags.nowait;
|
||||
DP("Call to %s with interop " DPxMOD ", nowait %" PRId32 "\n", __func__,
|
||||
DPxPTR(Interop), Nowait);
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with interop " << Interop
|
||||
<< ", nowait " << Nowait;
|
||||
if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop)
|
||||
return OFFLOAD_FAIL;
|
||||
|
||||
if (Interop->interop_type == kmp_interop_type_targetsync) {
|
||||
if (Deps) {
|
||||
if (Nowait) {
|
||||
DP("Warning: nowait flag on interop use with dependences not supported"
|
||||
"yet. Ignored\n");
|
||||
ODBG(ODT_Interface)
|
||||
<< "Warning: nowait flag on interop use with dependences "
|
||||
"not supported yet. Ignored";
|
||||
Nowait = false;
|
||||
}
|
||||
|
||||
@@ -288,8 +294,8 @@ int __tgt_interop_use60(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
|
||||
auto DeviceOrErr = Interop->getDevice();
|
||||
if (!DeviceOrErr) {
|
||||
REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(Interop),
|
||||
toString(DeviceOrErr.takeError()).c_str());
|
||||
REPORT() << "Failed to get device for interop " << Interop << ": "
|
||||
<< toString(DeviceOrErr.takeError());
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
auto &IOPDevice = *DeviceOrErr;
|
||||
@@ -309,15 +315,16 @@ int __tgt_interop_use60(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
|
||||
int __tgt_interop_release(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
interop_ctx_t *Ctx, dep_pack_t *Deps) {
|
||||
DP("Call to %s with interop " DPxMOD "\n", __func__, DPxPTR(Interop));
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with interop " << Interop;
|
||||
|
||||
if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop)
|
||||
return OFFLOAD_FAIL;
|
||||
|
||||
if (Interop->interop_type == kmp_interop_type_targetsync) {
|
||||
if (Ctx->flags.nowait)
|
||||
DP("Warning: nowait flag on interop destroy not supported "
|
||||
"yet. Ignored\n");
|
||||
ODBG(ODT_Interface)
|
||||
<< "Warning: nowait flag on interop destroy not supported yet. "
|
||||
"Ignored";
|
||||
if (Deps) {
|
||||
__kmpc_omp_wait_deps(LocRef, Ctx->gtid, Deps->ndeps, Deps->deplist,
|
||||
Deps->ndeps_noalias, Deps->noalias_deplist);
|
||||
@@ -326,8 +333,8 @@ int __tgt_interop_release(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
|
||||
auto DeviceOrErr = Interop->getDevice();
|
||||
if (!DeviceOrErr) {
|
||||
REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(Interop),
|
||||
toString(DeviceOrErr.takeError()).c_str());
|
||||
REPORT() << "Failed to get device for interop " << Interop << ": "
|
||||
<< toString(DeviceOrErr.takeError());
|
||||
return OFFLOAD_FAIL;
|
||||
}
|
||||
|
||||
@@ -337,9 +344,9 @@ int __tgt_interop_release(ident_t *LocRef, omp_interop_val_t *Interop,
|
||||
EXTERN int ompx_interop_add_completion_callback(omp_interop_val_t *Interop,
|
||||
ompx_interop_cb_t *CB,
|
||||
void *Data) {
|
||||
DP("Call to %s with interop " DPxMOD ", property callback " DPxMOD
|
||||
"and data " DPxMOD "\n",
|
||||
__func__, DPxPTR(Interop), DPxPTR(CB), DPxPTR(Data));
|
||||
ODBG(ODT_Interface) << "Call to " << __func__ << " with interop " << Interop
|
||||
<< ", property callback " << reinterpret_cast<void *>(CB)
|
||||
<< " and data " << Data;
|
||||
|
||||
if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop)
|
||||
return omp_irc_other;
|
||||
@@ -424,7 +431,7 @@ int32_t omp_interop_val_t::sync_barrier(DeviceTy &Device) {
|
||||
FATAL_MESSAGE(device_id, "Interop sync barrier failed for %p object\n",
|
||||
this);
|
||||
}
|
||||
DP("Calling completion callbacks for " DPxMOD "\n", DPxPTR(this));
|
||||
ODBG(ODT_Sync) << "Calling completion callbacks for " << this;
|
||||
runCompletionCbs();
|
||||
return OFFLOAD_SUCCESS;
|
||||
}
|
||||
@@ -445,8 +452,8 @@ void syncImplicitInterops(int Gtid, void *Event) {
|
||||
if (PM->InteropTbl.size() == 0)
|
||||
return;
|
||||
|
||||
DP("target_sync: syncing interops for gtid %" PRId32 ", event " DPxMOD "\n",
|
||||
Gtid, DPxPTR(Event));
|
||||
ODBG(ODT_Sync) << "target_sync: syncing interops for gtid " << Gtid
|
||||
<< ", event " << Event;
|
||||
|
||||
for (auto iop : PM->InteropTbl) {
|
||||
if (iop->async_info && iop->async_info->Queue && iop->isOwnedBy(Gtid) &&
|
||||
@@ -454,8 +461,8 @@ void syncImplicitInterops(int Gtid, void *Event) {
|
||||
|
||||
auto DeviceOrErr = iop->getDevice();
|
||||
if (!DeviceOrErr) {
|
||||
REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(iop),
|
||||
toString(DeviceOrErr.takeError()).c_str());
|
||||
REPORT() << "Failed to get device for interop " << iop << ": "
|
||||
<< toString(DeviceOrErr.takeError());
|
||||
continue;
|
||||
}
|
||||
auto &IOPDevice = *DeviceOrErr;
|
||||
@@ -482,12 +489,12 @@ void syncImplicitInterops(int Gtid, void *Event) {
|
||||
}
|
||||
|
||||
void InteropTblTy::clear() {
|
||||
DP("Clearing Interop Table\n");
|
||||
ODBG(ODT_Deinit) << "Clearing Interop Table";
|
||||
PerThreadTable::clear([](auto &IOP) {
|
||||
auto DeviceOrErr = IOP->getDevice();
|
||||
if (!DeviceOrErr) {
|
||||
REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(IOP),
|
||||
toString(DeviceOrErr.takeError()).c_str());
|
||||
REPORT() << "Failed to get device for interop " << IOP << ": "
|
||||
<< toString(DeviceOrErr.takeError());
|
||||
return;
|
||||
}
|
||||
IOP->release(*DeviceOrErr);
|
||||
|
||||
Reference in New Issue
Block a user