From b4dbe7a649c6eb80507e1ff290531faf4095facc Mon Sep 17 00:00:00 2001 From: amdsc21 <96135754+amdsc21@users.noreply.github.com> Date: Sat, 11 Mar 2023 02:39:58 +0100 Subject: [PATCH] fix isnan --- src/common/math.h | 8 ++++++-- tests/cpp/common/test_hist_util.h | 7 ++----- tests/cpp/data/test_device_adapter.cu | 6 +----- tests/cpp/data/test_iterative_dmatrix.cu | 5 ----- tests/cpp/data/test_proxy_dmatrix.cu | 5 ----- tests/cpp/data/test_simple_dmatrix.cu | 5 ----- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/common/math.h b/src/common/math.h index 9c9ee604d..62c609f0b 100644 --- a/src/common/math.h +++ b/src/common/math.h @@ -155,16 +155,20 @@ bool CheckNAN(double v); #else XGBOOST_DEVICE bool inline CheckNAN(float x) { -#if defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) +#if defined(__CUDA_ARCH__) return isnan(x); +#elif defined(__HIP_PLATFORM_AMD__) + return __builtin_isnan(x); #else return std::isnan(x); #endif // defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) } XGBOOST_DEVICE bool inline CheckNAN(double x) { -#if defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) +#if defined(__CUDA_ARCH__) return isnan(x); +#elif defined(__HIP_PLATFORM_AMD__) + return __builtin_isnan(x); #else return std::isnan(x); #endif // defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) diff --git a/tests/cpp/common/test_hist_util.h b/tests/cpp/common/test_hist_util.h index 7750e5ade..f368dfd5a 100644 --- a/tests/cpp/common/test_hist_util.h +++ b/tests/cpp/common/test_hist_util.h @@ -15,13 +15,10 @@ #include "../filesystem.h" // dmlc::TemporaryDirectory #include "../helpers.h" -#ifdef __CUDACC__ +#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__) #include #include "../../../src/data/device_adapter.cuh" -#elif defined(__HIP_PLATFORM_AMD__) -#include -#include "../../../src/data/device_adapter.hip.h" -#endif // __CUDACC__ +#endif // __CUDACC__, __HIP_PLATFORM_AMD__ // Some helper functions used to test both GPU and CPU algorithms // diff --git a/tests/cpp/data/test_device_adapter.cu b/tests/cpp/data/test_device_adapter.cu index dc00b0dc6..f1c1f204b 100644 --- a/tests/cpp/data/test_device_adapter.cu +++ b/tests/cpp/data/test_device_adapter.cu @@ -7,13 +7,9 @@ #include "../helpers.h" #include -#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" -#elif defined(XGBOOST_USE_HIP) -#include "../../../src/data/device_adapter.hip.h" -#endif - #include "test_array_interface.h" + using namespace xgboost; // NOLINT void TestCudfAdapter() diff --git a/tests/cpp/data/test_iterative_dmatrix.cu b/tests/cpp/data/test_iterative_dmatrix.cu index 43c1d0d82..be97a3f6a 100644 --- a/tests/cpp/data/test_iterative_dmatrix.cu +++ b/tests/cpp/data/test_iterative_dmatrix.cu @@ -3,12 +3,7 @@ */ #include -#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" -#elif defined(XGBOOST_USE_HIP) -#include "../../../src/data/device_adapter.hip.h" -#endif - #include "../../../src/data/ellpack_page.cuh" #include "../../../src/data/iterative_dmatrix.h" #include "../helpers.h" diff --git a/tests/cpp/data/test_proxy_dmatrix.cu b/tests/cpp/data/test_proxy_dmatrix.cu index fcc27ba3b..e13cb54f1 100644 --- a/tests/cpp/data/test_proxy_dmatrix.cu +++ b/tests/cpp/data/test_proxy_dmatrix.cu @@ -3,12 +3,7 @@ #include #include "../helpers.h" -#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" -#elif defined(XGBOOST_USE_HIP) -#include "../../../src/data/device_adapter.hip.h" -#endif - #include "../../../src/data/proxy_dmatrix.h" namespace xgboost { diff --git a/tests/cpp/data/test_simple_dmatrix.cu b/tests/cpp/data/test_simple_dmatrix.cu index 938150683..931daa9e7 100644 --- a/tests/cpp/data/test_simple_dmatrix.cu +++ b/tests/cpp/data/test_simple_dmatrix.cu @@ -4,12 +4,7 @@ #include -#if defined(XGBOOST_USE_CUDA) #include "../../../src/data/device_adapter.cuh" -#elif defined(XGBOOST_USE_HIP) -#include "../../../src/data/device_adapter.hip.h" -#endif - #include "../helpers.h" #include "test_array_interface.h" #include "../../../src/data/array_interface.h"