-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpot.cl
190 lines (142 loc) · 4.71 KB
/
dpot.cl
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
__kernel void epot (__global double* potential,
__global double* charges,
__global double* locx,
__global double* locy,
__global double* locz,
int num_of_charges,
int sizex,int sizey,int sizez,
double dx, double dy, double dz,
double origin_x, double origin_y, double origin_z) {
int j;
int sizexBYsizey = sizex*sizey;
int index = get_global_id(0);
int index_z = index/sizexBYsizey;
int index_y = (index-index_z*sizexBYsizey)/sizex;
int index_x = index-index_z*sizexBYsizey-index_y*sizex;
double distance_x, distance_y, distance_z;
double sum = 0.f;
double corrector = 0.f;
double y,t;
for(j=0;j<num_of_charges;j++) {
distance_x = (origin_x+((double)index_x)*dx)-locx[j];
distance_y = (origin_y+((double)index_y)*dy)-locy[j];
distance_z = (origin_z+((double)index_z)*dz)-locz[j];
y = charges[j]
*rsqrt(distance_x*distance_x
+distance_y*distance_y
+distance_z*distance_z)-corrector;
t = sum + y;
corrector = (t-sum)-y;
sum = t;
}
potential[index]=sum;
}
__kernel void contractionL1(__global double* potential,
__global double* realpotential,
__global double* contracted,
__global char* mask,
int num_of_points_per_contraction) {
int contraction_number = get_global_id(0);
int contracted_size = get_global_size(0);
// int num_of_points_per_contraction = dimension/contracted_size;
int local_location;
int i;
double sum = 0.f;
double corrector = 0.f;
double y,t;
double diff;
for(i=0;i<num_of_points_per_contraction;i++) {
local_location = contraction_number*num_of_points_per_contraction+i;
if (mask[local_location] != 1) {
diff = potential[local_location]-realpotential[local_location];
y = fabs(diff)-corrector;
t = sum + y;
corrector = (t-sum)-y;
sum = t;
}
}
contracted[contraction_number] = sum;
}
__kernel void contractionL2(__global double* potential,
__global double* realpotential,
__global double* contracted,
__global char* mask,
int num_of_points_per_contraction) {
int contraction_number = get_global_id(0);
int contracted_size = get_global_size(0);
// int num_of_points_per_contraction = dimension/contracted_size;
int local_location;
int i;
double sum = 0.f;
double corrector = 0.f;
double y,t;
double diff;
for(i=0;i<num_of_points_per_contraction;i++) {
local_location = contraction_number*num_of_points_per_contraction+i;
if (mask[local_location] != 1) {
diff = potential[local_location]-realpotential[local_location];
y = diff*diff-corrector;
t = sum + y;
corrector = (t-sum)-y;
sum = t;
}
}
contracted[contraction_number] = sum;
}
__kernel void contractionL1w(__global double* potential,
__global double* realpotential,
__global double* contracted,
__global char* mask,
int num_of_points_per_contraction) {
double small = 0.000000010536;
int contraction_number = get_global_id(0);
int contracted_size = get_global_size(0);
//int num_of_points_per_contraction = dimension/contracted_size;
int local_location;
int i;
double sum = 0.f;
double corrector = 0.f;
double y,t;
double diff;
for(i=0;i<num_of_points_per_contraction;i++) {
local_location = contraction_number*num_of_points_per_contraction+i;
if (mask[local_location] != 1) {
diff = potential[local_location]-realpotential[local_location];
y = fabs(diff)/(fabs(realpotential[local_location])+small)-corrector;
t = sum + y;
corrector = (t-sum)-y;
sum = t;
}
}
contracted[contraction_number] = sum;
}
__kernel void contractionL2w(__global double* potential,
__global double* realpotential,
__global double* contracted,
__global char* mask,
int num_of_points_per_contraction) {
double small = 0.000000010536;
int contraction_number = get_global_id(0);
int contracted_size = get_global_size(0);
//int num_of_points_per_contraction = dimension/contracted_size;
int local_location;
int i;
double sum = 0.f;
double corrector = 0.f;
double y,t;
double diff;
for(i=0;i<num_of_points_per_contraction;i++) {
local_location = contraction_number*num_of_points_per_contraction+i;
if (mask[local_location] != 1) {
diff = potential[local_location]-realpotential[local_location];
y = diff*diff
/(realpotential[local_location]*realpotential[local_location]+small)
-corrector;
t = sum + y;
corrector = (t-sum)-y;
sum = t;
}
}
contracted[contraction_number] = sum;
}