blob: 0030de8791a0bcf2b426e9e905fb3aa418686d01 (
plain)
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
|
// { dg-do run }
#include <cassert>
struct S
{
int *myarr;
int len;
};
class C
{
S smemb;
#pragma omp declare mapper (custom:S s) map(to:s.myarr) \
map(tofrom:s.myarr[0:s.len])
public:
C(int l)
{
smemb.myarr = new int[l];
smemb.len = l;
for (int i = 0; i < l; i++)
smemb.myarr[i] = 0;
}
void bump();
void check();
};
void
C::bump ()
{
#pragma omp target map(mapper(custom), tofrom: smemb)
{
for (int i = 0; i < smemb.len; i++)
smemb.myarr[i]++;
}
}
void
C::check ()
{
for (int i = 0; i < smemb.len; i++)
assert (smemb.myarr[i] == 1);
}
int main (int argc, char *argv[])
{
C test (100);
test.bump ();
test.check ();
return 0;
}
|