| 1 |
/* { dg-additional-options -std=c++23 } */ |
| 2 |
|
| 3 |
/* numerics */ |
| 4 |
|
| 5 |
#include <algorithm> |
| 6 |
#include <numeric> |
| 7 |
#include <ranges> |
| 8 |
#include <span> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
//TODO PR120454 "C++ constexpr vs. OpenMP implicit mapping" |
| 12 |
#pragma omp declare target(std::ranges::all_of, std::ranges::iota) |
| 13 |
|
| 14 |
#include "target-flex-common.h" |
| 15 |
|
| 16 |
namespace stdr = std::ranges; |
| 17 |
|
| 18 |
bool test(std::size_t arg) |
| 19 |
{ |
| 20 |
bool ok; |
| 21 |
int midpoint_out; |
| 22 |
std::vector<int> vec(arg); |
| 23 |
int *data = vec.data(); |
| 24 |
std::size_t size = vec.size(); |
| 25 |
#pragma omp target defaultmap(none) map(from: ok, midpoint_out) map(tofrom: data[:size]) map(to: arg, size) |
| 26 |
{ |
| 27 |
std::span span = {data, size}; |
| 28 |
bool inner_ok = true; |
| 29 |
{ |
| 30 |
VERIFY (stdr::all_of(span, [](int v){ return v == int{}; })); |
| 31 |
stdr::iota(span, 0); |
| 32 |
midpoint_out = *std::midpoint(span.data(), span.data() + span.size()); |
| 33 |
} |
| 34 |
end: |
| 35 |
ok = inner_ok; |
| 36 |
} |
| 37 |
if (!ok) |
| 38 |
return false; |
| 39 |
VERIFY_NON_TARGET (stdr::equal(vec, std::views::iota(0, static_cast<int>(vec.size())))); |
| 40 |
VERIFY_NON_TARGET (*std::midpoint(vec.data(), vec.data() + vec.size()) |
| 41 |
== midpoint_out); |
| 42 |
return true; |
| 43 |
} |
| 44 |
|
| 45 |
int main() |
| 46 |
{ |
| 47 |
volatile std::size_t arg = 42; |
| 48 |
return test(arg) ? 0 : 1; |
| 49 |
} |