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_ElecEw_VdwLJ_GeomW4P1_VF_avx_128_fma_single
52 * Electrostatics interaction: Ewald
53 * VdW interaction: LennardJones
54 * Geometry: Water4-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecEw_VdwLJ_GeomW4P1_VF_avx_128_fma_single
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int jnrA,jnrB,jnrC,jnrD;
75 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
76 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
79 real *shiftvec,*fshift,*x,*f;
80 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
82 __m128 fscal,rcutoff,rcutoff2,jidxall;
84 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
86 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
88 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
90 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
97 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
100 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
103 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
104 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
106 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
107 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
109 __m128 dummy_mask,cutoff_mask;
110 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
111 __m128 one = _mm_set1_ps(1.0);
112 __m128 two = _mm_set1_ps(2.0);
118 jindex = nlist->jindex;
120 shiftidx = nlist->shift;
122 shiftvec = fr->shift_vec[0];
123 fshift = fr->fshift[0];
124 facel = _mm_set1_ps(fr->epsfac);
125 charge = mdatoms->chargeA;
126 nvdwtype = fr->ntype;
128 vdwtype = mdatoms->typeA;
130 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
131 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
132 beta2 = _mm_mul_ps(beta,beta);
133 beta3 = _mm_mul_ps(beta,beta2);
134 ewtab = fr->ic->tabq_coul_FDV0;
135 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
136 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
138 /* Setup water-specific parameters */
139 inr = nlist->iinr[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 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
143 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
145 /* Avoid stupid compiler warnings */
146 jnrA = jnrB = jnrC = jnrD = 0;
155 for(iidx=0;iidx<4*DIM;iidx++)
160 /* Start outer loop over neighborlists */
161 for(iidx=0; iidx<nri; iidx++)
163 /* Load shift vector for this list */
164 i_shift_offset = DIM*shiftidx[iidx];
166 /* Load limits for loop over neighbors */
167 j_index_start = jindex[iidx];
168 j_index_end = jindex[iidx+1];
170 /* Get outer coordinate index */
172 i_coord_offset = DIM*inr;
174 /* Load i particle coords and add shift vector */
175 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
176 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
178 fix0 = _mm_setzero_ps();
179 fiy0 = _mm_setzero_ps();
180 fiz0 = _mm_setzero_ps();
181 fix1 = _mm_setzero_ps();
182 fiy1 = _mm_setzero_ps();
183 fiz1 = _mm_setzero_ps();
184 fix2 = _mm_setzero_ps();
185 fiy2 = _mm_setzero_ps();
186 fiz2 = _mm_setzero_ps();
187 fix3 = _mm_setzero_ps();
188 fiy3 = _mm_setzero_ps();
189 fiz3 = _mm_setzero_ps();
191 /* Reset potential sums */
192 velecsum = _mm_setzero_ps();
193 vvdwsum = _mm_setzero_ps();
195 /* Start inner kernel loop */
196 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
199 /* Get j neighbor index, and coordinate index */
204 j_coord_offsetA = DIM*jnrA;
205 j_coord_offsetB = DIM*jnrB;
206 j_coord_offsetC = DIM*jnrC;
207 j_coord_offsetD = DIM*jnrD;
209 /* load j atom coordinates */
210 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
211 x+j_coord_offsetC,x+j_coord_offsetD,
214 /* Calculate displacement vector */
215 dx00 = _mm_sub_ps(ix0,jx0);
216 dy00 = _mm_sub_ps(iy0,jy0);
217 dz00 = _mm_sub_ps(iz0,jz0);
218 dx10 = _mm_sub_ps(ix1,jx0);
219 dy10 = _mm_sub_ps(iy1,jy0);
220 dz10 = _mm_sub_ps(iz1,jz0);
221 dx20 = _mm_sub_ps(ix2,jx0);
222 dy20 = _mm_sub_ps(iy2,jy0);
223 dz20 = _mm_sub_ps(iz2,jz0);
224 dx30 = _mm_sub_ps(ix3,jx0);
225 dy30 = _mm_sub_ps(iy3,jy0);
226 dz30 = _mm_sub_ps(iz3,jz0);
228 /* Calculate squared distance and things based on it */
229 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
230 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
231 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
232 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
234 rinv10 = gmx_mm_invsqrt_ps(rsq10);
235 rinv20 = gmx_mm_invsqrt_ps(rsq20);
236 rinv30 = gmx_mm_invsqrt_ps(rsq30);
238 rinvsq00 = gmx_mm_inv_ps(rsq00);
239 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
240 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
241 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
243 /* Load parameters for j particles */
244 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
245 charge+jnrC+0,charge+jnrD+0);
246 vdwjidx0A = 2*vdwtype[jnrA+0];
247 vdwjidx0B = 2*vdwtype[jnrB+0];
248 vdwjidx0C = 2*vdwtype[jnrC+0];
249 vdwjidx0D = 2*vdwtype[jnrD+0];
251 fjx0 = _mm_setzero_ps();
252 fjy0 = _mm_setzero_ps();
253 fjz0 = _mm_setzero_ps();
255 /**************************
256 * CALCULATE INTERACTIONS *
257 **************************/
259 /* Compute parameters for interactions between i and j atoms */
260 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
261 vdwparam+vdwioffset0+vdwjidx0B,
262 vdwparam+vdwioffset0+vdwjidx0C,
263 vdwparam+vdwioffset0+vdwjidx0D,
266 /* LENNARD-JONES DISPERSION/REPULSION */
268 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
269 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
270 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
271 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
272 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
274 /* Update potential sum for this i atom from the interaction with this j atom. */
275 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
279 /* Update vectorial force */
280 fix0 = _mm_macc_ps(dx00,fscal,fix0);
281 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
282 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
284 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
285 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
286 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
288 /**************************
289 * CALCULATE INTERACTIONS *
290 **************************/
292 r10 = _mm_mul_ps(rsq10,rinv10);
294 /* Compute parameters for interactions between i and j atoms */
295 qq10 = _mm_mul_ps(iq1,jq0);
297 /* EWALD ELECTROSTATICS */
299 /* Analytical PME correction */
300 zeta2 = _mm_mul_ps(beta2,rsq10);
301 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
302 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
303 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
304 felec = _mm_mul_ps(qq10,felec);
305 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
306 velec = _mm_nmacc_ps(pmecorrV,beta,rinv10);
307 velec = _mm_mul_ps(qq10,velec);
309 /* Update potential sum for this i atom from the interaction with this j atom. */
310 velecsum = _mm_add_ps(velecsum,velec);
314 /* Update vectorial force */
315 fix1 = _mm_macc_ps(dx10,fscal,fix1);
316 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
317 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
319 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
320 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
321 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
323 /**************************
324 * CALCULATE INTERACTIONS *
325 **************************/
327 r20 = _mm_mul_ps(rsq20,rinv20);
329 /* Compute parameters for interactions between i and j atoms */
330 qq20 = _mm_mul_ps(iq2,jq0);
332 /* EWALD ELECTROSTATICS */
334 /* Analytical PME correction */
335 zeta2 = _mm_mul_ps(beta2,rsq20);
336 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
337 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
338 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
339 felec = _mm_mul_ps(qq20,felec);
340 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
341 velec = _mm_nmacc_ps(pmecorrV,beta,rinv20);
342 velec = _mm_mul_ps(qq20,velec);
344 /* Update potential sum for this i atom from the interaction with this j atom. */
345 velecsum = _mm_add_ps(velecsum,velec);
349 /* Update vectorial force */
350 fix2 = _mm_macc_ps(dx20,fscal,fix2);
351 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
352 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
354 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
355 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
356 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
362 r30 = _mm_mul_ps(rsq30,rinv30);
364 /* Compute parameters for interactions between i and j atoms */
365 qq30 = _mm_mul_ps(iq3,jq0);
367 /* EWALD ELECTROSTATICS */
369 /* Analytical PME correction */
370 zeta2 = _mm_mul_ps(beta2,rsq30);
371 rinv3 = _mm_mul_ps(rinvsq30,rinv30);
372 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
373 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
374 felec = _mm_mul_ps(qq30,felec);
375 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
376 velec = _mm_nmacc_ps(pmecorrV,beta,rinv30);
377 velec = _mm_mul_ps(qq30,velec);
379 /* Update potential sum for this i atom from the interaction with this j atom. */
380 velecsum = _mm_add_ps(velecsum,velec);
384 /* Update vectorial force */
385 fix3 = _mm_macc_ps(dx30,fscal,fix3);
386 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
387 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
389 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
390 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
391 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
393 fjptrA = f+j_coord_offsetA;
394 fjptrB = f+j_coord_offsetB;
395 fjptrC = f+j_coord_offsetC;
396 fjptrD = f+j_coord_offsetD;
398 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
400 /* Inner loop uses 122 flops */
406 /* Get j neighbor index, and coordinate index */
407 jnrlistA = jjnr[jidx];
408 jnrlistB = jjnr[jidx+1];
409 jnrlistC = jjnr[jidx+2];
410 jnrlistD = jjnr[jidx+3];
411 /* Sign of each element will be negative for non-real atoms.
412 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
413 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
415 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
416 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
417 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
418 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
419 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
420 j_coord_offsetA = DIM*jnrA;
421 j_coord_offsetB = DIM*jnrB;
422 j_coord_offsetC = DIM*jnrC;
423 j_coord_offsetD = DIM*jnrD;
425 /* load j atom coordinates */
426 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
427 x+j_coord_offsetC,x+j_coord_offsetD,
430 /* Calculate displacement vector */
431 dx00 = _mm_sub_ps(ix0,jx0);
432 dy00 = _mm_sub_ps(iy0,jy0);
433 dz00 = _mm_sub_ps(iz0,jz0);
434 dx10 = _mm_sub_ps(ix1,jx0);
435 dy10 = _mm_sub_ps(iy1,jy0);
436 dz10 = _mm_sub_ps(iz1,jz0);
437 dx20 = _mm_sub_ps(ix2,jx0);
438 dy20 = _mm_sub_ps(iy2,jy0);
439 dz20 = _mm_sub_ps(iz2,jz0);
440 dx30 = _mm_sub_ps(ix3,jx0);
441 dy30 = _mm_sub_ps(iy3,jy0);
442 dz30 = _mm_sub_ps(iz3,jz0);
444 /* Calculate squared distance and things based on it */
445 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
446 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
447 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
448 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
450 rinv10 = gmx_mm_invsqrt_ps(rsq10);
451 rinv20 = gmx_mm_invsqrt_ps(rsq20);
452 rinv30 = gmx_mm_invsqrt_ps(rsq30);
454 rinvsq00 = gmx_mm_inv_ps(rsq00);
455 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
456 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
457 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
459 /* Load parameters for j particles */
460 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
461 charge+jnrC+0,charge+jnrD+0);
462 vdwjidx0A = 2*vdwtype[jnrA+0];
463 vdwjidx0B = 2*vdwtype[jnrB+0];
464 vdwjidx0C = 2*vdwtype[jnrC+0];
465 vdwjidx0D = 2*vdwtype[jnrD+0];
467 fjx0 = _mm_setzero_ps();
468 fjy0 = _mm_setzero_ps();
469 fjz0 = _mm_setzero_ps();
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
475 /* Compute parameters for interactions between i and j atoms */
476 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
477 vdwparam+vdwioffset0+vdwjidx0B,
478 vdwparam+vdwioffset0+vdwjidx0C,
479 vdwparam+vdwioffset0+vdwjidx0D,
482 /* LENNARD-JONES DISPERSION/REPULSION */
484 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
485 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
486 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
487 vvdw = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
488 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
490 /* Update potential sum for this i atom from the interaction with this j atom. */
491 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
492 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
496 fscal = _mm_andnot_ps(dummy_mask,fscal);
498 /* Update vectorial force */
499 fix0 = _mm_macc_ps(dx00,fscal,fix0);
500 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
501 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
503 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
504 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
505 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
507 /**************************
508 * CALCULATE INTERACTIONS *
509 **************************/
511 r10 = _mm_mul_ps(rsq10,rinv10);
512 r10 = _mm_andnot_ps(dummy_mask,r10);
514 /* Compute parameters for interactions between i and j atoms */
515 qq10 = _mm_mul_ps(iq1,jq0);
517 /* EWALD ELECTROSTATICS */
519 /* Analytical PME correction */
520 zeta2 = _mm_mul_ps(beta2,rsq10);
521 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
522 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
523 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
524 felec = _mm_mul_ps(qq10,felec);
525 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
526 velec = _mm_nmacc_ps(pmecorrV,beta,rinv10);
527 velec = _mm_mul_ps(qq10,velec);
529 /* Update potential sum for this i atom from the interaction with this j atom. */
530 velec = _mm_andnot_ps(dummy_mask,velec);
531 velecsum = _mm_add_ps(velecsum,velec);
535 fscal = _mm_andnot_ps(dummy_mask,fscal);
537 /* Update vectorial force */
538 fix1 = _mm_macc_ps(dx10,fscal,fix1);
539 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
540 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
542 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
543 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
544 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
546 /**************************
547 * CALCULATE INTERACTIONS *
548 **************************/
550 r20 = _mm_mul_ps(rsq20,rinv20);
551 r20 = _mm_andnot_ps(dummy_mask,r20);
553 /* Compute parameters for interactions between i and j atoms */
554 qq20 = _mm_mul_ps(iq2,jq0);
556 /* EWALD ELECTROSTATICS */
558 /* Analytical PME correction */
559 zeta2 = _mm_mul_ps(beta2,rsq20);
560 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
561 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
562 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
563 felec = _mm_mul_ps(qq20,felec);
564 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
565 velec = _mm_nmacc_ps(pmecorrV,beta,rinv20);
566 velec = _mm_mul_ps(qq20,velec);
568 /* Update potential sum for this i atom from the interaction with this j atom. */
569 velec = _mm_andnot_ps(dummy_mask,velec);
570 velecsum = _mm_add_ps(velecsum,velec);
574 fscal = _mm_andnot_ps(dummy_mask,fscal);
576 /* Update vectorial force */
577 fix2 = _mm_macc_ps(dx20,fscal,fix2);
578 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
579 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
581 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
582 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
583 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
589 r30 = _mm_mul_ps(rsq30,rinv30);
590 r30 = _mm_andnot_ps(dummy_mask,r30);
592 /* Compute parameters for interactions between i and j atoms */
593 qq30 = _mm_mul_ps(iq3,jq0);
595 /* EWALD ELECTROSTATICS */
597 /* Analytical PME correction */
598 zeta2 = _mm_mul_ps(beta2,rsq30);
599 rinv3 = _mm_mul_ps(rinvsq30,rinv30);
600 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
601 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
602 felec = _mm_mul_ps(qq30,felec);
603 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
604 velec = _mm_nmacc_ps(pmecorrV,beta,rinv30);
605 velec = _mm_mul_ps(qq30,velec);
607 /* Update potential sum for this i atom from the interaction with this j atom. */
608 velec = _mm_andnot_ps(dummy_mask,velec);
609 velecsum = _mm_add_ps(velecsum,velec);
613 fscal = _mm_andnot_ps(dummy_mask,fscal);
615 /* Update vectorial force */
616 fix3 = _mm_macc_ps(dx30,fscal,fix3);
617 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
618 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
620 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
621 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
622 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
624 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
625 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
626 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
627 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
629 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
631 /* Inner loop uses 125 flops */
634 /* End of innermost loop */
636 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
637 f+i_coord_offset,fshift+i_shift_offset);
640 /* Update potential energies */
641 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
642 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
644 /* Increment number of inner iterations */
645 inneriter += j_index_end - j_index_start;
647 /* Outer loop uses 26 flops */
650 /* Increment number of outer iterations */
653 /* Update outer/inner flops */
655 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*125);
658 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwLJ_GeomW4P1_F_avx_128_fma_single
659 * Electrostatics interaction: Ewald
660 * VdW interaction: LennardJones
661 * Geometry: Water4-Particle
662 * Calculate force/pot: Force
665 nb_kernel_ElecEw_VdwLJ_GeomW4P1_F_avx_128_fma_single
666 (t_nblist * gmx_restrict nlist,
667 rvec * gmx_restrict xx,
668 rvec * gmx_restrict ff,
669 t_forcerec * gmx_restrict fr,
670 t_mdatoms * gmx_restrict mdatoms,
671 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
672 t_nrnb * gmx_restrict nrnb)
674 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
675 * just 0 for non-waters.
676 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
677 * jnr indices corresponding to data put in the four positions in the SIMD register.
679 int i_shift_offset,i_coord_offset,outeriter,inneriter;
680 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
681 int jnrA,jnrB,jnrC,jnrD;
682 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
683 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
684 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
686 real *shiftvec,*fshift,*x,*f;
687 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
689 __m128 fscal,rcutoff,rcutoff2,jidxall;
691 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
693 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
695 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
697 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
704 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
707 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
710 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
711 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
713 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
714 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
716 __m128 dummy_mask,cutoff_mask;
717 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
718 __m128 one = _mm_set1_ps(1.0);
719 __m128 two = _mm_set1_ps(2.0);
725 jindex = nlist->jindex;
727 shiftidx = nlist->shift;
729 shiftvec = fr->shift_vec[0];
730 fshift = fr->fshift[0];
731 facel = _mm_set1_ps(fr->epsfac);
732 charge = mdatoms->chargeA;
733 nvdwtype = fr->ntype;
735 vdwtype = mdatoms->typeA;
737 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
738 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
739 beta2 = _mm_mul_ps(beta,beta);
740 beta3 = _mm_mul_ps(beta,beta2);
741 ewtab = fr->ic->tabq_coul_F;
742 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
743 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
745 /* Setup water-specific parameters */
746 inr = nlist->iinr[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 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
750 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
752 /* Avoid stupid compiler warnings */
753 jnrA = jnrB = jnrC = jnrD = 0;
762 for(iidx=0;iidx<4*DIM;iidx++)
767 /* Start outer loop over neighborlists */
768 for(iidx=0; iidx<nri; iidx++)
770 /* Load shift vector for this list */
771 i_shift_offset = DIM*shiftidx[iidx];
773 /* Load limits for loop over neighbors */
774 j_index_start = jindex[iidx];
775 j_index_end = jindex[iidx+1];
777 /* Get outer coordinate index */
779 i_coord_offset = DIM*inr;
781 /* Load i particle coords and add shift vector */
782 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
783 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
785 fix0 = _mm_setzero_ps();
786 fiy0 = _mm_setzero_ps();
787 fiz0 = _mm_setzero_ps();
788 fix1 = _mm_setzero_ps();
789 fiy1 = _mm_setzero_ps();
790 fiz1 = _mm_setzero_ps();
791 fix2 = _mm_setzero_ps();
792 fiy2 = _mm_setzero_ps();
793 fiz2 = _mm_setzero_ps();
794 fix3 = _mm_setzero_ps();
795 fiy3 = _mm_setzero_ps();
796 fiz3 = _mm_setzero_ps();
798 /* Start inner kernel loop */
799 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
802 /* Get j neighbor index, and coordinate index */
807 j_coord_offsetA = DIM*jnrA;
808 j_coord_offsetB = DIM*jnrB;
809 j_coord_offsetC = DIM*jnrC;
810 j_coord_offsetD = DIM*jnrD;
812 /* load j atom coordinates */
813 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
814 x+j_coord_offsetC,x+j_coord_offsetD,
817 /* Calculate displacement vector */
818 dx00 = _mm_sub_ps(ix0,jx0);
819 dy00 = _mm_sub_ps(iy0,jy0);
820 dz00 = _mm_sub_ps(iz0,jz0);
821 dx10 = _mm_sub_ps(ix1,jx0);
822 dy10 = _mm_sub_ps(iy1,jy0);
823 dz10 = _mm_sub_ps(iz1,jz0);
824 dx20 = _mm_sub_ps(ix2,jx0);
825 dy20 = _mm_sub_ps(iy2,jy0);
826 dz20 = _mm_sub_ps(iz2,jz0);
827 dx30 = _mm_sub_ps(ix3,jx0);
828 dy30 = _mm_sub_ps(iy3,jy0);
829 dz30 = _mm_sub_ps(iz3,jz0);
831 /* Calculate squared distance and things based on it */
832 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
833 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
834 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
835 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
837 rinv10 = gmx_mm_invsqrt_ps(rsq10);
838 rinv20 = gmx_mm_invsqrt_ps(rsq20);
839 rinv30 = gmx_mm_invsqrt_ps(rsq30);
841 rinvsq00 = gmx_mm_inv_ps(rsq00);
842 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
843 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
844 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
846 /* Load parameters for j particles */
847 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
848 charge+jnrC+0,charge+jnrD+0);
849 vdwjidx0A = 2*vdwtype[jnrA+0];
850 vdwjidx0B = 2*vdwtype[jnrB+0];
851 vdwjidx0C = 2*vdwtype[jnrC+0];
852 vdwjidx0D = 2*vdwtype[jnrD+0];
854 fjx0 = _mm_setzero_ps();
855 fjy0 = _mm_setzero_ps();
856 fjz0 = _mm_setzero_ps();
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
862 /* Compute parameters for interactions between i and j atoms */
863 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
864 vdwparam+vdwioffset0+vdwjidx0B,
865 vdwparam+vdwioffset0+vdwjidx0C,
866 vdwparam+vdwioffset0+vdwjidx0D,
869 /* LENNARD-JONES DISPERSION/REPULSION */
871 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
872 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
876 /* Update vectorial force */
877 fix0 = _mm_macc_ps(dx00,fscal,fix0);
878 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
879 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
881 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
882 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
883 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
889 r10 = _mm_mul_ps(rsq10,rinv10);
891 /* Compute parameters for interactions between i and j atoms */
892 qq10 = _mm_mul_ps(iq1,jq0);
894 /* EWALD ELECTROSTATICS */
896 /* Analytical PME correction */
897 zeta2 = _mm_mul_ps(beta2,rsq10);
898 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
899 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
900 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
901 felec = _mm_mul_ps(qq10,felec);
905 /* Update vectorial force */
906 fix1 = _mm_macc_ps(dx10,fscal,fix1);
907 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
908 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
910 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
911 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
912 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
918 r20 = _mm_mul_ps(rsq20,rinv20);
920 /* Compute parameters for interactions between i and j atoms */
921 qq20 = _mm_mul_ps(iq2,jq0);
923 /* EWALD ELECTROSTATICS */
925 /* Analytical PME correction */
926 zeta2 = _mm_mul_ps(beta2,rsq20);
927 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
928 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
929 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
930 felec = _mm_mul_ps(qq20,felec);
934 /* Update vectorial force */
935 fix2 = _mm_macc_ps(dx20,fscal,fix2);
936 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
937 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
939 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
940 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
941 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
943 /**************************
944 * CALCULATE INTERACTIONS *
945 **************************/
947 r30 = _mm_mul_ps(rsq30,rinv30);
949 /* Compute parameters for interactions between i and j atoms */
950 qq30 = _mm_mul_ps(iq3,jq0);
952 /* EWALD ELECTROSTATICS */
954 /* Analytical PME correction */
955 zeta2 = _mm_mul_ps(beta2,rsq30);
956 rinv3 = _mm_mul_ps(rinvsq30,rinv30);
957 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
958 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
959 felec = _mm_mul_ps(qq30,felec);
963 /* Update vectorial force */
964 fix3 = _mm_macc_ps(dx30,fscal,fix3);
965 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
966 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
968 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
969 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
970 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
972 fjptrA = f+j_coord_offsetA;
973 fjptrB = f+j_coord_offsetB;
974 fjptrC = f+j_coord_offsetC;
975 fjptrD = f+j_coord_offsetD;
977 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
979 /* Inner loop uses 114 flops */
985 /* Get j neighbor index, and coordinate index */
986 jnrlistA = jjnr[jidx];
987 jnrlistB = jjnr[jidx+1];
988 jnrlistC = jjnr[jidx+2];
989 jnrlistD = jjnr[jidx+3];
990 /* Sign of each element will be negative for non-real atoms.
991 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
992 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
994 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
995 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
996 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
997 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
998 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
999 j_coord_offsetA = DIM*jnrA;
1000 j_coord_offsetB = DIM*jnrB;
1001 j_coord_offsetC = DIM*jnrC;
1002 j_coord_offsetD = DIM*jnrD;
1004 /* load j atom coordinates */
1005 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1006 x+j_coord_offsetC,x+j_coord_offsetD,
1009 /* Calculate displacement vector */
1010 dx00 = _mm_sub_ps(ix0,jx0);
1011 dy00 = _mm_sub_ps(iy0,jy0);
1012 dz00 = _mm_sub_ps(iz0,jz0);
1013 dx10 = _mm_sub_ps(ix1,jx0);
1014 dy10 = _mm_sub_ps(iy1,jy0);
1015 dz10 = _mm_sub_ps(iz1,jz0);
1016 dx20 = _mm_sub_ps(ix2,jx0);
1017 dy20 = _mm_sub_ps(iy2,jy0);
1018 dz20 = _mm_sub_ps(iz2,jz0);
1019 dx30 = _mm_sub_ps(ix3,jx0);
1020 dy30 = _mm_sub_ps(iy3,jy0);
1021 dz30 = _mm_sub_ps(iz3,jz0);
1023 /* Calculate squared distance and things based on it */
1024 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1025 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1026 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1027 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
1029 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1030 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1031 rinv30 = gmx_mm_invsqrt_ps(rsq30);
1033 rinvsq00 = gmx_mm_inv_ps(rsq00);
1034 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1035 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1036 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
1038 /* Load parameters for j particles */
1039 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1040 charge+jnrC+0,charge+jnrD+0);
1041 vdwjidx0A = 2*vdwtype[jnrA+0];
1042 vdwjidx0B = 2*vdwtype[jnrB+0];
1043 vdwjidx0C = 2*vdwtype[jnrC+0];
1044 vdwjidx0D = 2*vdwtype[jnrD+0];
1046 fjx0 = _mm_setzero_ps();
1047 fjy0 = _mm_setzero_ps();
1048 fjz0 = _mm_setzero_ps();
1050 /**************************
1051 * CALCULATE INTERACTIONS *
1052 **************************/
1054 /* Compute parameters for interactions between i and j atoms */
1055 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1056 vdwparam+vdwioffset0+vdwjidx0B,
1057 vdwparam+vdwioffset0+vdwjidx0C,
1058 vdwparam+vdwioffset0+vdwjidx0D,
1061 /* LENNARD-JONES DISPERSION/REPULSION */
1063 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1064 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1068 fscal = _mm_andnot_ps(dummy_mask,fscal);
1070 /* Update vectorial force */
1071 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1072 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1073 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1075 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1076 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1077 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1083 r10 = _mm_mul_ps(rsq10,rinv10);
1084 r10 = _mm_andnot_ps(dummy_mask,r10);
1086 /* Compute parameters for interactions between i and j atoms */
1087 qq10 = _mm_mul_ps(iq1,jq0);
1089 /* EWALD ELECTROSTATICS */
1091 /* Analytical PME correction */
1092 zeta2 = _mm_mul_ps(beta2,rsq10);
1093 rinv3 = _mm_mul_ps(rinvsq10,rinv10);
1094 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1095 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1096 felec = _mm_mul_ps(qq10,felec);
1100 fscal = _mm_andnot_ps(dummy_mask,fscal);
1102 /* Update vectorial force */
1103 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1104 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1105 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1107 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1108 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1109 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1111 /**************************
1112 * CALCULATE INTERACTIONS *
1113 **************************/
1115 r20 = _mm_mul_ps(rsq20,rinv20);
1116 r20 = _mm_andnot_ps(dummy_mask,r20);
1118 /* Compute parameters for interactions between i and j atoms */
1119 qq20 = _mm_mul_ps(iq2,jq0);
1121 /* EWALD ELECTROSTATICS */
1123 /* Analytical PME correction */
1124 zeta2 = _mm_mul_ps(beta2,rsq20);
1125 rinv3 = _mm_mul_ps(rinvsq20,rinv20);
1126 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1127 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1128 felec = _mm_mul_ps(qq20,felec);
1132 fscal = _mm_andnot_ps(dummy_mask,fscal);
1134 /* Update vectorial force */
1135 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1136 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1137 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1139 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1140 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1141 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1143 /**************************
1144 * CALCULATE INTERACTIONS *
1145 **************************/
1147 r30 = _mm_mul_ps(rsq30,rinv30);
1148 r30 = _mm_andnot_ps(dummy_mask,r30);
1150 /* Compute parameters for interactions between i and j atoms */
1151 qq30 = _mm_mul_ps(iq3,jq0);
1153 /* EWALD ELECTROSTATICS */
1155 /* Analytical PME correction */
1156 zeta2 = _mm_mul_ps(beta2,rsq30);
1157 rinv3 = _mm_mul_ps(rinvsq30,rinv30);
1158 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
1159 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1160 felec = _mm_mul_ps(qq30,felec);
1164 fscal = _mm_andnot_ps(dummy_mask,fscal);
1166 /* Update vectorial force */
1167 fix3 = _mm_macc_ps(dx30,fscal,fix3);
1168 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
1169 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
1171 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
1172 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
1173 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1175 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1176 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1177 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1178 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1180 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1182 /* Inner loop uses 117 flops */
1185 /* End of innermost loop */
1187 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1188 f+i_coord_offset,fshift+i_shift_offset);
1190 /* Increment number of inner iterations */
1191 inneriter += j_index_end - j_index_start;
1193 /* Outer loop uses 24 flops */
1196 /* Increment number of outer iterations */
1199 /* Update outer/inner flops */
1201 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*117);