try elementwise_metric.cu

This commit is contained in:
amdsc21 2023-03-08 22:42:48 +01:00
parent 946f9e9802
commit 6fa248b75f
7 changed files with 35 additions and 19 deletions

View File

@ -40,23 +40,12 @@
#endif // defined(__CUDACC__) #endif // defined(__CUDACC__)
namespace dh { namespace dh {
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__) #if defined(__CUDACC__)
/* /*
* Error handling functions * Error handling functions
*/ */
#define safe_cuda(ans) ThrowOnCudaError((ans), __FILE__, __LINE__) #define safe_cuda(ans) ThrowOnCudaError((ans), __FILE__, __LINE__)
#if defined(XGBOOST_USE_HIP)
inline hipError_t ThrowOnCudaError(hipError_t code, const char *file, int line)
{
if (code != hipSuccess) {
LOG(FATAL) << thrust::system_error(code, thrust::hip_category(),
std::string{file} + ": " + // NOLINT
std::to_string(line)).what();
}
return code;
}
#else
inline cudaError_t ThrowOnCudaError(cudaError_t code, const char *file, int line) inline cudaError_t ThrowOnCudaError(cudaError_t code, const char *file, int line)
{ {
if (code != cudaSuccess) { if (code != cudaSuccess) {
@ -66,8 +55,23 @@ inline cudaError_t ThrowOnCudaError(cudaError_t code, const char *file, int line
} }
return code; return code;
} }
#elif defined(__HIP_PLATFORM_AMD__)
/*
* Error handling functions
*/
#define safe_cuda(ans) ThrowOnCudaError((ans), __FILE__, __LINE__)
inline hipError_t ThrowOnCudaError(hipError_t code, const char *file, int line)
{
if (code != hipSuccess) {
LOG(FATAL) << thrust::system_error(code, thrust::hip_category(),
std::string{file} + ": " + // NOLINT
std::to_string(line)).what();
}
return code;
}
#endif #endif
#endif // defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
} // namespace dh } // namespace dh
namespace xgboost { namespace xgboost {

View File

@ -1,2 +1,4 @@
#if defined(XGBOOST_USE_HIP)
#include "context.cu" #include "context.cu"
#endif

View File

@ -1,3 +1,4 @@
#if defined(XGBOOST_USE_HIP)
#include "gbtree.cu" #include "gbtree.cu"
#endif

View File

@ -3,8 +3,6 @@
*/ */
// Dummy file to keep the CUDA conditional compile trick. // Dummy file to keep the CUDA conditional compile trick.
#if !defined(XGBOOST_USE_CUDA) #if !defined(XGBOOST_USE_CUDA) && !defined(XGBOOST_USE_HIP)
#include "elementwise_metric.cu" #include "elementwise_metric.cu"
#elif !defined(XGBOOST_USE_HIP) #endif // !defined(XGBOOST_USE_CUDA) && !defined(XGBOOST_USE_HIP)
#include "elementwise_metric.hip"
#endif // !defined(XGBOOST_USE_CUDA)

View File

@ -1,2 +1,4 @@
#if defined(XGBOOST_USE_HIP)
#include "elementwise_metric.cu" #include "elementwise_metric.cu"
#endif

View File

@ -3,6 +3,6 @@
*/ */
// Dummy file to keep the CUDA conditional compile trick. // Dummy file to keep the CUDA conditional compile trick.
#if !defined(XGBOOST_USE_CUDA) #if !defined(XGBOOST_USE_CUDA) && !defined(XGBOOST_USE_HIP)
#include "multiclass_metric.cu" #include "multiclass_metric.cu"
#endif // !defined(XGBOOST_USE_CUDA) #endif // !defined(XGBOOST_USE_CUDA)

View File

@ -23,6 +23,15 @@
#include "../common/device_helpers.cuh" #include "../common/device_helpers.cuh"
#endif // XGBOOST_USE_CUDA #endif // XGBOOST_USE_CUDA
#if defined(XGBOOST_USE_HIP)
#include <thrust/execution_policy.h> // thrust::cuda::par
#include <thrust/functional.h> // thrust::plus<>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform_reduce.h>
#include "../common/device_helpers.hip.h"
#endif // XGBOOST_USE_HIP
namespace xgboost { namespace xgboost {
namespace metric { namespace metric {
// tag the this file, used by force static link later. // tag the this file, used by force static link later.