fix Pointer Attr

This commit is contained in:
amdsc21 2023-03-10 19:06:02 +01:00
parent 9f072b50ba
commit 5e8b1842b9
3 changed files with 27 additions and 6 deletions

View File

@ -4,13 +4,13 @@ python mapfeat.py
# split train and test # split train and test
python mknfold.py machine.txt 1 python mknfold.py machine.txt 1
# training and output the models # training and output the models
../../xgboost machine.conf ../../../xgboost machine.conf
# output predictions of test data # output predictions of test data
../../xgboost machine.conf task=pred model_in=0002.model ../../../xgboost machine.conf task=pred model_in=0002.model
# print the boosters of 0002.model in dump.raw.txt # print the boosters of 0002.model in dump.raw.txt
../../xgboost machine.conf task=dump model_in=0002.model name_dump=dump.raw.txt ../../../xgboost machine.conf task=dump model_in=0002.model name_dump=dump.raw.txt
# print the boosters of 0002.model in dump.nice.txt with feature map # print the boosters of 0002.model in dump.nice.txt with feature map
../../xgboost machine.conf task=dump model_in=0002.model fmap=featmap.txt name_dump=dump.nice.txt ../../../xgboost machine.conf task=dump model_in=0002.model fmap=featmap.txt name_dump=dump.nice.txt
# cat the result # cat the result
cat dump.nice.txt cat dump.nice.txt

View File

@ -59,7 +59,24 @@ bool ArrayInterfaceHandler::IsCudaPtr(void const* ptr) {
return false; return false;
} }
#elif defined(XGBOOST_USE_HIP) #elif defined(XGBOOST_USE_HIP)
return false; hipPointerAttribute_t attr;
auto err = hipPointerGetAttributes(&attr, ptr);
// reset error
CHECK_EQ(err, hipGetLastError());
if (err == hipErrorInvalidValue) {
return false;
} else if (err == hipSuccess) {
switch (attr.memoryType) {
case hipMemoryTypeUnified:
case hipMemoryTypeHost:
return false;
default:
return true;
}
return true;
} else {
return false;
}
#endif #endif
} }
} // namespace xgboost } // namespace xgboost

View File

@ -35,7 +35,11 @@ auto SetDeviceToPtr(void const* ptr) {
dh::safe_cuda(cudaSetDevice(ptr_device)); dh::safe_cuda(cudaSetDevice(ptr_device));
return ptr_device; return ptr_device;
#elif defined(XGBOOST_USE_HIP) /* this is wrong, need to figure out */ #elif defined(XGBOOST_USE_HIP) /* this is wrong, need to figure out */
return 0; hipPointerAttribute_t attr;
dh::safe_cuda(hipPointerGetAttributes(&attr, ptr));
int32_t ptr_device = attr.device;
dh::safe_cuda(hipSetDevice(ptr_device));
return ptr_device;
#endif #endif
} }