DPC++ Runtime
Runtime libraries for oneAPI DPC++
defines_elementary.hpp
Go to the documentation of this file.
1 //==---------------- defines_elementary.hpp - DPC++ Explicit SIMD API ------==//
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 // Elementary definitions used in Explicit SIMD APIs.
9 //===----------------------------------------------------------------------===//
10 
11 #pragma once
12 
14 
15 #ifdef __SYCL_DEVICE_ONLY__
16 #define SYCL_ESIMD_KERNEL __attribute__((sycl_explicit_simd))
17 #define SYCL_ESIMD_FUNCTION __attribute__((sycl_explicit_simd))
18 
19 // Mark a function being nodebug.
20 #define ESIMD_NODEBUG __attribute__((nodebug))
21 // Mark a "ESIMD global": accessible from all functions in current translation
22 // unit, separate copy per subgroup (work-item), mapped to SPIR-V private
23 // storage class.
24 #define ESIMD_PRIVATE \
25  __attribute__((opencl_private)) __attribute__((sycl_explicit_simd))
26 // Bind a ESIMD global variable to a specific register.
27 #define ESIMD_REGISTER(n) __attribute__((register_num(n)))
28 
29 #define __ESIMD_API ESIMD_NODEBUG ESIMD_INLINE
30 #else // __SYCL_DEVICE_ONLY__
31 #define SYCL_ESIMD_KERNEL
32 #define SYCL_ESIMD_FUNCTION
33 
34 // TODO ESIMD define what this means on Windows host
35 #define ESIMD_NODEBUG
36 // On host device ESIMD global is a thread local static var. This assumes that
37 // each work-item is mapped to a separate OS thread on host device.
38 #define ESIMD_PRIVATE thread_local
39 #define ESIMD_REGISTER(n)
40 #ifdef __ESIMD_BUILD_HOST_CODE
41 #define __ESIMD_API ESIMD_INLINE
42 #else // __ESIMD_BUILD_HOST_CODE
43 #define __ESIMD_API ESIMD_NOINLINE __attribute__((internal_linkage))
44 #endif // __ESIMD_BUILD_HOST_CODE
45 #endif // __SYCL_DEVICE_ONLY__
46 
47 // Mark a function being noinline
48 #define ESIMD_NOINLINE __attribute__((noinline))
49 // Force a function to be inlined. 'inline' is used to preserve ODR for
50 // functions defined in a header.
51 #define ESIMD_INLINE inline __attribute__((always_inline))
52 
53 // Macros for internal use
54 #define __ESIMD_NS sycl::ext::intel::esimd
55 #define __ESIMD_DNS sycl::ext::intel::esimd::detail
56 #define __ESIMD_ENS sycl::ext::intel::experimental::esimd
57 #define __ESIMD_EDNS sycl::ext::intel::experimental::esimd::detail
58 #define __ESIMD_XMX_NS sycl::ext::intel::esimd::xmx
59 #define __ESIMD_XMX_DNS sycl::ext::intel::esimd::xmx::detail
60 
61 #define __ESIMD_QUOTE1(m) #m
62 #define __ESIMD_QUOTE(m) __ESIMD_QUOTE1(m)
63 #define __ESIMD_NS_QUOTED __ESIMD_QUOTE(__ESIMD_NS)
64 #define __ESIMD_DEPRECATED(new_api) \
65  __SYCL_DEPRECATED("use " __ESIMD_NS_QUOTED "::" __ESIMD_QUOTE(new_api))
66