| 1 |
/* structured bindings */ |
| 2 |
|
| 3 |
#include <array> |
| 4 |
#include <tuple> |
| 5 |
|
| 6 |
#include "target-flex-common.h" |
| 7 |
|
| 8 |
template<typename Array, typename Tuple, typename Struct> |
| 9 |
bool test(Array array, Tuple tuple, Struct s) |
| 10 |
{ |
| 11 |
bool ok; |
| 12 |
auto array_2nd_in = std::get<2>(array); |
| 13 |
auto tuple_2nd_in = std::get<2>(tuple); |
| 14 |
auto s_2nd_in = s._2; |
| 15 |
decltype(array_2nd_in) array_2nd_out_0; |
| 16 |
decltype(tuple_2nd_in) tuple_2nd_out_0; |
| 17 |
decltype(s_2nd_in) s_2nd_out_0; |
| 18 |
decltype(array_2nd_in) array_2nd_out_1; |
| 19 |
decltype(tuple_2nd_in) tuple_2nd_out_1; |
| 20 |
decltype(s_2nd_in) s_2nd_out_1; |
| 21 |
decltype(array_2nd_in) array_2nd_out_2; |
| 22 |
decltype(tuple_2nd_in) tuple_2nd_out_2; |
| 23 |
decltype(s_2nd_in) s_2nd_out_2; |
| 24 |
#pragma omp target map(from: ok, \ |
| 25 |
array_2nd_out_0, tuple_2nd_out_0, s_2nd_out_0, \ |
| 26 |
array_2nd_out_1, tuple_2nd_out_1, s_2nd_out_1, \ |
| 27 |
array_2nd_out_2, tuple_2nd_out_2, s_2nd_out_2) \ |
| 28 |
map(to: array_2nd_in, tuple_2nd_in, s_2nd_in, array, tuple, s) |
| 29 |
{ |
| 30 |
bool inner_ok = true; |
| 31 |
{ |
| 32 |
{ |
| 33 |
auto [array_0th, array_1st, array_2nd] = array; |
| 34 |
VERIFY (array_2nd_in == array_2nd); |
| 35 |
VERIFY (std::get<2>(array) == array_2nd); |
| 36 |
array_2nd_out_0 = array_2nd; |
| 37 |
auto [tuple_0th, tuple_1st, tuple_2nd] = tuple; |
| 38 |
VERIFY (tuple_2nd_in == tuple_2nd); |
| 39 |
VERIFY (std::get<2>(tuple) == tuple_2nd); |
| 40 |
tuple_2nd_out_0 = tuple_2nd; |
| 41 |
auto [s_0th, s_1st, s_2nd] = s; |
| 42 |
VERIFY (s_2nd_in == s_2nd); |
| 43 |
VERIFY (s._2 == s_2nd); |
| 44 |
s_2nd_out_0 = s_2nd; |
| 45 |
} |
| 46 |
{ |
| 47 |
auto& [array_0th, array_1st, array_2nd] = array; |
| 48 |
VERIFY (array_2nd_in == array_2nd); |
| 49 |
VERIFY (std::get<2>(array) == array_2nd); |
| 50 |
array_2nd_out_1 = array_2nd; |
| 51 |
auto& [tuple_0th, tuple_1st, tuple_2nd] = tuple; |
| 52 |
VERIFY (tuple_2nd_in == tuple_2nd); |
| 53 |
VERIFY (std::get<2>(tuple) == tuple_2nd); |
| 54 |
tuple_2nd_out_1 = tuple_2nd; |
| 55 |
auto& [s_0th, s_1st, s_2nd] = s; |
| 56 |
VERIFY (s_2nd_in == s_2nd); |
| 57 |
VERIFY (s._2 == s_2nd); |
| 58 |
s_2nd_out_1 = s_2nd; |
| 59 |
} |
| 60 |
{ |
| 61 |
const auto& [array_0th, array_1st, array_2nd] = array; |
| 62 |
VERIFY (array_2nd_in == array_2nd); |
| 63 |
VERIFY (std::get<2>(array) == array_2nd); |
| 64 |
array_2nd_out_2 = array_2nd; |
| 65 |
const auto& [tuple_0th, tuple_1st, tuple_2nd] = tuple; |
| 66 |
VERIFY (tuple_2nd_in == tuple_2nd); |
| 67 |
VERIFY (std::get<2>(tuple) == tuple_2nd); |
| 68 |
tuple_2nd_out_2 = tuple_2nd; |
| 69 |
const auto& [s_0th, s_1st, s_2nd] = s; |
| 70 |
VERIFY (s_2nd_in == s_2nd); |
| 71 |
VERIFY (s._2 == s_2nd); |
| 72 |
s_2nd_out_2 = s_2nd; |
| 73 |
} |
| 74 |
} |
| 75 |
end: |
| 76 |
ok = inner_ok; |
| 77 |
} |
| 78 |
if (!ok) |
| 79 |
return false; |
| 80 |
VERIFY_NON_TARGET (array_2nd_out_0 == array_2nd_in); |
| 81 |
VERIFY_NON_TARGET (tuple_2nd_out_0 == tuple_2nd_in); |
| 82 |
VERIFY_NON_TARGET (s_2nd_out_0 == s_2nd_in); |
| 83 |
VERIFY_NON_TARGET (array_2nd_out_1 == array_2nd_in); |
| 84 |
VERIFY_NON_TARGET (tuple_2nd_out_1 == tuple_2nd_in); |
| 85 |
VERIFY_NON_TARGET (s_2nd_out_1 == s_2nd_in); |
| 86 |
VERIFY_NON_TARGET (array_2nd_out_2 == array_2nd_in); |
| 87 |
VERIFY_NON_TARGET (tuple_2nd_out_2 == tuple_2nd_in); |
| 88 |
VERIFY_NON_TARGET (s_2nd_out_2 == s_2nd_in); |
| 89 |
|
| 90 |
return true; |
| 91 |
} |
| 92 |
|
| 93 |
struct S |
| 94 |
{ |
| 95 |
char _0; |
| 96 |
float _1; |
| 97 |
int _2; |
| 98 |
}; |
| 99 |
|
| 100 |
int main() |
| 101 |
{ |
| 102 |
const bool test_res |
| 103 |
= test(std::array{0, 1, 2}, |
| 104 |
std::tuple{'a', 3.14f, 42}, |
| 105 |
S{'a', 3.14f, 42}); |
| 106 |
return test_res ? 0 : 1; |
| 107 |
} |