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_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: LennardJones
54 * Geometry: Water4-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
94 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
97 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
100 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
101 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
102 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
103 real rswitch_scalar,d_scalar;
104 __m128d dummy_mask,cutoff_mask;
105 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
106 __m128d one = _mm_set1_pd(1.0);
107 __m128d two = _mm_set1_pd(2.0);
113 jindex = nlist->jindex;
115 shiftidx = nlist->shift;
117 shiftvec = fr->shift_vec[0];
118 fshift = fr->fshift[0];
119 facel = _mm_set1_pd(fr->epsfac);
120 charge = mdatoms->chargeA;
121 krf = _mm_set1_pd(fr->ic->k_rf);
122 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
123 crf = _mm_set1_pd(fr->ic->c_rf);
124 nvdwtype = fr->ntype;
126 vdwtype = mdatoms->typeA;
128 /* Setup water-specific parameters */
129 inr = nlist->iinr[0];
130 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
131 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
132 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
136 rcutoff_scalar = fr->rcoulomb;
137 rcutoff = _mm_set1_pd(rcutoff_scalar);
138 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
140 rswitch_scalar = fr->rvdw_switch;
141 rswitch = _mm_set1_pd(rswitch_scalar);
142 /* Setup switch parameters */
143 d_scalar = rcutoff_scalar-rswitch_scalar;
144 d = _mm_set1_pd(d_scalar);
145 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
146 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
147 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
148 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
149 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
150 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
152 /* Avoid stupid compiler warnings */
160 /* Start outer loop over neighborlists */
161 for(iidx=0; iidx<nri; iidx++)
163 /* Load shift vector for this list */
164 i_shift_offset = DIM*shiftidx[iidx];
166 /* Load limits for loop over neighbors */
167 j_index_start = jindex[iidx];
168 j_index_end = jindex[iidx+1];
170 /* Get outer coordinate index */
172 i_coord_offset = DIM*inr;
174 /* Load i particle coords and add shift vector */
175 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
176 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
178 fix0 = _mm_setzero_pd();
179 fiy0 = _mm_setzero_pd();
180 fiz0 = _mm_setzero_pd();
181 fix1 = _mm_setzero_pd();
182 fiy1 = _mm_setzero_pd();
183 fiz1 = _mm_setzero_pd();
184 fix2 = _mm_setzero_pd();
185 fiy2 = _mm_setzero_pd();
186 fiz2 = _mm_setzero_pd();
187 fix3 = _mm_setzero_pd();
188 fiy3 = _mm_setzero_pd();
189 fiz3 = _mm_setzero_pd();
191 /* Reset potential sums */
192 velecsum = _mm_setzero_pd();
193 vvdwsum = _mm_setzero_pd();
195 /* Start inner kernel loop */
196 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
199 /* Get j neighbor index, and coordinate index */
202 j_coord_offsetA = DIM*jnrA;
203 j_coord_offsetB = DIM*jnrB;
205 /* load j atom coordinates */
206 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
209 /* Calculate displacement vector */
210 dx00 = _mm_sub_pd(ix0,jx0);
211 dy00 = _mm_sub_pd(iy0,jy0);
212 dz00 = _mm_sub_pd(iz0,jz0);
213 dx10 = _mm_sub_pd(ix1,jx0);
214 dy10 = _mm_sub_pd(iy1,jy0);
215 dz10 = _mm_sub_pd(iz1,jz0);
216 dx20 = _mm_sub_pd(ix2,jx0);
217 dy20 = _mm_sub_pd(iy2,jy0);
218 dz20 = _mm_sub_pd(iz2,jz0);
219 dx30 = _mm_sub_pd(ix3,jx0);
220 dy30 = _mm_sub_pd(iy3,jy0);
221 dz30 = _mm_sub_pd(iz3,jz0);
223 /* Calculate squared distance and things based on it */
224 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
225 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
226 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
227 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
229 rinv00 = gmx_mm_invsqrt_pd(rsq00);
230 rinv10 = gmx_mm_invsqrt_pd(rsq10);
231 rinv20 = gmx_mm_invsqrt_pd(rsq20);
232 rinv30 = gmx_mm_invsqrt_pd(rsq30);
234 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
235 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
236 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
237 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
239 /* Load parameters for j particles */
240 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
241 vdwjidx0A = 2*vdwtype[jnrA+0];
242 vdwjidx0B = 2*vdwtype[jnrB+0];
244 fjx0 = _mm_setzero_pd();
245 fjy0 = _mm_setzero_pd();
246 fjz0 = _mm_setzero_pd();
248 /**************************
249 * CALCULATE INTERACTIONS *
250 **************************/
252 if (gmx_mm_any_lt(rsq00,rcutoff2))
255 r00 = _mm_mul_pd(rsq00,rinv00);
257 /* Compute parameters for interactions between i and j atoms */
258 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
259 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
261 /* LENNARD-JONES DISPERSION/REPULSION */
263 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
264 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
265 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
266 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
267 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
269 d = _mm_sub_pd(r00,rswitch);
270 d = _mm_max_pd(d,_mm_setzero_pd());
271 d2 = _mm_mul_pd(d,d);
272 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
274 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
276 /* Evaluate switch function */
277 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
278 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
279 vvdw = _mm_mul_pd(vvdw,sw);
280 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
282 /* Update potential sum for this i atom from the interaction with this j atom. */
283 vvdw = _mm_and_pd(vvdw,cutoff_mask);
284 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
288 fscal = _mm_and_pd(fscal,cutoff_mask);
290 /* Update vectorial force */
291 fix0 = _mm_macc_pd(dx00,fscal,fix0);
292 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
293 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
295 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
296 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
297 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
301 /**************************
302 * CALCULATE INTERACTIONS *
303 **************************/
305 if (gmx_mm_any_lt(rsq10,rcutoff2))
308 /* Compute parameters for interactions between i and j atoms */
309 qq10 = _mm_mul_pd(iq1,jq0);
311 /* REACTION-FIELD ELECTROSTATICS */
312 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
313 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
315 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
317 /* Update potential sum for this i atom from the interaction with this j atom. */
318 velec = _mm_and_pd(velec,cutoff_mask);
319 velecsum = _mm_add_pd(velecsum,velec);
323 fscal = _mm_and_pd(fscal,cutoff_mask);
325 /* Update vectorial force */
326 fix1 = _mm_macc_pd(dx10,fscal,fix1);
327 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
328 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
330 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
331 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
332 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
340 if (gmx_mm_any_lt(rsq20,rcutoff2))
343 /* Compute parameters for interactions between i and j atoms */
344 qq20 = _mm_mul_pd(iq2,jq0);
346 /* REACTION-FIELD ELECTROSTATICS */
347 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
348 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
350 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
352 /* Update potential sum for this i atom from the interaction with this j atom. */
353 velec = _mm_and_pd(velec,cutoff_mask);
354 velecsum = _mm_add_pd(velecsum,velec);
358 fscal = _mm_and_pd(fscal,cutoff_mask);
360 /* Update vectorial force */
361 fix2 = _mm_macc_pd(dx20,fscal,fix2);
362 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
363 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
365 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
366 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
367 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
371 /**************************
372 * CALCULATE INTERACTIONS *
373 **************************/
375 if (gmx_mm_any_lt(rsq30,rcutoff2))
378 /* Compute parameters for interactions between i and j atoms */
379 qq30 = _mm_mul_pd(iq3,jq0);
381 /* REACTION-FIELD ELECTROSTATICS */
382 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
383 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
385 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
387 /* Update potential sum for this i atom from the interaction with this j atom. */
388 velec = _mm_and_pd(velec,cutoff_mask);
389 velecsum = _mm_add_pd(velecsum,velec);
393 fscal = _mm_and_pd(fscal,cutoff_mask);
395 /* Update vectorial force */
396 fix3 = _mm_macc_pd(dx30,fscal,fix3);
397 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
398 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
400 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
401 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
402 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
406 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
408 /* Inner loop uses 182 flops */
415 j_coord_offsetA = DIM*jnrA;
417 /* load j atom coordinates */
418 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
421 /* Calculate displacement vector */
422 dx00 = _mm_sub_pd(ix0,jx0);
423 dy00 = _mm_sub_pd(iy0,jy0);
424 dz00 = _mm_sub_pd(iz0,jz0);
425 dx10 = _mm_sub_pd(ix1,jx0);
426 dy10 = _mm_sub_pd(iy1,jy0);
427 dz10 = _mm_sub_pd(iz1,jz0);
428 dx20 = _mm_sub_pd(ix2,jx0);
429 dy20 = _mm_sub_pd(iy2,jy0);
430 dz20 = _mm_sub_pd(iz2,jz0);
431 dx30 = _mm_sub_pd(ix3,jx0);
432 dy30 = _mm_sub_pd(iy3,jy0);
433 dz30 = _mm_sub_pd(iz3,jz0);
435 /* Calculate squared distance and things based on it */
436 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
437 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
438 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
439 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
441 rinv00 = gmx_mm_invsqrt_pd(rsq00);
442 rinv10 = gmx_mm_invsqrt_pd(rsq10);
443 rinv20 = gmx_mm_invsqrt_pd(rsq20);
444 rinv30 = gmx_mm_invsqrt_pd(rsq30);
446 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
447 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
448 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
449 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
451 /* Load parameters for j particles */
452 jq0 = _mm_load_sd(charge+jnrA+0);
453 vdwjidx0A = 2*vdwtype[jnrA+0];
455 fjx0 = _mm_setzero_pd();
456 fjy0 = _mm_setzero_pd();
457 fjz0 = _mm_setzero_pd();
459 /**************************
460 * CALCULATE INTERACTIONS *
461 **************************/
463 if (gmx_mm_any_lt(rsq00,rcutoff2))
466 r00 = _mm_mul_pd(rsq00,rinv00);
468 /* Compute parameters for interactions between i and j atoms */
469 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
471 /* LENNARD-JONES DISPERSION/REPULSION */
473 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
474 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
475 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
476 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
477 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
479 d = _mm_sub_pd(r00,rswitch);
480 d = _mm_max_pd(d,_mm_setzero_pd());
481 d2 = _mm_mul_pd(d,d);
482 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
484 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
486 /* Evaluate switch function */
487 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
488 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
489 vvdw = _mm_mul_pd(vvdw,sw);
490 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
492 /* Update potential sum for this i atom from the interaction with this j atom. */
493 vvdw = _mm_and_pd(vvdw,cutoff_mask);
494 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
495 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
499 fscal = _mm_and_pd(fscal,cutoff_mask);
501 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
503 /* Update vectorial force */
504 fix0 = _mm_macc_pd(dx00,fscal,fix0);
505 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
506 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
508 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
509 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
510 fjz0 = _mm_macc_pd(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_pd(iq1,jq0);
524 /* REACTION-FIELD ELECTROSTATICS */
525 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
526 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
528 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
530 /* Update potential sum for this i atom from the interaction with this j atom. */
531 velec = _mm_and_pd(velec,cutoff_mask);
532 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
533 velecsum = _mm_add_pd(velecsum,velec);
537 fscal = _mm_and_pd(fscal,cutoff_mask);
539 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
541 /* Update vectorial force */
542 fix1 = _mm_macc_pd(dx10,fscal,fix1);
543 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
544 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
546 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
547 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
548 fjz0 = _mm_macc_pd(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_pd(iq2,jq0);
562 /* REACTION-FIELD ELECTROSTATICS */
563 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
564 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
566 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
568 /* Update potential sum for this i atom from the interaction with this j atom. */
569 velec = _mm_and_pd(velec,cutoff_mask);
570 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
571 velecsum = _mm_add_pd(velecsum,velec);
575 fscal = _mm_and_pd(fscal,cutoff_mask);
577 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
579 /* Update vectorial force */
580 fix2 = _mm_macc_pd(dx20,fscal,fix2);
581 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
582 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
584 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
585 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
586 fjz0 = _mm_macc_pd(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_pd(iq3,jq0);
600 /* REACTION-FIELD ELECTROSTATICS */
601 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
602 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
604 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
606 /* Update potential sum for this i atom from the interaction with this j atom. */
607 velec = _mm_and_pd(velec,cutoff_mask);
608 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
609 velecsum = _mm_add_pd(velecsum,velec);
613 fscal = _mm_and_pd(fscal,cutoff_mask);
615 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
617 /* Update vectorial force */
618 fix3 = _mm_macc_pd(dx30,fscal,fix3);
619 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
620 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
622 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
623 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
624 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
628 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
630 /* Inner loop uses 182 flops */
633 /* End of innermost loop */
635 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
636 f+i_coord_offset,fshift+i_shift_offset);
639 /* Update potential energies */
640 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
641 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
643 /* Increment number of inner iterations */
644 inneriter += j_index_end - j_index_start;
646 /* Outer loop uses 26 flops */
649 /* Increment number of outer iterations */
652 /* Update outer/inner flops */
654 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*182);
657 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
658 * Electrostatics interaction: ReactionField
659 * VdW interaction: LennardJones
660 * Geometry: Water4-Particle
661 * Calculate force/pot: Force
664 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
665 (t_nblist * gmx_restrict nlist,
666 rvec * gmx_restrict xx,
667 rvec * gmx_restrict ff,
668 t_forcerec * gmx_restrict fr,
669 t_mdatoms * gmx_restrict mdatoms,
670 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
671 t_nrnb * gmx_restrict nrnb)
673 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
674 * just 0 for non-waters.
675 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
676 * jnr indices corresponding to data put in the four positions in the SIMD register.
678 int i_shift_offset,i_coord_offset,outeriter,inneriter;
679 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
681 int j_coord_offsetA,j_coord_offsetB;
682 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
684 real *shiftvec,*fshift,*x,*f;
685 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
687 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
689 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
691 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
693 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
694 int vdwjidx0A,vdwjidx0B;
695 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
696 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
697 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
698 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
699 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
700 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
703 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
706 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
707 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
708 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
709 real rswitch_scalar,d_scalar;
710 __m128d dummy_mask,cutoff_mask;
711 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
712 __m128d one = _mm_set1_pd(1.0);
713 __m128d two = _mm_set1_pd(2.0);
719 jindex = nlist->jindex;
721 shiftidx = nlist->shift;
723 shiftvec = fr->shift_vec[0];
724 fshift = fr->fshift[0];
725 facel = _mm_set1_pd(fr->epsfac);
726 charge = mdatoms->chargeA;
727 krf = _mm_set1_pd(fr->ic->k_rf);
728 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
729 crf = _mm_set1_pd(fr->ic->c_rf);
730 nvdwtype = fr->ntype;
732 vdwtype = mdatoms->typeA;
734 /* Setup water-specific parameters */
735 inr = nlist->iinr[0];
736 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
737 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
738 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
739 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
741 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
742 rcutoff_scalar = fr->rcoulomb;
743 rcutoff = _mm_set1_pd(rcutoff_scalar);
744 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
746 rswitch_scalar = fr->rvdw_switch;
747 rswitch = _mm_set1_pd(rswitch_scalar);
748 /* Setup switch parameters */
749 d_scalar = rcutoff_scalar-rswitch_scalar;
750 d = _mm_set1_pd(d_scalar);
751 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
752 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
753 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
754 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
755 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
756 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
758 /* Avoid stupid compiler warnings */
766 /* Start outer loop over neighborlists */
767 for(iidx=0; iidx<nri; iidx++)
769 /* Load shift vector for this list */
770 i_shift_offset = DIM*shiftidx[iidx];
772 /* Load limits for loop over neighbors */
773 j_index_start = jindex[iidx];
774 j_index_end = jindex[iidx+1];
776 /* Get outer coordinate index */
778 i_coord_offset = DIM*inr;
780 /* Load i particle coords and add shift vector */
781 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
782 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
784 fix0 = _mm_setzero_pd();
785 fiy0 = _mm_setzero_pd();
786 fiz0 = _mm_setzero_pd();
787 fix1 = _mm_setzero_pd();
788 fiy1 = _mm_setzero_pd();
789 fiz1 = _mm_setzero_pd();
790 fix2 = _mm_setzero_pd();
791 fiy2 = _mm_setzero_pd();
792 fiz2 = _mm_setzero_pd();
793 fix3 = _mm_setzero_pd();
794 fiy3 = _mm_setzero_pd();
795 fiz3 = _mm_setzero_pd();
797 /* Start inner kernel loop */
798 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
801 /* Get j neighbor index, and coordinate index */
804 j_coord_offsetA = DIM*jnrA;
805 j_coord_offsetB = DIM*jnrB;
807 /* load j atom coordinates */
808 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
811 /* Calculate displacement vector */
812 dx00 = _mm_sub_pd(ix0,jx0);
813 dy00 = _mm_sub_pd(iy0,jy0);
814 dz00 = _mm_sub_pd(iz0,jz0);
815 dx10 = _mm_sub_pd(ix1,jx0);
816 dy10 = _mm_sub_pd(iy1,jy0);
817 dz10 = _mm_sub_pd(iz1,jz0);
818 dx20 = _mm_sub_pd(ix2,jx0);
819 dy20 = _mm_sub_pd(iy2,jy0);
820 dz20 = _mm_sub_pd(iz2,jz0);
821 dx30 = _mm_sub_pd(ix3,jx0);
822 dy30 = _mm_sub_pd(iy3,jy0);
823 dz30 = _mm_sub_pd(iz3,jz0);
825 /* Calculate squared distance and things based on it */
826 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
827 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
828 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
829 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
831 rinv00 = gmx_mm_invsqrt_pd(rsq00);
832 rinv10 = gmx_mm_invsqrt_pd(rsq10);
833 rinv20 = gmx_mm_invsqrt_pd(rsq20);
834 rinv30 = gmx_mm_invsqrt_pd(rsq30);
836 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
837 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
838 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
839 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
841 /* Load parameters for j particles */
842 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
843 vdwjidx0A = 2*vdwtype[jnrA+0];
844 vdwjidx0B = 2*vdwtype[jnrB+0];
846 fjx0 = _mm_setzero_pd();
847 fjy0 = _mm_setzero_pd();
848 fjz0 = _mm_setzero_pd();
850 /**************************
851 * CALCULATE INTERACTIONS *
852 **************************/
854 if (gmx_mm_any_lt(rsq00,rcutoff2))
857 r00 = _mm_mul_pd(rsq00,rinv00);
859 /* Compute parameters for interactions between i and j atoms */
860 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
861 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
863 /* LENNARD-JONES DISPERSION/REPULSION */
865 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
866 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
867 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
868 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
869 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
871 d = _mm_sub_pd(r00,rswitch);
872 d = _mm_max_pd(d,_mm_setzero_pd());
873 d2 = _mm_mul_pd(d,d);
874 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
876 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
878 /* Evaluate switch function */
879 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
880 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
881 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
885 fscal = _mm_and_pd(fscal,cutoff_mask);
887 /* Update vectorial force */
888 fix0 = _mm_macc_pd(dx00,fscal,fix0);
889 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
890 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
892 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
893 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
894 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
898 /**************************
899 * CALCULATE INTERACTIONS *
900 **************************/
902 if (gmx_mm_any_lt(rsq10,rcutoff2))
905 /* Compute parameters for interactions between i and j atoms */
906 qq10 = _mm_mul_pd(iq1,jq0);
908 /* REACTION-FIELD ELECTROSTATICS */
909 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
911 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
915 fscal = _mm_and_pd(fscal,cutoff_mask);
917 /* Update vectorial force */
918 fix1 = _mm_macc_pd(dx10,fscal,fix1);
919 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
920 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
922 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
923 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
924 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
928 /**************************
929 * CALCULATE INTERACTIONS *
930 **************************/
932 if (gmx_mm_any_lt(rsq20,rcutoff2))
935 /* Compute parameters for interactions between i and j atoms */
936 qq20 = _mm_mul_pd(iq2,jq0);
938 /* REACTION-FIELD ELECTROSTATICS */
939 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
941 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
945 fscal = _mm_and_pd(fscal,cutoff_mask);
947 /* Update vectorial force */
948 fix2 = _mm_macc_pd(dx20,fscal,fix2);
949 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
950 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
952 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
953 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
954 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
958 /**************************
959 * CALCULATE INTERACTIONS *
960 **************************/
962 if (gmx_mm_any_lt(rsq30,rcutoff2))
965 /* Compute parameters for interactions between i and j atoms */
966 qq30 = _mm_mul_pd(iq3,jq0);
968 /* REACTION-FIELD ELECTROSTATICS */
969 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
971 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
975 fscal = _mm_and_pd(fscal,cutoff_mask);
977 /* Update vectorial force */
978 fix3 = _mm_macc_pd(dx30,fscal,fix3);
979 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
980 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
982 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
983 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
984 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
988 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
990 /* Inner loop uses 161 flops */
997 j_coord_offsetA = DIM*jnrA;
999 /* load j atom coordinates */
1000 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
1003 /* Calculate displacement vector */
1004 dx00 = _mm_sub_pd(ix0,jx0);
1005 dy00 = _mm_sub_pd(iy0,jy0);
1006 dz00 = _mm_sub_pd(iz0,jz0);
1007 dx10 = _mm_sub_pd(ix1,jx0);
1008 dy10 = _mm_sub_pd(iy1,jy0);
1009 dz10 = _mm_sub_pd(iz1,jz0);
1010 dx20 = _mm_sub_pd(ix2,jx0);
1011 dy20 = _mm_sub_pd(iy2,jy0);
1012 dz20 = _mm_sub_pd(iz2,jz0);
1013 dx30 = _mm_sub_pd(ix3,jx0);
1014 dy30 = _mm_sub_pd(iy3,jy0);
1015 dz30 = _mm_sub_pd(iz3,jz0);
1017 /* Calculate squared distance and things based on it */
1018 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1019 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
1020 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
1021 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
1023 rinv00 = gmx_mm_invsqrt_pd(rsq00);
1024 rinv10 = gmx_mm_invsqrt_pd(rsq10);
1025 rinv20 = gmx_mm_invsqrt_pd(rsq20);
1026 rinv30 = gmx_mm_invsqrt_pd(rsq30);
1028 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
1029 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1030 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1031 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
1033 /* Load parameters for j particles */
1034 jq0 = _mm_load_sd(charge+jnrA+0);
1035 vdwjidx0A = 2*vdwtype[jnrA+0];
1037 fjx0 = _mm_setzero_pd();
1038 fjy0 = _mm_setzero_pd();
1039 fjz0 = _mm_setzero_pd();
1041 /**************************
1042 * CALCULATE INTERACTIONS *
1043 **************************/
1045 if (gmx_mm_any_lt(rsq00,rcutoff2))
1048 r00 = _mm_mul_pd(rsq00,rinv00);
1050 /* Compute parameters for interactions between i and j atoms */
1051 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1053 /* LENNARD-JONES DISPERSION/REPULSION */
1055 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
1056 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
1057 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
1058 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
1059 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
1061 d = _mm_sub_pd(r00,rswitch);
1062 d = _mm_max_pd(d,_mm_setzero_pd());
1063 d2 = _mm_mul_pd(d,d);
1064 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
1066 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
1068 /* Evaluate switch function */
1069 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1070 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
1071 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
1075 fscal = _mm_and_pd(fscal,cutoff_mask);
1077 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1079 /* Update vectorial force */
1080 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1081 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1082 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1084 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1085 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1086 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1090 /**************************
1091 * CALCULATE INTERACTIONS *
1092 **************************/
1094 if (gmx_mm_any_lt(rsq10,rcutoff2))
1097 /* Compute parameters for interactions between i and j atoms */
1098 qq10 = _mm_mul_pd(iq1,jq0);
1100 /* REACTION-FIELD ELECTROSTATICS */
1101 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1103 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
1107 fscal = _mm_and_pd(fscal,cutoff_mask);
1109 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1111 /* Update vectorial force */
1112 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1113 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1114 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1116 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1117 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1118 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1122 /**************************
1123 * CALCULATE INTERACTIONS *
1124 **************************/
1126 if (gmx_mm_any_lt(rsq20,rcutoff2))
1129 /* Compute parameters for interactions between i and j atoms */
1130 qq20 = _mm_mul_pd(iq2,jq0);
1132 /* REACTION-FIELD ELECTROSTATICS */
1133 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1135 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
1139 fscal = _mm_and_pd(fscal,cutoff_mask);
1141 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1143 /* Update vectorial force */
1144 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1145 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1146 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1148 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1149 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1150 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1154 /**************************
1155 * CALCULATE INTERACTIONS *
1156 **************************/
1158 if (gmx_mm_any_lt(rsq30,rcutoff2))
1161 /* Compute parameters for interactions between i and j atoms */
1162 qq30 = _mm_mul_pd(iq3,jq0);
1164 /* REACTION-FIELD ELECTROSTATICS */
1165 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
1167 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
1171 fscal = _mm_and_pd(fscal,cutoff_mask);
1173 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1175 /* Update vectorial force */
1176 fix3 = _mm_macc_pd(dx30,fscal,fix3);
1177 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
1178 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
1180 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
1181 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
1182 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
1186 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1188 /* Inner loop uses 161 flops */
1191 /* End of innermost loop */
1193 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1194 f+i_coord_offset,fshift+i_shift_offset);
1196 /* Increment number of inner iterations */
1197 inneriter += j_index_end - j_index_start;
1199 /* Outer loop uses 24 flops */
1202 /* Increment number of outer iterations */
1205 /* Update outer/inner flops */
1207 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*161);