From 1c6bf7bf0bf77b4bc1bf5756e5b1c59fcf6b0808 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Fri, 26 Feb 2021 14:13:15 -0600 Subject: [PATCH 1/2] Adds a wrapper for the destructor sycl::platform pointer. --- dpctl-capi/include/dpctl_sycl_platform_interface.h | 9 +++++++++ dpctl-capi/source/dpctl_sycl_platform_interface.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/dpctl-capi/include/dpctl_sycl_platform_interface.h b/dpctl-capi/include/dpctl_sycl_platform_interface.h index 9d428d7cfe..0e63679849 100644 --- a/dpctl-capi/include/dpctl_sycl_platform_interface.h +++ b/dpctl-capi/include/dpctl_sycl_platform_interface.h @@ -30,9 +30,18 @@ #include "Support/MemOwnershipAttrs.h" #include "dpctl_data_types.h" #include "dpctl_sycl_enum_types.h" +#include "dpctl_sycl_types.h" DPCTL_C_EXTERN_C_BEGIN +/*! + * @brief Deletes the DPCTLSyclProgramRef pointer. + * + * @param PRef An opaque pointer to a sycl::platform. + */ +DPCTL_API +void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef); + /*! * @brief Returns the number of non-host type sycl::platform available on the * system. diff --git a/dpctl-capi/source/dpctl_sycl_platform_interface.cpp b/dpctl-capi/source/dpctl_sycl_platform_interface.cpp index 8ab5e66b5e..c062949ade 100644 --- a/dpctl-capi/source/dpctl_sycl_platform_interface.cpp +++ b/dpctl-capi/source/dpctl_sycl_platform_interface.cpp @@ -26,6 +26,7 @@ #include "dpctl_sycl_platform_interface.h" #include "../helper/include/dpctl_utils_helper.h" +#include "Support/CBindingWrapping.h" #include #include #include @@ -36,6 +37,9 @@ using namespace cl::sycl; namespace { + +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(platform, DPCTLSyclPlatformRef); + std::set get_set_of_non_hostbackends() { std::set be_set; @@ -64,6 +68,12 @@ std::set get_set_of_non_hostbackends() } // namespace +void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef) +{ + auto P = unwrap(PRef); + delete P; +} + /*! * Prints out the following sycl::info::platform attributes for each platform * found on the system: From 464128b804b40668c5c1abc6de019d5568d2d8d3 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Sat, 27 Feb 2021 00:17:28 -0600 Subject: [PATCH 2/2] Update _backend.pxd --- dpctl/_backend.pxd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dpctl/_backend.pxd b/dpctl/_backend.pxd index 23836cb545..a9c95dec53 100644 --- a/dpctl/_backend.pxd +++ b/dpctl/_backend.pxd @@ -75,6 +75,7 @@ cdef extern from "dpctl_sycl_types.h": cdef struct DPCTLOpaqueSyclDeviceSelector cdef struct DPCTLOpaqueSyclEvent cdef struct DPCTLOpaqueSyclKernel + cdef struct DPCTLOpaqueSyclPlatform cdef struct DPCTLOpaqueSyclProgram cdef struct DPCTLOpaqueSyclQueue cdef struct DPCTLOpaqueSyclUSM @@ -84,6 +85,7 @@ cdef extern from "dpctl_sycl_types.h": ctypedef DPCTLOpaqueSyclDeviceSelector *DPCTLSyclDeviceSelectorRef ctypedef DPCTLOpaqueSyclEvent *DPCTLSyclEventRef ctypedef DPCTLOpaqueSyclKernel *DPCTLSyclKernelRef + ctypedef DPCTLOpaqueSyclPlatform *DPCTLSyclPlatformRef ctypedef DPCTLOpaqueSyclProgram *DPCTLSyclProgramRef ctypedef DPCTLOpaqueSyclQueue *DPCTLSyclQueueRef ctypedef DPCTLOpaqueSyclUSM *DPCTLSyclUSMRef @@ -138,6 +140,7 @@ cdef extern from "dpctl_sycl_kernel_interface.h": cdef extern from "dpctl_sycl_platform_interface.h": + cdef void DPCTLPlatform_Delete() cdef size_t DPCTLPlatform_GetNumNonHostPlatforms() cdef void DPCTLPlatform_DumpInfo() cdef size_t DPCTLPlatform_GetNumNonHostBackends()