Skip to content

Sycl wrappers #30

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 5 commits into from
Sep 18, 2020
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
5 changes: 5 additions & 0 deletions backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ message(STATUS "OpenCL_LIBRARY: ${OpenCL_LIBRARY}")
add_library(
DPPLSyclInterface
SHARED
source/dppl_sycl_context_interface.cpp
source/dppl_sycl_device_interface.cpp
source/dppl_sycl_platform_interface.cpp
source/dppl_sycl_queue_interface.cpp
source/dppl_sycl_queue_manager.cpp
source/dppl_utils.cpp
)

# Install DPPLOpenCLInterface
Expand Down
54 changes: 54 additions & 0 deletions backends/include/dppl_sycl_context_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//===--- dppl_sycl_context_interface.h - DPPL-SYCL interface --*--C++ --*--===//
//
// Python Data Parallel Processing Library (PyDPPL)
//
// Copyright 2020 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 a C API to SYCL's sycl::context interface.
///
//===----------------------------------------------------------------------===//

#pragma once

#include "dppl_data_types.h"
#include "dppl_sycl_types.h"
#include "Support/DllExport.h"
#include "Support/ExternC.h"
#include "Support/MemOwnershipAttrs.h"
#include <stdbool.h>

DPPL_C_EXTERN_C_BEGIN

/*!
* @brief Returns true if this SYCL context is a host context.
*
* @param CtxtRef A opaque pointer to a sycl::context.
* @return True if the SYCL context is a host context, else False.
*/
DPPL_API
bool DPPLIsHostContext (__dppl_keep const DPPLSyclContextRef CtxtRef);

/*!
* @brief Delete the pointer after casting it to sycl::context
*
* @param CtxtRef The DPPLSyclContextRef pointer to be deleted.
*/
DPPL_API
void DPPLDeleteSyclContext (__dppl_take DPPLSyclContextRef CtxtRef);

DPPL_C_EXTERN_C_END
151 changes: 151 additions & 0 deletions backends/include/dppl_sycl_device_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
//===--- dppl_sycl_device_interface.h - DPPL-SYCL interface ---*---C++ -*---===//
//
// Python Data Parallel Processing Library (PyDPPL)
//
// Copyright 2020 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 a C interface to sycl::device. Not all of the device
/// API is exposed, only the bits needed in other places like context and queue
/// interfaces.
///
//===----------------------------------------------------------------------===//

#pragma once

#include "dppl_data_types.h"
#include "dppl_sycl_types.h"
#include "Support/DllExport.h"
#include "Support/ExternC.h"
#include "Support/MemOwnershipAttrs.h"

DPPL_C_EXTERN_C_BEGIN

/*!
* @brief Redefinition of Sycl's device_type so that we do not have to include
* sycl.hpp here and in the Python bindings.
*
*/
typedef enum
{
DPPL_CPU,
DPPL_GPU,
DPPL_ACCELERATOR,
DPPL_CUSTOM,
DPPL_AUTOMATIC,
DPPL_HOST,
DPPL_ALL
} DPPLSyclDeviceType;

/*!
* @brief Prints out some of the info::deivice attributes for the device.
*
* @param DRef A DPPLSyclDeviceRef pointer.
*/
DPPL_API
void DPPLDumpDeviceInfo (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Deletes a DPPLSyclDeviceRef pointer after casting to to sycl::device.
*
* @param DRef The DPPLSyclDeviceRef pointer to be freed.
*/
DPPL_API
void DPPLDeleteSyclDevice (__dppl_take DPPLSyclDeviceRef DRef);

/*!
* @brief Returns true if this SYCL device is an OpenCL device and the device
* type is sycl::info::device_type::accelerator.
*
* @param DRef Opaque pointer to a sycl::device
* @return True if the device type is an accelerator, else False.
*/
DPPL_API
bool DPPLDeviceIsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns true if this SYCL device is an OpenCL device and the device
* type is sycl::info::device_type::cpu.
*
* @param DRef Opaque pointer to a sycl::device
* @return True if the device type is a cpu, else False.
*/
DPPL_API
bool DPPLDeviceIsCPU (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns true if this SYCL device is an OpenCL device and the device
* type is sycl::info::device_type::gpu.
*
* @param DRef Opaque pointer to a sycl::device
* @return True if the device type is a gpu, else False.
*/
DPPL_API
bool DPPLDeviceIsGPU (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns true if this SYCL device is a host device.
*
* @param DRef Opaque pointer to a sycl::device
* @return True if the device is a host device, else False.
*/
DPPL_API
bool DPPLDeviceIsHost (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns the OpenCL software driver version as a C string.
*
* @param DRef Opaque pointer to a sycl::device
* @return A C string in the form major_number.minor.number that corresponds
* to the OpenCL driver version if this is a OpenCL device.
*/
DPPL_API
__dppl_give const char*
DPPLGetDeviceDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns a C string for the device name.
*
* @param DRef Opaque pointer to a sycl::device
* @return A C string containing the OpenCL device name.
*/
DPPL_API
__dppl_give const char*
DPPLGetDeviceName (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns a C string corresponding to the vendor name.
*
* @param DRef Opaque pointer to a sycl::device
* @return A C string containing the OpenCL device vendor name.
*/
DPPL_API
__dppl_give const char*
DPPLGetDeviceVendorName (__dppl_keep const DPPLSyclDeviceRef DRef);

/*!
* @brief Returns True if the device and the host share a unified memory
* subsystem, else returns False.
*
* @param DRef Opaque pointer to a sycl::device
* @return Boolean indicating if the device shares a unified memory subsystem
* with the host.
*/
DPPL_API
bool DPPLGetDeviceHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef);

DPPL_C_EXTERN_C_END
49 changes: 49 additions & 0 deletions backends/include/dppl_sycl_platform_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===--- dppl_sycl_platform_interface.h - DPPL-SYCL interface ---*--C++ -*-===//
//
// Python Data Parallel Processing Library (PyDPPL)
//
// Copyright 2020 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 a C interface to sycl::platform interface functions.
///
//===----------------------------------------------------------------------===//

#pragma once

#include "dppl_data_types.h"
#include "Support/DllExport.h"
#include "Support/ExternC.h"

DPPL_C_EXTERN_C_BEGIN

/*!
* @brief Get the number of sycl::platform available on the system.
*
* @return The number of available sycl::platforms.
*/
DPPL_API
size_t DPPLPlatform_GetNumPlatforms ();

/*!
* @brief Prints out some selected info about all sycl::platform on the system.
*
*/
DPPL_API
void DPPLPlatform_DumpInfo ();

DPPL_C_EXTERN_C_END
Loading