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_p_f_s_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_f_s_s)8 int ostei_p_f_s_s(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__p_f_s_s)
13 {
14
15 SIMINT_ASSUME_ALIGN_DBL(work);
16 SIMINT_ASSUME_ALIGN_DBL(INT__p_f_s_s);
17 int ab, cd, abcd;
18 int istart, jstart;
19 int iprimcd, nprim_icd, icd;
20 const int check_screen = (screen_tol > 0.0);
21 int i, j;
22 int n;
23 int not_screened;
24 int real_abcd;
25 int iket;
26
27 // partition workspace
28 double * const INT__s_f_s_s = work + (SIMINT_NSHELL_SIMD * 0);
29 double * const INT__s_g_s_s = work + (SIMINT_NSHELL_SIMD * 10);
30 SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*25);
31 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
32 SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_s_s = primwork + 5;
33 SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_s_s = primwork + 17;
34 SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_s_s = primwork + 35;
35 SIMINT_DBLTYPE * const restrict PRIM_INT__s_g_s_s = primwork + 55;
36 double * const hrrwork = (double *)(primwork + 70);
37
38
39 // Create constants
40 const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
41 const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
42 const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
43 const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
44
45
46 ////////////////////////////////////////
47 // Loop over shells and primitives
48 ////////////////////////////////////////
49
50 real_abcd = 0;
51 istart = 0;
52 for(ab = 0; ab < P.nshell12_clip; ++ab)
53 {
54 const int iend = istart + P.nprim12[ab];
55
56 cd = 0;
57 jstart = 0;
58
59 for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
60 {
61 const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
62 int jend = jstart;
63 for(i = 0; i < nshellbatch; i++)
64 jend += Q.nprim12[cd+i];
65
66 // Clear the beginning of the workspace (where we are accumulating integrals)
67 memset(work, 0, SIMINT_NSHELL_SIMD * 25 * sizeof(double));
68 abcd = 0;
69
70
71 for(i = istart; i < iend; ++i)
72 {
73 SIMINT_DBLTYPE bra_screen_max; // only used if check_screen
74
75 if(check_screen)
76 {
77 // Skip this whole thing if always insignificant
78 if((P.screen[i] * Q.screen_max) < screen_tol)
79 continue;
80 bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
81 }
82
83 icd = 0;
84 iprimcd = 0;
85 nprim_icd = Q.nprim12[cd];
86 double * restrict PRIM_PTR_INT__s_f_s_s = INT__s_f_s_s + abcd * 10;
87 double * restrict PRIM_PTR_INT__s_g_s_s = INT__s_g_s_s + abcd * 15;
88
89
90
91 // Load these one per loop over i
92 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
93 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
94 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
95
96 const SIMINT_DBLTYPE P_PB[3] = { SIMINT_DBLSET1(P.PB_x[i]), SIMINT_DBLSET1(P.PB_y[i]), SIMINT_DBLSET1(P.PB_z[i]) };
97
98 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
99 {
100 // calculate the shell offsets
101 // these are the offset from the shell pointed to by cd
102 // for each element
103 int shelloffsets[SIMINT_SIMD_LEN] = {0};
104 int lastoffset = 0;
105 const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
106
107 if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
108 {
109 // Handle if the first element of the vector is a new shell
110 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
111 {
112 nprim_icd += Q.nprim12[cd + (++icd)];
113 PRIM_PTR_INT__s_f_s_s += 10;
114 PRIM_PTR_INT__s_g_s_s += 15;
115 }
116 iprimcd++;
117 for(n = 1; n < SIMINT_SIMD_LEN; ++n)
118 {
119 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
120 {
121 shelloffsets[n] = shelloffsets[n-1] + 1;
122 lastoffset++;
123 nprim_icd += Q.nprim12[cd + (++icd)];
124 }
125 else
126 shelloffsets[n] = shelloffsets[n-1];
127 iprimcd++;
128 }
129 }
130 else
131 iprimcd += SIMINT_SIMD_LEN;
132
133 // Do we have to compute this vector (or has it been screened out)?
134 // (not_screened != 0 means we have to do this vector)
135 if(check_screen)
136 {
137 const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
138 if(vmax < screen_tol)
139 {
140 PRIM_PTR_INT__s_f_s_s += lastoffset*10;
141 PRIM_PTR_INT__s_g_s_s += lastoffset*15;
142 continue;
143 }
144 }
145
146 const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
147 const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
148 const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
149 const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
150
151
152 /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
153 SIMINT_DBLTYPE PQ[3];
154 PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
155 PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
156 PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
157 SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
158 R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
159 R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
160
161 const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
162 const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
163 const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
164 const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
165 const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
166 const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
167
168 // NOTE: Minus sign!
169 const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
170 SIMINT_DBLTYPE aop_PQ[3];
171 aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
172 aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
173 aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
174
175
176 //////////////////////////////////////////////
177 // Fjt function section
178 // Maximum v value: 4
179 //////////////////////////////////////////////
180 // The parameter to the Fjt function
181 const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
182
183
184 const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
185
186
187 boys_F_split(PRIM_INT__s_s_s_s, F_x, 4);
188 SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
189 prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
190 for(n = 0; n <= 4; n++)
191 PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
192
193 //////////////////////////////////////////////
194 // Primitive integrals: Vertical recurrance
195 //////////////////////////////////////////////
196
197 const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
198 const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
199 const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
200
201
202
203 // Forming PRIM_INT__s_p_s_s[4 * 3];
204 for(n = 0; n < 4; ++n) // loop over orders of auxiliary function
205 {
206
207 PRIM_INT__s_p_s_s[n * 3 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
208 PRIM_INT__s_p_s_s[n * 3 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]);
209
210 PRIM_INT__s_p_s_s[n * 3 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
211 PRIM_INT__s_p_s_s[n * 3 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 1]);
212
213 PRIM_INT__s_p_s_s[n * 3 + 2] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
214 PRIM_INT__s_p_s_s[n * 3 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 2]);
215
216 }
217
218
219
220 // Forming PRIM_INT__s_d_s_s[3 * 6];
221 for(n = 0; n < 3; ++n) // loop over orders of auxiliary function
222 {
223
224 PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_p_s_s[n * 3 + 0]);
225 PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_s[n * 6 + 0]);
226 PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 0]);
227
228 PRIM_INT__s_d_s_s[n * 6 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_p_s_s[n * 3 + 0]);
229 PRIM_INT__s_d_s_s[n * 6 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_s[n * 6 + 1]);
230
231 PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_MUL(P_PB[1], PRIM_INT__s_p_s_s[n * 3 + 1]);
232 PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_s[n * 6 + 3]);
233 PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 3]);
234
235 PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_MUL(P_PB[2], PRIM_INT__s_p_s_s[n * 3 + 2]);
236 PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_d_s_s[n * 6 + 5]);
237 PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 5]);
238
239 }
240
241
242
243 // Forming PRIM_INT__s_f_s_s[2 * 10];
244 for(n = 0; n < 2; ++n) // loop over orders of auxiliary function
245 {
246
247 PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 0]);
248 PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 0]);
249 PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]), PRIM_INT__s_f_s_s[n * 10 + 0]);
250
251 PRIM_INT__s_f_s_s[n * 10 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 0]);
252 PRIM_INT__s_f_s_s[n * 10 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 1]);
253
254 PRIM_INT__s_f_s_s[n * 10 + 2] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 0]);
255 PRIM_INT__s_f_s_s[n * 10 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 2]);
256
257 PRIM_INT__s_f_s_s[n * 10 + 3] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 3]);
258 PRIM_INT__s_f_s_s[n * 10 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 3]);
259
260 PRIM_INT__s_f_s_s[n * 10 + 4] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 1]);
261 PRIM_INT__s_f_s_s[n * 10 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 1], PRIM_INT__s_f_s_s[n * 10 + 4]);
262
263 PRIM_INT__s_f_s_s[n * 10 + 5] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 5]);
264 PRIM_INT__s_f_s_s[n * 10 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 5]);
265
266 PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 3]);
267 PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 6]);
268 PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_s[n * 3 + 1]), PRIM_INT__s_f_s_s[n * 10 + 6]);
269
270 PRIM_INT__s_f_s_s[n * 10 + 7] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 3]);
271 PRIM_INT__s_f_s_s[n * 10 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 7]);
272
273 PRIM_INT__s_f_s_s[n * 10 + 8] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 5]);
274 PRIM_INT__s_f_s_s[n * 10 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 8]);
275
276 PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 5]);
277 PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 9]);
278 PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_s[n * 3 + 2]), PRIM_INT__s_f_s_s[n * 10 + 9]);
279
280 }
281
282
283 VRR_J_s_g_s_s(
284 PRIM_INT__s_g_s_s,
285 PRIM_INT__s_f_s_s,
286 PRIM_INT__s_d_s_s,
287 P_PB,
288 a_over_p,
289 aop_PQ,
290 one_over_2p,
291 1);
292
293
294
295
296 ////////////////////////////////////
297 // Accumulate contracted integrals
298 ////////////////////////////////////
299 if(lastoffset == 0)
300 {
301 contract_all(10, PRIM_INT__s_f_s_s, PRIM_PTR_INT__s_f_s_s);
302 contract_all(15, PRIM_INT__s_g_s_s, PRIM_PTR_INT__s_g_s_s);
303 }
304 else
305 {
306 contract(10, shelloffsets, PRIM_INT__s_f_s_s, PRIM_PTR_INT__s_f_s_s);
307 contract(15, shelloffsets, PRIM_INT__s_g_s_s, PRIM_PTR_INT__s_g_s_s);
308 PRIM_PTR_INT__s_f_s_s += lastoffset*10;
309 PRIM_PTR_INT__s_g_s_s += lastoffset*15;
310 }
311
312 } // close loop over j
313 } // close loop over i
314
315 //Advance to the next batch
316 jstart = SIMINT_SIMD_ROUND(jend);
317
318 //////////////////////////////////////////////
319 // Contracted integrals: Horizontal recurrance
320 //////////////////////////////////////////////
321
322
323 const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
324
325
326 for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
327 {
328
329 // set up HRR pointers
330 double const * restrict HRR_INT__s_f_s_s = INT__s_f_s_s + abcd * 10;
331 double const * restrict HRR_INT__s_g_s_s = INT__s_g_s_s + abcd * 15;
332 double * restrict HRR_INT__p_f_s_s = INT__p_f_s_s + real_abcd * 30;
333
334 // form INT__p_f_s_s
335 HRR_I_p_f(
336 HRR_INT__p_f_s_s,
337 HRR_INT__s_f_s_s,
338 HRR_INT__s_g_s_s,
339 hAB, 1);
340
341
342 } // close HRR loop
343
344
345 } // close loop cdbatch
346
347 istart = iend;
348 } // close loop over ab
349
350 return P.nshell12_clip * Q.nshell12_clip;
351 }
352
353