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_ElecRF_VdwLJ_GeomW4W4_VF_avx_128_fma_double
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: LennardJones
56 * Geometry: Water4-Water4
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRF_VdwLJ_GeomW4W4_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 int vdwjidx1A,vdwjidx1B;
93 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
94 int vdwjidx2A,vdwjidx2B;
95 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
96 int vdwjidx3A,vdwjidx3B;
97 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
98 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
99 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
100 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
101 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
102 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
103 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
104 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
105 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
106 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
107 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
108 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
111 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
114 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
115 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
116 __m128d dummy_mask,cutoff_mask;
117 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
118 __m128d one = _mm_set1_pd(1.0);
119 __m128d two = _mm_set1_pd(2.0);
125 jindex = nlist->jindex;
127 shiftidx = nlist->shift;
129 shiftvec = fr->shift_vec[0];
130 fshift = fr->fshift[0];
131 facel = _mm_set1_pd(fr->epsfac);
132 charge = mdatoms->chargeA;
133 krf = _mm_set1_pd(fr->ic->k_rf);
134 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
135 crf = _mm_set1_pd(fr->ic->c_rf);
136 nvdwtype = fr->ntype;
138 vdwtype = mdatoms->typeA;
140 /* Setup water-specific parameters */
141 inr = nlist->iinr[0];
142 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
143 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
144 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
145 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
147 jq1 = _mm_set1_pd(charge[inr+1]);
148 jq2 = _mm_set1_pd(charge[inr+2]);
149 jq3 = _mm_set1_pd(charge[inr+3]);
150 vdwjidx0A = 2*vdwtype[inr+0];
151 c6_00 = _mm_set1_pd(vdwparam[vdwioffset0+vdwjidx0A]);
152 c12_00 = _mm_set1_pd(vdwparam[vdwioffset0+vdwjidx0A+1]);
153 qq11 = _mm_mul_pd(iq1,jq1);
154 qq12 = _mm_mul_pd(iq1,jq2);
155 qq13 = _mm_mul_pd(iq1,jq3);
156 qq21 = _mm_mul_pd(iq2,jq1);
157 qq22 = _mm_mul_pd(iq2,jq2);
158 qq23 = _mm_mul_pd(iq2,jq3);
159 qq31 = _mm_mul_pd(iq3,jq1);
160 qq32 = _mm_mul_pd(iq3,jq2);
161 qq33 = _mm_mul_pd(iq3,jq3);
163 /* Avoid stupid compiler warnings */
171 /* Start outer loop over neighborlists */
172 for(iidx=0; iidx<nri; iidx++)
174 /* Load shift vector for this list */
175 i_shift_offset = DIM*shiftidx[iidx];
177 /* Load limits for loop over neighbors */
178 j_index_start = jindex[iidx];
179 j_index_end = jindex[iidx+1];
181 /* Get outer coordinate index */
183 i_coord_offset = DIM*inr;
185 /* Load i particle coords and add shift vector */
186 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
187 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
189 fix0 = _mm_setzero_pd();
190 fiy0 = _mm_setzero_pd();
191 fiz0 = _mm_setzero_pd();
192 fix1 = _mm_setzero_pd();
193 fiy1 = _mm_setzero_pd();
194 fiz1 = _mm_setzero_pd();
195 fix2 = _mm_setzero_pd();
196 fiy2 = _mm_setzero_pd();
197 fiz2 = _mm_setzero_pd();
198 fix3 = _mm_setzero_pd();
199 fiy3 = _mm_setzero_pd();
200 fiz3 = _mm_setzero_pd();
202 /* Reset potential sums */
203 velecsum = _mm_setzero_pd();
204 vvdwsum = _mm_setzero_pd();
206 /* Start inner kernel loop */
207 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
210 /* Get j neighbor index, and coordinate index */
213 j_coord_offsetA = DIM*jnrA;
214 j_coord_offsetB = DIM*jnrB;
216 /* load j atom coordinates */
217 gmx_mm_load_4rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
218 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
219 &jy2,&jz2,&jx3,&jy3,&jz3);
221 /* Calculate displacement vector */
222 dx00 = _mm_sub_pd(ix0,jx0);
223 dy00 = _mm_sub_pd(iy0,jy0);
224 dz00 = _mm_sub_pd(iz0,jz0);
225 dx11 = _mm_sub_pd(ix1,jx1);
226 dy11 = _mm_sub_pd(iy1,jy1);
227 dz11 = _mm_sub_pd(iz1,jz1);
228 dx12 = _mm_sub_pd(ix1,jx2);
229 dy12 = _mm_sub_pd(iy1,jy2);
230 dz12 = _mm_sub_pd(iz1,jz2);
231 dx13 = _mm_sub_pd(ix1,jx3);
232 dy13 = _mm_sub_pd(iy1,jy3);
233 dz13 = _mm_sub_pd(iz1,jz3);
234 dx21 = _mm_sub_pd(ix2,jx1);
235 dy21 = _mm_sub_pd(iy2,jy1);
236 dz21 = _mm_sub_pd(iz2,jz1);
237 dx22 = _mm_sub_pd(ix2,jx2);
238 dy22 = _mm_sub_pd(iy2,jy2);
239 dz22 = _mm_sub_pd(iz2,jz2);
240 dx23 = _mm_sub_pd(ix2,jx3);
241 dy23 = _mm_sub_pd(iy2,jy3);
242 dz23 = _mm_sub_pd(iz2,jz3);
243 dx31 = _mm_sub_pd(ix3,jx1);
244 dy31 = _mm_sub_pd(iy3,jy1);
245 dz31 = _mm_sub_pd(iz3,jz1);
246 dx32 = _mm_sub_pd(ix3,jx2);
247 dy32 = _mm_sub_pd(iy3,jy2);
248 dz32 = _mm_sub_pd(iz3,jz2);
249 dx33 = _mm_sub_pd(ix3,jx3);
250 dy33 = _mm_sub_pd(iy3,jy3);
251 dz33 = _mm_sub_pd(iz3,jz3);
253 /* Calculate squared distance and things based on it */
254 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
255 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
256 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
257 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
258 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
259 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
260 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
261 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
262 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
263 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
265 rinv11 = gmx_mm_invsqrt_pd(rsq11);
266 rinv12 = gmx_mm_invsqrt_pd(rsq12);
267 rinv13 = gmx_mm_invsqrt_pd(rsq13);
268 rinv21 = gmx_mm_invsqrt_pd(rsq21);
269 rinv22 = gmx_mm_invsqrt_pd(rsq22);
270 rinv23 = gmx_mm_invsqrt_pd(rsq23);
271 rinv31 = gmx_mm_invsqrt_pd(rsq31);
272 rinv32 = gmx_mm_invsqrt_pd(rsq32);
273 rinv33 = gmx_mm_invsqrt_pd(rsq33);
275 rinvsq00 = gmx_mm_inv_pd(rsq00);
276 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
277 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
278 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
279 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
280 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
281 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
282 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
283 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
284 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
286 fjx0 = _mm_setzero_pd();
287 fjy0 = _mm_setzero_pd();
288 fjz0 = _mm_setzero_pd();
289 fjx1 = _mm_setzero_pd();
290 fjy1 = _mm_setzero_pd();
291 fjz1 = _mm_setzero_pd();
292 fjx2 = _mm_setzero_pd();
293 fjy2 = _mm_setzero_pd();
294 fjz2 = _mm_setzero_pd();
295 fjx3 = _mm_setzero_pd();
296 fjy3 = _mm_setzero_pd();
297 fjz3 = _mm_setzero_pd();
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
303 /* LENNARD-JONES DISPERSION/REPULSION */
305 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
306 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
307 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
308 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
309 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
311 /* Update potential sum for this i atom from the interaction with this j atom. */
312 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
316 /* Update vectorial force */
317 fix0 = _mm_macc_pd(dx00,fscal,fix0);
318 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
319 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
321 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
322 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
323 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* REACTION-FIELD ELECTROSTATICS */
330 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
331 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
333 /* Update potential sum for this i atom from the interaction with this j atom. */
334 velecsum = _mm_add_pd(velecsum,velec);
338 /* Update vectorial force */
339 fix1 = _mm_macc_pd(dx11,fscal,fix1);
340 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
341 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
343 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
344 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
345 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
351 /* REACTION-FIELD ELECTROSTATICS */
352 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
353 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velecsum = _mm_add_pd(velecsum,velec);
360 /* Update vectorial force */
361 fix1 = _mm_macc_pd(dx12,fscal,fix1);
362 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
363 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
365 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
366 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
367 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
373 /* REACTION-FIELD ELECTROSTATICS */
374 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
375 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
377 /* Update potential sum for this i atom from the interaction with this j atom. */
378 velecsum = _mm_add_pd(velecsum,velec);
382 /* Update vectorial force */
383 fix1 = _mm_macc_pd(dx13,fscal,fix1);
384 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
385 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
387 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
388 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
389 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
395 /* REACTION-FIELD ELECTROSTATICS */
396 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
397 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
399 /* Update potential sum for this i atom from the interaction with this j atom. */
400 velecsum = _mm_add_pd(velecsum,velec);
404 /* Update vectorial force */
405 fix2 = _mm_macc_pd(dx21,fscal,fix2);
406 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
407 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
409 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
410 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
411 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
413 /**************************
414 * CALCULATE INTERACTIONS *
415 **************************/
417 /* REACTION-FIELD ELECTROSTATICS */
418 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
419 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
421 /* Update potential sum for this i atom from the interaction with this j atom. */
422 velecsum = _mm_add_pd(velecsum,velec);
426 /* Update vectorial force */
427 fix2 = _mm_macc_pd(dx22,fscal,fix2);
428 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
429 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
431 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
432 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
433 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
435 /**************************
436 * CALCULATE INTERACTIONS *
437 **************************/
439 /* REACTION-FIELD ELECTROSTATICS */
440 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
441 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
443 /* Update potential sum for this i atom from the interaction with this j atom. */
444 velecsum = _mm_add_pd(velecsum,velec);
448 /* Update vectorial force */
449 fix2 = _mm_macc_pd(dx23,fscal,fix2);
450 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
451 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
453 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
454 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
455 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 /* REACTION-FIELD ELECTROSTATICS */
462 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
463 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
465 /* Update potential sum for this i atom from the interaction with this j atom. */
466 velecsum = _mm_add_pd(velecsum,velec);
470 /* Update vectorial force */
471 fix3 = _mm_macc_pd(dx31,fscal,fix3);
472 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
473 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
475 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
476 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
477 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
483 /* REACTION-FIELD ELECTROSTATICS */
484 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
485 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
487 /* Update potential sum for this i atom from the interaction with this j atom. */
488 velecsum = _mm_add_pd(velecsum,velec);
492 /* Update vectorial force */
493 fix3 = _mm_macc_pd(dx32,fscal,fix3);
494 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
495 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
497 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
498 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
499 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
501 /**************************
502 * CALCULATE INTERACTIONS *
503 **************************/
505 /* REACTION-FIELD ELECTROSTATICS */
506 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
507 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
509 /* Update potential sum for this i atom from the interaction with this j atom. */
510 velecsum = _mm_add_pd(velecsum,velec);
514 /* Update vectorial force */
515 fix3 = _mm_macc_pd(dx33,fscal,fix3);
516 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
517 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
519 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
520 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
521 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
523 gmx_mm_decrement_4rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
525 /* Inner loop uses 353 flops */
532 j_coord_offsetA = DIM*jnrA;
534 /* load j atom coordinates */
535 gmx_mm_load_4rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
536 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
537 &jy2,&jz2,&jx3,&jy3,&jz3);
539 /* Calculate displacement vector */
540 dx00 = _mm_sub_pd(ix0,jx0);
541 dy00 = _mm_sub_pd(iy0,jy0);
542 dz00 = _mm_sub_pd(iz0,jz0);
543 dx11 = _mm_sub_pd(ix1,jx1);
544 dy11 = _mm_sub_pd(iy1,jy1);
545 dz11 = _mm_sub_pd(iz1,jz1);
546 dx12 = _mm_sub_pd(ix1,jx2);
547 dy12 = _mm_sub_pd(iy1,jy2);
548 dz12 = _mm_sub_pd(iz1,jz2);
549 dx13 = _mm_sub_pd(ix1,jx3);
550 dy13 = _mm_sub_pd(iy1,jy3);
551 dz13 = _mm_sub_pd(iz1,jz3);
552 dx21 = _mm_sub_pd(ix2,jx1);
553 dy21 = _mm_sub_pd(iy2,jy1);
554 dz21 = _mm_sub_pd(iz2,jz1);
555 dx22 = _mm_sub_pd(ix2,jx2);
556 dy22 = _mm_sub_pd(iy2,jy2);
557 dz22 = _mm_sub_pd(iz2,jz2);
558 dx23 = _mm_sub_pd(ix2,jx3);
559 dy23 = _mm_sub_pd(iy2,jy3);
560 dz23 = _mm_sub_pd(iz2,jz3);
561 dx31 = _mm_sub_pd(ix3,jx1);
562 dy31 = _mm_sub_pd(iy3,jy1);
563 dz31 = _mm_sub_pd(iz3,jz1);
564 dx32 = _mm_sub_pd(ix3,jx2);
565 dy32 = _mm_sub_pd(iy3,jy2);
566 dz32 = _mm_sub_pd(iz3,jz2);
567 dx33 = _mm_sub_pd(ix3,jx3);
568 dy33 = _mm_sub_pd(iy3,jy3);
569 dz33 = _mm_sub_pd(iz3,jz3);
571 /* Calculate squared distance and things based on it */
572 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
573 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
574 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
575 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
576 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
577 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
578 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
579 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
580 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
581 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
583 rinv11 = gmx_mm_invsqrt_pd(rsq11);
584 rinv12 = gmx_mm_invsqrt_pd(rsq12);
585 rinv13 = gmx_mm_invsqrt_pd(rsq13);
586 rinv21 = gmx_mm_invsqrt_pd(rsq21);
587 rinv22 = gmx_mm_invsqrt_pd(rsq22);
588 rinv23 = gmx_mm_invsqrt_pd(rsq23);
589 rinv31 = gmx_mm_invsqrt_pd(rsq31);
590 rinv32 = gmx_mm_invsqrt_pd(rsq32);
591 rinv33 = gmx_mm_invsqrt_pd(rsq33);
593 rinvsq00 = gmx_mm_inv_pd(rsq00);
594 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
595 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
596 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
597 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
598 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
599 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
600 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
601 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
602 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
604 fjx0 = _mm_setzero_pd();
605 fjy0 = _mm_setzero_pd();
606 fjz0 = _mm_setzero_pd();
607 fjx1 = _mm_setzero_pd();
608 fjy1 = _mm_setzero_pd();
609 fjz1 = _mm_setzero_pd();
610 fjx2 = _mm_setzero_pd();
611 fjy2 = _mm_setzero_pd();
612 fjz2 = _mm_setzero_pd();
613 fjx3 = _mm_setzero_pd();
614 fjy3 = _mm_setzero_pd();
615 fjz3 = _mm_setzero_pd();
617 /**************************
618 * CALCULATE INTERACTIONS *
619 **************************/
621 /* LENNARD-JONES DISPERSION/REPULSION */
623 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
624 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
625 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
626 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
627 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
629 /* Update potential sum for this i atom from the interaction with this j atom. */
630 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
631 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
635 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
637 /* Update vectorial force */
638 fix0 = _mm_macc_pd(dx00,fscal,fix0);
639 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
640 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
642 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
643 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
644 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
646 /**************************
647 * CALCULATE INTERACTIONS *
648 **************************/
650 /* REACTION-FIELD ELECTROSTATICS */
651 velec = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
652 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
654 /* Update potential sum for this i atom from the interaction with this j atom. */
655 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
656 velecsum = _mm_add_pd(velecsum,velec);
660 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
662 /* Update vectorial force */
663 fix1 = _mm_macc_pd(dx11,fscal,fix1);
664 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
665 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
667 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
668 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
669 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
671 /**************************
672 * CALCULATE INTERACTIONS *
673 **************************/
675 /* REACTION-FIELD ELECTROSTATICS */
676 velec = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
677 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
679 /* Update potential sum for this i atom from the interaction with this j atom. */
680 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
681 velecsum = _mm_add_pd(velecsum,velec);
685 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
687 /* Update vectorial force */
688 fix1 = _mm_macc_pd(dx12,fscal,fix1);
689 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
690 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
692 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
693 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
694 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
696 /**************************
697 * CALCULATE INTERACTIONS *
698 **************************/
700 /* REACTION-FIELD ELECTROSTATICS */
701 velec = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
702 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
704 /* Update potential sum for this i atom from the interaction with this j atom. */
705 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
706 velecsum = _mm_add_pd(velecsum,velec);
710 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
712 /* Update vectorial force */
713 fix1 = _mm_macc_pd(dx13,fscal,fix1);
714 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
715 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
717 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
718 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
719 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
721 /**************************
722 * CALCULATE INTERACTIONS *
723 **************************/
725 /* REACTION-FIELD ELECTROSTATICS */
726 velec = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
727 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
729 /* Update potential sum for this i atom from the interaction with this j atom. */
730 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
731 velecsum = _mm_add_pd(velecsum,velec);
735 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
737 /* Update vectorial force */
738 fix2 = _mm_macc_pd(dx21,fscal,fix2);
739 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
740 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
742 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
743 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
744 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
746 /**************************
747 * CALCULATE INTERACTIONS *
748 **************************/
750 /* REACTION-FIELD ELECTROSTATICS */
751 velec = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
752 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
754 /* Update potential sum for this i atom from the interaction with this j atom. */
755 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
756 velecsum = _mm_add_pd(velecsum,velec);
760 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
762 /* Update vectorial force */
763 fix2 = _mm_macc_pd(dx22,fscal,fix2);
764 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
765 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
767 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
768 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
769 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
771 /**************************
772 * CALCULATE INTERACTIONS *
773 **************************/
775 /* REACTION-FIELD ELECTROSTATICS */
776 velec = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
777 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
779 /* Update potential sum for this i atom from the interaction with this j atom. */
780 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
781 velecsum = _mm_add_pd(velecsum,velec);
785 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
787 /* Update vectorial force */
788 fix2 = _mm_macc_pd(dx23,fscal,fix2);
789 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
790 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
792 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
793 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
794 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
796 /**************************
797 * CALCULATE INTERACTIONS *
798 **************************/
800 /* REACTION-FIELD ELECTROSTATICS */
801 velec = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
802 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
804 /* Update potential sum for this i atom from the interaction with this j atom. */
805 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
806 velecsum = _mm_add_pd(velecsum,velec);
810 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
812 /* Update vectorial force */
813 fix3 = _mm_macc_pd(dx31,fscal,fix3);
814 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
815 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
817 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
818 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
819 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
821 /**************************
822 * CALCULATE INTERACTIONS *
823 **************************/
825 /* REACTION-FIELD ELECTROSTATICS */
826 velec = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
827 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
829 /* Update potential sum for this i atom from the interaction with this j atom. */
830 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
831 velecsum = _mm_add_pd(velecsum,velec);
835 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
837 /* Update vectorial force */
838 fix3 = _mm_macc_pd(dx32,fscal,fix3);
839 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
840 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
842 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
843 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
844 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
846 /**************************
847 * CALCULATE INTERACTIONS *
848 **************************/
850 /* REACTION-FIELD ELECTROSTATICS */
851 velec = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
852 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
854 /* Update potential sum for this i atom from the interaction with this j atom. */
855 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
856 velecsum = _mm_add_pd(velecsum,velec);
860 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
862 /* Update vectorial force */
863 fix3 = _mm_macc_pd(dx33,fscal,fix3);
864 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
865 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
867 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
868 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
869 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
871 gmx_mm_decrement_4rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
873 /* Inner loop uses 353 flops */
876 /* End of innermost loop */
878 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
879 f+i_coord_offset,fshift+i_shift_offset);
882 /* Update potential energies */
883 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
884 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
886 /* Increment number of inner iterations */
887 inneriter += j_index_end - j_index_start;
889 /* Outer loop uses 26 flops */
892 /* Increment number of outer iterations */
895 /* Update outer/inner flops */
897 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*353);
900 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_avx_128_fma_double
901 * Electrostatics interaction: ReactionField
902 * VdW interaction: LennardJones
903 * Geometry: Water4-Water4
904 * Calculate force/pot: Force
907 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_avx_128_fma_double
908 (t_nblist * gmx_restrict nlist,
909 rvec * gmx_restrict xx,
910 rvec * gmx_restrict ff,
911 t_forcerec * gmx_restrict fr,
912 t_mdatoms * gmx_restrict mdatoms,
913 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
914 t_nrnb * gmx_restrict nrnb)
916 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
917 * just 0 for non-waters.
918 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
919 * jnr indices corresponding to data put in the four positions in the SIMD register.
921 int i_shift_offset,i_coord_offset,outeriter,inneriter;
922 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
924 int j_coord_offsetA,j_coord_offsetB;
925 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
927 real *shiftvec,*fshift,*x,*f;
928 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
930 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
932 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
934 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
936 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
937 int vdwjidx0A,vdwjidx0B;
938 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
939 int vdwjidx1A,vdwjidx1B;
940 __m128d jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
941 int vdwjidx2A,vdwjidx2B;
942 __m128d jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
943 int vdwjidx3A,vdwjidx3B;
944 __m128d jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
945 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
946 __m128d dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
947 __m128d dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
948 __m128d dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
949 __m128d dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
950 __m128d dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
951 __m128d dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
952 __m128d dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
953 __m128d dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
954 __m128d dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
955 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
958 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
961 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
962 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
963 __m128d dummy_mask,cutoff_mask;
964 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
965 __m128d one = _mm_set1_pd(1.0);
966 __m128d two = _mm_set1_pd(2.0);
972 jindex = nlist->jindex;
974 shiftidx = nlist->shift;
976 shiftvec = fr->shift_vec[0];
977 fshift = fr->fshift[0];
978 facel = _mm_set1_pd(fr->epsfac);
979 charge = mdatoms->chargeA;
980 krf = _mm_set1_pd(fr->ic->k_rf);
981 krf2 = _mm_set1_pd(fr->ic->k_rf*2.0);
982 crf = _mm_set1_pd(fr->ic->c_rf);
983 nvdwtype = fr->ntype;
985 vdwtype = mdatoms->typeA;
987 /* Setup water-specific parameters */
988 inr = nlist->iinr[0];
989 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
990 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
991 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
992 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
994 jq1 = _mm_set1_pd(charge[inr+1]);
995 jq2 = _mm_set1_pd(charge[inr+2]);
996 jq3 = _mm_set1_pd(charge[inr+3]);
997 vdwjidx0A = 2*vdwtype[inr+0];
998 c6_00 = _mm_set1_pd(vdwparam[vdwioffset0+vdwjidx0A]);
999 c12_00 = _mm_set1_pd(vdwparam[vdwioffset0+vdwjidx0A+1]);
1000 qq11 = _mm_mul_pd(iq1,jq1);
1001 qq12 = _mm_mul_pd(iq1,jq2);
1002 qq13 = _mm_mul_pd(iq1,jq3);
1003 qq21 = _mm_mul_pd(iq2,jq1);
1004 qq22 = _mm_mul_pd(iq2,jq2);
1005 qq23 = _mm_mul_pd(iq2,jq3);
1006 qq31 = _mm_mul_pd(iq3,jq1);
1007 qq32 = _mm_mul_pd(iq3,jq2);
1008 qq33 = _mm_mul_pd(iq3,jq3);
1010 /* Avoid stupid compiler warnings */
1012 j_coord_offsetA = 0;
1013 j_coord_offsetB = 0;
1018 /* Start outer loop over neighborlists */
1019 for(iidx=0; iidx<nri; iidx++)
1021 /* Load shift vector for this list */
1022 i_shift_offset = DIM*shiftidx[iidx];
1024 /* Load limits for loop over neighbors */
1025 j_index_start = jindex[iidx];
1026 j_index_end = jindex[iidx+1];
1028 /* Get outer coordinate index */
1030 i_coord_offset = DIM*inr;
1032 /* Load i particle coords and add shift vector */
1033 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
1034 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1036 fix0 = _mm_setzero_pd();
1037 fiy0 = _mm_setzero_pd();
1038 fiz0 = _mm_setzero_pd();
1039 fix1 = _mm_setzero_pd();
1040 fiy1 = _mm_setzero_pd();
1041 fiz1 = _mm_setzero_pd();
1042 fix2 = _mm_setzero_pd();
1043 fiy2 = _mm_setzero_pd();
1044 fiz2 = _mm_setzero_pd();
1045 fix3 = _mm_setzero_pd();
1046 fiy3 = _mm_setzero_pd();
1047 fiz3 = _mm_setzero_pd();
1049 /* Start inner kernel loop */
1050 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1053 /* Get j neighbor index, and coordinate index */
1055 jnrB = jjnr[jidx+1];
1056 j_coord_offsetA = DIM*jnrA;
1057 j_coord_offsetB = DIM*jnrB;
1059 /* load j atom coordinates */
1060 gmx_mm_load_4rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
1061 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1062 &jy2,&jz2,&jx3,&jy3,&jz3);
1064 /* Calculate displacement vector */
1065 dx00 = _mm_sub_pd(ix0,jx0);
1066 dy00 = _mm_sub_pd(iy0,jy0);
1067 dz00 = _mm_sub_pd(iz0,jz0);
1068 dx11 = _mm_sub_pd(ix1,jx1);
1069 dy11 = _mm_sub_pd(iy1,jy1);
1070 dz11 = _mm_sub_pd(iz1,jz1);
1071 dx12 = _mm_sub_pd(ix1,jx2);
1072 dy12 = _mm_sub_pd(iy1,jy2);
1073 dz12 = _mm_sub_pd(iz1,jz2);
1074 dx13 = _mm_sub_pd(ix1,jx3);
1075 dy13 = _mm_sub_pd(iy1,jy3);
1076 dz13 = _mm_sub_pd(iz1,jz3);
1077 dx21 = _mm_sub_pd(ix2,jx1);
1078 dy21 = _mm_sub_pd(iy2,jy1);
1079 dz21 = _mm_sub_pd(iz2,jz1);
1080 dx22 = _mm_sub_pd(ix2,jx2);
1081 dy22 = _mm_sub_pd(iy2,jy2);
1082 dz22 = _mm_sub_pd(iz2,jz2);
1083 dx23 = _mm_sub_pd(ix2,jx3);
1084 dy23 = _mm_sub_pd(iy2,jy3);
1085 dz23 = _mm_sub_pd(iz2,jz3);
1086 dx31 = _mm_sub_pd(ix3,jx1);
1087 dy31 = _mm_sub_pd(iy3,jy1);
1088 dz31 = _mm_sub_pd(iz3,jz1);
1089 dx32 = _mm_sub_pd(ix3,jx2);
1090 dy32 = _mm_sub_pd(iy3,jy2);
1091 dz32 = _mm_sub_pd(iz3,jz2);
1092 dx33 = _mm_sub_pd(ix3,jx3);
1093 dy33 = _mm_sub_pd(iy3,jy3);
1094 dz33 = _mm_sub_pd(iz3,jz3);
1096 /* Calculate squared distance and things based on it */
1097 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1098 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1099 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1100 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1101 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1102 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1103 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1104 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1105 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1106 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1108 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1109 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1110 rinv13 = gmx_mm_invsqrt_pd(rsq13);
1111 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1112 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1113 rinv23 = gmx_mm_invsqrt_pd(rsq23);
1114 rinv31 = gmx_mm_invsqrt_pd(rsq31);
1115 rinv32 = gmx_mm_invsqrt_pd(rsq32);
1116 rinv33 = gmx_mm_invsqrt_pd(rsq33);
1118 rinvsq00 = gmx_mm_inv_pd(rsq00);
1119 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1120 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1121 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
1122 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1123 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1124 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1125 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1126 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1127 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1129 fjx0 = _mm_setzero_pd();
1130 fjy0 = _mm_setzero_pd();
1131 fjz0 = _mm_setzero_pd();
1132 fjx1 = _mm_setzero_pd();
1133 fjy1 = _mm_setzero_pd();
1134 fjz1 = _mm_setzero_pd();
1135 fjx2 = _mm_setzero_pd();
1136 fjy2 = _mm_setzero_pd();
1137 fjz2 = _mm_setzero_pd();
1138 fjx3 = _mm_setzero_pd();
1139 fjy3 = _mm_setzero_pd();
1140 fjz3 = _mm_setzero_pd();
1142 /**************************
1143 * CALCULATE INTERACTIONS *
1144 **************************/
1146 /* LENNARD-JONES DISPERSION/REPULSION */
1148 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
1149 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
1153 /* Update vectorial force */
1154 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1155 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1156 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1158 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1159 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1160 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1162 /**************************
1163 * CALCULATE INTERACTIONS *
1164 **************************/
1166 /* REACTION-FIELD ELECTROSTATICS */
1167 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1171 /* Update vectorial force */
1172 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1173 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1174 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1176 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1177 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1178 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1180 /**************************
1181 * CALCULATE INTERACTIONS *
1182 **************************/
1184 /* REACTION-FIELD ELECTROSTATICS */
1185 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1189 /* Update vectorial force */
1190 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1191 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1192 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1194 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1195 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1196 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1198 /**************************
1199 * CALCULATE INTERACTIONS *
1200 **************************/
1202 /* REACTION-FIELD ELECTROSTATICS */
1203 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1207 /* Update vectorial force */
1208 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1209 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1210 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1212 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1213 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1214 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1216 /**************************
1217 * CALCULATE INTERACTIONS *
1218 **************************/
1220 /* REACTION-FIELD ELECTROSTATICS */
1221 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1225 /* Update vectorial force */
1226 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1227 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1228 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1230 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1231 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1232 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1234 /**************************
1235 * CALCULATE INTERACTIONS *
1236 **************************/
1238 /* REACTION-FIELD ELECTROSTATICS */
1239 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1243 /* Update vectorial force */
1244 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1245 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1246 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1248 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1249 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1250 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1252 /**************************
1253 * CALCULATE INTERACTIONS *
1254 **************************/
1256 /* REACTION-FIELD ELECTROSTATICS */
1257 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1261 /* Update vectorial force */
1262 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1263 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1264 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1266 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1267 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1268 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1270 /**************************
1271 * CALCULATE INTERACTIONS *
1272 **************************/
1274 /* REACTION-FIELD ELECTROSTATICS */
1275 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1279 /* Update vectorial force */
1280 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1281 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1282 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1284 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1285 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1286 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1288 /**************************
1289 * CALCULATE INTERACTIONS *
1290 **************************/
1292 /* REACTION-FIELD ELECTROSTATICS */
1293 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1297 /* Update vectorial force */
1298 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1299 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1300 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1302 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1303 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1304 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1306 /**************************
1307 * CALCULATE INTERACTIONS *
1308 **************************/
1310 /* REACTION-FIELD ELECTROSTATICS */
1311 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1315 /* Update vectorial force */
1316 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1317 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1318 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1320 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1321 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1322 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1324 gmx_mm_decrement_4rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1326 /* Inner loop uses 303 flops */
1329 if(jidx<j_index_end)
1333 j_coord_offsetA = DIM*jnrA;
1335 /* load j atom coordinates */
1336 gmx_mm_load_4rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
1337 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1338 &jy2,&jz2,&jx3,&jy3,&jz3);
1340 /* Calculate displacement vector */
1341 dx00 = _mm_sub_pd(ix0,jx0);
1342 dy00 = _mm_sub_pd(iy0,jy0);
1343 dz00 = _mm_sub_pd(iz0,jz0);
1344 dx11 = _mm_sub_pd(ix1,jx1);
1345 dy11 = _mm_sub_pd(iy1,jy1);
1346 dz11 = _mm_sub_pd(iz1,jz1);
1347 dx12 = _mm_sub_pd(ix1,jx2);
1348 dy12 = _mm_sub_pd(iy1,jy2);
1349 dz12 = _mm_sub_pd(iz1,jz2);
1350 dx13 = _mm_sub_pd(ix1,jx3);
1351 dy13 = _mm_sub_pd(iy1,jy3);
1352 dz13 = _mm_sub_pd(iz1,jz3);
1353 dx21 = _mm_sub_pd(ix2,jx1);
1354 dy21 = _mm_sub_pd(iy2,jy1);
1355 dz21 = _mm_sub_pd(iz2,jz1);
1356 dx22 = _mm_sub_pd(ix2,jx2);
1357 dy22 = _mm_sub_pd(iy2,jy2);
1358 dz22 = _mm_sub_pd(iz2,jz2);
1359 dx23 = _mm_sub_pd(ix2,jx3);
1360 dy23 = _mm_sub_pd(iy2,jy3);
1361 dz23 = _mm_sub_pd(iz2,jz3);
1362 dx31 = _mm_sub_pd(ix3,jx1);
1363 dy31 = _mm_sub_pd(iy3,jy1);
1364 dz31 = _mm_sub_pd(iz3,jz1);
1365 dx32 = _mm_sub_pd(ix3,jx2);
1366 dy32 = _mm_sub_pd(iy3,jy2);
1367 dz32 = _mm_sub_pd(iz3,jz2);
1368 dx33 = _mm_sub_pd(ix3,jx3);
1369 dy33 = _mm_sub_pd(iy3,jy3);
1370 dz33 = _mm_sub_pd(iz3,jz3);
1372 /* Calculate squared distance and things based on it */
1373 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
1374 rsq11 = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1375 rsq12 = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1376 rsq13 = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1377 rsq21 = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1378 rsq22 = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1379 rsq23 = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1380 rsq31 = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1381 rsq32 = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1382 rsq33 = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1384 rinv11 = gmx_mm_invsqrt_pd(rsq11);
1385 rinv12 = gmx_mm_invsqrt_pd(rsq12);
1386 rinv13 = gmx_mm_invsqrt_pd(rsq13);
1387 rinv21 = gmx_mm_invsqrt_pd(rsq21);
1388 rinv22 = gmx_mm_invsqrt_pd(rsq22);
1389 rinv23 = gmx_mm_invsqrt_pd(rsq23);
1390 rinv31 = gmx_mm_invsqrt_pd(rsq31);
1391 rinv32 = gmx_mm_invsqrt_pd(rsq32);
1392 rinv33 = gmx_mm_invsqrt_pd(rsq33);
1394 rinvsq00 = gmx_mm_inv_pd(rsq00);
1395 rinvsq11 = _mm_mul_pd(rinv11,rinv11);
1396 rinvsq12 = _mm_mul_pd(rinv12,rinv12);
1397 rinvsq13 = _mm_mul_pd(rinv13,rinv13);
1398 rinvsq21 = _mm_mul_pd(rinv21,rinv21);
1399 rinvsq22 = _mm_mul_pd(rinv22,rinv22);
1400 rinvsq23 = _mm_mul_pd(rinv23,rinv23);
1401 rinvsq31 = _mm_mul_pd(rinv31,rinv31);
1402 rinvsq32 = _mm_mul_pd(rinv32,rinv32);
1403 rinvsq33 = _mm_mul_pd(rinv33,rinv33);
1405 fjx0 = _mm_setzero_pd();
1406 fjy0 = _mm_setzero_pd();
1407 fjz0 = _mm_setzero_pd();
1408 fjx1 = _mm_setzero_pd();
1409 fjy1 = _mm_setzero_pd();
1410 fjz1 = _mm_setzero_pd();
1411 fjx2 = _mm_setzero_pd();
1412 fjy2 = _mm_setzero_pd();
1413 fjz2 = _mm_setzero_pd();
1414 fjx3 = _mm_setzero_pd();
1415 fjy3 = _mm_setzero_pd();
1416 fjz3 = _mm_setzero_pd();
1418 /**************************
1419 * CALCULATE INTERACTIONS *
1420 **************************/
1422 /* LENNARD-JONES DISPERSION/REPULSION */
1424 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
1425 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
1429 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1431 /* Update vectorial force */
1432 fix0 = _mm_macc_pd(dx00,fscal,fix0);
1433 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
1434 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
1436 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
1437 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
1438 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
1440 /**************************
1441 * CALCULATE INTERACTIONS *
1442 **************************/
1444 /* REACTION-FIELD ELECTROSTATICS */
1445 felec = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1449 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1451 /* Update vectorial force */
1452 fix1 = _mm_macc_pd(dx11,fscal,fix1);
1453 fiy1 = _mm_macc_pd(dy11,fscal,fiy1);
1454 fiz1 = _mm_macc_pd(dz11,fscal,fiz1);
1456 fjx1 = _mm_macc_pd(dx11,fscal,fjx1);
1457 fjy1 = _mm_macc_pd(dy11,fscal,fjy1);
1458 fjz1 = _mm_macc_pd(dz11,fscal,fjz1);
1460 /**************************
1461 * CALCULATE INTERACTIONS *
1462 **************************/
1464 /* REACTION-FIELD ELECTROSTATICS */
1465 felec = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1469 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1471 /* Update vectorial force */
1472 fix1 = _mm_macc_pd(dx12,fscal,fix1);
1473 fiy1 = _mm_macc_pd(dy12,fscal,fiy1);
1474 fiz1 = _mm_macc_pd(dz12,fscal,fiz1);
1476 fjx2 = _mm_macc_pd(dx12,fscal,fjx2);
1477 fjy2 = _mm_macc_pd(dy12,fscal,fjy2);
1478 fjz2 = _mm_macc_pd(dz12,fscal,fjz2);
1480 /**************************
1481 * CALCULATE INTERACTIONS *
1482 **************************/
1484 /* REACTION-FIELD ELECTROSTATICS */
1485 felec = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1489 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1491 /* Update vectorial force */
1492 fix1 = _mm_macc_pd(dx13,fscal,fix1);
1493 fiy1 = _mm_macc_pd(dy13,fscal,fiy1);
1494 fiz1 = _mm_macc_pd(dz13,fscal,fiz1);
1496 fjx3 = _mm_macc_pd(dx13,fscal,fjx3);
1497 fjy3 = _mm_macc_pd(dy13,fscal,fjy3);
1498 fjz3 = _mm_macc_pd(dz13,fscal,fjz3);
1500 /**************************
1501 * CALCULATE INTERACTIONS *
1502 **************************/
1504 /* REACTION-FIELD ELECTROSTATICS */
1505 felec = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1509 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1511 /* Update vectorial force */
1512 fix2 = _mm_macc_pd(dx21,fscal,fix2);
1513 fiy2 = _mm_macc_pd(dy21,fscal,fiy2);
1514 fiz2 = _mm_macc_pd(dz21,fscal,fiz2);
1516 fjx1 = _mm_macc_pd(dx21,fscal,fjx1);
1517 fjy1 = _mm_macc_pd(dy21,fscal,fjy1);
1518 fjz1 = _mm_macc_pd(dz21,fscal,fjz1);
1520 /**************************
1521 * CALCULATE INTERACTIONS *
1522 **************************/
1524 /* REACTION-FIELD ELECTROSTATICS */
1525 felec = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1529 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1531 /* Update vectorial force */
1532 fix2 = _mm_macc_pd(dx22,fscal,fix2);
1533 fiy2 = _mm_macc_pd(dy22,fscal,fiy2);
1534 fiz2 = _mm_macc_pd(dz22,fscal,fiz2);
1536 fjx2 = _mm_macc_pd(dx22,fscal,fjx2);
1537 fjy2 = _mm_macc_pd(dy22,fscal,fjy2);
1538 fjz2 = _mm_macc_pd(dz22,fscal,fjz2);
1540 /**************************
1541 * CALCULATE INTERACTIONS *
1542 **************************/
1544 /* REACTION-FIELD ELECTROSTATICS */
1545 felec = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1549 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1551 /* Update vectorial force */
1552 fix2 = _mm_macc_pd(dx23,fscal,fix2);
1553 fiy2 = _mm_macc_pd(dy23,fscal,fiy2);
1554 fiz2 = _mm_macc_pd(dz23,fscal,fiz2);
1556 fjx3 = _mm_macc_pd(dx23,fscal,fjx3);
1557 fjy3 = _mm_macc_pd(dy23,fscal,fjy3);
1558 fjz3 = _mm_macc_pd(dz23,fscal,fjz3);
1560 /**************************
1561 * CALCULATE INTERACTIONS *
1562 **************************/
1564 /* REACTION-FIELD ELECTROSTATICS */
1565 felec = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1569 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1571 /* Update vectorial force */
1572 fix3 = _mm_macc_pd(dx31,fscal,fix3);
1573 fiy3 = _mm_macc_pd(dy31,fscal,fiy3);
1574 fiz3 = _mm_macc_pd(dz31,fscal,fiz3);
1576 fjx1 = _mm_macc_pd(dx31,fscal,fjx1);
1577 fjy1 = _mm_macc_pd(dy31,fscal,fjy1);
1578 fjz1 = _mm_macc_pd(dz31,fscal,fjz1);
1580 /**************************
1581 * CALCULATE INTERACTIONS *
1582 **************************/
1584 /* REACTION-FIELD ELECTROSTATICS */
1585 felec = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1589 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1591 /* Update vectorial force */
1592 fix3 = _mm_macc_pd(dx32,fscal,fix3);
1593 fiy3 = _mm_macc_pd(dy32,fscal,fiy3);
1594 fiz3 = _mm_macc_pd(dz32,fscal,fiz3);
1596 fjx2 = _mm_macc_pd(dx32,fscal,fjx2);
1597 fjy2 = _mm_macc_pd(dy32,fscal,fjy2);
1598 fjz2 = _mm_macc_pd(dz32,fscal,fjz2);
1600 /**************************
1601 * CALCULATE INTERACTIONS *
1602 **************************/
1604 /* REACTION-FIELD ELECTROSTATICS */
1605 felec = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1609 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1611 /* Update vectorial force */
1612 fix3 = _mm_macc_pd(dx33,fscal,fix3);
1613 fiy3 = _mm_macc_pd(dy33,fscal,fiy3);
1614 fiz3 = _mm_macc_pd(dz33,fscal,fiz3);
1616 fjx3 = _mm_macc_pd(dx33,fscal,fjx3);
1617 fjy3 = _mm_macc_pd(dy33,fscal,fjy3);
1618 fjz3 = _mm_macc_pd(dz33,fscal,fjz3);
1620 gmx_mm_decrement_4rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1622 /* Inner loop uses 303 flops */
1625 /* End of innermost loop */
1627 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1628 f+i_coord_offset,fshift+i_shift_offset);
1630 /* Increment number of inner iterations */
1631 inneriter += j_index_end - j_index_start;
1633 /* Outer loop uses 24 flops */
1636 /* Increment number of outer iterations */
1639 /* Update outer/inner flops */
1641 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*303);