2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/math/vec.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_avx_128_fma_double
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: None
56 * Geometry: Water4-Water4
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_avx_128_fma_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88 int vdwjidx1A,vdwjidx1B;
89 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
90 int vdwjidx2A,vdwjidx2B;
91 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
92 int vdwjidx3A,vdwjidx3B;
93 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
94 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
95 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
96 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
97 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
98 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
99 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
100 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
101 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
102 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
103 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
105 __m128d dummy_mask,cutoff_mask;
106 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
107 __m128d one = _mm_set1_pd(1.0);
108 __m128d two = _mm_set1_pd(2.0);
114 jindex = nlist->jindex;
116 shiftidx = nlist->shift;
118 shiftvec = fr->shift_vec[0];
119 fshift = fr->fshift[0];
120 facel = _mm_set1_pd(fr->epsfac);
121 charge = mdatoms->chargeA;
122 krf = _mm_set1_pd(fr->ic->k_rf);
123 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
124 crf = _mm_set1_pd(fr->ic->c_rf);
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
129 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
130 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
132 jq1 = _mm_set1_pd(charge[inr+1]);
133 jq2 = _mm_set1_pd(charge[inr+2]);
134 jq3 = _mm_set1_pd(charge[inr+3]);
135 qq11 = _mm_mul_pd(iq1,jq1);
136 qq12 = _mm_mul_pd(iq1,jq2);
137 qq13 = _mm_mul_pd(iq1,jq3);
138 qq21 = _mm_mul_pd(iq2,jq1);
139 qq22 = _mm_mul_pd(iq2,jq2);
140 qq23 = _mm_mul_pd(iq2,jq3);
141 qq31 = _mm_mul_pd(iq3,jq1);
142 qq32 = _mm_mul_pd(iq3,jq2);
143 qq33 = _mm_mul_pd(iq3,jq3);
145 /* Avoid stupid compiler warnings */
153 /* Start outer loop over neighborlists */
154 for(iidx=0; iidx<nri; iidx++)
156 /* Load shift vector for this list */
157 i_shift_offset = DIM*shiftidx[iidx];
159 /* Load limits for loop over neighbors */
160 j_index_start = jindex[iidx];
161 j_index_end = jindex[iidx+1];
163 /* Get outer coordinate index */
165 i_coord_offset = DIM*inr;
167 /* Load i particle coords and add shift vector */
168 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
169 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
171 fix1 = _mm_setzero_pd();
172 fiy1 = _mm_setzero_pd();
173 fiz1 = _mm_setzero_pd();
174 fix2 = _mm_setzero_pd();
175 fiy2 = _mm_setzero_pd();
176 fiz2 = _mm_setzero_pd();
177 fix3 = _mm_setzero_pd();
178 fiy3 = _mm_setzero_pd();
179 fiz3 = _mm_setzero_pd();
181 /* Reset potential sums */
182 velecsum = _mm_setzero_pd();
184 /* Start inner kernel loop */
185 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
188 /* Get j neighbor index, and coordinate index */
191 j_coord_offsetA = DIM*jnrA;
192 j_coord_offsetB = DIM*jnrB;
194 /* load j atom coordinates */
195 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
196 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
198 /* Calculate displacement vector */
199 dx11 = _mm_sub_pd(ix1,jx1);
200 dy11 = _mm_sub_pd(iy1,jy1);
201 dz11 = _mm_sub_pd(iz1,jz1);
202 dx12 = _mm_sub_pd(ix1,jx2);
203 dy12 = _mm_sub_pd(iy1,jy2);
204 dz12 = _mm_sub_pd(iz1,jz2);
205 dx13 = _mm_sub_pd(ix1,jx3);
206 dy13 = _mm_sub_pd(iy1,jy3);
207 dz13 = _mm_sub_pd(iz1,jz3);
208 dx21 = _mm_sub_pd(ix2,jx1);
209 dy21 = _mm_sub_pd(iy2,jy1);
210 dz21 = _mm_sub_pd(iz2,jz1);
211 dx22 = _mm_sub_pd(ix2,jx2);
212 dy22 = _mm_sub_pd(iy2,jy2);
213 dz22 = _mm_sub_pd(iz2,jz2);
214 dx23 = _mm_sub_pd(ix2,jx3);
215 dy23 = _mm_sub_pd(iy2,jy3);
216 dz23 = _mm_sub_pd(iz2,jz3);
217 dx31 = _mm_sub_pd(ix3,jx1);
218 dy31 = _mm_sub_pd(iy3,jy1);
219 dz31 = _mm_sub_pd(iz3,jz1);
220 dx32 = _mm_sub_pd(ix3,jx2);
221 dy32 = _mm_sub_pd(iy3,jy2);
222 dz32 = _mm_sub_pd(iz3,jz2);
223 dx33 = _mm_sub_pd(ix3,jx3);
224 dy33 = _mm_sub_pd(iy3,jy3);
225 dz33 = _mm_sub_pd(iz3,jz3);
227 /* Calculate squared distance and things based on it */
228 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
229 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
230 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
231 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
232 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
233 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
234 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
235 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
236 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
238 rinv11 = gmx_mm_invsqrt_pd(rsq11);
239 rinv12 = gmx_mm_invsqrt_pd(rsq12);
240 rinv13 = gmx_mm_invsqrt_pd(rsq13);
241 rinv21 = gmx_mm_invsqrt_pd(rsq21);
242 rinv22 = gmx_mm_invsqrt_pd(rsq22);
243 rinv23 = gmx_mm_invsqrt_pd(rsq23);
244 rinv31 = gmx_mm_invsqrt_pd(rsq31);
245 rinv32 = gmx_mm_invsqrt_pd(rsq32);
246 rinv33 = gmx_mm_invsqrt_pd(rsq33);
248 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
249 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
250 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
251 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
252 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
253 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
254 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
255 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
256 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
258 fjx1 = _mm_setzero_pd();
259 fjy1 = _mm_setzero_pd();
260 fjz1 = _mm_setzero_pd();
261 fjx2 = _mm_setzero_pd();
262 fjy2 = _mm_setzero_pd();
263 fjz2 = _mm_setzero_pd();
264 fjx3 = _mm_setzero_pd();
265 fjy3 = _mm_setzero_pd();
266 fjz3 = _mm_setzero_pd();
268 /**************************
269 * CALCULATE INTERACTIONS *
270 **************************/
272 /* REACTION-FIELD ELECTROSTATICS */
273 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
274 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
276 /* Update potential sum for this i atom from the interaction with this j atom. */
277 velecsum = _mm_add_pd(velecsum,velec);
281 /* Update vectorial force */
282 fix1 = _mm_macc_pd(dx11,fscal,fix1);
283 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
284 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
286 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
287 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
288 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
290 /**************************
291 * CALCULATE INTERACTIONS *
292 **************************/
294 /* REACTION-FIELD ELECTROSTATICS */
295 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
296 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
298 /* Update potential sum for this i atom from the interaction with this j atom. */
299 velecsum = _mm_add_pd(velecsum,velec);
303 /* Update vectorial force */
304 fix1 = _mm_macc_pd(dx12,fscal,fix1);
305 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
306 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
308 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
309 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
310 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
316 /* REACTION-FIELD ELECTROSTATICS */
317 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
318 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
320 /* Update potential sum for this i atom from the interaction with this j atom. */
321 velecsum = _mm_add_pd(velecsum,velec);
325 /* Update vectorial force */
326 fix1 = _mm_macc_pd(dx13,fscal,fix1);
327 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
328 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
330 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
331 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
332 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
340 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
342 /* Update potential sum for this i atom from the interaction with this j atom. */
343 velecsum = _mm_add_pd(velecsum,velec);
347 /* Update vectorial force */
348 fix2 = _mm_macc_pd(dx21,fscal,fix2);
349 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
350 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
352 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
353 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
354 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
362 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
364 /* Update potential sum for this i atom from the interaction with this j atom. */
365 velecsum = _mm_add_pd(velecsum,velec);
369 /* Update vectorial force */
370 fix2 = _mm_macc_pd(dx22,fscal,fix2);
371 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
372 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
374 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
375 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
376 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
378 /**************************
379 * CALCULATE INTERACTIONS *
380 **************************/
382 /* REACTION-FIELD ELECTROSTATICS */
383 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
384 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
386 /* Update potential sum for this i atom from the interaction with this j atom. */
387 velecsum = _mm_add_pd(velecsum,velec);
391 /* Update vectorial force */
392 fix2 = _mm_macc_pd(dx23,fscal,fix2);
393 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
394 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
396 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
397 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
398 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 /* REACTION-FIELD ELECTROSTATICS */
405 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
406 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
408 /* Update potential sum for this i atom from the interaction with this j atom. */
409 velecsum = _mm_add_pd(velecsum,velec);
413 /* Update vectorial force */
414 fix3 = _mm_macc_pd(dx31,fscal,fix3);
415 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
416 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
418 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
419 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
420 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
422 /**************************
423 * CALCULATE INTERACTIONS *
424 **************************/
426 /* REACTION-FIELD ELECTROSTATICS */
427 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
428 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
430 /* Update potential sum for this i atom from the interaction with this j atom. */
431 velecsum = _mm_add_pd(velecsum,velec);
435 /* Update vectorial force */
436 fix3 = _mm_macc_pd(dx32,fscal,fix3);
437 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
438 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
440 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
441 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
442 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
444 /**************************
445 * CALCULATE INTERACTIONS *
446 **************************/
448 /* REACTION-FIELD ELECTROSTATICS */
449 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
450 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
452 /* Update potential sum for this i atom from the interaction with this j atom. */
453 velecsum = _mm_add_pd(velecsum,velec);
457 /* Update vectorial force */
458 fix3 = _mm_macc_pd(dx33,fscal,fix3);
459 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
460 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
462 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
463 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
464 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
466 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
468 /* Inner loop uses 315 flops */
475 j_coord_offsetA = DIM*jnrA;
477 /* load j atom coordinates */
478 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA+DIM,
479 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
481 /* Calculate displacement vector */
482 dx11 = _mm_sub_pd(ix1,jx1);
483 dy11 = _mm_sub_pd(iy1,jy1);
484 dz11 = _mm_sub_pd(iz1,jz1);
485 dx12 = _mm_sub_pd(ix1,jx2);
486 dy12 = _mm_sub_pd(iy1,jy2);
487 dz12 = _mm_sub_pd(iz1,jz2);
488 dx13 = _mm_sub_pd(ix1,jx3);
489 dy13 = _mm_sub_pd(iy1,jy3);
490 dz13 = _mm_sub_pd(iz1,jz3);
491 dx21 = _mm_sub_pd(ix2,jx1);
492 dy21 = _mm_sub_pd(iy2,jy1);
493 dz21 = _mm_sub_pd(iz2,jz1);
494 dx22 = _mm_sub_pd(ix2,jx2);
495 dy22 = _mm_sub_pd(iy2,jy2);
496 dz22 = _mm_sub_pd(iz2,jz2);
497 dx23 = _mm_sub_pd(ix2,jx3);
498 dy23 = _mm_sub_pd(iy2,jy3);
499 dz23 = _mm_sub_pd(iz2,jz3);
500 dx31 = _mm_sub_pd(ix3,jx1);
501 dy31 = _mm_sub_pd(iy3,jy1);
502 dz31 = _mm_sub_pd(iz3,jz1);
503 dx32 = _mm_sub_pd(ix3,jx2);
504 dy32 = _mm_sub_pd(iy3,jy2);
505 dz32 = _mm_sub_pd(iz3,jz2);
506 dx33 = _mm_sub_pd(ix3,jx3);
507 dy33 = _mm_sub_pd(iy3,jy3);
508 dz33 = _mm_sub_pd(iz3,jz3);
510 /* Calculate squared distance and things based on it */
511 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
512 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
513 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
514 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
515 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
516 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
517 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
518 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
519 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
521 rinv11 = gmx_mm_invsqrt_pd(rsq11);
522 rinv12 = gmx_mm_invsqrt_pd(rsq12);
523 rinv13 = gmx_mm_invsqrt_pd(rsq13);
524 rinv21 = gmx_mm_invsqrt_pd(rsq21);
525 rinv22 = gmx_mm_invsqrt_pd(rsq22);
526 rinv23 = gmx_mm_invsqrt_pd(rsq23);
527 rinv31 = gmx_mm_invsqrt_pd(rsq31);
528 rinv32 = gmx_mm_invsqrt_pd(rsq32);
529 rinv33 = gmx_mm_invsqrt_pd(rsq33);
531 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
532 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
533 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
534 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
535 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
536 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
537 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
538 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
539 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
541 fjx1 = _mm_setzero_pd();
542 fjy1 = _mm_setzero_pd();
543 fjz1 = _mm_setzero_pd();
544 fjx2 = _mm_setzero_pd();
545 fjy2 = _mm_setzero_pd();
546 fjz2 = _mm_setzero_pd();
547 fjx3 = _mm_setzero_pd();
548 fjy3 = _mm_setzero_pd();
549 fjz3 = _mm_setzero_pd();
551 /**************************
552 * CALCULATE INTERACTIONS *
553 **************************/
555 /* REACTION-FIELD ELECTROSTATICS */
556 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
557 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
559 /* Update potential sum for this i atom from the interaction with this j atom. */
560 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
561 velecsum = _mm_add_pd(velecsum,velec);
565 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
567 /* Update vectorial force */
568 fix1 = _mm_macc_pd(dx11,fscal,fix1);
569 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
570 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
572 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
573 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
574 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
580 /* REACTION-FIELD ELECTROSTATICS */
581 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
582 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
584 /* Update potential sum for this i atom from the interaction with this j atom. */
585 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
586 velecsum = _mm_add_pd(velecsum,velec);
590 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
592 /* Update vectorial force */
593 fix1 = _mm_macc_pd(dx12,fscal,fix1);
594 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
595 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
597 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
598 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
599 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
605 /* REACTION-FIELD ELECTROSTATICS */
606 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
607 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
609 /* Update potential sum for this i atom from the interaction with this j atom. */
610 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
611 velecsum = _mm_add_pd(velecsum,velec);
615 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
617 /* Update vectorial force */
618 fix1 = _mm_macc_pd(dx13,fscal,fix1);
619 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
620 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
622 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
623 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
624 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
626 /**************************
627 * CALCULATE INTERACTIONS *
628 **************************/
630 /* REACTION-FIELD ELECTROSTATICS */
631 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
632 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
634 /* Update potential sum for this i atom from the interaction with this j atom. */
635 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
636 velecsum = _mm_add_pd(velecsum,velec);
640 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
642 /* Update vectorial force */
643 fix2 = _mm_macc_pd(dx21,fscal,fix2);
644 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
645 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
647 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
648 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
649 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
651 /**************************
652 * CALCULATE INTERACTIONS *
653 **************************/
655 /* REACTION-FIELD ELECTROSTATICS */
656 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
657 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
659 /* Update potential sum for this i atom from the interaction with this j atom. */
660 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
661 velecsum = _mm_add_pd(velecsum,velec);
665 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
667 /* Update vectorial force */
668 fix2 = _mm_macc_pd(dx22,fscal,fix2);
669 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
670 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
672 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
673 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
674 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
676 /**************************
677 * CALCULATE INTERACTIONS *
678 **************************/
680 /* REACTION-FIELD ELECTROSTATICS */
681 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
682 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
684 /* Update potential sum for this i atom from the interaction with this j atom. */
685 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
686 velecsum = _mm_add_pd(velecsum,velec);
690 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
692 /* Update vectorial force */
693 fix2 = _mm_macc_pd(dx23,fscal,fix2);
694 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
695 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
697 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
698 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
699 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
701 /**************************
702 * CALCULATE INTERACTIONS *
703 **************************/
705 /* REACTION-FIELD ELECTROSTATICS */
706 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
707 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
709 /* Update potential sum for this i atom from the interaction with this j atom. */
710 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
711 velecsum = _mm_add_pd(velecsum,velec);
715 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
717 /* Update vectorial force */
718 fix3 = _mm_macc_pd(dx31,fscal,fix3);
719 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
720 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
722 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
723 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
724 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
726 /**************************
727 * CALCULATE INTERACTIONS *
728 **************************/
730 /* REACTION-FIELD ELECTROSTATICS */
731 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
732 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
734 /* Update potential sum for this i atom from the interaction with this j atom. */
735 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
736 velecsum = _mm_add_pd(velecsum,velec);
740 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
742 /* Update vectorial force */
743 fix3 = _mm_macc_pd(dx32,fscal,fix3);
744 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
745 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
747 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
748 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
749 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 /* REACTION-FIELD ELECTROSTATICS */
756 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
757 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
759 /* Update potential sum for this i atom from the interaction with this j atom. */
760 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
761 velecsum = _mm_add_pd(velecsum,velec);
765 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
767 /* Update vectorial force */
768 fix3 = _mm_macc_pd(dx33,fscal,fix3);
769 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
770 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
772 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
773 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
774 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
776 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
778 /* Inner loop uses 315 flops */
781 /* End of innermost loop */
783 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
784 f+i_coord_offset+DIM,fshift+i_shift_offset);
787 /* Update potential energies */
788 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
790 /* Increment number of inner iterations */
791 inneriter += j_index_end - j_index_start;
793 /* Outer loop uses 19 flops */
796 /* Increment number of outer iterations */
799 /* Update outer/inner flops */
801 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*19 + inneriter*315);
804 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
805 * Electrostatics interaction: ReactionField
806 * VdW interaction: None
807 * Geometry: Water4-Water4
808 * Calculate force/pot: Force
811 nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
812 (t_nblist * gmx_restrict nlist,
813 rvec * gmx_restrict xx,
814 rvec * gmx_restrict ff,
815 t_forcerec * gmx_restrict fr,
816 t_mdatoms * gmx_restrict mdatoms,
817 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
818 t_nrnb * gmx_restrict nrnb)
820 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
821 * just 0 for non-waters.
822 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
823 * jnr indices corresponding to data put in the four positions in the SIMD register.
825 int i_shift_offset,i_coord_offset,outeriter,inneriter;
826 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
828 int j_coord_offsetA,j_coord_offsetB;
829 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
831 real *shiftvec,*fshift,*x,*f;
832 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
834 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
836 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
838 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
839 int vdwjidx1A,vdwjidx1B;
840 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
841 int vdwjidx2A,vdwjidx2B;
842 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
843 int vdwjidx3A,vdwjidx3B;
844 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
845 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
846 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
847 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
848 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
849 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
850 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
851 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
852 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
853 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
854 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
856 __m128d dummy_mask,cutoff_mask;
857 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
858 __m128d one = _mm_set1_pd(1.0);
859 __m128d two = _mm_set1_pd(2.0);
865 jindex = nlist->jindex;
867 shiftidx = nlist->shift;
869 shiftvec = fr->shift_vec[0];
870 fshift = fr->fshift[0];
871 facel = _mm_set1_pd(fr->epsfac);
872 charge = mdatoms->chargeA;
873 krf = _mm_set1_pd(fr->ic->k_rf);
874 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
875 crf = _mm_set1_pd(fr->ic->c_rf);
877 /* Setup water-specific parameters */
878 inr = nlist->iinr[0];
879 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
880 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
881 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
883 jq1 = _mm_set1_pd(charge[inr+1]);
884 jq2 = _mm_set1_pd(charge[inr+2]);
885 jq3 = _mm_set1_pd(charge[inr+3]);
886 qq11 = _mm_mul_pd(iq1,jq1);
887 qq12 = _mm_mul_pd(iq1,jq2);
888 qq13 = _mm_mul_pd(iq1,jq3);
889 qq21 = _mm_mul_pd(iq2,jq1);
890 qq22 = _mm_mul_pd(iq2,jq2);
891 qq23 = _mm_mul_pd(iq2,jq3);
892 qq31 = _mm_mul_pd(iq3,jq1);
893 qq32 = _mm_mul_pd(iq3,jq2);
894 qq33 = _mm_mul_pd(iq3,jq3);
896 /* Avoid stupid compiler warnings */
904 /* Start outer loop over neighborlists */
905 for(iidx=0; iidx<nri; iidx++)
907 /* Load shift vector for this list */
908 i_shift_offset = DIM*shiftidx[iidx];
910 /* Load limits for loop over neighbors */
911 j_index_start = jindex[iidx];
912 j_index_end = jindex[iidx+1];
914 /* Get outer coordinate index */
916 i_coord_offset = DIM*inr;
918 /* Load i particle coords and add shift vector */
919 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
920 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
922 fix1 = _mm_setzero_pd();
923 fiy1 = _mm_setzero_pd();
924 fiz1 = _mm_setzero_pd();
925 fix2 = _mm_setzero_pd();
926 fiy2 = _mm_setzero_pd();
927 fiz2 = _mm_setzero_pd();
928 fix3 = _mm_setzero_pd();
929 fiy3 = _mm_setzero_pd();
930 fiz3 = _mm_setzero_pd();
932 /* Start inner kernel loop */
933 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
936 /* Get j neighbor index, and coordinate index */
939 j_coord_offsetA = DIM*jnrA;
940 j_coord_offsetB = DIM*jnrB;
942 /* load j atom coordinates */
943 gmx_mm_load_3rvec_2ptr_swizzle_pd(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
944 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
946 /* Calculate displacement vector */
947 dx11 = _mm_sub_pd(ix1,jx1);
948 dy11 = _mm_sub_pd(iy1,jy1);
949 dz11 = _mm_sub_pd(iz1,jz1);
950 dx12 = _mm_sub_pd(ix1,jx2);
951 dy12 = _mm_sub_pd(iy1,jy2);
952 dz12 = _mm_sub_pd(iz1,jz2);
953 dx13 = _mm_sub_pd(ix1,jx3);
954 dy13 = _mm_sub_pd(iy1,jy3);
955 dz13 = _mm_sub_pd(iz1,jz3);
956 dx21 = _mm_sub_pd(ix2,jx1);
957 dy21 = _mm_sub_pd(iy2,jy1);
958 dz21 = _mm_sub_pd(iz2,jz1);
959 dx22 = _mm_sub_pd(ix2,jx2);
960 dy22 = _mm_sub_pd(iy2,jy2);
961 dz22 = _mm_sub_pd(iz2,jz2);
962 dx23 = _mm_sub_pd(ix2,jx3);
963 dy23 = _mm_sub_pd(iy2,jy3);
964 dz23 = _mm_sub_pd(iz2,jz3);
965 dx31 = _mm_sub_pd(ix3,jx1);
966 dy31 = _mm_sub_pd(iy3,jy1);
967 dz31 = _mm_sub_pd(iz3,jz1);
968 dx32 = _mm_sub_pd(ix3,jx2);
969 dy32 = _mm_sub_pd(iy3,jy2);
970 dz32 = _mm_sub_pd(iz3,jz2);
971 dx33 = _mm_sub_pd(ix3,jx3);
972 dy33 = _mm_sub_pd(iy3,jy3);
973 dz33 = _mm_sub_pd(iz3,jz3);
975 /* Calculate squared distance and things based on it */
976 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
977 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
978 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
979 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
980 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
981 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
982 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
983 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
984 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
986 rinv11 = gmx_mm_invsqrt_pd(rsq11);
987 rinv12 = gmx_mm_invsqrt_pd(rsq12);
988 rinv13 = gmx_mm_invsqrt_pd(rsq13);
989 rinv21 = gmx_mm_invsqrt_pd(rsq21);
990 rinv22 = gmx_mm_invsqrt_pd(rsq22);
991 rinv23 = gmx_mm_invsqrt_pd(rsq23);
992 rinv31 = gmx_mm_invsqrt_pd(rsq31);
993 rinv32 = gmx_mm_invsqrt_pd(rsq32);
994 rinv33 = gmx_mm_invsqrt_pd(rsq33);
996 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
997 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
998 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
999 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1000 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1001 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1002 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1003 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1004 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1006 fjx1 = _mm_setzero_pd();
1007 fjy1 = _mm_setzero_pd();
1008 fjz1 = _mm_setzero_pd();
1009 fjx2 = _mm_setzero_pd();
1010 fjy2 = _mm_setzero_pd();
1011 fjz2 = _mm_setzero_pd();
1012 fjx3 = _mm_setzero_pd();
1013 fjy3 = _mm_setzero_pd();
1014 fjz3 = _mm_setzero_pd();
1016 /**************************
1017 * CALCULATE INTERACTIONS *
1018 **************************/
1020 /* REACTION-FIELD ELECTROSTATICS */
1021 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1025 /* Update vectorial force */
1026 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1027 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1028 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1030 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1031 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1032 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1034 /**************************
1035 * CALCULATE INTERACTIONS *
1036 **************************/
1038 /* REACTION-FIELD ELECTROSTATICS */
1039 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1043 /* Update vectorial force */
1044 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1045 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1046 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1048 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1049 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1050 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1052 /**************************
1053 * CALCULATE INTERACTIONS *
1054 **************************/
1056 /* REACTION-FIELD ELECTROSTATICS */
1057 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1061 /* Update vectorial force */
1062 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1063 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1064 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1066 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1067 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1068 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1074 /* REACTION-FIELD ELECTROSTATICS */
1075 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1079 /* Update vectorial force */
1080 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1081 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1082 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1084 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1085 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1086 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1088 /**************************
1089 * CALCULATE INTERACTIONS *
1090 **************************/
1092 /* REACTION-FIELD ELECTROSTATICS */
1093 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1097 /* Update vectorial force */
1098 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1099 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1100 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1102 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1103 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1104 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1106 /**************************
1107 * CALCULATE INTERACTIONS *
1108 **************************/
1110 /* REACTION-FIELD ELECTROSTATICS */
1111 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1115 /* Update vectorial force */
1116 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1117 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1118 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1120 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1121 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1122 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1124 /**************************
1125 * CALCULATE INTERACTIONS *
1126 **************************/
1128 /* REACTION-FIELD ELECTROSTATICS */
1129 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1133 /* Update vectorial force */
1134 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1135 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1136 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1138 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1139 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1140 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1146 /* REACTION-FIELD ELECTROSTATICS */
1147 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1151 /* Update vectorial force */
1152 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1153 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1154 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1156 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1157 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1158 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1160 /**************************
1161 * CALCULATE INTERACTIONS *
1162 **************************/
1164 /* REACTION-FIELD ELECTROSTATICS */
1165 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1169 /* Update vectorial force */
1170 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1171 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1172 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1174 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1175 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1176 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1178 gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1180 /* Inner loop uses 270 flops */
1183 if(jidx<j_index_end)
1187 j_coord_offsetA = DIM*jnrA;
1189 /* load j atom coordinates */
1190 gmx_mm_load_3rvec_1ptr_swizzle_pd(x+j_coord_offsetA+DIM,
1191 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1193 /* Calculate displacement vector */
1194 dx11 = _mm_sub_pd(ix1,jx1);
1195 dy11 = _mm_sub_pd(iy1,jy1);
1196 dz11 = _mm_sub_pd(iz1,jz1);
1197 dx12 = _mm_sub_pd(ix1,jx2);
1198 dy12 = _mm_sub_pd(iy1,jy2);
1199 dz12 = _mm_sub_pd(iz1,jz2);
1200 dx13 = _mm_sub_pd(ix1,jx3);
1201 dy13 = _mm_sub_pd(iy1,jy3);
1202 dz13 = _mm_sub_pd(iz1,jz3);
1203 dx21 = _mm_sub_pd(ix2,jx1);
1204 dy21 = _mm_sub_pd(iy2,jy1);
1205 dz21 = _mm_sub_pd(iz2,jz1);
1206 dx22 = _mm_sub_pd(ix2,jx2);
1207 dy22 = _mm_sub_pd(iy2,jy2);
1208 dz22 = _mm_sub_pd(iz2,jz2);
1209 dx23 = _mm_sub_pd(ix2,jx3);
1210 dy23 = _mm_sub_pd(iy2,jy3);
1211 dz23 = _mm_sub_pd(iz2,jz3);
1212 dx31 = _mm_sub_pd(ix3,jx1);
1213 dy31 = _mm_sub_pd(iy3,jy1);
1214 dz31 = _mm_sub_pd(iz3,jz1);
1215 dx32 = _mm_sub_pd(ix3,jx2);
1216 dy32 = _mm_sub_pd(iy3,jy2);
1217 dz32 = _mm_sub_pd(iz3,jz2);
1218 dx33 = _mm_sub_pd(ix3,jx3);
1219 dy33 = _mm_sub_pd(iy3,jy3);
1220 dz33 = _mm_sub_pd(iz3,jz3);
1222 /* Calculate squared distance and things based on it */
1223 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1224 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1225 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1226 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1227 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1228 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1229 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1230 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1231 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1233 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1234 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1235 rinv13 = gmx_mm_invsqrt_pd(rsq13);
1236 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1237 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1238 rinv23 = gmx_mm_invsqrt_pd(rsq23);
1239 rinv31 = gmx_mm_invsqrt_pd(rsq31);
1240 rinv32 = gmx_mm_invsqrt_pd(rsq32);
1241 rinv33 = gmx_mm_invsqrt_pd(rsq33);
1243 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1244 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1245 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
1246 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1247 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1248 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1249 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1250 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1251 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1253 fjx1 = _mm_setzero_pd();
1254 fjy1 = _mm_setzero_pd();
1255 fjz1 = _mm_setzero_pd();
1256 fjx2 = _mm_setzero_pd();
1257 fjy2 = _mm_setzero_pd();
1258 fjz2 = _mm_setzero_pd();
1259 fjx3 = _mm_setzero_pd();
1260 fjy3 = _mm_setzero_pd();
1261 fjz3 = _mm_setzero_pd();
1263 /**************************
1264 * CALCULATE INTERACTIONS *
1265 **************************/
1267 /* REACTION-FIELD ELECTROSTATICS */
1268 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1272 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1274 /* Update vectorial force */
1275 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1276 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1277 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1279 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1280 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1281 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1283 /**************************
1284 * CALCULATE INTERACTIONS *
1285 **************************/
1287 /* REACTION-FIELD ELECTROSTATICS */
1288 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1292 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1294 /* Update vectorial force */
1295 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1296 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1297 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1299 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1300 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1301 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1303 /**************************
1304 * CALCULATE INTERACTIONS *
1305 **************************/
1307 /* REACTION-FIELD ELECTROSTATICS */
1308 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1312 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1314 /* Update vectorial force */
1315 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1316 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1317 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1319 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1320 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1321 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1323 /**************************
1324 * CALCULATE INTERACTIONS *
1325 **************************/
1327 /* REACTION-FIELD ELECTROSTATICS */
1328 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1332 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1334 /* Update vectorial force */
1335 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1336 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1337 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1339 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1340 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1341 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1343 /**************************
1344 * CALCULATE INTERACTIONS *
1345 **************************/
1347 /* REACTION-FIELD ELECTROSTATICS */
1348 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1352 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1354 /* Update vectorial force */
1355 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1356 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1357 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1359 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1360 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1361 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1363 /**************************
1364 * CALCULATE INTERACTIONS *
1365 **************************/
1367 /* REACTION-FIELD ELECTROSTATICS */
1368 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1372 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1374 /* Update vectorial force */
1375 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1376 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1377 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1379 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1380 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1381 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1383 /**************************
1384 * CALCULATE INTERACTIONS *
1385 **************************/
1387 /* REACTION-FIELD ELECTROSTATICS */
1388 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1392 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1394 /* Update vectorial force */
1395 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1396 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1397 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1399 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1400 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1401 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1403 /**************************
1404 * CALCULATE INTERACTIONS *
1405 **************************/
1407 /* REACTION-FIELD ELECTROSTATICS */
1408 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1412 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1414 /* Update vectorial force */
1415 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1416 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1417 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1419 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1420 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1421 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1423 /**************************
1424 * CALCULATE INTERACTIONS *
1425 **************************/
1427 /* REACTION-FIELD ELECTROSTATICS */
1428 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1432 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1434 /* Update vectorial force */
1435 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1436 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1437 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1439 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1440 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1441 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1443 gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1445 /* Inner loop uses 270 flops */
1448 /* End of innermost loop */
1450 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1451 f+i_coord_offset+DIM,fshift+i_shift_offset);
1453 /* Increment number of inner iterations */
1454 inneriter += j_index_end - j_index_start;
1456 /* Outer loop uses 18 flops */
1459 /* Increment number of outer iterations */
1462 /* Update outer/inner flops */
1464 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*18 + inneriter*270);