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.
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_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: LennardJones
56 * Geometry: Water4-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
89 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
90 int vdwjidx0A,vdwjidx0B;
91 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
92 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
93 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
94 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
95 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
96 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
99 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
102 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
103 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
104 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
105 real rswitch_scalar,d_scalar;
106 __m128d dummy_mask,cutoff_mask;
107 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
108 __m128d one = _mm_set1_pd(1.0);
109 __m128d two = _mm_set1_pd(2.0);
115 jindex = nlist->jindex;
117 shiftidx = nlist->shift;
119 shiftvec = fr->shift_vec[0];
120 fshift = fr->fshift[0];
121 facel = _mm_set1_pd(fr->epsfac);
122 charge = mdatoms->chargeA;
123 krf = _mm_set1_pd(fr->ic->k_rf);
124 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
125 crf = _mm_set1_pd(fr->ic->c_rf);
126 nvdwtype = fr->ntype;
128 vdwtype = mdatoms->typeA;
130 /* Setup water-specific parameters */
131 inr = nlist->iinr[0];
132 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
133 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
134 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
135 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
137 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
138 rcutoff_scalar = fr->rcoulomb;
139 rcutoff = _mm_set1_pd(rcutoff_scalar);
140 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
142 rswitch_scalar = fr->rvdw_switch;
143 rswitch = _mm_set1_pd(rswitch_scalar);
144 /* Setup switch parameters */
145 d_scalar = rcutoff_scalar-rswitch_scalar;
146 d = _mm_set1_pd(d_scalar);
147 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
148 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
149 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
150 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
151 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
152 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
154 /* Avoid stupid compiler warnings */
162 /* Start outer loop over neighborlists */
163 for(iidx=0; iidx<nri; iidx++)
165 /* Load shift vector for this list */
166 i_shift_offset = DIM*shiftidx[iidx];
168 /* Load limits for loop over neighbors */
169 j_index_start = jindex[iidx];
170 j_index_end = jindex[iidx+1];
172 /* Get outer coordinate index */
174 i_coord_offset = DIM*inr;
176 /* Load i particle coords and add shift vector */
177 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
178 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
180 fix0 = _mm_setzero_pd();
181 fiy0 = _mm_setzero_pd();
182 fiz0 = _mm_setzero_pd();
183 fix1 = _mm_setzero_pd();
184 fiy1 = _mm_setzero_pd();
185 fiz1 = _mm_setzero_pd();
186 fix2 = _mm_setzero_pd();
187 fiy2 = _mm_setzero_pd();
188 fiz2 = _mm_setzero_pd();
189 fix3 = _mm_setzero_pd();
190 fiy3 = _mm_setzero_pd();
191 fiz3 = _mm_setzero_pd();
193 /* Reset potential sums */
194 velecsum = _mm_setzero_pd();
195 vvdwsum = _mm_setzero_pd();
197 /* Start inner kernel loop */
198 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
201 /* Get j neighbor index, and coordinate index */
204 j_coord_offsetA = DIM*jnrA;
205 j_coord_offsetB = DIM*jnrB;
207 /* load j atom coordinates */
208 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
211 /* Calculate displacement vector */
212 dx00 = _mm_sub_pd(ix0,jx0);
213 dy00 = _mm_sub_pd(iy0,jy0);
214 dz00 = _mm_sub_pd(iz0,jz0);
215 dx10 = _mm_sub_pd(ix1,jx0);
216 dy10 = _mm_sub_pd(iy1,jy0);
217 dz10 = _mm_sub_pd(iz1,jz0);
218 dx20 = _mm_sub_pd(ix2,jx0);
219 dy20 = _mm_sub_pd(iy2,jy0);
220 dz20 = _mm_sub_pd(iz2,jz0);
221 dx30 = _mm_sub_pd(ix3,jx0);
222 dy30 = _mm_sub_pd(iy3,jy0);
223 dz30 = _mm_sub_pd(iz3,jz0);
225 /* Calculate squared distance and things based on it */
226 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
227 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
228 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
229 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
231 rinv00 = gmx_mm_invsqrt_pd(rsq00);
232 rinv10 = gmx_mm_invsqrt_pd(rsq10);
233 rinv20 = gmx_mm_invsqrt_pd(rsq20);
234 rinv30 = gmx_mm_invsqrt_pd(rsq30);
236 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
237 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
238 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
239 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
241 /* Load parameters for j particles */
242 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
243 vdwjidx0A = 2*vdwtype[jnrA+0];
244 vdwjidx0B = 2*vdwtype[jnrB+0];
246 fjx0 = _mm_setzero_pd();
247 fjy0 = _mm_setzero_pd();
248 fjz0 = _mm_setzero_pd();
250 /**************************
251 * CALCULATE INTERACTIONS *
252 **************************/
254 if (gmx_mm_any_lt(rsq00,rcutoff2))
257 r00 = _mm_mul_pd(rsq00,rinv00);
259 /* Compute parameters for interactions between i and j atoms */
260 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
261 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
263 /* LENNARD-JONES DISPERSION/REPULSION */
265 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
266 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
267 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
268 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
269 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
271 d = _mm_sub_pd(r00,rswitch);
272 d = _mm_max_pd(d,_mm_setzero_pd());
273 d2 = _mm_mul_pd(d,d);
274 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
276 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
278 /* Evaluate switch function */
279 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
280 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
281 vvdw = _mm_mul_pd(vvdw,sw);
282 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
284 /* Update potential sum for this i atom from the interaction with this j atom. */
285 vvdw = _mm_and_pd(vvdw,cutoff_mask);
286 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
290 fscal = _mm_and_pd(fscal,cutoff_mask);
292 /* Update vectorial force */
293 fix0 = _mm_macc_pd(dx00,fscal,fix0);
294 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
295 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
297 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
298 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
299 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
307 if (gmx_mm_any_lt(rsq10,rcutoff2))
310 /* Compute parameters for interactions between i and j atoms */
311 qq10 = _mm_mul_pd(iq1,jq0);
313 /* REACTION-FIELD ELECTROSTATICS */
314 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
315 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
317 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
319 /* Update potential sum for this i atom from the interaction with this j atom. */
320 velec = _mm_and_pd(velec,cutoff_mask);
321 velecsum = _mm_add_pd(velecsum,velec);
325 fscal = _mm_and_pd(fscal,cutoff_mask);
327 /* Update vectorial force */
328 fix1 = _mm_macc_pd(dx10,fscal,fix1);
329 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
330 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
332 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
333 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
334 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
338 /**************************
339 * CALCULATE INTERACTIONS *
340 **************************/
342 if (gmx_mm_any_lt(rsq20,rcutoff2))
345 /* Compute parameters for interactions between i and j atoms */
346 qq20 = _mm_mul_pd(iq2,jq0);
348 /* REACTION-FIELD ELECTROSTATICS */
349 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
350 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
352 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
354 /* Update potential sum for this i atom from the interaction with this j atom. */
355 velec = _mm_and_pd(velec,cutoff_mask);
356 velecsum = _mm_add_pd(velecsum,velec);
360 fscal = _mm_and_pd(fscal,cutoff_mask);
362 /* Update vectorial force */
363 fix2 = _mm_macc_pd(dx20,fscal,fix2);
364 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
365 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
367 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
368 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
369 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
373 /**************************
374 * CALCULATE INTERACTIONS *
375 **************************/
377 if (gmx_mm_any_lt(rsq30,rcutoff2))
380 /* Compute parameters for interactions between i and j atoms */
381 qq30 = _mm_mul_pd(iq3,jq0);
383 /* REACTION-FIELD ELECTROSTATICS */
384 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
385 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
387 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
389 /* Update potential sum for this i atom from the interaction with this j atom. */
390 velec = _mm_and_pd(velec,cutoff_mask);
391 velecsum = _mm_add_pd(velecsum,velec);
395 fscal = _mm_and_pd(fscal,cutoff_mask);
397 /* Update vectorial force */
398 fix3 = _mm_macc_pd(dx30,fscal,fix3);
399 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
400 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
402 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
403 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
404 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
408 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
410 /* Inner loop uses 182 flops */
417 j_coord_offsetA = DIM*jnrA;
419 /* load j atom coordinates */
420 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
423 /* Calculate displacement vector */
424 dx00 = _mm_sub_pd(ix0,jx0);
425 dy00 = _mm_sub_pd(iy0,jy0);
426 dz00 = _mm_sub_pd(iz0,jz0);
427 dx10 = _mm_sub_pd(ix1,jx0);
428 dy10 = _mm_sub_pd(iy1,jy0);
429 dz10 = _mm_sub_pd(iz1,jz0);
430 dx20 = _mm_sub_pd(ix2,jx0);
431 dy20 = _mm_sub_pd(iy2,jy0);
432 dz20 = _mm_sub_pd(iz2,jz0);
433 dx30 = _mm_sub_pd(ix3,jx0);
434 dy30 = _mm_sub_pd(iy3,jy0);
435 dz30 = _mm_sub_pd(iz3,jz0);
437 /* Calculate squared distance and things based on it */
438 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
439 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
440 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
441 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
443 rinv00 = gmx_mm_invsqrt_pd(rsq00);
444 rinv10 = gmx_mm_invsqrt_pd(rsq10);
445 rinv20 = gmx_mm_invsqrt_pd(rsq20);
446 rinv30 = gmx_mm_invsqrt_pd(rsq30);
448 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
449 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
450 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
451 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
453 /* Load parameters for j particles */
454 jq0 = _mm_load_sd(charge+jnrA+0);
455 vdwjidx0A = 2*vdwtype[jnrA+0];
457 fjx0 = _mm_setzero_pd();
458 fjy0 = _mm_setzero_pd();
459 fjz0 = _mm_setzero_pd();
461 /**************************
462 * CALCULATE INTERACTIONS *
463 **************************/
465 if (gmx_mm_any_lt(rsq00,rcutoff2))
468 r00 = _mm_mul_pd(rsq00,rinv00);
470 /* Compute parameters for interactions between i and j atoms */
471 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
473 /* LENNARD-JONES DISPERSION/REPULSION */
475 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
476 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
477 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
478 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
479 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
481 d = _mm_sub_pd(r00,rswitch);
482 d = _mm_max_pd(d,_mm_setzero_pd());
483 d2 = _mm_mul_pd(d,d);
484 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
486 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
488 /* Evaluate switch function */
489 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
490 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
491 vvdw = _mm_mul_pd(vvdw,sw);
492 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
494 /* Update potential sum for this i atom from the interaction with this j atom. */
495 vvdw = _mm_and_pd(vvdw,cutoff_mask);
496 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
497 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
501 fscal = _mm_and_pd(fscal,cutoff_mask);
503 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
505 /* Update vectorial force */
506 fix0 = _mm_macc_pd(dx00,fscal,fix0);
507 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
508 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
510 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
511 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
512 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
516 /**************************
517 * CALCULATE INTERACTIONS *
518 **************************/
520 if (gmx_mm_any_lt(rsq10,rcutoff2))
523 /* Compute parameters for interactions between i and j atoms */
524 qq10 = _mm_mul_pd(iq1,jq0);
526 /* REACTION-FIELD ELECTROSTATICS */
527 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
528 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
530 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
532 /* Update potential sum for this i atom from the interaction with this j atom. */
533 velec = _mm_and_pd(velec,cutoff_mask);
534 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
535 velecsum = _mm_add_pd(velecsum,velec);
539 fscal = _mm_and_pd(fscal,cutoff_mask);
541 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
543 /* Update vectorial force */
544 fix1 = _mm_macc_pd(dx10,fscal,fix1);
545 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
546 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
548 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
549 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
550 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
558 if (gmx_mm_any_lt(rsq20,rcutoff2))
561 /* Compute parameters for interactions between i and j atoms */
562 qq20 = _mm_mul_pd(iq2,jq0);
564 /* REACTION-FIELD ELECTROSTATICS */
565 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
566 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
568 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
570 /* Update potential sum for this i atom from the interaction with this j atom. */
571 velec = _mm_and_pd(velec,cutoff_mask);
572 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
573 velecsum = _mm_add_pd(velecsum,velec);
577 fscal = _mm_and_pd(fscal,cutoff_mask);
579 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
581 /* Update vectorial force */
582 fix2 = _mm_macc_pd(dx20,fscal,fix2);
583 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
584 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
586 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
587 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
588 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
596 if (gmx_mm_any_lt(rsq30,rcutoff2))
599 /* Compute parameters for interactions between i and j atoms */
600 qq30 = _mm_mul_pd(iq3,jq0);
602 /* REACTION-FIELD ELECTROSTATICS */
603 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
604 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
606 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
608 /* Update potential sum for this i atom from the interaction with this j atom. */
609 velec = _mm_and_pd(velec,cutoff_mask);
610 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
611 velecsum = _mm_add_pd(velecsum,velec);
615 fscal = _mm_and_pd(fscal,cutoff_mask);
617 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
619 /* Update vectorial force */
620 fix3 = _mm_macc_pd(dx30,fscal,fix3);
621 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
622 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
624 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
625 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
626 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
630 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
632 /* Inner loop uses 182 flops */
635 /* End of innermost loop */
637 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
638 f+i_coord_offset,fshift+i_shift_offset);
641 /* Update potential energies */
642 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
643 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
645 /* Increment number of inner iterations */
646 inneriter += j_index_end - j_index_start;
648 /* Outer loop uses 26 flops */
651 /* Increment number of outer iterations */
654 /* Update outer/inner flops */
656 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*182);
659 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
660 * Electrostatics interaction: ReactionField
661 * VdW interaction: LennardJones
662 * Geometry: Water4-Particle
663 * Calculate force/pot: Force
666 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
667 (t_nblist * gmx_restrict nlist,
668 rvec * gmx_restrict xx,
669 rvec * gmx_restrict ff,
670 t_forcerec * gmx_restrict fr,
671 t_mdatoms * gmx_restrict mdatoms,
672 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
673 t_nrnb * gmx_restrict nrnb)
675 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
676 * just 0 for non-waters.
677 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
678 * jnr indices corresponding to data put in the four positions in the SIMD register.
680 int i_shift_offset,i_coord_offset,outeriter,inneriter;
681 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
683 int j_coord_offsetA,j_coord_offsetB;
684 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
686 real *shiftvec,*fshift,*x,*f;
687 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
689 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
691 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
693 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
695 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
696 int vdwjidx0A,vdwjidx0B;
697 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
698 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
699 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
700 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
701 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
702 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
705 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
708 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
709 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
710 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
711 real rswitch_scalar,d_scalar;
712 __m128d dummy_mask,cutoff_mask;
713 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
714 __m128d one = _mm_set1_pd(1.0);
715 __m128d two = _mm_set1_pd(2.0);
721 jindex = nlist->jindex;
723 shiftidx = nlist->shift;
725 shiftvec = fr->shift_vec[0];
726 fshift = fr->fshift[0];
727 facel = _mm_set1_pd(fr->epsfac);
728 charge = mdatoms->chargeA;
729 krf = _mm_set1_pd(fr->ic->k_rf);
730 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
731 crf = _mm_set1_pd(fr->ic->c_rf);
732 nvdwtype = fr->ntype;
734 vdwtype = mdatoms->typeA;
736 /* Setup water-specific parameters */
737 inr = nlist->iinr[0];
738 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
739 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
740 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
741 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
743 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
744 rcutoff_scalar = fr->rcoulomb;
745 rcutoff = _mm_set1_pd(rcutoff_scalar);
746 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
748 rswitch_scalar = fr->rvdw_switch;
749 rswitch = _mm_set1_pd(rswitch_scalar);
750 /* Setup switch parameters */
751 d_scalar = rcutoff_scalar-rswitch_scalar;
752 d = _mm_set1_pd(d_scalar);
753 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
754 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
755 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
756 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
757 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
758 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
760 /* Avoid stupid compiler warnings */
768 /* Start outer loop over neighborlists */
769 for(iidx=0; iidx<nri; iidx++)
771 /* Load shift vector for this list */
772 i_shift_offset = DIM*shiftidx[iidx];
774 /* Load limits for loop over neighbors */
775 j_index_start = jindex[iidx];
776 j_index_end = jindex[iidx+1];
778 /* Get outer coordinate index */
780 i_coord_offset = DIM*inr;
782 /* Load i particle coords and add shift vector */
783 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
784 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
786 fix0 = _mm_setzero_pd();
787 fiy0 = _mm_setzero_pd();
788 fiz0 = _mm_setzero_pd();
789 fix1 = _mm_setzero_pd();
790 fiy1 = _mm_setzero_pd();
791 fiz1 = _mm_setzero_pd();
792 fix2 = _mm_setzero_pd();
793 fiy2 = _mm_setzero_pd();
794 fiz2 = _mm_setzero_pd();
795 fix3 = _mm_setzero_pd();
796 fiy3 = _mm_setzero_pd();
797 fiz3 = _mm_setzero_pd();
799 /* Start inner kernel loop */
800 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
803 /* Get j neighbor index, and coordinate index */
806 j_coord_offsetA = DIM*jnrA;
807 j_coord_offsetB = DIM*jnrB;
809 /* load j atom coordinates */
810 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
813 /* Calculate displacement vector */
814 dx00 = _mm_sub_pd(ix0,jx0);
815 dy00 = _mm_sub_pd(iy0,jy0);
816 dz00 = _mm_sub_pd(iz0,jz0);
817 dx10 = _mm_sub_pd(ix1,jx0);
818 dy10 = _mm_sub_pd(iy1,jy0);
819 dz10 = _mm_sub_pd(iz1,jz0);
820 dx20 = _mm_sub_pd(ix2,jx0);
821 dy20 = _mm_sub_pd(iy2,jy0);
822 dz20 = _mm_sub_pd(iz2,jz0);
823 dx30 = _mm_sub_pd(ix3,jx0);
824 dy30 = _mm_sub_pd(iy3,jy0);
825 dz30 = _mm_sub_pd(iz3,jz0);
827 /* Calculate squared distance and things based on it */
828 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
829 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
830 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
831 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
833 rinv00 = gmx_mm_invsqrt_pd(rsq00);
834 rinv10 = gmx_mm_invsqrt_pd(rsq10);
835 rinv20 = gmx_mm_invsqrt_pd(rsq20);
836 rinv30 = gmx_mm_invsqrt_pd(rsq30);
838 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
839 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
840 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
841 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
843 /* Load parameters for j particles */
844 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
845 vdwjidx0A = 2*vdwtype[jnrA+0];
846 vdwjidx0B = 2*vdwtype[jnrB+0];
848 fjx0 = _mm_setzero_pd();
849 fjy0 = _mm_setzero_pd();
850 fjz0 = _mm_setzero_pd();
852 /**************************
853 * CALCULATE INTERACTIONS *
854 **************************/
856 if (gmx_mm_any_lt(rsq00,rcutoff2))
859 r00 = _mm_mul_pd(rsq00,rinv00);
861 /* Compute parameters for interactions between i and j atoms */
862 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
863 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
865 /* LENNARD-JONES DISPERSION/REPULSION */
867 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
868 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
869 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
870 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
871 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
873 d = _mm_sub_pd(r00,rswitch);
874 d = _mm_max_pd(d,_mm_setzero_pd());
875 d2 = _mm_mul_pd(d,d);
876 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
878 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
880 /* Evaluate switch function */
881 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
882 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
883 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
887 fscal = _mm_and_pd(fscal,cutoff_mask);
889 /* Update vectorial force */
890 fix0 = _mm_macc_pd(dx00,fscal,fix0);
891 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
892 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
894 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
895 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
896 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
900 /**************************
901 * CALCULATE INTERACTIONS *
902 **************************/
904 if (gmx_mm_any_lt(rsq10,rcutoff2))
907 /* Compute parameters for interactions between i and j atoms */
908 qq10 = _mm_mul_pd(iq1,jq0);
910 /* REACTION-FIELD ELECTROSTATICS */
911 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
913 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
917 fscal = _mm_and_pd(fscal,cutoff_mask);
919 /* Update vectorial force */
920 fix1 = _mm_macc_pd(dx10,fscal,fix1);
921 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
922 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
924 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
925 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
926 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
930 /**************************
931 * CALCULATE INTERACTIONS *
932 **************************/
934 if (gmx_mm_any_lt(rsq20,rcutoff2))
937 /* Compute parameters for interactions between i and j atoms */
938 qq20 = _mm_mul_pd(iq2,jq0);
940 /* REACTION-FIELD ELECTROSTATICS */
941 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
943 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
947 fscal = _mm_and_pd(fscal,cutoff_mask);
949 /* Update vectorial force */
950 fix2 = _mm_macc_pd(dx20,fscal,fix2);
951 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
952 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
954 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
955 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
956 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
960 /**************************
961 * CALCULATE INTERACTIONS *
962 **************************/
964 if (gmx_mm_any_lt(rsq30,rcutoff2))
967 /* Compute parameters for interactions between i and j atoms */
968 qq30 = _mm_mul_pd(iq3,jq0);
970 /* REACTION-FIELD ELECTROSTATICS */
971 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
973 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
977 fscal = _mm_and_pd(fscal,cutoff_mask);
979 /* Update vectorial force */
980 fix3 = _mm_macc_pd(dx30,fscal,fix3);
981 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
982 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
984 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
985 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
986 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
990 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
992 /* Inner loop uses 161 flops */
999 j_coord_offsetA = DIM*jnrA;
1001 /* load j atom coordinates */
1002 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
1005 /* Calculate displacement vector */
1006 dx00 = _mm_sub_pd(ix0,jx0);
1007 dy00 = _mm_sub_pd(iy0,jy0);
1008 dz00 = _mm_sub_pd(iz0,jz0);
1009 dx10 = _mm_sub_pd(ix1,jx0);
1010 dy10 = _mm_sub_pd(iy1,jy0);
1011 dz10 = _mm_sub_pd(iz1,jz0);
1012 dx20 = _mm_sub_pd(ix2,jx0);
1013 dy20 = _mm_sub_pd(iy2,jy0);
1014 dz20 = _mm_sub_pd(iz2,jz0);
1015 dx30 = _mm_sub_pd(ix3,jx0);
1016 dy30 = _mm_sub_pd(iy3,jy0);
1017 dz30 = _mm_sub_pd(iz3,jz0);
1019 /* Calculate squared distance and things based on it */
1020 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1021 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
1022 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
1023 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
1025 rinv00 = gmx_mm_invsqrt_pd(rsq00);
1026 rinv10 = gmx_mm_invsqrt_pd(rsq10);
1027 rinv20 = gmx_mm_invsqrt_pd(rsq20);
1028 rinv30 = gmx_mm_invsqrt_pd(rsq30);
1030 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
1031 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1032 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1033 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
1035 /* Load parameters for j particles */
1036 jq0 = _mm_load_sd(charge+jnrA+0);
1037 vdwjidx0A = 2*vdwtype[jnrA+0];
1039 fjx0 = _mm_setzero_pd();
1040 fjy0 = _mm_setzero_pd();
1041 fjz0 = _mm_setzero_pd();
1043 /**************************
1044 * CALCULATE INTERACTIONS *
1045 **************************/
1047 if (gmx_mm_any_lt(rsq00,rcutoff2))
1050 r00 = _mm_mul_pd(rsq00,rinv00);
1052 /* Compute parameters for interactions between i and j atoms */
1053 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1055 /* LENNARD-JONES DISPERSION/REPULSION */
1057 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
1058 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
1059 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
1060 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
1061 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
1063 d = _mm_sub_pd(r00,rswitch);
1064 d = _mm_max_pd(d,_mm_setzero_pd());
1065 d2 = _mm_mul_pd(d,d);
1066 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
1068 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
1070 /* Evaluate switch function */
1071 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1072 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
1073 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
1077 fscal = _mm_and_pd(fscal,cutoff_mask);
1079 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1081 /* Update vectorial force */
1082 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1083 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1084 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1086 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1087 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1088 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1092 /**************************
1093 * CALCULATE INTERACTIONS *
1094 **************************/
1096 if (gmx_mm_any_lt(rsq10,rcutoff2))
1099 /* Compute parameters for interactions between i and j atoms */
1100 qq10 = _mm_mul_pd(iq1,jq0);
1102 /* REACTION-FIELD ELECTROSTATICS */
1103 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1105 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
1109 fscal = _mm_and_pd(fscal,cutoff_mask);
1111 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1113 /* Update vectorial force */
1114 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1115 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1116 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1118 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1119 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1120 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1124 /**************************
1125 * CALCULATE INTERACTIONS *
1126 **************************/
1128 if (gmx_mm_any_lt(rsq20,rcutoff2))
1131 /* Compute parameters for interactions between i and j atoms */
1132 qq20 = _mm_mul_pd(iq2,jq0);
1134 /* REACTION-FIELD ELECTROSTATICS */
1135 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1137 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
1141 fscal = _mm_and_pd(fscal,cutoff_mask);
1143 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1145 /* Update vectorial force */
1146 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1147 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1148 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1150 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1151 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1152 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1156 /**************************
1157 * CALCULATE INTERACTIONS *
1158 **************************/
1160 if (gmx_mm_any_lt(rsq30,rcutoff2))
1163 /* Compute parameters for interactions between i and j atoms */
1164 qq30 = _mm_mul_pd(iq3,jq0);
1166 /* REACTION-FIELD ELECTROSTATICS */
1167 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
1169 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
1173 fscal = _mm_and_pd(fscal,cutoff_mask);
1175 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1177 /* Update vectorial force */
1178 fix3 = _mm_macc_pd(dx30,fscal,fix3);
1179 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
1180 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
1182 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
1183 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
1184 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
1188 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1190 /* Inner loop uses 161 flops */
1193 /* End of innermost loop */
1195 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1196 f+i_coord_offset,fshift+i_shift_offset);
1198 /* Increment number of inner iterations */
1199 inneriter += j_index_end - j_index_start;
1201 /* Outer loop uses 24 flops */
1204 /* Increment number of outer iterations */
1207 /* Update outer/inner flops */
1209 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*161);