2 * Note: this file was generated by the Gromacs avx_128_fma_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_single.h"
34 #include "kernelutil_x86_avx_128_fma_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_avx_128_fma_single
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: LennardJones
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_avx_128_fma_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
62 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
63 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
65 real *shiftvec,*fshift,*x,*f;
66 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
68 __m128 fscal,rcutoff,rcutoff2,jidxall;
70 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
77 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
78 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
79 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
80 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
81 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
82 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
83 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
86 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
89 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
90 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
91 __m128 dummy_mask,cutoff_mask;
92 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
93 __m128 one = _mm_set1_ps(1.0);
94 __m128 two = _mm_set1_ps(2.0);
100 jindex = nlist->jindex;
102 shiftidx = nlist->shift;
104 shiftvec = fr->shift_vec[0];
105 fshift = fr->fshift[0];
106 facel = _mm_set1_ps(fr->epsfac);
107 charge = mdatoms->chargeA;
108 krf = _mm_set1_ps(fr->ic->k_rf);
109 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
110 crf = _mm_set1_ps(fr->ic->c_rf);
111 nvdwtype = fr->ntype;
113 vdwtype = mdatoms->typeA;
115 /* Setup water-specific parameters */
116 inr = nlist->iinr[0];
117 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
118 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
119 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
120 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
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 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
128 rvdw = _mm_set1_ps(fr->rvdw);
130 /* Avoid stupid compiler warnings */
131 jnrA = jnrB = jnrC = jnrD = 0;
140 for(iidx=0;iidx<4*DIM;iidx++)
145 /* Start outer loop over neighborlists */
146 for(iidx=0; iidx<nri; iidx++)
148 /* Load shift vector for this list */
149 i_shift_offset = DIM*shiftidx[iidx];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
161 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
163 fix0 = _mm_setzero_ps();
164 fiy0 = _mm_setzero_ps();
165 fiz0 = _mm_setzero_ps();
166 fix1 = _mm_setzero_ps();
167 fiy1 = _mm_setzero_ps();
168 fiz1 = _mm_setzero_ps();
169 fix2 = _mm_setzero_ps();
170 fiy2 = _mm_setzero_ps();
171 fiz2 = _mm_setzero_ps();
172 fix3 = _mm_setzero_ps();
173 fiy3 = _mm_setzero_ps();
174 fiz3 = _mm_setzero_ps();
176 /* Reset potential sums */
177 velecsum = _mm_setzero_ps();
178 vvdwsum = _mm_setzero_ps();
180 /* Start inner kernel loop */
181 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
184 /* Get j neighbor index, and coordinate index */
189 j_coord_offsetA = DIM*jnrA;
190 j_coord_offsetB = DIM*jnrB;
191 j_coord_offsetC = DIM*jnrC;
192 j_coord_offsetD = DIM*jnrD;
194 /* load j atom coordinates */
195 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
196 x+j_coord_offsetC,x+j_coord_offsetD,
199 /* Calculate displacement vector */
200 dx00 = _mm_sub_ps(ix0,jx0);
201 dy00 = _mm_sub_ps(iy0,jy0);
202 dz00 = _mm_sub_ps(iz0,jz0);
203 dx10 = _mm_sub_ps(ix1,jx0);
204 dy10 = _mm_sub_ps(iy1,jy0);
205 dz10 = _mm_sub_ps(iz1,jz0);
206 dx20 = _mm_sub_ps(ix2,jx0);
207 dy20 = _mm_sub_ps(iy2,jy0);
208 dz20 = _mm_sub_ps(iz2,jz0);
209 dx30 = _mm_sub_ps(ix3,jx0);
210 dy30 = _mm_sub_ps(iy3,jy0);
211 dz30 = _mm_sub_ps(iz3,jz0);
213 /* Calculate squared distance and things based on it */
214 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
215 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
216 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
217 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
219 rinv10 = gmx_mm_invsqrt_ps(rsq10);
220 rinv20 = gmx_mm_invsqrt_ps(rsq20);
221 rinv30 = gmx_mm_invsqrt_ps(rsq30);
223 rinvsq00 = gmx_mm_inv_ps(rsq00);
224 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
225 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
226 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
228 /* Load parameters for j particles */
229 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
230 charge+jnrC+0,charge+jnrD+0);
231 vdwjidx0A = 2*vdwtype[jnrA+0];
232 vdwjidx0B = 2*vdwtype[jnrB+0];
233 vdwjidx0C = 2*vdwtype[jnrC+0];
234 vdwjidx0D = 2*vdwtype[jnrD+0];
236 fjx0 = _mm_setzero_ps();
237 fjy0 = _mm_setzero_ps();
238 fjz0 = _mm_setzero_ps();
240 /**************************
241 * CALCULATE INTERACTIONS *
242 **************************/
244 if (gmx_mm_any_lt(rsq00,rcutoff2))
247 /* Compute parameters for interactions between i and j atoms */
248 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
249 vdwparam+vdwioffset0+vdwjidx0B,
250 vdwparam+vdwioffset0+vdwjidx0C,
251 vdwparam+vdwioffset0+vdwjidx0D,
254 /* LENNARD-JONES DISPERSION/REPULSION */
256 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
257 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
258 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
259 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
260 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
261 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
263 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 vvdw = _mm_and_ps(vvdw,cutoff_mask);
267 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
271 fscal = _mm_and_ps(fscal,cutoff_mask);
273 /* Update vectorial force */
274 fix0 = _mm_macc_ps(dx00,fscal,fix0);
275 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
276 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
278 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
279 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
280 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
288 if (gmx_mm_any_lt(rsq10,rcutoff2))
291 /* Compute parameters for interactions between i and j atoms */
292 qq10 = _mm_mul_ps(iq1,jq0);
294 /* REACTION-FIELD ELECTROSTATICS */
295 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
296 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
298 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
300 /* Update potential sum for this i atom from the interaction with this j atom. */
301 velec = _mm_and_ps(velec,cutoff_mask);
302 velecsum = _mm_add_ps(velecsum,velec);
306 fscal = _mm_and_ps(fscal,cutoff_mask);
308 /* Update vectorial force */
309 fix1 = _mm_macc_ps(dx10,fscal,fix1);
310 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
311 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
313 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
314 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
315 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
323 if (gmx_mm_any_lt(rsq20,rcutoff2))
326 /* Compute parameters for interactions between i and j atoms */
327 qq20 = _mm_mul_ps(iq2,jq0);
329 /* REACTION-FIELD ELECTROSTATICS */
330 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
331 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
333 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
335 /* Update potential sum for this i atom from the interaction with this j atom. */
336 velec = _mm_and_ps(velec,cutoff_mask);
337 velecsum = _mm_add_ps(velecsum,velec);
341 fscal = _mm_and_ps(fscal,cutoff_mask);
343 /* Update vectorial force */
344 fix2 = _mm_macc_ps(dx20,fscal,fix2);
345 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
346 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
348 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
349 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
350 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
354 /**************************
355 * CALCULATE INTERACTIONS *
356 **************************/
358 if (gmx_mm_any_lt(rsq30,rcutoff2))
361 /* Compute parameters for interactions between i and j atoms */
362 qq30 = _mm_mul_ps(iq3,jq0);
364 /* REACTION-FIELD ELECTROSTATICS */
365 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
366 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
368 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
370 /* Update potential sum for this i atom from the interaction with this j atom. */
371 velec = _mm_and_ps(velec,cutoff_mask);
372 velecsum = _mm_add_ps(velecsum,velec);
376 fscal = _mm_and_ps(fscal,cutoff_mask);
378 /* Update vectorial force */
379 fix3 = _mm_macc_ps(dx30,fscal,fix3);
380 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
381 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
383 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
384 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
385 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
389 fjptrA = f+j_coord_offsetA;
390 fjptrB = f+j_coord_offsetB;
391 fjptrC = f+j_coord_offsetC;
392 fjptrD = f+j_coord_offsetD;
394 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
396 /* Inner loop uses 161 flops */
402 /* Get j neighbor index, and coordinate index */
403 jnrlistA = jjnr[jidx];
404 jnrlistB = jjnr[jidx+1];
405 jnrlistC = jjnr[jidx+2];
406 jnrlistD = jjnr[jidx+3];
407 /* Sign of each element will be negative for non-real atoms.
408 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
409 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
411 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
412 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
413 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
414 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
415 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
416 j_coord_offsetA = DIM*jnrA;
417 j_coord_offsetB = DIM*jnrB;
418 j_coord_offsetC = DIM*jnrC;
419 j_coord_offsetD = DIM*jnrD;
421 /* load j atom coordinates */
422 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
423 x+j_coord_offsetC,x+j_coord_offsetD,
426 /* Calculate displacement vector */
427 dx00 = _mm_sub_ps(ix0,jx0);
428 dy00 = _mm_sub_ps(iy0,jy0);
429 dz00 = _mm_sub_ps(iz0,jz0);
430 dx10 = _mm_sub_ps(ix1,jx0);
431 dy10 = _mm_sub_ps(iy1,jy0);
432 dz10 = _mm_sub_ps(iz1,jz0);
433 dx20 = _mm_sub_ps(ix2,jx0);
434 dy20 = _mm_sub_ps(iy2,jy0);
435 dz20 = _mm_sub_ps(iz2,jz0);
436 dx30 = _mm_sub_ps(ix3,jx0);
437 dy30 = _mm_sub_ps(iy3,jy0);
438 dz30 = _mm_sub_ps(iz3,jz0);
440 /* Calculate squared distance and things based on it */
441 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
442 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
443 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
444 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
446 rinv10 = gmx_mm_invsqrt_ps(rsq10);
447 rinv20 = gmx_mm_invsqrt_ps(rsq20);
448 rinv30 = gmx_mm_invsqrt_ps(rsq30);
450 rinvsq00 = gmx_mm_inv_ps(rsq00);
451 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
452 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
453 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
455 /* Load parameters for j particles */
456 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
457 charge+jnrC+0,charge+jnrD+0);
458 vdwjidx0A = 2*vdwtype[jnrA+0];
459 vdwjidx0B = 2*vdwtype[jnrB+0];
460 vdwjidx0C = 2*vdwtype[jnrC+0];
461 vdwjidx0D = 2*vdwtype[jnrD+0];
463 fjx0 = _mm_setzero_ps();
464 fjy0 = _mm_setzero_ps();
465 fjz0 = _mm_setzero_ps();
467 /**************************
468 * CALCULATE INTERACTIONS *
469 **************************/
471 if (gmx_mm_any_lt(rsq00,rcutoff2))
474 /* Compute parameters for interactions between i and j atoms */
475 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
476 vdwparam+vdwioffset0+vdwjidx0B,
477 vdwparam+vdwioffset0+vdwjidx0C,
478 vdwparam+vdwioffset0+vdwjidx0D,
481 /* LENNARD-JONES DISPERSION/REPULSION */
483 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
484 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
485 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
486 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
487 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
488 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
490 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
492 /* Update potential sum for this i atom from the interaction with this j atom. */
493 vvdw = _mm_and_ps(vvdw,cutoff_mask);
494 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
495 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
499 fscal = _mm_and_ps(fscal,cutoff_mask);
501 fscal = _mm_andnot_ps(dummy_mask,fscal);
503 /* Update vectorial force */
504 fix0 = _mm_macc_ps(dx00,fscal,fix0);
505 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
506 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
508 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
509 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
510 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
514 /**************************
515 * CALCULATE INTERACTIONS *
516 **************************/
518 if (gmx_mm_any_lt(rsq10,rcutoff2))
521 /* Compute parameters for interactions between i and j atoms */
522 qq10 = _mm_mul_ps(iq1,jq0);
524 /* REACTION-FIELD ELECTROSTATICS */
525 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
526 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
528 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
530 /* Update potential sum for this i atom from the interaction with this j atom. */
531 velec = _mm_and_ps(velec,cutoff_mask);
532 velec = _mm_andnot_ps(dummy_mask,velec);
533 velecsum = _mm_add_ps(velecsum,velec);
537 fscal = _mm_and_ps(fscal,cutoff_mask);
539 fscal = _mm_andnot_ps(dummy_mask,fscal);
541 /* Update vectorial force */
542 fix1 = _mm_macc_ps(dx10,fscal,fix1);
543 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
544 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
546 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
547 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
548 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
552 /**************************
553 * CALCULATE INTERACTIONS *
554 **************************/
556 if (gmx_mm_any_lt(rsq20,rcutoff2))
559 /* Compute parameters for interactions between i and j atoms */
560 qq20 = _mm_mul_ps(iq2,jq0);
562 /* REACTION-FIELD ELECTROSTATICS */
563 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
564 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
566 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
568 /* Update potential sum for this i atom from the interaction with this j atom. */
569 velec = _mm_and_ps(velec,cutoff_mask);
570 velec = _mm_andnot_ps(dummy_mask,velec);
571 velecsum = _mm_add_ps(velecsum,velec);
575 fscal = _mm_and_ps(fscal,cutoff_mask);
577 fscal = _mm_andnot_ps(dummy_mask,fscal);
579 /* Update vectorial force */
580 fix2 = _mm_macc_ps(dx20,fscal,fix2);
581 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
582 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
584 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
585 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
586 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
590 /**************************
591 * CALCULATE INTERACTIONS *
592 **************************/
594 if (gmx_mm_any_lt(rsq30,rcutoff2))
597 /* Compute parameters for interactions between i and j atoms */
598 qq30 = _mm_mul_ps(iq3,jq0);
600 /* REACTION-FIELD ELECTROSTATICS */
601 velec = _mm_mul_ps(qq30,_mm_sub_ps(_mm_macc_ps(krf,rsq30,rinv30),crf));
602 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
604 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
606 /* Update potential sum for this i atom from the interaction with this j atom. */
607 velec = _mm_and_ps(velec,cutoff_mask);
608 velec = _mm_andnot_ps(dummy_mask,velec);
609 velecsum = _mm_add_ps(velecsum,velec);
613 fscal = _mm_and_ps(fscal,cutoff_mask);
615 fscal = _mm_andnot_ps(dummy_mask,fscal);
617 /* Update vectorial force */
618 fix3 = _mm_macc_ps(dx30,fscal,fix3);
619 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
620 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
622 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
623 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
624 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
628 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
629 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
630 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
631 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
633 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
635 /* Inner loop uses 161 flops */
638 /* End of innermost loop */
640 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
641 f+i_coord_offset,fshift+i_shift_offset);
644 /* Update potential energies */
645 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
646 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
648 /* Increment number of inner iterations */
649 inneriter += j_index_end - j_index_start;
651 /* Outer loop uses 26 flops */
654 /* Increment number of outer iterations */
657 /* Update outer/inner flops */
659 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*161);
662 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
663 * Electrostatics interaction: ReactionField
664 * VdW interaction: LennardJones
665 * Geometry: Water4-Particle
666 * Calculate force/pot: Force
669 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_avx_128_fma_single
670 (t_nblist * gmx_restrict nlist,
671 rvec * gmx_restrict xx,
672 rvec * gmx_restrict ff,
673 t_forcerec * gmx_restrict fr,
674 t_mdatoms * gmx_restrict mdatoms,
675 nb_kernel_data_t * gmx_restrict kernel_data,
676 t_nrnb * gmx_restrict nrnb)
678 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
679 * just 0 for non-waters.
680 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
681 * jnr indices corresponding to data put in the four positions in the SIMD register.
683 int i_shift_offset,i_coord_offset,outeriter,inneriter;
684 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
685 int jnrA,jnrB,jnrC,jnrD;
686 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
687 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
688 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
690 real *shiftvec,*fshift,*x,*f;
691 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
693 __m128 fscal,rcutoff,rcutoff2,jidxall;
695 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
697 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
699 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
701 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
702 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
703 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
704 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
705 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
706 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
707 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
708 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
711 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
714 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
715 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
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 krf = _mm_set1_ps(fr->ic->k_rf);
734 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
735 crf = _mm_set1_ps(fr->ic->c_rf);
736 nvdwtype = fr->ntype;
738 vdwtype = mdatoms->typeA;
740 /* Setup water-specific parameters */
741 inr = nlist->iinr[0];
742 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
743 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
744 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
745 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
747 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
748 rcutoff_scalar = fr->rcoulomb;
749 rcutoff = _mm_set1_ps(rcutoff_scalar);
750 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
752 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
753 rvdw = _mm_set1_ps(fr->rvdw);
755 /* Avoid stupid compiler warnings */
756 jnrA = jnrB = jnrC = jnrD = 0;
765 for(iidx=0;iidx<4*DIM;iidx++)
770 /* Start outer loop over neighborlists */
771 for(iidx=0; iidx<nri; iidx++)
773 /* Load shift vector for this list */
774 i_shift_offset = DIM*shiftidx[iidx];
776 /* Load limits for loop over neighbors */
777 j_index_start = jindex[iidx];
778 j_index_end = jindex[iidx+1];
780 /* Get outer coordinate index */
782 i_coord_offset = DIM*inr;
784 /* Load i particle coords and add shift vector */
785 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
786 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
788 fix0 = _mm_setzero_ps();
789 fiy0 = _mm_setzero_ps();
790 fiz0 = _mm_setzero_ps();
791 fix1 = _mm_setzero_ps();
792 fiy1 = _mm_setzero_ps();
793 fiz1 = _mm_setzero_ps();
794 fix2 = _mm_setzero_ps();
795 fiy2 = _mm_setzero_ps();
796 fiz2 = _mm_setzero_ps();
797 fix3 = _mm_setzero_ps();
798 fiy3 = _mm_setzero_ps();
799 fiz3 = _mm_setzero_ps();
801 /* Start inner kernel loop */
802 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
805 /* Get j neighbor index, and coordinate index */
810 j_coord_offsetA = DIM*jnrA;
811 j_coord_offsetB = DIM*jnrB;
812 j_coord_offsetC = DIM*jnrC;
813 j_coord_offsetD = DIM*jnrD;
815 /* load j atom coordinates */
816 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
817 x+j_coord_offsetC,x+j_coord_offsetD,
820 /* Calculate displacement vector */
821 dx00 = _mm_sub_ps(ix0,jx0);
822 dy00 = _mm_sub_ps(iy0,jy0);
823 dz00 = _mm_sub_ps(iz0,jz0);
824 dx10 = _mm_sub_ps(ix1,jx0);
825 dy10 = _mm_sub_ps(iy1,jy0);
826 dz10 = _mm_sub_ps(iz1,jz0);
827 dx20 = _mm_sub_ps(ix2,jx0);
828 dy20 = _mm_sub_ps(iy2,jy0);
829 dz20 = _mm_sub_ps(iz2,jz0);
830 dx30 = _mm_sub_ps(ix3,jx0);
831 dy30 = _mm_sub_ps(iy3,jy0);
832 dz30 = _mm_sub_ps(iz3,jz0);
834 /* Calculate squared distance and things based on it */
835 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
836 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
837 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
838 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
840 rinv10 = gmx_mm_invsqrt_ps(rsq10);
841 rinv20 = gmx_mm_invsqrt_ps(rsq20);
842 rinv30 = gmx_mm_invsqrt_ps(rsq30);
844 rinvsq00 = gmx_mm_inv_ps(rsq00);
845 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
846 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
847 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
849 /* Load parameters for j particles */
850 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
851 charge+jnrC+0,charge+jnrD+0);
852 vdwjidx0A = 2*vdwtype[jnrA+0];
853 vdwjidx0B = 2*vdwtype[jnrB+0];
854 vdwjidx0C = 2*vdwtype[jnrC+0];
855 vdwjidx0D = 2*vdwtype[jnrD+0];
857 fjx0 = _mm_setzero_ps();
858 fjy0 = _mm_setzero_ps();
859 fjz0 = _mm_setzero_ps();
861 /**************************
862 * CALCULATE INTERACTIONS *
863 **************************/
865 if (gmx_mm_any_lt(rsq00,rcutoff2))
868 /* Compute parameters for interactions between i and j atoms */
869 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
870 vdwparam+vdwioffset0+vdwjidx0B,
871 vdwparam+vdwioffset0+vdwjidx0C,
872 vdwparam+vdwioffset0+vdwjidx0D,
875 /* LENNARD-JONES DISPERSION/REPULSION */
877 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
878 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
880 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
884 fscal = _mm_and_ps(fscal,cutoff_mask);
886 /* Update vectorial force */
887 fix0 = _mm_macc_ps(dx00,fscal,fix0);
888 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
889 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
891 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
892 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
893 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
897 /**************************
898 * CALCULATE INTERACTIONS *
899 **************************/
901 if (gmx_mm_any_lt(rsq10,rcutoff2))
904 /* Compute parameters for interactions between i and j atoms */
905 qq10 = _mm_mul_ps(iq1,jq0);
907 /* REACTION-FIELD ELECTROSTATICS */
908 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
910 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
914 fscal = _mm_and_ps(fscal,cutoff_mask);
916 /* Update vectorial force */
917 fix1 = _mm_macc_ps(dx10,fscal,fix1);
918 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
919 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
921 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
922 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
923 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
927 /**************************
928 * CALCULATE INTERACTIONS *
929 **************************/
931 if (gmx_mm_any_lt(rsq20,rcutoff2))
934 /* Compute parameters for interactions between i and j atoms */
935 qq20 = _mm_mul_ps(iq2,jq0);
937 /* REACTION-FIELD ELECTROSTATICS */
938 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
940 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
944 fscal = _mm_and_ps(fscal,cutoff_mask);
946 /* Update vectorial force */
947 fix2 = _mm_macc_ps(dx20,fscal,fix2);
948 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
949 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
951 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
952 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
953 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
961 if (gmx_mm_any_lt(rsq30,rcutoff2))
964 /* Compute parameters for interactions between i and j atoms */
965 qq30 = _mm_mul_ps(iq3,jq0);
967 /* REACTION-FIELD ELECTROSTATICS */
968 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
970 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
974 fscal = _mm_and_ps(fscal,cutoff_mask);
976 /* Update vectorial force */
977 fix3 = _mm_macc_ps(dx30,fscal,fix3);
978 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
979 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
981 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
982 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
983 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
987 fjptrA = f+j_coord_offsetA;
988 fjptrB = f+j_coord_offsetB;
989 fjptrC = f+j_coord_offsetC;
990 fjptrD = f+j_coord_offsetD;
992 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
994 /* Inner loop uses 132 flops */
1000 /* Get j neighbor index, and coordinate index */
1001 jnrlistA = jjnr[jidx];
1002 jnrlistB = jjnr[jidx+1];
1003 jnrlistC = jjnr[jidx+2];
1004 jnrlistD = jjnr[jidx+3];
1005 /* Sign of each element will be negative for non-real atoms.
1006 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1007 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1009 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1010 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1011 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1012 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1013 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1014 j_coord_offsetA = DIM*jnrA;
1015 j_coord_offsetB = DIM*jnrB;
1016 j_coord_offsetC = DIM*jnrC;
1017 j_coord_offsetD = DIM*jnrD;
1019 /* load j atom coordinates */
1020 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1021 x+j_coord_offsetC,x+j_coord_offsetD,
1024 /* Calculate displacement vector */
1025 dx00 = _mm_sub_ps(ix0,jx0);
1026 dy00 = _mm_sub_ps(iy0,jy0);
1027 dz00 = _mm_sub_ps(iz0,jz0);
1028 dx10 = _mm_sub_ps(ix1,jx0);
1029 dy10 = _mm_sub_ps(iy1,jy0);
1030 dz10 = _mm_sub_ps(iz1,jz0);
1031 dx20 = _mm_sub_ps(ix2,jx0);
1032 dy20 = _mm_sub_ps(iy2,jy0);
1033 dz20 = _mm_sub_ps(iz2,jz0);
1034 dx30 = _mm_sub_ps(ix3,jx0);
1035 dy30 = _mm_sub_ps(iy3,jy0);
1036 dz30 = _mm_sub_ps(iz3,jz0);
1038 /* Calculate squared distance and things based on it */
1039 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1040 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1041 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1042 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
1044 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1045 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1046 rinv30 = gmx_mm_invsqrt_ps(rsq30);
1048 rinvsq00 = gmx_mm_inv_ps(rsq00);
1049 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1050 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1051 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
1053 /* Load parameters for j particles */
1054 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1055 charge+jnrC+0,charge+jnrD+0);
1056 vdwjidx0A = 2*vdwtype[jnrA+0];
1057 vdwjidx0B = 2*vdwtype[jnrB+0];
1058 vdwjidx0C = 2*vdwtype[jnrC+0];
1059 vdwjidx0D = 2*vdwtype[jnrD+0];
1061 fjx0 = _mm_setzero_ps();
1062 fjy0 = _mm_setzero_ps();
1063 fjz0 = _mm_setzero_ps();
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1069 if (gmx_mm_any_lt(rsq00,rcutoff2))
1072 /* Compute parameters for interactions between i and j atoms */
1073 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1074 vdwparam+vdwioffset0+vdwjidx0B,
1075 vdwparam+vdwioffset0+vdwjidx0C,
1076 vdwparam+vdwioffset0+vdwjidx0D,
1079 /* LENNARD-JONES DISPERSION/REPULSION */
1081 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1082 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1084 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1088 fscal = _mm_and_ps(fscal,cutoff_mask);
1090 fscal = _mm_andnot_ps(dummy_mask,fscal);
1092 /* Update vectorial force */
1093 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1094 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1095 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1097 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1098 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1099 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1103 /**************************
1104 * CALCULATE INTERACTIONS *
1105 **************************/
1107 if (gmx_mm_any_lt(rsq10,rcutoff2))
1110 /* Compute parameters for interactions between i and j atoms */
1111 qq10 = _mm_mul_ps(iq1,jq0);
1113 /* REACTION-FIELD ELECTROSTATICS */
1114 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1116 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1120 fscal = _mm_and_ps(fscal,cutoff_mask);
1122 fscal = _mm_andnot_ps(dummy_mask,fscal);
1124 /* Update vectorial force */
1125 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1126 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1127 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1129 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1130 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1131 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1135 /**************************
1136 * CALCULATE INTERACTIONS *
1137 **************************/
1139 if (gmx_mm_any_lt(rsq20,rcutoff2))
1142 /* Compute parameters for interactions between i and j atoms */
1143 qq20 = _mm_mul_ps(iq2,jq0);
1145 /* REACTION-FIELD ELECTROSTATICS */
1146 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1148 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1152 fscal = _mm_and_ps(fscal,cutoff_mask);
1154 fscal = _mm_andnot_ps(dummy_mask,fscal);
1156 /* Update vectorial force */
1157 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1158 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1159 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1161 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1162 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1163 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1167 /**************************
1168 * CALCULATE INTERACTIONS *
1169 **************************/
1171 if (gmx_mm_any_lt(rsq30,rcutoff2))
1174 /* Compute parameters for interactions between i and j atoms */
1175 qq30 = _mm_mul_ps(iq3,jq0);
1177 /* REACTION-FIELD ELECTROSTATICS */
1178 felec = _mm_mul_ps(qq30,_mm_msub_ps(rinv30,rinvsq30,krf2));
1180 cutoff_mask = _mm_cmplt_ps(rsq30,rcutoff2);
1184 fscal = _mm_and_ps(fscal,cutoff_mask);
1186 fscal = _mm_andnot_ps(dummy_mask,fscal);
1188 /* Update vectorial force */
1189 fix3 = _mm_macc_ps(dx30,fscal,fix3);
1190 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
1191 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
1193 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
1194 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
1195 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1199 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1200 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1201 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1202 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1204 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1206 /* Inner loop uses 132 flops */
1209 /* End of innermost loop */
1211 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1212 f+i_coord_offset,fshift+i_shift_offset);
1214 /* Increment number of inner iterations */
1215 inneriter += j_index_end - j_index_start;
1217 /* Outer loop uses 24 flops */
1220 /* Increment number of outer iterations */
1223 /* Update outer/inner flops */
1225 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);