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_ElecRFCut_VdwLJSh_GeomW4P1_VF_avx_128_fma_single
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_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;
89 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
90 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
91 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
92 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
93 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
94 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
95 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
96 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
99 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
102 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
103 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
104 __m128 dummy_mask,cutoff_mask;
105 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
106 __m128 one = _mm_set1_ps(1.0);
107 __m128 two = _mm_set1_ps(2.0);
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
119 facel = _mm_set1_ps(fr->ic->epsfac);
120 charge = mdatoms->chargeA;
121 krf = _mm_set1_ps(fr->ic->k_rf);
122 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
123 crf = _mm_set1_ps(fr->ic->c_rf);
124 nvdwtype = fr->ntype;
126 vdwtype = mdatoms->typeA;
128 /* Setup water-specific parameters */
129 inr = nlist->iinr[0];
130 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
131 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
132 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
136 rcutoff_scalar = fr->ic->rcoulomb;
137 rcutoff = _mm_set1_ps(rcutoff_scalar);
138 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
140 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
141 rvdw = _mm_set1_ps(fr->ic->rvdw);
143 /* Avoid stupid compiler warnings */
144 jnrA = jnrB = jnrC = jnrD = 0;
153 for(iidx=0;iidx<4*DIM;iidx++)
158 /* Start outer loop over neighborlists */
159 for(iidx=0; iidx<nri; iidx++)
161 /* Load shift vector for this list */
162 i_shift_offset = DIM*shiftidx[iidx];
164 /* Load limits for loop over neighbors */
165 j_index_start = jindex[iidx];
166 j_index_end = jindex[iidx+1];
168 /* Get outer coordinate index */
170 i_coord_offset = DIM*inr;
172 /* Load i particle coords and add shift vector */
173 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
174 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
176 fix0 = _mm_setzero_ps();
177 fiy0 = _mm_setzero_ps();
178 fiz0 = _mm_setzero_ps();
179 fix1 = _mm_setzero_ps();
180 fiy1 = _mm_setzero_ps();
181 fiz1 = _mm_setzero_ps();
182 fix2 = _mm_setzero_ps();
183 fiy2 = _mm_setzero_ps();
184 fiz2 = _mm_setzero_ps();
185 fix3 = _mm_setzero_ps();
186 fiy3 = _mm_setzero_ps();
187 fiz3 = _mm_setzero_ps();
189 /* Reset potential sums */
190 velecsum = _mm_setzero_ps();
191 vvdwsum = _mm_setzero_ps();
193 /* Start inner kernel loop */
194 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
197 /* Get j neighbor index, and coordinate index */
202 j_coord_offsetA = DIM*jnrA;
203 j_coord_offsetB = DIM*jnrB;
204 j_coord_offsetC = DIM*jnrC;
205 j_coord_offsetD = DIM*jnrD;
207 /* load j atom coordinates */
208 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
209 x+j_coord_offsetC,x+j_coord_offsetD,
212 /* Calculate displacement vector */
213 dx00 = _mm_sub_ps(ix0,jx0);
214 dy00 = _mm_sub_ps(iy0,jy0);
215 dz00 = _mm_sub_ps(iz0,jz0);
216 dx10 = _mm_sub_ps(ix1,jx0);
217 dy10 = _mm_sub_ps(iy1,jy0);
218 dz10 = _mm_sub_ps(iz1,jz0);
219 dx20 = _mm_sub_ps(ix2,jx0);
220 dy20 = _mm_sub_ps(iy2,jy0);
221 dz20 = _mm_sub_ps(iz2,jz0);
222 dx30 = _mm_sub_ps(ix3,jx0);
223 dy30 = _mm_sub_ps(iy3,jy0);
224 dz30 = _mm_sub_ps(iz3,jz0);
226 /* Calculate squared distance and things based on it */
227 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
228 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
229 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
230 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
232 rinv10 = avx128fma_invsqrt_f(rsq10);
233 rinv20 = avx128fma_invsqrt_f(rsq20);
234 rinv30 = avx128fma_invsqrt_f(rsq30);
236 rinvsq00 = avx128fma_inv_f(rsq00);
237 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
238 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
239 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
241 /* Load parameters for j particles */
242 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
243 charge+jnrC+0,charge+jnrD+0);
244 vdwjidx0A = 2*vdwtype[jnrA+0];
245 vdwjidx0B = 2*vdwtype[jnrB+0];
246 vdwjidx0C = 2*vdwtype[jnrC+0];
247 vdwjidx0D = 2*vdwtype[jnrD+0];
249 fjx0 = _mm_setzero_ps();
250 fjy0 = _mm_setzero_ps();
251 fjz0 = _mm_setzero_ps();
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
257 if (gmx_mm_any_lt(rsq00,rcutoff2))
260 /* Compute parameters for interactions between i and j atoms */
261 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
262 vdwparam+vdwioffset0+vdwjidx0B,
263 vdwparam+vdwioffset0+vdwjidx0C,
264 vdwparam+vdwioffset0+vdwjidx0D,
267 /* LENNARD-JONES DISPERSION/REPULSION */
269 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
270 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
271 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
272 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
273 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
274 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
276 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
278 /* Update potential sum for this i atom from the interaction with this j atom. */
279 vvdw = _mm_and_ps(vvdw,cutoff_mask);
280 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
284 fscal = _mm_and_ps(fscal,cutoff_mask);
286 /* Update vectorial force */
287 fix0 = _mm_macc_ps(dx00,fscal,fix0);
288 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
289 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
291 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
292 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
293 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
301 if (gmx_mm_any_lt(rsq10,rcutoff2))
304 /* Compute parameters for interactions between i and j atoms */
305 qq10 = _mm_mul_ps(iq1,jq0);
307 /* REACTION-FIELD ELECTROSTATICS */
308 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
309 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
311 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
313 /* Update potential sum for this i atom from the interaction with this j atom. */
314 velec = _mm_and_ps(velec,cutoff_mask);
315 velecsum = _mm_add_ps(velecsum,velec);
319 fscal = _mm_and_ps(fscal,cutoff_mask);
321 /* Update vectorial force */
322 fix1 = _mm_macc_ps(dx10,fscal,fix1);
323 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
324 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
326 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
327 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
328 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
332 /**************************
333 * CALCULATE INTERACTIONS *
334 **************************/
336 if (gmx_mm_any_lt(rsq20,rcutoff2))
339 /* Compute parameters for interactions between i and j atoms */
340 qq20 = _mm_mul_ps(iq2,jq0);
342 /* REACTION-FIELD ELECTROSTATICS */
343 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
344 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
346 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
348 /* Update potential sum for this i atom from the interaction with this j atom. */
349 velec = _mm_and_ps(velec,cutoff_mask);
350 velecsum = _mm_add_ps(velecsum,velec);
354 fscal = _mm_and_ps(fscal,cutoff_mask);
356 /* Update vectorial force */
357 fix2 = _mm_macc_ps(dx20,fscal,fix2);
358 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
359 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
361 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
362 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
363 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
371 if (gmx_mm_any_lt(rsq30,rcutoff2))
374 /* Compute parameters for interactions between i and j atoms */
375 qq30 = _mm_mul_ps(iq3,jq0);
377 /* REACTION-FIELD ELECTROSTATICS */
378 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
379 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
381 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
383 /* Update potential sum for this i atom from the interaction with this j atom. */
384 velec = _mm_and_ps(velec,cutoff_mask);
385 velecsum = _mm_add_ps(velecsum,velec);
389 fscal = _mm_and_ps(fscal,cutoff_mask);
391 /* Update vectorial force */
392 fix3 = _mm_macc_ps(dx30,fscal,fix3);
393 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
394 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
396 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
397 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
398 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
402 fjptrA = f+j_coord_offsetA;
403 fjptrB = f+j_coord_offsetB;
404 fjptrC = f+j_coord_offsetC;
405 fjptrD = f+j_coord_offsetD;
407 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
409 /* Inner loop uses 161 flops */
415 /* Get j neighbor index, and coordinate index */
416 jnrlistA = jjnr[jidx];
417 jnrlistB = jjnr[jidx+1];
418 jnrlistC = jjnr[jidx+2];
419 jnrlistD = jjnr[jidx+3];
420 /* Sign of each element will be negative for non-real atoms.
421 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
422 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
424 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
425 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
426 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
427 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
428 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
429 j_coord_offsetA = DIM*jnrA;
430 j_coord_offsetB = DIM*jnrB;
431 j_coord_offsetC = DIM*jnrC;
432 j_coord_offsetD = DIM*jnrD;
434 /* load j atom coordinates */
435 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
436 x+j_coord_offsetC,x+j_coord_offsetD,
439 /* Calculate displacement vector */
440 dx00 = _mm_sub_ps(ix0,jx0);
441 dy00 = _mm_sub_ps(iy0,jy0);
442 dz00 = _mm_sub_ps(iz0,jz0);
443 dx10 = _mm_sub_ps(ix1,jx0);
444 dy10 = _mm_sub_ps(iy1,jy0);
445 dz10 = _mm_sub_ps(iz1,jz0);
446 dx20 = _mm_sub_ps(ix2,jx0);
447 dy20 = _mm_sub_ps(iy2,jy0);
448 dz20 = _mm_sub_ps(iz2,jz0);
449 dx30 = _mm_sub_ps(ix3,jx0);
450 dy30 = _mm_sub_ps(iy3,jy0);
451 dz30 = _mm_sub_ps(iz3,jz0);
453 /* Calculate squared distance and things based on it */
454 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
455 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
456 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
457 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
459 rinv10 = avx128fma_invsqrt_f(rsq10);
460 rinv20 = avx128fma_invsqrt_f(rsq20);
461 rinv30 = avx128fma_invsqrt_f(rsq30);
463 rinvsq00 = avx128fma_inv_f(rsq00);
464 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
465 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
466 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
468 /* Load parameters for j particles */
469 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
470 charge+jnrC+0,charge+jnrD+0);
471 vdwjidx0A = 2*vdwtype[jnrA+0];
472 vdwjidx0B = 2*vdwtype[jnrB+0];
473 vdwjidx0C = 2*vdwtype[jnrC+0];
474 vdwjidx0D = 2*vdwtype[jnrD+0];
476 fjx0 = _mm_setzero_ps();
477 fjy0 = _mm_setzero_ps();
478 fjz0 = _mm_setzero_ps();
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
484 if (gmx_mm_any_lt(rsq00,rcutoff2))
487 /* Compute parameters for interactions between i and j atoms */
488 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
489 vdwparam+vdwioffset0+vdwjidx0B,
490 vdwparam+vdwioffset0+vdwjidx0C,
491 vdwparam+vdwioffset0+vdwjidx0D,
494 /* LENNARD-JONES DISPERSION/REPULSION */
496 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
497 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
498 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
499 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
500 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
501 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
503 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
505 /* Update potential sum for this i atom from the interaction with this j atom. */
506 vvdw = _mm_and_ps(vvdw,cutoff_mask);
507 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
508 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
512 fscal = _mm_and_ps(fscal,cutoff_mask);
514 fscal = _mm_andnot_ps(dummy_mask,fscal);
516 /* Update vectorial force */
517 fix0 = _mm_macc_ps(dx00,fscal,fix0);
518 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
519 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
521 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
522 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
523 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
531 if (gmx_mm_any_lt(rsq10,rcutoff2))
534 /* Compute parameters for interactions between i and j atoms */
535 qq10 = _mm_mul_ps(iq1,jq0);
537 /* REACTION-FIELD ELECTROSTATICS */
538 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
539 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
541 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
543 /* Update potential sum for this i atom from the interaction with this j atom. */
544 velec = _mm_and_ps(velec,cutoff_mask);
545 velec = _mm_andnot_ps(dummy_mask,velec);
546 velecsum = _mm_add_ps(velecsum,velec);
550 fscal = _mm_and_ps(fscal,cutoff_mask);
552 fscal = _mm_andnot_ps(dummy_mask,fscal);
554 /* Update vectorial force */
555 fix1 = _mm_macc_ps(dx10,fscal,fix1);
556 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
557 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
559 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
560 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
561 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
565 /**************************
566 * CALCULATE INTERACTIONS *
567 **************************/
569 if (gmx_mm_any_lt(rsq20,rcutoff2))
572 /* Compute parameters for interactions between i and j atoms */
573 qq20 = _mm_mul_ps(iq2,jq0);
575 /* REACTION-FIELD ELECTROSTATICS */
576 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
577 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
579 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
581 /* Update potential sum for this i atom from the interaction with this j atom. */
582 velec = _mm_and_ps(velec,cutoff_mask);
583 velec = _mm_andnot_ps(dummy_mask,velec);
584 velecsum = _mm_add_ps(velecsum,velec);
588 fscal = _mm_and_ps(fscal,cutoff_mask);
590 fscal = _mm_andnot_ps(dummy_mask,fscal);
592 /* Update vectorial force */
593 fix2 = _mm_macc_ps(dx20,fscal,fix2);
594 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
595 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
597 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
598 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
599 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
607 if (gmx_mm_any_lt(rsq30,rcutoff2))
610 /* Compute parameters for interactions between i and j atoms */
611 qq30 = _mm_mul_ps(iq3,jq0);
613 /* REACTION-FIELD ELECTROSTATICS */
614 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
615 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
617 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
619 /* Update potential sum for this i atom from the interaction with this j atom. */
620 velec = _mm_and_ps(velec,cutoff_mask);
621 velec = _mm_andnot_ps(dummy_mask,velec);
622 velecsum = _mm_add_ps(velecsum,velec);
626 fscal = _mm_and_ps(fscal,cutoff_mask);
628 fscal = _mm_andnot_ps(dummy_mask,fscal);
630 /* Update vectorial force */
631 fix3 = _mm_macc_ps(dx30,fscal,fix3);
632 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
633 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
635 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
636 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
637 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
641 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
642 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
643 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
644 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
646 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
648 /* Inner loop uses 161 flops */
651 /* End of innermost loop */
653 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
654 f+i_coord_offset,fshift+i_shift_offset);
657 /* Update potential energies */
658 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
659 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
661 /* Increment number of inner iterations */
662 inneriter += j_index_end - j_index_start;
664 /* Outer loop uses 26 flops */
667 /* Increment number of outer iterations */
670 /* Update outer/inner flops */
672 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*161);
675 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
676 * Electrostatics interaction: ReactionField
677 * VdW interaction: LennardJones
678 * Geometry: Water4-Particle
679 * Calculate force/pot: Force
682 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
683 (t_nblist * gmx_restrict nlist,
684 rvec * gmx_restrict xx,
685 rvec * gmx_restrict ff,
686 struct t_forcerec * gmx_restrict fr,
687 t_mdatoms * gmx_restrict mdatoms,
688 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
689 t_nrnb * gmx_restrict nrnb)
691 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
692 * just 0 for non-waters.
693 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
694 * jnr indices corresponding to data put in the four positions in the SIMD register.
696 int i_shift_offset,i_coord_offset,outeriter,inneriter;
697 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
698 int jnrA,jnrB,jnrC,jnrD;
699 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
700 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
701 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
703 real *shiftvec,*fshift,*x,*f;
704 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
706 __m128 fscal,rcutoff,rcutoff2,jidxall;
708 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
710 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
712 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
714 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
715 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
716 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
717 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
718 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
719 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
720 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
721 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
724 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
727 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
728 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
729 __m128 dummy_mask,cutoff_mask;
730 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
731 __m128 one = _mm_set1_ps(1.0);
732 __m128 two = _mm_set1_ps(2.0);
738 jindex = nlist->jindex;
740 shiftidx = nlist->shift;
742 shiftvec = fr->shift_vec[0];
743 fshift = fr->fshift[0];
744 facel = _mm_set1_ps(fr->ic->epsfac);
745 charge = mdatoms->chargeA;
746 krf = _mm_set1_ps(fr->ic->k_rf);
747 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
748 crf = _mm_set1_ps(fr->ic->c_rf);
749 nvdwtype = fr->ntype;
751 vdwtype = mdatoms->typeA;
753 /* Setup water-specific parameters */
754 inr = nlist->iinr[0];
755 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
756 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
757 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
758 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
760 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
761 rcutoff_scalar = fr->ic->rcoulomb;
762 rcutoff = _mm_set1_ps(rcutoff_scalar);
763 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
765 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
766 rvdw = _mm_set1_ps(fr->ic->rvdw);
768 /* Avoid stupid compiler warnings */
769 jnrA = jnrB = jnrC = jnrD = 0;
778 for(iidx=0;iidx<4*DIM;iidx++)
783 /* Start outer loop over neighborlists */
784 for(iidx=0; iidx<nri; iidx++)
786 /* Load shift vector for this list */
787 i_shift_offset = DIM*shiftidx[iidx];
789 /* Load limits for loop over neighbors */
790 j_index_start = jindex[iidx];
791 j_index_end = jindex[iidx+1];
793 /* Get outer coordinate index */
795 i_coord_offset = DIM*inr;
797 /* Load i particle coords and add shift vector */
798 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
799 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
801 fix0 = _mm_setzero_ps();
802 fiy0 = _mm_setzero_ps();
803 fiz0 = _mm_setzero_ps();
804 fix1 = _mm_setzero_ps();
805 fiy1 = _mm_setzero_ps();
806 fiz1 = _mm_setzero_ps();
807 fix2 = _mm_setzero_ps();
808 fiy2 = _mm_setzero_ps();
809 fiz2 = _mm_setzero_ps();
810 fix3 = _mm_setzero_ps();
811 fiy3 = _mm_setzero_ps();
812 fiz3 = _mm_setzero_ps();
814 /* Start inner kernel loop */
815 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
818 /* Get j neighbor index, and coordinate index */
823 j_coord_offsetA = DIM*jnrA;
824 j_coord_offsetB = DIM*jnrB;
825 j_coord_offsetC = DIM*jnrC;
826 j_coord_offsetD = DIM*jnrD;
828 /* load j atom coordinates */
829 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
830 x+j_coord_offsetC,x+j_coord_offsetD,
833 /* Calculate displacement vector */
834 dx00 = _mm_sub_ps(ix0,jx0);
835 dy00 = _mm_sub_ps(iy0,jy0);
836 dz00 = _mm_sub_ps(iz0,jz0);
837 dx10 = _mm_sub_ps(ix1,jx0);
838 dy10 = _mm_sub_ps(iy1,jy0);
839 dz10 = _mm_sub_ps(iz1,jz0);
840 dx20 = _mm_sub_ps(ix2,jx0);
841 dy20 = _mm_sub_ps(iy2,jy0);
842 dz20 = _mm_sub_ps(iz2,jz0);
843 dx30 = _mm_sub_ps(ix3,jx0);
844 dy30 = _mm_sub_ps(iy3,jy0);
845 dz30 = _mm_sub_ps(iz3,jz0);
847 /* Calculate squared distance and things based on it */
848 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
849 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
850 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
851 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
853 rinv10 = avx128fma_invsqrt_f(rsq10);
854 rinv20 = avx128fma_invsqrt_f(rsq20);
855 rinv30 = avx128fma_invsqrt_f(rsq30);
857 rinvsq00 = avx128fma_inv_f(rsq00);
858 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
859 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
860 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
862 /* Load parameters for j particles */
863 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
864 charge+jnrC+0,charge+jnrD+0);
865 vdwjidx0A = 2*vdwtype[jnrA+0];
866 vdwjidx0B = 2*vdwtype[jnrB+0];
867 vdwjidx0C = 2*vdwtype[jnrC+0];
868 vdwjidx0D = 2*vdwtype[jnrD+0];
870 fjx0 = _mm_setzero_ps();
871 fjy0 = _mm_setzero_ps();
872 fjz0 = _mm_setzero_ps();
874 /**************************
875 * CALCULATE INTERACTIONS *
876 **************************/
878 if (gmx_mm_any_lt(rsq00,rcutoff2))
881 /* Compute parameters for interactions between i and j atoms */
882 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
883 vdwparam+vdwioffset0+vdwjidx0B,
884 vdwparam+vdwioffset0+vdwjidx0C,
885 vdwparam+vdwioffset0+vdwjidx0D,
888 /* LENNARD-JONES DISPERSION/REPULSION */
890 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
891 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
893 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
897 fscal = _mm_and_ps(fscal,cutoff_mask);
899 /* Update vectorial force */
900 fix0 = _mm_macc_ps(dx00,fscal,fix0);
901 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
902 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
904 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
905 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
906 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
910 /**************************
911 * CALCULATE INTERACTIONS *
912 **************************/
914 if (gmx_mm_any_lt(rsq10,rcutoff2))
917 /* Compute parameters for interactions between i and j atoms */
918 qq10 = _mm_mul_ps(iq1,jq0);
920 /* REACTION-FIELD ELECTROSTATICS */
921 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
923 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
927 fscal = _mm_and_ps(fscal,cutoff_mask);
929 /* Update vectorial force */
930 fix1 = _mm_macc_ps(dx10,fscal,fix1);
931 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
932 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
934 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
935 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
936 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
940 /**************************
941 * CALCULATE INTERACTIONS *
942 **************************/
944 if (gmx_mm_any_lt(rsq20,rcutoff2))
947 /* Compute parameters for interactions between i and j atoms */
948 qq20 = _mm_mul_ps(iq2,jq0);
950 /* REACTION-FIELD ELECTROSTATICS */
951 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
953 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
957 fscal = _mm_and_ps(fscal,cutoff_mask);
959 /* Update vectorial force */
960 fix2 = _mm_macc_ps(dx20,fscal,fix2);
961 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
962 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
964 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
965 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
966 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
970 /**************************
971 * CALCULATE INTERACTIONS *
972 **************************/
974 if (gmx_mm_any_lt(rsq30,rcutoff2))
977 /* Compute parameters for interactions between i and j atoms */
978 qq30 = _mm_mul_ps(iq3,jq0);
980 /* REACTION-FIELD ELECTROSTATICS */
981 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
983 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
987 fscal = _mm_and_ps(fscal,cutoff_mask);
989 /* Update vectorial force */
990 fix3 = _mm_macc_ps(dx30,fscal,fix3);
991 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
992 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
994 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
995 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
996 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1000 fjptrA = f+j_coord_offsetA;
1001 fjptrB = f+j_coord_offsetB;
1002 fjptrC = f+j_coord_offsetC;
1003 fjptrD = f+j_coord_offsetD;
1005 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1007 /* Inner loop uses 132 flops */
1010 if(jidx<j_index_end)
1013 /* Get j neighbor index, and coordinate index */
1014 jnrlistA = jjnr[jidx];
1015 jnrlistB = jjnr[jidx+1];
1016 jnrlistC = jjnr[jidx+2];
1017 jnrlistD = jjnr[jidx+3];
1018 /* Sign of each element will be negative for non-real atoms.
1019 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1020 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1022 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1023 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1024 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1025 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1026 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1027 j_coord_offsetA = DIM*jnrA;
1028 j_coord_offsetB = DIM*jnrB;
1029 j_coord_offsetC = DIM*jnrC;
1030 j_coord_offsetD = DIM*jnrD;
1032 /* load j atom coordinates */
1033 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1034 x+j_coord_offsetC,x+j_coord_offsetD,
1037 /* Calculate displacement vector */
1038 dx00 = _mm_sub_ps(ix0,jx0);
1039 dy00 = _mm_sub_ps(iy0,jy0);
1040 dz00 = _mm_sub_ps(iz0,jz0);
1041 dx10 = _mm_sub_ps(ix1,jx0);
1042 dy10 = _mm_sub_ps(iy1,jy0);
1043 dz10 = _mm_sub_ps(iz1,jz0);
1044 dx20 = _mm_sub_ps(ix2,jx0);
1045 dy20 = _mm_sub_ps(iy2,jy0);
1046 dz20 = _mm_sub_ps(iz2,jz0);
1047 dx30 = _mm_sub_ps(ix3,jx0);
1048 dy30 = _mm_sub_ps(iy3,jy0);
1049 dz30 = _mm_sub_ps(iz3,jz0);
1051 /* Calculate squared distance and things based on it */
1052 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1053 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1054 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1055 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
1057 rinv10 = avx128fma_invsqrt_f(rsq10);
1058 rinv20 = avx128fma_invsqrt_f(rsq20);
1059 rinv30 = avx128fma_invsqrt_f(rsq30);
1061 rinvsq00 = avx128fma_inv_f(rsq00);
1062 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1063 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1064 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
1066 /* Load parameters for j particles */
1067 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1068 charge+jnrC+0,charge+jnrD+0);
1069 vdwjidx0A = 2*vdwtype[jnrA+0];
1070 vdwjidx0B = 2*vdwtype[jnrB+0];
1071 vdwjidx0C = 2*vdwtype[jnrC+0];
1072 vdwjidx0D = 2*vdwtype[jnrD+0];
1074 fjx0 = _mm_setzero_ps();
1075 fjy0 = _mm_setzero_ps();
1076 fjz0 = _mm_setzero_ps();
1078 /**************************
1079 * CALCULATE INTERACTIONS *
1080 **************************/
1082 if (gmx_mm_any_lt(rsq00,rcutoff2))
1085 /* Compute parameters for interactions between i and j atoms */
1086 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1087 vdwparam+vdwioffset0+vdwjidx0B,
1088 vdwparam+vdwioffset0+vdwjidx0C,
1089 vdwparam+vdwioffset0+vdwjidx0D,
1092 /* LENNARD-JONES DISPERSION/REPULSION */
1094 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1095 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1097 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1101 fscal = _mm_and_ps(fscal,cutoff_mask);
1103 fscal = _mm_andnot_ps(dummy_mask,fscal);
1105 /* Update vectorial force */
1106 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1107 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1108 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1110 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1111 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1112 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1116 /**************************
1117 * CALCULATE INTERACTIONS *
1118 **************************/
1120 if (gmx_mm_any_lt(rsq10,rcutoff2))
1123 /* Compute parameters for interactions between i and j atoms */
1124 qq10 = _mm_mul_ps(iq1,jq0);
1126 /* REACTION-FIELD ELECTROSTATICS */
1127 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1129 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1133 fscal = _mm_and_ps(fscal,cutoff_mask);
1135 fscal = _mm_andnot_ps(dummy_mask,fscal);
1137 /* Update vectorial force */
1138 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1139 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1140 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1142 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1143 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1144 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1148 /**************************
1149 * CALCULATE INTERACTIONS *
1150 **************************/
1152 if (gmx_mm_any_lt(rsq20,rcutoff2))
1155 /* Compute parameters for interactions between i and j atoms */
1156 qq20 = _mm_mul_ps(iq2,jq0);
1158 /* REACTION-FIELD ELECTROSTATICS */
1159 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1161 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1165 fscal = _mm_and_ps(fscal,cutoff_mask);
1167 fscal = _mm_andnot_ps(dummy_mask,fscal);
1169 /* Update vectorial force */
1170 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1171 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1172 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1174 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1175 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1176 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1180 /**************************
1181 * CALCULATE INTERACTIONS *
1182 **************************/
1184 if (gmx_mm_any_lt(rsq30,rcutoff2))
1187 /* Compute parameters for interactions between i and j atoms */
1188 qq30 = _mm_mul_ps(iq3,jq0);
1190 /* REACTION-FIELD ELECTROSTATICS */
1191 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
1193 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
1197 fscal = _mm_and_ps(fscal,cutoff_mask);
1199 fscal = _mm_andnot_ps(dummy_mask,fscal);
1201 /* Update vectorial force */
1202 fix3 = _mm_macc_ps(dx30,fscal,fix3);
1203 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
1204 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
1206 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
1207 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
1208 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1212 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1213 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1214 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1215 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1217 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1219 /* Inner loop uses 132 flops */
1222 /* End of innermost loop */
1224 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1225 f+i_coord_offset,fshift+i_shift_offset);
1227 /* Increment number of inner iterations */
1228 inneriter += j_index_end - j_index_start;
1230 /* Outer loop uses 24 flops */
1233 /* Increment number of outer iterations */
1236 /* Update outer/inner flops */
1238 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);