2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017,2018, 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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_avx_128_fma_single
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Water3
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwLJ_GeomW3W3_VF_avx_128_fma_single
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73 int jnrA,jnrB,jnrC,jnrD;
74 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81 __m128 fscal,rcutoff,rcutoff2,jidxall;
83 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
89 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
91 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
92 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
93 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
94 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
95 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
96 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
97 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
98 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
99 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
100 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
101 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
102 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
103 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
106 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
109 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
110 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
111 __m128 dummy_mask,cutoff_mask;
112 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
113 __m128 one = _mm_set1_ps(1.0);
114 __m128 two = _mm_set1_ps(2.0);
120 jindex = nlist->jindex;
122 shiftidx = nlist->shift;
124 shiftvec = fr->shift_vec[0];
125 fshift = fr->fshift[0];
126 facel = _mm_set1_ps(fr->ic->epsfac);
127 charge = mdatoms->chargeA;
128 krf = _mm_set1_ps(fr->ic->k_rf);
129 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
130 crf = _mm_set1_ps(fr->ic->c_rf);
131 nvdwtype = fr->ntype;
133 vdwtype = mdatoms->typeA;
135 /* Setup water-specific parameters */
136 inr = nlist->iinr[0];
137 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
138 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
139 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
140 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
142 jq0 = _mm_set1_ps(charge[inr+0]);
143 jq1 = _mm_set1_ps(charge[inr+1]);
144 jq2 = _mm_set1_ps(charge[inr+2]);
145 vdwjidx0A = 2*vdwtype[inr+0];
146 qq00 = _mm_mul_ps(iq0,jq0);
147 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
148 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
149 qq01 = _mm_mul_ps(iq0,jq1);
150 qq02 = _mm_mul_ps(iq0,jq2);
151 qq10 = _mm_mul_ps(iq1,jq0);
152 qq11 = _mm_mul_ps(iq1,jq1);
153 qq12 = _mm_mul_ps(iq1,jq2);
154 qq20 = _mm_mul_ps(iq2,jq0);
155 qq21 = _mm_mul_ps(iq2,jq1);
156 qq22 = _mm_mul_ps(iq2,jq2);
158 /* Avoid stupid compiler warnings */
159 jnrA = jnrB = jnrC = jnrD = 0;
168 for(iidx=0;iidx<4*DIM;iidx++)
173 /* Start outer loop over neighborlists */
174 for(iidx=0; iidx<nri; iidx++)
176 /* Load shift vector for this list */
177 i_shift_offset = DIM*shiftidx[iidx];
179 /* Load limits for loop over neighbors */
180 j_index_start = jindex[iidx];
181 j_index_end = jindex[iidx+1];
183 /* Get outer coordinate index */
185 i_coord_offset = DIM*inr;
187 /* Load i particle coords and add shift vector */
188 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
189 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
191 fix0 = _mm_setzero_ps();
192 fiy0 = _mm_setzero_ps();
193 fiz0 = _mm_setzero_ps();
194 fix1 = _mm_setzero_ps();
195 fiy1 = _mm_setzero_ps();
196 fiz1 = _mm_setzero_ps();
197 fix2 = _mm_setzero_ps();
198 fiy2 = _mm_setzero_ps();
199 fiz2 = _mm_setzero_ps();
201 /* Reset potential sums */
202 velecsum = _mm_setzero_ps();
203 vvdwsum = _mm_setzero_ps();
205 /* Start inner kernel loop */
206 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
209 /* Get j neighbor index, and coordinate index */
214 j_coord_offsetA = DIM*jnrA;
215 j_coord_offsetB = DIM*jnrB;
216 j_coord_offsetC = DIM*jnrC;
217 j_coord_offsetD = DIM*jnrD;
219 /* load j atom coordinates */
220 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
221 x+j_coord_offsetC,x+j_coord_offsetD,
222 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
224 /* Calculate displacement vector */
225 dx00 = _mm_sub_ps(ix0,jx0);
226 dy00 = _mm_sub_ps(iy0,jy0);
227 dz00 = _mm_sub_ps(iz0,jz0);
228 dx01 = _mm_sub_ps(ix0,jx1);
229 dy01 = _mm_sub_ps(iy0,jy1);
230 dz01 = _mm_sub_ps(iz0,jz1);
231 dx02 = _mm_sub_ps(ix0,jx2);
232 dy02 = _mm_sub_ps(iy0,jy2);
233 dz02 = _mm_sub_ps(iz0,jz2);
234 dx10 = _mm_sub_ps(ix1,jx0);
235 dy10 = _mm_sub_ps(iy1,jy0);
236 dz10 = _mm_sub_ps(iz1,jz0);
237 dx11 = _mm_sub_ps(ix1,jx1);
238 dy11 = _mm_sub_ps(iy1,jy1);
239 dz11 = _mm_sub_ps(iz1,jz1);
240 dx12 = _mm_sub_ps(ix1,jx2);
241 dy12 = _mm_sub_ps(iy1,jy2);
242 dz12 = _mm_sub_ps(iz1,jz2);
243 dx20 = _mm_sub_ps(ix2,jx0);
244 dy20 = _mm_sub_ps(iy2,jy0);
245 dz20 = _mm_sub_ps(iz2,jz0);
246 dx21 = _mm_sub_ps(ix2,jx1);
247 dy21 = _mm_sub_ps(iy2,jy1);
248 dz21 = _mm_sub_ps(iz2,jz1);
249 dx22 = _mm_sub_ps(ix2,jx2);
250 dy22 = _mm_sub_ps(iy2,jy2);
251 dz22 = _mm_sub_ps(iz2,jz2);
253 /* Calculate squared distance and things based on it */
254 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
255 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
256 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
257 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
258 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
259 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
260 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
261 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
262 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
264 rinv00 = avx128fma_invsqrt_f(rsq00);
265 rinv01 = avx128fma_invsqrt_f(rsq01);
266 rinv02 = avx128fma_invsqrt_f(rsq02);
267 rinv10 = avx128fma_invsqrt_f(rsq10);
268 rinv11 = avx128fma_invsqrt_f(rsq11);
269 rinv12 = avx128fma_invsqrt_f(rsq12);
270 rinv20 = avx128fma_invsqrt_f(rsq20);
271 rinv21 = avx128fma_invsqrt_f(rsq21);
272 rinv22 = avx128fma_invsqrt_f(rsq22);
274 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
275 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
276 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
277 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
278 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
279 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
280 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
281 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
282 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
284 fjx0 = _mm_setzero_ps();
285 fjy0 = _mm_setzero_ps();
286 fjz0 = _mm_setzero_ps();
287 fjx1 = _mm_setzero_ps();
288 fjy1 = _mm_setzero_ps();
289 fjz1 = _mm_setzero_ps();
290 fjx2 = _mm_setzero_ps();
291 fjy2 = _mm_setzero_ps();
292 fjz2 = _mm_setzero_ps();
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
298 /* REACTION-FIELD ELECTROSTATICS */
299 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_macc_ps(krf,rsq00,rinv00),crf));
300 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
302 /* LENNARD-JONES DISPERSION/REPULSION */
304 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
305 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
306 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
307 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
308 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
310 /* Update potential sum for this i atom from the interaction with this j atom. */
311 velecsum = _mm_add_ps(velecsum,velec);
312 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
314 fscal = _mm_add_ps(felec,fvdw);
316 /* Update vectorial force */
317 fix0 = _mm_macc_ps(dx00,fscal,fix0);
318 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
319 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
321 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
322 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
323 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* REACTION-FIELD ELECTROSTATICS */
330 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_macc_ps(krf,rsq01,rinv01),crf));
331 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
333 /* Update potential sum for this i atom from the interaction with this j atom. */
334 velecsum = _mm_add_ps(velecsum,velec);
338 /* Update vectorial force */
339 fix0 = _mm_macc_ps(dx01,fscal,fix0);
340 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
341 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
343 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
344 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
345 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
351 /* REACTION-FIELD ELECTROSTATICS */
352 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_macc_ps(krf,rsq02,rinv02),crf));
353 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velecsum = _mm_add_ps(velecsum,velec);
360 /* Update vectorial force */
361 fix0 = _mm_macc_ps(dx02,fscal,fix0);
362 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
363 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
365 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
366 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
367 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
373 /* REACTION-FIELD ELECTROSTATICS */
374 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
375 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
377 /* Update potential sum for this i atom from the interaction with this j atom. */
378 velecsum = _mm_add_ps(velecsum,velec);
382 /* Update vectorial force */
383 fix1 = _mm_macc_ps(dx10,fscal,fix1);
384 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
385 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
387 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
388 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
389 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
395 /* REACTION-FIELD ELECTROSTATICS */
396 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_macc_ps(krf,rsq11,rinv11),crf));
397 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
399 /* Update potential sum for this i atom from the interaction with this j atom. */
400 velecsum = _mm_add_ps(velecsum,velec);
404 /* Update vectorial force */
405 fix1 = _mm_macc_ps(dx11,fscal,fix1);
406 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
407 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
409 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
410 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
411 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
417 /* REACTION-FIELD ELECTROSTATICS */
418 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_macc_ps(krf,rsq12,rinv12),crf));
419 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
421 /* Update potential sum for this i atom from the interaction with this j atom. */
422 velecsum = _mm_add_ps(velecsum,velec);
426 /* Update vectorial force */
427 fix1 = _mm_macc_ps(dx12,fscal,fix1);
428 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
429 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
431 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
432 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
433 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
439 /* REACTION-FIELD ELECTROSTATICS */
440 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
441 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
443 /* Update potential sum for this i atom from the interaction with this j atom. */
444 velecsum = _mm_add_ps(velecsum,velec);
448 /* Update vectorial force */
449 fix2 = _mm_macc_ps(dx20,fscal,fix2);
450 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
451 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
453 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
454 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
455 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 /* REACTION-FIELD ELECTROSTATICS */
462 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_macc_ps(krf,rsq21,rinv21),crf));
463 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
465 /* Update potential sum for this i atom from the interaction with this j atom. */
466 velecsum = _mm_add_ps(velecsum,velec);
470 /* Update vectorial force */
471 fix2 = _mm_macc_ps(dx21,fscal,fix2);
472 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
473 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
475 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
476 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
477 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
483 /* REACTION-FIELD ELECTROSTATICS */
484 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_macc_ps(krf,rsq22,rinv22),crf));
485 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
487 /* Update potential sum for this i atom from the interaction with this j atom. */
488 velecsum = _mm_add_ps(velecsum,velec);
492 /* Update vectorial force */
493 fix2 = _mm_macc_ps(dx22,fscal,fix2);
494 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
495 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
497 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
498 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
499 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
501 fjptrA = f+j_coord_offsetA;
502 fjptrB = f+j_coord_offsetB;
503 fjptrC = f+j_coord_offsetC;
504 fjptrD = f+j_coord_offsetD;
506 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
507 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
509 /* Inner loop uses 327 flops */
515 /* Get j neighbor index, and coordinate index */
516 jnrlistA = jjnr[jidx];
517 jnrlistB = jjnr[jidx+1];
518 jnrlistC = jjnr[jidx+2];
519 jnrlistD = jjnr[jidx+3];
520 /* Sign of each element will be negative for non-real atoms.
521 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
522 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
524 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
525 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
526 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
527 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
528 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
529 j_coord_offsetA = DIM*jnrA;
530 j_coord_offsetB = DIM*jnrB;
531 j_coord_offsetC = DIM*jnrC;
532 j_coord_offsetD = DIM*jnrD;
534 /* load j atom coordinates */
535 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
536 x+j_coord_offsetC,x+j_coord_offsetD,
537 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
539 /* Calculate displacement vector */
540 dx00 = _mm_sub_ps(ix0,jx0);
541 dy00 = _mm_sub_ps(iy0,jy0);
542 dz00 = _mm_sub_ps(iz0,jz0);
543 dx01 = _mm_sub_ps(ix0,jx1);
544 dy01 = _mm_sub_ps(iy0,jy1);
545 dz01 = _mm_sub_ps(iz0,jz1);
546 dx02 = _mm_sub_ps(ix0,jx2);
547 dy02 = _mm_sub_ps(iy0,jy2);
548 dz02 = _mm_sub_ps(iz0,jz2);
549 dx10 = _mm_sub_ps(ix1,jx0);
550 dy10 = _mm_sub_ps(iy1,jy0);
551 dz10 = _mm_sub_ps(iz1,jz0);
552 dx11 = _mm_sub_ps(ix1,jx1);
553 dy11 = _mm_sub_ps(iy1,jy1);
554 dz11 = _mm_sub_ps(iz1,jz1);
555 dx12 = _mm_sub_ps(ix1,jx2);
556 dy12 = _mm_sub_ps(iy1,jy2);
557 dz12 = _mm_sub_ps(iz1,jz2);
558 dx20 = _mm_sub_ps(ix2,jx0);
559 dy20 = _mm_sub_ps(iy2,jy0);
560 dz20 = _mm_sub_ps(iz2,jz0);
561 dx21 = _mm_sub_ps(ix2,jx1);
562 dy21 = _mm_sub_ps(iy2,jy1);
563 dz21 = _mm_sub_ps(iz2,jz1);
564 dx22 = _mm_sub_ps(ix2,jx2);
565 dy22 = _mm_sub_ps(iy2,jy2);
566 dz22 = _mm_sub_ps(iz2,jz2);
568 /* Calculate squared distance and things based on it */
569 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
570 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
571 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
572 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
573 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
574 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
575 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
576 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
577 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
579 rinv00 = avx128fma_invsqrt_f(rsq00);
580 rinv01 = avx128fma_invsqrt_f(rsq01);
581 rinv02 = avx128fma_invsqrt_f(rsq02);
582 rinv10 = avx128fma_invsqrt_f(rsq10);
583 rinv11 = avx128fma_invsqrt_f(rsq11);
584 rinv12 = avx128fma_invsqrt_f(rsq12);
585 rinv20 = avx128fma_invsqrt_f(rsq20);
586 rinv21 = avx128fma_invsqrt_f(rsq21);
587 rinv22 = avx128fma_invsqrt_f(rsq22);
589 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
590 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
591 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
592 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
593 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
594 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
595 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
596 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
597 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
599 fjx0 = _mm_setzero_ps();
600 fjy0 = _mm_setzero_ps();
601 fjz0 = _mm_setzero_ps();
602 fjx1 = _mm_setzero_ps();
603 fjy1 = _mm_setzero_ps();
604 fjz1 = _mm_setzero_ps();
605 fjx2 = _mm_setzero_ps();
606 fjy2 = _mm_setzero_ps();
607 fjz2 = _mm_setzero_ps();
609 /**************************
610 * CALCULATE INTERACTIONS *
611 **************************/
613 /* REACTION-FIELD ELECTROSTATICS */
614 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_macc_ps(krf,rsq00,rinv00),crf));
615 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
617 /* LENNARD-JONES DISPERSION/REPULSION */
619 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
620 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
621 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
622 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
623 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
625 /* Update potential sum for this i atom from the interaction with this j atom. */
626 velec = _mm_andnot_ps(dummy_mask,velec);
627 velecsum = _mm_add_ps(velecsum,velec);
628 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
629 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
631 fscal = _mm_add_ps(felec,fvdw);
633 fscal = _mm_andnot_ps(dummy_mask,fscal);
635 /* Update vectorial force */
636 fix0 = _mm_macc_ps(dx00,fscal,fix0);
637 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
638 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
640 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
641 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
642 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
644 /**************************
645 * CALCULATE INTERACTIONS *
646 **************************/
648 /* REACTION-FIELD ELECTROSTATICS */
649 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_macc_ps(krf,rsq01,rinv01),crf));
650 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
652 /* Update potential sum for this i atom from the interaction with this j atom. */
653 velec = _mm_andnot_ps(dummy_mask,velec);
654 velecsum = _mm_add_ps(velecsum,velec);
658 fscal = _mm_andnot_ps(dummy_mask,fscal);
660 /* Update vectorial force */
661 fix0 = _mm_macc_ps(dx01,fscal,fix0);
662 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
663 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
665 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
666 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
667 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
669 /**************************
670 * CALCULATE INTERACTIONS *
671 **************************/
673 /* REACTION-FIELD ELECTROSTATICS */
674 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_macc_ps(krf,rsq02,rinv02),crf));
675 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
677 /* Update potential sum for this i atom from the interaction with this j atom. */
678 velec = _mm_andnot_ps(dummy_mask,velec);
679 velecsum = _mm_add_ps(velecsum,velec);
683 fscal = _mm_andnot_ps(dummy_mask,fscal);
685 /* Update vectorial force */
686 fix0 = _mm_macc_ps(dx02,fscal,fix0);
687 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
688 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
690 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
691 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
692 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
694 /**************************
695 * CALCULATE INTERACTIONS *
696 **************************/
698 /* REACTION-FIELD ELECTROSTATICS */
699 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
700 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
702 /* Update potential sum for this i atom from the interaction with this j atom. */
703 velec = _mm_andnot_ps(dummy_mask,velec);
704 velecsum = _mm_add_ps(velecsum,velec);
708 fscal = _mm_andnot_ps(dummy_mask,fscal);
710 /* Update vectorial force */
711 fix1 = _mm_macc_ps(dx10,fscal,fix1);
712 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
713 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
715 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
716 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
717 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
719 /**************************
720 * CALCULATE INTERACTIONS *
721 **************************/
723 /* REACTION-FIELD ELECTROSTATICS */
724 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_macc_ps(krf,rsq11,rinv11),crf));
725 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
727 /* Update potential sum for this i atom from the interaction with this j atom. */
728 velec = _mm_andnot_ps(dummy_mask,velec);
729 velecsum = _mm_add_ps(velecsum,velec);
733 fscal = _mm_andnot_ps(dummy_mask,fscal);
735 /* Update vectorial force */
736 fix1 = _mm_macc_ps(dx11,fscal,fix1);
737 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
738 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
740 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
741 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
742 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
744 /**************************
745 * CALCULATE INTERACTIONS *
746 **************************/
748 /* REACTION-FIELD ELECTROSTATICS */
749 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_macc_ps(krf,rsq12,rinv12),crf));
750 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
752 /* Update potential sum for this i atom from the interaction with this j atom. */
753 velec = _mm_andnot_ps(dummy_mask,velec);
754 velecsum = _mm_add_ps(velecsum,velec);
758 fscal = _mm_andnot_ps(dummy_mask,fscal);
760 /* Update vectorial force */
761 fix1 = _mm_macc_ps(dx12,fscal,fix1);
762 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
763 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
765 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
766 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
767 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
769 /**************************
770 * CALCULATE INTERACTIONS *
771 **************************/
773 /* REACTION-FIELD ELECTROSTATICS */
774 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
775 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
777 /* Update potential sum for this i atom from the interaction with this j atom. */
778 velec = _mm_andnot_ps(dummy_mask,velec);
779 velecsum = _mm_add_ps(velecsum,velec);
783 fscal = _mm_andnot_ps(dummy_mask,fscal);
785 /* Update vectorial force */
786 fix2 = _mm_macc_ps(dx20,fscal,fix2);
787 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
788 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
790 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
791 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
792 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 /* REACTION-FIELD ELECTROSTATICS */
799 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_macc_ps(krf,rsq21,rinv21),crf));
800 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
802 /* Update potential sum for this i atom from the interaction with this j atom. */
803 velec = _mm_andnot_ps(dummy_mask,velec);
804 velecsum = _mm_add_ps(velecsum,velec);
808 fscal = _mm_andnot_ps(dummy_mask,fscal);
810 /* Update vectorial force */
811 fix2 = _mm_macc_ps(dx21,fscal,fix2);
812 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
813 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
815 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
816 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
817 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
819 /**************************
820 * CALCULATE INTERACTIONS *
821 **************************/
823 /* REACTION-FIELD ELECTROSTATICS */
824 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_macc_ps(krf,rsq22,rinv22),crf));
825 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
827 /* Update potential sum for this i atom from the interaction with this j atom. */
828 velec = _mm_andnot_ps(dummy_mask,velec);
829 velecsum = _mm_add_ps(velecsum,velec);
833 fscal = _mm_andnot_ps(dummy_mask,fscal);
835 /* Update vectorial force */
836 fix2 = _mm_macc_ps(dx22,fscal,fix2);
837 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
838 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
840 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
841 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
842 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
844 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
845 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
846 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
847 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
849 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
850 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
852 /* Inner loop uses 327 flops */
855 /* End of innermost loop */
857 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
858 f+i_coord_offset,fshift+i_shift_offset);
861 /* Update potential energies */
862 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
863 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
865 /* Increment number of inner iterations */
866 inneriter += j_index_end - j_index_start;
868 /* Outer loop uses 20 flops */
871 /* Increment number of outer iterations */
874 /* Update outer/inner flops */
876 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*327);
879 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_avx_128_fma_single
880 * Electrostatics interaction: ReactionField
881 * VdW interaction: LennardJones
882 * Geometry: Water3-Water3
883 * Calculate force/pot: Force
886 nb_kernel_ElecRF_VdwLJ_GeomW3W3_F_avx_128_fma_single
887 (t_nblist * gmx_restrict nlist,
888 rvec * gmx_restrict xx,
889 rvec * gmx_restrict ff,
890 struct t_forcerec * gmx_restrict fr,
891 t_mdatoms * gmx_restrict mdatoms,
892 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
893 t_nrnb * gmx_restrict nrnb)
895 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
896 * just 0 for non-waters.
897 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
898 * jnr indices corresponding to data put in the four positions in the SIMD register.
900 int i_shift_offset,i_coord_offset,outeriter,inneriter;
901 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
902 int jnrA,jnrB,jnrC,jnrD;
903 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
904 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
905 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
907 real *shiftvec,*fshift,*x,*f;
908 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
910 __m128 fscal,rcutoff,rcutoff2,jidxall;
912 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
914 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
916 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
917 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
918 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
919 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
920 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
921 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
922 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
923 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
924 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
925 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
926 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
927 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
928 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
929 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
930 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
931 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
932 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
935 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
938 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
939 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
940 __m128 dummy_mask,cutoff_mask;
941 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
942 __m128 one = _mm_set1_ps(1.0);
943 __m128 two = _mm_set1_ps(2.0);
949 jindex = nlist->jindex;
951 shiftidx = nlist->shift;
953 shiftvec = fr->shift_vec[0];
954 fshift = fr->fshift[0];
955 facel = _mm_set1_ps(fr->ic->epsfac);
956 charge = mdatoms->chargeA;
957 krf = _mm_set1_ps(fr->ic->k_rf);
958 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
959 crf = _mm_set1_ps(fr->ic->c_rf);
960 nvdwtype = fr->ntype;
962 vdwtype = mdatoms->typeA;
964 /* Setup water-specific parameters */
965 inr = nlist->iinr[0];
966 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
967 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
968 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
969 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
971 jq0 = _mm_set1_ps(charge[inr+0]);
972 jq1 = _mm_set1_ps(charge[inr+1]);
973 jq2 = _mm_set1_ps(charge[inr+2]);
974 vdwjidx0A = 2*vdwtype[inr+0];
975 qq00 = _mm_mul_ps(iq0,jq0);
976 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
977 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
978 qq01 = _mm_mul_ps(iq0,jq1);
979 qq02 = _mm_mul_ps(iq0,jq2);
980 qq10 = _mm_mul_ps(iq1,jq0);
981 qq11 = _mm_mul_ps(iq1,jq1);
982 qq12 = _mm_mul_ps(iq1,jq2);
983 qq20 = _mm_mul_ps(iq2,jq0);
984 qq21 = _mm_mul_ps(iq2,jq1);
985 qq22 = _mm_mul_ps(iq2,jq2);
987 /* Avoid stupid compiler warnings */
988 jnrA = jnrB = jnrC = jnrD = 0;
997 for(iidx=0;iidx<4*DIM;iidx++)
1002 /* Start outer loop over neighborlists */
1003 for(iidx=0; iidx<nri; iidx++)
1005 /* Load shift vector for this list */
1006 i_shift_offset = DIM*shiftidx[iidx];
1008 /* Load limits for loop over neighbors */
1009 j_index_start = jindex[iidx];
1010 j_index_end = jindex[iidx+1];
1012 /* Get outer coordinate index */
1014 i_coord_offset = DIM*inr;
1016 /* Load i particle coords and add shift vector */
1017 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1018 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1020 fix0 = _mm_setzero_ps();
1021 fiy0 = _mm_setzero_ps();
1022 fiz0 = _mm_setzero_ps();
1023 fix1 = _mm_setzero_ps();
1024 fiy1 = _mm_setzero_ps();
1025 fiz1 = _mm_setzero_ps();
1026 fix2 = _mm_setzero_ps();
1027 fiy2 = _mm_setzero_ps();
1028 fiz2 = _mm_setzero_ps();
1030 /* Start inner kernel loop */
1031 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1034 /* Get j neighbor index, and coordinate index */
1036 jnrB = jjnr[jidx+1];
1037 jnrC = jjnr[jidx+2];
1038 jnrD = jjnr[jidx+3];
1039 j_coord_offsetA = DIM*jnrA;
1040 j_coord_offsetB = DIM*jnrB;
1041 j_coord_offsetC = DIM*jnrC;
1042 j_coord_offsetD = DIM*jnrD;
1044 /* load j atom coordinates */
1045 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1046 x+j_coord_offsetC,x+j_coord_offsetD,
1047 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1049 /* Calculate displacement vector */
1050 dx00 = _mm_sub_ps(ix0,jx0);
1051 dy00 = _mm_sub_ps(iy0,jy0);
1052 dz00 = _mm_sub_ps(iz0,jz0);
1053 dx01 = _mm_sub_ps(ix0,jx1);
1054 dy01 = _mm_sub_ps(iy0,jy1);
1055 dz01 = _mm_sub_ps(iz0,jz1);
1056 dx02 = _mm_sub_ps(ix0,jx2);
1057 dy02 = _mm_sub_ps(iy0,jy2);
1058 dz02 = _mm_sub_ps(iz0,jz2);
1059 dx10 = _mm_sub_ps(ix1,jx0);
1060 dy10 = _mm_sub_ps(iy1,jy0);
1061 dz10 = _mm_sub_ps(iz1,jz0);
1062 dx11 = _mm_sub_ps(ix1,jx1);
1063 dy11 = _mm_sub_ps(iy1,jy1);
1064 dz11 = _mm_sub_ps(iz1,jz1);
1065 dx12 = _mm_sub_ps(ix1,jx2);
1066 dy12 = _mm_sub_ps(iy1,jy2);
1067 dz12 = _mm_sub_ps(iz1,jz2);
1068 dx20 = _mm_sub_ps(ix2,jx0);
1069 dy20 = _mm_sub_ps(iy2,jy0);
1070 dz20 = _mm_sub_ps(iz2,jz0);
1071 dx21 = _mm_sub_ps(ix2,jx1);
1072 dy21 = _mm_sub_ps(iy2,jy1);
1073 dz21 = _mm_sub_ps(iz2,jz1);
1074 dx22 = _mm_sub_ps(ix2,jx2);
1075 dy22 = _mm_sub_ps(iy2,jy2);
1076 dz22 = _mm_sub_ps(iz2,jz2);
1078 /* Calculate squared distance and things based on it */
1079 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1080 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1081 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1082 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1083 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1084 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1085 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1086 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1087 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1089 rinv00 = avx128fma_invsqrt_f(rsq00);
1090 rinv01 = avx128fma_invsqrt_f(rsq01);
1091 rinv02 = avx128fma_invsqrt_f(rsq02);
1092 rinv10 = avx128fma_invsqrt_f(rsq10);
1093 rinv11 = avx128fma_invsqrt_f(rsq11);
1094 rinv12 = avx128fma_invsqrt_f(rsq12);
1095 rinv20 = avx128fma_invsqrt_f(rsq20);
1096 rinv21 = avx128fma_invsqrt_f(rsq21);
1097 rinv22 = avx128fma_invsqrt_f(rsq22);
1099 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1100 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1101 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1102 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1103 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1104 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1105 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1106 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1107 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1109 fjx0 = _mm_setzero_ps();
1110 fjy0 = _mm_setzero_ps();
1111 fjz0 = _mm_setzero_ps();
1112 fjx1 = _mm_setzero_ps();
1113 fjy1 = _mm_setzero_ps();
1114 fjz1 = _mm_setzero_ps();
1115 fjx2 = _mm_setzero_ps();
1116 fjy2 = _mm_setzero_ps();
1117 fjz2 = _mm_setzero_ps();
1119 /**************************
1120 * CALCULATE INTERACTIONS *
1121 **************************/
1123 /* REACTION-FIELD ELECTROSTATICS */
1124 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
1126 /* LENNARD-JONES DISPERSION/REPULSION */
1128 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1129 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1131 fscal = _mm_add_ps(felec,fvdw);
1133 /* Update vectorial force */
1134 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1135 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1136 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1138 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1139 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1140 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1146 /* REACTION-FIELD ELECTROSTATICS */
1147 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
1151 /* Update vectorial force */
1152 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1153 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1154 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1156 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1157 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1158 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1160 /**************************
1161 * CALCULATE INTERACTIONS *
1162 **************************/
1164 /* REACTION-FIELD ELECTROSTATICS */
1165 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
1169 /* Update vectorial force */
1170 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1171 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1172 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1174 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1175 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1176 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1178 /**************************
1179 * CALCULATE INTERACTIONS *
1180 **************************/
1182 /* REACTION-FIELD ELECTROSTATICS */
1183 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1187 /* Update vectorial force */
1188 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1189 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1190 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1192 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1193 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1194 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1196 /**************************
1197 * CALCULATE INTERACTIONS *
1198 **************************/
1200 /* REACTION-FIELD ELECTROSTATICS */
1201 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
1205 /* Update vectorial force */
1206 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1207 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1208 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1210 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1211 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1212 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1214 /**************************
1215 * CALCULATE INTERACTIONS *
1216 **************************/
1218 /* REACTION-FIELD ELECTROSTATICS */
1219 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
1223 /* Update vectorial force */
1224 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1225 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1226 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1228 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1229 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1230 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1232 /**************************
1233 * CALCULATE INTERACTIONS *
1234 **************************/
1236 /* REACTION-FIELD ELECTROSTATICS */
1237 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1241 /* Update vectorial force */
1242 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1243 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1244 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1246 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1247 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1248 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1250 /**************************
1251 * CALCULATE INTERACTIONS *
1252 **************************/
1254 /* REACTION-FIELD ELECTROSTATICS */
1255 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
1259 /* Update vectorial force */
1260 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1261 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1262 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1264 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1265 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1266 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1268 /**************************
1269 * CALCULATE INTERACTIONS *
1270 **************************/
1272 /* REACTION-FIELD ELECTROSTATICS */
1273 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
1277 /* Update vectorial force */
1278 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1279 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1280 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1282 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1283 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1284 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1286 fjptrA = f+j_coord_offsetA;
1287 fjptrB = f+j_coord_offsetB;
1288 fjptrC = f+j_coord_offsetC;
1289 fjptrD = f+j_coord_offsetD;
1291 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1292 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1294 /* Inner loop uses 277 flops */
1297 if(jidx<j_index_end)
1300 /* Get j neighbor index, and coordinate index */
1301 jnrlistA = jjnr[jidx];
1302 jnrlistB = jjnr[jidx+1];
1303 jnrlistC = jjnr[jidx+2];
1304 jnrlistD = jjnr[jidx+3];
1305 /* Sign of each element will be negative for non-real atoms.
1306 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1307 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1309 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1310 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1311 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1312 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1313 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1314 j_coord_offsetA = DIM*jnrA;
1315 j_coord_offsetB = DIM*jnrB;
1316 j_coord_offsetC = DIM*jnrC;
1317 j_coord_offsetD = DIM*jnrD;
1319 /* load j atom coordinates */
1320 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1321 x+j_coord_offsetC,x+j_coord_offsetD,
1322 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1324 /* Calculate displacement vector */
1325 dx00 = _mm_sub_ps(ix0,jx0);
1326 dy00 = _mm_sub_ps(iy0,jy0);
1327 dz00 = _mm_sub_ps(iz0,jz0);
1328 dx01 = _mm_sub_ps(ix0,jx1);
1329 dy01 = _mm_sub_ps(iy0,jy1);
1330 dz01 = _mm_sub_ps(iz0,jz1);
1331 dx02 = _mm_sub_ps(ix0,jx2);
1332 dy02 = _mm_sub_ps(iy0,jy2);
1333 dz02 = _mm_sub_ps(iz0,jz2);
1334 dx10 = _mm_sub_ps(ix1,jx0);
1335 dy10 = _mm_sub_ps(iy1,jy0);
1336 dz10 = _mm_sub_ps(iz1,jz0);
1337 dx11 = _mm_sub_ps(ix1,jx1);
1338 dy11 = _mm_sub_ps(iy1,jy1);
1339 dz11 = _mm_sub_ps(iz1,jz1);
1340 dx12 = _mm_sub_ps(ix1,jx2);
1341 dy12 = _mm_sub_ps(iy1,jy2);
1342 dz12 = _mm_sub_ps(iz1,jz2);
1343 dx20 = _mm_sub_ps(ix2,jx0);
1344 dy20 = _mm_sub_ps(iy2,jy0);
1345 dz20 = _mm_sub_ps(iz2,jz0);
1346 dx21 = _mm_sub_ps(ix2,jx1);
1347 dy21 = _mm_sub_ps(iy2,jy1);
1348 dz21 = _mm_sub_ps(iz2,jz1);
1349 dx22 = _mm_sub_ps(ix2,jx2);
1350 dy22 = _mm_sub_ps(iy2,jy2);
1351 dz22 = _mm_sub_ps(iz2,jz2);
1353 /* Calculate squared distance and things based on it */
1354 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1355 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1356 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1357 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1358 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1359 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1360 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1361 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1362 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1364 rinv00 = avx128fma_invsqrt_f(rsq00);
1365 rinv01 = avx128fma_invsqrt_f(rsq01);
1366 rinv02 = avx128fma_invsqrt_f(rsq02);
1367 rinv10 = avx128fma_invsqrt_f(rsq10);
1368 rinv11 = avx128fma_invsqrt_f(rsq11);
1369 rinv12 = avx128fma_invsqrt_f(rsq12);
1370 rinv20 = avx128fma_invsqrt_f(rsq20);
1371 rinv21 = avx128fma_invsqrt_f(rsq21);
1372 rinv22 = avx128fma_invsqrt_f(rsq22);
1374 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1375 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1376 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1377 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1378 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1379 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1380 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1381 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1382 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1384 fjx0 = _mm_setzero_ps();
1385 fjy0 = _mm_setzero_ps();
1386 fjz0 = _mm_setzero_ps();
1387 fjx1 = _mm_setzero_ps();
1388 fjy1 = _mm_setzero_ps();
1389 fjz1 = _mm_setzero_ps();
1390 fjx2 = _mm_setzero_ps();
1391 fjy2 = _mm_setzero_ps();
1392 fjz2 = _mm_setzero_ps();
1394 /**************************
1395 * CALCULATE INTERACTIONS *
1396 **************************/
1398 /* REACTION-FIELD ELECTROSTATICS */
1399 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
1401 /* LENNARD-JONES DISPERSION/REPULSION */
1403 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1404 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1406 fscal = _mm_add_ps(felec,fvdw);
1408 fscal = _mm_andnot_ps(dummy_mask,fscal);
1410 /* Update vectorial force */
1411 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1412 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1413 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1415 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1416 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1417 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1419 /**************************
1420 * CALCULATE INTERACTIONS *
1421 **************************/
1423 /* REACTION-FIELD ELECTROSTATICS */
1424 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
1428 fscal = _mm_andnot_ps(dummy_mask,fscal);
1430 /* Update vectorial force */
1431 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1432 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1433 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1435 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1436 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1437 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1439 /**************************
1440 * CALCULATE INTERACTIONS *
1441 **************************/
1443 /* REACTION-FIELD ELECTROSTATICS */
1444 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
1448 fscal = _mm_andnot_ps(dummy_mask,fscal);
1450 /* Update vectorial force */
1451 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1452 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1453 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1455 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1456 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1457 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1459 /**************************
1460 * CALCULATE INTERACTIONS *
1461 **************************/
1463 /* REACTION-FIELD ELECTROSTATICS */
1464 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1468 fscal = _mm_andnot_ps(dummy_mask,fscal);
1470 /* Update vectorial force */
1471 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1472 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1473 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1475 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1476 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1477 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1479 /**************************
1480 * CALCULATE INTERACTIONS *
1481 **************************/
1483 /* REACTION-FIELD ELECTROSTATICS */
1484 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
1488 fscal = _mm_andnot_ps(dummy_mask,fscal);
1490 /* Update vectorial force */
1491 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1492 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1493 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1495 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1496 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1497 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1499 /**************************
1500 * CALCULATE INTERACTIONS *
1501 **************************/
1503 /* REACTION-FIELD ELECTROSTATICS */
1504 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
1508 fscal = _mm_andnot_ps(dummy_mask,fscal);
1510 /* Update vectorial force */
1511 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1512 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1513 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1515 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1516 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1517 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1519 /**************************
1520 * CALCULATE INTERACTIONS *
1521 **************************/
1523 /* REACTION-FIELD ELECTROSTATICS */
1524 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1528 fscal = _mm_andnot_ps(dummy_mask,fscal);
1530 /* Update vectorial force */
1531 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1532 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1533 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1535 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1536 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1537 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1539 /**************************
1540 * CALCULATE INTERACTIONS *
1541 **************************/
1543 /* REACTION-FIELD ELECTROSTATICS */
1544 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
1548 fscal = _mm_andnot_ps(dummy_mask,fscal);
1550 /* Update vectorial force */
1551 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1552 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1553 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1555 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1556 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1557 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1559 /**************************
1560 * CALCULATE INTERACTIONS *
1561 **************************/
1563 /* REACTION-FIELD ELECTROSTATICS */
1564 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
1568 fscal = _mm_andnot_ps(dummy_mask,fscal);
1570 /* Update vectorial force */
1571 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1572 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1573 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1575 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1576 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1577 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1579 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1580 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1581 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1582 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1584 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1585 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1587 /* Inner loop uses 277 flops */
1590 /* End of innermost loop */
1592 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1593 f+i_coord_offset,fshift+i_shift_offset);
1595 /* Increment number of inner iterations */
1596 inneriter += j_index_end - j_index_start;
1598 /* Outer loop uses 18 flops */
1601 /* Increment number of outer iterations */
1604 /* Update outer/inner flops */
1606 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*277);