Skip to content

Commit a4eb55f

Browse files
authored
Feature/add platform destructor (#298)
* Adds a wrapper for the destructor sycl::platform pointer. * Update _backend.pxd to include the new C API functions.
1 parent 3278a06 commit a4eb55f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

dpctl-capi/include/dpctl_sycl_platform_interface.h

+9
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@
3030
#include "Support/MemOwnershipAttrs.h"
3131
#include "dpctl_data_types.h"
3232
#include "dpctl_sycl_enum_types.h"
33+
#include "dpctl_sycl_types.h"
3334

3435
DPCTL_C_EXTERN_C_BEGIN
3536

37+
/*!
38+
* @brief Deletes the DPCTLSyclProgramRef pointer.
39+
*
40+
* @param PRef An opaque pointer to a sycl::platform.
41+
*/
42+
DPCTL_API
43+
void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef);
44+
3645
/*!
3746
* @brief Returns the number of non-host type sycl::platform available on the
3847
* system.

dpctl-capi/source/dpctl_sycl_platform_interface.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "dpctl_sycl_platform_interface.h"
2828
#include "../helper/include/dpctl_utils_helper.h"
29+
#include "Support/CBindingWrapping.h"
2930
#include <CL/sycl.hpp>
3031
#include <iomanip>
3132
#include <iostream>
@@ -36,6 +37,9 @@ using namespace cl::sycl;
3637

3738
namespace
3839
{
40+
41+
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(platform, DPCTLSyclPlatformRef);
42+
3943
std::set<DPCTLSyclBackendType> get_set_of_non_hostbackends()
4044
{
4145
std::set<DPCTLSyclBackendType> be_set;
@@ -64,6 +68,12 @@ std::set<DPCTLSyclBackendType> get_set_of_non_hostbackends()
6468

6569
} // namespace
6670

71+
void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef)
72+
{
73+
auto P = unwrap(PRef);
74+
delete P;
75+
}
76+
6777
/*!
6878
* Prints out the following sycl::info::platform attributes for each platform
6979
* found on the system:

dpctl/_backend.pxd

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ cdef extern from "dpctl_sycl_types.h":
7575
cdef struct DPCTLOpaqueSyclDeviceSelector
7676
cdef struct DPCTLOpaqueSyclEvent
7777
cdef struct DPCTLOpaqueSyclKernel
78+
cdef struct DPCTLOpaqueSyclPlatform
7879
cdef struct DPCTLOpaqueSyclProgram
7980
cdef struct DPCTLOpaqueSyclQueue
8081
cdef struct DPCTLOpaqueSyclUSM
@@ -84,6 +85,7 @@ cdef extern from "dpctl_sycl_types.h":
8485
ctypedef DPCTLOpaqueSyclDeviceSelector *DPCTLSyclDeviceSelectorRef
8586
ctypedef DPCTLOpaqueSyclEvent *DPCTLSyclEventRef
8687
ctypedef DPCTLOpaqueSyclKernel *DPCTLSyclKernelRef
88+
ctypedef DPCTLOpaqueSyclPlatform *DPCTLSyclPlatformRef
8789
ctypedef DPCTLOpaqueSyclProgram *DPCTLSyclProgramRef
8890
ctypedef DPCTLOpaqueSyclQueue *DPCTLSyclQueueRef
8991
ctypedef DPCTLOpaqueSyclUSM *DPCTLSyclUSMRef
@@ -138,6 +140,7 @@ cdef extern from "dpctl_sycl_kernel_interface.h":
138140

139141

140142
cdef extern from "dpctl_sycl_platform_interface.h":
143+
cdef void DPCTLPlatform_Delete()
141144
cdef size_t DPCTLPlatform_GetNumNonHostPlatforms()
142145
cdef void DPCTLPlatform_DumpInfo()
143146
cdef size_t DPCTLPlatform_GetNumNonHostBackends()

0 commit comments

Comments
 (0)