1 #include "simint/boys/boys.h"
2 #include "simint/ostei/gen/ostei_generated.h"
3 #include "simint/vectorization/vectorization.h"
4 #include <math.h>
5 #include <string.h>
6
7
ostei_s_s_s_f(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__s_s_s_f)8 int ostei_s_s_s_f(struct simint_multi_shellpair const P,
9 struct simint_multi_shellpair const Q,
10 double screen_tol,
11 double * const restrict work,
12 double * const restrict INT__s_s_s_f)
13 {
14
15 SIMINT_ASSUME_ALIGN_DBL(work);
16 SIMINT_ASSUME_ALIGN_DBL(INT__s_s_s_f);
17 memset(INT__s_s_s_f, 0, P.nshell12_clip * Q.nshell12_clip * 10 * sizeof(double));
18
19 int ab, cd, abcd;
20 int istart, jstart;
21 int iprimcd, nprim_icd, icd;
22 const int check_screen = (screen_tol > 0.0);
23 int i, j;
24 int n;
25 int not_screened;
26
27 // partition workspace
28 SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*0);
29 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
30 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_p = primwork + 4;
31 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_d = primwork + 13;
32 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_f = primwork + 25;
33 double * const hrrwork = (double *)(primwork + 35);
34
35
36 // Create constants
37 const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
38 const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
39 const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
40
41
42 ////////////////////////////////////////
43 // Loop over shells and primitives
44 ////////////////////////////////////////
45
46 abcd = 0;
47 istart = 0;
48 for(ab = 0; ab < P.nshell12_clip; ++ab)
49 {
50 const int iend = istart + P.nprim12[ab];
51
52 cd = 0;
53 jstart = 0;
54
55 for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
56 {
57 const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
58 int jend = jstart;
59 for(i = 0; i < nshellbatch; i++)
60 jend += Q.nprim12[cd+i];
61
62
63 for(i = istart; i < iend; ++i)
64 {
65 SIMINT_DBLTYPE bra_screen_max; // only used if check_screen
66
67 if(check_screen)
68 {
69 // Skip this whole thing if always insignificant
70 if((P.screen[i] * Q.screen_max) < screen_tol)
71 continue;
72 bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
73 }
74
75 icd = 0;
76 iprimcd = 0;
77 nprim_icd = Q.nprim12[cd];
78 double * restrict PRIM_PTR_INT__s_s_s_f = INT__s_s_s_f + abcd * 10;
79
80
81
82 // Load these one per loop over i
83 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
84 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
85 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
86
87
88 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
89 {
90 // calculate the shell offsets
91 // these are the offset from the shell pointed to by cd
92 // for each element
93 int shelloffsets[SIMINT_SIMD_LEN] = {0};
94 int lastoffset = 0;
95 const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
96
97 if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
98 {
99 // Handle if the first element of the vector is a new shell
100 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
101 {
102 nprim_icd += Q.nprim12[cd + (++icd)];
103 PRIM_PTR_INT__s_s_s_f += 10;
104 }
105 iprimcd++;
106 for(n = 1; n < SIMINT_SIMD_LEN; ++n)
107 {
108 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
109 {
110 shelloffsets[n] = shelloffsets[n-1] + 1;
111 lastoffset++;
112 nprim_icd += Q.nprim12[cd + (++icd)];
113 }
114 else
115 shelloffsets[n] = shelloffsets[n-1];
116 iprimcd++;
117 }
118 }
119 else
120 iprimcd += SIMINT_SIMD_LEN;
121
122 // Do we have to compute this vector (or has it been screened out)?
123 // (not_screened != 0 means we have to do this vector)
124 if(check_screen)
125 {
126 const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
127 if(vmax < screen_tol)
128 {
129 PRIM_PTR_INT__s_s_s_f += lastoffset*10;
130 continue;
131 }
132 }
133
134 const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
135 const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
136 const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
137 const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
138
139
140 /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
141 SIMINT_DBLTYPE PQ[3];
142 PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
143 PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
144 PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
145 SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
146 R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
147 R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
148
149 const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
150 const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
151 const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
152 const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
153 const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
154 const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
155 const SIMINT_DBLTYPE Q_PB[3] = { SIMINT_DBLLOAD(Q.PB_x, j), SIMINT_DBLLOAD(Q.PB_y, j), SIMINT_DBLLOAD(Q.PB_z, j) };
156
157 SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
158 SIMINT_DBLTYPE aoq_PQ[3];
159 aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
160 aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
161 aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
162 // Put a minus sign here so we don't have to in RR routines
163 a_over_q = SIMINT_NEG(a_over_q);
164
165
166 //////////////////////////////////////////////
167 // Fjt function section
168 // Maximum v value: 3
169 //////////////////////////////////////////////
170 // The parameter to the Fjt function
171 const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
172
173
174 const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
175
176
177 boys_F_split(PRIM_INT__s_s_s_s, F_x, 3);
178 SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
179 prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
180 for(n = 0; n <= 3; n++)
181 PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
182
183 //////////////////////////////////////////////
184 // Primitive integrals: Vertical recurrance
185 //////////////////////////////////////////////
186
187 const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
188 const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
189
190
191
192 // Forming PRIM_INT__s_s_s_p[3 * 3];
193 for(n = 0; n < 3; ++n) // loop over orders of auxiliary function
194 {
195
196 PRIM_INT__s_s_s_p[n * 3 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
197 PRIM_INT__s_s_s_p[n * 3 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 0]);
198
199 PRIM_INT__s_s_s_p[n * 3 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
200 PRIM_INT__s_s_s_p[n * 3 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 1]);
201
202 PRIM_INT__s_s_s_p[n * 3 + 2] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
203 PRIM_INT__s_s_s_p[n * 3 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 2]);
204
205 }
206
207
208
209 // Forming PRIM_INT__s_s_s_d[2 * 6];
210 for(n = 0; n < 2; ++n) // loop over orders of auxiliary function
211 {
212
213 PRIM_INT__s_s_s_d[n * 6 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_p[n * 3 + 0]);
214 PRIM_INT__s_s_s_d[n * 6 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_p[(n+1) * 3 + 0], PRIM_INT__s_s_s_d[n * 6 + 0]);
215 PRIM_INT__s_s_s_d[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_s_d[n * 6 + 0]);
216
217 PRIM_INT__s_s_s_d[n * 6 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_p[n * 3 + 0]);
218 PRIM_INT__s_s_s_d[n * 6 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_p[(n+1) * 3 + 0], PRIM_INT__s_s_s_d[n * 6 + 1]);
219
220 PRIM_INT__s_s_s_d[n * 6 + 3] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_p[n * 3 + 1]);
221 PRIM_INT__s_s_s_d[n * 6 + 3] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_p[(n+1) * 3 + 1], PRIM_INT__s_s_s_d[n * 6 + 3]);
222 PRIM_INT__s_s_s_d[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_s_d[n * 6 + 3]);
223
224 PRIM_INT__s_s_s_d[n * 6 + 5] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_p[n * 3 + 2]);
225 PRIM_INT__s_s_s_d[n * 6 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_p[(n+1) * 3 + 2], PRIM_INT__s_s_s_d[n * 6 + 5]);
226 PRIM_INT__s_s_s_d[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_s_d[n * 6 + 5]);
227
228 }
229
230
231
232 // Forming PRIM_INT__s_s_s_f[1 * 10];
233 for(n = 0; n < 1; ++n) // loop over orders of auxiliary function
234 {
235
236 PRIM_INT__s_s_s_f[n * 10 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_d[n * 6 + 0]);
237 PRIM_INT__s_s_s_f[n * 10 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_d[(n+1) * 6 + 0], PRIM_INT__s_s_s_f[n * 10 + 0]);
238 PRIM_INT__s_s_s_f[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_p[(n+1) * 3 + 0], PRIM_INT__s_s_s_p[n * 3 + 0]), PRIM_INT__s_s_s_f[n * 10 + 0]);
239
240 PRIM_INT__s_s_s_f[n * 10 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_d[n * 6 + 0]);
241 PRIM_INT__s_s_s_f[n * 10 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_d[(n+1) * 6 + 0], PRIM_INT__s_s_s_f[n * 10 + 1]);
242
243 PRIM_INT__s_s_s_f[n * 10 + 2] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_d[n * 6 + 0]);
244 PRIM_INT__s_s_s_f[n * 10 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_d[(n+1) * 6 + 0], PRIM_INT__s_s_s_f[n * 10 + 2]);
245
246 PRIM_INT__s_s_s_f[n * 10 + 3] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_d[n * 6 + 3]);
247 PRIM_INT__s_s_s_f[n * 10 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_d[(n+1) * 6 + 3], PRIM_INT__s_s_s_f[n * 10 + 3]);
248
249 PRIM_INT__s_s_s_f[n * 10 + 4] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_d[n * 6 + 1]);
250 PRIM_INT__s_s_s_f[n * 10 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_d[(n+1) * 6 + 1], PRIM_INT__s_s_s_f[n * 10 + 4]);
251
252 PRIM_INT__s_s_s_f[n * 10 + 5] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_d[n * 6 + 5]);
253 PRIM_INT__s_s_s_f[n * 10 + 5] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_d[(n+1) * 6 + 5], PRIM_INT__s_s_s_f[n * 10 + 5]);
254
255 PRIM_INT__s_s_s_f[n * 10 + 6] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_d[n * 6 + 3]);
256 PRIM_INT__s_s_s_f[n * 10 + 6] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_d[(n+1) * 6 + 3], PRIM_INT__s_s_s_f[n * 10 + 6]);
257 PRIM_INT__s_s_s_f[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_p[(n+1) * 3 + 1], PRIM_INT__s_s_s_p[n * 3 + 1]), PRIM_INT__s_s_s_f[n * 10 + 6]);
258
259 PRIM_INT__s_s_s_f[n * 10 + 7] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_d[n * 6 + 3]);
260 PRIM_INT__s_s_s_f[n * 10 + 7] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_d[(n+1) * 6 + 3], PRIM_INT__s_s_s_f[n * 10 + 7]);
261
262 PRIM_INT__s_s_s_f[n * 10 + 8] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_d[n * 6 + 5]);
263 PRIM_INT__s_s_s_f[n * 10 + 8] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_d[(n+1) * 6 + 5], PRIM_INT__s_s_s_f[n * 10 + 8]);
264
265 PRIM_INT__s_s_s_f[n * 10 + 9] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_d[n * 6 + 5]);
266 PRIM_INT__s_s_s_f[n * 10 + 9] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_d[(n+1) * 6 + 5], PRIM_INT__s_s_s_f[n * 10 + 9]);
267 PRIM_INT__s_s_s_f[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_p[(n+1) * 3 + 2], PRIM_INT__s_s_s_p[n * 3 + 2]), PRIM_INT__s_s_s_f[n * 10 + 9]);
268
269 }
270
271
272
273
274 ////////////////////////////////////
275 // Accumulate contracted integrals
276 ////////////////////////////////////
277 if(lastoffset == 0)
278 {
279 contract_all(10, PRIM_INT__s_s_s_f, PRIM_PTR_INT__s_s_s_f);
280 }
281 else
282 {
283 contract(10, shelloffsets, PRIM_INT__s_s_s_f, PRIM_PTR_INT__s_s_s_f);
284 PRIM_PTR_INT__s_s_s_f += lastoffset*10;
285 }
286
287 } // close loop over j
288 } // close loop over i
289
290 //Advance to the next batch
291 jstart = SIMINT_SIMD_ROUND(jend);
292 abcd += nshellbatch;
293
294 } // close loop cdbatch
295
296 istart = iend;
297 } // close loop over ab
298
299 return P.nshell12_clip * Q.nshell12_clip;
300 }
301
302