-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmintest.cpp
150 lines (124 loc) · 2.02 KB
/
mintest.cpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#define COUNT 10
#include <stdlib.h>
#include "tracerlib.h"
#include <stdio.h>
struct chunck
{
size_t start,end;
double *data;
};
double *A;
double *B;
double *C;
double *D;
size_t *I;
chunck *chuncks;
void init()
{
for(int i = 0; i < COUNT; i++)
{
A[i] = 1;
B[i] = 1;
C[i] = 1;
}
for(int i = 0; i < COUNT; i++)
{
I[i] = i;
}
}
void indirect()
{
for(int i = 0; i < COUNT; i++)
{
A[I[i]] = B[i] + 1;
}
}
void basic()
{
for(int i = 0; i < COUNT*4; i++)
{
A[i] = B[i] + 1;
}
}
void basic2()
{
for(int i = 0; i < COUNT; i++)
{
A[i] = C[i] + 1;
}
}
void dependant()
{
for(int i = 1; i < COUNT*3; i++)
{
C[i] = C[i-1] + 1;
}
}
double reduction()
{
double c = 0;
for(int i = 0; i < COUNT; i++)
{
c += (A[i] * B[i]);
}
return c;
}
void loop_bounds_dynamic(size_t start, size_t end, double *data, double *data2)
{
for(size_t i = start; i <= end; i++)
{
data[i] = data[i]+data2[i]*2;
}
}
void caseloop()
{
for(int i = 0; i < COUNT; i++)
{
switch(i)
{
case 1:
A[i] = B[i]+C[i];
default:
C[i] = B[i]+1;
}
}
}
void execute()
{
for(size_t i = 0; i < COUNT*10; i++)
{
chuncks[0].data[i] = 1;
chuncks[1].data[i] = 1;
}
chuncks[0].start = COUNT;
chuncks[0].end = COUNT+COUNT;
chuncks[1].start = COUNT;
chuncks[1].end = COUNT+COUNT;
loop_bounds_dynamic(chuncks[0].start,chuncks[0].end,chuncks[0].data,chuncks[1].data);
init();
basic();
init();
indirect();
init();
dependant();
basic2();
caseloop();
init();
C[0] = reduction();
}
int main()
{
A = (double *) malloc(sizeof(double) * COUNT * 10);
B = (double *) malloc(sizeof(double) * COUNT * 10);
C = (double *) malloc(sizeof(double) * COUNT * 10);
I = (size_t *) malloc(sizeof(size_t)*COUNT * 10);
chuncks = (chunck *) malloc (sizeof(chunck)*2);
chuncks[0].data = (double *) malloc(sizeof(double) * COUNT * 10);
chuncks[1].data = (double *) malloc(sizeof(double) * COUNT * 10);
execute();
free(A);
free(B);
free(C);
free(I);
return 0;
}