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

distributed_device_policy renamed to sycl_device_collection #1746

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, U init, BinaryOp bi
{
using T = stdrng::range_value_t<O>;

static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, distributed_device_policy>);
static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

auto zipped_view = views::zip(r, o);
auto zipped_segments = zipped_view.zipped_segments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
namespace oneapi::dpl::experimental::dr::sp
{

struct distributed_device_policy
struct sycl_device_collection
{
distributed_device_policy(sycl::device device) : devices_({device}) {}
distributed_device_policy(sycl::queue queue) : devices_({queue.get_device()}) {}
sycl_device_collection(sycl::device device) : devices_({device}) {}
sycl_device_collection(sycl::queue queue) : devices_({queue.get_device()}) {}

distributed_device_policy() : devices_({sycl::queue{}.get_device()}) {}
sycl_device_collection() : devices_({sycl::queue{}.get_device()}) {}

template <stdrng::range R>
requires(std::is_same_v<stdrng::range_value_t<R>, sycl::device>) distributed_device_policy(R&& devices)
requires(std::is_same_v<stdrng::range_value_t<R>, sycl::device>) sycl_device_collection(R&& devices)
: devices_(stdrng::begin(devices), stdrng::end(devices))
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void
for_each(ExecutionPolicy&& policy, R&& r, Fn fn)
{
static_assert( // currently only one policy supported
std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, distributed_device_policy>);
std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

std::vector<sycl::event> events;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ inclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, BinaryOp binary_op,
{
using T = stdrng::range_value_t<O>;

static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, distributed_device_policy>);
static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

auto zipped_view = views::zip(r, o);
auto zipped_segments = zipped_view.zipped_segments();

std::vector<sycl::event> events;

auto root = devices()[0];
device_allocator<T> allocator(context(), root);
vector<T, device_allocator<T>> partial_sums(std::size_t(zipped_segments.size()), allocator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ T
reduce(ExecutionPolicy&& policy, R&& r, T init, BinaryOp binary_op)
{

static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, distributed_device_policy>);
static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

using future_t = decltype(reduce_async(__detail::dpl_policy(0), ranges::segments(r)[0].begin(),
ranges::segments(r)[0].end(), init, binary_op));

std::vector<future_t> futures;

for (auto&& segment : ranges::segments(r))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ transform(ExecutionPolicy&& policy, distributed_range auto&& in, distributed_ite
{

static_assert( // currently only one policy supported
std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, distributed_device_policy>);
std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

std::vector<sycl::event> events;
using OutT = typename decltype(out)::value_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ nprocs()
return __detail::ngpus();
}

inline distributed_device_policy par_unseq;
inline sycl_device_collection par_unseq;
akukanov marked this conversation as resolved.
Show resolved Hide resolved

template <stdrng::range R>
inline void
Expand All @@ -100,7 +100,7 @@ init(R&& devices) requires(std::is_same_v<sycl::device, std::remove_cvref_t<stdr
__detail::dpl_policies_.emplace_back(__detail::queues_.back());
}

par_unseq = distributed_device_policy(__detail::devices_);
par_unseq = sycl_device_collection(__detail::devices_);
}

// example call: init(sycl::default_selector_v)
Expand Down
Loading