use __HIPCC__ for device code

This commit is contained in:
Hui Liu
2024-01-24 11:57:58 -08:00
parent fd3ad29dc4
commit 74677e4e9d
22 changed files with 69 additions and 68 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

@@ -14,7 +14,7 @@
namespace xgboost::common {
namespace {
constexpr DeviceOrd TransformDevice() {
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
return DeviceOrd::CUDA(0);
#else
return DeviceOrd::CPU();
@@ -51,7 +51,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<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

@@ -3,7 +3,7 @@
*/
#pragma once
#if defined(__CUDACC__) || defined(__HIP_PLATFORM_AMD__)
#if defined(__CUDACC__) || defined(__HIPCC__)
#include "../../src/data/ellpack_page.cuh"
#endif
@@ -12,7 +12,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);
@@ -356,7 +356,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;