Skip to content

Commit 1edf230

Browse files
diptorupdDiptorup Deb
authored andcommitted
Introduce the concept of sycl backends into dpctl.
-- Queues now need to be queried using both backend and device type. -- Fix test cases. -- Platform interfaces now can return the list of available backends. -- Fix skiped tests. -- Expand the platform interface to provide backend info. -- Move backend enums to platfrom from context. -- Add comments. -- Store opencl_cpu, opencl_gpu, and level0_gpu queues inside queue manager. -- Fixed enum typedefs, added cython dict to store backends and device types.
1 parent cace295 commit 1edf230

19 files changed

+680
-374
lines changed

backends/include/dppl_sycl_context_interface.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,14 @@
2727

2828
#include "dppl_data_types.h"
2929
#include "dppl_sycl_types.h"
30+
#include "dppl_sycl_platform_interface.h"
3031
#include "Support/DllExport.h"
3132
#include "Support/ExternC.h"
3233
#include "Support/MemOwnershipAttrs.h"
3334
#include <stdbool.h>
3435

3536
DPPL_C_EXTERN_C_BEGIN
3637

37-
/*!
38-
* @brief Redefinition of DPC++'s backend types. We have this wrapper so that
39-
* the sycl header is not exposed to Python extensions.
40-
*
41-
*/
42-
typedef enum
43-
{
44-
DPPL_OPENCL = 1 << 16,
45-
DPPL_HOST = 1 << 15,
46-
DPPL_LEVEL_ZERO = 1 << 14,
47-
DPPL_CUDA = 1 << 13
48-
} DPPLSyclBEType;
49-
5038
/*!
5139
* @brief Returns true if this SYCL context is a host context.
5240
*
@@ -63,7 +51,7 @@ bool DPPLContext_IsHost (__dppl_keep const DPPLSyclContextRef CtxRef);
6351
* @return {return} My Param doc
6452
*/
6553
DPPL_API
66-
DPPLSyclBackendType
54+
DPPLSyclBEType
6755
DPPLContext_GetBackend (__dppl_keep const DPPLSyclContextRef CtxRef);
6856

6957
/*!

backends/include/dppl_sycl_device_interface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ DPPL_C_EXTERN_C_BEGIN
4040
* sycl.hpp here and in the Python bindings.
4141
*
4242
*/
43-
typedef enum
43+
enum DPPLSyclDeviceType
4444
{
4545
DPPL_CPU = 1 << 0,
4646
DPPL_GPU = 1 << 1,
4747
DPPL_ACCELERATOR = 1 << 2,
4848
DPPL_CUSTOM = 1 << 3,
4949
DPPL_AUTOMATIC = 1 << 4,
50-
DPPL_HOST = 1 << 5,
50+
DPPL_HOST_DEVICE = 1 << 5,
5151
DPPL_ALL = 1 << 6
5252
// IMP: before adding new values here look at DPPLSyclBEType enum. The
5353
// values should not overlap.
54-
} DPPLSyclDeviceType;
54+
};
5555

5656
/*!
5757
* @brief Prints out some of the info::deivice attributes for the device.

backends/include/dppl_sycl_platform_interface.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,57 @@
2828
#include "dppl_data_types.h"
2929
#include "Support/DllExport.h"
3030
#include "Support/ExternC.h"
31+
#include "Support/MemOwnershipAttrs.h"
3132

3233
DPPL_C_EXTERN_C_BEGIN
3334

3435
/*!
35-
* @brief Get the number of sycl::platform available on the system.
36+
* @brief Redefinition of DPC++'s backend types. We have this wrapper so that
37+
* the sycl header is not exposed to Python extensions.
38+
*
39+
*/
40+
enum DPPLSyclBEType
41+
{
42+
DPPL_UNKNOWN_BACKEND = 0x0,
43+
DPPL_OPENCL = 1 << 16,
44+
DPPL_HOST = 1 << 15,
45+
DPPL_LEVEL_ZERO = 1 << 14,
46+
DPPL_CUDA = 1 << 13
47+
};
48+
49+
/*!
50+
* @brief Returns the number of sycl::platform available on the system.
3651
*
3752
* @return The number of available sycl::platforms.
3853
*/
3954
DPPL_API
4055
size_t DPPLPlatform_GetNumPlatforms ();
4156

