Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add platform destructor #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dpctl-capi/include/dpctl_sycl_platform_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions dpctl-capi/source/dpctl_sycl_platform_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "dpctl_sycl_platform_interface.h"
#include "../helper/include/dpctl_utils_helper.h"
#include "Support/CBindingWrapping.h"
#include <CL/sycl.hpp>
#include <iomanip>
#include <iostream>
Expand All @@ -36,6 +37,9 @@ using namespace cl::sycl;

namespace
{

DEFINE_SIMPLE_CONVERSION_FUNCTIONS(platform, DPCTLSyclPlatformRef);

std::set<DPCTLSyclBackendType> get_set_of_non_hostbackends()
{
std::set<DPCTLSyclBackendType> be_set;
Expand Down Expand Up @@ -64,6 +68,12 @@ std::set<DPCTLSyclBackendType> 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:
Expand Down
3 changes: 3 additions & 0 deletions dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down