use __HIPCC__ for device code

This commit is contained in:
Hui Liu
2024-01-24 12:32:51 -08:00
parent 7dc152450e
commit dc7ee041cc
22 changed files with 73 additions and 72 deletions

View File

@@ -15,10 +15,10 @@
#include "../filesystem.h" // dmlc::TemporaryDirectory
#include "../helpers.h"
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#include <xgboost/json.h>
#include "../../../src/data/device_adapter.cuh"
#endif // __CUDACC__, __HIP_PLATFORM_AMD__
#endif // __CUDACC__, __HIPCC__
// Some helper functions used to test both GPU and CPU algorithms
//
@@ -47,7 +47,7 @@ inline std::vector<float> GenerateRandomWeights(int num_rows) {
return w;
}
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
inline data::CupyAdapter AdapterFromData(const thrust::device_vector<float> &x,
int num_rows, int num_columns) {
Json array_interface{Object()};

View File

@@ -99,7 +99,7 @@ struct TestRBeginREnd {
Span<float> s (arr);
#if defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
auto rbeg = dh::trbegin(s);
auto rend = dh::trend(s);
#else

View File

@@ -11,7 +11,7 @@
#include "../../../src/common/transform.h"
#include "../helpers.h"
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#define TRANSFORM_GPU 0
@@ -53,7 +53,7 @@ TEST(Transform, DeclareUnifiedTest(Basic)) {
ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin()));
}
#if !defined(__CUDACC__) && !defined(__HIP_PLATFORM_AMD__)
#if !defined(__CUDACC__) && !defined(__HIPCC__)
TEST(TransformDeathTest, Exception) {
size_t const kSize {16};
std::vector<bst_float> h_in(kSize);

View File

@@ -28,19 +28,19 @@
#include "filesystem.h" // dmlc::TemporaryDirectory
#include "xgboost/linalg.h"
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#define DeclareUnifiedTest(name) GPU ## name
#else
#define DeclareUnifiedTest(name) name
#endif
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#define GPUIDX (common::AllVisibleGPUs() == 1 ? 0 : collective::GetRank())
#else
#define GPUIDX (-1)
#endif
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#define DeclareUnifiedDistributedTest(name) MGPU ## name
#else
#define DeclareUnifiedDistributedTest(name) name

View File

@@ -1,4 +1,4 @@
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#include "../../src/data/ellpack_page.cuh"
#endif
@@ -7,7 +7,7 @@
#include "./helpers.h" // for RandomDataGenerator
namespace xgboost {
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
namespace {
class HistogramCutsWrapper : public common::HistogramCuts {
public:

View File

@@ -20,7 +20,7 @@
namespace xgboost {
namespace metric {
#if !defined(__CUDACC__) && !defined(__HIP_PLATFORM_AMD__)
#if !defined(__CUDACC__) && !defined(__HIPCC__)
TEST(Metric, AMS) {
auto ctx = MakeCUDACtx(GPUIDX);
EXPECT_ANY_THROW(Metric::Create("ams", &ctx));

View File

@@ -278,7 +278,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"tweedie-nloglik@1.1"});
}
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
TEST(Objective, CPU_vs_CUDA) {
Context ctx = MakeCUDACtx(GPUIDX);
@@ -358,7 +358,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
}
// CoxRegression not implemented in GPU code, no need for testing.
#if !defined(__CUDACC__) && !defined(__HIP_PLATFORM_AMD__)
#if !defined(__CUDACC__) && !defined(__HIPCC__)
TEST(Objective, CoxRegressionGPair) {
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;