2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_VF_avx_128_fma_double
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_VF_avx_128_fma_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81 int vdwjidx0A,vdwjidx0B;
82 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
87 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
90 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
91 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
93 __m128d ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
95 __m128d dummy_mask,cutoff_mask;
96 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
97 __m128d one = _mm_set1_pd(1.0);
98 __m128d two = _mm_set1_pd(2.0);
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
110 facel = _mm_set1_pd(fr->ic->epsfac);
111 charge = mdatoms->chargeA;
112 nvdwtype = fr->ntype;
114 vdwtype = mdatoms->typeA;
116 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
117 ewtab = fr->ic->tabq_coul_FDV0;
118 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
119 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
121 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
122 rcutoff_scalar = fr->ic->rcoulomb;
123 rcutoff = _mm_set1_pd(rcutoff_scalar);
124 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
126 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
127 rvdw = _mm_set1_pd(fr->ic->rvdw);
129 /* Avoid stupid compiler warnings */
137 /* Start outer loop over neighborlists */
138 for(iidx=0; iidx<nri; iidx++)
140 /* Load shift vector for this list */
141 i_shift_offset = DIM*shiftidx[iidx];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
154 fix0 = _mm_setzero_pd();
155 fiy0 = _mm_setzero_pd();
156 fiz0 = _mm_setzero_pd();
158 /* Load parameters for i particles */
159 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
160 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
162 /* Reset potential sums */
163 velecsum = _mm_setzero_pd();
164 vvdwsum = _mm_setzero_pd();
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
170 /* Get j neighbor index, and coordinate index */
173 j_coord_offsetA = DIM*jnrA;
174 j_coord_offsetB = DIM*jnrB;
176 /* load j atom coordinates */
177 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
180 /* Calculate displacement vector */
181 dx00 = _mm_sub_pd(ix0,jx0);
182 dy00 = _mm_sub_pd(iy0,jy0);
183 dz00 = _mm_sub_pd(iz0,jz0);
185 /* Calculate squared distance and things based on it */
186 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
188 rinv00 = avx128fma_invsqrt_d(rsq00);
190 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
192 /* Load parameters for j particles */
193 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
194 vdwjidx0A = 2*vdwtype[jnrA+0];
195 vdwjidx0B = 2*vdwtype[jnrB+0];
197 /**************************
198 * CALCULATE INTERACTIONS *
199 **************************/
201 if (gmx_mm_any_lt(rsq00,rcutoff2))
204 r00 = _mm_mul_pd(rsq00,rinv00);
206 /* Compute parameters for interactions between i and j atoms */
207 qq00 = _mm_mul_pd(iq0,jq0);
208 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
209 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
211 /* EWALD ELECTROSTATICS */
213 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
214 ewrt = _mm_mul_pd(r00,ewtabscale);
215 ewitab = _mm_cvttpd_epi32(ewrt);
217 eweps = _mm_frcz_pd(ewrt);
219 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
221 twoeweps = _mm_add_pd(eweps,eweps);
222 ewitab = _mm_slli_epi32(ewitab,2);
223 ewtabF = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,0) );
224 ewtabD = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,1) );
225 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
226 ewtabV = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,0) +2);
227 ewtabFn = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,1) +2);
228 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
229 felec = _mm_macc_pd(eweps,ewtabD,ewtabF);
230 velec = _mm_nmacc_pd(_mm_mul_pd(ewtabhalfspace,eweps) ,_mm_add_pd(ewtabF,felec), ewtabV);
231 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_sub_pd(rinv00,sh_ewald),velec));
232 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
234 /* LENNARD-JONES DISPERSION/REPULSION */
236 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
237 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
238 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
239 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
240 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
241 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
243 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
245 /* Update potential sum for this i atom from the interaction with this j atom. */
246 velec = _mm_and_pd(velec,cutoff_mask);
247 velecsum = _mm_add_pd(velecsum,velec);
248 vvdw = _mm_and_pd(vvdw,cutoff_mask);
249 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
251 fscal = _mm_add_pd(felec,fvdw);
253 fscal = _mm_and_pd(fscal,cutoff_mask);
255 /* Update vectorial force */
256 fix0 = _mm_macc_pd(dx00,fscal,fix0);
257 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
258 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
260 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
261 _mm_mul_pd(dx00,fscal),
262 _mm_mul_pd(dy00,fscal),
263 _mm_mul_pd(dz00,fscal));
267 /* Inner loop uses 67 flops */
274 j_coord_offsetA = DIM*jnrA;
276 /* load j atom coordinates */
277 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
280 /* Calculate displacement vector */
281 dx00 = _mm_sub_pd(ix0,jx0);
282 dy00 = _mm_sub_pd(iy0,jy0);
283 dz00 = _mm_sub_pd(iz0,jz0);
285 /* Calculate squared distance and things based on it */
286 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
288 rinv00 = avx128fma_invsqrt_d(rsq00);
290 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
292 /* Load parameters for j particles */
293 jq0 = _mm_load_sd(charge+jnrA+0);
294 vdwjidx0A = 2*vdwtype[jnrA+0];
296 /**************************
297 * CALCULATE INTERACTIONS *
298 **************************/
300 if (gmx_mm_any_lt(rsq00,rcutoff2))
303 r00 = _mm_mul_pd(rsq00,rinv00);
305 /* Compute parameters for interactions between i and j atoms */
306 qq00 = _mm_mul_pd(iq0,jq0);
307 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
309 /* EWALD ELECTROSTATICS */
311 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
312 ewrt = _mm_mul_pd(r00,ewtabscale);
313 ewitab = _mm_cvttpd_epi32(ewrt);
315 eweps = _mm_frcz_pd(ewrt);
317 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
319 twoeweps = _mm_add_pd(eweps,eweps);
320 ewitab = _mm_slli_epi32(ewitab,2);
321 ewtabF = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,0) );
322 ewtabD = _mm_setzero_pd();
323 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
324 ewtabV = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,0) +2);
325 ewtabFn = _mm_setzero_pd();
326 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
327 felec = _mm_macc_pd(eweps,ewtabD,ewtabF);
328 velec = _mm_nmacc_pd(_mm_mul_pd(ewtabhalfspace,eweps) ,_mm_add_pd(ewtabF,felec), ewtabV);
329 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_sub_pd(rinv00,sh_ewald),velec));
330 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
332 /* LENNARD-JONES DISPERSION/REPULSION */
334 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
335 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
336 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
337 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
338 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
339 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
341 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
343 /* Update potential sum for this i atom from the interaction with this j atom. */
344 velec = _mm_and_pd(velec,cutoff_mask);
345 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
346 velecsum = _mm_add_pd(velecsum,velec);
347 vvdw = _mm_and_pd(vvdw,cutoff_mask);
348 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
349 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
351 fscal = _mm_add_pd(felec,fvdw);
353 fscal = _mm_and_pd(fscal,cutoff_mask);
355 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
357 /* Update vectorial force */
358 fix0 = _mm_macc_pd(dx00,fscal,fix0);
359 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
360 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
362 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
363 _mm_mul_pd(dx00,fscal),
364 _mm_mul_pd(dy00,fscal),
365 _mm_mul_pd(dz00,fscal));
369 /* Inner loop uses 67 flops */
372 /* End of innermost loop */
374 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
375 f+i_coord_offset,fshift+i_shift_offset);
378 /* Update potential energies */
379 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
380 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
382 /* Increment number of inner iterations */
383 inneriter += j_index_end - j_index_start;
385 /* Outer loop uses 9 flops */
388 /* Increment number of outer iterations */
391 /* Update outer/inner flops */
393 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*67);
396 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_F_avx_128_fma_double
397 * Electrostatics interaction: Ewald
398 * VdW interaction: LennardJones
399 * Geometry: Particle-Particle
400 * Calculate force/pot: Force
403 nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_F_avx_128_fma_double
404 (t_nblist * gmx_restrict nlist,
405 rvec * gmx_restrict xx,
406 rvec * gmx_restrict ff,
407 struct t_forcerec * gmx_restrict fr,
408 t_mdatoms * gmx_restrict mdatoms,
409 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
410 t_nrnb * gmx_restrict nrnb)
412 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
413 * just 0 for non-waters.
414 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
415 * jnr indices corresponding to data put in the four positions in the SIMD register.
417 int i_shift_offset,i_coord_offset,outeriter,inneriter;
418 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
420 int j_coord_offsetA,j_coord_offsetB;
421 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
423 real *shiftvec,*fshift,*x,*f;
424 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
426 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
427 int vdwjidx0A,vdwjidx0B;
428 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
429 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
430 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
433 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
436 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
437 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
439 __m128d ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
441 __m128d dummy_mask,cutoff_mask;
442 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
443 __m128d one = _mm_set1_pd(1.0);
444 __m128d two = _mm_set1_pd(2.0);
450 jindex = nlist->jindex;
452 shiftidx = nlist->shift;
454 shiftvec = fr->shift_vec[0];
455 fshift = fr->fshift[0];
456 facel = _mm_set1_pd(fr->ic->epsfac);
457 charge = mdatoms->chargeA;
458 nvdwtype = fr->ntype;
460 vdwtype = mdatoms->typeA;
462 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
463 ewtab = fr->ic->tabq_coul_F;
464 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
465 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
467 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
468 rcutoff_scalar = fr->ic->rcoulomb;
469 rcutoff = _mm_set1_pd(rcutoff_scalar);
470 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
472 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
473 rvdw = _mm_set1_pd(fr->ic->rvdw);
475 /* Avoid stupid compiler warnings */
483 /* Start outer loop over neighborlists */
484 for(iidx=0; iidx<nri; iidx++)
486 /* Load shift vector for this list */
487 i_shift_offset = DIM*shiftidx[iidx];
489 /* Load limits for loop over neighbors */
490 j_index_start = jindex[iidx];
491 j_index_end = jindex[iidx+1];
493 /* Get outer coordinate index */
495 i_coord_offset = DIM*inr;
497 /* Load i particle coords and add shift vector */
498 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
500 fix0 = _mm_setzero_pd();
501 fiy0 = _mm_setzero_pd();
502 fiz0 = _mm_setzero_pd();
504 /* Load parameters for i particles */
505 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
506 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
508 /* Start inner kernel loop */
509 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
512 /* Get j neighbor index, and coordinate index */
515 j_coord_offsetA = DIM*jnrA;
516 j_coord_offsetB = DIM*jnrB;
518 /* load j atom coordinates */
519 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
522 /* Calculate displacement vector */
523 dx00 = _mm_sub_pd(ix0,jx0);
524 dy00 = _mm_sub_pd(iy0,jy0);
525 dz00 = _mm_sub_pd(iz0,jz0);
527 /* Calculate squared distance and things based on it */
528 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
530 rinv00 = avx128fma_invsqrt_d(rsq00);
532 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
534 /* Load parameters for j particles */
535 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
536 vdwjidx0A = 2*vdwtype[jnrA+0];
537 vdwjidx0B = 2*vdwtype[jnrB+0];
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
543 if (gmx_mm_any_lt(rsq00,rcutoff2))
546 r00 = _mm_mul_pd(rsq00,rinv00);
548 /* Compute parameters for interactions between i and j atoms */
549 qq00 = _mm_mul_pd(iq0,jq0);
550 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
551 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
553 /* EWALD ELECTROSTATICS */
555 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
556 ewrt = _mm_mul_pd(r00,ewtabscale);
557 ewitab = _mm_cvttpd_epi32(ewrt);
559 eweps = _mm_frcz_pd(ewrt);
561 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
563 twoeweps = _mm_add_pd(eweps,eweps);
564 gmx_mm_load_2pair_swizzle_pd(ewtab+_mm_extract_epi32(ewitab,0),ewtab+_mm_extract_epi32(ewitab,1),
566 felec = _mm_macc_pd(eweps,ewtabFn,_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF));
567 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
569 /* LENNARD-JONES DISPERSION/REPULSION */
571 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
572 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
574 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
576 fscal = _mm_add_pd(felec,fvdw);
578 fscal = _mm_and_pd(fscal,cutoff_mask);
580 /* Update vectorial force */
581 fix0 = _mm_macc_pd(dx00,fscal,fix0);
582 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
583 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
585 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
586 _mm_mul_pd(dx00,fscal),
587 _mm_mul_pd(dy00,fscal),
588 _mm_mul_pd(dz00,fscal));
592 /* Inner loop uses 49 flops */
599 j_coord_offsetA = DIM*jnrA;
601 /* load j atom coordinates */
602 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
605 /* Calculate displacement vector */
606 dx00 = _mm_sub_pd(ix0,jx0);
607 dy00 = _mm_sub_pd(iy0,jy0);
608 dz00 = _mm_sub_pd(iz0,jz0);
610 /* Calculate squared distance and things based on it */
611 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
613 rinv00 = avx128fma_invsqrt_d(rsq00);
615 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
617 /* Load parameters for j particles */
618 jq0 = _mm_load_sd(charge+jnrA+0);
619 vdwjidx0A = 2*vdwtype[jnrA+0];
621 /**************************
622 * CALCULATE INTERACTIONS *
623 **************************/
625 if (gmx_mm_any_lt(rsq00,rcutoff2))
628 r00 = _mm_mul_pd(rsq00,rinv00);
630 /* Compute parameters for interactions between i and j atoms */
631 qq00 = _mm_mul_pd(iq0,jq0);
632 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
634 /* EWALD ELECTROSTATICS */
636 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
637 ewrt = _mm_mul_pd(r00,ewtabscale);
638 ewitab = _mm_cvttpd_epi32(ewrt);
640 eweps = _mm_frcz_pd(ewrt);
642 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
644 twoeweps = _mm_add_pd(eweps,eweps);
645 gmx_mm_load_1pair_swizzle_pd(ewtab+_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
646 felec = _mm_macc_pd(eweps,ewtabFn,_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF));
647 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
649 /* LENNARD-JONES DISPERSION/REPULSION */
651 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
652 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
654 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
656 fscal = _mm_add_pd(felec,fvdw);
658 fscal = _mm_and_pd(fscal,cutoff_mask);
660 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
662 /* Update vectorial force */
663 fix0 = _mm_macc_pd(dx00,fscal,fix0);
664 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
665 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
667 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
668 _mm_mul_pd(dx00,fscal),
669 _mm_mul_pd(dy00,fscal),
670 _mm_mul_pd(dz00,fscal));
674 /* Inner loop uses 49 flops */
677 /* End of innermost loop */
679 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
680 f+i_coord_offset,fshift+i_shift_offset);
682 /* Increment number of inner iterations */
683 inneriter += j_index_end - j_index_start;
685 /* Outer loop uses 7 flops */
688 /* Increment number of outer iterations */
691 /* Update outer/inner flops */
693 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*49);