mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
libgomp/ * testsuite/libgomp.c++/target-std__array-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__array-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__bitset-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__bitset-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__deque-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__deque-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__forward_list-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__forward_list-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__list-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__list-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__map-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__map-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__multimap-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__multimap-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__multiset-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__multiset-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__set-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__set-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__span-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__span-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__valarray-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__valarray-concurrent.C: Adjust. * testsuite/libgomp.c++/target-std__vector-concurrent-usm.C: New. * testsuite/libgomp.c++/target-std__vector-concurrent.C: Adjust.
63 lines
1.1 KiB
C
63 lines
1.1 KiB
C
// { dg-do run }
|
|
// { dg-additional-options -DMEM_SHARED { target offload_device_shared_as } }
|
|
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <array>
|
|
#include <algorithm>
|
|
|
|
#define N 50000
|
|
|
|
void init (int data[])
|
|
{
|
|
for (int i = 0; i < N; ++i)
|
|
data[i] = rand ();
|
|
}
|
|
|
|
#pragma omp declare target
|
|
bool validate (const std::array<int,N> &arr, int data[])
|
|
{
|
|
for (int i = 0; i < N; ++i)
|
|
if (arr[i] != data[i] * data[i])
|
|
return false;
|
|
return true;
|
|
}
|
|
#pragma omp end declare target
|
|
|
|
int main (void)
|
|
{
|
|
int data[N];
|
|
bool ok;
|
|
std::array<int,N> arr;
|
|
|
|
srand (time (NULL));
|
|
init (data);
|
|
|
|
#ifndef MEM_SHARED
|
|
#pragma omp target data map (to: data[:N]) map (alloc: arr)
|
|
#endif
|
|
{
|
|
#pragma omp target
|
|
{
|
|
#ifndef MEM_SHARED
|
|
new (&arr) std::array<int,N> ();
|
|
#endif
|
|
std::copy (data, data + N, arr.begin ());
|
|
}
|
|
|
|
#pragma omp target teams distribute parallel for
|
|
for (int i = 0; i < N; ++i)
|
|
arr[i] *= arr[i];
|
|
|
|
#pragma omp target map (from: ok)
|
|
{
|
|
ok = validate (arr, data);
|
|
#ifndef MEM_SHARED
|
|
arr.~array ();
|
|
#endif
|
|
}
|
|
}
|
|
|
|
return ok ? 0 : 1;
|
|
}
|