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_i_p(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_i_p)8 int ostei_s_s_i_p(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_i_p)
13 {
14
15 SIMINT_ASSUME_ALIGN_DBL(work);
16 SIMINT_ASSUME_ALIGN_DBL(INT__s_s_i_p);
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 ibra;
26
27 // partition workspace
28 double * const INT__s_s_i_s = work + (SIMINT_NSHELL_SIMD * 0);
29 double * const INT__s_s_k_s = work + (SIMINT_NSHELL_SIMD * 28);
30 SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*64);
31 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
32 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_p_s = primwork + 8;
33 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_d_s = primwork + 29;
34 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_f_s = primwork + 65;
35 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_g_s = primwork + 115;
36 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_h_s = primwork + 175;
37 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_i_s = primwork + 238;
38 SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_k_s = primwork + 294;
39 double * const hrrwork = (double *)(primwork + 330);
40
41
42 // Create constants
43 const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
44 const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
45 const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
46 const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
47 const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
48 const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
49 const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
50
51
52 ////////////////////////////////////////
53 // Loop over shells and primitives
54 ////////////////////////////////////////
55
56 real_abcd = 0;
57 istart = 0;
58 for(ab = 0; ab < P.nshell12_clip; ++ab)
59 {
60 const int iend = istart + P.nprim12[ab];
61
62 cd = 0;
63 jstart = 0;
64
65 for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
66 {
67 const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
68 int jend = jstart;
69 for(i = 0; i < nshellbatch; i++)
70 jend += Q.nprim12[cd+i];
71
72 // Clear the beginning of the workspace (where we are accumulating integrals)
73 memset(work, 0, SIMINT_NSHELL_SIMD * 64 * sizeof(double));
74 abcd = 0;
75
76
77 for(i = istart; i < iend; ++i)
78 {
79 SIMINT_DBLTYPE bra_screen_max; // only used if check_screen
80
81 if(check_screen)
82 {
83 // Skip this whole thing if always insignificant
84 if((P.screen[i] * Q.screen_max) < screen_tol)
85 continue;
86 bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
87 }
88
89 icd = 0;
90 iprimcd = 0;
91 nprim_icd = Q.nprim12[cd];
92 double * restrict PRIM_PTR_INT__s_s_i_s = INT__s_s_i_s + abcd * 28;
93 double * restrict PRIM_PTR_INT__s_s_k_s = INT__s_s_k_s + abcd * 36;
94
95
96
97 // Load these one per loop over i
98 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
99 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
100 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
101
102
103 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
104 {
105 // calculate the shell offsets
106 // these are the offset from the shell pointed to by cd
107 // for each element
108 int shelloffsets[SIMINT_SIMD_LEN] = {0};
109 int lastoffset = 0;
110 const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
111
112 if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
113 {
114 // Handle if the first element of the vector is a new shell
115 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
116 {
117 nprim_icd += Q.nprim12[cd + (++icd)];
118 PRIM_PTR_INT__s_s_i_s += 28;
119 PRIM_PTR_INT__s_s_k_s += 36;
120 }
121 iprimcd++;
122 for(n = 1; n < SIMINT_SIMD_LEN; ++n)
123 {
124 if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
125 {
126 shelloffsets[n] = shelloffsets[n-1] + 1;
127 lastoffset++;
128 nprim_icd += Q.nprim12[cd + (++icd)];
129 }
130 else
131 shelloffsets[n] = shelloffsets[n-1];
132 iprimcd++;
133 }
134 }
135 else
136 iprimcd += SIMINT_SIMD_LEN;
137
138 // Do we have to compute this vector (or has it been screened out)?
139 // (not_screened != 0 means we have to do this vector)
140 if(check_screen)
141 {
142 const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
143 if(vmax < screen_tol)
144 {
145 PRIM_PTR_INT__s_s_i_s += lastoffset*28;
146 PRIM_PTR_INT__s_s_k_s += lastoffset*36;
147 continue;
148 }
149 }
150
151 const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
152 const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
153 const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
154 const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
155
156
157 /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
158 SIMINT_DBLTYPE PQ[3];
159 PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
160 PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
161 PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
162 SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
163 R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
164 R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
165
166 const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
167 const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
168 const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
169 const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
170 const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
171 const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
172 const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
173
174 SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
175 SIMINT_DBLTYPE aoq_PQ[3];
176 aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
177 aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
178 aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
179 // Put a minus sign here so we don't have to in RR routines
180 a_over_q = SIMINT_NEG(a_over_q);
181
182
183 //////////////////////////////////////////////
184 // Fjt function section
185 // Maximum v value: 7
186 //////////////////////////////////////////////
187 // The parameter to the Fjt function
188 const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
189
190
191 const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
192
193
194 boys_F_split(PRIM_INT__s_s_s_s, F_x, 7);
195 SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
196 prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
197 for(n = 0; n <= 7; n++)
198 PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
199
200 //////////////////////////////////////////////
201 // Primitive integrals: Vertical recurrance
202 //////////////////////////////////////////////
203
204 const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
205 const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
206 const SIMINT_DBLTYPE vrr_const_3_over_2q = SIMINT_MUL(const_3, one_over_2q);
207 const SIMINT_DBLTYPE vrr_const_4_over_2q = SIMINT_MUL(const_4, one_over_2q);
208 const SIMINT_DBLTYPE vrr_const_5_over_2q = SIMINT_MUL(const_5, one_over_2q);
209 const SIMINT_DBLTYPE vrr_const_6_over_2q = SIMINT_MUL(const_6, one_over_2q);
210
211
212
213 // Forming PRIM_INT__s_s_p_s[7 * 3];
214 for(n = 0; n < 7; ++n) // loop over orders of auxiliary function
215 {
216
217 PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
218 PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]);
219
220 PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
221 PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 1]);
222
223 PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
224 PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 2]);
225
226 }
227
228
229
230 // Forming PRIM_INT__s_s_d_s[6 * 6];
231 for(n = 0; n < 6; ++n) // loop over orders of auxiliary function
232 {
233
234 PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
235 PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 0]);
236 PRIM_INT__s_s_d_s[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_d_s[n * 6 + 0]);
237
238 PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
239 PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 3]);
240 PRIM_INT__s_s_d_s[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_d_s[n * 6 + 3]);
241
242 PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
243 PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_d_s[n * 6 + 5]);
244 PRIM_INT__s_s_d_s[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_d_s[n * 6 + 5]);
245
246 }
247
248
249
250 // Forming PRIM_INT__s_s_f_s[5 * 10];
251 for(n = 0; n < 5; ++n) // loop over orders of auxiliary function
252 {
253
254 PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
255 PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 0]);
256 PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]), PRIM_INT__s_s_f_s[n * 10 + 0]);
257
258 PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
259 PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 1]);
260
261 PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
262 PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 6]);
263 PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_p_s[n * 3 + 1]), PRIM_INT__s_s_f_s[n * 10 + 6]);
264
265 PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
266 PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 9]);
267 PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_p_s[n * 3 + 2]), PRIM_INT__s_s_f_s[n * 10 + 9]);
268
269 }
270
271
272 VRR_K_s_s_g_s(
273 PRIM_INT__s_s_g_s,
274 PRIM_INT__s_s_f_s,
275 PRIM_INT__s_s_d_s,
276 Q_PA,
277 a_over_q,
278 aoq_PQ,
279 one_over_2q,
280 4);
281
282
283 VRR_K_s_s_h_s(
284 PRIM_INT__s_s_h_s,
285 PRIM_INT__s_s_g_s,
286 PRIM_INT__s_s_f_s,
287 Q_PA,
288 a_over_q,
289 aoq_PQ,
290 one_over_2q,
291 3);
292
293
294 ostei_general_vrr1_K(6, 2,
295 one_over_2q, a_over_q, aoq_PQ, Q_PA,
296 PRIM_INT__s_s_h_s, PRIM_INT__s_s_g_s, PRIM_INT__s_s_i_s);
297
298
299 ostei_general_vrr1_K(7, 1,
300 one_over_2q, a_over_q, aoq_PQ, Q_PA,
301 PRIM_INT__s_s_i_s, PRIM_INT__s_s_h_s, PRIM_INT__s_s_k_s);
302
303
304
305
306 ////////////////////////////////////
307 // Accumulate contracted integrals
308 ////////////////////////////////////
309 if(lastoffset == 0)
310 {
311 contract_all(28, PRIM_INT__s_s_i_s, PRIM_PTR_INT__s_s_i_s);
312 contract_all(36, PRIM_INT__s_s_k_s, PRIM_PTR_INT__s_s_k_s);
313 }
314 else
315 {
316 contract(28, shelloffsets, PRIM_INT__s_s_i_s, PRIM_PTR_INT__s_s_i_s);
317 contract(36, shelloffsets, PRIM_INT__s_s_k_s, PRIM_PTR_INT__s_s_k_s);
318 PRIM_PTR_INT__s_s_i_s += lastoffset*28;
319 PRIM_PTR_INT__s_s_k_s += lastoffset*36;
320 }
321
322 } // close loop over j
323 } // close loop over i
324
325 //Advance to the next batch
326 jstart = SIMINT_SIMD_ROUND(jend);
327
328 //////////////////////////////////////////////
329 // Contracted integrals: Horizontal recurrance
330 //////////////////////////////////////////////
331
332
333
334
335 for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
336 {
337 const double hCD[3] = { Q.AB_x[cd+abcd], Q.AB_y[cd+abcd], Q.AB_z[cd+abcd] };
338
339 // set up HRR pointers
340 double const * restrict HRR_INT__s_s_i_s = INT__s_s_i_s + abcd * 28;
341 double const * restrict HRR_INT__s_s_k_s = INT__s_s_k_s + abcd * 36;
342 double * restrict HRR_INT__s_s_i_p = INT__s_s_i_p + real_abcd * 84;
343
344 // form INT__s_s_i_p
345 ostei_general_hrr_L(0, 0, 6, 1, hCD, HRR_INT__s_s_k_s, HRR_INT__s_s_i_s, HRR_INT__s_s_i_p);
346
347
348 } // close HRR loop
349
350
351 } // close loop cdbatch
352
353 istart = iend;
354 } // close loop over ab
355
356 return P.nshell12_clip * Q.nshell12_clip;
357 }
358
ostei_s_s_p_i(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_p_i)359 int ostei_s_s_p_i(struct simint_multi_shellpair const P,
360 struct simint_multi_shellpair const Q,
361 double screen_tol,
362 double * const restrict work,
363 double * const restrict INT__s_s_p_i)
364 {
365 double Q_AB[3*Q.nshell12];
366 struct simint_multi_shellpair Q_tmp = Q;
367 Q_tmp.PA_x = Q.PB_x; Q_tmp.PA_y = Q.PB_y; Q_tmp.PA_z = Q.PB_z;
368 Q_tmp.PB_x = Q.PA_x; Q_tmp.PB_y = Q.PA_y; Q_tmp.PB_z = Q.PA_z;
369 Q_tmp.AB_x = Q_AB;
370 Q_tmp.AB_y = Q_AB + Q.nshell12;
371 Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
372
373 for(int i = 0; i < Q.nshell12; i++)
374 {
375 Q_tmp.AB_x[i] = -Q.AB_x[i];
376 Q_tmp.AB_y[i] = -Q.AB_y[i];
377 Q_tmp.AB_z[i] = -Q.AB_z[i];
378 }
379
380 int ret = ostei_s_s_i_p(P, Q_tmp, screen_tol, work, INT__s_s_p_i);
381 double buffer[84] SIMINT_ALIGN_ARRAY_DBL;
382
383 for(int q = 0; q < ret; q++)
384 {
385 int idx = 0;
386 for(int a = 0; a < 1; ++a)
387 for(int b = 0; b < 1; ++b)
388 for(int c = 0; c < 3; ++c)
389 for(int d = 0; d < 28; ++d)
390 buffer[idx++] = INT__s_s_p_i[q*84+a*84+b*84+d*3+c];
391
392 memcpy(INT__s_s_p_i+q*84, buffer, 84*sizeof(double));
393 }
394
395 return ret;
396 }
397
398