2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_128_fma_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_avx_128_fma_single
51 * Electrostatics interaction: Ewald
52 * VdW interaction: None
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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;
73 int jnrA,jnrB,jnrC,jnrD;
74 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81 __m128 fscal,rcutoff,rcutoff2,jidxall;
83 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
85 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
86 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
87 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
90 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
91 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
93 __m128 dummy_mask,cutoff_mask;
94 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
95 __m128 one = _mm_set1_ps(1.0);
96 __m128 two = _mm_set1_ps(2.0);
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
108 facel = _mm_set1_ps(fr->ic->epsfac);
109 charge = mdatoms->chargeA;
111 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
112 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
113 beta2 = _mm_mul_ps(beta,beta);
114 beta3 = _mm_mul_ps(beta,beta2);
115 ewtab = fr->ic->tabq_coul_FDV0;
116 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
117 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
119 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
120 rcutoff_scalar = fr->ic->rcoulomb;
121 rcutoff = _mm_set1_ps(rcutoff_scalar);
122 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
124 /* Avoid stupid compiler warnings */
125 jnrA = jnrB = jnrC = jnrD = 0;
134 for(iidx=0;iidx<4*DIM;iidx++)
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
156 fix0 = _mm_setzero_ps();
157 fiy0 = _mm_setzero_ps();
158 fiz0 = _mm_setzero_ps();
160 /* Load parameters for i particles */
161 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
163 /* Reset potential sums */
164 velecsum = _mm_setzero_ps();
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
170 /* Get j neighbor index, and coordinate index */
175 j_coord_offsetA = DIM*jnrA;
176 j_coord_offsetB = DIM*jnrB;
177 j_coord_offsetC = DIM*jnrC;
178 j_coord_offsetD = DIM*jnrD;
180 /* load j atom coordinates */
181 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
182 x+j_coord_offsetC,x+j_coord_offsetD,
185 /* Calculate displacement vector */
186 dx00 = _mm_sub_ps(ix0,jx0);
187 dy00 = _mm_sub_ps(iy0,jy0);
188 dz00 = _mm_sub_ps(iz0,jz0);
190 /* Calculate squared distance and things based on it */
191 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
193 rinv00 = avx128fma_invsqrt_f(rsq00);
195 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
197 /* Load parameters for j particles */
198 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
199 charge+jnrC+0,charge+jnrD+0);
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
205 if (gmx_mm_any_lt(rsq00,rcutoff2))
208 r00 = _mm_mul_ps(rsq00,rinv00);
210 /* Compute parameters for interactions between i and j atoms */
211 qq00 = _mm_mul_ps(iq0,jq0);
213 /* EWALD ELECTROSTATICS */
215 /* Analytical PME correction */
216 zeta2 = _mm_mul_ps(beta2,rsq00);
217 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
218 pmecorrF = avx128fma_pmecorrF_f(zeta2);
219 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
220 felec = _mm_mul_ps(qq00,felec);
221 pmecorrV = avx128fma_pmecorrV_f(zeta2);
222 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
223 velec = _mm_mul_ps(qq00,velec);
225 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
227 /* Update potential sum for this i atom from the interaction with this j atom. */
228 velec = _mm_and_ps(velec,cutoff_mask);
229 velecsum = _mm_add_ps(velecsum,velec);
233 fscal = _mm_and_ps(fscal,cutoff_mask);
235 /* Update vectorial force */
236 fix0 = _mm_macc_ps(dx00,fscal,fix0);
237 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
238 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
240 fjptrA = f+j_coord_offsetA;
241 fjptrB = f+j_coord_offsetB;
242 fjptrC = f+j_coord_offsetC;
243 fjptrD = f+j_coord_offsetD;
244 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
245 _mm_mul_ps(dx00,fscal),
246 _mm_mul_ps(dy00,fscal),
247 _mm_mul_ps(dz00,fscal));
251 /* Inner loop uses 33 flops */
257 /* Get j neighbor index, and coordinate index */
258 jnrlistA = jjnr[jidx];
259 jnrlistB = jjnr[jidx+1];
260 jnrlistC = jjnr[jidx+2];
261 jnrlistD = jjnr[jidx+3];
262 /* Sign of each element will be negative for non-real atoms.
263 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
264 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
266 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
267 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
268 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
269 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
270 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
271 j_coord_offsetA = DIM*jnrA;
272 j_coord_offsetB = DIM*jnrB;
273 j_coord_offsetC = DIM*jnrC;
274 j_coord_offsetD = DIM*jnrD;
276 /* load j atom coordinates */
277 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
278 x+j_coord_offsetC,x+j_coord_offsetD,
281 /* Calculate displacement vector */
282 dx00 = _mm_sub_ps(ix0,jx0);
283 dy00 = _mm_sub_ps(iy0,jy0);
284 dz00 = _mm_sub_ps(iz0,jz0);
286 /* Calculate squared distance and things based on it */
287 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
289 rinv00 = avx128fma_invsqrt_f(rsq00);
291 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
293 /* Load parameters for j particles */
294 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
295 charge+jnrC+0,charge+jnrD+0);
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
301 if (gmx_mm_any_lt(rsq00,rcutoff2))
304 r00 = _mm_mul_ps(rsq00,rinv00);
305 r00 = _mm_andnot_ps(dummy_mask,r00);
307 /* Compute parameters for interactions between i and j atoms */
308 qq00 = _mm_mul_ps(iq0,jq0);
310 /* EWALD ELECTROSTATICS */
312 /* Analytical PME correction */
313 zeta2 = _mm_mul_ps(beta2,rsq00);
314 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
315 pmecorrF = avx128fma_pmecorrF_f(zeta2);
316 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
317 felec = _mm_mul_ps(qq00,felec);
318 pmecorrV = avx128fma_pmecorrV_f(zeta2);
319 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
320 velec = _mm_mul_ps(qq00,velec);
322 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
324 /* Update potential sum for this i atom from the interaction with this j atom. */
325 velec = _mm_and_ps(velec,cutoff_mask);
326 velec = _mm_andnot_ps(dummy_mask,velec);
327 velecsum = _mm_add_ps(velecsum,velec);
331 fscal = _mm_and_ps(fscal,cutoff_mask);
333 fscal = _mm_andnot_ps(dummy_mask,fscal);
335 /* Update vectorial force */
336 fix0 = _mm_macc_ps(dx00,fscal,fix0);
337 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
338 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
340 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
341 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
342 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
343 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
344 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
345 _mm_mul_ps(dx00,fscal),
346 _mm_mul_ps(dy00,fscal),
347 _mm_mul_ps(dz00,fscal));
351 /* Inner loop uses 34 flops */
354 /* End of innermost loop */
356 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
357 f+i_coord_offset,fshift+i_shift_offset);
360 /* Update potential energies */
361 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
363 /* Increment number of inner iterations */
364 inneriter += j_index_end - j_index_start;
366 /* Outer loop uses 8 flops */
369 /* Increment number of outer iterations */
372 /* Update outer/inner flops */
374 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*34);
377 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
378 * Electrostatics interaction: Ewald
379 * VdW interaction: None
380 * Geometry: Particle-Particle
381 * Calculate force/pot: Force
384 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
385 (t_nblist * gmx_restrict nlist,
386 rvec * gmx_restrict xx,
387 rvec * gmx_restrict ff,
388 struct t_forcerec * gmx_restrict fr,
389 t_mdatoms * gmx_restrict mdatoms,
390 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
391 t_nrnb * gmx_restrict nrnb)
393 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
394 * just 0 for non-waters.
395 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
396 * jnr indices corresponding to data put in the four positions in the SIMD register.
398 int i_shift_offset,i_coord_offset,outeriter,inneriter;
399 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
400 int jnrA,jnrB,jnrC,jnrD;
401 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
402 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
403 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
405 real *shiftvec,*fshift,*x,*f;
406 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
408 __m128 fscal,rcutoff,rcutoff2,jidxall;
410 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
411 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
412 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
413 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
414 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
417 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
418 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
420 __m128 dummy_mask,cutoff_mask;
421 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
422 __m128 one = _mm_set1_ps(1.0);
423 __m128 two = _mm_set1_ps(2.0);
429 jindex = nlist->jindex;
431 shiftidx = nlist->shift;
433 shiftvec = fr->shift_vec[0];
434 fshift = fr->fshift[0];
435 facel = _mm_set1_ps(fr->ic->epsfac);
436 charge = mdatoms->chargeA;
438 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
439 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
440 beta2 = _mm_mul_ps(beta,beta);
441 beta3 = _mm_mul_ps(beta,beta2);
442 ewtab = fr->ic->tabq_coul_F;
443 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
444 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
446 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
447 rcutoff_scalar = fr->ic->rcoulomb;
448 rcutoff = _mm_set1_ps(rcutoff_scalar);
449 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
451 /* Avoid stupid compiler warnings */
452 jnrA = jnrB = jnrC = jnrD = 0;
461 for(iidx=0;iidx<4*DIM;iidx++)
466 /* Start outer loop over neighborlists */
467 for(iidx=0; iidx<nri; iidx++)
469 /* Load shift vector for this list */
470 i_shift_offset = DIM*shiftidx[iidx];
472 /* Load limits for loop over neighbors */
473 j_index_start = jindex[iidx];
474 j_index_end = jindex[iidx+1];
476 /* Get outer coordinate index */
478 i_coord_offset = DIM*inr;
480 /* Load i particle coords and add shift vector */
481 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
483 fix0 = _mm_setzero_ps();
484 fiy0 = _mm_setzero_ps();
485 fiz0 = _mm_setzero_ps();
487 /* Load parameters for i particles */
488 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
490 /* Start inner kernel loop */
491 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
494 /* Get j neighbor index, and coordinate index */
499 j_coord_offsetA = DIM*jnrA;
500 j_coord_offsetB = DIM*jnrB;
501 j_coord_offsetC = DIM*jnrC;
502 j_coord_offsetD = DIM*jnrD;
504 /* load j atom coordinates */
505 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
506 x+j_coord_offsetC,x+j_coord_offsetD,
509 /* Calculate displacement vector */
510 dx00 = _mm_sub_ps(ix0,jx0);
511 dy00 = _mm_sub_ps(iy0,jy0);
512 dz00 = _mm_sub_ps(iz0,jz0);
514 /* Calculate squared distance and things based on it */
515 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
517 rinv00 = avx128fma_invsqrt_f(rsq00);
519 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
521 /* Load parameters for j particles */
522 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
523 charge+jnrC+0,charge+jnrD+0);
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
529 if (gmx_mm_any_lt(rsq00,rcutoff2))
532 r00 = _mm_mul_ps(rsq00,rinv00);
534 /* Compute parameters for interactions between i and j atoms */
535 qq00 = _mm_mul_ps(iq0,jq0);
537 /* EWALD ELECTROSTATICS */
539 /* Analytical PME correction */
540 zeta2 = _mm_mul_ps(beta2,rsq00);
541 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
542 pmecorrF = avx128fma_pmecorrF_f(zeta2);
543 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
544 felec = _mm_mul_ps(qq00,felec);
546 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
550 fscal = _mm_and_ps(fscal,cutoff_mask);
552 /* Update vectorial force */
553 fix0 = _mm_macc_ps(dx00,fscal,fix0);
554 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
555 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
557 fjptrA = f+j_coord_offsetA;
558 fjptrB = f+j_coord_offsetB;
559 fjptrC = f+j_coord_offsetC;
560 fjptrD = f+j_coord_offsetD;
561 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
562 _mm_mul_ps(dx00,fscal),
563 _mm_mul_ps(dy00,fscal),
564 _mm_mul_ps(dz00,fscal));
568 /* Inner loop uses 31 flops */
574 /* Get j neighbor index, and coordinate index */
575 jnrlistA = jjnr[jidx];
576 jnrlistB = jjnr[jidx+1];
577 jnrlistC = jjnr[jidx+2];
578 jnrlistD = jjnr[jidx+3];
579 /* Sign of each element will be negative for non-real atoms.
580 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
581 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
583 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
584 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
585 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
586 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
587 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
588 j_coord_offsetA = DIM*jnrA;
589 j_coord_offsetB = DIM*jnrB;
590 j_coord_offsetC = DIM*jnrC;
591 j_coord_offsetD = DIM*jnrD;
593 /* load j atom coordinates */
594 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
595 x+j_coord_offsetC,x+j_coord_offsetD,
598 /* Calculate displacement vector */
599 dx00 = _mm_sub_ps(ix0,jx0);
600 dy00 = _mm_sub_ps(iy0,jy0);
601 dz00 = _mm_sub_ps(iz0,jz0);
603 /* Calculate squared distance and things based on it */
604 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
606 rinv00 = avx128fma_invsqrt_f(rsq00);
608 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
610 /* Load parameters for j particles */
611 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
612 charge+jnrC+0,charge+jnrD+0);
614 /**************************
615 * CALCULATE INTERACTIONS *
616 **************************/
618 if (gmx_mm_any_lt(rsq00,rcutoff2))
621 r00 = _mm_mul_ps(rsq00,rinv00);
622 r00 = _mm_andnot_ps(dummy_mask,r00);
624 /* Compute parameters for interactions between i and j atoms */
625 qq00 = _mm_mul_ps(iq0,jq0);
627 /* EWALD ELECTROSTATICS */
629 /* Analytical PME correction */
630 zeta2 = _mm_mul_ps(beta2,rsq00);
631 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
632 pmecorrF = avx128fma_pmecorrF_f(zeta2);
633 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
634 felec = _mm_mul_ps(qq00,felec);
636 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
640 fscal = _mm_and_ps(fscal,cutoff_mask);
642 fscal = _mm_andnot_ps(dummy_mask,fscal);
644 /* Update vectorial force */
645 fix0 = _mm_macc_ps(dx00,fscal,fix0);
646 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
647 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
649 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
650 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
651 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
652 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
653 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
654 _mm_mul_ps(dx00,fscal),
655 _mm_mul_ps(dy00,fscal),
656 _mm_mul_ps(dz00,fscal));
660 /* Inner loop uses 32 flops */
663 /* End of innermost loop */
665 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
666 f+i_coord_offset,fshift+i_shift_offset);
668 /* Increment number of inner iterations */
669 inneriter += j_index_end - j_index_start;
671 /* Outer loop uses 7 flops */
674 /* Increment number of outer iterations */
677 /* Update outer/inner flops */
679 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*32);