Skip to content

Commit 3af9b6e

Browse files
committed
Adds DPPL C-API wrappers for Sycl context, device, queue classes.
- The Sycl queue manager is not separated out from the queue interface. - C-API for sycl::context, sycl::device, sycl::queue classes. - The Cython extension now has classes for SyclQueue, SyclDevice, SyclContext.
1 parent 7aa0512 commit 3af9b6e

16 files changed

+1169
-527
lines changed

backends/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ message(STATUS "OpenCL_LIBRARY: ${OpenCL_LIBRARY}")
9696
add_library(
9797
DPPLSyclInterface
9898
SHARED
99+
source/dppl_sycl_context_interface.cpp
100+
source/dppl_sycl_device_interface.cpp
99101
source/dppl_sycl_queue_interface.cpp
102+
source/dppl_sycl_queue_manager.cpp
100103
)
101104

102105
# Install DPPLOpenCLInterface
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===--- dppl_sycl_context_interface.h - DPPL-SYCL interface --*--C++ --*--===//
2+
//
3+
// Python Data Parallel Processing Library (PyDPPL)
4+
//
5+
// Copyright 2020 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
///
21+
/// \file
22+
/// This header declares a C API to SYCL's sycl::context interface.
23+
///
24+
//===----------------------------------------------------------------------===//
25+
26+
#pragma once
27+
28+
#include "dppl_data_types.h"
29+
#include "dppl_sycl_types.h"
30+
#include "Support/DllExport.h"
31+
#include "Support/ExternC.h"
32+
#include "Support/MemOwnershipAttrs.h"
33+
#include <stdbool.h>
34+
35+
DPPL_C_EXTERN_C_BEGIN
36+
37+
/*!
38+
* @brief
39+
*
40+
* @param CtxtRef My Param doc
41+
* @return {return} My Param doc
42+
*/
43+
bool DPPLIsHostContext (__dppl_keep const DPPLSyclContextRef CtxtRef);
44+
45+
/*!
46+
* @brief
47+
*
48+
* @param CtxtRef My Param doc
49+
*/
50+
void DPPLDeleteSyclContext (__dppl_take DPPLSyclContextRef CtxtRef);
51+
52+
DPPL_C_EXTERN_C_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
//===--- dppl_sycl_device_interface.h - DPPL-SYCL interface ---*---C++ -*---===//
2+
//
3+
// Python Data Parallel Processing Library (PyDPPL)
4+
//
5+
// Copyright 2020 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
///
21+
/// \file
22+
/// This header declares a C interface to sycl::device. Not all of the device
23+
/// API is exposed, only the bits needed in other places like context and queue
24+
/// interfaces.
25+
///
26+
//===----------------------------------------------------------------------===//
27+
28+
#pragma once
29+
30+
#include "dppl_data_types.h"
31+
#include "dppl_sycl_types.h"
32+
#include "Support/DllExport.h"
33+
#include "Support/ExternC.h"
34+
#include "Support/MemOwnershipAttrs.h"
35+
36+
DPPL_C_EXTERN_C_BEGIN
37+
38+
/*!
39+
* @brief Redefinition of Sycl's device_type so that we do not have to include
40+
* sycl.hpp here and in the Python bindings.
41+
*
42+
*/
43+
typedef enum
44+
{
45+
DPPL_CPU,
46+
DPPL_GPU,
47+
DPPL_ACCELERATOR,
48+
DPPL_CUSTOM,
49+
DPPL_AUTOMATIC,
50+
DPPL_HOST,
51+
DPPL_ALL
52+
} DPPLSyclDeviceType;
53+
54+
/*!
55+
* @brief Prints out some of the info::deivice attributes for the device.
56+
*
57+
* @param DRef A DPPLSyclDeviceRef pointer.
58+
*/
59+
DPPL_API
60+
void DPPLDumpDeviceInfo (__dppl_keep const DPPLSyclDeviceRef DRef);
61+
62+
/*!
63+
* @brief Frees a DPPLSyclDeviceRef pointer.
64+
*
65+
* @param DRef The DPPLSyclDeviceRef pointer to be freed.
66+
*/
67+
DPPL_API
68+
void DPPLDeleteSyclDevice (__dppl_take DPPLSyclDeviceRef DRef);
69+
70+
/*!
71+
* @brief
72+
*
73+
* @param DRef My Param doc
74+
* @return {return} My Param doc
75+
*/
76+
DPPL_API
77+
bool DPPLDeviceIsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef);
78+
79+
/*!
80+
* @brief
81+
*
82+
* @param DRef My Param doc
83+
* @return {return} My Param doc
84+
*/
85+
DPPL_API
86+
bool DPPLDeviceIsCPU (__dppl_keep const DPPLSyclDeviceRef DRef);
87+
88+
/*!
89+
* @brief
90+
*
91+
* @param DRef My Param doc
92+
* @return {return} My Param doc
93+
*/
94+
DPPL_API
95+
bool DPPLDeviceIsGPU (__dppl_keep const DPPLSyclDeviceRef DRef);
96+
97+
/*!
98+
* @brief
99+
*
100+
* @param DRef My Param doc
101+
* @return {return} My Param doc
102+
*/
103+
DPPL_API
104+
bool DPPLDeviceIsHost (__dppl_keep const DPPLSyclDeviceRef DRef);
105+
106+
/*!
107+
* @brief
108+
*
109+
* @param DRef My Param doc
110+
* @return {return} My Param doc
111+
*/
112+
DPPL_API
113+
__dppl_give const char*
114+
DPPLGetDeviceDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef);
115+
116+
/*!
117+
* @brief
118+
*
119+
* @param DriverInfo My Param doc
120+
* @return {return} My Param doc
121+
*/
122+
DPPL_API
123+
void DPPLDeleteDeviceDriverInfo (__dppl_take const char* DriverInfo);
124+
125+
/*!
126+
* @brief
127+
*
128+
* @param DRef My Param doc
129+
* @return {return} My Param doc
130+
*/
131+
DPPL_API
132+
__dppl_give const char*
133+
DPPLGetDeviceName (__dppl_keep const DPPLSyclDeviceRef DRef);
134+
135+
/*!
136+
* @brief
137+
*
138+
* @param DeviceName My Param doc
139+
* @return {return} My Param doc
140+
*/
141+
DPPL_API
142+
void DPPLDeleteDeviceName (__dppl_take const char* DeviceName);
143+
144+
/*!
145+
* @brief
146+
*
147+
* @param DRef My Param doc
148+
* @return {return} My Param doc
149+
*/
150+
DPPL_API
151+
__dppl_give const char*
152+
DPPLGetDeviceVendorName (__dppl_keep const DPPLSyclDeviceRef DRef);
153+
154+
/*!
155+
* @brief
156+
*
157+
* @param char My Param doc
158+
* @return {return} My Param doc
159+
*/
160+
DPPL_API
161+
void DPPLDeleteDeviceVendorName (__dppl_take const char* VendorName);
162+
163+
/*!
164+
* @brief
165+
*
166+
* @param DRef My Param doc
167+
* @return {return} My Param doc
168+
*/
169+
DPPL_API
170+
bool DPPLGetDeviceHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef);
171+
172+
DPPL_C_EXTERN_C_END

0 commit comments

Comments
 (0)