blob: b3f743a8c384e767396e59347ca52c6959481d7a (
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
|
#include <string.h>
#define N 1024
int A[N];
int B[N];
void loop_with_condition() {
int i;
__sync_synchronize();
for (i = 0; i < N; i++) {
if (i <= N / 2) {
if (i > 20)
A[i] = 1;
else
A[i] = 2;
}
B[i] = 3;
}
__sync_synchronize();
}
int main () {
int i;
memset(A, 0, sizeof(int) * N);
memset(B, 0, sizeof(int) * N);
loop_with_condition();
for (i = 0; i < N; i++)
if (B[i] != 3)
return 1;
for (i = 0; i < N; i++)
if (i <= N / 2 && i > 20 && A[i] != 1)
return 1;
else if (i > N / 2) {
if (i <= 20 && A[i] != 2)
return 1;
if (i > 20 && A[i] != 0)
return 1;
}
return 0;
}
|