Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYCL. Unify calculations for objectives reg:absoluteerror, reg:quantileerror, binary:hinge #10993

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

razdoburdin
Copy link
Contributor

Hi, I work on unification of sycl-plugin with the main part of the framework.
This PR unify calculations for some objective functions: reg:absoluteerror, reg:quantileerror and binary:hinge

The procedure of unification occurs in the following way:

  1. source files with objective functions are compiled with sycl compiler in case sycl-plugin is enabled.
  2. Instead of the original implementation of linalg::ElementWiseKernel the sycl realisation is used.

Comment on lines +48 to +57
template<typename Fn, typename TupleType, size_t ... I>
auto call(Fn&& fn, TupleType t, std::index_sequence<I ...>) {
return fn(std::get<I>(t) ...);
}

template<typename Fn, typename TupleType>
auto call(Fn&& fn, TupleType t) {
static constexpr auto size = std::tuple_size<TupleType>::value;
return call(fn, t, std::make_index_sequence<size>{});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this just std::apply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but std::apply can not be executed in sycl-kernel.

@@ -48,7 +48,7 @@ std::string ObjFunction::GetSyclImplementationName(const std::string& name) {
return name + sycl_postfix;
} else {
// Function hasn't specific sycl implementation
LOG(FATAL) << "`" << name << "` doesn't have sycl implementation yet\n";
// LOG(FATAL) << "`" << name << "` doesn't have sycl implementation yet\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -49,6 +49,7 @@ void ElementWiseKernelHost(linalg::TensorView<T, D> t, std::int32_t n_threads, F
}

#if !defined(XGBOOST_USE_CUDA)
#if !defined(XGBOOST_USE_SYCL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if !(use_cuda or use_sycl)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -45,7 +45,7 @@ namespace {
template <typename Fn>
PackedReduceResult Reduce(Context const* ctx, MetaInfo const& info, Fn&& loss) {
PackedReduceResult result;
auto labels = info.labels.View(ctx->Device());
auto labels = info.labels.View(ctx->Device().IsSycl() ? DeviceOrd::CPU() : ctx->Device());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you want to use IsCPU instead of IsSycl?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This function doesn't have sycl-specific implementation yet. So for the proper execution on cpu the data should be transferred back to host.
I plan to add sycl-implementation for it in the future. Didn't do it by single PR just to avoid unreadable PR size.

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge once the CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants