-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcopyin_copyout.c
68 lines (59 loc) · 1.13 KB
/
copyin_copyout.c
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
66
67
#include "acc_testsuite.h"
#ifndef T1
//T1:, V:1.0-2.7
int test1(){
int err = 0;
real_t test = 0;
#pragma acc parallel loop copyin(test) copyout(test) reduction(+:test)
for( int x = 0; x <n; ++x){
test += 1;
}
if(fabs(test - n) > PRECISION){
err++;
}
return err;
}
#endif
#ifndef T2
//T2: , V:1.0-2.7
int test2(){
int err = 0;
real_t *test = (real_t *)malloc(n * sizeof(real_t));
for(int x = 0; x < n; ++x){
test[x] = 1.0;
}
#pragma acc parallel loop copyin(test[0:n]) copyout(test[0:n])
for(int x = 0; x < n; ++x){
test[x] += 1.0;
}
for(int x = 0; x < n; ++x){
if(fabs(test[x] - 2.0) > PRECISION){
err++;
}
}
return err;
}
#endif
int main(){
int failcode = 0;
int failed;
#ifndef T1
failed = 0;
for( int x = 0; x < NUM_TEST_CALLS; ++x){
failed += test1();
}
if(failed){
failcode += (1 << 0);
}
#endif
#ifndef T2
failed = 0;
for( int x = 0; x < NUM_TEST_CALLS; ++x){
failed += test2();
}
if(failed){
failcode += (1 << 1);
}
#endif
return failcode;
}