|
| 1 | +//===--- dppl_sycl_device_interface.h - DPPL-SYCL interface ---*---C++ -*---===// |
| 2 | +// |
| 3 | +// Python Data Parallel Processing Library (PyDPPL) |
| 4 | +// |
| 5 | +// Copyright 2020 Intel Corporation |
| 6 | +// |
| 7 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +// you may not use this file except in compliance with the License. |
| 9 | +// You may obtain a copy of the License at |
| 10 | +// |
| 11 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +// |
| 13 | +// Unless required by applicable law or agreed to in writing, software |
| 14 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +// See the License for the specific language governing permissions and |
| 17 | +// limitations under the License. |
| 18 | +// |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | +/// |
| 21 | +/// \file |
| 22 | +/// This header declares a C interface to sycl::device. Not all of the device |
| 23 | +/// API is exposed, only the bits needed in other places like context and queue |
| 24 | +/// interfaces. |
| 25 | +/// |
| 26 | +//===----------------------------------------------------------------------===// |
| 27 | + |
| 28 | +#pragma once |
| 29 | + |
| 30 | +#include "dppl_data_types.h" |
| 31 | +#include "dppl_sycl_types.h" |
| 32 | +#include "Support/DllExport.h" |
| 33 | +#include "Support/ExternC.h" |
| 34 | +#include "Support/MemOwnershipAttrs.h" |
| 35 | + |
| 36 | +DPPL_C_EXTERN_C_BEGIN |
| 37 | + |
| 38 | +/*! |
| 39 | + * @brief Redefinition of Sycl's device_type so that we do not have to include |
| 40 | + * sycl.hpp here and in the Python bindings. |
| 41 | + * |
| 42 | + */ |
| 43 | +typedef enum |
| 44 | +{ |
| 45 | + DPPL_CPU, |
| 46 | + DPPL_GPU, |
| 47 | + DPPL_ACCELERATOR, |
| 48 | + DPPL_CUSTOM, |
| 49 | + DPPL_AUTOMATIC, |
| 50 | + DPPL_HOST, |
| 51 | + DPPL_ALL |
| 52 | +} DPPLSyclDeviceType; |
| 53 | + |
| 54 | +/*! |
| 55 | + * @brief Prints out some of the info::deivice attributes for the device. |
| 56 | + * |
| 57 | + * @param DRef A DPPLSyclDeviceRef pointer. |
| 58 | + */ |
| 59 | +DPPL_API |
| 60 | +void DPPLDumpDeviceInfo (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 61 | + |
| 62 | +/*! |
| 63 | + * @brief Deletes a DPPLSyclDeviceRef pointer after casting to to sycl::device. |
| 64 | + * |
| 65 | + * @param DRef The DPPLSyclDeviceRef pointer to be freed. |
| 66 | + */ |
| 67 | +DPPL_API |
| 68 | +void DPPLDeleteSyclDevice (__dppl_take DPPLSyclDeviceRef DRef); |
| 69 | + |
| 70 | +/*! |
| 71 | + * @brief Returns true if this SYCL device is an OpenCL device and the device |
| 72 | + * type is sycl::info::device_type::accelerator. |
| 73 | + * |
| 74 | + * @param DRef Opaque pointer to a sycl::device |
| 75 | + * @return True if the device type is an accelerator, else False. |
| 76 | + */ |
| 77 | +DPPL_API |
| 78 | +bool DPPLDeviceIsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 79 | + |
| 80 | +/*! |
| 81 | + * @brief Returns true if this SYCL device is an OpenCL device and the device |
| 82 | + * type is sycl::info::device_type::cpu. |
| 83 | + * |
| 84 | + * @param DRef Opaque pointer to a sycl::device |
| 85 | + * @return True if the device type is a cpu, else False. |
| 86 | + */ |
| 87 | +DPPL_API |
| 88 | +bool DPPLDeviceIsCPU (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 89 | + |
| 90 | +/*! |
| 91 | + * @brief Returns true if this SYCL device is an OpenCL device and the device |
| 92 | + * type is sycl::info::device_type::gpu. |
| 93 | + * |
| 94 | + * @param DRef Opaque pointer to a sycl::device |
| 95 | + * @return True if the device type is a gpu, else False. |
| 96 | + */ |
| 97 | +DPPL_API |
| 98 | +bool DPPLDeviceIsGPU (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 99 | + |
| 100 | +/*! |
| 101 | + * @brief Returns true if this SYCL device is a host device. |
| 102 | + * |
| 103 | + * @param DRef Opaque pointer to a sycl::device |
| 104 | + * @return True if the device is a host device, else False. |
| 105 | + */ |
| 106 | +DPPL_API |
| 107 | +bool DPPLDeviceIsHost (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 108 | + |
| 109 | +/*! |
| 110 | + * @brief Returns the OpenCL software driver version as a C string. |
| 111 | + * |
| 112 | + * @param DRef Opaque pointer to a sycl::device |
| 113 | + * @return A C string in the form major_number.minor.number that corresponds |
| 114 | + * to the OpenCL driver version if this is a OpenCL device. |
| 115 | + */ |
| 116 | +DPPL_API |
| 117 | +__dppl_give const char* |
| 118 | +DPPLGetDeviceDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 119 | + |
| 120 | +/*! |
| 121 | + * @brief Deletes a C string corresponding to the string returned by |
| 122 | + * DPPLGetDeviceDriverInfo(). |
| 123 | + * |
| 124 | + * @param DriverInfo C String for the driver number. |
| 125 | + */ |
| 126 | +DPPL_API |
| 127 | +void DPPLDeleteDeviceDriverInfo (__dppl_take const char* DriverInfo); |
| 128 | + |
| 129 | +/*! |
| 130 | + * @brief Returns a C string for the device name. |
| 131 | + * |
| 132 | + * @param DRef Opaque pointer to a sycl::device |
| 133 | + * @return A C string containing the OpenCL device name. |
| 134 | + */ |
| 135 | +DPPL_API |
| 136 | +__dppl_give const char* |
| 137 | +DPPLGetDeviceName (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 138 | + |
| 139 | +/*! |
| 140 | + * @brief Deletes a C string corresponding to the string returned by |
| 141 | + * DPPLGetDeviceName(). |
| 142 | + * |
| 143 | + * @param DeviceName C String for the device name. |
| 144 | + */ |
| 145 | +DPPL_API |
| 146 | +void DPPLDeleteDeviceName (__dppl_take const char* DeviceName); |
| 147 | + |
| 148 | +/*! |
| 149 | + * @brief Returns a C string corresponding to the vendor name. |
| 150 | + * |
| 151 | + * @param DRef Opaque pointer to a sycl::device |
| 152 | + * @return A C string containing the OpenCL device vendor name. |
| 153 | + */ |
| 154 | +DPPL_API |
| 155 | +__dppl_give const char* |
| 156 | +DPPLGetDeviceVendorName (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 157 | + |
| 158 | +/*! |
| 159 | + * @brief Deletes a C string corresponding to the string returned by |
| 160 | + * DPPLGetDeviceVendorName(). |
| 161 | + * |
| 162 | + * @param char C String for the vendor name. |
| 163 | + */ |
| 164 | +DPPL_API |
| 165 | +void DPPLDeleteDeviceVendorName (__dppl_take const char* VendorName); |
| 166 | + |
| 167 | +/*! |
| 168 | + * @brief Returns True if the device and the host share a unified memory |
| 169 | + * subsystem, else returns False. |
| 170 | + * |
| 171 | + * @param DRef Opaque pointer to a sycl::device |
| 172 | + * @return Boolean indicating if the device shares a unified memory subsystem |
| 173 | + * with the host. |
| 174 | + */ |
| 175 | +DPPL_API |
| 176 | +bool DPPLGetDeviceHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef); |
| 177 | + |
| 178 | +DPPL_C_EXTERN_C_END |
0 commit comments