blob: 438c64a1593cd2f4c47b70d18ebe837a25bf056c (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <assert.h>
#include <complex.h>
#include <math.h>
#define uchar unsigned char
#define C 123
#define TEST(type) \
type foo_##type (void) \
{ \
_Complex type a = C + 45I; \
return __real__ a; \
}
#pragma omp declare target
TEST (char)
TEST (uchar)
TEST (short)
TEST (int)
float
bar (float a, float b)
{
_Complex float c = a + b * I;
c += 11.f + 12.f * I;
_Complex float d = 2.f + 4.44f * I;
return __real__(crealf (c + d) + cimag (d) * I);
}
#pragma omp end declare target
int
main (void)
{
int v = 0;
float v2 = 0.0f;
#pragma omp target map(to: v)
v = foo_char ();
assert (v == C);
#pragma omp target map(to: v)
v = foo_uchar ();
assert (v == C);
#pragma omp target map(to: v)
v = foo_short ();
assert (v == C);
#pragma omp target map(to: v)
v = foo_int ();
assert (v == C);
#pragma omp target map(to: v2)
v2 = bar (1.12f, 4.44f);
assert (fabs (v2 - 14.12) < 0.0001f);
}
|