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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.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_ElecEwSh_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
52 * Electrostatics interaction: Ewald
53 * VdW interaction: LennardJones
54 * Geometry: Water3-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_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;
89 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
90 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
91 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
93 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
94 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
97 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
100 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
101 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
103 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
104 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
106 __m128 dummy_mask,cutoff_mask;
107 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
108 __m128 one = _mm_set1_ps(1.0);
109 __m128 two = _mm_set1_ps(2.0);
115 jindex = nlist->jindex;
117 shiftidx = nlist->shift;
119 shiftvec = fr->shift_vec[0];
120 fshift = fr->fshift[0];
121 facel = _mm_set1_ps(fr->epsfac);
122 charge = mdatoms->chargeA;
123 nvdwtype = fr->ntype;
125 vdwtype = mdatoms->typeA;
127 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
128 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
129 beta2 = _mm_mul_ps(beta,beta);
130 beta3 = _mm_mul_ps(beta,beta2);
131 ewtab = fr->ic->tabq_coul_FDV0;
132 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
133 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
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 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
143 rcutoff_scalar = fr->rcoulomb;
144 rcutoff = _mm_set1_ps(rcutoff_scalar);
145 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
147 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
148 rvdw = _mm_set1_ps(fr->rvdw);
150 /* Avoid stupid compiler warnings */
151 jnrA = jnrB = jnrC = jnrD = 0;
160 for(iidx=0;iidx<4*DIM;iidx++)
165 /* Start outer loop over neighborlists */
166 for(iidx=0; iidx<nri; iidx++)
168 /* Load shift vector for this list */
169 i_shift_offset = DIM*shiftidx[iidx];
171 /* Load limits for loop over neighbors */
172 j_index_start = jindex[iidx];
173 j_index_end = jindex[iidx+1];
175 /* Get outer coordinate index */
177 i_coord_offset = DIM*inr;
179 /* Load i particle coords and add shift vector */
180 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
181 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
183 fix0 = _mm_setzero_ps();
184 fiy0 = _mm_setzero_ps();
185 fiz0 = _mm_setzero_ps();
186 fix1 = _mm_setzero_ps();
187 fiy1 = _mm_setzero_ps();
188 fiz1 = _mm_setzero_ps();
189 fix2 = _mm_setzero_ps();
190 fiy2 = _mm_setzero_ps();
191 fiz2 = _mm_setzero_ps();
193 /* Reset potential sums */
194 velecsum = _mm_setzero_ps();
195 vvdwsum = _mm_setzero_ps();
197 /* Start inner kernel loop */
198 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
201 /* Get j neighbor index, and coordinate index */
206 j_coord_offsetA = DIM*jnrA;
207 j_coord_offsetB = DIM*jnrB;
208 j_coord_offsetC = DIM*jnrC;
209 j_coord_offsetD = DIM*jnrD;
211 /* load j atom coordinates */
212 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
213 x+j_coord_offsetC,x+j_coord_offsetD,
216 /* Calculate displacement vector */
217 dx00 = _mm_sub_ps(ix0,jx0);
218 dy00 = _mm_sub_ps(iy0,jy0);
219 dz00 = _mm_sub_ps(iz0,jz0);
220 dx10 = _mm_sub_ps(ix1,jx0);
221 dy10 = _mm_sub_ps(iy1,jy0);
222 dz10 = _mm_sub_ps(iz1,jz0);
223 dx20 = _mm_sub_ps(ix2,jx0);
224 dy20 = _mm_sub_ps(iy2,jy0);
225 dz20 = _mm_sub_ps(iz2,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);
232 rinv00 = gmx_mm_invsqrt_ps(rsq00);
233 rinv10 = gmx_mm_invsqrt_ps(rsq10);
234 rinv20 = gmx_mm_invsqrt_ps(rsq20);
236 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
237 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
238 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
240 /* Load parameters for j particles */
241 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
242 charge+jnrC+0,charge+jnrD+0);
243 vdwjidx0A = 2*vdwtype[jnrA+0];
244 vdwjidx0B = 2*vdwtype[jnrB+0];
245 vdwjidx0C = 2*vdwtype[jnrC+0];
246 vdwjidx0D = 2*vdwtype[jnrD+0];
248 fjx0 = _mm_setzero_ps();
249 fjy0 = _mm_setzero_ps();
250 fjz0 = _mm_setzero_ps();
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 if (gmx_mm_any_lt(rsq00,rcutoff2))
259 r00 = _mm_mul_ps(rsq00,rinv00);
261 /* Compute parameters for interactions between i and j atoms */
262 qq00 = _mm_mul_ps(iq0,jq0);
263 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
264 vdwparam+vdwioffset0+vdwjidx0B,
265 vdwparam+vdwioffset0+vdwjidx0C,
266 vdwparam+vdwioffset0+vdwjidx0D,
269 /* EWALD ELECTROSTATICS */
271 /* Analytical PME correction */
272 zeta2 = _mm_mul_ps(beta2,rsq00);
273 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
274 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
275 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
276 felec = _mm_mul_ps(qq00,felec);
277 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
278 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
279 velec = _mm_mul_ps(qq00,velec);
281 /* LENNARD-JONES DISPERSION/REPULSION */
283 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
284 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
285 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
286 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
287 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
288 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
290 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
292 /* Update potential sum for this i atom from the interaction with this j atom. */
293 velec = _mm_and_ps(velec,cutoff_mask);
294 velecsum = _mm_add_ps(velecsum,velec);
295 vvdw = _mm_and_ps(vvdw,cutoff_mask);
296 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
298 fscal = _mm_add_ps(felec,fvdw);
300 fscal = _mm_and_ps(fscal,cutoff_mask);
302 /* Update vectorial force */
303 fix0 = _mm_macc_ps(dx00,fscal,fix0);
304 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
305 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
307 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
308 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
309 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
313 /**************************
314 * CALCULATE INTERACTIONS *
315 **************************/
317 if (gmx_mm_any_lt(rsq10,rcutoff2))
320 r10 = _mm_mul_ps(rsq10,rinv10);
322 /* Compute parameters for interactions between i and j atoms */
323 qq10 = _mm_mul_ps(iq1,jq0);
325 /* EWALD ELECTROSTATICS */
327 /* Analytical PME correction */
328 zeta2 = _mm_mul_ps(beta2,rsq10);
329 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
330 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
331 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
332 felec = _mm_mul_ps(qq10,felec);
333 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
334 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
335 velec = _mm_mul_ps(qq10,velec);
337 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
339 /* Update potential sum for this i atom from the interaction with this j atom. */
340 velec = _mm_and_ps(velec,cutoff_mask);
341 velecsum = _mm_add_ps(velecsum,velec);
345 fscal = _mm_and_ps(fscal,cutoff_mask);
347 /* Update vectorial force */
348 fix1 = _mm_macc_ps(dx10,fscal,fix1);
349 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
350 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
352 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
353 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
354 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
362 if (gmx_mm_any_lt(rsq20,rcutoff2))
365 r20 = _mm_mul_ps(rsq20,rinv20);
367 /* Compute parameters for interactions between i and j atoms */
368 qq20 = _mm_mul_ps(iq2,jq0);
370 /* EWALD ELECTROSTATICS */
372 /* Analytical PME correction */
373 zeta2 = _mm_mul_ps(beta2,rsq20);
374 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
375 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
376 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
377 felec = _mm_mul_ps(qq20,felec);
378 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
379 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
380 velec = _mm_mul_ps(qq20,velec);
382 cutoff_mask = _mm_cmplt_ps(rsq20,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 fix2 = _mm_macc_ps(dx20,fscal,fix2);
394 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
395 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
397 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
398 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
399 fjz0 = _mm_macc_ps(dz20,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 117 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);
451 /* Calculate squared distance and things based on it */
452 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
453 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
454 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
456 rinv00 = gmx_mm_invsqrt_ps(rsq00);
457 rinv10 = gmx_mm_invsqrt_ps(rsq10);
458 rinv20 = gmx_mm_invsqrt_ps(rsq20);
460 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
461 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
462 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
464 /* Load parameters for j particles */
465 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
466 charge+jnrC+0,charge+jnrD+0);
467 vdwjidx0A = 2*vdwtype[jnrA+0];
468 vdwjidx0B = 2*vdwtype[jnrB+0];
469 vdwjidx0C = 2*vdwtype[jnrC+0];
470 vdwjidx0D = 2*vdwtype[jnrD+0];
472 fjx0 = _mm_setzero_ps();
473 fjy0 = _mm_setzero_ps();
474 fjz0 = _mm_setzero_ps();
476 /**************************
477 * CALCULATE INTERACTIONS *
478 **************************/
480 if (gmx_mm_any_lt(rsq00,rcutoff2))
483 r00 = _mm_mul_ps(rsq00,rinv00);
484 r00 = _mm_andnot_ps(dummy_mask,r00);
486 /* Compute parameters for interactions between i and j atoms */
487 qq00 = _mm_mul_ps(iq0,jq0);
488 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
489 vdwparam+vdwioffset0+vdwjidx0B,
490 vdwparam+vdwioffset0+vdwjidx0C,
491 vdwparam+vdwioffset0+vdwjidx0D,
494 /* EWALD ELECTROSTATICS */
496 /* Analytical PME correction */
497 zeta2 = _mm_mul_ps(beta2,rsq00);
498 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
499 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
500 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
501 felec = _mm_mul_ps(qq00,felec);
502 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
503 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
504 velec = _mm_mul_ps(qq00,velec);
506 /* LENNARD-JONES DISPERSION/REPULSION */
508 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
509 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
510 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
511 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
512 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
513 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
515 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
517 /* Update potential sum for this i atom from the interaction with this j atom. */
518 velec = _mm_and_ps(velec,cutoff_mask);
519 velec = _mm_andnot_ps(dummy_mask,velec);
520 velecsum = _mm_add_ps(velecsum,velec);
521 vvdw = _mm_and_ps(vvdw,cutoff_mask);
522 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
523 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
525 fscal = _mm_add_ps(felec,fvdw);
527 fscal = _mm_and_ps(fscal,cutoff_mask);
529 fscal = _mm_andnot_ps(dummy_mask,fscal);
531 /* Update vectorial force */
532 fix0 = _mm_macc_ps(dx00,fscal,fix0);
533 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
534 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
536 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
537 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
538 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
542 /**************************
543 * CALCULATE INTERACTIONS *
544 **************************/
546 if (gmx_mm_any_lt(rsq10,rcutoff2))
549 r10 = _mm_mul_ps(rsq10,rinv10);
550 r10 = _mm_andnot_ps(dummy_mask,r10);
552 /* Compute parameters for interactions between i and j atoms */
553 qq10 = _mm_mul_ps(iq1,jq0);
555 /* EWALD ELECTROSTATICS */
557 /* Analytical PME correction */
558 zeta2 = _mm_mul_ps(beta2,rsq10);
559 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
560 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
561 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
562 felec = _mm_mul_ps(qq10,felec);
563 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
564 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
565 velec = _mm_mul_ps(qq10,velec);
567 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
569 /* Update potential sum for this i atom from the interaction with this j atom. */
570 velec = _mm_and_ps(velec,cutoff_mask);
571 velec = _mm_andnot_ps(dummy_mask,velec);
572 velecsum = _mm_add_ps(velecsum,velec);
576 fscal = _mm_and_ps(fscal,cutoff_mask);
578 fscal = _mm_andnot_ps(dummy_mask,fscal);
580 /* Update vectorial force */
581 fix1 = _mm_macc_ps(dx10,fscal,fix1);
582 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
583 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
585 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
586 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
587 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
595 if (gmx_mm_any_lt(rsq20,rcutoff2))
598 r20 = _mm_mul_ps(rsq20,rinv20);
599 r20 = _mm_andnot_ps(dummy_mask,r20);
601 /* Compute parameters for interactions between i and j atoms */
602 qq20 = _mm_mul_ps(iq2,jq0);
604 /* EWALD ELECTROSTATICS */
606 /* Analytical PME correction */
607 zeta2 = _mm_mul_ps(beta2,rsq20);
608 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
609 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
610 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
611 felec = _mm_mul_ps(qq20,felec);
612 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
613 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
614 velec = _mm_mul_ps(qq20,velec);
616 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
618 /* Update potential sum for this i atom from the interaction with this j atom. */
619 velec = _mm_and_ps(velec,cutoff_mask);
620 velec = _mm_andnot_ps(dummy_mask,velec);
621 velecsum = _mm_add_ps(velecsum,velec);
625 fscal = _mm_and_ps(fscal,cutoff_mask);
627 fscal = _mm_andnot_ps(dummy_mask,fscal);
629 /* Update vectorial force */
630 fix2 = _mm_macc_ps(dx20,fscal,fix2);
631 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
632 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
634 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
635 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
636 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
640 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
641 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
642 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
643 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
645 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
647 /* Inner loop uses 120 flops */
650 /* End of innermost loop */
652 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
653 f+i_coord_offset,fshift+i_shift_offset);
656 /* Update potential energies */
657 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
658 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
660 /* Increment number of inner iterations */
661 inneriter += j_index_end - j_index_start;
663 /* Outer loop uses 20 flops */
666 /* Increment number of outer iterations */
669 /* Update outer/inner flops */
671 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
674 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_F_avx_128_fma_single
675 * Electrostatics interaction: Ewald
676 * VdW interaction: LennardJones
677 * Geometry: Water3-Particle
678 * Calculate force/pot: Force
681 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_F_avx_128_fma_single
682 (t_nblist * gmx_restrict nlist,
683 rvec * gmx_restrict xx,
684 rvec * gmx_restrict ff,
685 t_forcerec * gmx_restrict fr,
686 t_mdatoms * gmx_restrict mdatoms,
687 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
688 t_nrnb * gmx_restrict nrnb)
690 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
691 * just 0 for non-waters.
692 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
693 * jnr indices corresponding to data put in the four positions in the SIMD register.
695 int i_shift_offset,i_coord_offset,outeriter,inneriter;
696 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
697 int jnrA,jnrB,jnrC,jnrD;
698 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
699 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
700 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
702 real *shiftvec,*fshift,*x,*f;
703 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
705 __m128 fscal,rcutoff,rcutoff2,jidxall;
707 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
709 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
711 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
712 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
713 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
714 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
715 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
716 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
717 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
720 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
723 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
724 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
726 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
727 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
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->epsfac);
745 charge = mdatoms->chargeA;
746 nvdwtype = fr->ntype;
748 vdwtype = mdatoms->typeA;
750 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
751 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
752 beta2 = _mm_mul_ps(beta,beta);
753 beta3 = _mm_mul_ps(beta,beta2);
754 ewtab = fr->ic->tabq_coul_F;
755 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
756 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
758 /* Setup water-specific parameters */
759 inr = nlist->iinr[0];
760 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
761 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
762 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
763 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
765 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
766 rcutoff_scalar = fr->rcoulomb;
767 rcutoff = _mm_set1_ps(rcutoff_scalar);
768 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
770 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
771 rvdw = _mm_set1_ps(fr->rvdw);
773 /* Avoid stupid compiler warnings */
774 jnrA = jnrB = jnrC = jnrD = 0;
783 for(iidx=0;iidx<4*DIM;iidx++)
788 /* Start outer loop over neighborlists */
789 for(iidx=0; iidx<nri; iidx++)
791 /* Load shift vector for this list */
792 i_shift_offset = DIM*shiftidx[iidx];
794 /* Load limits for loop over neighbors */
795 j_index_start = jindex[iidx];
796 j_index_end = jindex[iidx+1];
798 /* Get outer coordinate index */
800 i_coord_offset = DIM*inr;
802 /* Load i particle coords and add shift vector */
803 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
804 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
806 fix0 = _mm_setzero_ps();
807 fiy0 = _mm_setzero_ps();
808 fiz0 = _mm_setzero_ps();
809 fix1 = _mm_setzero_ps();
810 fiy1 = _mm_setzero_ps();
811 fiz1 = _mm_setzero_ps();
812 fix2 = _mm_setzero_ps();
813 fiy2 = _mm_setzero_ps();
814 fiz2 = _mm_setzero_ps();
816 /* Start inner kernel loop */
817 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
820 /* Get j neighbor index, and coordinate index */
825 j_coord_offsetA = DIM*jnrA;
826 j_coord_offsetB = DIM*jnrB;
827 j_coord_offsetC = DIM*jnrC;
828 j_coord_offsetD = DIM*jnrD;
830 /* load j atom coordinates */
831 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
832 x+j_coord_offsetC,x+j_coord_offsetD,
835 /* Calculate displacement vector */
836 dx00 = _mm_sub_ps(ix0,jx0);
837 dy00 = _mm_sub_ps(iy0,jy0);
838 dz00 = _mm_sub_ps(iz0,jz0);
839 dx10 = _mm_sub_ps(ix1,jx0);
840 dy10 = _mm_sub_ps(iy1,jy0);
841 dz10 = _mm_sub_ps(iz1,jz0);
842 dx20 = _mm_sub_ps(ix2,jx0);
843 dy20 = _mm_sub_ps(iy2,jy0);
844 dz20 = _mm_sub_ps(iz2,jz0);
846 /* Calculate squared distance and things based on it */
847 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
848 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
849 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
851 rinv00 = gmx_mm_invsqrt_ps(rsq00);
852 rinv10 = gmx_mm_invsqrt_ps(rsq10);
853 rinv20 = gmx_mm_invsqrt_ps(rsq20);
855 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
856 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
857 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
859 /* Load parameters for j particles */
860 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
861 charge+jnrC+0,charge+jnrD+0);
862 vdwjidx0A = 2*vdwtype[jnrA+0];
863 vdwjidx0B = 2*vdwtype[jnrB+0];
864 vdwjidx0C = 2*vdwtype[jnrC+0];
865 vdwjidx0D = 2*vdwtype[jnrD+0];
867 fjx0 = _mm_setzero_ps();
868 fjy0 = _mm_setzero_ps();
869 fjz0 = _mm_setzero_ps();
871 /**************************
872 * CALCULATE INTERACTIONS *
873 **************************/
875 if (gmx_mm_any_lt(rsq00,rcutoff2))
878 r00 = _mm_mul_ps(rsq00,rinv00);
880 /* Compute parameters for interactions between i and j atoms */
881 qq00 = _mm_mul_ps(iq0,jq0);
882 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
883 vdwparam+vdwioffset0+vdwjidx0B,
884 vdwparam+vdwioffset0+vdwjidx0C,
885 vdwparam+vdwioffset0+vdwjidx0D,
888 /* EWALD ELECTROSTATICS */
890 /* Analytical PME correction */
891 zeta2 = _mm_mul_ps(beta2,rsq00);
892 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
893 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
894 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
895 felec = _mm_mul_ps(qq00,felec);
897 /* LENNARD-JONES DISPERSION/REPULSION */
899 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
900 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
902 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
904 fscal = _mm_add_ps(felec,fvdw);
906 fscal = _mm_and_ps(fscal,cutoff_mask);
908 /* Update vectorial force */
909 fix0 = _mm_macc_ps(dx00,fscal,fix0);
910 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
911 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
913 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
914 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
915 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
919 /**************************
920 * CALCULATE INTERACTIONS *
921 **************************/
923 if (gmx_mm_any_lt(rsq10,rcutoff2))
926 r10 = _mm_mul_ps(rsq10,rinv10);
928 /* Compute parameters for interactions between i and j atoms */
929 qq10 = _mm_mul_ps(iq1,jq0);
931 /* EWALD ELECTROSTATICS */
933 /* Analytical PME correction */
934 zeta2 = _mm_mul_ps(beta2,rsq10);
935 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
936 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
937 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
938 felec = _mm_mul_ps(qq10,felec);
940 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
944 fscal = _mm_and_ps(fscal,cutoff_mask);
946 /* Update vectorial force */
947 fix1 = _mm_macc_ps(dx10,fscal,fix1);
948 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
949 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
951 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
952 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
953 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
961 if (gmx_mm_any_lt(rsq20,rcutoff2))
964 r20 = _mm_mul_ps(rsq20,rinv20);
966 /* Compute parameters for interactions between i and j atoms */
967 qq20 = _mm_mul_ps(iq2,jq0);
969 /* EWALD ELECTROSTATICS */
971 /* Analytical PME correction */
972 zeta2 = _mm_mul_ps(beta2,rsq20);
973 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
974 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
975 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
976 felec = _mm_mul_ps(qq20,felec);
978 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
982 fscal = _mm_and_ps(fscal,cutoff_mask);
984 /* Update vectorial force */
985 fix2 = _mm_macc_ps(dx20,fscal,fix2);
986 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
987 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
989 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
990 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
991 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
995 fjptrA = f+j_coord_offsetA;
996 fjptrB = f+j_coord_offsetB;
997 fjptrC = f+j_coord_offsetC;
998 fjptrD = f+j_coord_offsetD;
1000 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1002 /* Inner loop uses 100 flops */
1005 if(jidx<j_index_end)
1008 /* Get j neighbor index, and coordinate index */
1009 jnrlistA = jjnr[jidx];
1010 jnrlistB = jjnr[jidx+1];
1011 jnrlistC = jjnr[jidx+2];
1012 jnrlistD = jjnr[jidx+3];
1013 /* Sign of each element will be negative for non-real atoms.
1014 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1015 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1017 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1018 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1019 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1020 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1021 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1022 j_coord_offsetA = DIM*jnrA;
1023 j_coord_offsetB = DIM*jnrB;
1024 j_coord_offsetC = DIM*jnrC;
1025 j_coord_offsetD = DIM*jnrD;
1027 /* load j atom coordinates */
1028 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1029 x+j_coord_offsetC,x+j_coord_offsetD,
1032 /* Calculate displacement vector */
1033 dx00 = _mm_sub_ps(ix0,jx0);
1034 dy00 = _mm_sub_ps(iy0,jy0);
1035 dz00 = _mm_sub_ps(iz0,jz0);
1036 dx10 = _mm_sub_ps(ix1,jx0);
1037 dy10 = _mm_sub_ps(iy1,jy0);
1038 dz10 = _mm_sub_ps(iz1,jz0);
1039 dx20 = _mm_sub_ps(ix2,jx0);
1040 dy20 = _mm_sub_ps(iy2,jy0);
1041 dz20 = _mm_sub_ps(iz2,jz0);
1043 /* Calculate squared distance and things based on it */
1044 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1045 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1046 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1048 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1049 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1050 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1052 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1053 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1054 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1056 /* Load parameters for j particles */
1057 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1058 charge+jnrC+0,charge+jnrD+0);
1059 vdwjidx0A = 2*vdwtype[jnrA+0];
1060 vdwjidx0B = 2*vdwtype[jnrB+0];
1061 vdwjidx0C = 2*vdwtype[jnrC+0];
1062 vdwjidx0D = 2*vdwtype[jnrD+0];
1064 fjx0 = _mm_setzero_ps();
1065 fjy0 = _mm_setzero_ps();
1066 fjz0 = _mm_setzero_ps();
1068 /**************************
1069 * CALCULATE INTERACTIONS *
1070 **************************/
1072 if (gmx_mm_any_lt(rsq00,rcutoff2))
1075 r00 = _mm_mul_ps(rsq00,rinv00);
1076 r00 = _mm_andnot_ps(dummy_mask,r00);
1078 /* Compute parameters for interactions between i and j atoms */
1079 qq00 = _mm_mul_ps(iq0,jq0);
1080 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1081 vdwparam+vdwioffset0+vdwjidx0B,
1082 vdwparam+vdwioffset0+vdwjidx0C,
1083 vdwparam+vdwioffset0+vdwjidx0D,
1086 /* EWALD ELECTROSTATICS */
1088 /* Analytical PME correction */
1089 zeta2 = _mm_mul_ps(beta2,rsq00);
1090 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
1091 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1092 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1093 felec = _mm_mul_ps(qq00,felec);
1095 /* LENNARD-JONES DISPERSION/REPULSION */
1097 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1098 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1100 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1102 fscal = _mm_add_ps(felec,fvdw);
1104 fscal = _mm_and_ps(fscal,cutoff_mask);
1106 fscal = _mm_andnot_ps(dummy_mask,fscal);
1108 /* Update vectorial force */
1109 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1110 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1111 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1113 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1114 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1115 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1119 /**************************
1120 * CALCULATE INTERACTIONS *
1121 **************************/
1123 if (gmx_mm_any_lt(rsq10,rcutoff2))
1126 r10 = _mm_mul_ps(rsq10,rinv10);
1127 r10 = _mm_andnot_ps(dummy_mask,r10);
1129 /* Compute parameters for interactions between i and j atoms */
1130 qq10 = _mm_mul_ps(iq1,jq0);
1132 /* EWALD ELECTROSTATICS */
1134 /* Analytical PME correction */
1135 zeta2 = _mm_mul_ps(beta2,rsq10);
1136 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
1137 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1138 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1139 felec = _mm_mul_ps(qq10,felec);
1141 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1145 fscal = _mm_and_ps(fscal,cutoff_mask);
1147 fscal = _mm_andnot_ps(dummy_mask,fscal);
1149 /* Update vectorial force */
1150 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1151 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1152 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1154 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1155 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1156 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1160 /**************************
1161 * CALCULATE INTERACTIONS *
1162 **************************/
1164 if (gmx_mm_any_lt(rsq20,rcutoff2))
1167 r20 = _mm_mul_ps(rsq20,rinv20);
1168 r20 = _mm_andnot_ps(dummy_mask,r20);
1170 /* Compute parameters for interactions between i and j atoms */
1171 qq20 = _mm_mul_ps(iq2,jq0);
1173 /* EWALD ELECTROSTATICS */
1175 /* Analytical PME correction */
1176 zeta2 = _mm_mul_ps(beta2,rsq20);
1177 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
1178 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1179 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1180 felec = _mm_mul_ps(qq20,felec);
1182 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1186 fscal = _mm_and_ps(fscal,cutoff_mask);
1188 fscal = _mm_andnot_ps(dummy_mask,fscal);
1190 /* Update vectorial force */
1191 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1192 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1193 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1195 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1196 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1197 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1201 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1202 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1203 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1204 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1206 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1208 /* Inner loop uses 103 flops */
1211 /* End of innermost loop */
1213 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1214 f+i_coord_offset,fshift+i_shift_offset);
1216 /* Increment number of inner iterations */
1217 inneriter += j_index_end - j_index_start;
1219 /* Outer loop uses 18 flops */
1222 /* Increment number of outer iterations */
1225 /* Update outer/inner flops */
1227 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*103);