Skip to content

Feature/platform interface #336

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

Merged
merged 2 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
80 changes: 62 additions & 18 deletions dpctl-capi/include/dpctl_sycl_platform_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,42 @@
#include "Support/MemOwnershipAttrs.h"
#include "dpctl_data_types.h"
#include "dpctl_sycl_enum_types.h"
#include "dpctl_sycl_platform_manager.h"
#include "dpctl_sycl_types.h"

DPCTL_C_EXTERN_C_BEGIN

/*!
* @brief Returns a copy of the DPCTLSyclPlatformRef object.
*
* @param DRef DPCTLSyclPlatformRef object to be copied.
* @return A new DPCTLSyclPlatformRef created by copying the passed in
* DPCTLSyclPlatformRef object.
*/
DPCTL_API
__dpctl_give DPCTLSyclPlatformRef
DPCTLPlatform_Copy(__dpctl_keep const DPCTLSyclPlatformRef PRef);

/*!
* @brief Creates a new DPCTLSyclPlatformRef for a SYCL platform constructed
* using SYCL's default_selector.
*
* @return A new DPCTLSyclPlatformRef pointer wrapping a SYCL platform object.
*/
DPCTL_API
__dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_Create();

/*!
* @brief Creates a new DPCTLSyclPlatformRef for a SYCL platform constructed
* using the device_selector wrapped by DPCTLSyclDeviceSelectorRef.
*
* @param DSRef An opaque pointer to a SYCL device_selector object.
* @return A new DPCTLSyclPlatformRef pointer wrapping a SYCL platform object.
*/
DPCTL_API
__dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_CreateFromSelector(
__dpctl_keep const DPCTLSyclDeviceSelectorRef DSRef);

/*!
* @brief Deletes the DPCTLSyclProgramRef pointer.
*
Expand All @@ -43,46 +75,58 @@ DPCTL_API
void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef);

/*!
* @brief Returns the number of non-host type sycl::platform available on the
* system.
* @brief Returns a DPCTLSyclBackendType enum value identifying the SYCL
* backend associated with the platform.
*
* @return The number of available sycl::platforms.
* @param PRef Opaque pointer to a sycl::platform
* @return A DPCTLSyclBackendType enum value identifying the SYCL backend
* associated with the platform.
*/
DPCTL_API
size_t DPCTLPlatform_GetNumNonHostPlatforms();
DPCTLSyclBackendType
DPCTLPlatform_GetBackend(__dpctl_keep const DPCTLSyclPlatformRef PRef);

/*!
* @brief Returns the number of unique non-host sycl backends on the system.
* @brief Returns a C string for the platform name.
*
* @return The number of unique sycl backends.
* @param PRef Opaque pointer to a sycl::platform
* @return A C string containing the name of the sycl::platform.
*/
DPCTL_API
size_t DPCTLPlatform_GetNumNonHostBackends();
__dpctl_give const char *
DPCTLPlatform_GetName(__dpctl_keep const DPCTLSyclPlatformRef PRef);

/*!
* @brief Returns an array of the unique non-host DPCTLSyclBackendType values on
* the system.
* @brief Returns a C string corresponding to the vendor providing the platform.
*
* @return An array of DPCTLSyclBackendType enum values.
* @param PRef Opaque pointer to a sycl::platform
* @return A C string containing the name of the vendor provifing the
* platform.
*/
DPCTL_API
__dpctl_give DPCTLSyclBackendType *DPCTLPlatform_GetListOfNonHostBackends();
__dpctl_give const char *
DPCTLPlatform_GetVendor(__dpctl_keep const DPCTLSyclPlatformRef PRef);

/*!
* @brief Frees an array of DPCTLSyclBackendType enum values.
* @brief Returns the software driver version of the sycl::platform as a C
* string.
*
* @param BEArr An array of DPCTLSyclBackendType enum values to be
* freed.
* @param PRef Opaque pointer to a sycl::platform
* @return A C string containing the software driver version of the device
* associated with the platform.
*/
DPCTL_API
void DPCTLPlatform_DeleteListOfBackends(
__dpctl_take DPCTLSyclBackendType *BEArr);
__dpctl_give const char *
DPCTLPlatform_GetVersion(__dpctl_keep const DPCTLSyclPlatformRef PRef);

/*!
* @brief Prints out some selected info about all sycl::platform on the system.
* @brief Returns an opaque pointer to a vector of SYCL platforms available on
* the system.
*
* @return A #DPCTLPlatformVectorRef containing #DPCTLSyclPlatformRef
* objects.
*/
DPCTL_API
void DPCTLPlatform_DumpInfo();
__dpctl_give DPCTLPlatformVectorRef DPCTLPlatform_GetPlatforms();

DPCTL_C_EXTERN_C_END
47 changes: 47 additions & 0 deletions dpctl-capi/include/dpctl_sycl_platform_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//===-- dpctl_sycl_platform_manager.h - Helpers for sycl::platform -*-C++-*- =//
//
// Data Parallel Control (dpCtl)
//
// Copyright 2020-2021 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This header declares helper functions to work with sycl::platform objects.
///
//===----------------------------------------------------------------------===//

#pragma once

#include "Support/DllExport.h"
#include "Support/ExternC.h"
#include "Support/MemOwnershipAttrs.h"
#include "dpctl_sycl_types.h"
#include "dpctl_vector.h"

DPCTL_C_EXTERN_C_BEGIN

// Declares a set of types abd functions to deal with vectors of
// DPCTLSyclPlatformRef. Refer dpctl_vector_macros.h
DPCTL_DECLARE_VECTOR(Platform)

/*!
* @brief Prints out information about the sycl::platform argument.
* @param PRef A #DPCTLSyclPlatformRef opaque pointer.
*/
DPCTL_API
void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef);

DPCTL_C_EXTERN_C_END
Loading