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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_avx_128_fma_single
54 * Electrostatics interaction: Ewald
55 * VdW interaction: None
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_VF_avx_128_fma_single
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
88 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
94 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
96 __m128 dummy_mask,cutoff_mask;
97 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
98 __m128 one = _mm_set1_ps(1.0);
99 __m128 two = _mm_set1_ps(2.0);
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
111 facel = _mm_set1_ps(fr->epsfac);
112 charge = mdatoms->chargeA;
114 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
115 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
116 beta2 = _mm_mul_ps(beta,beta);
117 beta3 = _mm_mul_ps(beta,beta2);
118 ewtab = fr->ic->tabq_coul_FDV0;
119 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
120 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
122 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
123 rcutoff_scalar = fr->rcoulomb;
124 rcutoff = _mm_set1_ps(rcutoff_scalar);
125 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
127 /* Avoid stupid compiler warnings */
128 jnrA = jnrB = jnrC = jnrD = 0;
137 for(iidx=0;iidx<4*DIM;iidx++)
142 /* Start outer loop over neighborlists */
143 for(iidx=0; iidx<nri; iidx++)
145 /* Load shift vector for this list */
146 i_shift_offset = DIM*shiftidx[iidx];
148 /* Load limits for loop over neighbors */
149 j_index_start = jindex[iidx];
150 j_index_end = jindex[iidx+1];
152 /* Get outer coordinate index */
154 i_coord_offset = DIM*inr;
156 /* Load i particle coords and add shift vector */
157 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
159 fix0 = _mm_setzero_ps();
160 fiy0 = _mm_setzero_ps();
161 fiz0 = _mm_setzero_ps();
163 /* Load parameters for i particles */
164 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
166 /* Reset potential sums */
167 velecsum = _mm_setzero_ps();
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
173 /* Get j neighbor index, and coordinate index */
178 j_coord_offsetA = DIM*jnrA;
179 j_coord_offsetB = DIM*jnrB;
180 j_coord_offsetC = DIM*jnrC;
181 j_coord_offsetD = DIM*jnrD;
183 /* load j atom coordinates */
184 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
185 x+j_coord_offsetC,x+j_coord_offsetD,
188 /* Calculate displacement vector */
189 dx00 = _mm_sub_ps(ix0,jx0);
190 dy00 = _mm_sub_ps(iy0,jy0);
191 dz00 = _mm_sub_ps(iz0,jz0);
193 /* Calculate squared distance and things based on it */
194 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
196 rinv00 = gmx_mm_invsqrt_ps(rsq00);
198 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
200 /* Load parameters for j particles */
201 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
202 charge+jnrC+0,charge+jnrD+0);
204 /**************************
205 * CALCULATE INTERACTIONS *
206 **************************/
208 if (gmx_mm_any_lt(rsq00,rcutoff2))
211 r00 = _mm_mul_ps(rsq00,rinv00);
213 /* Compute parameters for interactions between i and j atoms */
214 qq00 = _mm_mul_ps(iq0,jq0);
216 /* EWALD ELECTROSTATICS */
218 /* Analytical PME correction */
219 zeta2 = _mm_mul_ps(beta2,rsq00);
220 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
221 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
222 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
223 felec = _mm_mul_ps(qq00,felec);
224 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
225 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
226 velec = _mm_mul_ps(qq00,velec);
228 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
230 /* Update potential sum for this i atom from the interaction with this j atom. */
231 velec = _mm_and_ps(velec,cutoff_mask);
232 velecsum = _mm_add_ps(velecsum,velec);
236 fscal = _mm_and_ps(fscal,cutoff_mask);
238 /* Update vectorial force */
239 fix0 = _mm_macc_ps(dx00,fscal,fix0);
240 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
241 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
243 fjptrA = f+j_coord_offsetA;
244 fjptrB = f+j_coord_offsetB;
245 fjptrC = f+j_coord_offsetC;
246 fjptrD = f+j_coord_offsetD;
247 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
248 _mm_mul_ps(dx00,fscal),
249 _mm_mul_ps(dy00,fscal),
250 _mm_mul_ps(dz00,fscal));
254 /* Inner loop uses 33 flops */
260 /* Get j neighbor index, and coordinate index */
261 jnrlistA = jjnr[jidx];
262 jnrlistB = jjnr[jidx+1];
263 jnrlistC = jjnr[jidx+2];
264 jnrlistD = jjnr[jidx+3];
265 /* Sign of each element will be negative for non-real atoms.
266 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
267 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
269 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
270 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
271 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
272 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
273 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
274 j_coord_offsetA = DIM*jnrA;
275 j_coord_offsetB = DIM*jnrB;
276 j_coord_offsetC = DIM*jnrC;
277 j_coord_offsetD = DIM*jnrD;
279 /* load j atom coordinates */
280 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
281 x+j_coord_offsetC,x+j_coord_offsetD,
284 /* Calculate displacement vector */
285 dx00 = _mm_sub_ps(ix0,jx0);
286 dy00 = _mm_sub_ps(iy0,jy0);
287 dz00 = _mm_sub_ps(iz0,jz0);
289 /* Calculate squared distance and things based on it */
290 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
292 rinv00 = gmx_mm_invsqrt_ps(rsq00);
294 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
296 /* Load parameters for j particles */
297 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
298 charge+jnrC+0,charge+jnrD+0);
300 /**************************
301 * CALCULATE INTERACTIONS *
302 **************************/
304 if (gmx_mm_any_lt(rsq00,rcutoff2))
307 r00 = _mm_mul_ps(rsq00,rinv00);
308 r00 = _mm_andnot_ps(dummy_mask,r00);
310 /* Compute parameters for interactions between i and j atoms */
311 qq00 = _mm_mul_ps(iq0,jq0);
313 /* EWALD ELECTROSTATICS */
315 /* Analytical PME correction */
316 zeta2 = _mm_mul_ps(beta2,rsq00);
317 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
318 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
319 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
320 felec = _mm_mul_ps(qq00,felec);
321 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
322 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
323 velec = _mm_mul_ps(qq00,velec);
325 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
327 /* Update potential sum for this i atom from the interaction with this j atom. */
328 velec = _mm_and_ps(velec,cutoff_mask);
329 velec = _mm_andnot_ps(dummy_mask,velec);
330 velecsum = _mm_add_ps(velecsum,velec);
334 fscal = _mm_and_ps(fscal,cutoff_mask);
336 fscal = _mm_andnot_ps(dummy_mask,fscal);
338 /* Update vectorial force */
339 fix0 = _mm_macc_ps(dx00,fscal,fix0);
340 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
341 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
343 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
344 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
345 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
346 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
347 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
348 _mm_mul_ps(dx00,fscal),
349 _mm_mul_ps(dy00,fscal),
350 _mm_mul_ps(dz00,fscal));
354 /* Inner loop uses 34 flops */
357 /* End of innermost loop */
359 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
360 f+i_coord_offset,fshift+i_shift_offset);
363 /* Update potential energies */
364 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
366 /* Increment number of inner iterations */
367 inneriter += j_index_end - j_index_start;
369 /* Outer loop uses 8 flops */
372 /* Increment number of outer iterations */
375 /* Update outer/inner flops */
377 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*34);
380 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
381 * Electrostatics interaction: Ewald
382 * VdW interaction: None
383 * Geometry: Particle-Particle
384 * Calculate force/pot: Force
387 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
388 (t_nblist * gmx_restrict nlist,
389 rvec * gmx_restrict xx,
390 rvec * gmx_restrict ff,
391 t_forcerec * gmx_restrict fr,
392 t_mdatoms * gmx_restrict mdatoms,
393 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
394 t_nrnb * gmx_restrict nrnb)
396 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
397 * just 0 for non-waters.
398 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
399 * jnr indices corresponding to data put in the four positions in the SIMD register.
401 int i_shift_offset,i_coord_offset,outeriter,inneriter;
402 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
403 int jnrA,jnrB,jnrC,jnrD;
404 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
405 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
406 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
408 real *shiftvec,*fshift,*x,*f;
409 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
411 __m128 fscal,rcutoff,rcutoff2,jidxall;
413 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
414 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
415 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
416 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
417 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
420 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
421 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
423 __m128 dummy_mask,cutoff_mask;
424 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
425 __m128 one = _mm_set1_ps(1.0);
426 __m128 two = _mm_set1_ps(2.0);
432 jindex = nlist->jindex;
434 shiftidx = nlist->shift;
436 shiftvec = fr->shift_vec[0];
437 fshift = fr->fshift[0];
438 facel = _mm_set1_ps(fr->epsfac);
439 charge = mdatoms->chargeA;
441 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
442 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
443 beta2 = _mm_mul_ps(beta,beta);
444 beta3 = _mm_mul_ps(beta,beta2);
445 ewtab = fr->ic->tabq_coul_F;
446 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
447 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
449 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
450 rcutoff_scalar = fr->rcoulomb;
451 rcutoff = _mm_set1_ps(rcutoff_scalar);
452 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
454 /* Avoid stupid compiler warnings */
455 jnrA = jnrB = jnrC = jnrD = 0;
464 for(iidx=0;iidx<4*DIM;iidx++)
469 /* Start outer loop over neighborlists */
470 for(iidx=0; iidx<nri; iidx++)
472 /* Load shift vector for this list */
473 i_shift_offset = DIM*shiftidx[iidx];
475 /* Load limits for loop over neighbors */
476 j_index_start = jindex[iidx];
477 j_index_end = jindex[iidx+1];
479 /* Get outer coordinate index */
481 i_coord_offset = DIM*inr;
483 /* Load i particle coords and add shift vector */
484 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
486 fix0 = _mm_setzero_ps();
487 fiy0 = _mm_setzero_ps();
488 fiz0 = _mm_setzero_ps();
490 /* Load parameters for i particles */
491 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
493 /* Start inner kernel loop */
494 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
497 /* Get j neighbor index, and coordinate index */
502 j_coord_offsetA = DIM*jnrA;
503 j_coord_offsetB = DIM*jnrB;
504 j_coord_offsetC = DIM*jnrC;
505 j_coord_offsetD = DIM*jnrD;
507 /* load j atom coordinates */
508 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
509 x+j_coord_offsetC,x+j_coord_offsetD,
512 /* Calculate displacement vector */
513 dx00 = _mm_sub_ps(ix0,jx0);
514 dy00 = _mm_sub_ps(iy0,jy0);
515 dz00 = _mm_sub_ps(iz0,jz0);
517 /* Calculate squared distance and things based on it */
518 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
520 rinv00 = gmx_mm_invsqrt_ps(rsq00);
522 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
524 /* Load parameters for j particles */
525 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
526 charge+jnrC+0,charge+jnrD+0);
528 /**************************
529 * CALCULATE INTERACTIONS *
530 **************************/
532 if (gmx_mm_any_lt(rsq00,rcutoff2))
535 r00 = _mm_mul_ps(rsq00,rinv00);
537 /* Compute parameters for interactions between i and j atoms */
538 qq00 = _mm_mul_ps(iq0,jq0);
540 /* EWALD ELECTROSTATICS */
542 /* Analytical PME correction */
543 zeta2 = _mm_mul_ps(beta2,rsq00);
544 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
545 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
546 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
547 felec = _mm_mul_ps(qq00,felec);
549 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
553 fscal = _mm_and_ps(fscal,cutoff_mask);
555 /* Update vectorial force */
556 fix0 = _mm_macc_ps(dx00,fscal,fix0);
557 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
558 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
560 fjptrA = f+j_coord_offsetA;
561 fjptrB = f+j_coord_offsetB;
562 fjptrC = f+j_coord_offsetC;
563 fjptrD = f+j_coord_offsetD;
564 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
565 _mm_mul_ps(dx00,fscal),
566 _mm_mul_ps(dy00,fscal),
567 _mm_mul_ps(dz00,fscal));
571 /* Inner loop uses 31 flops */
577 /* Get j neighbor index, and coordinate index */
578 jnrlistA = jjnr[jidx];
579 jnrlistB = jjnr[jidx+1];
580 jnrlistC = jjnr[jidx+2];
581 jnrlistD = jjnr[jidx+3];
582 /* Sign of each element will be negative for non-real atoms.
583 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
584 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
586 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
587 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
588 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
589 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
590 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
591 j_coord_offsetA = DIM*jnrA;
592 j_coord_offsetB = DIM*jnrB;
593 j_coord_offsetC = DIM*jnrC;
594 j_coord_offsetD = DIM*jnrD;
596 /* load j atom coordinates */
597 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
598 x+j_coord_offsetC,x+j_coord_offsetD,
601 /* Calculate displacement vector */
602 dx00 = _mm_sub_ps(ix0,jx0);
603 dy00 = _mm_sub_ps(iy0,jy0);
604 dz00 = _mm_sub_ps(iz0,jz0);
606 /* Calculate squared distance and things based on it */
607 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
609 rinv00 = gmx_mm_invsqrt_ps(rsq00);
611 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
613 /* Load parameters for j particles */
614 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
615 charge+jnrC+0,charge+jnrD+0);
617 /**************************
618 * CALCULATE INTERACTIONS *
619 **************************/
621 if (gmx_mm_any_lt(rsq00,rcutoff2))
624 r00 = _mm_mul_ps(rsq00,rinv00);
625 r00 = _mm_andnot_ps(dummy_mask,r00);
627 /* Compute parameters for interactions between i and j atoms */
628 qq00 = _mm_mul_ps(iq0,jq0);
630 /* EWALD ELECTROSTATICS */
632 /* Analytical PME correction */
633 zeta2 = _mm_mul_ps(beta2,rsq00);
634 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
635 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
636 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
637 felec = _mm_mul_ps(qq00,felec);
639 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
643 fscal = _mm_and_ps(fscal,cutoff_mask);
645 fscal = _mm_andnot_ps(dummy_mask,fscal);
647 /* Update vectorial force */
648 fix0 = _mm_macc_ps(dx00,fscal,fix0);
649 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
650 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
652 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
653 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
654 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
655 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
656 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
657 _mm_mul_ps(dx00,fscal),
658 _mm_mul_ps(dy00,fscal),
659 _mm_mul_ps(dz00,fscal));
663 /* Inner loop uses 32 flops */
666 /* End of innermost loop */
668 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
669 f+i_coord_offset,fshift+i_shift_offset);
671 /* Increment number of inner iterations */
672 inneriter += j_index_end - j_index_start;
674 /* Outer loop uses 7 flops */
677 /* Increment number of outer iterations */
680 /* Update outer/inner flops */
682 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*32);