Skip to content

Commit 9d4edbe

Browse files
author
dmitry.razdoburdin
committed
Resolving interfaces conflicts
1 parent 569d998 commit 9d4edbe

8 files changed

+44
-35
lines changed

plugin/updater_oneapi/hist_util_oneapi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void GHistIndexMatrixOneAPI::Init(sycl::queue qu,
110110
int max_bins) {
111111
nfeatures = p_fmat_device.p_mat->Info().num_col_;
112112

113-
cut = SketchOnDMatrix(p_fmat_device.p_mat, max_bins);
113+
cut = SketchOnDMatrix(p_fmat_device.p_mat, max_bins, common::OmpGetNumThreads(0));
114114
cut_device.Init(qu, cut);
115115

116116
max_num_bins = max_bins;

plugin/updater_oneapi/multiclass_obj_oneapi.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ class SoftmaxMultiClassObjOneAPI : public ObjFunction {
7878
void Configure(Args const& args) override {
7979
param_.UpdateAllowUnknown(args);
8080

81-
sycl::default_selector selector;
82-
qu_ = sycl::queue(selector);
81+
// sycl::default_selector selector;
82+
// qu_ = sycl::queue(selector);
83+
qu_ = sycl::queue(sycl::default_selector_v);
8384
}
8485

8586
void GetGradient(const HostDeviceVector<bst_float>& preds,
@@ -108,7 +109,7 @@ class SoftmaxMultiClassObjOneAPI : public ObjFunction {
108109
}
109110

110111
sycl::buffer<bst_float, 1> preds_buf(preds.HostPointer(), preds.Size());
111-
sycl::buffer<bst_float, 1> labels_buf(info.labels.HostPointer(), info.labels.Size());
112+
sycl::buffer<bst_float, 1> labels_buf(info.labels.Data()->HostPointer(), info.labels.Size());
112113
sycl::buffer<GradientPair, 1> out_gpair_buf(out_gpair->HostPointer(), out_gpair->Size());
113114
sycl::buffer<bst_float, 1> weights_buf(is_null_weight ? NULL : info.weights_.HostPointer(),
114115
is_null_weight ? 1 : info.weights_.Size());
@@ -209,7 +210,7 @@ class SoftmaxMultiClassObjOneAPI : public ObjFunction {
209210
}
210211
}
211212

212-
struct ObjInfo Task() const override {return {ObjInfo::kClassification, false}; }
213+
struct ObjInfo Task() const override {return {ObjInfo::kClassification}; }
213214

214215
void SaveConfig(Json* p_out) const override {
215216
auto& out = *p_out;

plugin/updater_oneapi/predictor_oneapi.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PredictorOneAPI : public Predictor {
3434
if (generic_param->device_id != GenericParameter::kDefaultId) {
3535
int n_devices = (int)devices.size();
3636
CHECK_LT(generic_param->device_id, n_devices);
37-
is_cpu = devices[generic_param->device_id].is_cpu() | devices[generic_param->device_id].is_host();
37+
is_cpu = devices[generic_param->device_id].is_cpu();
3838
}
3939
LOG(INFO) << "device_id = " << generic_param->device_id << ", is_cpu = " << int(is_cpu);
4040

@@ -60,11 +60,11 @@ class PredictorOneAPI : public Predictor {
6060
predictor_backend_->PredictBatch(dmat, predts, model, tree_begin, tree_end);
6161
}
6262

63-
bool InplacePredict(dmlc::any const &x, std::shared_ptr<DMatrix> p_m,
63+
bool InplacePredict(std::shared_ptr<DMatrix> p_m,
6464
const gbm::GBTreeModel &model, float missing,
6565
PredictionCacheEntry *out_preds, uint32_t tree_begin,
6666
unsigned tree_end) const override {
67-
return predictor_backend_->InplacePredict(x, p_m, model, missing, out_preds, tree_begin, tree_end);
67+
return predictor_backend_->InplacePredict(p_m, model, missing, out_preds, tree_begin, tree_end);
6868
}
6969

7070
void PredictInstance(const SparsePage::Inst& inst,
@@ -306,6 +306,7 @@ class GPUPredictorOneAPI : public Predictor {
306306
CHECK_EQ(out_preds->Size(), n);
307307
std::copy(base_margin.begin(), base_margin.end(), out_preds_h.begin());
308308
} else {
309+
auto base_score = model.learner_model_param->BaseScore(ctx_)(0);
309310
if (!base_margin.empty()) {
310311
std::ostringstream oss;
311312
oss << "Ignoring the base margin, since it has incorrect length. "
@@ -318,11 +319,10 @@ class GPUPredictorOneAPI : public Predictor {
318319
oss << "[number of data points], i.e. " << info.num_row_ << ". ";
319320
}
320321
oss << "Instead, all data points will use "
321-
<< "base_score = " << model.learner_model_param->base_score;
322+
<< "base_score = " << base_score;
322323
LOG(WARNING) << oss.str();
323324
}
324-
std::fill(out_preds_h.begin(), out_preds_h.end(),
325-
model.learner_model_param->base_score);
325+
std::fill(out_preds_h.begin(), out_preds_h.end(), base_score);
326326
}
327327
}
328328

@@ -333,8 +333,9 @@ class GPUPredictorOneAPI : public Predictor {
333333
if (generic_param->device_id != GenericParameter::kDefaultId) {
334334
qu_ = sycl::queue(devices[generic_param->device_id]);
335335
} else {
336-
sycl::default_selector selector;
337-
qu_ = sycl::queue(selector);
336+
// sycl::default_selector selector;
337+
// qu_ = sycl::queue(selector);
338+
qu_ = sycl::queue(sycl::default_selector_v);
338339
}
339340
}
340341

@@ -364,11 +365,11 @@ class GPUPredictorOneAPI : public Predictor {
364365
}
365366
}
366367

367-
bool InplacePredict(dmlc::any const &x, std::shared_ptr<DMatrix> p_m,
368+
bool InplacePredict(std::shared_ptr<DMatrix> p_m,
368369
const gbm::GBTreeModel &model, float missing,
369370
PredictionCacheEntry *out_preds, uint32_t tree_begin,
370371
unsigned tree_end) const override {
371-
return cpu_predictor->InplacePredict(x, p_m, model, missing, out_preds, tree_begin, tree_end);
372+
return cpu_predictor->InplacePredict(p_m, model, missing, out_preds, tree_begin, tree_end);
372373
}
373374

374375
void PredictInstance(const SparsePage::Inst& inst,

plugin/updater_oneapi/regression_loss_oneapi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct LinearSquareLossOneAPI {
3939

4040
static const char* Name() { return "reg:squarederror_oneapi"; }
4141

42-
static ObjInfo Info() { return {ObjInfo::kRegression, true}; }
42+
static ObjInfo Info() { return {ObjInfo::kRegression, true, false}; }
4343
};
4444

4545
// TODO: DPC++ does not fully support std math inside offloaded kernels
@@ -67,7 +67,7 @@ struct SquaredLogErrorOneAPI {
6767

6868
static const char* Name() { return "reg:squaredlogerror_oneapi"; }
6969

70-
static ObjInfo Info() { return {ObjInfo::kRegression, false}; }
70+
static ObjInfo Info() { return ObjInfo::kRegression; }
7171
};
7272

7373
// logistic loss for probability regression task
@@ -104,7 +104,7 @@ struct LogisticRegressionOneAPI {
104104

105105
static const char* Name() { return "reg:logistic_oneapi"; }
106106

107-
static ObjInfo Info() { return {ObjInfo::kRegression, false}; }
107+
static ObjInfo Info() { return ObjInfo::kRegression; }
108108
};
109109

110110
// logistic loss for binary classification task
@@ -144,7 +144,7 @@ struct LogisticRawOneAPI : public LogisticRegressionOneAPI {
144144

145145
static const char* Name() { return "binary:logitraw_oneapi"; }
146146

147-
static ObjInfo Info() { return {ObjInfo::kRegression, false}; }
147+
static ObjInfo Info() { return ObjInfo::kRegression; }
148148
};
149149

150150
} // namespace obj

plugin/updater_oneapi/regression_obj_oneapi.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ class RegLossObjOneAPI : public ObjFunction {
4040
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
4141
param_.UpdateAllowUnknown(args);
4242

43-
sycl::default_selector selector;
44-
qu_ = sycl::queue(selector);
43+
// sycl::default_selector selector;
44+
// qu_ = sycl::queue(selector);
45+
qu_ = sycl::queue(sycl::default_selector_v);
4546
}
4647

4748
void GetGradient(const HostDeviceVector<bst_float>& preds,

plugin/updater_oneapi/updater_quantile_hist_oneapi.cc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,27 @@ void QuantileHistMakerOneAPI::Configure(const Args& args) {
3535
if (param.device_id != GenericParameter::kDefaultId) {
3636
int n_devices = (int)devices.size();
3737
CHECK_LT(param.device_id, n_devices);
38-
is_cpu = devices[param.device_id].is_cpu() | devices[param.device_id].is_host();
38+
is_cpu = devices[param.device_id].is_cpu();
3939
}
4040
LOG(INFO) << "device_id = " << param.device_id << ", is_cpu = " << int(is_cpu);
4141

4242
if (is_cpu)
4343
{
44-
updater_backend_.reset(TreeUpdater::Create("grow_quantile_histmaker", tparam_, task_));
44+
updater_backend_.reset(TreeUpdater::Create("grow_quantile_histmaker", ctx_, task_));
4545
updater_backend_->Configure(args);
4646
}
4747
else
4848
{
49-
updater_backend_.reset(TreeUpdater::Create("grow_quantile_histmaker_oneapi_gpu", tparam_, task_));
49+
updater_backend_.reset(TreeUpdater::Create("grow_quantile_histmaker_oneapi_gpu", ctx_, task_));
5050
updater_backend_->Configure(args);
5151
}
5252
}
5353

5454
void QuantileHistMakerOneAPI::Update(HostDeviceVector<GradientPair> *gpair,
5555
DMatrix *dmat,
56+
common::Span<HostDeviceVector<bst_node_t>> out_position,
5657
const std::vector<RegTree *> &trees) {
57-
updater_backend_->Update(gpair, dmat, trees);
58+
updater_backend_->Update(gpair, dmat, out_position, trees);
5859
}
5960

6061
bool QuantileHistMakerOneAPI::UpdatePredictionCache(
@@ -78,7 +79,7 @@ void GPUQuantileHistMakerOneAPI::Configure(const Args& args) {
7879

7980
// initialize pruner
8081
if (!pruner_) {
81-
pruner_.reset(TreeUpdater::Create("prune", tparam_, task_));
82+
pruner_.reset(TreeUpdater::Create("prune", ctx_, task_));
8283
}
8384
pruner_->Configure(args);
8485
param_.UpdateAllowUnknown(args);
@@ -113,6 +114,7 @@ void GPUQuantileHistMakerOneAPI::CallBuilderUpdate(const std::unique_ptr<Builder
113114
}
114115
void GPUQuantileHistMakerOneAPI::Update(HostDeviceVector<GradientPair> *gpair,
115116
DMatrix *dmat,
117+
common::Span<HostDeviceVector<bst_node_t>> out_position,
116118
const std::vector<RegTree *> &trees) {
117119
if (dmat != p_last_dmat_ || is_gmat_initialized_ == false) {
118120
updater_monitor_.Start("GmatInitialization");
@@ -243,7 +245,8 @@ void GPUQuantileHistMakerOneAPI::Builder<GradientSumT>::ReduceHists(std::vector<
243245
const GradientPairT* psrc = reinterpret_cast<const GradientPairT*>(this_hist.DataConst());
244246
std::copy(psrc, psrc + nbins, reduce_buffer.begin() + i * nbins);
245247
}
246-
histred_.Allreduce(reduce_buffer.data(), nbins * sync_ids.size());
248+
collective::Allreduce<collective::Operation::kSum>(reduce_buffer.data(), nbins * sync_ids.size());
249+
// histred_.Allreduce(reduce_buffer.data(), nbins * sync_ids.size());
247250
for (size_t i = 0; i < sync_ids.size(); i++) {
248251
auto this_hist = hist_[sync_ids[i]];
249252
GradientPairT* psrc = reinterpret_cast<GradientPairT*>(this_hist.Data());
@@ -1349,7 +1352,8 @@ void GPUQuantileHistMakerOneAPI::Builder<GradientSumT>::InitNewNode(int nid,
13491352
grad_stat.Add(gpair[*it].GetGrad(), gpair[*it].GetHess());
13501353
}
13511354
}
1352-
histred_.Allreduce(&grad_stat, 1);
1355+
collective::Allreduce<collective::Operation::kSum>(&grad_stat, 1);
1356+
// histred_.Allreduce(&grad_stat, 1);
13531357
snode_[nid].stats = GradStatsOneAPI<GradientSumT>(grad_stat.GetGrad(), grad_stat.GetHess());
13541358
} else {
13551359
int parent_id = tree[nid].Parent();
@@ -1397,15 +1401,15 @@ template void GPUQuantileHistMakerOneAPI::Builder<double>::PartitionKernel<uint3
13971401
XGBOOST_REGISTER_TREE_UPDATER(QuantileHistMakerOneAPI, "grow_quantile_histmaker_oneapi")
13981402
.describe("Grow tree using quantized histogram with dpc++.")
13991403
.set_body(
1400-
[](ObjInfo task) {
1401-
return new QuantileHistMakerOneAPI(task);
1404+
[](GenericParameter const* ctx, ObjInfo task) {
1405+
return new QuantileHistMakerOneAPI(ctx, task);
14021406
});
14031407

14041408
XGBOOST_REGISTER_TREE_UPDATER(GPUQuantileHistMakerOneAPI, "grow_quantile_histmaker_oneapi_gpu")
14051409
.describe("Grow tree using quantized histogram with dpc++ on GPU.")
14061410
.set_body(
1407-
[]() {
1408-
return new GPUQuantileHistMakerOneAPI();
1411+
[](GenericParameter const* ctx, ObjInfo task) {
1412+
return new GPUQuantileHistMakerOneAPI(ctx, task);
14091413
});
14101414
} // namespace tree
14111415
} // namespace xgboost

plugin/updater_oneapi/updater_quantile_hist_oneapi.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ struct OneAPIHistMakerTrainParam
9898
/*! \brief construct a tree using quantized feature values with DPC++ interface */
9999
class QuantileHistMakerOneAPI: public TreeUpdater {
100100
public:
101-
explicit QuantileHistMakerOneAPI(ObjInfo task) : task_{task} {}
101+
explicit QuantileHistMakerOneAPI(GenericParameter const* ctx, ObjInfo task) : TreeUpdater(ctx), task_{task} {}
102102
void Configure(const Args& args) override;
103103

104104
void Update(HostDeviceVector<GradientPair>* gpair,
105105
DMatrix* dmat,
106+
common::Span<HostDeviceVector<bst_node_t>> out_position,
106107
const std::vector<RegTree*>& trees) override;
107108

108109
bool UpdatePredictionCache(const DMatrix* data,
@@ -162,13 +163,14 @@ struct NodeEntry {
162163
/*! \brief construct a tree using quantized feature values with DPC++ backend on GPU*/
163164
class GPUQuantileHistMakerOneAPI: public TreeUpdater {
164165
public:
165-
explicit GPUQuantileHistMakerOneAPI(ObjInfo task) : task_{task} {
166+
explicit GPUQuantileHistMakerOneAPI(GenericParameter const* ctx, ObjInfo task) : TreeUpdater(ctx), task_{task} {
166167
updater_monitor_.Init("GPUQuantileHistMakerOneAPI");
167168
}
168169
void Configure(const Args& args) override;
169170

170171
void Update(HostDeviceVector<GradientPair>* gpair,
171172
DMatrix* dmat,
173+
common::Span<HostDeviceVector<bst_node_t>> out_position,
172174
const std::vector<RegTree*>& trees) override;
173175

174176
bool UpdatePredictionCache(const DMatrix* data,
@@ -490,7 +492,7 @@ class GPUQuantileHistMakerOneAPI: public TreeUpdater {
490492
common::Monitor builder_monitor_;
491493
common::Monitor kernel_monitor_;
492494
common::ParallelGHistBuilderOneAPI<GradientSumT> hist_buffer_;
493-
rabit::Reducer<GradientPairT, GradientPairT::Reduce> histred_;
495+
// rabit::op::Reducer<GradientPairT, GradientPairT::Reduce> histred_;
494496
std::unique_ptr<HistSynchronizerOneAPI<GradientSumT>> hist_synchronizer_;
495497
std::unique_ptr<HistRowsAdderOneAPI<GradientSumT>> hist_rows_adder_;
496498

0 commit comments

Comments
 (0)