Skip to content

Commit a0a098d

Browse files
Merge branch 'master' of https://github.com/IntelPython/dpnp into noncentral_chisquare
2 parents fa5f1ea + 6fddc73 commit a0a098d

18 files changed

+618
-227
lines changed

dpnp/backend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ elseif(WIN32)
232232
set(DPNP_MATHLIB_DEP_LIBS
233233
mkl_sycl_dll
234234
mkl_intel_ilp64_dll
235-
mkl_sequential_dll
235+
mkl_tbb_thread_dll # mkl_sequential_dll
236236
mkl_core_dll
237237
sycl
238238
OpenCL

dpnp/backend/examples/example11.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//*****************************************************************************
2+
// Copyright (c) 2016-2020, Intel Corporation
3+
// All rights reserved.
4+
//
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions are met:
7+
// - Redistributions of source code must retain the above copyright notice,
8+
// this list of conditions and the following disclaimer.
9+
// - Redistributions in binary form must reproduce the above copyright notice,
10+
// this list of conditions and the following disclaimer in the documentation
11+
// and/or other materials provided with the distribution.
12+
//
13+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
// THE POSSIBILITY OF SUCH DAMAGE.
24+
//*****************************************************************************
25+
26+
/**
27+
* Example 11.
28+
*
29+
* This example shows simple usage of the DPNP C++ Backend library RNG shuffle function
30+
* for one and ndim arrays.
31+
*
32+
* Possible compile line:
33+
* g++ -g dpnp/backend/examples/example11.cpp -Idpnp -Idpnp/backend/include -Ldpnp -Wl,-rpath='$ORIGIN'/dpnp -ldpnp_backend_c -o example11
34+
*
35+
*/
36+
37+
#include <iostream>
38+
39+
#include <dpnp_iface.hpp>
40+
41+
template <typename T>
42+
void print_dpnp_array(T* arr, size_t size)
43+
{
44+
std::cout << std::endl;
45+
for (size_t i = 0; i < size; ++i)
46+
{
47+
std::cout << arr[i] << ", ";
48+
}
49+
std::cout << std::endl;
50+
}
51+
52+
int main(int, char**)
53+
{
54+
// Two cases:
55+
// 1) array size = 100, ndim = 1, high_dim_size = 10 (aka ndarray with shape (100,) )
56+
// 2) array size = 100, ndim = 2, high_dim_size = 20 (e.g. ndarray with shape (20, 5) and len(array) = 20 )
57+
const size_t ndim_cases = 2;
58+
const size_t itemsize = sizeof(double);
59+
const size_t ndim[ndim_cases] = {1, 2};
60+
const size_t high_dim_size[ndim_cases] = {100, 20};
61+
const size_t size = 100;
62+
const size_t seed = 1234;
63+
64+
// DPNPC dpnp_rng_shuffle_c
65+
// DPNPC interface
66+
double* array_1 = reinterpret_cast<double*>(dpnp_memory_alloc_c(size * sizeof(double)));
67+
for (size_t i = 0; i < ndim_cases; i++)
68+
{
69+
std::cout << "\nREPRODUCE: DPNPC dpnp_rng_shuffle_c:";
70+
std::cout << "\nDIMS: " << ndim[i] <<std::endl;
71+
// init array 0, 1, 2, 3, 4, 5, 6, ....
72+
dpnp_arange_c<double>(0, 1, array_1, size);
73+
// print before shuffle
74+
std::cout << "\nINPUT array:";
75+
print_dpnp_array(array_1, size);
76+
dpnp_rng_srand_c(seed);
77+
dpnp_rng_shuffle_c<double>(array_1, itemsize, ndim[i], high_dim_size[i], size);
78+
// print shuffle result
79+
std::cout << "\nSHUFFLE INPUT array:";
80+
print_dpnp_array(array_1, size);
81+
}
82+
dpnp_memory_free_c(array_1);
83+
}

dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp

Lines changed: 83 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,58 +47,110 @@
4747
/** */ \
4848
/** Function "__name__" executes operator "__operation1__" over each element of the array */ \
4949
/** */ \
50-
/** @param[in] array1 Input array. */ \
51-
/** @param[out] result1 Output array. */ \
52-
/** @param[in] size Number of elements in the input array. */ \
50+
/** @param[out] result_out Output array. */ \
51+
/** @param[in] result_size Output array size. */ \
52+
/** @param[in] result_ndim Number of output array dimensions. */ \
53+
/** @param[in] result_shape Output array shape. */ \
54+
/** @param[in] result_strides Output array strides. */ \
55+
/** @param[in] input1_in Input array 1. */ \
56+
/** @param[in] input1_size Input array 1 size. */ \
57+
/** @param[in] input1_ndim Number of input array 1 dimensions. */ \
58+
/** @param[in] input1_shape Input array 1 shape. */ \
59+
/** @param[in] input1_strides Input array 1 strides. */ \
60+
/** @param[in] where Where condition. */ \
5361
template <typename _DataType_input, typename _DataType_output> \
54-
void __name__(void* array1, void* result1, size_t size);
62+
void __name__(void* result_out, \
63+
const size_t result_size, \
64+
const size_t result_ndim, \
65+
const size_t* result_shape, \
66+
const size_t* result_strides, \
67+
const void* input1_in, \
68+
const size_t input1_size, \
69+
const size_t input1_ndim, \
70+
const size_t* input1_shape, \
71+
const size_t* input1_strides, \
72+
const size_t* where);
5573

5674
#endif
5775

58-
MACRO_1ARG_2TYPES_OP(dpnp_acos_c, cl::sycl::acos(input_elem), oneapi::mkl::vm::acos(DPNP_QUEUE, size, array1, result))
76+
MACRO_1ARG_2TYPES_OP(dpnp_acos_c,
77+
cl::sycl::acos(input_elem),
78+
oneapi::mkl::vm::acos(DPNP_QUEUE, input1_size, input1_data, result))
5979
MACRO_1ARG_2TYPES_OP(dpnp_acosh_c,
6080
cl::sycl::acosh(input_elem),
61-
oneapi::mkl::vm::acosh(DPNP_QUEUE, size, array1, result))
62-
MACRO_1ARG_2TYPES_OP(dpnp_asin_c, cl::sycl::asin(input_elem), oneapi::mkl::vm::asin(DPNP_QUEUE, size, array1, result))
81+
oneapi::mkl::vm::acosh(DPNP_QUEUE, input1_size, input1_data, result))
82+
MACRO_1ARG_2TYPES_OP(dpnp_asin_c,
83+
cl::sycl::asin(input_elem),
84+
oneapi::mkl::vm::asin(DPNP_QUEUE, input1_size, input1_data, result))
6385
MACRO_1ARG_2TYPES_OP(dpnp_asinh_c,
6486
cl::sycl::asinh(input_elem),
65-
oneapi::mkl::vm::asinh(DPNP_QUEUE, size, array1, result))
66-
MACRO_1ARG_2TYPES_OP(dpnp_atan_c, cl::sycl::atan(input_elem), oneapi::mkl::vm::atan(DPNP_QUEUE, size, array1, result))
87+
oneapi::mkl::vm::asinh(DPNP_QUEUE, input1_size, input1_data, result))
88+
MACRO_1ARG_2TYPES_OP(dpnp_atan_c,
89+
cl::sycl::atan(input_elem),
90+
oneapi::mkl::vm::atan(DPNP_QUEUE, input1_size, input1_data, result))
6791
MACRO_1ARG_2TYPES_OP(dpnp_atanh_c,
6892
cl::sycl::atanh(input_elem),
69-
oneapi::mkl::vm::atanh(DPNP_QUEUE, size, array1, result))
70-
MACRO_1ARG_2TYPES_OP(dpnp_cbrt_c, cl::sycl::cbrt(input_elem), oneapi::mkl::vm::cbrt(DPNP_QUEUE, size, array1, result))
71-
MACRO_1ARG_2TYPES_OP(dpnp_ceil_c, cl::sycl::ceil(input_elem), oneapi::mkl::vm::ceil(DPNP_QUEUE, size, array1, result))
72-
MACRO_1ARG_2TYPES_OP(__dpnp_copyto_c, input_elem, DPNP_QUEUE.submit(kernel_func))
73-
MACRO_1ARG_2TYPES_OP(dpnp_cos_c, cl::sycl::cos(input_elem), oneapi::mkl::vm::cos(DPNP_QUEUE, size, array1, result))
74-
MACRO_1ARG_2TYPES_OP(dpnp_cosh_c, cl::sycl::cosh(input_elem), oneapi::mkl::vm::cosh(DPNP_QUEUE, size, array1, result))
93+
oneapi::mkl::vm::atanh(DPNP_QUEUE, input1_size, input1_data, result))
94+
MACRO_1ARG_2TYPES_OP(dpnp_cbrt_c,
95+
cl::sycl::cbrt(input_elem),
96+
oneapi::mkl::vm::cbrt(DPNP_QUEUE, input1_size, input1_data, result))
97+
MACRO_1ARG_2TYPES_OP(dpnp_ceil_c,
98+
cl::sycl::ceil(input_elem),
99+
oneapi::mkl::vm::ceil(DPNP_QUEUE, input1_size, input1_data, result))
100+
MACRO_1ARG_2TYPES_OP(dpnp_copyto_c, input_elem, DPNP_QUEUE.submit(kernel_func))
101+
MACRO_1ARG_2TYPES_OP(dpnp_cos_c,
102+
cl::sycl::cos(input_elem),
103+
oneapi::mkl::vm::cos(DPNP_QUEUE, input1_size, input1_data, result))
104+
MACRO_1ARG_2TYPES_OP(dpnp_cosh_c,
105+
cl::sycl::cosh(input_elem),
106+
oneapi::mkl::vm::cosh(DPNP_QUEUE, input1_size, input1_data, result))
75107
MACRO_1ARG_2TYPES_OP(dpnp_degrees_c, cl::sycl::degrees(input_elem), DPNP_QUEUE.submit(kernel_func))
76-
MACRO_1ARG_2TYPES_OP(dpnp_ediff1d_c, array1[i + 1] - input_elem, DPNP_QUEUE.submit(kernel_func))
77-
MACRO_1ARG_2TYPES_OP(dpnp_exp2_c, cl::sycl::exp2(input_elem), oneapi::mkl::vm::exp2(DPNP_QUEUE, size, array1, result))
78-
MACRO_1ARG_2TYPES_OP(dpnp_exp_c, cl::sycl::exp(input_elem), oneapi::mkl::vm::exp(DPNP_QUEUE, size, array1, result))
108+
MACRO_1ARG_2TYPES_OP(dpnp_ediff1d_c, input1_data[output_id + 1] - input_elem, DPNP_QUEUE.submit(kernel_func))
109+
MACRO_1ARG_2TYPES_OP(dpnp_exp2_c,
110+
cl::sycl::exp2(input_elem),
111+
oneapi::mkl::vm::exp2(DPNP_QUEUE, input1_size, input1_data, result))
112+
MACRO_1ARG_2TYPES_OP(dpnp_exp_c,
113+
cl::sycl::exp(input_elem),
114+
oneapi::mkl::vm::exp(DPNP_QUEUE, input1_size, input1_data, result))
79115
MACRO_1ARG_2TYPES_OP(dpnp_expm1_c,
80116
cl::sycl::expm1(input_elem),
81-
oneapi::mkl::vm::expm1(DPNP_QUEUE, size, array1, result))
82-
MACRO_1ARG_2TYPES_OP(dpnp_fabs_c, cl::sycl::fabs(input_elem), oneapi::mkl::vm::abs(DPNP_QUEUE, size, array1, result))
117+
oneapi::mkl::vm::expm1(DPNP_QUEUE, input1_size, input1_data, result))
118+
MACRO_1ARG_2TYPES_OP(dpnp_fabs_c,
119+
cl::sycl::fabs(input_elem),
120+
oneapi::mkl::vm::abs(DPNP_QUEUE, input1_size, input1_data, result))
83121
MACRO_1ARG_2TYPES_OP(dpnp_floor_c,
84122
cl::sycl::floor(input_elem),
85-
oneapi::mkl::vm::floor(DPNP_QUEUE, size, array1, result))
123+
oneapi::mkl::vm::floor(DPNP_QUEUE, input1_size, input1_data, result))
86124
MACRO_1ARG_2TYPES_OP(dpnp_log10_c,
87125
cl::sycl::log10(input_elem),
88-
oneapi::mkl::vm::log10(DPNP_QUEUE, size, array1, result))
126+
oneapi::mkl::vm::log10(DPNP_QUEUE, input1_size, input1_data, result))
89127
MACRO_1ARG_2TYPES_OP(dpnp_log1p_c,
90128
cl::sycl::log1p(input_elem),
91-
oneapi::mkl::vm::log1p(DPNP_QUEUE, size, array1, result))
92-
MACRO_1ARG_2TYPES_OP(dpnp_log2_c, cl::sycl::log2(input_elem), oneapi::mkl::vm::log2(DPNP_QUEUE, size, array1, result))
93-
MACRO_1ARG_2TYPES_OP(dpnp_log_c, cl::sycl::log(input_elem), oneapi::mkl::vm::ln(DPNP_QUEUE, size, array1, result))
129+
oneapi::mkl::vm::log1p(DPNP_QUEUE, input1_size, input1_data, result))
130+
MACRO_1ARG_2TYPES_OP(dpnp_log2_c,
131+
cl::sycl::log2(input_elem),
132+
oneapi::mkl::vm::log2(DPNP_QUEUE, input1_size, input1_data, result))
133+
MACRO_1ARG_2TYPES_OP(dpnp_log_c,
134+
cl::sycl::log(input_elem),
135+
oneapi::mkl::vm::ln(DPNP_QUEUE, input1_size, input1_data, result))
94136
MACRO_1ARG_2TYPES_OP(dpnp_radians_c, cl::sycl::radians(input_elem), DPNP_QUEUE.submit(kernel_func))
95-
MACRO_1ARG_2TYPES_OP(dpnp_sin_c, cl::sycl::sin(input_elem), oneapi::mkl::vm::sin(DPNP_QUEUE, size, array1, result))
96-
MACRO_1ARG_2TYPES_OP(dpnp_sinh_c, cl::sycl::sinh(input_elem), oneapi::mkl::vm::sinh(DPNP_QUEUE, size, array1, result))
97-
MACRO_1ARG_2TYPES_OP(dpnp_sqrt_c, cl::sycl::sqrt(input_elem), oneapi::mkl::vm::sqrt(DPNP_QUEUE, size, array1, result))
98-
MACRO_1ARG_2TYPES_OP(dpnp_tan_c, cl::sycl::tan(input_elem), oneapi::mkl::vm::tan(DPNP_QUEUE, size, array1, result))
99-
MACRO_1ARG_2TYPES_OP(dpnp_tanh_c, cl::sycl::tanh(input_elem), oneapi::mkl::vm::tanh(DPNP_QUEUE, size, array1, result))
137+
MACRO_1ARG_2TYPES_OP(dpnp_sin_c,
138+
cl::sycl::sin(input_elem),
139+
oneapi::mkl::vm::sin(DPNP_QUEUE, input1_size, input1_data, result))
140+
MACRO_1ARG_2TYPES_OP(dpnp_sinh_c,
141+
cl::sycl::sinh(input_elem),
142+
oneapi::mkl::vm::sinh(DPNP_QUEUE, input1_size, input1_data, result))
143+
MACRO_1ARG_2TYPES_OP(dpnp_sqrt_c,
144+
cl::sycl::sqrt(input_elem),
145+
oneapi::mkl::vm::sqrt(DPNP_QUEUE, input1_size, input1_data, result))
146+
MACRO_1ARG_2TYPES_OP(dpnp_tan_c,
147+
cl::sycl::tan(input_elem),
148+
oneapi::mkl::vm::tan(DPNP_QUEUE, input1_size, input1_data, result))
149+
MACRO_1ARG_2TYPES_OP(dpnp_tanh_c,
150+
cl::sycl::tanh(input_elem),
151+
oneapi::mkl::vm::tanh(DPNP_QUEUE, input1_size, input1_data, result))
100152
MACRO_1ARG_2TYPES_OP(dpnp_trunc_c,
101153
cl::sycl::trunc(input_elem),
102-
oneapi::mkl::vm::trunc(DPNP_QUEUE, size, array1, result))
154+
oneapi::mkl::vm::trunc(DPNP_QUEUE, input1_size, input1_data, result))
103155

104156
#undef MACRO_1ARG_2TYPES_OP

0 commit comments

Comments
 (0)