2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
49 #include "gmx_math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
54 * Electrostatics interaction: Ewald
55 * VdW interaction: LennardJones
56 * Geometry: Water3-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
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 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);
105 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
106 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
108 __m128 dummy_mask,cutoff_mask;
109 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
110 __m128 one = _mm_set1_ps(1.0);
111 __m128 two = _mm_set1_ps(2.0);
117 jindex = nlist->jindex;
119 shiftidx = nlist->shift;
121 shiftvec = fr->shift_vec[0];
122 fshift = fr->fshift[0];
123 facel = _mm_set1_ps(fr->epsfac);
124 charge = mdatoms->chargeA;
125 nvdwtype = fr->ntype;
127 vdwtype = mdatoms->typeA;
129 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
130 beta = _mm_set1_ps(fr->ic->ewaldcoeff);
131 beta2 = _mm_mul_ps(beta,beta);
132 beta3 = _mm_mul_ps(beta,beta2);
133 ewtab = fr->ic->tabq_coul_FDV0;
134 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
135 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
137 /* Setup water-specific parameters */
138 inr = nlist->iinr[0];
139 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
140 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
141 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
142 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
144 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
145 rcutoff_scalar = fr->rcoulomb;
146 rcutoff = _mm_set1_ps(rcutoff_scalar);
147 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
149 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
150 rvdw = _mm_set1_ps(fr->rvdw);
152 /* Avoid stupid compiler warnings */
153 jnrA = jnrB = jnrC = jnrD = 0;
162 for(iidx=0;iidx<4*DIM;iidx++)
167 /* Start outer loop over neighborlists */
168 for(iidx=0; iidx<nri; iidx++)
170 /* Load shift vector for this list */
171 i_shift_offset = DIM*shiftidx[iidx];
173 /* Load limits for loop over neighbors */
174 j_index_start = jindex[iidx];
175 j_index_end = jindex[iidx+1];
177 /* Get outer coordinate index */
179 i_coord_offset = DIM*inr;
181 /* Load i particle coords and add shift vector */
182 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
183 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
185 fix0 = _mm_setzero_ps();
186 fiy0 = _mm_setzero_ps();
187 fiz0 = _mm_setzero_ps();
188 fix1 = _mm_setzero_ps();
189 fiy1 = _mm_setzero_ps();
190 fiz1 = _mm_setzero_ps();
191 fix2 = _mm_setzero_ps();
192 fiy2 = _mm_setzero_ps();
193 fiz2 = _mm_setzero_ps();
195 /* Reset potential sums */
196 velecsum = _mm_setzero_ps();
197 vvdwsum = _mm_setzero_ps();
199 /* Start inner kernel loop */
200 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
203 /* Get j neighbor index, and coordinate index */
208 j_coord_offsetA = DIM*jnrA;
209 j_coord_offsetB = DIM*jnrB;
210 j_coord_offsetC = DIM*jnrC;
211 j_coord_offsetD = DIM*jnrD;
213 /* load j atom coordinates */
214 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
215 x+j_coord_offsetC,x+j_coord_offsetD,
218 /* Calculate displacement vector */
219 dx00 = _mm_sub_ps(ix0,jx0);
220 dy00 = _mm_sub_ps(iy0,jy0);
221 dz00 = _mm_sub_ps(iz0,jz0);
222 dx10 = _mm_sub_ps(ix1,jx0);
223 dy10 = _mm_sub_ps(iy1,jy0);
224 dz10 = _mm_sub_ps(iz1,jz0);
225 dx20 = _mm_sub_ps(ix2,jx0);
226 dy20 = _mm_sub_ps(iy2,jy0);
227 dz20 = _mm_sub_ps(iz2,jz0);
229 /* Calculate squared distance and things based on it */
230 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
231 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
232 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
234 rinv00 = gmx_mm_invsqrt_ps(rsq00);
235 rinv10 = gmx_mm_invsqrt_ps(rsq10);
236 rinv20 = gmx_mm_invsqrt_ps(rsq20);
238 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
239 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
240 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
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 r00 = _mm_mul_ps(rsq00,rinv00);
263 /* Compute parameters for interactions between i and j atoms */
264 qq00 = _mm_mul_ps(iq0,jq0);
265 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
266 vdwparam+vdwioffset0+vdwjidx0B,
267 vdwparam+vdwioffset0+vdwjidx0C,
268 vdwparam+vdwioffset0+vdwjidx0D,
271 /* EWALD ELECTROSTATICS */
273 /* Analytical PME correction */
274 zeta2 = _mm_mul_ps(beta2,rsq00);
275 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
276 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
277 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
278 felec = _mm_mul_ps(qq00,felec);
279 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
280 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
281 velec = _mm_mul_ps(qq00,velec);
283 /* LENNARD-JONES DISPERSION/REPULSION */
285 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
286 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
287 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
288 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
289 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
290 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
292 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
294 /* Update potential sum for this i atom from the interaction with this j atom. */
295 velec = _mm_and_ps(velec,cutoff_mask);
296 velecsum = _mm_add_ps(velecsum,velec);
297 vvdw = _mm_and_ps(vvdw,cutoff_mask);
298 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
300 fscal = _mm_add_ps(felec,fvdw);
302 fscal = _mm_and_ps(fscal,cutoff_mask);
304 /* Update vectorial force */
305 fix0 = _mm_macc_ps(dx00,fscal,fix0);
306 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
307 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
309 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
310 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
311 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
315 /**************************
316 * CALCULATE INTERACTIONS *
317 **************************/
319 if (gmx_mm_any_lt(rsq10,rcutoff2))
322 r10 = _mm_mul_ps(rsq10,rinv10);
324 /* Compute parameters for interactions between i and j atoms */
325 qq10 = _mm_mul_ps(iq1,jq0);
327 /* EWALD ELECTROSTATICS */
329 /* Analytical PME correction */
330 zeta2 = _mm_mul_ps(beta2,rsq10);
331 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
332 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
333 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
334 felec = _mm_mul_ps(qq10,felec);
335 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
336 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
337 velec = _mm_mul_ps(qq10,velec);
339 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
341 /* Update potential sum for this i atom from the interaction with this j atom. */
342 velec = _mm_and_ps(velec,cutoff_mask);
343 velecsum = _mm_add_ps(velecsum,velec);
347 fscal = _mm_and_ps(fscal,cutoff_mask);
349 /* Update vectorial force */
350 fix1 = _mm_macc_ps(dx10,fscal,fix1);
351 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
352 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
354 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
355 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
356 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
364 if (gmx_mm_any_lt(rsq20,rcutoff2))
367 r20 = _mm_mul_ps(rsq20,rinv20);
369 /* Compute parameters for interactions between i and j atoms */
370 qq20 = _mm_mul_ps(iq2,jq0);
372 /* EWALD ELECTROSTATICS */
374 /* Analytical PME correction */
375 zeta2 = _mm_mul_ps(beta2,rsq20);
376 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
377 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
378 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
379 felec = _mm_mul_ps(qq20,felec);
380 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
381 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
382 velec = _mm_mul_ps(qq20,velec);
384 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
386 /* Update potential sum for this i atom from the interaction with this j atom. */
387 velec = _mm_and_ps(velec,cutoff_mask);
388 velecsum = _mm_add_ps(velecsum,velec);
392 fscal = _mm_and_ps(fscal,cutoff_mask);
394 /* Update vectorial force */
395 fix2 = _mm_macc_ps(dx20,fscal,fix2);
396 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
397 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
399 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
400 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
401 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
405 fjptrA = f+j_coord_offsetA;
406 fjptrB = f+j_coord_offsetB;
407 fjptrC = f+j_coord_offsetC;
408 fjptrD = f+j_coord_offsetD;
410 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
412 /* Inner loop uses 117 flops */
418 /* Get j neighbor index, and coordinate index */
419 jnrlistA = jjnr[jidx];
420 jnrlistB = jjnr[jidx+1];
421 jnrlistC = jjnr[jidx+2];
422 jnrlistD = jjnr[jidx+3];
423 /* Sign of each element will be negative for non-real atoms.
424 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
425 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
427 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
428 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
429 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
430 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
431 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
432 j_coord_offsetA = DIM*jnrA;
433 j_coord_offsetB = DIM*jnrB;
434 j_coord_offsetC = DIM*jnrC;
435 j_coord_offsetD = DIM*jnrD;
437 /* load j atom coordinates */
438 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
439 x+j_coord_offsetC,x+j_coord_offsetD,
442 /* Calculate displacement vector */
443 dx00 = _mm_sub_ps(ix0,jx0);
444 dy00 = _mm_sub_ps(iy0,jy0);
445 dz00 = _mm_sub_ps(iz0,jz0);
446 dx10 = _mm_sub_ps(ix1,jx0);
447 dy10 = _mm_sub_ps(iy1,jy0);
448 dz10 = _mm_sub_ps(iz1,jz0);
449 dx20 = _mm_sub_ps(ix2,jx0);
450 dy20 = _mm_sub_ps(iy2,jy0);
451 dz20 = _mm_sub_ps(iz2,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);
458 rinv00 = gmx_mm_invsqrt_ps(rsq00);
459 rinv10 = gmx_mm_invsqrt_ps(rsq10);
460 rinv20 = gmx_mm_invsqrt_ps(rsq20);
462 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
463 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
464 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
466 /* Load parameters for j particles */
467 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
468 charge+jnrC+0,charge+jnrD+0);
469 vdwjidx0A = 2*vdwtype[jnrA+0];
470 vdwjidx0B = 2*vdwtype[jnrB+0];
471 vdwjidx0C = 2*vdwtype[jnrC+0];
472 vdwjidx0D = 2*vdwtype[jnrD+0];
474 fjx0 = _mm_setzero_ps();
475 fjy0 = _mm_setzero_ps();
476 fjz0 = _mm_setzero_ps();
478 /**************************
479 * CALCULATE INTERACTIONS *
480 **************************/
482 if (gmx_mm_any_lt(rsq00,rcutoff2))
485 r00 = _mm_mul_ps(rsq00,rinv00);
486 r00 = _mm_andnot_ps(dummy_mask,r00);
488 /* Compute parameters for interactions between i and j atoms */
489 qq00 = _mm_mul_ps(iq0,jq0);
490 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
491 vdwparam+vdwioffset0+vdwjidx0B,
492 vdwparam+vdwioffset0+vdwjidx0C,
493 vdwparam+vdwioffset0+vdwjidx0D,
496 /* EWALD ELECTROSTATICS */
498 /* Analytical PME correction */
499 zeta2 = _mm_mul_ps(beta2,rsq00);
500 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
501 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
502 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
503 felec = _mm_mul_ps(qq00,felec);
504 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
505 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
506 velec = _mm_mul_ps(qq00,velec);
508 /* LENNARD-JONES DISPERSION/REPULSION */
510 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
511 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
512 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
513 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
514 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
515 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
517 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
519 /* Update potential sum for this i atom from the interaction with this j atom. */
520 velec = _mm_and_ps(velec,cutoff_mask);
521 velec = _mm_andnot_ps(dummy_mask,velec);
522 velecsum = _mm_add_ps(velecsum,velec);
523 vvdw = _mm_and_ps(vvdw,cutoff_mask);
524 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
525 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
527 fscal = _mm_add_ps(felec,fvdw);
529 fscal = _mm_and_ps(fscal,cutoff_mask);
531 fscal = _mm_andnot_ps(dummy_mask,fscal);
533 /* Update vectorial force */
534 fix0 = _mm_macc_ps(dx00,fscal,fix0);
535 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
536 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
538 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
539 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
540 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
544 /**************************
545 * CALCULATE INTERACTIONS *
546 **************************/
548 if (gmx_mm_any_lt(rsq10,rcutoff2))
551 r10 = _mm_mul_ps(rsq10,rinv10);
552 r10 = _mm_andnot_ps(dummy_mask,r10);
554 /* Compute parameters for interactions between i and j atoms */
555 qq10 = _mm_mul_ps(iq1,jq0);
557 /* EWALD ELECTROSTATICS */
559 /* Analytical PME correction */
560 zeta2 = _mm_mul_ps(beta2,rsq10);
561 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
562 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
563 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
564 felec = _mm_mul_ps(qq10,felec);
565 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
566 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
567 velec = _mm_mul_ps(qq10,velec);
569 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
571 /* Update potential sum for this i atom from the interaction with this j atom. */
572 velec = _mm_and_ps(velec,cutoff_mask);
573 velec = _mm_andnot_ps(dummy_mask,velec);
574 velecsum = _mm_add_ps(velecsum,velec);
578 fscal = _mm_and_ps(fscal,cutoff_mask);
580 fscal = _mm_andnot_ps(dummy_mask,fscal);
582 /* Update vectorial force */
583 fix1 = _mm_macc_ps(dx10,fscal,fix1);
584 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
585 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
587 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
588 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
589 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
593 /**************************
594 * CALCULATE INTERACTIONS *
595 **************************/
597 if (gmx_mm_any_lt(rsq20,rcutoff2))
600 r20 = _mm_mul_ps(rsq20,rinv20);
601 r20 = _mm_andnot_ps(dummy_mask,r20);
603 /* Compute parameters for interactions between i and j atoms */
604 qq20 = _mm_mul_ps(iq2,jq0);
606 /* EWALD ELECTROSTATICS */
608 /* Analytical PME correction */
609 zeta2 = _mm_mul_ps(beta2,rsq20);
610 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
611 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
612 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
613 felec = _mm_mul_ps(qq20,felec);
614 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
615 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
616 velec = _mm_mul_ps(qq20,velec);
618 cutoff_mask = _mm_cmplt_ps(rsq20,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 fix2 = _mm_macc_ps(dx20,fscal,fix2);
633 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
634 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
636 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
637 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
638 fjz0 = _mm_macc_ps(dz20,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 120 flops */
652 /* End of innermost loop */
654 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
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 20 flops */
668 /* Increment number of outer iterations */
671 /* Update outer/inner flops */
673 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
676 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_F_avx_128_fma_single
677 * Electrostatics interaction: Ewald
678 * VdW interaction: LennardJones
679 * Geometry: Water3-Particle
680 * Calculate force/pot: Force
683 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_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;
714 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
715 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
716 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
717 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
718 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
719 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
722 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
725 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
726 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
728 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
729 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
731 __m128 dummy_mask,cutoff_mask;
732 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
733 __m128 one = _mm_set1_ps(1.0);
734 __m128 two = _mm_set1_ps(2.0);
740 jindex = nlist->jindex;
742 shiftidx = nlist->shift;
744 shiftvec = fr->shift_vec[0];
745 fshift = fr->fshift[0];
746 facel = _mm_set1_ps(fr->epsfac);
747 charge = mdatoms->chargeA;
748 nvdwtype = fr->ntype;
750 vdwtype = mdatoms->typeA;
752 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
753 beta = _mm_set1_ps(fr->ic->ewaldcoeff);
754 beta2 = _mm_mul_ps(beta,beta);
755 beta3 = _mm_mul_ps(beta,beta2);
756 ewtab = fr->ic->tabq_coul_F;
757 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
758 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
760 /* Setup water-specific parameters */
761 inr = nlist->iinr[0];
762 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
763 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
764 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
765 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
767 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
768 rcutoff_scalar = fr->rcoulomb;
769 rcutoff = _mm_set1_ps(rcutoff_scalar);
770 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
772 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
773 rvdw = _mm_set1_ps(fr->rvdw);
775 /* Avoid stupid compiler warnings */
776 jnrA = jnrB = jnrC = jnrD = 0;
785 for(iidx=0;iidx<4*DIM;iidx++)
790 /* Start outer loop over neighborlists */
791 for(iidx=0; iidx<nri; iidx++)
793 /* Load shift vector for this list */
794 i_shift_offset = DIM*shiftidx[iidx];
796 /* Load limits for loop over neighbors */
797 j_index_start = jindex[iidx];
798 j_index_end = jindex[iidx+1];
800 /* Get outer coordinate index */
802 i_coord_offset = DIM*inr;
804 /* Load i particle coords and add shift vector */
805 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
806 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
808 fix0 = _mm_setzero_ps();
809 fiy0 = _mm_setzero_ps();
810 fiz0 = _mm_setzero_ps();
811 fix1 = _mm_setzero_ps();
812 fiy1 = _mm_setzero_ps();
813 fiz1 = _mm_setzero_ps();
814 fix2 = _mm_setzero_ps();
815 fiy2 = _mm_setzero_ps();
816 fiz2 = _mm_setzero_ps();
818 /* Start inner kernel loop */
819 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
822 /* Get j neighbor index, and coordinate index */
827 j_coord_offsetA = DIM*jnrA;
828 j_coord_offsetB = DIM*jnrB;
829 j_coord_offsetC = DIM*jnrC;
830 j_coord_offsetD = DIM*jnrD;
832 /* load j atom coordinates */
833 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
834 x+j_coord_offsetC,x+j_coord_offsetD,
837 /* Calculate displacement vector */
838 dx00 = _mm_sub_ps(ix0,jx0);
839 dy00 = _mm_sub_ps(iy0,jy0);
840 dz00 = _mm_sub_ps(iz0,jz0);
841 dx10 = _mm_sub_ps(ix1,jx0);
842 dy10 = _mm_sub_ps(iy1,jy0);
843 dz10 = _mm_sub_ps(iz1,jz0);
844 dx20 = _mm_sub_ps(ix2,jx0);
845 dy20 = _mm_sub_ps(iy2,jy0);
846 dz20 = _mm_sub_ps(iz2,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);
853 rinv00 = gmx_mm_invsqrt_ps(rsq00);
854 rinv10 = gmx_mm_invsqrt_ps(rsq10);
855 rinv20 = gmx_mm_invsqrt_ps(rsq20);
857 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
858 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
859 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
861 /* Load parameters for j particles */
862 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
863 charge+jnrC+0,charge+jnrD+0);
864 vdwjidx0A = 2*vdwtype[jnrA+0];
865 vdwjidx0B = 2*vdwtype[jnrB+0];
866 vdwjidx0C = 2*vdwtype[jnrC+0];
867 vdwjidx0D = 2*vdwtype[jnrD+0];
869 fjx0 = _mm_setzero_ps();
870 fjy0 = _mm_setzero_ps();
871 fjz0 = _mm_setzero_ps();
873 /**************************
874 * CALCULATE INTERACTIONS *
875 **************************/
877 if (gmx_mm_any_lt(rsq00,rcutoff2))
880 r00 = _mm_mul_ps(rsq00,rinv00);
882 /* Compute parameters for interactions between i and j atoms */
883 qq00 = _mm_mul_ps(iq0,jq0);
884 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
885 vdwparam+vdwioffset0+vdwjidx0B,
886 vdwparam+vdwioffset0+vdwjidx0C,
887 vdwparam+vdwioffset0+vdwjidx0D,
890 /* EWALD ELECTROSTATICS */
892 /* Analytical PME correction */
893 zeta2 = _mm_mul_ps(beta2,rsq00);
894 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
895 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
896 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
897 felec = _mm_mul_ps(qq00,felec);
899 /* LENNARD-JONES DISPERSION/REPULSION */
901 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
902 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
904 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
906 fscal = _mm_add_ps(felec,fvdw);
908 fscal = _mm_and_ps(fscal,cutoff_mask);
910 /* Update vectorial force */
911 fix0 = _mm_macc_ps(dx00,fscal,fix0);
912 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
913 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
915 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
916 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
917 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
921 /**************************
922 * CALCULATE INTERACTIONS *
923 **************************/
925 if (gmx_mm_any_lt(rsq10,rcutoff2))
928 r10 = _mm_mul_ps(rsq10,rinv10);
930 /* Compute parameters for interactions between i and j atoms */
931 qq10 = _mm_mul_ps(iq1,jq0);
933 /* EWALD ELECTROSTATICS */
935 /* Analytical PME correction */
936 zeta2 = _mm_mul_ps(beta2,rsq10);
937 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
938 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
939 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
940 felec = _mm_mul_ps(qq10,felec);
942 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
946 fscal = _mm_and_ps(fscal,cutoff_mask);
948 /* Update vectorial force */
949 fix1 = _mm_macc_ps(dx10,fscal,fix1);
950 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
951 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
953 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
954 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
955 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
959 /**************************
960 * CALCULATE INTERACTIONS *
961 **************************/
963 if (gmx_mm_any_lt(rsq20,rcutoff2))
966 r20 = _mm_mul_ps(rsq20,rinv20);
968 /* Compute parameters for interactions between i and j atoms */
969 qq20 = _mm_mul_ps(iq2,jq0);
971 /* EWALD ELECTROSTATICS */
973 /* Analytical PME correction */
974 zeta2 = _mm_mul_ps(beta2,rsq20);
975 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
976 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
977 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
978 felec = _mm_mul_ps(qq20,felec);
980 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
984 fscal = _mm_and_ps(fscal,cutoff_mask);
986 /* Update vectorial force */
987 fix2 = _mm_macc_ps(dx20,fscal,fix2);
988 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
989 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
991 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
992 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
993 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
997 fjptrA = f+j_coord_offsetA;
998 fjptrB = f+j_coord_offsetB;
999 fjptrC = f+j_coord_offsetC;
1000 fjptrD = f+j_coord_offsetD;
1002 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1004 /* Inner loop uses 100 flops */
1007 if(jidx<j_index_end)
1010 /* Get j neighbor index, and coordinate index */
1011 jnrlistA = jjnr[jidx];
1012 jnrlistB = jjnr[jidx+1];
1013 jnrlistC = jjnr[jidx+2];
1014 jnrlistD = jjnr[jidx+3];
1015 /* Sign of each element will be negative for non-real atoms.
1016 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1017 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1019 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1020 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1021 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1022 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1023 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1024 j_coord_offsetA = DIM*jnrA;
1025 j_coord_offsetB = DIM*jnrB;
1026 j_coord_offsetC = DIM*jnrC;
1027 j_coord_offsetD = DIM*jnrD;
1029 /* load j atom coordinates */
1030 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1031 x+j_coord_offsetC,x+j_coord_offsetD,
1034 /* Calculate displacement vector */
1035 dx00 = _mm_sub_ps(ix0,jx0);
1036 dy00 = _mm_sub_ps(iy0,jy0);
1037 dz00 = _mm_sub_ps(iz0,jz0);
1038 dx10 = _mm_sub_ps(ix1,jx0);
1039 dy10 = _mm_sub_ps(iy1,jy0);
1040 dz10 = _mm_sub_ps(iz1,jz0);
1041 dx20 = _mm_sub_ps(ix2,jx0);
1042 dy20 = _mm_sub_ps(iy2,jy0);
1043 dz20 = _mm_sub_ps(iz2,jz0);
1045 /* Calculate squared distance and things based on it */
1046 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1047 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1048 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1050 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1051 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1052 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1054 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1055 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1056 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1058 /* Load parameters for j particles */
1059 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1060 charge+jnrC+0,charge+jnrD+0);
1061 vdwjidx0A = 2*vdwtype[jnrA+0];
1062 vdwjidx0B = 2*vdwtype[jnrB+0];
1063 vdwjidx0C = 2*vdwtype[jnrC+0];
1064 vdwjidx0D = 2*vdwtype[jnrD+0];
1066 fjx0 = _mm_setzero_ps();
1067 fjy0 = _mm_setzero_ps();
1068 fjz0 = _mm_setzero_ps();
1070 /**************************
1071 * CALCULATE INTERACTIONS *
1072 **************************/
1074 if (gmx_mm_any_lt(rsq00,rcutoff2))
1077 r00 = _mm_mul_ps(rsq00,rinv00);
1078 r00 = _mm_andnot_ps(dummy_mask,r00);
1080 /* Compute parameters for interactions between i and j atoms */
1081 qq00 = _mm_mul_ps(iq0,jq0);
1082 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1083 vdwparam+vdwioffset0+vdwjidx0B,
1084 vdwparam+vdwioffset0+vdwjidx0C,
1085 vdwparam+vdwioffset0+vdwjidx0D,
1088 /* EWALD ELECTROSTATICS */
1090 /* Analytical PME correction */
1091 zeta2 = _mm_mul_ps(beta2,rsq00);
1092 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
1093 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1094 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1095 felec = _mm_mul_ps(qq00,felec);
1097 /* LENNARD-JONES DISPERSION/REPULSION */
1099 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1100 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1102 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1104 fscal = _mm_add_ps(felec,fvdw);
1106 fscal = _mm_and_ps(fscal,cutoff_mask);
1108 fscal = _mm_andnot_ps(dummy_mask,fscal);
1110 /* Update vectorial force */
1111 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1112 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1113 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1115 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1116 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1117 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1125 if (gmx_mm_any_lt(rsq10,rcutoff2))
1128 r10 = _mm_mul_ps(rsq10,rinv10);
1129 r10 = _mm_andnot_ps(dummy_mask,r10);
1131 /* Compute parameters for interactions between i and j atoms */
1132 qq10 = _mm_mul_ps(iq1,jq0);
1134 /* EWALD ELECTROSTATICS */
1136 /* Analytical PME correction */
1137 zeta2 = _mm_mul_ps(beta2,rsq10);
1138 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
1139 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1140 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1141 felec = _mm_mul_ps(qq10,felec);
1143 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1147 fscal = _mm_and_ps(fscal,cutoff_mask);
1149 fscal = _mm_andnot_ps(dummy_mask,fscal);
1151 /* Update vectorial force */
1152 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1153 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1154 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1156 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1157 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1158 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1162 /**************************
1163 * CALCULATE INTERACTIONS *
1164 **************************/
1166 if (gmx_mm_any_lt(rsq20,rcutoff2))
1169 r20 = _mm_mul_ps(rsq20,rinv20);
1170 r20 = _mm_andnot_ps(dummy_mask,r20);
1172 /* Compute parameters for interactions between i and j atoms */
1173 qq20 = _mm_mul_ps(iq2,jq0);
1175 /* EWALD ELECTROSTATICS */
1177 /* Analytical PME correction */
1178 zeta2 = _mm_mul_ps(beta2,rsq20);
1179 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
1180 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1181 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1182 felec = _mm_mul_ps(qq20,felec);
1184 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1188 fscal = _mm_and_ps(fscal,cutoff_mask);
1190 fscal = _mm_andnot_ps(dummy_mask,fscal);
1192 /* Update vectorial force */
1193 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1194 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1195 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1197 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1198 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1199 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1203 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1204 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1205 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1206 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1208 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1210 /* Inner loop uses 103 flops */
1213 /* End of innermost loop */
1215 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1216 f+i_coord_offset,fshift+i_shift_offset);
1218 /* Increment number of inner iterations */
1219 inneriter += j_index_end - j_index_start;
1221 /* Outer loop uses 18 flops */
1224 /* Increment number of outer iterations */
1227 /* Update outer/inner flops */
1229 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*103);