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_single 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_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_VF_avx_128_fma_single
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: CubicSplineTable
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
94 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
95 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
96 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
97 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
98 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
99 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
100 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
101 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
102 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
103 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
104 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
105 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
106 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
109 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
112 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
113 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
115 __m128i ifour = _mm_set1_epi32(4);
116 __m128 rt,vfeps,twovfeps,vftabscale,Y,F,G,H,Fp,VV,FF;
118 __m128 dummy_mask,cutoff_mask;
119 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
120 __m128 one = _mm_set1_ps(1.0);
121 __m128 two = _mm_set1_ps(2.0);
127 jindex = nlist->jindex;
129 shiftidx = nlist->shift;
131 shiftvec = fr->shift_vec[0];
132 fshift = fr->fshift[0];
133 facel = _mm_set1_ps(fr->epsfac);
134 charge = mdatoms->chargeA;
135 krf = _mm_set1_ps(fr->ic->k_rf);
136 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
137 crf = _mm_set1_ps(fr->ic->c_rf);
138 nvdwtype = fr->ntype;
140 vdwtype = mdatoms->typeA;
142 vftab = kernel_data->table_vdw->data;
143 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
145 /* Setup water-specific parameters */
146 inr = nlist->iinr[0];
147 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
148 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
149 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
150 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
152 jq0 = _mm_set1_ps(charge[inr+0]);
153 jq1 = _mm_set1_ps(charge[inr+1]);
154 jq2 = _mm_set1_ps(charge[inr+2]);
155 vdwjidx0A = 2*vdwtype[inr+0];
156 qq00 = _mm_mul_ps(iq0,jq0);
157 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
158 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
159 qq01 = _mm_mul_ps(iq0,jq1);
160 qq02 = _mm_mul_ps(iq0,jq2);
161 qq10 = _mm_mul_ps(iq1,jq0);
162 qq11 = _mm_mul_ps(iq1,jq1);
163 qq12 = _mm_mul_ps(iq1,jq2);
164 qq20 = _mm_mul_ps(iq2,jq0);
165 qq21 = _mm_mul_ps(iq2,jq1);
166 qq22 = _mm_mul_ps(iq2,jq2);
168 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
169 rcutoff_scalar = fr->rcoulomb;
170 rcutoff = _mm_set1_ps(rcutoff_scalar);
171 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
173 /* Avoid stupid compiler warnings */
174 jnrA = jnrB = jnrC = jnrD = 0;
183 for(iidx=0;iidx<4*DIM;iidx++)
188 /* Start outer loop over neighborlists */
189 for(iidx=0; iidx<nri; iidx++)
191 /* Load shift vector for this list */
192 i_shift_offset = DIM*shiftidx[iidx];
194 /* Load limits for loop over neighbors */
195 j_index_start = jindex[iidx];
196 j_index_end = jindex[iidx+1];
198 /* Get outer coordinate index */
200 i_coord_offset = DIM*inr;
202 /* Load i particle coords and add shift vector */
203 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
204 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
206 fix0 = _mm_setzero_ps();
207 fiy0 = _mm_setzero_ps();
208 fiz0 = _mm_setzero_ps();
209 fix1 = _mm_setzero_ps();
210 fiy1 = _mm_setzero_ps();
211 fiz1 = _mm_setzero_ps();
212 fix2 = _mm_setzero_ps();
213 fiy2 = _mm_setzero_ps();
214 fiz2 = _mm_setzero_ps();
216 /* Reset potential sums */
217 velecsum = _mm_setzero_ps();
218 vvdwsum = _mm_setzero_ps();
220 /* Start inner kernel loop */
221 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
224 /* Get j neighbor index, and coordinate index */
229 j_coord_offsetA = DIM*jnrA;
230 j_coord_offsetB = DIM*jnrB;
231 j_coord_offsetC = DIM*jnrC;
232 j_coord_offsetD = DIM*jnrD;
234 /* load j atom coordinates */
235 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
236 x+j_coord_offsetC,x+j_coord_offsetD,
237 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
239 /* Calculate displacement vector */
240 dx00 = _mm_sub_ps(ix0,jx0);
241 dy00 = _mm_sub_ps(iy0,jy0);
242 dz00 = _mm_sub_ps(iz0,jz0);
243 dx01 = _mm_sub_ps(ix0,jx1);
244 dy01 = _mm_sub_ps(iy0,jy1);
245 dz01 = _mm_sub_ps(iz0,jz1);
246 dx02 = _mm_sub_ps(ix0,jx2);
247 dy02 = _mm_sub_ps(iy0,jy2);
248 dz02 = _mm_sub_ps(iz0,jz2);
249 dx10 = _mm_sub_ps(ix1,jx0);
250 dy10 = _mm_sub_ps(iy1,jy0);
251 dz10 = _mm_sub_ps(iz1,jz0);
252 dx11 = _mm_sub_ps(ix1,jx1);
253 dy11 = _mm_sub_ps(iy1,jy1);
254 dz11 = _mm_sub_ps(iz1,jz1);
255 dx12 = _mm_sub_ps(ix1,jx2);
256 dy12 = _mm_sub_ps(iy1,jy2);
257 dz12 = _mm_sub_ps(iz1,jz2);
258 dx20 = _mm_sub_ps(ix2,jx0);
259 dy20 = _mm_sub_ps(iy2,jy0);
260 dz20 = _mm_sub_ps(iz2,jz0);
261 dx21 = _mm_sub_ps(ix2,jx1);
262 dy21 = _mm_sub_ps(iy2,jy1);
263 dz21 = _mm_sub_ps(iz2,jz1);
264 dx22 = _mm_sub_ps(ix2,jx2);
265 dy22 = _mm_sub_ps(iy2,jy2);
266 dz22 = _mm_sub_ps(iz2,jz2);
268 /* Calculate squared distance and things based on it */
269 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
270 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
271 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
272 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
273 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
274 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
275 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
276 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
277 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
279 rinv00 = gmx_mm_invsqrt_ps(rsq00);
280 rinv01 = gmx_mm_invsqrt_ps(rsq01);
281 rinv02 = gmx_mm_invsqrt_ps(rsq02);
282 rinv10 = gmx_mm_invsqrt_ps(rsq10);
283 rinv11 = gmx_mm_invsqrt_ps(rsq11);
284 rinv12 = gmx_mm_invsqrt_ps(rsq12);
285 rinv20 = gmx_mm_invsqrt_ps(rsq20);
286 rinv21 = gmx_mm_invsqrt_ps(rsq21);
287 rinv22 = gmx_mm_invsqrt_ps(rsq22);
289 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
290 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
291 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
292 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
293 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
294 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
295 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
296 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
297 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
299 fjx0 = _mm_setzero_ps();
300 fjy0 = _mm_setzero_ps();
301 fjz0 = _mm_setzero_ps();
302 fjx1 = _mm_setzero_ps();
303 fjy1 = _mm_setzero_ps();
304 fjz1 = _mm_setzero_ps();
305 fjx2 = _mm_setzero_ps();
306 fjy2 = _mm_setzero_ps();
307 fjz2 = _mm_setzero_ps();
309 /**************************
310 * CALCULATE INTERACTIONS *
311 **************************/
313 if (gmx_mm_any_lt(rsq00,rcutoff2))
316 r00 = _mm_mul_ps(rsq00,rinv00);
318 /* Calculate table index by multiplying r with table scale and truncate to integer */
319 rt = _mm_mul_ps(r00,vftabscale);
320 vfitab = _mm_cvttps_epi32(rt);
322 vfeps = _mm_frcz_ps(rt);
324 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
326 twovfeps = _mm_add_ps(vfeps,vfeps);
327 vfitab = _mm_slli_epi32(vfitab,3);
329 /* REACTION-FIELD ELECTROSTATICS */
330 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_macc_ps(krf,rsq00,rinv00),crf));
331 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
333 /* CUBIC SPLINE TABLE DISPERSION */
334 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
335 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
336 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
337 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
338 _MM_TRANSPOSE4_PS(Y,F,G,H);
339 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
340 VV = _mm_macc_ps(vfeps,Fp,Y);
341 vvdw6 = _mm_mul_ps(c6_00,VV);
342 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
343 fvdw6 = _mm_mul_ps(c6_00,FF);
345 /* CUBIC SPLINE TABLE REPULSION */
346 vfitab = _mm_add_epi32(vfitab,ifour);
347 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
348 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
349 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
350 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
351 _MM_TRANSPOSE4_PS(Y,F,G,H);
352 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
353 VV = _mm_macc_ps(vfeps,Fp,Y);
354 vvdw12 = _mm_mul_ps(c12_00,VV);
355 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
356 fvdw12 = _mm_mul_ps(c12_00,FF);
357 vvdw = _mm_add_ps(vvdw12,vvdw6);
358 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
360 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
362 /* Update potential sum for this i atom from the interaction with this j atom. */
363 velec = _mm_and_ps(velec,cutoff_mask);
364 velecsum = _mm_add_ps(velecsum,velec);
365 vvdw = _mm_and_ps(vvdw,cutoff_mask);
366 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
368 fscal = _mm_add_ps(felec,fvdw);
370 fscal = _mm_and_ps(fscal,cutoff_mask);
372 /* Update vectorial force */
373 fix0 = _mm_macc_ps(dx00,fscal,fix0);
374 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
375 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
377 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
378 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
379 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
387 if (gmx_mm_any_lt(rsq01,rcutoff2))
390 /* REACTION-FIELD ELECTROSTATICS */
391 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_macc_ps(krf,rsq01,rinv01),crf));
392 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
394 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
396 /* Update potential sum for this i atom from the interaction with this j atom. */
397 velec = _mm_and_ps(velec,cutoff_mask);
398 velecsum = _mm_add_ps(velecsum,velec);
402 fscal = _mm_and_ps(fscal,cutoff_mask);
404 /* Update vectorial force */
405 fix0 = _mm_macc_ps(dx01,fscal,fix0);
406 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
407 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
409 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
410 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
411 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
415 /**************************
416 * CALCULATE INTERACTIONS *
417 **************************/
419 if (gmx_mm_any_lt(rsq02,rcutoff2))
422 /* REACTION-FIELD ELECTROSTATICS */
423 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_macc_ps(krf,rsq02,rinv02),crf));
424 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
426 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
428 /* Update potential sum for this i atom from the interaction with this j atom. */
429 velec = _mm_and_ps(velec,cutoff_mask);
430 velecsum = _mm_add_ps(velecsum,velec);
434 fscal = _mm_and_ps(fscal,cutoff_mask);
436 /* Update vectorial force */
437 fix0 = _mm_macc_ps(dx02,fscal,fix0);
438 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
439 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
441 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
442 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
443 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
447 /**************************
448 * CALCULATE INTERACTIONS *
449 **************************/
451 if (gmx_mm_any_lt(rsq10,rcutoff2))
454 /* REACTION-FIELD ELECTROSTATICS */
455 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
456 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
458 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
460 /* Update potential sum for this i atom from the interaction with this j atom. */
461 velec = _mm_and_ps(velec,cutoff_mask);
462 velecsum = _mm_add_ps(velecsum,velec);
466 fscal = _mm_and_ps(fscal,cutoff_mask);
468 /* Update vectorial force */
469 fix1 = _mm_macc_ps(dx10,fscal,fix1);
470 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
471 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
473 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
474 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
475 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
483 if (gmx_mm_any_lt(rsq11,rcutoff2))
486 /* REACTION-FIELD ELECTROSTATICS */
487 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_macc_ps(krf,rsq11,rinv11),crf));
488 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
490 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
492 /* Update potential sum for this i atom from the interaction with this j atom. */
493 velec = _mm_and_ps(velec,cutoff_mask);
494 velecsum = _mm_add_ps(velecsum,velec);
498 fscal = _mm_and_ps(fscal,cutoff_mask);
500 /* Update vectorial force */
501 fix1 = _mm_macc_ps(dx11,fscal,fix1);
502 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
503 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
505 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
506 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
507 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
515 if (gmx_mm_any_lt(rsq12,rcutoff2))
518 /* REACTION-FIELD ELECTROSTATICS */
519 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_macc_ps(krf,rsq12,rinv12),crf));
520 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
522 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
524 /* Update potential sum for this i atom from the interaction with this j atom. */
525 velec = _mm_and_ps(velec,cutoff_mask);
526 velecsum = _mm_add_ps(velecsum,velec);
530 fscal = _mm_and_ps(fscal,cutoff_mask);
532 /* Update vectorial force */
533 fix1 = _mm_macc_ps(dx12,fscal,fix1);
534 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
535 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
537 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
538 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
539 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
547 if (gmx_mm_any_lt(rsq20,rcutoff2))
550 /* REACTION-FIELD ELECTROSTATICS */
551 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
552 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
554 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
556 /* Update potential sum for this i atom from the interaction with this j atom. */
557 velec = _mm_and_ps(velec,cutoff_mask);
558 velecsum = _mm_add_ps(velecsum,velec);
562 fscal = _mm_and_ps(fscal,cutoff_mask);
564 /* Update vectorial force */
565 fix2 = _mm_macc_ps(dx20,fscal,fix2);
566 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
567 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
569 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
570 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
571 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
579 if (gmx_mm_any_lt(rsq21,rcutoff2))
582 /* REACTION-FIELD ELECTROSTATICS */
583 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_macc_ps(krf,rsq21,rinv21),crf));
584 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
586 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
588 /* Update potential sum for this i atom from the interaction with this j atom. */
589 velec = _mm_and_ps(velec,cutoff_mask);
590 velecsum = _mm_add_ps(velecsum,velec);
594 fscal = _mm_and_ps(fscal,cutoff_mask);
596 /* Update vectorial force */
597 fix2 = _mm_macc_ps(dx21,fscal,fix2);
598 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
599 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
601 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
602 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
603 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
607 /**************************
608 * CALCULATE INTERACTIONS *
609 **************************/
611 if (gmx_mm_any_lt(rsq22,rcutoff2))
614 /* REACTION-FIELD ELECTROSTATICS */
615 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_macc_ps(krf,rsq22,rinv22),crf));
616 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
618 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
620 /* Update potential sum for this i atom from the interaction with this j atom. */
621 velec = _mm_and_ps(velec,cutoff_mask);
622 velecsum = _mm_add_ps(velecsum,velec);
626 fscal = _mm_and_ps(fscal,cutoff_mask);
628 /* Update vectorial force */
629 fix2 = _mm_macc_ps(dx22,fscal,fix2);
630 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
631 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
633 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
634 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
635 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
639 fjptrA = f+j_coord_offsetA;
640 fjptrB = f+j_coord_offsetB;
641 fjptrC = f+j_coord_offsetC;
642 fjptrD = f+j_coord_offsetD;
644 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
645 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
647 /* Inner loop uses 387 flops */
653 /* Get j neighbor index, and coordinate index */
654 jnrlistA = jjnr[jidx];
655 jnrlistB = jjnr[jidx+1];
656 jnrlistC = jjnr[jidx+2];
657 jnrlistD = jjnr[jidx+3];
658 /* Sign of each element will be negative for non-real atoms.
659 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
660 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
662 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
663 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
664 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
665 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
666 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
667 j_coord_offsetA = DIM*jnrA;
668 j_coord_offsetB = DIM*jnrB;
669 j_coord_offsetC = DIM*jnrC;
670 j_coord_offsetD = DIM*jnrD;
672 /* load j atom coordinates */
673 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
674 x+j_coord_offsetC,x+j_coord_offsetD,
675 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
677 /* Calculate displacement vector */
678 dx00 = _mm_sub_ps(ix0,jx0);
679 dy00 = _mm_sub_ps(iy0,jy0);
680 dz00 = _mm_sub_ps(iz0,jz0);
681 dx01 = _mm_sub_ps(ix0,jx1);
682 dy01 = _mm_sub_ps(iy0,jy1);
683 dz01 = _mm_sub_ps(iz0,jz1);
684 dx02 = _mm_sub_ps(ix0,jx2);
685 dy02 = _mm_sub_ps(iy0,jy2);
686 dz02 = _mm_sub_ps(iz0,jz2);
687 dx10 = _mm_sub_ps(ix1,jx0);
688 dy10 = _mm_sub_ps(iy1,jy0);
689 dz10 = _mm_sub_ps(iz1,jz0);
690 dx11 = _mm_sub_ps(ix1,jx1);
691 dy11 = _mm_sub_ps(iy1,jy1);
692 dz11 = _mm_sub_ps(iz1,jz1);
693 dx12 = _mm_sub_ps(ix1,jx2);
694 dy12 = _mm_sub_ps(iy1,jy2);
695 dz12 = _mm_sub_ps(iz1,jz2);
696 dx20 = _mm_sub_ps(ix2,jx0);
697 dy20 = _mm_sub_ps(iy2,jy0);
698 dz20 = _mm_sub_ps(iz2,jz0);
699 dx21 = _mm_sub_ps(ix2,jx1);
700 dy21 = _mm_sub_ps(iy2,jy1);
701 dz21 = _mm_sub_ps(iz2,jz1);
702 dx22 = _mm_sub_ps(ix2,jx2);
703 dy22 = _mm_sub_ps(iy2,jy2);
704 dz22 = _mm_sub_ps(iz2,jz2);
706 /* Calculate squared distance and things based on it */
707 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
708 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
709 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
710 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
711 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
712 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
713 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
714 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
715 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
717 rinv00 = gmx_mm_invsqrt_ps(rsq00);
718 rinv01 = gmx_mm_invsqrt_ps(rsq01);
719 rinv02 = gmx_mm_invsqrt_ps(rsq02);
720 rinv10 = gmx_mm_invsqrt_ps(rsq10);
721 rinv11 = gmx_mm_invsqrt_ps(rsq11);
722 rinv12 = gmx_mm_invsqrt_ps(rsq12);
723 rinv20 = gmx_mm_invsqrt_ps(rsq20);
724 rinv21 = gmx_mm_invsqrt_ps(rsq21);
725 rinv22 = gmx_mm_invsqrt_ps(rsq22);
727 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
728 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
729 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
730 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
731 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
732 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
733 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
734 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
735 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
737 fjx0 = _mm_setzero_ps();
738 fjy0 = _mm_setzero_ps();
739 fjz0 = _mm_setzero_ps();
740 fjx1 = _mm_setzero_ps();
741 fjy1 = _mm_setzero_ps();
742 fjz1 = _mm_setzero_ps();
743 fjx2 = _mm_setzero_ps();
744 fjy2 = _mm_setzero_ps();
745 fjz2 = _mm_setzero_ps();
747 /**************************
748 * CALCULATE INTERACTIONS *
749 **************************/
751 if (gmx_mm_any_lt(rsq00,rcutoff2))
754 r00 = _mm_mul_ps(rsq00,rinv00);
755 r00 = _mm_andnot_ps(dummy_mask,r00);
757 /* Calculate table index by multiplying r with table scale and truncate to integer */
758 rt = _mm_mul_ps(r00,vftabscale);
759 vfitab = _mm_cvttps_epi32(rt);
761 vfeps = _mm_frcz_ps(rt);
763 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
765 twovfeps = _mm_add_ps(vfeps,vfeps);
766 vfitab = _mm_slli_epi32(vfitab,3);
768 /* REACTION-FIELD ELECTROSTATICS */
769 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_macc_ps(krf,rsq00,rinv00),crf));
770 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
772 /* CUBIC SPLINE TABLE DISPERSION */
773 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
774 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
775 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
776 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
777 _MM_TRANSPOSE4_PS(Y,F,G,H);
778 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
779 VV = _mm_macc_ps(vfeps,Fp,Y);
780 vvdw6 = _mm_mul_ps(c6_00,VV);
781 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
782 fvdw6 = _mm_mul_ps(c6_00,FF);
784 /* CUBIC SPLINE TABLE REPULSION */
785 vfitab = _mm_add_epi32(vfitab,ifour);
786 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
787 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
788 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
789 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
790 _MM_TRANSPOSE4_PS(Y,F,G,H);
791 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
792 VV = _mm_macc_ps(vfeps,Fp,Y);
793 vvdw12 = _mm_mul_ps(c12_00,VV);
794 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
795 fvdw12 = _mm_mul_ps(c12_00,FF);
796 vvdw = _mm_add_ps(vvdw12,vvdw6);
797 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
799 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
801 /* Update potential sum for this i atom from the interaction with this j atom. */
802 velec = _mm_and_ps(velec,cutoff_mask);
803 velec = _mm_andnot_ps(dummy_mask,velec);
804 velecsum = _mm_add_ps(velecsum,velec);
805 vvdw = _mm_and_ps(vvdw,cutoff_mask);
806 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
807 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
809 fscal = _mm_add_ps(felec,fvdw);
811 fscal = _mm_and_ps(fscal,cutoff_mask);
813 fscal = _mm_andnot_ps(dummy_mask,fscal);
815 /* Update vectorial force */
816 fix0 = _mm_macc_ps(dx00,fscal,fix0);
817 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
818 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
820 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
821 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
822 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
826 /**************************
827 * CALCULATE INTERACTIONS *
828 **************************/
830 if (gmx_mm_any_lt(rsq01,rcutoff2))
833 /* REACTION-FIELD ELECTROSTATICS */
834 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_macc_ps(krf,rsq01,rinv01),crf));
835 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
837 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
839 /* Update potential sum for this i atom from the interaction with this j atom. */
840 velec = _mm_and_ps(velec,cutoff_mask);
841 velec = _mm_andnot_ps(dummy_mask,velec);
842 velecsum = _mm_add_ps(velecsum,velec);
846 fscal = _mm_and_ps(fscal,cutoff_mask);
848 fscal = _mm_andnot_ps(dummy_mask,fscal);
850 /* Update vectorial force */
851 fix0 = _mm_macc_ps(dx01,fscal,fix0);
852 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
853 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
855 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
856 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
857 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
861 /**************************
862 * CALCULATE INTERACTIONS *
863 **************************/
865 if (gmx_mm_any_lt(rsq02,rcutoff2))
868 /* REACTION-FIELD ELECTROSTATICS */
869 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_macc_ps(krf,rsq02,rinv02),crf));
870 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
872 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
874 /* Update potential sum for this i atom from the interaction with this j atom. */
875 velec = _mm_and_ps(velec,cutoff_mask);
876 velec = _mm_andnot_ps(dummy_mask,velec);
877 velecsum = _mm_add_ps(velecsum,velec);
881 fscal = _mm_and_ps(fscal,cutoff_mask);
883 fscal = _mm_andnot_ps(dummy_mask,fscal);
885 /* Update vectorial force */
886 fix0 = _mm_macc_ps(dx02,fscal,fix0);
887 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
888 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
890 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
891 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
892 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
896 /**************************
897 * CALCULATE INTERACTIONS *
898 **************************/
900 if (gmx_mm_any_lt(rsq10,rcutoff2))
903 /* REACTION-FIELD ELECTROSTATICS */
904 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_macc_ps(krf,rsq10,rinv10),crf));
905 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
907 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
909 /* Update potential sum for this i atom from the interaction with this j atom. */
910 velec = _mm_and_ps(velec,cutoff_mask);
911 velec = _mm_andnot_ps(dummy_mask,velec);
912 velecsum = _mm_add_ps(velecsum,velec);
916 fscal = _mm_and_ps(fscal,cutoff_mask);
918 fscal = _mm_andnot_ps(dummy_mask,fscal);
920 /* Update vectorial force */
921 fix1 = _mm_macc_ps(dx10,fscal,fix1);
922 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
923 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
925 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
926 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
927 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
935 if (gmx_mm_any_lt(rsq11,rcutoff2))
938 /* REACTION-FIELD ELECTROSTATICS */
939 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_macc_ps(krf,rsq11,rinv11),crf));
940 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
942 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
944 /* Update potential sum for this i atom from the interaction with this j atom. */
945 velec = _mm_and_ps(velec,cutoff_mask);
946 velec = _mm_andnot_ps(dummy_mask,velec);
947 velecsum = _mm_add_ps(velecsum,velec);
951 fscal = _mm_and_ps(fscal,cutoff_mask);
953 fscal = _mm_andnot_ps(dummy_mask,fscal);
955 /* Update vectorial force */
956 fix1 = _mm_macc_ps(dx11,fscal,fix1);
957 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
958 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
960 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
961 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
962 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
966 /**************************
967 * CALCULATE INTERACTIONS *
968 **************************/
970 if (gmx_mm_any_lt(rsq12,rcutoff2))
973 /* REACTION-FIELD ELECTROSTATICS */
974 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_macc_ps(krf,rsq12,rinv12),crf));
975 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
977 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
979 /* Update potential sum for this i atom from the interaction with this j atom. */
980 velec = _mm_and_ps(velec,cutoff_mask);
981 velec = _mm_andnot_ps(dummy_mask,velec);
982 velecsum = _mm_add_ps(velecsum,velec);
986 fscal = _mm_and_ps(fscal,cutoff_mask);
988 fscal = _mm_andnot_ps(dummy_mask,fscal);
990 /* Update vectorial force */
991 fix1 = _mm_macc_ps(dx12,fscal,fix1);
992 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
993 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
995 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
996 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
997 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1001 /**************************
1002 * CALCULATE INTERACTIONS *
1003 **************************/
1005 if (gmx_mm_any_lt(rsq20,rcutoff2))
1008 /* REACTION-FIELD ELECTROSTATICS */
1009 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_macc_ps(krf,rsq20,rinv20),crf));
1010 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1012 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1014 /* Update potential sum for this i atom from the interaction with this j atom. */
1015 velec = _mm_and_ps(velec,cutoff_mask);
1016 velec = _mm_andnot_ps(dummy_mask,velec);
1017 velecsum = _mm_add_ps(velecsum,velec);
1021 fscal = _mm_and_ps(fscal,cutoff_mask);
1023 fscal = _mm_andnot_ps(dummy_mask,fscal);
1025 /* Update vectorial force */
1026 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1027 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1028 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1030 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1031 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1032 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1036 /**************************
1037 * CALCULATE INTERACTIONS *
1038 **************************/
1040 if (gmx_mm_any_lt(rsq21,rcutoff2))
1043 /* REACTION-FIELD ELECTROSTATICS */
1044 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_macc_ps(krf,rsq21,rinv21),crf));
1045 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
1047 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1049 /* Update potential sum for this i atom from the interaction with this j atom. */
1050 velec = _mm_and_ps(velec,cutoff_mask);
1051 velec = _mm_andnot_ps(dummy_mask,velec);
1052 velecsum = _mm_add_ps(velecsum,velec);
1056 fscal = _mm_and_ps(fscal,cutoff_mask);
1058 fscal = _mm_andnot_ps(dummy_mask,fscal);
1060 /* Update vectorial force */
1061 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1062 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1063 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1065 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1066 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1067 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1071 /**************************
1072 * CALCULATE INTERACTIONS *
1073 **************************/
1075 if (gmx_mm_any_lt(rsq22,rcutoff2))
1078 /* REACTION-FIELD ELECTROSTATICS */
1079 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_macc_ps(krf,rsq22,rinv22),crf));
1080 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
1082 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1084 /* Update potential sum for this i atom from the interaction with this j atom. */
1085 velec = _mm_and_ps(velec,cutoff_mask);
1086 velec = _mm_andnot_ps(dummy_mask,velec);
1087 velecsum = _mm_add_ps(velecsum,velec);
1091 fscal = _mm_and_ps(fscal,cutoff_mask);
1093 fscal = _mm_andnot_ps(dummy_mask,fscal);
1095 /* Update vectorial force */
1096 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1097 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1098 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1100 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1101 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1102 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1106 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1107 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1108 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1109 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1111 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1112 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1114 /* Inner loop uses 388 flops */
1117 /* End of innermost loop */
1119 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1120 f+i_coord_offset,fshift+i_shift_offset);
1123 /* Update potential energies */
1124 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1125 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1127 /* Increment number of inner iterations */
1128 inneriter += j_index_end - j_index_start;
1130 /* Outer loop uses 20 flops */
1133 /* Increment number of outer iterations */
1136 /* Update outer/inner flops */
1138 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*388);
1141 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_avx_128_fma_single
1142 * Electrostatics interaction: ReactionField
1143 * VdW interaction: CubicSplineTable
1144 * Geometry: Water3-Water3
1145 * Calculate force/pot: Force
1148 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_avx_128_fma_single
1149 (t_nblist * gmx_restrict nlist,
1150 rvec * gmx_restrict xx,
1151 rvec * gmx_restrict ff,
1152 t_forcerec * gmx_restrict fr,
1153 t_mdatoms * gmx_restrict mdatoms,
1154 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1155 t_nrnb * gmx_restrict nrnb)
1157 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1158 * just 0 for non-waters.
1159 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
1160 * jnr indices corresponding to data put in the four positions in the SIMD register.
1162 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1163 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1164 int jnrA,jnrB,jnrC,jnrD;
1165 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1166 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1167 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1168 real rcutoff_scalar;
1169 real *shiftvec,*fshift,*x,*f;
1170 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1171 real scratch[4*DIM];
1172 __m128 fscal,rcutoff,rcutoff2,jidxall;
1174 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1176 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1178 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1179 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1180 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1181 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1182 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1183 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1184 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1185 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1186 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1187 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1188 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1189 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1190 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1191 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1192 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1193 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1194 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
1197 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1200 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
1201 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
1203 __m128i ifour = _mm_set1_epi32(4);
1204 __m128 rt,vfeps,twovfeps,vftabscale,Y,F,G,H,Fp,VV,FF;
1206 __m128 dummy_mask,cutoff_mask;
1207 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1208 __m128 one = _mm_set1_ps(1.0);
1209 __m128 two = _mm_set1_ps(2.0);
1215 jindex = nlist->jindex;
1217 shiftidx = nlist->shift;
1219 shiftvec = fr->shift_vec[0];
1220 fshift = fr->fshift[0];
1221 facel = _mm_set1_ps(fr->epsfac);
1222 charge = mdatoms->chargeA;
1223 krf = _mm_set1_ps(fr->ic->k_rf);
1224 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
1225 crf = _mm_set1_ps(fr->ic->c_rf);
1226 nvdwtype = fr->ntype;
1227 vdwparam = fr->nbfp;
1228 vdwtype = mdatoms->typeA;
1230 vftab = kernel_data->table_vdw->data;
1231 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
1233 /* Setup water-specific parameters */
1234 inr = nlist->iinr[0];
1235 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
1236 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1237 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1238 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
1240 jq0 = _mm_set1_ps(charge[inr+0]);
1241 jq1 = _mm_set1_ps(charge[inr+1]);
1242 jq2 = _mm_set1_ps(charge[inr+2]);
1243 vdwjidx0A = 2*vdwtype[inr+0];
1244 qq00 = _mm_mul_ps(iq0,jq0);
1245 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1246 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1247 qq01 = _mm_mul_ps(iq0,jq1);
1248 qq02 = _mm_mul_ps(iq0,jq2);
1249 qq10 = _mm_mul_ps(iq1,jq0);
1250 qq11 = _mm_mul_ps(iq1,jq1);
1251 qq12 = _mm_mul_ps(iq1,jq2);
1252 qq20 = _mm_mul_ps(iq2,jq0);
1253 qq21 = _mm_mul_ps(iq2,jq1);
1254 qq22 = _mm_mul_ps(iq2,jq2);
1256 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1257 rcutoff_scalar = fr->rcoulomb;
1258 rcutoff = _mm_set1_ps(rcutoff_scalar);
1259 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
1261 /* Avoid stupid compiler warnings */
1262 jnrA = jnrB = jnrC = jnrD = 0;
1263 j_coord_offsetA = 0;
1264 j_coord_offsetB = 0;
1265 j_coord_offsetC = 0;
1266 j_coord_offsetD = 0;
1271 for(iidx=0;iidx<4*DIM;iidx++)
1273 scratch[iidx] = 0.0;
1276 /* Start outer loop over neighborlists */
1277 for(iidx=0; iidx<nri; iidx++)
1279 /* Load shift vector for this list */
1280 i_shift_offset = DIM*shiftidx[iidx];
1282 /* Load limits for loop over neighbors */
1283 j_index_start = jindex[iidx];
1284 j_index_end = jindex[iidx+1];
1286 /* Get outer coordinate index */
1288 i_coord_offset = DIM*inr;
1290 /* Load i particle coords and add shift vector */
1291 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1292 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1294 fix0 = _mm_setzero_ps();
1295 fiy0 = _mm_setzero_ps();
1296 fiz0 = _mm_setzero_ps();
1297 fix1 = _mm_setzero_ps();
1298 fiy1 = _mm_setzero_ps();
1299 fiz1 = _mm_setzero_ps();
1300 fix2 = _mm_setzero_ps();
1301 fiy2 = _mm_setzero_ps();
1302 fiz2 = _mm_setzero_ps();
1304 /* Start inner kernel loop */
1305 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1308 /* Get j neighbor index, and coordinate index */
1310 jnrB = jjnr[jidx+1];
1311 jnrC = jjnr[jidx+2];
1312 jnrD = jjnr[jidx+3];
1313 j_coord_offsetA = DIM*jnrA;
1314 j_coord_offsetB = DIM*jnrB;
1315 j_coord_offsetC = DIM*jnrC;
1316 j_coord_offsetD = DIM*jnrD;
1318 /* load j atom coordinates */
1319 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1320 x+j_coord_offsetC,x+j_coord_offsetD,
1321 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1323 /* Calculate displacement vector */
1324 dx00 = _mm_sub_ps(ix0,jx0);
1325 dy00 = _mm_sub_ps(iy0,jy0);
1326 dz00 = _mm_sub_ps(iz0,jz0);
1327 dx01 = _mm_sub_ps(ix0,jx1);
1328 dy01 = _mm_sub_ps(iy0,jy1);
1329 dz01 = _mm_sub_ps(iz0,jz1);
1330 dx02 = _mm_sub_ps(ix0,jx2);
1331 dy02 = _mm_sub_ps(iy0,jy2);
1332 dz02 = _mm_sub_ps(iz0,jz2);
1333 dx10 = _mm_sub_ps(ix1,jx0);
1334 dy10 = _mm_sub_ps(iy1,jy0);
1335 dz10 = _mm_sub_ps(iz1,jz0);
1336 dx11 = _mm_sub_ps(ix1,jx1);
1337 dy11 = _mm_sub_ps(iy1,jy1);
1338 dz11 = _mm_sub_ps(iz1,jz1);
1339 dx12 = _mm_sub_ps(ix1,jx2);
1340 dy12 = _mm_sub_ps(iy1,jy2);
1341 dz12 = _mm_sub_ps(iz1,jz2);
1342 dx20 = _mm_sub_ps(ix2,jx0);
1343 dy20 = _mm_sub_ps(iy2,jy0);
1344 dz20 = _mm_sub_ps(iz2,jz0);
1345 dx21 = _mm_sub_ps(ix2,jx1);
1346 dy21 = _mm_sub_ps(iy2,jy1);
1347 dz21 = _mm_sub_ps(iz2,jz1);
1348 dx22 = _mm_sub_ps(ix2,jx2);
1349 dy22 = _mm_sub_ps(iy2,jy2);
1350 dz22 = _mm_sub_ps(iz2,jz2);
1352 /* Calculate squared distance and things based on it */
1353 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1354 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1355 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1356 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1357 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1358 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1359 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1360 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1361 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1363 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1364 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1365 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1366 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1367 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1368 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1369 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1370 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1371 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1373 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1374 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1375 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1376 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1377 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1378 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1379 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1380 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1381 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1383 fjx0 = _mm_setzero_ps();
1384 fjy0 = _mm_setzero_ps();
1385 fjz0 = _mm_setzero_ps();
1386 fjx1 = _mm_setzero_ps();
1387 fjy1 = _mm_setzero_ps();
1388 fjz1 = _mm_setzero_ps();
1389 fjx2 = _mm_setzero_ps();
1390 fjy2 = _mm_setzero_ps();
1391 fjz2 = _mm_setzero_ps();
1393 /**************************
1394 * CALCULATE INTERACTIONS *
1395 **************************/
1397 if (gmx_mm_any_lt(rsq00,rcutoff2))
1400 r00 = _mm_mul_ps(rsq00,rinv00);
1402 /* Calculate table index by multiplying r with table scale and truncate to integer */
1403 rt = _mm_mul_ps(r00,vftabscale);
1404 vfitab = _mm_cvttps_epi32(rt);
1406 vfeps = _mm_frcz_ps(rt);
1408 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
1410 twovfeps = _mm_add_ps(vfeps,vfeps);
1411 vfitab = _mm_slli_epi32(vfitab,3);
1413 /* REACTION-FIELD ELECTROSTATICS */
1414 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
1416 /* CUBIC SPLINE TABLE DISPERSION */
1417 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1418 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1419 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1420 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1421 _MM_TRANSPOSE4_PS(Y,F,G,H);
1422 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1423 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1424 fvdw6 = _mm_mul_ps(c6_00,FF);
1426 /* CUBIC SPLINE TABLE REPULSION */
1427 vfitab = _mm_add_epi32(vfitab,ifour);
1428 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1429 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1430 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1431 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1432 _MM_TRANSPOSE4_PS(Y,F,G,H);
1433 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1434 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1435 fvdw12 = _mm_mul_ps(c12_00,FF);
1436 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
1438 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1440 fscal = _mm_add_ps(felec,fvdw);
1442 fscal = _mm_and_ps(fscal,cutoff_mask);
1444 /* Update vectorial force */
1445 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1446 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1447 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1449 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1450 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1451 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1455 /**************************
1456 * CALCULATE INTERACTIONS *
1457 **************************/
1459 if (gmx_mm_any_lt(rsq01,rcutoff2))
1462 /* REACTION-FIELD ELECTROSTATICS */
1463 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
1465 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
1469 fscal = _mm_and_ps(fscal,cutoff_mask);
1471 /* Update vectorial force */
1472 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1473 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1474 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1476 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1477 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1478 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1482 /**************************
1483 * CALCULATE INTERACTIONS *
1484 **************************/
1486 if (gmx_mm_any_lt(rsq02,rcutoff2))
1489 /* REACTION-FIELD ELECTROSTATICS */
1490 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
1492 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
1496 fscal = _mm_and_ps(fscal,cutoff_mask);
1498 /* Update vectorial force */
1499 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1500 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1501 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1503 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1504 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1505 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1509 /**************************
1510 * CALCULATE INTERACTIONS *
1511 **************************/
1513 if (gmx_mm_any_lt(rsq10,rcutoff2))
1516 /* REACTION-FIELD ELECTROSTATICS */
1517 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1519 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1523 fscal = _mm_and_ps(fscal,cutoff_mask);
1525 /* Update vectorial force */
1526 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1527 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1528 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1530 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1531 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1532 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1536 /**************************
1537 * CALCULATE INTERACTIONS *
1538 **************************/
1540 if (gmx_mm_any_lt(rsq11,rcutoff2))
1543 /* REACTION-FIELD ELECTROSTATICS */
1544 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
1546 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
1550 fscal = _mm_and_ps(fscal,cutoff_mask);
1552 /* Update vectorial force */
1553 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1554 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1555 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1557 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1558 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1559 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1563 /**************************
1564 * CALCULATE INTERACTIONS *
1565 **************************/
1567 if (gmx_mm_any_lt(rsq12,rcutoff2))
1570 /* REACTION-FIELD ELECTROSTATICS */
1571 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
1573 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
1577 fscal = _mm_and_ps(fscal,cutoff_mask);
1579 /* Update vectorial force */
1580 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1581 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1582 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1584 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1585 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1586 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1590 /**************************
1591 * CALCULATE INTERACTIONS *
1592 **************************/
1594 if (gmx_mm_any_lt(rsq20,rcutoff2))
1597 /* REACTION-FIELD ELECTROSTATICS */
1598 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1600 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1604 fscal = _mm_and_ps(fscal,cutoff_mask);
1606 /* Update vectorial force */
1607 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1608 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1609 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1611 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1612 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1613 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1617 /**************************
1618 * CALCULATE INTERACTIONS *
1619 **************************/
1621 if (gmx_mm_any_lt(rsq21,rcutoff2))
1624 /* REACTION-FIELD ELECTROSTATICS */
1625 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
1627 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1631 fscal = _mm_and_ps(fscal,cutoff_mask);
1633 /* Update vectorial force */
1634 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1635 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1636 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1638 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1639 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1640 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1644 /**************************
1645 * CALCULATE INTERACTIONS *
1646 **************************/
1648 if (gmx_mm_any_lt(rsq22,rcutoff2))
1651 /* REACTION-FIELD ELECTROSTATICS */
1652 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
1654 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1658 fscal = _mm_and_ps(fscal,cutoff_mask);
1660 /* Update vectorial force */
1661 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1662 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1663 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1665 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1666 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1667 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1671 fjptrA = f+j_coord_offsetA;
1672 fjptrB = f+j_coord_offsetB;
1673 fjptrC = f+j_coord_offsetC;
1674 fjptrD = f+j_coord_offsetD;
1676 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1677 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1679 /* Inner loop uses 324 flops */
1682 if(jidx<j_index_end)
1685 /* Get j neighbor index, and coordinate index */
1686 jnrlistA = jjnr[jidx];
1687 jnrlistB = jjnr[jidx+1];
1688 jnrlistC = jjnr[jidx+2];
1689 jnrlistD = jjnr[jidx+3];
1690 /* Sign of each element will be negative for non-real atoms.
1691 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1692 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1694 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1695 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1696 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1697 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1698 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1699 j_coord_offsetA = DIM*jnrA;
1700 j_coord_offsetB = DIM*jnrB;
1701 j_coord_offsetC = DIM*jnrC;
1702 j_coord_offsetD = DIM*jnrD;
1704 /* load j atom coordinates */
1705 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1706 x+j_coord_offsetC,x+j_coord_offsetD,
1707 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1709 /* Calculate displacement vector */
1710 dx00 = _mm_sub_ps(ix0,jx0);
1711 dy00 = _mm_sub_ps(iy0,jy0);
1712 dz00 = _mm_sub_ps(iz0,jz0);
1713 dx01 = _mm_sub_ps(ix0,jx1);
1714 dy01 = _mm_sub_ps(iy0,jy1);
1715 dz01 = _mm_sub_ps(iz0,jz1);
1716 dx02 = _mm_sub_ps(ix0,jx2);
1717 dy02 = _mm_sub_ps(iy0,jy2);
1718 dz02 = _mm_sub_ps(iz0,jz2);
1719 dx10 = _mm_sub_ps(ix1,jx0);
1720 dy10 = _mm_sub_ps(iy1,jy0);
1721 dz10 = _mm_sub_ps(iz1,jz0);
1722 dx11 = _mm_sub_ps(ix1,jx1);
1723 dy11 = _mm_sub_ps(iy1,jy1);
1724 dz11 = _mm_sub_ps(iz1,jz1);
1725 dx12 = _mm_sub_ps(ix1,jx2);
1726 dy12 = _mm_sub_ps(iy1,jy2);
1727 dz12 = _mm_sub_ps(iz1,jz2);
1728 dx20 = _mm_sub_ps(ix2,jx0);
1729 dy20 = _mm_sub_ps(iy2,jy0);
1730 dz20 = _mm_sub_ps(iz2,jz0);
1731 dx21 = _mm_sub_ps(ix2,jx1);
1732 dy21 = _mm_sub_ps(iy2,jy1);
1733 dz21 = _mm_sub_ps(iz2,jz1);
1734 dx22 = _mm_sub_ps(ix2,jx2);
1735 dy22 = _mm_sub_ps(iy2,jy2);
1736 dz22 = _mm_sub_ps(iz2,jz2);
1738 /* Calculate squared distance and things based on it */
1739 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1740 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1741 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1742 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1743 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1744 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1745 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1746 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1747 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1749 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1750 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1751 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1752 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1753 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1754 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1755 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1756 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1757 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1759 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1760 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1761 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1762 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1763 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1764 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1765 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1766 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1767 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1769 fjx0 = _mm_setzero_ps();
1770 fjy0 = _mm_setzero_ps();
1771 fjz0 = _mm_setzero_ps();
1772 fjx1 = _mm_setzero_ps();
1773 fjy1 = _mm_setzero_ps();
1774 fjz1 = _mm_setzero_ps();
1775 fjx2 = _mm_setzero_ps();
1776 fjy2 = _mm_setzero_ps();
1777 fjz2 = _mm_setzero_ps();
1779 /**************************
1780 * CALCULATE INTERACTIONS *
1781 **************************/
1783 if (gmx_mm_any_lt(rsq00,rcutoff2))
1786 r00 = _mm_mul_ps(rsq00,rinv00);
1787 r00 = _mm_andnot_ps(dummy_mask,r00);
1789 /* Calculate table index by multiplying r with table scale and truncate to integer */
1790 rt = _mm_mul_ps(r00,vftabscale);
1791 vfitab = _mm_cvttps_epi32(rt);
1793 vfeps = _mm_frcz_ps(rt);
1795 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
1797 twovfeps = _mm_add_ps(vfeps,vfeps);
1798 vfitab = _mm_slli_epi32(vfitab,3);
1800 /* REACTION-FIELD ELECTROSTATICS */
1801 felec = _mm_mul_ps(qq00,_mm_msub_ps(rinv00,rinvsq00,krf2));
1803 /* CUBIC SPLINE TABLE DISPERSION */
1804 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1805 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1806 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1807 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1808 _MM_TRANSPOSE4_PS(Y,F,G,H);
1809 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1810 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1811 fvdw6 = _mm_mul_ps(c6_00,FF);
1813 /* CUBIC SPLINE TABLE REPULSION */
1814 vfitab = _mm_add_epi32(vfitab,ifour);
1815 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1816 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1817 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1818 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1819 _MM_TRANSPOSE4_PS(Y,F,G,H);
1820 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1821 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1822 fvdw12 = _mm_mul_ps(c12_00,FF);
1823 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
1825 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1827 fscal = _mm_add_ps(felec,fvdw);
1829 fscal = _mm_and_ps(fscal,cutoff_mask);
1831 fscal = _mm_andnot_ps(dummy_mask,fscal);
1833 /* Update vectorial force */
1834 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1835 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1836 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1838 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1839 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1840 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1844 /**************************
1845 * CALCULATE INTERACTIONS *
1846 **************************/
1848 if (gmx_mm_any_lt(rsq01,rcutoff2))
1851 /* REACTION-FIELD ELECTROSTATICS */
1852 felec = _mm_mul_ps(qq01,_mm_msub_ps(rinv01,rinvsq01,krf2));
1854 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
1858 fscal = _mm_and_ps(fscal,cutoff_mask);
1860 fscal = _mm_andnot_ps(dummy_mask,fscal);
1862 /* Update vectorial force */
1863 fix0 = _mm_macc_ps(dx01,fscal,fix0);
1864 fiy0 = _mm_macc_ps(dy01,fscal,fiy0);
1865 fiz0 = _mm_macc_ps(dz01,fscal,fiz0);
1867 fjx1 = _mm_macc_ps(dx01,fscal,fjx1);
1868 fjy1 = _mm_macc_ps(dy01,fscal,fjy1);
1869 fjz1 = _mm_macc_ps(dz01,fscal,fjz1);
1873 /**************************
1874 * CALCULATE INTERACTIONS *
1875 **************************/
1877 if (gmx_mm_any_lt(rsq02,rcutoff2))
1880 /* REACTION-FIELD ELECTROSTATICS */
1881 felec = _mm_mul_ps(qq02,_mm_msub_ps(rinv02,rinvsq02,krf2));
1883 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
1887 fscal = _mm_and_ps(fscal,cutoff_mask);
1889 fscal = _mm_andnot_ps(dummy_mask,fscal);
1891 /* Update vectorial force */
1892 fix0 = _mm_macc_ps(dx02,fscal,fix0);
1893 fiy0 = _mm_macc_ps(dy02,fscal,fiy0);
1894 fiz0 = _mm_macc_ps(dz02,fscal,fiz0);
1896 fjx2 = _mm_macc_ps(dx02,fscal,fjx2);
1897 fjy2 = _mm_macc_ps(dy02,fscal,fjy2);
1898 fjz2 = _mm_macc_ps(dz02,fscal,fjz2);
1902 /**************************
1903 * CALCULATE INTERACTIONS *
1904 **************************/
1906 if (gmx_mm_any_lt(rsq10,rcutoff2))
1909 /* REACTION-FIELD ELECTROSTATICS */
1910 felec = _mm_mul_ps(qq10,_mm_msub_ps(rinv10,rinvsq10,krf2));
1912 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1916 fscal = _mm_and_ps(fscal,cutoff_mask);
1918 fscal = _mm_andnot_ps(dummy_mask,fscal);
1920 /* Update vectorial force */
1921 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1922 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1923 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1925 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1926 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1927 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1931 /**************************
1932 * CALCULATE INTERACTIONS *
1933 **************************/
1935 if (gmx_mm_any_lt(rsq11,rcutoff2))
1938 /* REACTION-FIELD ELECTROSTATICS */
1939 felec = _mm_mul_ps(qq11,_mm_msub_ps(rinv11,rinvsq11,krf2));
1941 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
1945 fscal = _mm_and_ps(fscal,cutoff_mask);
1947 fscal = _mm_andnot_ps(dummy_mask,fscal);
1949 /* Update vectorial force */
1950 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1951 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1952 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1954 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1955 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1956 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1960 /**************************
1961 * CALCULATE INTERACTIONS *
1962 **************************/
1964 if (gmx_mm_any_lt(rsq12,rcutoff2))
1967 /* REACTION-FIELD ELECTROSTATICS */
1968 felec = _mm_mul_ps(qq12,_mm_msub_ps(rinv12,rinvsq12,krf2));
1970 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
1974 fscal = _mm_and_ps(fscal,cutoff_mask);
1976 fscal = _mm_andnot_ps(dummy_mask,fscal);
1978 /* Update vectorial force */
1979 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1980 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1981 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1983 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1984 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1985 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1989 /**************************
1990 * CALCULATE INTERACTIONS *
1991 **************************/
1993 if (gmx_mm_any_lt(rsq20,rcutoff2))
1996 /* REACTION-FIELD ELECTROSTATICS */
1997 felec = _mm_mul_ps(qq20,_mm_msub_ps(rinv20,rinvsq20,krf2));
1999 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
2003 fscal = _mm_and_ps(fscal,cutoff_mask);
2005 fscal = _mm_andnot_ps(dummy_mask,fscal);
2007 /* Update vectorial force */
2008 fix2 = _mm_macc_ps(dx20,fscal,fix2);
2009 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
2010 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
2012 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
2013 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
2014 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
2018 /**************************
2019 * CALCULATE INTERACTIONS *
2020 **************************/
2022 if (gmx_mm_any_lt(rsq21,rcutoff2))
2025 /* REACTION-FIELD ELECTROSTATICS */
2026 felec = _mm_mul_ps(qq21,_mm_msub_ps(rinv21,rinvsq21,krf2));
2028 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
2032 fscal = _mm_and_ps(fscal,cutoff_mask);
2034 fscal = _mm_andnot_ps(dummy_mask,fscal);
2036 /* Update vectorial force */
2037 fix2 = _mm_macc_ps(dx21,fscal,fix2);
2038 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
2039 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
2041 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
2042 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
2043 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
2047 /**************************
2048 * CALCULATE INTERACTIONS *
2049 **************************/
2051 if (gmx_mm_any_lt(rsq22,rcutoff2))
2054 /* REACTION-FIELD ELECTROSTATICS */
2055 felec = _mm_mul_ps(qq22,_mm_msub_ps(rinv22,rinvsq22,krf2));
2057 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
2061 fscal = _mm_and_ps(fscal,cutoff_mask);
2063 fscal = _mm_andnot_ps(dummy_mask,fscal);
2065 /* Update vectorial force */
2066 fix2 = _mm_macc_ps(dx22,fscal,fix2);
2067 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
2068 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
2070 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
2071 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
2072 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
2076 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2077 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2078 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2079 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2081 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
2082 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2084 /* Inner loop uses 325 flops */
2087 /* End of innermost loop */
2089 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2090 f+i_coord_offset,fshift+i_shift_offset);
2092 /* Increment number of inner iterations */
2093 inneriter += j_index_end - j_index_start;
2095 /* Outer loop uses 18 flops */
2098 /* Increment number of outer iterations */
2101 /* Update outer/inner flops */
2103 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*325);