Switch back to the GPUIDX macro (#9438)

This commit is contained in:
Rong Ou
2023-08-04 00:14:31 -07:00
committed by GitHub
parent 1aabc690ec
commit bde1ebc209
21 changed files with 85 additions and 88 deletions

View File

@@ -16,7 +16,7 @@ namespace xgboost {
namespace common {
TEST(Objective, DeclareUnifiedTest(AFTObjConfiguration)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> objective(ObjFunction::Create("survival:aft", &ctx));
objective->Configure({ {"aft_loss_distribution", "logistic"},
{"aft_loss_distribution_scale", "5"} });
@@ -77,7 +77,7 @@ static inline void CheckGPairOverGridPoints(
}
TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
CheckGPairOverGridPoints(obj.get(), 100.0f, 100.0f, "normal",
@@ -101,7 +101,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
}
TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
CheckGPairOverGridPoints(obj.get(), 0.0f, 20.0f, "normal",
@@ -122,7 +122,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
}
TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
CheckGPairOverGridPoints(obj.get(), 60.0f, std::numeric_limits<float>::infinity(), "normal",
@@ -146,7 +146,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
}
TEST(Objective, DeclareUnifiedTest(AFTObjGPairIntervalCensoredLabels)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
CheckGPairOverGridPoints(obj.get(), 16.0f, 200.0f, "normal",

View File

@@ -6,7 +6,7 @@
#include "../helpers.h"
namespace xgboost {
TEST(Objective, DeclareUnifiedTest(HingeObj)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("binary:hinge", &ctx)};
float eps = std::numeric_limits<xgboost::bst_float>::min();

View File

@@ -71,7 +71,7 @@ void TestNDCGGPair(Context const* ctx) {
HostDeviceVector<float> predts{0, 1, 0, 1};
MetaInfo info;
info.labels = linalg::Tensor<float, 2>{{0, 1, 0, 1}, {4, 1}, GetGPUId()};
info.labels = linalg::Tensor<float, 2>{{0, 1, 0, 1}, {4, 1}, GPUIDX};
info.group_ptr_ = {0, 2, 4};
info.num_row_ = 4;
HostDeviceVector<GradientPair> gpairs;

View File

@@ -9,7 +9,7 @@
namespace xgboost {
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args {{"num_class", "3"}};
std::unique_ptr<ObjFunction> obj {
ObjFunction::Create("multi:softmax", &ctx)
@@ -36,7 +36,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
}
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
auto ctx = MakeCUDACtx(GetGPUId());
auto ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args{
std::pair<std::string, std::string>("num_class", "3")};
@@ -57,7 +57,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
}
TEST(Objective, DeclareUnifiedTest(SoftprobMultiClassBasic)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args {
std::pair<std::string, std::string>("num_class", "3")};

View File

@@ -14,7 +14,7 @@
namespace xgboost {
TEST(Objective, DeclareUnifiedTest(Quantile)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
{
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
@@ -37,7 +37,7 @@ TEST(Objective, DeclareUnifiedTest(Quantile)) {
}
TEST(Objective, DeclareUnifiedTest(QuantileIntercept)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:quantileerror", &ctx)};
obj->Configure(args);

View File

@@ -17,7 +17,7 @@
namespace xgboost {
TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squarederror", &ctx)};
@@ -39,7 +39,7 @@ TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
}
TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squaredlogerror", &ctx)};
@@ -62,7 +62,7 @@ TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
}
TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
Args args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:pseudohubererror", &ctx)};
@@ -91,7 +91,7 @@ TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
}
TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
@@ -107,7 +107,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
}
TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
@@ -136,7 +136,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
}
TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj {
ObjFunction::Create("binary:logitraw", &ctx)
@@ -152,7 +152,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
}
TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj {
ObjFunction::Create("count:poisson", &ctx)
@@ -176,7 +176,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
}
TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj {
ObjFunction::Create("count:poisson", &ctx)
@@ -205,7 +205,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
}
TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj {
ObjFunction::Create("reg:gamma", &ctx)
@@ -227,7 +227,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
}
TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:gamma", &ctx)};
@@ -256,7 +256,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
}
TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
@@ -280,7 +280,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
#if defined(__CUDACC__)
TEST(Objective, CPU_vs_CUDA) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
ObjFunction* obj = ObjFunction::Create("reg:squarederror", &ctx);
HostDeviceVector<GradientPair> cpu_out_preds;
@@ -331,7 +331,7 @@ TEST(Objective, CPU_vs_CUDA) {
#endif
TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
@@ -360,7 +360,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
// CoxRegression not implemented in GPU code, no need for testing.
#if !defined(__CUDACC__)
TEST(Objective, CoxRegressionGPair) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::vector<std::pair<std::string, std::string>> args;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("survival:cox", &ctx)};
@@ -375,7 +375,7 @@ TEST(Objective, CoxRegressionGPair) {
#endif
TEST(Objective, DeclareUnifiedTest(AbsoluteError)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
obj->Configure({});
CheckConfigReload(obj, "reg:absoluteerror");
@@ -419,7 +419,7 @@ TEST(Objective, DeclareUnifiedTest(AbsoluteError)) {
}
TEST(Objective, DeclareUnifiedTest(AbsoluteErrorLeaf)) {
Context ctx = MakeCUDACtx(GetGPUId());
Context ctx = MakeCUDACtx(GPUIDX);
bst_target_t constexpr kTargets = 3, kRows = 16;
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
obj->Configure({});