Repository navigation
Expand file tree
/
Copy pathdpctl_vector.h
More file actions
98 lines (91 loc) · 5.61 KB
/
Copy pathdpctl_vector.h
File metadata and controls
98 lines (91 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//===-- dpctl_vector.h - Defines macros for opaque vector types -*-C++-*- =//
//
// Data Parallel Control (dpctl)
//
// Copyright 2020-2021 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// A set of helper macros are defined here to create opaque lists (implemented
/// using std::vector) and helper functions of any dpctl type.
///
//===----------------------------------------------------------------------===//
#pragma once
#include "Support/DllExport.h"
#include "Support/ExternC.h"
#include "Support/MemOwnershipAttrs.h"
#include "dpctl_data_types.h"
DPCTL_C_EXTERN_C_BEGIN
/*!
* @brief Declare an opaque pointer type for a std::vector of opaque pointers
* wrapping SYCL data types.
*/
#define DPCTL_DECLARE_VECTOR_TYPE(EL) \
typedef struct DPCTL##EL##Vector *DPCTL##EL##VectorRef;
#define DPCTL_DECLARE_VECTOR_FN(EL) \
/*! \
@brief Create an opaque pointer to a std::vector of opaque pointers \
wrapping the SYCL data type. \
@return Returns a new opaque pointer to a vector. \
*/ \
DPCTL_API \
__dpctl_give DPCTL##EL##VectorRef DPCTL##EL##Vector_Create(void); \
/*! \
@brief Create an opaque pointer to a std::vector created from the \
input raw array. The elements of the input array are deep copied before \
inserting the copies into the vector. \
@param len Number of elements in the input array. \
@param elems A C array whose elements will be copied into the returned \
vector. \
@return Returns a new opaque pointer to a vector. \
*/ \
DPCTL_API \
__dpctl_give DPCTL##EL##VectorRef DPCTL##EL##Vector_CreateFromArray( \
size_t len, __dpctl_keep DPCTLSycl##EL##Ref *elems); \
\
/*! \
@brief Delete all elements in the vector and then delete the vector. \
@param VRef Opaque pointer to a vector to be deleted. \
*/ \
DPCTL_API \
void DPCTL##EL##Vector_Delete(__dpctl_take DPCTL##EL##VectorRef VRef); \
/*! \
@brief Delete all the elements of the std::vector \
@param VRef Opaque pointer to a vector. \
*/ \
DPCTL_API \
void DPCTL##EL##Vector_Clear(__dpctl_keep DPCTL##EL##VectorRef VRef); \
/*! \
@brief Returns the number of elements in the vector. \
@param VRef Opaque pointer to a vector. \
@return The current size of the vector. \
*/ \
DPCTL_API \
size_t DPCTL##EL##Vector_Size(__dpctl_keep DPCTL##EL##VectorRef VRef); \
/*! \
@brief Returns the element at the specified index. \
@param VRef Opaque pointer to a vector. \
@param index The index postion of the element to be returned. \
@return The element at the specified postion, if the index position is \
out of bounds then a nullptr is returned. \
*/ \
DPCTL_API \
__dpctl_give DPCTLSycl##EL##Ref DPCTL##EL##Vector_GetAt( \
__dpctl_keep DPCTL##EL##VectorRef VRef, size_t index);
#define DPCTL_DECLARE_VECTOR(EL) \
DPCTL_DECLARE_VECTOR_TYPE(EL) \
DPCTL_DECLARE_VECTOR_FN(EL)
DPCTL_C_EXTERN_C_END