Skip to content

Restyle custom elemwise kernels #113

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

Merged
merged 1 commit into from
Oct 5, 2020
Merged
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
73 changes: 39 additions & 34 deletions dpnp/backend/custom_kernels_elemwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@
_DataType_output* result = reinterpret_cast<_DataType_output*>(result1); \
\
cl::sycl::range<1> gws(size); \
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType_input> >( \
gws, \
[=](cl::sycl::id<1> global_id) \
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) { \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
_DataType_output input_elem = array1[i]; \
result[i] = __operation__; \
} \
}); /* parallel_for */ \
}); /* queue.submit */ \
_DataType_output input_elem = array1[i]; \
result[i] = __operation__; \
} \
}; \
\
auto kernel_func = [&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType_input> >( \
gws, kernel_parallel_for_func); \
}; \
\
event = DPNP_QUEUE.submit(kernel_func); \
\
event.wait(); \
} \
Expand All @@ -79,18 +81,19 @@
_DataType* result = reinterpret_cast<_DataType*>(result1); \
\
cl::sycl::range<1> gws(size); \
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType> >( \
gws, \
[=](cl::sycl::id<1> global_id) \
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) { \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
_DataType input_elem = array1[i]; \
result[i] = __operation__; \
} \
}); /* parallel_for */ \
}); /* queue.submit */ \
_DataType input_elem = array1[i]; \
result[i] = __operation__; \
} \
}; \
\
auto kernel_func = [&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType> >(gws, kernel_parallel_for_func); \
}; \
\
event = DPNP_QUEUE.submit(kernel_func); \
\
event.wait(); \
} \
Expand Down Expand Up @@ -118,19 +121,21 @@
_DataType_output* result = reinterpret_cast<_DataType_output*>(result1); \
\
cl::sycl::range<1> gws(size); \
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType_input1, _DataType_input2, _DataType_output> >( \
gws, \
[=](cl::sycl::id<1> global_id) \
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) { \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
size_t i = global_id[0]; /*for (size_t i = 0; i < size; ++i)*/ \
{ \
_DataType_output input_elem1 = array1[i]; \
_DataType_output input_elem2 = array2[i]; \
result[i] = __operation__; \
} \
}); /* parallel_for */ \
}); /* queue.submit */ \
_DataType_output input_elem1 = array1[i]; \
_DataType_output input_elem2 = array2[i]; \
result[i] = __operation__; \
} \
}; \
\
auto kernel_func = [&](cl::sycl::handler& cgh) { \
cgh.parallel_for<class custom_elemwise_##__name__##_c_kernel<_DataType_input1, _DataType_input2, _DataType_output> >( \
gws, kernel_parallel_for_func); \
}; \
\
event = DPNP_QUEUE.submit(kernel_func); \
\
event.wait(); \
} \
Expand Down