Debian Codegraph @

libgomp/testsuite/libgomp.c++/target-flex-80.C

raw
1 // { dg-additional-options "-std=c++20" }
2
3 /* std::span */
4
5 #include <span>
6
7 #include "target-flex-common.h"
8
9 template<typename It0, typename It1>
10 bool simple_equal(It0 it0, const It0 end0,
11 It1 it1, const It1 end1) noexcept
12 {
13 for (; it0 != end0; ++it0, ++it1)
14 if (it1 == end1 || *it0 != *it1)
15 return false;
16 return true;
17 }
18
19 template<typename T, std::size_t Size>
20 bool test(const T (&arr)[Size])
21 {
22 bool ok;
23 T out_arr[Size];
24 #pragma omp target map(from: ok) map(to: arr[:Size])
25 {
26 std::span span = {arr, Size};
27 bool inner_ok = true;
28 {
29 VERIFY (!span.empty());
30 VERIFY (span.size() == Size);
31 auto out_it = out_arr;
32 for (auto elem : span)
33 *(out_it++) = elem;
34 }
35 end:
36 ok = inner_ok;
37 }
38 if (!ok)
39 return false;
40 VERIFY_NON_TARGET (simple_equal(arr, arr + Size,
41 out_arr, out_arr + Size));
42 return true;
43 }
44
45 int main()
46 {
47 int arr[8] = {0, 1, 2, 3, 4, 5, 6, 7};
48 return test(arr) ? 0 : 1;
49 }