Skip to content

Commit

Permalink
Add user_cpu_context and ability to provide host_policy via it
Browse files Browse the repository at this point in the history
  • Loading branch information
olegkkruglov committed Oct 31, 2023
1 parent 4eb47a5 commit a192ac4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/oneapi/dal/compute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include "oneapi/dal/detail/compute_ops.hpp"
#include "oneapi/dal/detail/user_policy.hpp"
#include "oneapi/dal/detail/spmd_policy.hpp"
#include "oneapi/dal/spmd/communicator.hpp"

Expand All @@ -28,6 +29,11 @@ auto compute(Args&&... args) {
return dal::detail::compute_dispatch(std::forward<Args>(args)...);
}

template <typename... Args>
auto compute(detail::user_cpu_context uctx, Args&&... args) {
return dal::detail::compute_dispatch(uctx.get_host_policy(), std::forward<Args>(args)...);
}

#ifdef ONEDAL_DATA_PARALLEL
template <typename... Args>
auto compute(sycl::queue& queue, Args&&... args) {
Expand Down
1 change: 1 addition & 0 deletions cpp/oneapi/dal/detail/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ONEDAL_EXPORT host_policy : public base {
}
host_policy(const host_policy&) = default;
host_policy(host_policy&&) = default;
host_policy& operator= (const host_policy&) = default;

static host_policy get_default() {
return host_policy(make_default_impl());
Expand Down
6 changes: 6 additions & 0 deletions cpp/oneapi/dal/train.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include "oneapi/dal/detail/train_ops.hpp"
#include "oneapi/dal/detail/user_policy.hpp"
#include "oneapi/dal/detail/spmd_policy.hpp"
#include "oneapi/dal/spmd/communicator.hpp"

Expand All @@ -28,6 +29,11 @@ auto train(Args&&... args) {
return dal::detail::train_dispatch(std::forward<Args>(args)...);
}

template <typename... Args>
auto train(detail::user_cpu_context uctx, Args&&... args) {
return dal::detail::train_dispatch(uctx.get_host_policy(), std::forward<Args>(args)...);
}

#ifdef ONEDAL_DATA_PARALLEL
template <typename... Args>
auto train(sycl::queue& queue, Args&&... args) {
Expand Down

0 comments on commit a192ac4

Please sign in to comment.