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_single kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
48 #include "kernelutil_x86_avx_128_fma_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_avx_128_fma_single
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: LennardJones
54 * Geometry: Water4-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_avx_128_fma_single
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int jnrA,jnrB,jnrC,jnrD;
75 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
76 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
79 real *shiftvec,*fshift,*x,*f;
80 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
82 __m128 fscal,rcutoff,rcutoff2,jidxall;
84 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
86 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
88 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
90 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
97 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
100 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
103 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
104 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
105 __m128 dummy_mask,cutoff_mask;
106 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
107 __m128 one = _mm_set1_ps(1.0);
108 __m128 two = _mm_set1_ps(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_ps(fr->epsfac);
121 charge = mdatoms->chargeA;
122 krf = _mm_set1_ps(fr->ic->k_rf);
123 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
124 crf = _mm_set1_ps(fr->ic->c_rf);
125 nvdwtype = fr->ntype;
127 vdwtype = mdatoms->typeA;
129 /* Setup water-specific parameters */
130 inr = nlist->iinr[0];
131 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
132 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
133 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
134 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
136 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
137 rcutoff_scalar = fr->rcoulomb;
138 rcutoff = _mm_set1_ps(rcutoff_scalar);
139 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
141 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
142 rvdw = _mm_set1_ps(fr->rvdw);
144 /* Avoid stupid compiler warnings */
145 jnrA = jnrB = jnrC = jnrD = 0;
154 for(iidx=0;iidx<4*DIM;iidx++)
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
175 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
177 fix0 = _mm_setzero_ps();
178 fiy0 = _mm_setzero_ps();
179 fiz0 = _mm_setzero_ps();
180 fix1 = _mm_setzero_ps();
181 fiy1 = _mm_setzero_ps();
182 fiz1 = _mm_setzero_ps();
183 fix2 = _mm_setzero_ps();
184 fiy2 = _mm_setzero_ps();
185 fiz2 = _mm_setzero_ps();
186 fix3 = _mm_setzero_ps();
187 fiy3 = _mm_setzero_ps();
188 fiz3 = _mm_setzero_ps();
190 /* Reset potential sums */
191 velecsum = _mm_setzero_ps();
192 vvdwsum = _mm_setzero_ps();
194 /* Start inner kernel loop */
195 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
198 /* Get j neighbor index, and coordinate index */
203 j_coord_offsetA = DIM*jnrA;
204 j_coord_offsetB = DIM*jnrB;
205 j_coord_offsetC = DIM*jnrC;
206 j_coord_offsetD = DIM*jnrD;
208 /* load j atom coordinates */
209 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
210 x+j_coord_offsetC,x+j_coord_offsetD,
213 /* Calculate displacement vector */
214 dx00 = _mm_sub_ps(ix0,jx0);
215 dy00 = _mm_sub_ps(iy0,jy0);
216 dz00 = _mm_sub_ps(iz0,jz0);
217 dx10 = _mm_sub_ps(ix1,jx0);
218 dy10 = _mm_sub_ps(iy1,jy0);
219 dz10 = _mm_sub_ps(iz1,jz0);
220 dx20 = _mm_sub_ps(ix2,jx0);
221 dy20 = _mm_sub_ps(iy2,jy0);
222 dz20 = _mm_sub_ps(iz2,jz0);
223 dx30 = _mm_sub_ps(ix3,jx0);
224 dy30 = _mm_sub_ps(iy3,jy0);
225 dz30 = _mm_sub_ps(iz3,jz0);
227 /* Calculate squared distance and things based on it */
228 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
229 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
230 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
231 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
233 rinv10 = gmx_mm_invsqrt_ps(rsq10);
234 rinv20 = gmx_mm_invsqrt_ps(rsq20);
235 rinv30 = gmx_mm_invsqrt_ps(rsq30);
237 rinvsq00 = gmx_mm_inv_ps(rsq00);
238 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
239 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
240 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
242 /* Load parameters for j particles */
243 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
244 charge+jnrC+0,charge+jnrD+0);
245 vdwjidx0A = 2*vdwtype[jnrA+0];
246 vdwjidx0B = 2*vdwtype[jnrB+0];
247 vdwjidx0C = 2*vdwtype[jnrC+0];
248 vdwjidx0D = 2*vdwtype[jnrD+0];
250 fjx0 = _mm_setzero_ps();
251 fjy0 = _mm_setzero_ps();
252 fjz0 = _mm_setzero_ps();
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
258 if (gmx_mm_any_lt(rsq00,rcutoff2))
261 /* Compute parameters for interactions between i and j atoms */
262 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
263 vdwparam+vdwioffset0+vdwjidx0B,
264 vdwparam+vdwioffset0+vdwjidx0C,
265 vdwparam+vdwioffset0+vdwjidx0D,
268 /* LENNARD-JONES DISPERSION/REPULSION */
270 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
271 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
272 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
273 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
274 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
275 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
277 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
279 /* Update potential sum for this i atom from the interaction with this j atom. */
280 vvdw = _mm_and_ps(vvdw,cutoff_mask);
281 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
285 fscal = _mm_and_ps(fscal,cutoff_mask);
287 /* Update vectorial force */
288 fix0 = _mm_macc_ps(dx00,fscal,fix0);
289 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
290 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
292 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
293 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
294 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
302 if (gmx_mm_any_lt(rsq10,rcutoff2))
305 /* Compute parameters for interactions between i and j atoms */
306 qq10 = _mm_mul_ps(iq1,jq0);
308 /* REACTION-FIELD ELECTROSTATICS */
309 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
310 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
312 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
314 /* Update potential sum for this i atom from the interaction with this j atom. */
315 velec = _mm_and_ps(velec,cutoff_mask);
316 velecsum = _mm_add_ps(velecsum,velec);
320 fscal = _mm_and_ps(fscal,cutoff_mask);
322 /* Update vectorial force */
323 fix1 = _mm_macc_ps(dx10,fscal,fix1);
324 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
325 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
327 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
328 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
329 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
333 /**************************
334 * CALCULATE INTERACTIONS *
335 **************************/
337 if (gmx_mm_any_lt(rsq20,rcutoff2))
340 /* Compute parameters for interactions between i and j atoms */
341 qq20 = _mm_mul_ps(iq2,jq0);
343 /* REACTION-FIELD ELECTROSTATICS */
344 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
345 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
347 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
349 /* Update potential sum for this i atom from the interaction with this j atom. */
350 velec = _mm_and_ps(velec,cutoff_mask);
351 velecsum = _mm_add_ps(velecsum,velec);
355 fscal = _mm_and_ps(fscal,cutoff_mask);
357 /* Update vectorial force */
358 fix2 = _mm_macc_ps(dx20,fscal,fix2);
359 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
360 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
362 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
363 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
364 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
368 /**************************
369 * CALCULATE INTERACTIONS *
370 **************************/
372 if (gmx_mm_any_lt(rsq30,rcutoff2))
375 /* Compute parameters for interactions between i and j atoms */
376 qq30 = _mm_mul_ps(iq3,jq0);
378 /* REACTION-FIELD ELECTROSTATICS */
379 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
380 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
382 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
384 /* Update potential sum for this i atom from the interaction with this j atom. */
385 velec = _mm_and_ps(velec,cutoff_mask);
386 velecsum = _mm_add_ps(velecsum,velec);
390 fscal = _mm_and_ps(fscal,cutoff_mask);
392 /* Update vectorial force */
393 fix3 = _mm_macc_ps(dx30,fscal,fix3);
394 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
395 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
397 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
398 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
399 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
403 fjptrA = f+j_coord_offsetA;
404 fjptrB = f+j_coord_offsetB;
405 fjptrC = f+j_coord_offsetC;
406 fjptrD = f+j_coord_offsetD;
408 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
410 /* Inner loop uses 161 flops */
416 /* Get j neighbor index, and coordinate index */
417 jnrlistA = jjnr[jidx];
418 jnrlistB = jjnr[jidx+1];
419 jnrlistC = jjnr[jidx+2];
420 jnrlistD = jjnr[jidx+3];
421 /* Sign of each element will be negative for non-real atoms.
422 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
423 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
425 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
426 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
427 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
428 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
429 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
430 j_coord_offsetA = DIM*jnrA;
431 j_coord_offsetB = DIM*jnrB;
432 j_coord_offsetC = DIM*jnrC;
433 j_coord_offsetD = DIM*jnrD;
435 /* load j atom coordinates */
436 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
437 x+j_coord_offsetC,x+j_coord_offsetD,
440 /* Calculate displacement vector */
441 dx00 = _mm_sub_ps(ix0,jx0);
442 dy00 = _mm_sub_ps(iy0,jy0);
443 dz00 = _mm_sub_ps(iz0,jz0);
444 dx10 = _mm_sub_ps(ix1,jx0);
445 dy10 = _mm_sub_ps(iy1,jy0);
446 dz10 = _mm_sub_ps(iz1,jz0);
447 dx20 = _mm_sub_ps(ix2,jx0);
448 dy20 = _mm_sub_ps(iy2,jy0);
449 dz20 = _mm_sub_ps(iz2,jz0);
450 dx30 = _mm_sub_ps(ix3,jx0);
451 dy30 = _mm_sub_ps(iy3,jy0);
452 dz30 = _mm_sub_ps(iz3,jz0);
454 /* Calculate squared distance and things based on it */
455 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
456 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
457 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
458 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
460 rinv10 = gmx_mm_invsqrt_ps(rsq10);
461 rinv20 = gmx_mm_invsqrt_ps(rsq20);
462 rinv30 = gmx_mm_invsqrt_ps(rsq30);
464 rinvsq00 = gmx_mm_inv_ps(rsq00);
465 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
466 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
467 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
469 /* Load parameters for j particles */
470 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
471 charge+jnrC+0,charge+jnrD+0);
472 vdwjidx0A = 2*vdwtype[jnrA+0];
473 vdwjidx0B = 2*vdwtype[jnrB+0];
474 vdwjidx0C = 2*vdwtype[jnrC+0];
475 vdwjidx0D = 2*vdwtype[jnrD+0];
477 fjx0 = _mm_setzero_ps();
478 fjy0 = _mm_setzero_ps();
479 fjz0 = _mm_setzero_ps();
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
485 if (gmx_mm_any_lt(rsq00,rcutoff2))
488 /* Compute parameters for interactions between i and j atoms */
489 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
490 vdwparam+vdwioffset0+vdwjidx0B,
491 vdwparam+vdwioffset0+vdwjidx0C,
492 vdwparam+vdwioffset0+vdwjidx0D,
495 /* LENNARD-JONES DISPERSION/REPULSION */
497 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
498 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
499 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
500 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
501 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
502 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
504 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
506 /* Update potential sum for this i atom from the interaction with this j atom. */
507 vvdw = _mm_and_ps(vvdw,cutoff_mask);
508 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
509 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
513 fscal = _mm_and_ps(fscal,cutoff_mask);
515 fscal = _mm_andnot_ps(dummy_mask,fscal);
517 /* Update vectorial force */
518 fix0 = _mm_macc_ps(dx00,fscal,fix0);
519 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
520 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
522 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
523 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
524 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
532 if (gmx_mm_any_lt(rsq10,rcutoff2))
535 /* Compute parameters for interactions between i and j atoms */
536 qq10 = _mm_mul_ps(iq1,jq0);
538 /* REACTION-FIELD ELECTROSTATICS */
539 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
540 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
542 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
544 /* Update potential sum for this i atom from the interaction with this j atom. */
545 velec = _mm_and_ps(velec,cutoff_mask);
546 velec = _mm_andnot_ps(dummy_mask,velec);
547 velecsum = _mm_add_ps(velecsum,velec);
551 fscal = _mm_and_ps(fscal,cutoff_mask);
553 fscal = _mm_andnot_ps(dummy_mask,fscal);
555 /* Update vectorial force */
556 fix1 = _mm_macc_ps(dx10,fscal,fix1);
557 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
558 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
560 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
561 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
562 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
570 if (gmx_mm_any_lt(rsq20,rcutoff2))
573 /* Compute parameters for interactions between i and j atoms */
574 qq20 = _mm_mul_ps(iq2,jq0);
576 /* REACTION-FIELD ELECTROSTATICS */
577 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
578 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
580 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
582 /* Update potential sum for this i atom from the interaction with this j atom. */
583 velec = _mm_and_ps(velec,cutoff_mask);
584 velec = _mm_andnot_ps(dummy_mask,velec);
585 velecsum = _mm_add_ps(velecsum,velec);
589 fscal = _mm_and_ps(fscal,cutoff_mask);
591 fscal = _mm_andnot_ps(dummy_mask,fscal);
593 /* Update vectorial force */
594 fix2 = _mm_macc_ps(dx20,fscal,fix2);
595 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
596 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
598 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
599 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
600 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
604 /**************************
605 * CALCULATE INTERACTIONS *
606 **************************/
608 if (gmx_mm_any_lt(rsq30,rcutoff2))
611 /* Compute parameters for interactions between i and j atoms */
612 qq30 = _mm_mul_ps(iq3,jq0);
614 /* REACTION-FIELD ELECTROSTATICS */
615 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
616 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
618 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
620 /* Update potential sum for this i atom from the interaction with this j atom. */
621 velec = _mm_and_ps(velec,cutoff_mask);
622 velec = _mm_andnot_ps(dummy_mask,velec);
623 velecsum = _mm_add_ps(velecsum,velec);
627 fscal = _mm_and_ps(fscal,cutoff_mask);
629 fscal = _mm_andnot_ps(dummy_mask,fscal);
631 /* Update vectorial force */
632 fix3 = _mm_macc_ps(dx30,fscal,fix3);
633 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
634 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
636 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
637 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
638 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
642 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
643 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
644 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
645 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
647 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
649 /* Inner loop uses 161 flops */
652 /* End of innermost loop */
654 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
655 f+i_coord_offset,fshift+i_shift_offset);
658 /* Update potential energies */
659 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
660 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
662 /* Increment number of inner iterations */
663 inneriter += j_index_end - j_index_start;
665 /* Outer loop uses 26 flops */
668 /* Increment number of outer iterations */
671 /* Update outer/inner flops */
673 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*161);
676 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
677 * Electrostatics interaction: ReactionField
678 * VdW interaction: LennardJones
679 * Geometry: Water4-Particle
680 * Calculate force/pot: Force
683 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
684 (t_nblist * gmx_restrict nlist,
685 rvec * gmx_restrict xx,
686 rvec * gmx_restrict ff,
687 t_forcerec * gmx_restrict fr,
688 t_mdatoms * gmx_restrict mdatoms,
689 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
690 t_nrnb * gmx_restrict nrnb)
692 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
693 * just 0 for non-waters.
694 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
695 * jnr indices corresponding to data put in the four positions in the SIMD register.
697 int i_shift_offset,i_coord_offset,outeriter,inneriter;
698 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
699 int jnrA,jnrB,jnrC,jnrD;
700 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
701 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
702 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
704 real *shiftvec,*fshift,*x,*f;
705 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
707 __m128 fscal,rcutoff,rcutoff2,jidxall;
709 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
711 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
713 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
715 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
716 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
717 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
718 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
719 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
720 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
721 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
722 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
725 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
728 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
729 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
730 __m128 dummy_mask,cutoff_mask;
731 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
732 __m128 one = _mm_set1_ps(1.0);
733 __m128 two = _mm_set1_ps(2.0);
739 jindex = nlist->jindex;
741 shiftidx = nlist->shift;
743 shiftvec = fr->shift_vec[0];
744 fshift = fr->fshift[0];
745 facel = _mm_set1_ps(fr->epsfac);
746 charge = mdatoms->chargeA;
747 krf = _mm_set1_ps(fr->ic->k_rf);
748 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
749 crf = _mm_set1_ps(fr->ic->c_rf);
750 nvdwtype = fr->ntype;
752 vdwtype = mdatoms->typeA;
754 /* Setup water-specific parameters */
755 inr = nlist->iinr[0];
756 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
757 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
758 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
759 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
761 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
762 rcutoff_scalar = fr->rcoulomb;
763 rcutoff = _mm_set1_ps(rcutoff_scalar);
764 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
766 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
767 rvdw = _mm_set1_ps(fr->rvdw);
769 /* Avoid stupid compiler warnings */
770 jnrA = jnrB = jnrC = jnrD = 0;
779 for(iidx=0;iidx<4*DIM;iidx++)
784 /* Start outer loop over neighborlists */
785 for(iidx=0; iidx<nri; iidx++)
787 /* Load shift vector for this list */
788 i_shift_offset = DIM*shiftidx[iidx];
790 /* Load limits for loop over neighbors */
791 j_index_start = jindex[iidx];
792 j_index_end = jindex[iidx+1];
794 /* Get outer coordinate index */
796 i_coord_offset = DIM*inr;
798 /* Load i particle coords and add shift vector */
799 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
800 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
802 fix0 = _mm_setzero_ps();
803 fiy0 = _mm_setzero_ps();
804 fiz0 = _mm_setzero_ps();
805 fix1 = _mm_setzero_ps();
806 fiy1 = _mm_setzero_ps();
807 fiz1 = _mm_setzero_ps();
808 fix2 = _mm_setzero_ps();
809 fiy2 = _mm_setzero_ps();
810 fiz2 = _mm_setzero_ps();
811 fix3 = _mm_setzero_ps();
812 fiy3 = _mm_setzero_ps();
813 fiz3 = _mm_setzero_ps();
815 /* Start inner kernel loop */
816 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
819 /* Get j neighbor index, and coordinate index */
824 j_coord_offsetA = DIM*jnrA;
825 j_coord_offsetB = DIM*jnrB;
826 j_coord_offsetC = DIM*jnrC;
827 j_coord_offsetD = DIM*jnrD;
829 /* load j atom coordinates */
830 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
831 x+j_coord_offsetC,x+j_coord_offsetD,
834 /* Calculate displacement vector */
835 dx00 = _mm_sub_ps(ix0,jx0);
836 dy00 = _mm_sub_ps(iy0,jy0);
837 dz00 = _mm_sub_ps(iz0,jz0);
838 dx10 = _mm_sub_ps(ix1,jx0);
839 dy10 = _mm_sub_ps(iy1,jy0);
840 dz10 = _mm_sub_ps(iz1,jz0);
841 dx20 = _mm_sub_ps(ix2,jx0);
842 dy20 = _mm_sub_ps(iy2,jy0);
843 dz20 = _mm_sub_ps(iz2,jz0);
844 dx30 = _mm_sub_ps(ix3,jx0);
845 dy30 = _mm_sub_ps(iy3,jy0);
846 dz30 = _mm_sub_ps(iz3,jz0);
848 /* Calculate squared distance and things based on it */
849 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
850 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
851 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
852 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
854 rinv10 = gmx_mm_invsqrt_ps(rsq10);
855 rinv20 = gmx_mm_invsqrt_ps(rsq20);
856 rinv30 = gmx_mm_invsqrt_ps(rsq30);
858 rinvsq00 = gmx_mm_inv_ps(rsq00);
859 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
860 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
861 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
863 /* Load parameters for j particles */
864 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
865 charge+jnrC+0,charge+jnrD+0);
866 vdwjidx0A = 2*vdwtype[jnrA+0];
867 vdwjidx0B = 2*vdwtype[jnrB+0];
868 vdwjidx0C = 2*vdwtype[jnrC+0];
869 vdwjidx0D = 2*vdwtype[jnrD+0];
871 fjx0 = _mm_setzero_ps();
872 fjy0 = _mm_setzero_ps();
873 fjz0 = _mm_setzero_ps();
875 /**************************
876 * CALCULATE INTERACTIONS *
877 **************************/
879 if (gmx_mm_any_lt(rsq00,rcutoff2))
882 /* Compute parameters for interactions between i and j atoms */
883 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
884 vdwparam+vdwioffset0+vdwjidx0B,
885 vdwparam+vdwioffset0+vdwjidx0C,
886 vdwparam+vdwioffset0+vdwjidx0D,
889 /* LENNARD-JONES DISPERSION/REPULSION */
891 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
892 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
894 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
898 fscal = _mm_and_ps(fscal,cutoff_mask);
900 /* Update vectorial force */
901 fix0 = _mm_macc_ps(dx00,fscal,fix0);
902 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
903 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
905 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
906 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
907 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
911 /**************************
912 * CALCULATE INTERACTIONS *
913 **************************/
915 if (gmx_mm_any_lt(rsq10,rcutoff2))
918 /* Compute parameters for interactions between i and j atoms */
919 qq10 = _mm_mul_ps(iq1,jq0);
921 /* REACTION-FIELD ELECTROSTATICS */
922 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
924 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
928 fscal = _mm_and_ps(fscal,cutoff_mask);
930 /* Update vectorial force */
931 fix1 = _mm_macc_ps(dx10,fscal,fix1);
932 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
933 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
935 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
936 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
937 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
941 /**************************
942 * CALCULATE INTERACTIONS *
943 **************************/
945 if (gmx_mm_any_lt(rsq20,rcutoff2))
948 /* Compute parameters for interactions between i and j atoms */
949 qq20 = _mm_mul_ps(iq2,jq0);
951 /* REACTION-FIELD ELECTROSTATICS */
952 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
954 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
958 fscal = _mm_and_ps(fscal,cutoff_mask);
960 /* Update vectorial force */
961 fix2 = _mm_macc_ps(dx20,fscal,fix2);
962 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
963 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
965 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
966 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
967 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
975 if (gmx_mm_any_lt(rsq30,rcutoff2))
978 /* Compute parameters for interactions between i and j atoms */
979 qq30 = _mm_mul_ps(iq3,jq0);
981 /* REACTION-FIELD ELECTROSTATICS */
982 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
984 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
988 fscal = _mm_and_ps(fscal,cutoff_mask);
990 /* Update vectorial force */
991 fix3 = _mm_macc_ps(dx30,fscal,fix3);
992 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
993 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
995 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
996 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
997 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1001 fjptrA = f+j_coord_offsetA;
1002 fjptrB = f+j_coord_offsetB;
1003 fjptrC = f+j_coord_offsetC;
1004 fjptrD = f+j_coord_offsetD;
1006 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1008 /* Inner loop uses 132 flops */
1011 if(jidx<j_index_end)
1014 /* Get j neighbor index, and coordinate index */
1015 jnrlistA = jjnr[jidx];
1016 jnrlistB = jjnr[jidx+1];
1017 jnrlistC = jjnr[jidx+2];
1018 jnrlistD = jjnr[jidx+3];
1019 /* Sign of each element will be negative for non-real atoms.
1020 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1021 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1023 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1024 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1025 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1026 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1027 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1028 j_coord_offsetA = DIM*jnrA;
1029 j_coord_offsetB = DIM*jnrB;
1030 j_coord_offsetC = DIM*jnrC;
1031 j_coord_offsetD = DIM*jnrD;
1033 /* load j atom coordinates */
1034 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1035 x+j_coord_offsetC,x+j_coord_offsetD,
1038 /* Calculate displacement vector */
1039 dx00 = _mm_sub_ps(ix0,jx0);
1040 dy00 = _mm_sub_ps(iy0,jy0);
1041 dz00 = _mm_sub_ps(iz0,jz0);
1042 dx10 = _mm_sub_ps(ix1,jx0);
1043 dy10 = _mm_sub_ps(iy1,jy0);
1044 dz10 = _mm_sub_ps(iz1,jz0);
1045 dx20 = _mm_sub_ps(ix2,jx0);
1046 dy20 = _mm_sub_ps(iy2,jy0);
1047 dz20 = _mm_sub_ps(iz2,jz0);
1048 dx30 = _mm_sub_ps(ix3,jx0);
1049 dy30 = _mm_sub_ps(iy3,jy0);
1050 dz30 = _mm_sub_ps(iz3,jz0);
1052 /* Calculate squared distance and things based on it */
1053 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1054 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1055 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1056 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
1058 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1059 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1060 rinv30 = gmx_mm_invsqrt_ps(rsq30);
1062 rinvsq00 = gmx_mm_inv_ps(rsq00);
1063 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1064 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1065 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
1067 /* Load parameters for j particles */
1068 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1069 charge+jnrC+0,charge+jnrD+0);
1070 vdwjidx0A = 2*vdwtype[jnrA+0];
1071 vdwjidx0B = 2*vdwtype[jnrB+0];
1072 vdwjidx0C = 2*vdwtype[jnrC+0];
1073 vdwjidx0D = 2*vdwtype[jnrD+0];
1075 fjx0 = _mm_setzero_ps();
1076 fjy0 = _mm_setzero_ps();
1077 fjz0 = _mm_setzero_ps();
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1083 if (gmx_mm_any_lt(rsq00,rcutoff2))
1086 /* Compute parameters for interactions between i and j atoms */
1087 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1088 vdwparam+vdwioffset0+vdwjidx0B,
1089 vdwparam+vdwioffset0+vdwjidx0C,
1090 vdwparam+vdwioffset0+vdwjidx0D,
1093 /* LENNARD-JONES DISPERSION/REPULSION */
1095 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1096 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1098 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1102 fscal = _mm_and_ps(fscal,cutoff_mask);
1104 fscal = _mm_andnot_ps(dummy_mask,fscal);
1106 /* Update vectorial force */
1107 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1108 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1109 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1111 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1112 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1113 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1117 /**************************
1118 * CALCULATE INTERACTIONS *
1119 **************************/
1121 if (gmx_mm_any_lt(rsq10,rcutoff2))
1124 /* Compute parameters for interactions between i and j atoms */
1125 qq10 = _mm_mul_ps(iq1,jq0);
1127 /* REACTION-FIELD ELECTROSTATICS */
1128 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1130 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1134 fscal = _mm_and_ps(fscal,cutoff_mask);
1136 fscal = _mm_andnot_ps(dummy_mask,fscal);
1138 /* Update vectorial force */
1139 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1140 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1141 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1143 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1144 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1145 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1149 /**************************
1150 * CALCULATE INTERACTIONS *
1151 **************************/
1153 if (gmx_mm_any_lt(rsq20,rcutoff2))
1156 /* Compute parameters for interactions between i and j atoms */
1157 qq20 = _mm_mul_ps(iq2,jq0);
1159 /* REACTION-FIELD ELECTROSTATICS */
1160 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1162 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1166 fscal = _mm_and_ps(fscal,cutoff_mask);
1168 fscal = _mm_andnot_ps(dummy_mask,fscal);
1170 /* Update vectorial force */
1171 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1172 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1173 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1175 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1176 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1177 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1181 /**************************
1182 * CALCULATE INTERACTIONS *
1183 **************************/
1185 if (gmx_mm_any_lt(rsq30,rcutoff2))
1188 /* Compute parameters for interactions between i and j atoms */
1189 qq30 = _mm_mul_ps(iq3,jq0);
1191 /* REACTION-FIELD ELECTROSTATICS */
1192 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
1194 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
1198 fscal = _mm_and_ps(fscal,cutoff_mask);
1200 fscal = _mm_andnot_ps(dummy_mask,fscal);
1202 /* Update vectorial force */
1203 fix3 = _mm_macc_ps(dx30,fscal,fix3);
1204 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
1205 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
1207 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
1208 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
1209 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1213 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1214 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1215 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1216 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1218 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1220 /* Inner loop uses 132 flops */
1223 /* End of innermost loop */
1225 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1226 f+i_coord_offset,fshift+i_shift_offset);
1228 /* Increment number of inner iterations */
1229 inneriter += j_index_end - j_index_start;
1231 /* Outer loop uses 24 flops */
1234 /* Increment number of outer iterations */
1237 /* Update outer/inner flops */
1239 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);