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_ElecEwSh_VdwNone_GeomP1P1_VF_avx_128_fma_single
52 * Electrostatics interaction: Ewald
53 * VdW interaction: None
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_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;
85 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
86 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
91 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
92 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
94 __m128 dummy_mask,cutoff_mask;
95 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
96 __m128 one = _mm_set1_ps(1.0);
97 __m128 two = _mm_set1_ps(2.0);
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
109 facel = _mm_set1_ps(fr->epsfac);
110 charge = mdatoms->chargeA;
112 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
113 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
114 beta2 = _mm_mul_ps(beta,beta);
115 beta3 = _mm_mul_ps(beta,beta2);
116 ewtab = fr->ic->tabq_coul_FDV0;
117 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
118 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
120 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
121 rcutoff_scalar = fr->rcoulomb;
122 rcutoff = _mm_set1_ps(rcutoff_scalar);
123 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
125 /* Avoid stupid compiler warnings */
126 jnrA = jnrB = jnrC = jnrD = 0;
135 for(iidx=0;iidx<4*DIM;iidx++)
140 /* Start outer loop over neighborlists */
141 for(iidx=0; iidx<nri; iidx++)
143 /* Load shift vector for this list */
144 i_shift_offset = DIM*shiftidx[iidx];
146 /* Load limits for loop over neighbors */
147 j_index_start = jindex[iidx];
148 j_index_end = jindex[iidx+1];
150 /* Get outer coordinate index */
152 i_coord_offset = DIM*inr;
154 /* Load i particle coords and add shift vector */
155 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
157 fix0 = _mm_setzero_ps();
158 fiy0 = _mm_setzero_ps();
159 fiz0 = _mm_setzero_ps();
161 /* Load parameters for i particles */
162 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
164 /* Reset potential sums */
165 velecsum = _mm_setzero_ps();
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
171 /* Get j neighbor index, and coordinate index */
176 j_coord_offsetA = DIM*jnrA;
177 j_coord_offsetB = DIM*jnrB;
178 j_coord_offsetC = DIM*jnrC;
179 j_coord_offsetD = DIM*jnrD;
181 /* load j atom coordinates */
182 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
183 x+j_coord_offsetC,x+j_coord_offsetD,
186 /* Calculate displacement vector */
187 dx00 = _mm_sub_ps(ix0,jx0);
188 dy00 = _mm_sub_ps(iy0,jy0);
189 dz00 = _mm_sub_ps(iz0,jz0);
191 /* Calculate squared distance and things based on it */
192 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
194 rinv00 = gmx_mm_invsqrt_ps(rsq00);
196 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
198 /* Load parameters for j particles */
199 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
200 charge+jnrC+0,charge+jnrD+0);
202 /**************************
203 * CALCULATE INTERACTIONS *
204 **************************/
206 if (gmx_mm_any_lt(rsq00,rcutoff2))
209 r00 = _mm_mul_ps(rsq00,rinv00);
211 /* Compute parameters for interactions between i and j atoms */
212 qq00 = _mm_mul_ps(iq0,jq0);
214 /* EWALD ELECTROSTATICS */
216 /* Analytical PME correction */
217 zeta2 = _mm_mul_ps(beta2,rsq00);
218 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
219 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
220 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
221 felec = _mm_mul_ps(qq00,felec);
222 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
223 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
224 velec = _mm_mul_ps(qq00,velec);
226 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
228 /* Update potential sum for this i atom from the interaction with this j atom. */
229 velec = _mm_and_ps(velec,cutoff_mask);
230 velecsum = _mm_add_ps(velecsum,velec);
234 fscal = _mm_and_ps(fscal,cutoff_mask);
236 /* Update vectorial force */
237 fix0 = _mm_macc_ps(dx00,fscal,fix0);
238 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
239 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
241 fjptrA = f+j_coord_offsetA;
242 fjptrB = f+j_coord_offsetB;
243 fjptrC = f+j_coord_offsetC;
244 fjptrD = f+j_coord_offsetD;
245 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
246 _mm_mul_ps(dx00,fscal),
247 _mm_mul_ps(dy00,fscal),
248 _mm_mul_ps(dz00,fscal));
252 /* Inner loop uses 33 flops */
258 /* Get j neighbor index, and coordinate index */
259 jnrlistA = jjnr[jidx];
260 jnrlistB = jjnr[jidx+1];
261 jnrlistC = jjnr[jidx+2];
262 jnrlistD = jjnr[jidx+3];
263 /* Sign of each element will be negative for non-real atoms.
264 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
265 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
267 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
268 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
269 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
270 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
271 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
272 j_coord_offsetA = DIM*jnrA;
273 j_coord_offsetB = DIM*jnrB;
274 j_coord_offsetC = DIM*jnrC;
275 j_coord_offsetD = DIM*jnrD;
277 /* load j atom coordinates */
278 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
279 x+j_coord_offsetC,x+j_coord_offsetD,
282 /* Calculate displacement vector */
283 dx00 = _mm_sub_ps(ix0,jx0);
284 dy00 = _mm_sub_ps(iy0,jy0);
285 dz00 = _mm_sub_ps(iz0,jz0);
287 /* Calculate squared distance and things based on it */
288 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
290 rinv00 = gmx_mm_invsqrt_ps(rsq00);
292 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
294 /* Load parameters for j particles */
295 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
296 charge+jnrC+0,charge+jnrD+0);
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
302 if (gmx_mm_any_lt(rsq00,rcutoff2))
305 r00 = _mm_mul_ps(rsq00,rinv00);
306 r00 = _mm_andnot_ps(dummy_mask,r00);
308 /* Compute parameters for interactions between i and j atoms */
309 qq00 = _mm_mul_ps(iq0,jq0);
311 /* EWALD ELECTROSTATICS */
313 /* Analytical PME correction */
314 zeta2 = _mm_mul_ps(beta2,rsq00);
315 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
316 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
317 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
318 felec = _mm_mul_ps(qq00,felec);
319 pmecorrV = gmx_mm_pmecorrV_ps(zeta2);
320 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
321 velec = _mm_mul_ps(qq00,velec);
323 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
325 /* Update potential sum for this i atom from the interaction with this j atom. */
326 velec = _mm_and_ps(velec,cutoff_mask);
327 velec = _mm_andnot_ps(dummy_mask,velec);
328 velecsum = _mm_add_ps(velecsum,velec);
332 fscal = _mm_and_ps(fscal,cutoff_mask);
334 fscal = _mm_andnot_ps(dummy_mask,fscal);
336 /* Update vectorial force */
337 fix0 = _mm_macc_ps(dx00,fscal,fix0);
338 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
339 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
341 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
342 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
343 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
344 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
345 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
346 _mm_mul_ps(dx00,fscal),
347 _mm_mul_ps(dy00,fscal),
348 _mm_mul_ps(dz00,fscal));
352 /* Inner loop uses 34 flops */
355 /* End of innermost loop */
357 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
358 f+i_coord_offset,fshift+i_shift_offset);
361 /* Update potential energies */
362 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
364 /* Increment number of inner iterations */
365 inneriter += j_index_end - j_index_start;
367 /* Outer loop uses 8 flops */
370 /* Increment number of outer iterations */
373 /* Update outer/inner flops */
375 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*34);
378 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
379 * Electrostatics interaction: Ewald
380 * VdW interaction: None
381 * Geometry: Particle-Particle
382 * Calculate force/pot: Force
385 nb_kernel_ElecEwSh_VdwNone_GeomP1P1_F_avx_128_fma_single
386 (t_nblist * gmx_restrict nlist,
387 rvec * gmx_restrict xx,
388 rvec * gmx_restrict ff,
389 t_forcerec * gmx_restrict fr,
390 t_mdatoms * gmx_restrict mdatoms,
391 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
392 t_nrnb * gmx_restrict nrnb)
394 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
395 * just 0 for non-waters.
396 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
397 * jnr indices corresponding to data put in the four positions in the SIMD register.
399 int i_shift_offset,i_coord_offset,outeriter,inneriter;
400 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
401 int jnrA,jnrB,jnrC,jnrD;
402 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
403 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
404 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
406 real *shiftvec,*fshift,*x,*f;
407 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
409 __m128 fscal,rcutoff,rcutoff2,jidxall;
411 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
412 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
413 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
414 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
415 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
418 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
419 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
421 __m128 dummy_mask,cutoff_mask;
422 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
423 __m128 one = _mm_set1_ps(1.0);
424 __m128 two = _mm_set1_ps(2.0);
430 jindex = nlist->jindex;
432 shiftidx = nlist->shift;
434 shiftvec = fr->shift_vec[0];
435 fshift = fr->fshift[0];
436 facel = _mm_set1_ps(fr->epsfac);
437 charge = mdatoms->chargeA;
439 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
440 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
441 beta2 = _mm_mul_ps(beta,beta);
442 beta3 = _mm_mul_ps(beta,beta2);
443 ewtab = fr->ic->tabq_coul_F;
444 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
445 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
447 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
448 rcutoff_scalar = fr->rcoulomb;
449 rcutoff = _mm_set1_ps(rcutoff_scalar);
450 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
452 /* Avoid stupid compiler warnings */
453 jnrA = jnrB = jnrC = jnrD = 0;
462 for(iidx=0;iidx<4*DIM;iidx++)
467 /* Start outer loop over neighborlists */
468 for(iidx=0; iidx<nri; iidx++)
470 /* Load shift vector for this list */
471 i_shift_offset = DIM*shiftidx[iidx];
473 /* Load limits for loop over neighbors */
474 j_index_start = jindex[iidx];
475 j_index_end = jindex[iidx+1];
477 /* Get outer coordinate index */
479 i_coord_offset = DIM*inr;
481 /* Load i particle coords and add shift vector */
482 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
484 fix0 = _mm_setzero_ps();
485 fiy0 = _mm_setzero_ps();
486 fiz0 = _mm_setzero_ps();
488 /* Load parameters for i particles */
489 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
491 /* Start inner kernel loop */
492 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
495 /* Get j neighbor index, and coordinate index */
500 j_coord_offsetA = DIM*jnrA;
501 j_coord_offsetB = DIM*jnrB;
502 j_coord_offsetC = DIM*jnrC;
503 j_coord_offsetD = DIM*jnrD;
505 /* load j atom coordinates */
506 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
507 x+j_coord_offsetC,x+j_coord_offsetD,
510 /* Calculate displacement vector */
511 dx00 = _mm_sub_ps(ix0,jx0);
512 dy00 = _mm_sub_ps(iy0,jy0);
513 dz00 = _mm_sub_ps(iz0,jz0);
515 /* Calculate squared distance and things based on it */
516 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
518 rinv00 = gmx_mm_invsqrt_ps(rsq00);
520 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
522 /* Load parameters for j particles */
523 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
524 charge+jnrC+0,charge+jnrD+0);
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
530 if (gmx_mm_any_lt(rsq00,rcutoff2))
533 r00 = _mm_mul_ps(rsq00,rinv00);
535 /* Compute parameters for interactions between i and j atoms */
536 qq00 = _mm_mul_ps(iq0,jq0);
538 /* EWALD ELECTROSTATICS */
540 /* Analytical PME correction */
541 zeta2 = _mm_mul_ps(beta2,rsq00);
542 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
543 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
544 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
545 felec = _mm_mul_ps(qq00,felec);
547 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
551 fscal = _mm_and_ps(fscal,cutoff_mask);
553 /* Update vectorial force */
554 fix0 = _mm_macc_ps(dx00,fscal,fix0);
555 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
556 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
558 fjptrA = f+j_coord_offsetA;
559 fjptrB = f+j_coord_offsetB;
560 fjptrC = f+j_coord_offsetC;
561 fjptrD = f+j_coord_offsetD;
562 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
563 _mm_mul_ps(dx00,fscal),
564 _mm_mul_ps(dy00,fscal),
565 _mm_mul_ps(dz00,fscal));
569 /* Inner loop uses 31 flops */
575 /* Get j neighbor index, and coordinate index */
576 jnrlistA = jjnr[jidx];
577 jnrlistB = jjnr[jidx+1];
578 jnrlistC = jjnr[jidx+2];
579 jnrlistD = jjnr[jidx+3];
580 /* Sign of each element will be negative for non-real atoms.
581 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
582 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
584 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
585 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
586 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
587 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
588 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
589 j_coord_offsetA = DIM*jnrA;
590 j_coord_offsetB = DIM*jnrB;
591 j_coord_offsetC = DIM*jnrC;
592 j_coord_offsetD = DIM*jnrD;
594 /* load j atom coordinates */
595 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
596 x+j_coord_offsetC,x+j_coord_offsetD,
599 /* Calculate displacement vector */
600 dx00 = _mm_sub_ps(ix0,jx0);
601 dy00 = _mm_sub_ps(iy0,jy0);
602 dz00 = _mm_sub_ps(iz0,jz0);
604 /* Calculate squared distance and things based on it */
605 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
607 rinv00 = gmx_mm_invsqrt_ps(rsq00);
609 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
611 /* Load parameters for j particles */
612 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
613 charge+jnrC+0,charge+jnrD+0);
615 /**************************
616 * CALCULATE INTERACTIONS *
617 **************************/
619 if (gmx_mm_any_lt(rsq00,rcutoff2))
622 r00 = _mm_mul_ps(rsq00,rinv00);
623 r00 = _mm_andnot_ps(dummy_mask,r00);
625 /* Compute parameters for interactions between i and j atoms */
626 qq00 = _mm_mul_ps(iq0,jq0);
628 /* EWALD ELECTROSTATICS */
630 /* Analytical PME correction */
631 zeta2 = _mm_mul_ps(beta2,rsq00);
632 rinv3 = _mm_mul_ps(rinvsq00,rinv00);
633 pmecorrF = gmx_mm_pmecorrF_ps(zeta2);
634 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
635 felec = _mm_mul_ps(qq00,felec);
637 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
641 fscal = _mm_and_ps(fscal,cutoff_mask);
643 fscal = _mm_andnot_ps(dummy_mask,fscal);
645 /* Update vectorial force */
646 fix0 = _mm_macc_ps(dx00,fscal,fix0);
647 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
648 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
650 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
651 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
652 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
653 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
654 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
655 _mm_mul_ps(dx00,fscal),
656 _mm_mul_ps(dy00,fscal),
657 _mm_mul_ps(dz00,fscal));
661 /* Inner loop uses 32 flops */
664 /* End of innermost loop */
666 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
667 f+i_coord_offset,fshift+i_shift_offset);
669 /* Increment number of inner iterations */
670 inneriter += j_index_end - j_index_start;
672 /* Outer loop uses 7 flops */
675 /* Increment number of outer iterations */
678 /* Update outer/inner flops */
680 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*32);