Skip to content

Restyle statistics kernels #116

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
53 changes: 28 additions & 25 deletions dpnp/backend/custom_kernels_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@ void custom_cov_c(void* array1_in, void* result1, size_t nrows, size_t ncols)
// fill lower elements
cl::sycl::event event;
cl::sycl::range<1> gws(nrows * nrows);
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_cov_c_kernel<_DataType> >(
gws,
[=](cl::sycl::id<1> global_id)
{
const size_t idx = global_id[0];
const size_t row_idx = idx / nrows;
const size_t col_idx = idx - row_idx * nrows;
if (col_idx < row_idx)
{
result[idx] = result[col_idx * nrows + row_idx];
}
}); // parallel_for
}); // queue.submit
auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) {
const size_t idx = global_id[0];
const size_t row_idx = idx / nrows;
const size_t col_idx = idx - row_idx * nrows;
if (col_idx < row_idx)
{
result[idx] = result[col_idx * nrows + row_idx];
}
};

auto kernel_func = [&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_cov_c_kernel<_DataType> >(gws, kernel_parallel_for_func);
};

event = DPNP_QUEUE.submit(kernel_func);

event.wait();

dpnp_memory_free_c(mean);
Expand Down Expand Up @@ -350,18 +352,19 @@ void custom_var_c(
_ResultType* squared_deviations = reinterpret_cast<_ResultType*>(dpnp_memory_alloc_c(size * sizeof(_ResultType)));

cl::sycl::range<1> gws(size);
event = DPNP_QUEUE.submit([&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_var_c_kernel<_DataType, _ResultType> >(
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)*/
{
_ResultType deviation = static_cast<_ResultType>(array1[i]) - mean_val;
squared_deviations[i] = deviation * deviation;
}
}); /* parallel_for */
}); /* queue.submit */
_ResultType deviation = static_cast<_ResultType>(array1[i]) - mean_val;
squared_deviations[i] = deviation * deviation;
}
};

auto kernel_func = [&](cl::sycl::handler& cgh) {
cgh.parallel_for<class custom_var_c_kernel<_DataType, _ResultType> >(gws, kernel_parallel_for_func);
};

event = DPNP_QUEUE.submit(kernel_func);

event.wait();

Expand Down