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