DPNP C++ backend kernel library 0.18.0dev0
Data Parallel Extension for NumPy*
Loading...
Searching...
No Matches
dpnp_test_utils.hpp
1#include <iostream>
2#include <vector>
3
4#include "dpnp_iterator.hpp"
5
6using namespace std;
8using dpnpc_value_t = dpnpc_it_t::value_type;
9using dpnpc_index_t = dpnpc_it_t::size_type;
10
11template <typename _DataType>
12vector<_DataType> get_input_data(const vector<dpnpc_index_t> &shape)
13{
14 const dpnpc_index_t size =
15 accumulate(shape.begin(), shape.end(), dpnpc_index_t(1),
16 multiplies<dpnpc_index_t>());
17
18 vector<_DataType> input_data(size);
19 iota(input_data.begin(), input_data.end(),
20 1); // let's start from 1 to avoid cleaned memory comparison
21
22 return input_data;
23}
24
25template <typename _DataType>
26_DataType *get_shared_data(const vector<_DataType> &input_data)
27{
28 const size_t data_size_in_bytes = input_data.size() * sizeof(_DataType);
29 _DataType *shared_data =
30 reinterpret_cast<_DataType *>(dpnp_memory_alloc_c(data_size_in_bytes));
31 copy(input_data.begin(), input_data.end(), shared_data);
32
33 return shared_data;
34}
Iterator for DPNPC_id type.
char * dpnp_memory_alloc_c(DPCTLSyclQueueRef q_ref, size_t size_in_bytes)
SYCL queue memory allocation.