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

add nd_range to SYCL #83

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 10 additions & 6 deletions SYCLStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ void SYCLStream<T>::copy()
{
auto ka = d_a->template get_access<access::mode::read>(cgh);
auto kc = d_c->template get_access<access::mode::write>(cgh);
cgh.parallel_for<copy_kernel>(range<1>{array_size}, [=](id<1> idx)
cgh.parallel_for<copy_kernel>(nd_range<1>{array_size,LOCAL_SIZE}, [=](nd_item<1> it)
{
const auto idx = it.get_global_id(0);
kc[idx] = ka[idx];
});
});
Expand All @@ -107,8 +108,9 @@ void SYCLStream<T>::mul()
{
auto kb = d_b->template get_access<access::mode::write>(cgh);
auto kc = d_c->template get_access<access::mode::read>(cgh);
cgh.parallel_for<mul_kernel>(range<1>{array_size}, [=](id<1> idx)
cgh.parallel_for<mul_kernel>(nd_range<1>{array_size,LOCAL_SIZE}, [=](nd_item<1> it)
{
const auto idx = it.get_global_id(0);
kb[idx] = scalar * kc[idx];
});
});
Expand All @@ -123,8 +125,9 @@ void SYCLStream<T>::add()
auto ka = d_a->template get_access<access::mode::read>(cgh);
auto kb = d_b->template get_access<access::mode::read>(cgh);
auto kc = d_c->template get_access<access::mode::write>(cgh);
cgh.parallel_for<add_kernel>(range<1>{array_size}, [=](id<1> idx)
cgh.parallel_for<add_kernel>(nd_range<1>{array_size,LOCAL_SIZE}, [=](nd_item<1> it)
{
const auto idx = it.get_global_id(0);
kc[idx] = ka[idx] + kb[idx];
});
});
Expand All @@ -140,8 +143,9 @@ void SYCLStream<T>::triad()
auto ka = d_a->template get_access<access::mode::write>(cgh);
auto kb = d_b->template get_access<access::mode::read>(cgh);
auto kc = d_c->template get_access<access::mode::read>(cgh);
cgh.parallel_for<triad_kernel>(range<1>{array_size}, [=](id<1> idx)
cgh.parallel_for<triad_kernel>(nd_range<1>{array_size,LOCAL_SIZE}, [=](nd_item<1> it)
{
const auto idx = it.get_global_id(0);
ka[idx] = kb[idx] + scalar * kc[idx];
});
});
Expand Down Expand Up @@ -201,9 +205,9 @@ void SYCLStream<T>::init_arrays(T initA, T initB, T initC)
auto ka = d_a->template get_access<access::mode::write>(cgh);
auto kb = d_b->template get_access<access::mode::write>(cgh);
auto kc = d_c->template get_access<access::mode::write>(cgh);
cgh.parallel_for<init_kernel>(range<1>{array_size}, [=](item<1> item)
cgh.parallel_for<init_kernel>(nd_range<1>{array_size,LOCAL_SIZE}, [=](nd_item<1> item)
{
auto id = item.get_id(0);
const auto id = item.get_global_id(0);
ka[id] = initA;
kb[id] = initB;
kc[id] = initC;
Expand Down
2 changes: 2 additions & 0 deletions SYCLStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#define IMPLEMENTATION_STRING "SYCL"

#define LOCAL_SIZE 256

namespace sycl_kernels
{
template <class T> class init;
Expand Down