2 * Note: this file was generated by the Gromacs avx_128_fma_double 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_double.h"
34 #include "kernelutil_x86_avx_128_fma_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: LennardJones
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_avx_128_fma_double
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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
69 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
71 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
73 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
74 int vdwjidx0A,vdwjidx0B;
75 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
77 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
78 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
79 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
80 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
83 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
86 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
87 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
88 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
89 real rswitch_scalar,d_scalar;
90 __m128d dummy_mask,cutoff_mask;
91 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
92 __m128d one = _mm_set1_pd(1.0);
93 __m128d two = _mm_set1_pd(2.0);
99 jindex = nlist->jindex;
101 shiftidx = nlist->shift;
103 shiftvec = fr->shift_vec[0];
104 fshift = fr->fshift[0];
105 facel = _mm_set1_pd(fr->epsfac);
106 charge = mdatoms->chargeA;
107 krf = _mm_set1_pd(fr->ic->k_rf);
108 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
109 crf = _mm_set1_pd(fr->ic->c_rf);
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 /* Setup water-specific parameters */
115 inr = nlist->iinr[0];
116 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
117 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
118 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
119 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
121 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
122 rcutoff_scalar = fr->rcoulomb;
123 rcutoff = _mm_set1_pd(rcutoff_scalar);
124 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
126 rswitch_scalar = fr->rvdw_switch;
127 rswitch = _mm_set1_pd(rswitch_scalar);
128 /* Setup switch parameters */
129 d_scalar = rcutoff_scalar-rswitch_scalar;
130 d = _mm_set1_pd(d_scalar);
131 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
132 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
133 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
134 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
135 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
136 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
138 /* Avoid stupid compiler warnings */
146 /* Start outer loop over neighborlists */
147 for(iidx=0; iidx<nri; iidx++)
149 /* Load shift vector for this list */
150 i_shift_offset = DIM*shiftidx[iidx];
152 /* Load limits for loop over neighbors */
153 j_index_start = jindex[iidx];
154 j_index_end = jindex[iidx+1];
156 /* Get outer coordinate index */
158 i_coord_offset = DIM*inr;
160 /* Load i particle coords and add shift vector */
161 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
162 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
164 fix0 = _mm_setzero_pd();
165 fiy0 = _mm_setzero_pd();
166 fiz0 = _mm_setzero_pd();
167 fix1 = _mm_setzero_pd();
168 fiy1 = _mm_setzero_pd();
169 fiz1 = _mm_setzero_pd();
170 fix2 = _mm_setzero_pd();
171 fiy2 = _mm_setzero_pd();
172 fiz2 = _mm_setzero_pd();
173 fix3 = _mm_setzero_pd();
174 fiy3 = _mm_setzero_pd();
175 fiz3 = _mm_setzero_pd();
177 /* Reset potential sums */
178 velecsum = _mm_setzero_pd();
179 vvdwsum = _mm_setzero_pd();
181 /* Start inner kernel loop */
182 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
185 /* Get j neighbor index, and coordinate index */
188 j_coord_offsetA = DIM*jnrA;
189 j_coord_offsetB = DIM*jnrB;
191 /* load j atom coordinates */
192 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
195 /* Calculate displacement vector */
196 dx00 = _mm_sub_pd(ix0,jx0);
197 dy00 = _mm_sub_pd(iy0,jy0);
198 dz00 = _mm_sub_pd(iz0,jz0);
199 dx10 = _mm_sub_pd(ix1,jx0);
200 dy10 = _mm_sub_pd(iy1,jy0);
201 dz10 = _mm_sub_pd(iz1,jz0);
202 dx20 = _mm_sub_pd(ix2,jx0);
203 dy20 = _mm_sub_pd(iy2,jy0);
204 dz20 = _mm_sub_pd(iz2,jz0);
205 dx30 = _mm_sub_pd(ix3,jx0);
206 dy30 = _mm_sub_pd(iy3,jy0);
207 dz30 = _mm_sub_pd(iz3,jz0);
209 /* Calculate squared distance and things based on it */
210 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
211 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
212 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
213 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
215 rinv00 = gmx_mm_invsqrt_pd(rsq00);
216 rinv10 = gmx_mm_invsqrt_pd(rsq10);
217 rinv20 = gmx_mm_invsqrt_pd(rsq20);
218 rinv30 = gmx_mm_invsqrt_pd(rsq30);
220 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
221 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
222 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
223 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
225 /* Load parameters for j particles */
226 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
227 vdwjidx0A = 2*vdwtype[jnrA+0];
228 vdwjidx0B = 2*vdwtype[jnrB+0];
230 fjx0 = _mm_setzero_pd();
231 fjy0 = _mm_setzero_pd();
232 fjz0 = _mm_setzero_pd();
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
238 if (gmx_mm_any_lt(rsq00,rcutoff2))
241 r00 = _mm_mul_pd(rsq00,rinv00);
243 /* Compute parameters for interactions between i and j atoms */
244 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
245 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
247 /* LENNARD-JONES DISPERSION/REPULSION */
249 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
250 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
251 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
252 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
253 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
255 d = _mm_sub_pd(r00,rswitch);
256 d = _mm_max_pd(d,_mm_setzero_pd());
257 d2 = _mm_mul_pd(d,d);
258 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
260 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
262 /* Evaluate switch function */
263 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
264 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
265 vvdw = _mm_mul_pd(vvdw,sw);
266 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
268 /* Update potential sum for this i atom from the interaction with this j atom. */
269 vvdw = _mm_and_pd(vvdw,cutoff_mask);
270 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
274 fscal = _mm_and_pd(fscal,cutoff_mask);
276 /* Update vectorial force */
277 fix0 = _mm_macc_pd(dx00,fscal,fix0);
278 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
279 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
281 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
282 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
283 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
287 /**************************
288 * CALCULATE INTERACTIONS *
289 **************************/
291 if (gmx_mm_any_lt(rsq10,rcutoff2))
294 /* Compute parameters for interactions between i and j atoms */
295 qq10 = _mm_mul_pd(iq1,jq0);
297 /* REACTION-FIELD ELECTROSTATICS */
298 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
299 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
301 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
303 /* Update potential sum for this i atom from the interaction with this j atom. */
304 velec = _mm_and_pd(velec,cutoff_mask);
305 velecsum = _mm_add_pd(velecsum,velec);
309 fscal = _mm_and_pd(fscal,cutoff_mask);
311 /* Update vectorial force */
312 fix1 = _mm_macc_pd(dx10,fscal,fix1);
313 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
314 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
316 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
317 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
318 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
322 /**************************
323 * CALCULATE INTERACTIONS *
324 **************************/
326 if (gmx_mm_any_lt(rsq20,rcutoff2))
329 /* Compute parameters for interactions between i and j atoms */
330 qq20 = _mm_mul_pd(iq2,jq0);
332 /* REACTION-FIELD ELECTROSTATICS */
333 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
334 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
336 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
338 /* Update potential sum for this i atom from the interaction with this j atom. */
339 velec = _mm_and_pd(velec,cutoff_mask);
340 velecsum = _mm_add_pd(velecsum,velec);
344 fscal = _mm_and_pd(fscal,cutoff_mask);
346 /* Update vectorial force */
347 fix2 = _mm_macc_pd(dx20,fscal,fix2);
348 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
349 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
351 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
352 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
353 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
357 /**************************
358 * CALCULATE INTERACTIONS *
359 **************************/
361 if (gmx_mm_any_lt(rsq30,rcutoff2))
364 /* Compute parameters for interactions between i and j atoms */
365 qq30 = _mm_mul_pd(iq3,jq0);
367 /* REACTION-FIELD ELECTROSTATICS */
368 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
369 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
371 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
373 /* Update potential sum for this i atom from the interaction with this j atom. */
374 velec = _mm_and_pd(velec,cutoff_mask);
375 velecsum = _mm_add_pd(velecsum,velec);
379 fscal = _mm_and_pd(fscal,cutoff_mask);
381 /* Update vectorial force */
382 fix3 = _mm_macc_pd(dx30,fscal,fix3);
383 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
384 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
386 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
387 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
388 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
392 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
394 /* Inner loop uses 182 flops */
401 j_coord_offsetA = DIM*jnrA;
403 /* load j atom coordinates */
404 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
407 /* Calculate displacement vector */
408 dx00 = _mm_sub_pd(ix0,jx0);
409 dy00 = _mm_sub_pd(iy0,jy0);
410 dz00 = _mm_sub_pd(iz0,jz0);
411 dx10 = _mm_sub_pd(ix1,jx0);
412 dy10 = _mm_sub_pd(iy1,jy0);
413 dz10 = _mm_sub_pd(iz1,jz0);
414 dx20 = _mm_sub_pd(ix2,jx0);
415 dy20 = _mm_sub_pd(iy2,jy0);
416 dz20 = _mm_sub_pd(iz2,jz0);
417 dx30 = _mm_sub_pd(ix3,jx0);
418 dy30 = _mm_sub_pd(iy3,jy0);
419 dz30 = _mm_sub_pd(iz3,jz0);
421 /* Calculate squared distance and things based on it */
422 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
423 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
424 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
425 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
427 rinv00 = gmx_mm_invsqrt_pd(rsq00);
428 rinv10 = gmx_mm_invsqrt_pd(rsq10);
429 rinv20 = gmx_mm_invsqrt_pd(rsq20);
430 rinv30 = gmx_mm_invsqrt_pd(rsq30);
432 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
433 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
434 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
435 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
437 /* Load parameters for j particles */
438 jq0 = _mm_load_sd(charge+jnrA+0);
439 vdwjidx0A = 2*vdwtype[jnrA+0];
441 fjx0 = _mm_setzero_pd();
442 fjy0 = _mm_setzero_pd();
443 fjz0 = _mm_setzero_pd();
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
449 if (gmx_mm_any_lt(rsq00,rcutoff2))
452 r00 = _mm_mul_pd(rsq00,rinv00);
454 /* Compute parameters for interactions between i and j atoms */
455 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
457 /* LENNARD-JONES DISPERSION/REPULSION */
459 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
460 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
461 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
462 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
463 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
465 d = _mm_sub_pd(r00,rswitch);
466 d = _mm_max_pd(d,_mm_setzero_pd());
467 d2 = _mm_mul_pd(d,d);
468 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
470 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
472 /* Evaluate switch function */
473 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
474 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
475 vvdw = _mm_mul_pd(vvdw,sw);
476 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
478 /* Update potential sum for this i atom from the interaction with this j atom. */
479 vvdw = _mm_and_pd(vvdw,cutoff_mask);
480 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
481 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
485 fscal = _mm_and_pd(fscal,cutoff_mask);
487 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
489 /* Update vectorial force */
490 fix0 = _mm_macc_pd(dx00,fscal,fix0);
491 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
492 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
494 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
495 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
496 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
504 if (gmx_mm_any_lt(rsq10,rcutoff2))
507 /* Compute parameters for interactions between i and j atoms */
508 qq10 = _mm_mul_pd(iq1,jq0);
510 /* REACTION-FIELD ELECTROSTATICS */
511 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_macc_pd(krf,rsq10,rinv10),crf));
512 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
514 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
516 /* Update potential sum for this i atom from the interaction with this j atom. */
517 velec = _mm_and_pd(velec,cutoff_mask);
518 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
519 velecsum = _mm_add_pd(velecsum,velec);
523 fscal = _mm_and_pd(fscal,cutoff_mask);
525 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
527 /* Update vectorial force */
528 fix1 = _mm_macc_pd(dx10,fscal,fix1);
529 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
530 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
532 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
533 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
534 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
538 /**************************
539 * CALCULATE INTERACTIONS *
540 **************************/
542 if (gmx_mm_any_lt(rsq20,rcutoff2))
545 /* Compute parameters for interactions between i and j atoms */
546 qq20 = _mm_mul_pd(iq2,jq0);
548 /* REACTION-FIELD ELECTROSTATICS */
549 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_macc_pd(krf,rsq20,rinv20),crf));
550 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
552 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
554 /* Update potential sum for this i atom from the interaction with this j atom. */
555 velec = _mm_and_pd(velec,cutoff_mask);
556 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
557 velecsum = _mm_add_pd(velecsum,velec);
561 fscal = _mm_and_pd(fscal,cutoff_mask);
563 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
565 /* Update vectorial force */
566 fix2 = _mm_macc_pd(dx20,fscal,fix2);
567 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
568 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
570 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
571 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
572 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
580 if (gmx_mm_any_lt(rsq30,rcutoff2))
583 /* Compute parameters for interactions between i and j atoms */
584 qq30 = _mm_mul_pd(iq3,jq0);
586 /* REACTION-FIELD ELECTROSTATICS */
587 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_macc_pd(krf,rsq30,rinv30),crf));
588 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
590 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
592 /* Update potential sum for this i atom from the interaction with this j atom. */
593 velec = _mm_and_pd(velec,cutoff_mask);
594 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
595 velecsum = _mm_add_pd(velecsum,velec);
599 fscal = _mm_and_pd(fscal,cutoff_mask);
601 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
603 /* Update vectorial force */
604 fix3 = _mm_macc_pd(dx30,fscal,fix3);
605 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
606 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
608 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
609 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
610 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
614 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
616 /* Inner loop uses 182 flops */
619 /* End of innermost loop */
621 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
622 f+i_coord_offset,fshift+i_shift_offset);
625 /* Update potential energies */
626 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
627 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
629 /* Increment number of inner iterations */
630 inneriter += j_index_end - j_index_start;
632 /* Outer loop uses 26 flops */
635 /* Increment number of outer iterations */
638 /* Update outer/inner flops */
640 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*182);
643 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
644 * Electrostatics interaction: ReactionField
645 * VdW interaction: LennardJones
646 * Geometry: Water4-Particle
647 * Calculate force/pot: Force
650 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_avx_128_fma_double
651 (t_nblist * gmx_restrict nlist,
652 rvec * gmx_restrict xx,
653 rvec * gmx_restrict ff,
654 t_forcerec * gmx_restrict fr,
655 t_mdatoms * gmx_restrict mdatoms,
656 nb_kernel_data_t * gmx_restrict kernel_data,
657 t_nrnb * gmx_restrict nrnb)
659 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
660 * just 0 for non-waters.
661 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
662 * jnr indices corresponding to data put in the four positions in the SIMD register.
664 int i_shift_offset,i_coord_offset,outeriter,inneriter;
665 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
667 int j_coord_offsetA,j_coord_offsetB;
668 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
670 real *shiftvec,*fshift,*x,*f;
671 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
673 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
675 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
677 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
679 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
680 int vdwjidx0A,vdwjidx0B;
681 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
682 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
683 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
684 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
685 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
686 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
689 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
692 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
693 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
694 __m128d rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
695 real rswitch_scalar,d_scalar;
696 __m128d dummy_mask,cutoff_mask;
697 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
698 __m128d one = _mm_set1_pd(1.0);
699 __m128d two = _mm_set1_pd(2.0);
705 jindex = nlist->jindex;
707 shiftidx = nlist->shift;
709 shiftvec = fr->shift_vec[0];
710 fshift = fr->fshift[0];
711 facel = _mm_set1_pd(fr->epsfac);
712 charge = mdatoms->chargeA;
713 krf = _mm_set1_pd(fr->ic->k_rf);
714 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
715 crf = _mm_set1_pd(fr->ic->c_rf);
716 nvdwtype = fr->ntype;
718 vdwtype = mdatoms->typeA;
720 /* Setup water-specific parameters */
721 inr = nlist->iinr[0];
722 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
723 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
724 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
725 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
727 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
728 rcutoff_scalar = fr->rcoulomb;
729 rcutoff = _mm_set1_pd(rcutoff_scalar);
730 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
732 rswitch_scalar = fr->rvdw_switch;
733 rswitch = _mm_set1_pd(rswitch_scalar);
734 /* Setup switch parameters */
735 d_scalar = rcutoff_scalar-rswitch_scalar;
736 d = _mm_set1_pd(d_scalar);
737 swV3 = _mm_set1_pd(-10.0/(d_scalar*d_scalar*d_scalar));
738 swV4 = _mm_set1_pd( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
739 swV5 = _mm_set1_pd( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
740 swF2 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar));
741 swF3 = _mm_set1_pd( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
742 swF4 = _mm_set1_pd(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
744 /* Avoid stupid compiler warnings */
752 /* Start outer loop over neighborlists */
753 for(iidx=0; iidx<nri; iidx++)
755 /* Load shift vector for this list */
756 i_shift_offset = DIM*shiftidx[iidx];
758 /* Load limits for loop over neighbors */
759 j_index_start = jindex[iidx];
760 j_index_end = jindex[iidx+1];
762 /* Get outer coordinate index */
764 i_coord_offset = DIM*inr;
766 /* Load i particle coords and add shift vector */
767 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
768 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
770 fix0 = _mm_setzero_pd();
771 fiy0 = _mm_setzero_pd();
772 fiz0 = _mm_setzero_pd();
773 fix1 = _mm_setzero_pd();
774 fiy1 = _mm_setzero_pd();
775 fiz1 = _mm_setzero_pd();
776 fix2 = _mm_setzero_pd();
777 fiy2 = _mm_setzero_pd();
778 fiz2 = _mm_setzero_pd();
779 fix3 = _mm_setzero_pd();
780 fiy3 = _mm_setzero_pd();
781 fiz3 = _mm_setzero_pd();
783 /* Start inner kernel loop */
784 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
787 /* Get j neighbor index, and coordinate index */
790 j_coord_offsetA = DIM*jnrA;
791 j_coord_offsetB = DIM*jnrB;
793 /* load j atom coordinates */
794 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
797 /* Calculate displacement vector */
798 dx00 = _mm_sub_pd(ix0,jx0);
799 dy00 = _mm_sub_pd(iy0,jy0);
800 dz00 = _mm_sub_pd(iz0,jz0);
801 dx10 = _mm_sub_pd(ix1,jx0);
802 dy10 = _mm_sub_pd(iy1,jy0);
803 dz10 = _mm_sub_pd(iz1,jz0);
804 dx20 = _mm_sub_pd(ix2,jx0);
805 dy20 = _mm_sub_pd(iy2,jy0);
806 dz20 = _mm_sub_pd(iz2,jz0);
807 dx30 = _mm_sub_pd(ix3,jx0);
808 dy30 = _mm_sub_pd(iy3,jy0);
809 dz30 = _mm_sub_pd(iz3,jz0);
811 /* Calculate squared distance and things based on it */
812 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
813 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
814 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
815 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
817 rinv00 = gmx_mm_invsqrt_pd(rsq00);
818 rinv10 = gmx_mm_invsqrt_pd(rsq10);
819 rinv20 = gmx_mm_invsqrt_pd(rsq20);
820 rinv30 = gmx_mm_invsqrt_pd(rsq30);
822 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
823 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
824 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
825 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
827 /* Load parameters for j particles */
828 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
829 vdwjidx0A = 2*vdwtype[jnrA+0];
830 vdwjidx0B = 2*vdwtype[jnrB+0];
832 fjx0 = _mm_setzero_pd();
833 fjy0 = _mm_setzero_pd();
834 fjz0 = _mm_setzero_pd();
836 /**************************
837 * CALCULATE INTERACTIONS *
838 **************************/
840 if (gmx_mm_any_lt(rsq00,rcutoff2))
843 r00 = _mm_mul_pd(rsq00,rinv00);
845 /* Compute parameters for interactions between i and j atoms */
846 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
847 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
849 /* LENNARD-JONES DISPERSION/REPULSION */
851 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
852 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
853 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
854 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
855 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
857 d = _mm_sub_pd(r00,rswitch);
858 d = _mm_max_pd(d,_mm_setzero_pd());
859 d2 = _mm_mul_pd(d,d);
860 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
862 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
864 /* Evaluate switch function */
865 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
866 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
867 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
871 fscal = _mm_and_pd(fscal,cutoff_mask);
873 /* Update vectorial force */
874 fix0 = _mm_macc_pd(dx00,fscal,fix0);
875 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
876 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
878 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
879 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
880 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 if (gmx_mm_any_lt(rsq10,rcutoff2))
891 /* Compute parameters for interactions between i and j atoms */
892 qq10 = _mm_mul_pd(iq1,jq0);
894 /* REACTION-FIELD ELECTROSTATICS */
895 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
897 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
901 fscal = _mm_and_pd(fscal,cutoff_mask);
903 /* Update vectorial force */
904 fix1 = _mm_macc_pd(dx10,fscal,fix1);
905 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
906 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
908 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
909 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
910 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
918 if (gmx_mm_any_lt(rsq20,rcutoff2))
921 /* Compute parameters for interactions between i and j atoms */
922 qq20 = _mm_mul_pd(iq2,jq0);
924 /* REACTION-FIELD ELECTROSTATICS */
925 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
927 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
931 fscal = _mm_and_pd(fscal,cutoff_mask);
933 /* Update vectorial force */
934 fix2 = _mm_macc_pd(dx20,fscal,fix2);
935 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
936 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
938 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
939 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
940 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
948 if (gmx_mm_any_lt(rsq30,rcutoff2))
951 /* Compute parameters for interactions between i and j atoms */
952 qq30 = _mm_mul_pd(iq3,jq0);
954 /* REACTION-FIELD ELECTROSTATICS */
955 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
957 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
961 fscal = _mm_and_pd(fscal,cutoff_mask);
963 /* Update vectorial force */
964 fix3 = _mm_macc_pd(dx30,fscal,fix3);
965 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
966 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
968 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
969 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
970 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
974 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
976 /* Inner loop uses 161 flops */
983 j_coord_offsetA = DIM*jnrA;
985 /* load j atom coordinates */
986 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
989 /* Calculate displacement vector */
990 dx00 = _mm_sub_pd(ix0,jx0);
991 dy00 = _mm_sub_pd(iy0,jy0);
992 dz00 = _mm_sub_pd(iz0,jz0);
993 dx10 = _mm_sub_pd(ix1,jx0);
994 dy10 = _mm_sub_pd(iy1,jy0);
995 dz10 = _mm_sub_pd(iz1,jz0);
996 dx20 = _mm_sub_pd(ix2,jx0);
997 dy20 = _mm_sub_pd(iy2,jy0);
998 dz20 = _mm_sub_pd(iz2,jz0);
999 dx30 = _mm_sub_pd(ix3,jx0);
1000 dy30 = _mm_sub_pd(iy3,jy0);
1001 dz30 = _mm_sub_pd(iz3,jz0);
1003 /* Calculate squared distance and things based on it */
1004 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1005 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
1006 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
1007 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
1009 rinv00 = gmx_mm_invsqrt_pd(rsq00);
1010 rinv10 = gmx_mm_invsqrt_pd(rsq10);
1011 rinv20 = gmx_mm_invsqrt_pd(rsq20);
1012 rinv30 = gmx_mm_invsqrt_pd(rsq30);
1014 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
1015 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
1016 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
1017 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
1019 /* Load parameters for j particles */
1020 jq0 = _mm_load_sd(charge+jnrA+0);
1021 vdwjidx0A = 2*vdwtype[jnrA+0];
1023 fjx0 = _mm_setzero_pd();
1024 fjy0 = _mm_setzero_pd();
1025 fjz0 = _mm_setzero_pd();
1027 /**************************
1028 * CALCULATE INTERACTIONS *
1029 **************************/
1031 if (gmx_mm_any_lt(rsq00,rcutoff2))
1034 r00 = _mm_mul_pd(rsq00,rinv00);
1036 /* Compute parameters for interactions between i and j atoms */
1037 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1039 /* LENNARD-JONES DISPERSION/REPULSION */
1041 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
1042 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
1043 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
1044 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
1045 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
1047 d = _mm_sub_pd(r00,rswitch);
1048 d = _mm_max_pd(d,_mm_setzero_pd());
1049 d2 = _mm_mul_pd(d,d);
1050 sw = _mm_add_pd(one,_mm_mul_pd(d2,_mm_mul_pd(d,_mm_macc_pd(d,_mm_macc_pd(d,swV5,swV4),swV3))));
1052 dsw = _mm_mul_pd(d2,_mm_macc_pd(d,_mm_macc_pd(d,swF4,swF3),swF2));
1054 /* Evaluate switch function */
1055 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1056 fvdw = _mm_msub_pd( fvdw,sw , _mm_mul_pd(rinv00,_mm_mul_pd(vvdw,dsw)) );
1057 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
1061 fscal = _mm_and_pd(fscal,cutoff_mask);
1063 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1065 /* Update vectorial force */
1066 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1067 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1068 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1070 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1071 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1072 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1076 /**************************
1077 * CALCULATE INTERACTIONS *
1078 **************************/
1080 if (gmx_mm_any_lt(rsq10,rcutoff2))
1083 /* Compute parameters for interactions between i and j atoms */
1084 qq10 = _mm_mul_pd(iq1,jq0);
1086 /* REACTION-FIELD ELECTROSTATICS */
1087 felec = _mm_mul_pd(qq10,_mm_msub_pd(rinv10,rinvsq10,krf2));
1089 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
1093 fscal = _mm_and_pd(fscal,cutoff_mask);
1095 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1097 /* Update vectorial force */
1098 fix1 = _mm_macc_pd(dx10,fscal,fix1);
1099 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
1100 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
1102 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
1103 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
1104 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
1108 /**************************
1109 * CALCULATE INTERACTIONS *
1110 **************************/
1112 if (gmx_mm_any_lt(rsq20,rcutoff2))
1115 /* Compute parameters for interactions between i and j atoms */
1116 qq20 = _mm_mul_pd(iq2,jq0);
1118 /* REACTION-FIELD ELECTROSTATICS */
1119 felec = _mm_mul_pd(qq20,_mm_msub_pd(rinv20,rinvsq20,krf2));
1121 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
1125 fscal = _mm_and_pd(fscal,cutoff_mask);
1127 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1129 /* Update vectorial force */
1130 fix2 = _mm_macc_pd(dx20,fscal,fix2);
1131 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
1132 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
1134 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
1135 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
1136 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
1140 /**************************
1141 * CALCULATE INTERACTIONS *
1142 **************************/
1144 if (gmx_mm_any_lt(rsq30,rcutoff2))
1147 /* Compute parameters for interactions between i and j atoms */
1148 qq30 = _mm_mul_pd(iq3,jq0);
1150 /* REACTION-FIELD ELECTROSTATICS */
1151 felec = _mm_mul_pd(qq30,_mm_msub_pd(rinv30,rinvsq30,krf2));
1153 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
1157 fscal = _mm_and_pd(fscal,cutoff_mask);
1159 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1161 /* Update vectorial force */
1162 fix3 = _mm_macc_pd(dx30,fscal,fix3);
1163 fiy3 = _mm_macc_pd(dy30,fscal,fiy3);
1164 fiz3 = _mm_macc_pd(dz30,fscal,fiz3);
1166 fjx0 = _mm_macc_pd(dx30,fscal,fjx0);
1167 fjy0 = _mm_macc_pd(dy30,fscal,fjy0);
1168 fjz0 = _mm_macc_pd(dz30,fscal,fjz0);
1172 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1174 /* Inner loop uses 161 flops */
1177 /* End of innermost loop */
1179 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1180 f+i_coord_offset,fshift+i_shift_offset);
1182 /* Increment number of inner iterations */
1183 inneriter += j_index_end - j_index_start;
1185 /* Outer loop uses 24 flops */
1188 /* Increment number of outer iterations */
1191 /* Update outer/inner flops */
1193 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*161);