57+
/*!
58+
* @brief Returns the number of unique sycl backends on the system not counting
59+
* the host backend.
60+
*
61+
* @return The number of unique sycl backends.
62+
*/
63+
DPPL_API
64+
size_t DPPLPlatform_GetNumBackends ();
65+
66+
/*!
67+
* @brief Returns an array of the unique DPPLSyclBEType values on the system.
68+
*
69+
* @return An array of DPPLSyclBEType enum values.
70+
*/
71+
DPPL_API
72+
__dppl_give enum DPPLSyclBEType* DPPLPlatform_GetListOfBackends ();
73+
74+
/*!
75+
* @brief Frees an array of DPPLSyclBEType enum values.
76+
*
77+
* @param BEArr An array of DPPLSyclBEType enum values to be freed.
78+
*/
79+
DPPL_API
80+
void DPPLPlatform_DeleteListOfBackends (__dppl_take enum DPPLSyclBEType* BEArr);
81+
4282
/*!
4383
* @brief Prints out some selected info about all sycl::platform on the system.
4484
*

backends/include/dppl_sycl_queue_manager.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ __dppl_give DPPLSyclQueueRef DPPLQueueMgr_GetCurrentQueue ();
6464
* raised if no such device exists.
6565
*/
6666
DPPL_API
67-
__dppl_give DPPLSyclQueueRef DPPLQueueMgr_GetQueue (DPPLSyclBEType BETy,
68-
DPPLSyclDeviceType DeviceTy,
69-
size_t DNum);
67+
__dppl_give DPPLSyclQueueRef
68+
DPPLQueueMgr_GetQueue (enum DPPLSyclBEType BETy,
69+
enum DPPLSyclDeviceType DeviceTy,
70+
size_t DNum);
7071

7172
/*!
7273
* @brief Get the number of activated queues not including the global or
@@ -87,8 +88,8 @@ size_t DPPLQueueMgr_GetNumActivatedQueues ();
8788
* @return The number of available queues.
8889
*/
8990
DPPL_API
90-
size_t DPPLQueueMgr_GetNumQueues (DPPLSyclBEType BETy,
91-
DPPLSyclDeviceType DeviceTy);
91+
size_t DPPLQueueMgr_GetNumQueues (enum DPPLSyclBEType BETy,
92+
enum DPPLSyclDeviceType DeviceTy);
9293

9394
/*!
9495
* @brief Set the default DPPL queue to the sycl::queue for the given backend
@@ -101,8 +102,8 @@ size_t DPPLQueueMgr_GetNumQueues (DPPLSyclBEType BETy,
101102
* @param DNum Device id for the device (defaults to 0)
102103
*/
103104
DPPL_API
104-
void DPPLQueueMgr_SetAsDefaultQueue (DPPLSyclBEType BETy,
105-
DPPLSyclDeviceType DeviceTy,
105+
void DPPLQueueMgr_SetAsDefaultQueue (enum DPPLSyclBEType BETy,
106+
enum DPPLSyclDeviceType DeviceTy,
106107
size_t DNum);
107108

108109
/*!
@@ -127,8 +128,8 @@ void DPPLQueueMgr_SetAsDefaultQueue (DPPLSyclBEType BETy,
127128
*/
128129
DPPL_API
129130
__dppl_give DPPLSyclQueueRef
130-
DPPLQueueMgr_PushQueue (DPPLSyclBEType BETy,
131-
DPPLSyclDeviceType DeviceTy,
131+
DPPLQueueMgr_PushQueue (enum DPPLSyclBEType BETy,
132+
enum DPPLSyclDeviceType DeviceTy,
132133
size_t DNum);
133134

134135
/*!

backends/source/dppl_sycl_context_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void DPPLContext_Delete (__dppl_take DPPLSyclContextRef CtxRef)
4747
delete unwrap(CtxRef);
4848
}
4949

50-
DPPLSyclBackendType
50+
DPPLSyclBEType
5151
DPPLContext_GetBackend (__dppl_keep const DPPLSyclContextRef CtxRef)
5252
{
5353
auto BE = unwrap(CtxRef)->get_platform().get_backend();

0 commit comments

Comments
 (0)