alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
include
alpaka
core
Sycl.hpp
Go to the documentation of this file.
1
/* Copyright 2023 Jan Stephan, Luca Ferragina, Aurora Perego, Andrea Bocci
2
* SPDX-License-Identifier: MPL-2.0
3
*/
4
5
#pragma once
6
7
#include "
alpaka/Vec.hpp
"
8
#include "
alpaka/core/config.hpp
"
9
#include "
alpaka/meta/IntegerSequence.hpp
"
10
11
#include <array>
12
#include <cstddef>
13
#include <cstdio>
// the #define printf(...) breaks <cstdio> if it is included afterwards
14
#include <iostream>
15
#include <stdexcept>
16
#include <string>
17
#include <type_traits>
18
#include <utility>
19
20
#if ALPAKA_LANG_SYCL
21
22
# include <sycl/sycl.hpp>
23
24
// if SYCL is enabled with the AMD backend the printf will be killed because of missing compiler support
25
# ifdef __AMDGCN__
26
# define printf(...)
27
# else
28
29
# ifdef __SYCL_DEVICE_ONLY__
30
using
AlpakaFormat =
char
const
* [[clang::opencl_constant]];
31
# else
32
using
AlpakaFormat =
char
const
*;
33
# endif
34
35
# if ALPAKA_COMP_CLANG
36
# pragma clang diagnostic push
37
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
38
# endif
39
40
# define printf(FORMAT, ...) \
41
do \
42
{ \
43
static auto const format = AlpakaFormat{FORMAT}; \
44
sycl::ext::oneapi::experimental::printf(format, ##__VA_ARGS__); \
45
} while(false)
46
47
# if ALPAKA_COMP_CLANG
48
# pragma clang diagnostic pop
49
# endif
50
51
# endif
52
53
// SYCL vector types trait specializations.
54
namespace
alpaka
55
{
56
namespace
detail
57
{
58
// Remove std::is_same boilerplate
59
template
<
typename
T,
typename
... Ts>
60
struct
is_any : std::bool_constant<(std::is_same_v<T, Ts> || ...)>
61
{
62
};
63
}
// namespace detail
64
65
//! In contrast to CUDA SYCL doesn't know 1D vectors. It does
66
//! support OpenCL's data types which have additional requirements
67
//! on top of those in the C++ standard. Note that SYCL's equivalent
68
//! to CUDA's dim3 type is a different class type and thus not used
69
//! here.
70
template
<
typename
T>
71
struct
IsSyclBuiltInType
72
: detail::is_any<
73
T,
74
// built-in scalar types - these are the standard C++ built-in types, std::size_t, std::byte and
75
// sycl::half
76
sycl::half,
77
78
// 2 component vector types
79
sycl::char2,
80
sycl::uchar2,
81
sycl::short2,
82
sycl::ushort2,
83
sycl::int2,
84
sycl::uint2,
85
sycl::long2,
86
sycl::ulong2,
87
sycl::float2,
88
sycl::double2,
89
sycl::half2,
90
91
// 3 component vector types
92
sycl::char3,
93
sycl::uchar3,
94
sycl::short3,
95
sycl::ushort3,
96
sycl::int3,
97
sycl::uint3,
98
sycl::long3,
99
sycl::ulong3,
100
sycl::float3,
101
sycl::double3,
102
sycl::half3,
103
104
// 4 component vector types
105
sycl::char4,
106
sycl::uchar4,
107
sycl::short4,
108
sycl::ushort4,
109
sycl::int4,
110
sycl::uint4,
111
sycl::long4,
112
sycl::ulong4,
113
sycl::float4,
114
sycl::double4,
115
sycl::half4,
116
117
// 8 component vector types
118
sycl::char8,
119
sycl::uchar8,
120
sycl::short8,
121
sycl::ushort8,
122
sycl::int8,
123
sycl::uint8,
124
sycl::long8,
125
sycl::ulong8,
126
sycl::float8,
127
sycl::double8,
128
sycl::half8,
129
130
// 16 component vector types
131
sycl::char16,
132
sycl::uchar16,
133
sycl::short16,
134
sycl::ushort16,
135
sycl::int16,
136
sycl::uint16,
137
sycl::long16,
138
sycl::ulong16,
139
sycl::float16,
140
sycl::double16,
141
sycl::half16>
142
{
143
};
144
}
// namespace alpaka
145
#endif
IntegerSequence.hpp
Vec.hpp
config.hpp
alpaka
main alpaka namespace.
Definition
alpaka.hpp:76
Generated on
for alpaka by
1.16.1