This commit is contained in:
Hendrik Groove 2024-10-20 17:05:34 +02:00
parent 288193cf82
commit 7301022fed

View File

@ -62,49 +62,50 @@ void ArrayInterfaceHandler::SyncCudaStream(std::int64_t stream) {
} }
bool ArrayInterfaceHandler::IsCudaPtr(void const* ptr) { bool ArrayInterfaceHandler::IsCudaPtr(void const* ptr) {
LOG(INFO) << "Entering IsCudaPtr with ptr: " << ptr; std::cerr << "Entering IsCudaPtr with ptr: " << ptr << std::endl;
if (!ptr) { if (!ptr) {
LOG(INFO) << "Pointer is null, returning false"; std::cerr << "Pointer is null, returning false" << std::endl;
return false; return false;
} }
// Check if the pointer is within the process's address space // Check if the pointer is within the process's address space
uintptr_t ptr_value = reinterpret_cast<uintptr_t>(ptr); uintptr_t ptr_value = reinterpret_cast<uintptr_t>(ptr);
uintptr_t process_max_addr = (uintptr_t)-1; uintptr_t process_max_addr = (uintptr_t)-1;
LOG(INFO) << "Pointer value: " << ptr_value << ", Max address: " << process_max_addr; std::cerr << "Pointer value: " << ptr_value << ", Max address: " << process_max_addr << std::endl;
#if defined(XGBOOST_USE_HIP) #if defined(XGBOOST_USE_HIP)
hipPointerAttribute_t attr; hipPointerAttribute_t attr;
LOG(INFO) << "Calling hipPointerGetAttributes"; std::cerr << "Calling hipPointerGetAttributes" << std::endl;
auto err = hipPointerGetAttributes(&attr, ptr); auto err = hipPointerGetAttributes(&attr, ptr);
LOG(INFO) << "hipPointerGetAttributes returned: " << hipGetErrorString(err); std::cerr << "hipPointerGetAttributes returned: " << hipGetErrorString(err) << std::endl;
if (err == hipErrorInvalidValue) { if (err == hipErrorInvalidValue) {
LOG(INFO) << "Invalid pointer (hipErrorInvalidValue), returning false"; std::cerr << "Invalid pointer (hipErrorInvalidValue), returning false" << std::endl;
return false; return false;
} else if (err == hipSuccess) { } else if (err == hipSuccess) {
LOG(INFO) << "Pointer attributes obtained successfully"; std::cerr << "Pointer attributes obtained successfully" << std::endl;
LOG(INFO) << "Memory type: " << attr.type; std::cerr << "Memory type: " << attr.type << std::endl;
switch (attr.type) { switch (attr.type) {
case hipMemoryTypeUnregistered: case hipMemoryTypeUnregistered:
LOG(INFO) << "Memory type is Unregistered, returning false"; std::cerr << "Memory type is Unregistered, returning false" << std::endl;
return false; return false;
case hipMemoryTypeHost: case hipMemoryTypeHost:
LOG(INFO) << "Memory type is Host, returning false"; std::cerr << "Memory type is Host, returning false" << std::endl;
return false; return false;
case hipMemoryTypeDevice: case hipMemoryTypeDevice:
LOG(INFO) << "Memory type is Device, returning true"; std::cerr << "Memory type is Device, returning true" << std::endl;
return true; return true;
case hipMemoryTypeManaged: case hipMemoryTypeManaged:
LOG(INFO) << "Memory type is Managed, returning true"; std::cerr << "Memory type is Managed, returning true" << std::endl;
return true; return true;
default: default:
LOG(WARNING) << "Unknown memory type: " << attr.type; std::cerr << "Unknown memory type: " << attr.type << std::endl;
return true; return false;
} }
} else { } else {
LOG(WARNING) << "hipPointerGetAttributes failed with error: " std::cerr << "hipPointerGetAttributes failed with error: "
<< hipGetErrorString(err); << hipGetErrorString(err) << std::endl;
return false; return false;
} }
#elif defined(XGBOOST_USE_CUDA) #elif defined(XGBOOST_USE_CUDA)