|
| 1 | +//===---- dpctl_sycl_extension_interface.cpp - Implements C API for SYCL ext =// |
| 2 | +// |
| 3 | +// Data Parallel Control (dpctl) |
| 4 | +// |
| 5 | +// Copyright 2020-2025 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 file implements the data types and functions declared in |
| 23 | +/// dpctl_sycl_extension_interface.h. |
| 24 | +/// |
| 25 | +//===----------------------------------------------------------------------===// |
| 26 | + |
| 27 | +#include "dpctl_sycl_extension_interface.h" |
| 28 | + |
| 29 | +#include "dpctl_error_handlers.h" |
| 30 | +#include "dpctl_sycl_type_casters.hpp" |
| 31 | + |
| 32 | +#include <sycl/sycl.hpp> |
| 33 | + |
| 34 | +using namespace dpctl::syclinterface; |
| 35 | + |
| 36 | +DPCTL_API |
| 37 | +__dpctl_give DPCTLSyclWorkGroupMemoryRef |
| 38 | +DPCTLWorkGroupMemory_Create(size_t nbytes) |
| 39 | +{ |
| 40 | + DPCTLSyclWorkGroupMemoryRef wgm = nullptr; |
| 41 | + try { |
| 42 | + auto WorkGroupMem = new RawWorkGroupMemory{nbytes}; |
| 43 | + wgm = wrap<RawWorkGroupMemory>(WorkGroupMem); |
| 44 | + } catch (std::exception const &e) { |
| 45 | + error_handler(e, __FILE__, __func__, __LINE__); |
| 46 | + } |
| 47 | + return wgm; |
| 48 | +} |
| 49 | + |
| 50 | +DPCTL_API |
| 51 | +void DPCTLWorkGroupMemory_Delete(__dpctl_take DPCTLSyclWorkGroupMemoryRef Ref) |
| 52 | +{ |
| 53 | + delete unwrap<RawWorkGroupMemory>(Ref); |
| 54 | +} |
| 55 | + |
| 56 | +DPCTL_API |
| 57 | +bool DPCTLWorkGroupMemory_Available() |
| 58 | +{ |
| 59 | +#ifdef SYCL_EXT_ONEAPI_WORK_GROUP_MEMORY |
| 60 | + return true; |
| 61 | +#else |
| 62 | + return false; |
| 63 | +#endif |
| 64 | +} |
| 65 | + |
0 commit comments