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
|
/* Basic container usage. */
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#endif
bool vector_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::vector<int> vector;
ok = vector.empty();
}
return ok;
}
bool deque_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::deque<int> deque;
ok = deque.empty();
}
return ok;
}
bool list_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::list<int> list;
ok = list.empty();
}
return ok;
}
bool map_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::map<int, int> map;
ok = map.empty();
}
return ok;
}
bool set_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::set<int> set;
ok = set.empty();
}
return ok;
}
bool multimap_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::multimap<int, int> multimap;
ok = multimap.empty();
}
return ok;
}
bool multiset_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::multiset<int, int> multiset;
ok = multiset.empty();
}
return ok;
}
#if __cplusplus >= 201103L
bool array_test()
{
static constexpr std::size_t array_size = 42;
bool ok;
#pragma omp target map(from: ok)
{
std::array<int, array_size> array{};
ok = array[0] == 0
&& array[array_size - 1] == 0;
}
return ok;
}
bool forward_list_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::forward_list<int> forward_list;
ok = forward_list.empty();
}
return ok;
}
bool unordered_map_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::unordered_map<int, int> unordered_map;
ok = unordered_map.empty();
}
return ok;
}
bool unordered_set_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::unordered_set<int> unordered_set;
ok = unordered_set.empty();
}
return ok;
}
bool unordered_multimap_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::unordered_multimap<int, int> unordered_multimap;
ok = unordered_multimap.empty();
}
return ok;
}
bool unordered_multiset_test()
{
bool ok;
#pragma omp target map(from: ok)
{
std::unordered_multiset<int> unordered_multiset;
ok = unordered_multiset.empty();
}
return ok;
}
#else
bool array_test() { return true; }
bool forward_list_test() { return true; }
bool unordered_map_test() { return true; }
bool unordered_set_test() { return true; }
bool unordered_multimap_test() { return true; }
bool unordered_multiset_test() { return true; }
#endif
int main()
{
const bool vec_res = vector_test();
__builtin_printf("vector : %s\n", vec_res ? "PASS" : "FAIL");
const bool deque_res = deque_test();
__builtin_printf("deque : %s\n", deque_res ? "PASS" : "FAIL");
const bool list_res = list_test();
__builtin_printf("list : %s\n", list_res ? "PASS" : "FAIL");
const bool map_res = map_test();
__builtin_printf("map : %s\n", map_res ? "PASS" : "FAIL");
const bool set_res = set_test();
__builtin_printf("set : %s\n", set_res ? "PASS" : "FAIL");
const bool multimap_res = multimap_test();
__builtin_printf("multimap : %s\n", multimap_res ? "PASS" : "FAIL");
const bool multiset_res = multiset_test();
__builtin_printf("multiset : %s\n", multiset_res ? "PASS" : "FAIL");
const bool array_res = array_test();
__builtin_printf("array : %s\n", array_res ? "PASS" : "FAIL");
const bool forward_list_res = forward_list_test();
__builtin_printf("forward_list : %s\n", forward_list_res ? "PASS" : "FAIL");
const bool unordered_map_res = unordered_map_test();
__builtin_printf("unordered_map : %s\n", unordered_map_res ? "PASS" : "FAIL");
const bool unordered_set_res = unordered_set_test();
__builtin_printf("unordered_set : %s\n", unordered_set_res ? "PASS" : "FAIL");
const bool unordered_multimap_res = unordered_multimap_test();
__builtin_printf("unordered_multimap: %s\n", unordered_multimap_res ? "PASS" : "FAIL");
const bool unordered_multiset_res = unordered_multiset_test();
__builtin_printf("unordered_multiset: %s\n", unordered_multiset_res ? "PASS" : "FAIL");
const bool ok = vec_res
&& deque_res
&& list_res
&& map_res
&& set_res
&& multimap_res
&& multiset_res
&& array_res
&& forward_list_res
&& unordered_map_res
&& unordered_set_res
&& unordered_multimap_res
&& unordered_multiset_res;
return ok ? 0 : 1;
}
|