-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathstring_makers.h
215 lines (201 loc) · 5.94 KB
/
string_makers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2022 The Khronos Group Inc.
//
*******************************************************************************/
#ifndef __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H
#define __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H
#include <sstream>
#include <catch2/catch_tostring.hpp>
#include <sycl/sycl.hpp>
namespace Catch {
template <>
struct StringMaker<sycl::access_mode> {
using type = sycl::access_mode;
static std::string convert(type value) {
switch (value) {
case type::read:
return "access_mode::read";
case type::write:
return "access_mode::write";
case type::read_write:
return "access_mode::read_write";
case type::discard_write:
return "access_mode::discard_write (deprecated)";
case type::discard_read_write:
return "access_mode::discard_read_write (deprecated)";
case type::atomic:
return "access_mode::atomic (deprecated)";
default:
return "unknown access mode";
}
}
};
template <int Dimensions>
struct StringMaker<sycl::id<Dimensions>> {
static std::string convert(const sycl::id<Dimensions>& id) {
std::stringstream ss;
ss << "{";
for (int d = 0; d < Dimensions; ++d) {
ss << id[d];
if (d != Dimensions - 1) {
ss << ", ";
}
}
ss << "}";
return ss.str();
}
};
template <>
struct StringMaker<sycl::target> {
using type = sycl::target;
static std::string convert(type value) {
switch (value) {
case type::device:
return "target::device";
// FIXME: re-enable when target::host_task is implemented
#if !SYCL_CTS_COMPILING_WITH_ADAPTIVECPP
case type::host_task:
return "target::host_task";
#endif
case type::constant_buffer:
return "target::constant_buffer (deprecated)";
case type::local:
return "target::local (deprecated)";
case type::host_buffer:
return "target::host_buffer (deprecated)";
default:
return "unknown target";
}
}
};
template <>
struct StringMaker<sycl::aspect> {
using type = sycl::aspect;
static std::string convert(type value) {
switch (value) {
case type::cpu:
return "aspect::cpu";
case type::gpu:
return "aspect::gpu";
case type::accelerator:
return "aspect::accelerator";
case type::custom:
return "aspect::custom";
case type::emulated:
return "aspect::emulated";
case type::host_debuggable:
return "aspect::host_debuggable";
case type::fp16:
return "aspect::fp16";
case type::fp64:
return "aspect::fp64";
case type::atomic64:
return "aspect::atomic64";
case type::image:
return "aspect::image";
case type::online_compiler:
return "aspect::online_compiler";
case type::online_linker:
return "aspect::online_linker";
case type::queue_profiling:
return "aspect::queue_profiling";
case type::usm_device_allocations:
return "aspect::usm_device_allocations";
case type::usm_host_allocations:
return "aspect::usm_host_allocations";
case type::usm_atomic_host_allocations:
return "aspect::usm_atomic_host_allocations";
case type::usm_shared_allocations:
return "aspect::usm_shared_allocations";
case type::usm_atomic_shared_allocations:
return "aspect::usm_atomic_shared_allocations";
case type::usm_system_allocations:
return "aspect::usm_system_allocations";
default:
return "unknown aspect";
}
}
};
template <>
struct StringMaker<sycl::memory_order> {
using type = sycl::memory_order;
static std::string convert(const type& order) {
switch (order) {
case type::relaxed:
return "memory_order::relaxed";
case type::acq_rel:
return "memory_order::acq_rel";
case type::seq_cst:
return "memory_order::seq_cst";
case type::acquire:
return "memory_order::acquire";
case type::release:
return "memory_order::release";
default:
return "unknown memory_order";
}
}
};
template <>
struct StringMaker<sycl::memory_scope> {
using type = sycl::memory_scope;
static std::string convert(const type& scope) {
switch (scope) {
case type::work_item:
return "memory_scope::work_item";
case type::sub_group:
return "memory_scope::sub_group";
case type::work_group:
return "memory_scope::work_group";
case type::device:
return "memory_scope::device";
case type::system:
return "memory_scope::system";
default:
return "unknown memory_scope";
}
}
};
template <>
struct StringMaker<sycl::access::address_space> {
using type = sycl::access::address_space;
static std::string convert(const type& addr_space) {
switch (addr_space) {
case type::global_space:
return "address_space::global_space";
case type::local_space:
return "address_space::local_space";
case type::generic_space:
return "address_space::generic_space";
case type::private_space:
return "address_space::private_space";
default:
// no stringification for deprecated ones
return "unknown or deprecated address_space";
}
}
};
// FIXME: re-enable when sycl::access::decorated is implemented in adaptivecpp
#if !SYCL_CTS_COMPILING_WITH_ADAPTIVECPP
template <>
struct StringMaker<sycl::access::decorated> {
using type = sycl::access::decorated;
static std::string convert(type value) {
switch (value) {
case type::yes:
return "access::decorated::yes";
case type::no:
return "access::decorated::no";
case type::legacy:
return "access::decorated::legacy";
default:
return "unknown";
}
}
};
#endif
} // namespace Catch
#endif // __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H