|
| 1 | +# Data Parallel Control (dpctl) |
| 2 | +# |
| 3 | +# Copyright 2020-2022 Intel Corporation |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# distutils: language = c++ |
| 18 | +# cython: language_level=3 |
| 19 | +# cython: linetrace=True |
| 20 | + |
| 21 | +cimport libcpp.string |
| 22 | + |
| 23 | +cimport dpctl |
| 24 | +cimport dpctl.sycl |
| 25 | + |
| 26 | + |
| 27 | +cdef extern from "utils.hpp": |
| 28 | + cdef libcpp.string.string get_device_name(dpctl.sycl.device) |
| 29 | + cdef libcpp.string.string get_device_driver_version(dpctl.sycl.device) |
| 30 | + cdef dpctl.sycl.device *copy_device(dpctl.sycl.device) |
| 31 | + |
| 32 | + |
| 33 | +def device_name(dpctl.SyclDevice dev): |
| 34 | + cdef dpctl.DPCTLSyclDeviceRef d_ref = dev.get_device_ref() |
| 35 | + cdef const dpctl.sycl.device *dpcpp_device = dpctl.sycl.unwrap_device(d_ref) |
| 36 | + |
| 37 | + return get_device_name(dpcpp_device[0]) |
| 38 | + |
| 39 | + |
| 40 | +def device_driver_version(dpctl.SyclDevice dev): |
| 41 | + cdef dpctl.DPCTLSyclDeviceRef d_ref = dev.get_device_ref() |
| 42 | + cdef const dpctl.sycl.device *dpcpp_device = dpctl.sycl.unwrap_device(d_ref) |
| 43 | + |
| 44 | + return get_device_driver_version(dpcpp_device[0]) |
| 45 | + |
| 46 | + |
| 47 | +cpdef dpctl.SyclDevice device_copy(dpctl.SyclDevice dev): |
| 48 | + cdef dpctl.DPCTLSyclDeviceRef d_ref = dev.get_device_ref() |
| 49 | + cdef const dpctl.sycl.device *dpcpp_device = dpctl.sycl.unwrap_device(d_ref) |
| 50 | + cdef dpctl.sycl.device *copied_device = copy_device(dpcpp_device[0]) |
| 51 | + cdef dpctl.DPCTLSyclDeviceRef copied_d_ref = dpctl.sycl.wrap_device(copied_device) |
| 52 | + |
| 53 | + return dpctl.SyclDevice._create(copied_d_ref) |
0 commit comments