DPC++ Runtime
Runtime libraries for oneAPI DPC++
alloca.hpp
Go to the documentation of this file.
1 //==--- alloca.hpp --- SYCL extension for private memory allocations--------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/exception.hpp>
12 #include <sycl/kernel_handler.hpp>
13 #include <sycl/pointers.hpp>
14 
15 #ifdef __SYCL_DEVICE_ONLY__
16 #include "sycl/aspects.hpp"
17 #endif
18 
19 namespace sycl {
20 inline namespace _V1 {
21 namespace ext::oneapi::experimental {
22 
23 #ifdef __SYCL_DEVICE_ONLY__
24 
25 // On the device, this is an alias to __builtin_intel_sycl_alloca.
26 
35 template <typename ElementType, auto &SizeSpecName,
36  access::decorated DecorateAddress>
37 __SYCL_BUILTIN_ALIAS(__builtin_intel_sycl_alloca)
38 [[__sycl_detail__::__uses_aspects__(aspect::ext_oneapi_private_alloca)]] private_ptr<
39  ElementType, DecorateAddress> private_alloca(kernel_handler &kh);
40 
41 // On the device, this is an alias to __builtin_intel_sycl_alloca_with_align.
42 
52 template <typename ElementType, std::size_t Alignment, auto &SizeSpecName,
53  access::decorated DecorateAddress>
54 __SYCL_BUILTIN_ALIAS(__builtin_intel_sycl_alloca_with_align)
55 [[__sycl_detail__::__uses_aspects__(aspect::ext_oneapi_private_alloca)]] private_ptr<
56  ElementType, DecorateAddress> aligned_private_alloca(kernel_handler &kh);
57 
58 #else
59 
60 // On the host, throw, these are not supported.
61 template <typename ElementType, auto &SizeSpecName,
62  access::decorated DecorateAddress>
64  throw exception(sycl::errc::feature_not_supported,
65  "sycl::ext::oneapi::experimental::private_alloca is not "
66  "supported on host");
67 }
68 
69 template <typename ElementType, std::size_t Alignment, auto &SizeSpecName,
70  access::decorated DecorateAddress>
72 aligned_private_alloca(kernel_handler &kh) {
73  throw exception(sycl::errc::feature_not_supported,
74  "sycl::ext::oneapi::experimental::aligned_private_alloca is "
75  "not supported on host");
76 }
77 
78 #endif // __SYCL_DEVICE_ONLY__
79 
80 } // namespace ext::oneapi::experimental
81 } // namespace _V1
82 } // namespace sycl
#define __SYCL_BUILTIN_ALIAS(x)
Definition: defines.hpp:45
private_ptr< ElementType, DecorateAddress > private_alloca(kernel_handler &kh)
Definition: alloca.hpp:63
private_ptr< ElementType, DecorateAddress > aligned_private_alloca(kernel_handler &kh)
Definition: alloca.hpp:72
multi_ptr< ElementType, access::address_space::private_space, IsDecorated > private_ptr
Definition: pointers.hpp:44
Definition: access.hpp:18