array interface
This commit is contained in:
parent
206f305b65
commit
971d3ca8cd
@ -68,33 +68,37 @@ bool ArrayInterfaceHandler::IsCudaPtr(void const* ptr) {
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
hipPointerAttribute_t attr;
|
||||
std::cerr << "Calling hipPointerGetAttributes" << std::endl;
|
||||
auto err = hipPointerGetAttributes(&attr, ptr);
|
||||
|
||||
// Reset error
|
||||
hipError_t last_error = hipGetLastError();
|
||||
if (last_error != hipSuccess) {
|
||||
LOG(WARNING) << "HIP error after hipPointerGetAttributes: "
|
||||
<< hipGetErrorString(last_error);
|
||||
}
|
||||
std::cerr << "hipPointerGetAttributes returned: " << hipGetErrorString(err) << std::endl;
|
||||
|
||||
if (err == hipErrorInvalidValue) {
|
||||
std::cerr << "Invalid pointer, returning false" << std::endl;
|
||||
return false;
|
||||
} else if (err == hipSuccess) {
|
||||
// For ROCm 6.2.2, we use the `type` field
|
||||
std::cerr << "Pointer attributes obtained successfully" << std::endl;
|
||||
std::cerr << "Memory type: " << attr.type << std::endl;
|
||||
switch (attr.type) {
|
||||
case hipMemoryTypeUnregistered:
|
||||
std::cerr << "Memory type is Unregistered, returning false" << std::endl;
|
||||
return false;
|
||||
case hipMemoryTypeHost:
|
||||
std::cerr << "Memory type is Host, returning false" << std::endl;
|
||||
return false;
|
||||
case hipMemoryTypeDevice:
|
||||
std::cerr << "Memory type is Device, returning true" << std::endl;
|
||||
return true;
|
||||
case hipMemoryTypeManaged:
|
||||
std::cerr << "Memory type is Managed, returning true" << std::endl;
|
||||
return true;
|
||||
default:
|
||||
LOG(WARNING) << "Unknown memory type: " << attr.type;
|
||||
std::cerr << "Unknown memory type: " << attr.type << std::endl;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG(WARNING) << "hipPointerGetAttributes failed with error: "
|
||||
<< hipGetErrorString(err);
|
||||
std::cerr << "hipPointerGetAttributes failed with error: "
|
||||
<< hipGetErrorString(err) << std::endl;
|
||||
return false;
|
||||
}
|
||||
#elif defined(XGBOOST_USE_CUDA)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user