DPNP C++ backend kernel library 0.18.0dev0
Data Parallel Extension for NumPy*
Loading...
Searching...
No Matches
dpnp_iface.hpp
1//*****************************************************************************
2// Copyright (c) 2016-2025, 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 * This header file is for interface Cython with C++.
28 * It should not contains any backend specific headers (like SYCL or math
29 * library) because all included headers will be exposed in Cython compilation
30 * procedure
31 *
32 * We would like to avoid backend specific things in higher level Cython
33 * modules. Any backend interface functions and types should be defined here.
34 *
35 * Also, this file should contains documentation on functions and types
36 * which are used in the interface
37 */
38
39#pragma once
40#ifndef BACKEND_IFACE_H // Cython compatibility
41#define BACKEND_IFACE_H
42
43#include <cstdint>
44#include <vector>
45
46#ifdef _WIN32
47#define INP_DLLEXPORT __declspec(dllexport)
48#else
49#define INP_DLLEXPORT
50#endif
51
52#if defined(_MSC_VER)
53#include <BaseTsd.h>
54typedef SSIZE_T ssize_t;
55#endif
56
57typedef ssize_t shape_elem_type;
58
59#include <dpctl_sycl_interface.h>
60
61#include "dpnp_iface_random.hpp"
62
76INP_DLLEXPORT size_t dpnp_queue_is_cpu_c();
77
89INP_DLLEXPORT char *dpnp_memory_alloc_c(DPCTLSyclQueueRef q_ref,
90 size_t size_in_bytes);
91INP_DLLEXPORT char *dpnp_memory_alloc_c(size_t size_in_bytes);
92
93INP_DLLEXPORT void dpnp_memory_free_c(DPCTLSyclQueueRef q_ref, void *ptr);
94INP_DLLEXPORT void dpnp_memory_free_c(void *ptr);
95
96INP_DLLEXPORT void dpnp_memory_memcpy_c(DPCTLSyclQueueRef q_ref,
97 void *dst,
98 const void *src,
99 size_t size_in_bytes);
100INP_DLLEXPORT void
101 dpnp_memory_memcpy_c(void *dst, const void *src, size_t size_in_bytes);
102
116template <typename _DataType>
117INP_DLLEXPORT DPCTLSyclEventRef
118 dpnp_partition_c(DPCTLSyclQueueRef q_ref,
119 void *array,
120 void *array2,
121 void *result,
122 const size_t kth,
123 const shape_elem_type *shape,
124 const size_t ndim,
125 const DPCTLEventVectorRef dep_event_vec_ref);
126
127template <typename _DataType>
128INP_DLLEXPORT void dpnp_partition_c(void *array,
129 void *array2,
130 void *result,
131 const size_t kth,
132 const shape_elem_type *shape,
133 const size_t ndim);
134
145template <typename _DataType>
146INP_DLLEXPORT DPCTLSyclEventRef
147 dpnp_initval_c(DPCTLSyclQueueRef q_ref,
148 void *result1,
149 void *value,
150 size_t size,
151 const DPCTLEventVectorRef dep_event_vec_ref);
152
153template <typename _DataType>
154INP_DLLEXPORT void dpnp_initval_c(void *result1, void *value, size_t size);
155
156#define MACRO_1ARG_1TYPE_OP(__name__, __operation1__, __operation2__) \
157 template <typename _DataType> \
158 INP_DLLEXPORT DPCTLSyclEventRef __name__( \
159 DPCTLSyclQueueRef q_ref, void *result_out, const size_t result_size, \
160 const size_t result_ndim, const shape_elem_type *result_shape, \
161 const shape_elem_type *result_strides, const void *input1_in, \
162 const size_t input1_size, const size_t input1_ndim, \
163 const shape_elem_type *input1_shape, \
164 const shape_elem_type *input1_strides, const size_t *where, \
165 const DPCTLEventVectorRef dep_event_vec_ref); \
166 \
167 template <typename _DataType> \
168 INP_DLLEXPORT void __name__( \
169 void *result_out, const size_t result_size, const size_t result_ndim, \
170 const shape_elem_type *result_shape, \
171 const shape_elem_type *result_strides, const void *input1_in, \
172 const size_t input1_size, const size_t input1_ndim, \
173 const shape_elem_type *input1_shape, \
174 const shape_elem_type *input1_strides, const size_t *where);
175
176#include <dpnp_gen_1arg_1type_tbl.hpp>
177
189template <typename _DataType_input, typename _DataType_output>
190INP_DLLEXPORT DPCTLSyclEventRef
191 dpnp_modf_c(DPCTLSyclQueueRef q_ref,
192 void *array1_in,
193 void *result1_out,
194 void *result2_out,
195 size_t size,
196 const DPCTLEventVectorRef dep_event_vec_ref);
197
198template <typename _DataType_input, typename _DataType_output>
199INP_DLLEXPORT void dpnp_modf_c(void *array1_in,
200 void *result1_out,
201 void *result2_out,
202 size_t size);
203
213template <typename _DataType>
214INP_DLLEXPORT DPCTLSyclEventRef
215 dpnp_ones_c(DPCTLSyclQueueRef q_ref,
216 void *result,
217 size_t size,
218 const DPCTLEventVectorRef dep_event_vec_ref);
219
220template <typename _DataType>
221INP_DLLEXPORT void dpnp_ones_c(void *result, size_t size);
222
232template <typename _DataType>
233INP_DLLEXPORT DPCTLSyclEventRef
234 dpnp_ones_like_c(DPCTLSyclQueueRef q_ref,
235 void *result,
236 size_t size,
237 const DPCTLEventVectorRef dep_event_vec_ref);
238
239template <typename _DataType>
240INP_DLLEXPORT void dpnp_ones_like_c(void *result, size_t size);
241
251template <typename _DataType>
252INP_DLLEXPORT DPCTLSyclEventRef
253 dpnp_zeros_c(DPCTLSyclQueueRef q_ref,
254 void *result,
255 size_t size,
256 const DPCTLEventVectorRef dep_event_vec_ref);
257
258template <typename _DataType>
259INP_DLLEXPORT void dpnp_zeros_c(void *result, size_t size);
260
270template <typename _DataType>
271INP_DLLEXPORT DPCTLSyclEventRef
272 dpnp_zeros_like_c(DPCTLSyclQueueRef q_ref,
273 void *result,
274 size_t size,
275 const DPCTLEventVectorRef dep_event_vec_ref);
276
277template <typename _DataType>
278INP_DLLEXPORT void dpnp_zeros_like_c(void *result, size_t size);
279
280#endif // BACKEND_IFACE_H
DPCTLSyclEventRef dpnp_initval_c(DPCTLSyclQueueRef q_ref, void *result1, void *value, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
implementation of creating filled with value array function
size_t dpnp_queue_is_cpu_c()
SYCL queue device status.
DPCTLSyclEventRef dpnp_zeros_like_c(DPCTLSyclQueueRef q_ref, void *result, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
Implementation of zeros_like function.
DPCTLSyclEventRef dpnp_ones_c(DPCTLSyclQueueRef q_ref, void *result, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
Implementation of ones function.
DPCTLSyclEventRef dpnp_ones_like_c(DPCTLSyclQueueRef q_ref, void *result, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
Implementation of ones_like function.
char * dpnp_memory_alloc_c(DPCTLSyclQueueRef q_ref, size_t size_in_bytes)
SYCL queue memory allocation.
DPCTLSyclEventRef dpnp_modf_c(DPCTLSyclQueueRef q_ref, void *array1_in, void *result1_out, void *result2_out, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
modf function.
DPCTLSyclEventRef dpnp_zeros_c(DPCTLSyclQueueRef q_ref, void *result, size_t size, const DPCTLEventVectorRef dep_event_vec_ref)
Implementation of zeros function.
DPCTLSyclEventRef dpnp_partition_c(DPCTLSyclQueueRef q_ref, void *array, void *array2, void *result, const size_t kth, const shape_elem_type *shape, const size_t ndim, const DPCTLEventVectorRef dep_event_vec_ref)
Return a partitioned copy of an array.