2 * Note: this file was generated by the Gromacs avx_128_fma_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_single.h"
34 #include "kernelutil_x86_avx_128_fma_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
38 * Electrostatics interaction: Ewald
39 * VdW interaction: LennardJones
40 * Geometry: Water3-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
62 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
63 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
65 real *shiftvec,*fshift,*x,*f;
66 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
68 __m128 fscal,rcutoff,rcutoff2,jidxall;
70 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
75 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
76 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
77 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
78 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
79 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
80 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
83 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
86 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
87 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
89 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
90 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
92 __m128 dummy_mask,cutoff_mask;
93 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
94 __m128 one = _mm_set1_ps(1.0);
95 __m128 two = _mm_set1_ps(2.0);
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
107 facel = _mm_set1_ps(fr->epsfac);
108 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
114 beta = _mm_set1_ps(fr->ic->ewaldcoeff);
115 beta2 = _mm_mul_ps(beta,beta);
116 beta3 = _mm_mul_ps(beta,beta2);
117 ewtab = fr->ic->tabq_coul_FDV0;
118 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
119 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
121 /* Setup water-specific parameters */
122 inr = nlist->iinr[0];
123 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
124 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
125 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
126 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
128 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
129 rcutoff_scalar = fr->rcoulomb;
130 rcutoff = _mm_set1_ps(rcutoff_scalar);
131 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
133 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
134 rvdw = _mm_set1_ps(fr->rvdw);
136 /* Avoid stupid compiler warnings */
137 jnrA = jnrB = jnrC = jnrD = 0;
146 for(iidx=0;iidx<4*DIM;iidx++)
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
157 /* Load limits for loop over neighbors */
158 j_index_start = jindex[iidx];
159 j_index_end = jindex[iidx+1];
161 /* Get outer coordinate index */
163 i_coord_offset = DIM*inr;
165 /* Load i particle coords and add shift vector */
166 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
167 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
169 fix0 = _mm_setzero_ps();
170 fiy0 = _mm_setzero_ps();
171 fiz0 = _mm_setzero_ps();
172 fix1 = _mm_setzero_ps();
173 fiy1 = _mm_setzero_ps();
174 fiz1 = _mm_setzero_ps();
175 fix2 = _mm_setzero_ps();
176 fiy2 = _mm_setzero_ps();
177 fiz2 = _mm_setzero_ps();
179 /* Reset potential sums */
180 velecsum = _mm_setzero_ps();
181 vvdwsum = _mm_setzero_ps();
183 /* Start inner kernel loop */
184 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
187 /* Get j neighbor index, and coordinate index */
192 j_coord_offsetA = DIM*jnrA;
193 j_coord_offsetB = DIM*jnrB;
194 j_coord_offsetC = DIM*jnrC;
195 j_coord_offsetD = DIM*jnrD;
197 /* load j atom coordinates */
198 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
199 x+j_coord_offsetC,x+j_coord_offsetD,
202 /* Calculate displacement vector */
203 dx00 = _mm_sub_ps(ix0,jx0);
204 dy00 = _mm_sub_ps(iy0,jy0);
205 dz00 = _mm_sub_ps(iz0,jz0);
206 dx10 = _mm_sub_ps(ix1,jx0);
207 dy10 = _mm_sub_ps(iy1,jy0);
208 dz10 = _mm_sub_ps(iz1,jz0);
209 dx20 = _mm_sub_ps(ix2,jx0);
210 dy20 = _mm_sub_ps(iy2,jy0);
211 dz20 = _mm_sub_ps(iz2,jz0);
213 /* Calculate squared distance and things based on it */
214 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
215 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
216 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
218 rinv00 = gmx_mm_invsqrt_ps(rsq00);
219 rinv10 = gmx_mm_invsqrt_ps(rsq10);
220 rinv20 = gmx_mm_invsqrt_ps(rsq20);
222 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
223 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
224 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
226 /* Load parameters for j particles */
227 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
228 charge+jnrC+0,charge+jnrD+0);
229 vdwjidx0A = 2*vdwtype[jnrA+0];
230 vdwjidx0B = 2*vdwtype[jnrB+0];
231 vdwjidx0C = 2*vdwtype[jnrC+0];
232 vdwjidx0D = 2*vdwtype[jnrD+0];
234 fjx0 = _mm_setzero_ps();
235 fjy0 = _mm_setzero_ps();
236 fjz0 = _mm_setzero_ps();
238 /**************************
239 * CALCULATE INTERACTIONS *
240 **************************/
242 if (gmx_mm_any_lt(rsq00,rcutoff2))
245 r00 = _mm_mul_ps(rsq00,rinv00);
247 /* Compute parameters for interactions between i and j atoms */
248 qq00 = _mm_mul_ps(iq0,jq0);
249 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
250 vdwparam+vdwioffset0+vdwjidx0B,
251 vdwparam+vdwioffset0+vdwjidx0C,
252 vdwparam+vdwioffset0+vdwjidx0D,
255 /* EWALD ELECTROSTATICS */
257 /* Analytical PME correction */
258 zeta2 = _mm_mul_ps(beta2,rsq00);
259 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
260 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
261 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
262 felec = _mm_mul_ps(qq00,felec);
263 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
264 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
265 velec = _mm_mul_ps(qq00,velec);
267 /* LENNARD-JONES DISPERSION/REPULSION */
269 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
270 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
271 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
272 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
273 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
274 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
276 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
278 /* Update potential sum for this i atom from the interaction with this j atom. */
279 velec = _mm_and_ps(velec,cutoff_mask);
280 velecsum = _mm_add_ps(velecsum,velec);
281 vvdw = _mm_and_ps(vvdw,cutoff_mask);
282 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
284 fscal = _mm_add_ps(felec,fvdw);
286 fscal = _mm_and_ps(fscal,cutoff_mask);
288 /* Update vectorial force */
289 fix0 = _mm_macc_ps(dx00,fscal,fix0);
290 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
291 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
293 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
294 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
295 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
303 if (gmx_mm_any_lt(rsq10,rcutoff2))
306 r10 = _mm_mul_ps(rsq10,rinv10);
308 /* Compute parameters for interactions between i and j atoms */
309 qq10 = _mm_mul_ps(iq1,jq0);
311 /* EWALD ELECTROSTATICS */
313 /* Analytical PME correction */
314 zeta2 = _mm_mul_ps(beta2,rsq10);
315 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
316 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
317 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
318 felec = _mm_mul_ps(qq10,felec);
319 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
320 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
321 velec = _mm_mul_ps(qq10,velec);
323 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
325 /* Update potential sum for this i atom from the interaction with this j atom. */
326 velec = _mm_and_ps(velec,cutoff_mask);
327 velecsum = _mm_add_ps(velecsum,velec);
331 fscal = _mm_and_ps(fscal,cutoff_mask);
333 /* Update vectorial force */
334 fix1 = _mm_macc_ps(dx10,fscal,fix1);
335 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
336 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
338 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
339 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
340 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
344 /**************************
345 * CALCULATE INTERACTIONS *
346 **************************/
348 if (gmx_mm_any_lt(rsq20,rcutoff2))
351 r20 = _mm_mul_ps(rsq20,rinv20);
353 /* Compute parameters for interactions between i and j atoms */
354 qq20 = _mm_mul_ps(iq2,jq0);
356 /* EWALD ELECTROSTATICS */
358 /* Analytical PME correction */
359 zeta2 = _mm_mul_ps(beta2,rsq20);
360 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
361 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
362 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
363 felec = _mm_mul_ps(qq20,felec);
364 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
365 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
366 velec = _mm_mul_ps(qq20,velec);
368 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
370 /* Update potential sum for this i atom from the interaction with this j atom. */
371 velec = _mm_and_ps(velec,cutoff_mask);
372 velecsum = _mm_add_ps(velecsum,velec);
376 fscal = _mm_and_ps(fscal,cutoff_mask);
378 /* Update vectorial force */
379 fix2 = _mm_macc_ps(dx20,fscal,fix2);
380 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
381 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
383 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
384 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
385 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
389 fjptrA = f+j_coord_offsetA;
390 fjptrB = f+j_coord_offsetB;
391 fjptrC = f+j_coord_offsetC;
392 fjptrD = f+j_coord_offsetD;
394 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
396 /* Inner loop uses 117 flops */
402 /* Get j neighbor index, and coordinate index */
403 jnrlistA = jjnr[jidx];
404 jnrlistB = jjnr[jidx+1];
405 jnrlistC = jjnr[jidx+2];
406 jnrlistD = jjnr[jidx+3];
407 /* Sign of each element will be negative for non-real atoms.
408 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
409 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
411 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
412 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
413 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
414 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
415 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
416 j_coord_offsetA = DIM*jnrA;
417 j_coord_offsetB = DIM*jnrB;
418 j_coord_offsetC = DIM*jnrC;
419 j_coord_offsetD = DIM*jnrD;
421 /* load j atom coordinates */
422 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
423 x+j_coord_offsetC,x+j_coord_offsetD,
426 /* Calculate displacement vector */
427 dx00 = _mm_sub_ps(ix0,jx0);
428 dy00 = _mm_sub_ps(iy0,jy0);
429 dz00 = _mm_sub_ps(iz0,jz0);
430 dx10 = _mm_sub_ps(ix1,jx0);
431 dy10 = _mm_sub_ps(iy1,jy0);
432 dz10 = _mm_sub_ps(iz1,jz0);
433 dx20 = _mm_sub_ps(ix2,jx0);
434 dy20 = _mm_sub_ps(iy2,jy0);
435 dz20 = _mm_sub_ps(iz2,jz0);
437 /* Calculate squared distance and things based on it */
438 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
439 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
440 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
442 rinv00 = gmx_mm_invsqrt_ps(rsq00);
443 rinv10 = gmx_mm_invsqrt_ps(rsq10);
444 rinv20 = gmx_mm_invsqrt_ps(rsq20);
446 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
447 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
448 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
450 /* Load parameters for j particles */
451 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
452 charge+jnrC+0,charge+jnrD+0);
453 vdwjidx0A = 2*vdwtype[jnrA+0];
454 vdwjidx0B = 2*vdwtype[jnrB+0];
455 vdwjidx0C = 2*vdwtype[jnrC+0];
456 vdwjidx0D = 2*vdwtype[jnrD+0];
458 fjx0 = _mm_setzero_ps();
459 fjy0 = _mm_setzero_ps();
460 fjz0 = _mm_setzero_ps();
462 /**************************
463 * CALCULATE INTERACTIONS *
464 **************************/
466 if (gmx_mm_any_lt(rsq00,rcutoff2))
469 r00 = _mm_mul_ps(rsq00,rinv00);
470 r00 = _mm_andnot_ps(dummy_mask,r00);
472 /* Compute parameters for interactions between i and j atoms */
473 qq00 = _mm_mul_ps(iq0,jq0);
474 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
475 vdwparam+vdwioffset0+vdwjidx0B,
476 vdwparam+vdwioffset0+vdwjidx0C,
477 vdwparam+vdwioffset0+vdwjidx0D,
480 /* EWALD ELECTROSTATICS */
482 /* Analytical PME correction */
483 zeta2 = _mm_mul_ps(beta2,rsq00);
484 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
485 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
486 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
487 felec = _mm_mul_ps(qq00,felec);
488 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
489 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
490 velec = _mm_mul_ps(qq00,velec);
492 /* LENNARD-JONES DISPERSION/REPULSION */
494 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
495 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
496 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
497 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
498 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
499 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
501 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
503 /* Update potential sum for this i atom from the interaction with this j atom. */
504 velec = _mm_and_ps(velec,cutoff_mask);
505 velec = _mm_andnot_ps(dummy_mask,velec);
506 velecsum = _mm_add_ps(velecsum,velec);
507 vvdw = _mm_and_ps(vvdw,cutoff_mask);
508 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
509 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
511 fscal = _mm_add_ps(felec,fvdw);
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 r10 = _mm_mul_ps(rsq10,rinv10);
536 r10 = _mm_andnot_ps(dummy_mask,r10);
538 /* Compute parameters for interactions between i and j atoms */
539 qq10 = _mm_mul_ps(iq1,jq0);
541 /* EWALD ELECTROSTATICS */
543 /* Analytical PME correction */
544 zeta2 = _mm_mul_ps(beta2,rsq10);
545 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
546 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
547 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
548 felec = _mm_mul_ps(qq10,felec);
549 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
550 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
551 velec = _mm_mul_ps(qq10,velec);
553 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
555 /* Update potential sum for this i atom from the interaction with this j atom. */
556 velec = _mm_and_ps(velec,cutoff_mask);
557 velec = _mm_andnot_ps(dummy_mask,velec);
558 velecsum = _mm_add_ps(velecsum,velec);
562 fscal = _mm_and_ps(fscal,cutoff_mask);
564 fscal = _mm_andnot_ps(dummy_mask,fscal);
566 /* Update vectorial force */
567 fix1 = _mm_macc_ps(dx10,fscal,fix1);
568 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
569 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
571 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
572 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
573 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
577 /**************************
578 * CALCULATE INTERACTIONS *
579 **************************/
581 if (gmx_mm_any_lt(rsq20,rcutoff2))
584 r20 = _mm_mul_ps(rsq20,rinv20);
585 r20 = _mm_andnot_ps(dummy_mask,r20);
587 /* Compute parameters for interactions between i and j atoms */
588 qq20 = _mm_mul_ps(iq2,jq0);
590 /* EWALD ELECTROSTATICS */
592 /* Analytical PME correction */
593 zeta2 = _mm_mul_ps(beta2,rsq20);
594 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
595 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
596 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
597 felec = _mm_mul_ps(qq20,felec);
598 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
599 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
600 velec = _mm_mul_ps(qq20,velec);
602 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
604 /* Update potential sum for this i atom from the interaction with this j atom. */
605 velec = _mm_and_ps(velec,cutoff_mask);
606 velec = _mm_andnot_ps(dummy_mask,velec);
607 velecsum = _mm_add_ps(velecsum,velec);
611 fscal = _mm_and_ps(fscal,cutoff_mask);
613 fscal = _mm_andnot_ps(dummy_mask,fscal);
615 /* Update vectorial force */
616 fix2 = _mm_macc_ps(dx20,fscal,fix2);
617 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
618 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
620 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
621 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
622 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
626 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
627 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
628 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
629 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
631 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
633 /* Inner loop uses 120 flops */
636 /* End of innermost loop */
638 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
639 f+i_coord_offset,fshift+i_shift_offset);
642 /* Update potential energies */
643 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
644 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
646 /* Increment number of inner iterations */
647 inneriter += j_index_end - j_index_start;
649 /* Outer loop uses 20 flops */
652 /* Increment number of outer iterations */
655 /* Update outer/inner flops */
657 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
660 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_F_avx_128_fma_single
661 * Electrostatics interaction: Ewald
662 * VdW interaction: LennardJones
663 * Geometry: Water3-Particle
664 * Calculate force/pot: Force
667 nb_kernel_ElecEwSh_VdwLJSh_GeomW3P1_F_avx_128_fma_single
668 (t_nblist * gmx_restrict nlist,
669 rvec * gmx_restrict xx,
670 rvec * gmx_restrict ff,
671 t_forcerec * gmx_restrict fr,
672 t_mdatoms * gmx_restrict mdatoms,
673 nb_kernel_data_t * gmx_restrict kernel_data,
674 t_nrnb * gmx_restrict nrnb)
676 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
677 * just 0 for non-waters.
678 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
679 * jnr indices corresponding to data put in the four positions in the SIMD register.
681 int i_shift_offset,i_coord_offset,outeriter,inneriter;
682 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
683 int jnrA,jnrB,jnrC,jnrD;
684 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
685 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
686 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
688 real *shiftvec,*fshift,*x,*f;
689 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
691 __m128 fscal,rcutoff,rcutoff2,jidxall;
693 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
695 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
697 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
698 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
699 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
700 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
701 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
702 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
703 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
706 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
709 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
710 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
712 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
713 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
715 __m128 dummy_mask,cutoff_mask;
716 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
717 __m128 one = _mm_set1_ps(1.0);
718 __m128 two = _mm_set1_ps(2.0);
724 jindex = nlist->jindex;
726 shiftidx = nlist->shift;
728 shiftvec = fr->shift_vec[0];
729 fshift = fr->fshift[0];
730 facel = _mm_set1_ps(fr->epsfac);
731 charge = mdatoms->chargeA;
732 nvdwtype = fr->ntype;
734 vdwtype = mdatoms->typeA;
736 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
737 beta = _mm_set1_ps(fr->ic->ewaldcoeff);
738 beta2 = _mm_mul_ps(beta,beta);
739 beta3 = _mm_mul_ps(beta,beta2);
740 ewtab = fr->ic->tabq_coul_F;
741 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
742 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
744 /* Setup water-specific parameters */
745 inr = nlist->iinr[0];
746 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
747 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
748 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
749 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
751 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
752 rcutoff_scalar = fr->rcoulomb;
753 rcutoff = _mm_set1_ps(rcutoff_scalar);
754 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
756 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
757 rvdw = _mm_set1_ps(fr->rvdw);
759 /* Avoid stupid compiler warnings */
760 jnrA = jnrB = jnrC = jnrD = 0;
769 for(iidx=0;iidx<4*DIM;iidx++)
774 /* Start outer loop over neighborlists */
775 for(iidx=0; iidx<nri; iidx++)
777 /* Load shift vector for this list */
778 i_shift_offset = DIM*shiftidx[iidx];
780 /* Load limits for loop over neighbors */
781 j_index_start = jindex[iidx];
782 j_index_end = jindex[iidx+1];
784 /* Get outer coordinate index */
786 i_coord_offset = DIM*inr;
788 /* Load i particle coords and add shift vector */
789 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
790 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
792 fix0 = _mm_setzero_ps();
793 fiy0 = _mm_setzero_ps();
794 fiz0 = _mm_setzero_ps();
795 fix1 = _mm_setzero_ps();
796 fiy1 = _mm_setzero_ps();
797 fiz1 = _mm_setzero_ps();
798 fix2 = _mm_setzero_ps();
799 fiy2 = _mm_setzero_ps();
800 fiz2 = _mm_setzero_ps();
802 /* Start inner kernel loop */
803 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
806 /* Get j neighbor index, and coordinate index */
811 j_coord_offsetA = DIM*jnrA;
812 j_coord_offsetB = DIM*jnrB;
813 j_coord_offsetC = DIM*jnrC;
814 j_coord_offsetD = DIM*jnrD;
816 /* load j atom coordinates */
817 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
818 x+j_coord_offsetC,x+j_coord_offsetD,
821 /* Calculate displacement vector */
822 dx00 = _mm_sub_ps(ix0,jx0);
823 dy00 = _mm_sub_ps(iy0,jy0);
824 dz00 = _mm_sub_ps(iz0,jz0);
825 dx10 = _mm_sub_ps(ix1,jx0);
826 dy10 = _mm_sub_ps(iy1,jy0);
827 dz10 = _mm_sub_ps(iz1,jz0);
828 dx20 = _mm_sub_ps(ix2,jx0);
829 dy20 = _mm_sub_ps(iy2,jy0);
830 dz20 = _mm_sub_ps(iz2,jz0);
832 /* Calculate squared distance and things based on it */
833 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
834 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
835 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
837 rinv00 = gmx_mm_invsqrt_ps(rsq00);
838 rinv10 = gmx_mm_invsqrt_ps(rsq10);
839 rinv20 = gmx_mm_invsqrt_ps(rsq20);
841 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
842 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
843 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
845 /* Load parameters for j particles */
846 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
847 charge+jnrC+0,charge+jnrD+0);
848 vdwjidx0A = 2*vdwtype[jnrA+0];
849 vdwjidx0B = 2*vdwtype[jnrB+0];
850 vdwjidx0C = 2*vdwtype[jnrC+0];
851 vdwjidx0D = 2*vdwtype[jnrD+0];
853 fjx0 = _mm_setzero_ps();
854 fjy0 = _mm_setzero_ps();
855 fjz0 = _mm_setzero_ps();
857 /**************************
858 * CALCULATE INTERACTIONS *
859 **************************/
861 if (gmx_mm_any_lt(rsq00,rcutoff2))
864 r00 = _mm_mul_ps(rsq00,rinv00);
866 /* Compute parameters for interactions between i and j atoms */
867 qq00 = _mm_mul_ps(iq0,jq0);
868 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
869 vdwparam+vdwioffset0+vdwjidx0B,
870 vdwparam+vdwioffset0+vdwjidx0C,
871 vdwparam+vdwioffset0+vdwjidx0D,
874 /* EWALD ELECTROSTATICS */
876 /* Analytical PME correction */
877 zeta2 = _mm_mul_ps(beta2,rsq00);
878 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
879 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
880 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
881 felec = _mm_mul_ps(qq00,felec);
883 /* LENNARD-JONES DISPERSION/REPULSION */
885 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
886 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
888 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
890 fscal = _mm_add_ps(felec,fvdw);
892 fscal = _mm_and_ps(fscal,cutoff_mask);
894 /* Update vectorial force */
895 fix0 = _mm_macc_ps(dx00,fscal,fix0);
896 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
897 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
899 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
900 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
901 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
905 /**************************
906 * CALCULATE INTERACTIONS *
907 **************************/
909 if (gmx_mm_any_lt(rsq10,rcutoff2))
912 r10 = _mm_mul_ps(rsq10,rinv10);
914 /* Compute parameters for interactions between i and j atoms */
915 qq10 = _mm_mul_ps(iq1,jq0);
917 /* EWALD ELECTROSTATICS */
919 /* Analytical PME correction */
920 zeta2 = _mm_mul_ps(beta2,rsq10);
921 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
922 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
923 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
924 felec = _mm_mul_ps(qq10,felec);
926 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
930 fscal = _mm_and_ps(fscal,cutoff_mask);
932 /* Update vectorial force */
933 fix1 = _mm_macc_ps(dx10,fscal,fix1);
934 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
935 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
937 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
938 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
939 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
943 /**************************
944 * CALCULATE INTERACTIONS *
945 **************************/
947 if (gmx_mm_any_lt(rsq20,rcutoff2))
950 r20 = _mm_mul_ps(rsq20,rinv20);
952 /* Compute parameters for interactions between i and j atoms */
953 qq20 = _mm_mul_ps(iq2,jq0);
955 /* EWALD ELECTROSTATICS */
957 /* Analytical PME correction */
958 zeta2 = _mm_mul_ps(beta2,rsq20);
959 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
960 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
961 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
962 felec = _mm_mul_ps(qq20,felec);
964 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
968 fscal = _mm_and_ps(fscal,cutoff_mask);
970 /* Update vectorial force */
971 fix2 = _mm_macc_ps(dx20,fscal,fix2);
972 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
973 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
975 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
976 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
977 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
981 fjptrA = f+j_coord_offsetA;
982 fjptrB = f+j_coord_offsetB;
983 fjptrC = f+j_coord_offsetC;
984 fjptrD = f+j_coord_offsetD;
986 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
988 /* Inner loop uses 100 flops */
994 /* Get j neighbor index, and coordinate index */
995 jnrlistA = jjnr[jidx];
996 jnrlistB = jjnr[jidx+1];
997 jnrlistC = jjnr[jidx+2];
998 jnrlistD = jjnr[jidx+3];
999 /* Sign of each element will be negative for non-real atoms.
1000 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1001 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1003 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1004 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1005 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1006 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1007 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1008 j_coord_offsetA = DIM*jnrA;
1009 j_coord_offsetB = DIM*jnrB;
1010 j_coord_offsetC = DIM*jnrC;
1011 j_coord_offsetD = DIM*jnrD;
1013 /* load j atom coordinates */
1014 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1015 x+j_coord_offsetC,x+j_coord_offsetD,
1018 /* Calculate displacement vector */
1019 dx00 = _mm_sub_ps(ix0,jx0);
1020 dy00 = _mm_sub_ps(iy0,jy0);
1021 dz00 = _mm_sub_ps(iz0,jz0);
1022 dx10 = _mm_sub_ps(ix1,jx0);
1023 dy10 = _mm_sub_ps(iy1,jy0);
1024 dz10 = _mm_sub_ps(iz1,jz0);
1025 dx20 = _mm_sub_ps(ix2,jx0);
1026 dy20 = _mm_sub_ps(iy2,jy0);
1027 dz20 = _mm_sub_ps(iz2,jz0);
1029 /* Calculate squared distance and things based on it */
1030 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1031 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1032 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1034 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1035 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1036 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1038 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1039 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1040 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1042 /* Load parameters for j particles */
1043 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1044 charge+jnrC+0,charge+jnrD+0);
1045 vdwjidx0A = 2*vdwtype[jnrA+0];
1046 vdwjidx0B = 2*vdwtype[jnrB+0];
1047 vdwjidx0C = 2*vdwtype[jnrC+0];
1048 vdwjidx0D = 2*vdwtype[jnrD+0];
1050 fjx0 = _mm_setzero_ps();
1051 fjy0 = _mm_setzero_ps();
1052 fjz0 = _mm_setzero_ps();
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1058 if (gmx_mm_any_lt(rsq00,rcutoff2))
1061 r00 = _mm_mul_ps(rsq00,rinv00);
1062 r00 = _mm_andnot_ps(dummy_mask,r00);
1064 /* Compute parameters for interactions between i and j atoms */
1065 qq00 = _mm_mul_ps(iq0,jq0);
1066 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1067 vdwparam+vdwioffset0+vdwjidx0B,
1068 vdwparam+vdwioffset0+vdwjidx0C,
1069 vdwparam+vdwioffset0+vdwjidx0D,
1072 /* EWALD ELECTROSTATICS */
1074 /* Analytical PME correction */
1075 zeta2 = _mm_mul_ps(beta2,rsq00);
1076 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
1077 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1078 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1079 felec = _mm_mul_ps(qq00,felec);
1081 /* LENNARD-JONES DISPERSION/REPULSION */
1083 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1084 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1086 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1088 fscal = _mm_add_ps(felec,fvdw);
1090 fscal = _mm_and_ps(fscal,cutoff_mask);
1092 fscal = _mm_andnot_ps(dummy_mask,fscal);
1094 /* Update vectorial force */
1095 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1096 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1097 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1099 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1100 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1101 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1105 /**************************
1106 * CALCULATE INTERACTIONS *
1107 **************************/
1109 if (gmx_mm_any_lt(rsq10,rcutoff2))
1112 r10 = _mm_mul_ps(rsq10,rinv10);
1113 r10 = _mm_andnot_ps(dummy_mask,r10);
1115 /* Compute parameters for interactions between i and j atoms */
1116 qq10 = _mm_mul_ps(iq1,jq0);
1118 /* EWALD ELECTROSTATICS */
1120 /* Analytical PME correction */
1121 zeta2 = _mm_mul_ps(beta2,rsq10);
1122 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
1123 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1124 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1125 felec = _mm_mul_ps(qq10,felec);
1127 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1131 fscal = _mm_and_ps(fscal,cutoff_mask);
1133 fscal = _mm_andnot_ps(dummy_mask,fscal);
1135 /* Update vectorial force */
1136 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1137 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1138 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1140 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1141 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1142 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1146 /**************************
1147 * CALCULATE INTERACTIONS *
1148 **************************/
1150 if (gmx_mm_any_lt(rsq20,rcutoff2))
1153 r20 = _mm_mul_ps(rsq20,rinv20);
1154 r20 = _mm_andnot_ps(dummy_mask,r20);
1156 /* Compute parameters for interactions between i and j atoms */
1157 qq20 = _mm_mul_ps(iq2,jq0);
1159 /* EWALD ELECTROSTATICS */
1161 /* Analytical PME correction */
1162 zeta2 = _mm_mul_ps(beta2,rsq20);
1163 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
1164 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1165 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1166 felec = _mm_mul_ps(qq20,felec);
1168 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1172 fscal = _mm_and_ps(fscal,cutoff_mask);
1174 fscal = _mm_andnot_ps(dummy_mask,fscal);
1176 /* Update vectorial force */
1177 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1178 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1179 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1181 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1182 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1183 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1187 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1188 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1189 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1190 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1192 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1194 /* Inner loop uses 103 flops */
1197 /* End of innermost loop */
1199 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1200 f+i_coord_offset,fshift+i_shift_offset);
1202 /* Increment number of inner iterations */
1203 inneriter += j_index_end - j_index_start;
1205 /* Outer loop uses 18 flops */
1208 /* Increment number of outer iterations */
1211 /* Update outer/inner flops */
1213 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*103);