Skip to content

MEAN add MKL kernel #119

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 4 commits into from
Oct 6, 2020
Merged
Changes from 1 commit
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
22 changes: 18 additions & 4 deletions dpnp/backend/custom_kernels_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@

#include <iostream>
#include <mkl_blas_sycl.hpp>
#include <mkl_stats_sycl.hpp>

#include <backend_iface.hpp>
#include "backend_pstl.hpp"
#include "backend_utils.hpp"
#include "queue_sycl.hpp"

namespace mkl_blas = oneapi::mkl::blas::row_major;
namespace mkl_stats = oneapi::mkl::stats;

template <typename _DataType>
class custom_cov_c_kernel;
Expand Down Expand Up @@ -198,13 +200,25 @@ void custom_mean_c(void* array1_in, void* result1, const size_t* shape, size_t n
return;
}

_DataType* sum = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(1 * sizeof(_DataType)));
if constexpr (std::is_same<_DataType, double>::value || std::is_same<_DataType, float>::value)
{
_ResultType* array = reinterpret_cast<_DataType*>(array1_in);
auto dataset = mkl_stats::make_dataset<mkl_stats::layout::row_major>(1, size, array);

custom_sum_c<_DataType>(array1_in, sum, size);
cl::sycl::event event = mkl_stats::mean(DPNP_QUEUE, dataset, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a comment with documentation pointer to this functionality from MKL?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like
// http://asdada


result[0] = static_cast<_ResultType>(sum[0]) / static_cast<_ResultType>(size);
event.wait();
}
else
{
_DataType* sum = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(1 * sizeof(_DataType)));

dpnp_memory_free_c(sum);
custom_sum_c<_DataType>(array1_in, sum, size);

result[0] = static_cast<_ResultType>(sum[0]) / static_cast<_ResultType>(size);

dpnp_memory_free_c(sum);
}

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please delete this debug code

std::cout << "mean result " << result[0] << "\n";
Expand Down