2 * Note: this file was generated by the Gromacs sse2_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_sse2_single.h"
34 #include "kernelutil_x86_sse2_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_VF_sse2_single
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: CubicSplineTable
40 * Geometry: Water3-Water3
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_VF_sse2_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
62 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
63 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
65 real *shiftvec,*fshift,*x,*f;
66 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
68 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
70 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
75 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
76 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
77 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
78 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
79 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
80 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
81 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
82 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
83 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
84 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
85 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
86 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
87 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
88 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
89 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
90 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
96 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
97 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
99 __m128i ifour = _mm_set1_epi32(4);
100 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
102 __m128 dummy_mask,cutoff_mask;
103 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
104 __m128 one = _mm_set1_ps(1.0);
105 __m128 two = _mm_set1_ps(2.0);
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
117 facel = _mm_set1_ps(fr->epsfac);
118 charge = mdatoms->chargeA;
119 krf = _mm_set1_ps(fr->ic->k_rf);
120 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
121 crf = _mm_set1_ps(fr->ic->c_rf);
122 nvdwtype = fr->ntype;
124 vdwtype = mdatoms->typeA;
126 vftab = kernel_data->table_vdw->data;
127 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
129 /* Setup water-specific parameters */
130 inr = nlist->iinr[0];
131 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
132 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
133 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
134 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
136 jq0 = _mm_set1_ps(charge[inr+0]);
137 jq1 = _mm_set1_ps(charge[inr+1]);
138 jq2 = _mm_set1_ps(charge[inr+2]);
139 vdwjidx0A = 2*vdwtype[inr+0];
140 qq00 = _mm_mul_ps(iq0,jq0);
141 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
142 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
143 qq01 = _mm_mul_ps(iq0,jq1);
144 qq02 = _mm_mul_ps(iq0,jq2);
145 qq10 = _mm_mul_ps(iq1,jq0);
146 qq11 = _mm_mul_ps(iq1,jq1);
147 qq12 = _mm_mul_ps(iq1,jq2);
148 qq20 = _mm_mul_ps(iq2,jq0);
149 qq21 = _mm_mul_ps(iq2,jq1);
150 qq22 = _mm_mul_ps(iq2,jq2);
152 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
153 rcutoff_scalar = fr->rcoulomb;
154 rcutoff = _mm_set1_ps(rcutoff_scalar);
155 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
157 /* Avoid stupid compiler warnings */
158 jnrA = jnrB = jnrC = jnrD = 0;
167 for(iidx=0;iidx<4*DIM;iidx++)
172 /* Start outer loop over neighborlists */
173 for(iidx=0; iidx<nri; iidx++)
175 /* Load shift vector for this list */
176 i_shift_offset = DIM*shiftidx[iidx];
178 /* Load limits for loop over neighbors */
179 j_index_start = jindex[iidx];
180 j_index_end = jindex[iidx+1];
182 /* Get outer coordinate index */
184 i_coord_offset = DIM*inr;
186 /* Load i particle coords and add shift vector */
187 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
188 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
190 fix0 = _mm_setzero_ps();
191 fiy0 = _mm_setzero_ps();
192 fiz0 = _mm_setzero_ps();
193 fix1 = _mm_setzero_ps();
194 fiy1 = _mm_setzero_ps();
195 fiz1 = _mm_setzero_ps();
196 fix2 = _mm_setzero_ps();
197 fiy2 = _mm_setzero_ps();
198 fiz2 = _mm_setzero_ps();
200 /* Reset potential sums */
201 velecsum = _mm_setzero_ps();
202 vvdwsum = _mm_setzero_ps();
204 /* Start inner kernel loop */
205 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
208 /* Get j neighbor index, and coordinate index */
213 j_coord_offsetA = DIM*jnrA;
214 j_coord_offsetB = DIM*jnrB;
215 j_coord_offsetC = DIM*jnrC;
216 j_coord_offsetD = DIM*jnrD;
218 /* load j atom coordinates */
219 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
220 x+j_coord_offsetC,x+j_coord_offsetD,
221 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
223 /* Calculate displacement vector */
224 dx00 = _mm_sub_ps(ix0,jx0);
225 dy00 = _mm_sub_ps(iy0,jy0);
226 dz00 = _mm_sub_ps(iz0,jz0);
227 dx01 = _mm_sub_ps(ix0,jx1);
228 dy01 = _mm_sub_ps(iy0,jy1);
229 dz01 = _mm_sub_ps(iz0,jz1);
230 dx02 = _mm_sub_ps(ix0,jx2);
231 dy02 = _mm_sub_ps(iy0,jy2);
232 dz02 = _mm_sub_ps(iz0,jz2);
233 dx10 = _mm_sub_ps(ix1,jx0);
234 dy10 = _mm_sub_ps(iy1,jy0);
235 dz10 = _mm_sub_ps(iz1,jz0);
236 dx11 = _mm_sub_ps(ix1,jx1);
237 dy11 = _mm_sub_ps(iy1,jy1);
238 dz11 = _mm_sub_ps(iz1,jz1);
239 dx12 = _mm_sub_ps(ix1,jx2);
240 dy12 = _mm_sub_ps(iy1,jy2);
241 dz12 = _mm_sub_ps(iz1,jz2);
242 dx20 = _mm_sub_ps(ix2,jx0);
243 dy20 = _mm_sub_ps(iy2,jy0);
244 dz20 = _mm_sub_ps(iz2,jz0);
245 dx21 = _mm_sub_ps(ix2,jx1);
246 dy21 = _mm_sub_ps(iy2,jy1);
247 dz21 = _mm_sub_ps(iz2,jz1);
248 dx22 = _mm_sub_ps(ix2,jx2);
249 dy22 = _mm_sub_ps(iy2,jy2);
250 dz22 = _mm_sub_ps(iz2,jz2);
252 /* Calculate squared distance and things based on it */
253 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
254 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
255 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
256 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
257 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
258 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
259 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
260 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
261 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
263 rinv00 = gmx_mm_invsqrt_ps(rsq00);
264 rinv01 = gmx_mm_invsqrt_ps(rsq01);
265 rinv02 = gmx_mm_invsqrt_ps(rsq02);
266 rinv10 = gmx_mm_invsqrt_ps(rsq10);
267 rinv11 = gmx_mm_invsqrt_ps(rsq11);
268 rinv12 = gmx_mm_invsqrt_ps(rsq12);
269 rinv20 = gmx_mm_invsqrt_ps(rsq20);
270 rinv21 = gmx_mm_invsqrt_ps(rsq21);
271 rinv22 = gmx_mm_invsqrt_ps(rsq22);
273 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
274 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
275 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
276 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
277 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
278 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
279 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
280 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
281 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
283 fjx0 = _mm_setzero_ps();
284 fjy0 = _mm_setzero_ps();
285 fjz0 = _mm_setzero_ps();
286 fjx1 = _mm_setzero_ps();
287 fjy1 = _mm_setzero_ps();
288 fjz1 = _mm_setzero_ps();
289 fjx2 = _mm_setzero_ps();
290 fjy2 = _mm_setzero_ps();
291 fjz2 = _mm_setzero_ps();
293 /**************************
294 * CALCULATE INTERACTIONS *
295 **************************/
297 if (gmx_mm_any_lt(rsq00,rcutoff2))
300 r00 = _mm_mul_ps(rsq00,rinv00);
302 /* Calculate table index by multiplying r with table scale and truncate to integer */
303 rt = _mm_mul_ps(r00,vftabscale);
304 vfitab = _mm_cvttps_epi32(rt);
305 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
306 vfitab = _mm_slli_epi32(vfitab,3);
308 /* REACTION-FIELD ELECTROSTATICS */
309 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_add_ps(rinv00,_mm_mul_ps(krf,rsq00)),crf));
310 felec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
312 /* CUBIC SPLINE TABLE DISPERSION */
313 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
314 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
315 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
316 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
317 _MM_TRANSPOSE4_PS(Y,F,G,H);
318 Heps = _mm_mul_ps(vfeps,H);
319 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
320 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
321 vvdw6 = _mm_mul_ps(c6_00,VV);
322 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
323 fvdw6 = _mm_mul_ps(c6_00,FF);
325 /* CUBIC SPLINE TABLE REPULSION */
326 vfitab = _mm_add_epi32(vfitab,ifour);
327 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
328 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
329 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
330 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
331 _MM_TRANSPOSE4_PS(Y,F,G,H);
332 Heps = _mm_mul_ps(vfeps,H);
333 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
334 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
335 vvdw12 = _mm_mul_ps(c12_00,VV);
336 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
337 fvdw12 = _mm_mul_ps(c12_00,FF);
338 vvdw = _mm_add_ps(vvdw12,vvdw6);
339 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
341 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
343 /* Update potential sum for this i atom from the interaction with this j atom. */
344 velec = _mm_and_ps(velec,cutoff_mask);
345 velecsum = _mm_add_ps(velecsum,velec);
346 vvdw = _mm_and_ps(vvdw,cutoff_mask);
347 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
349 fscal = _mm_add_ps(felec,fvdw);
351 fscal = _mm_and_ps(fscal,cutoff_mask);
353 /* Calculate temporary vectorial force */
354 tx = _mm_mul_ps(fscal,dx00);
355 ty = _mm_mul_ps(fscal,dy00);
356 tz = _mm_mul_ps(fscal,dz00);
358 /* Update vectorial force */
359 fix0 = _mm_add_ps(fix0,tx);
360 fiy0 = _mm_add_ps(fiy0,ty);
361 fiz0 = _mm_add_ps(fiz0,tz);
363 fjx0 = _mm_add_ps(fjx0,tx);
364 fjy0 = _mm_add_ps(fjy0,ty);
365 fjz0 = _mm_add_ps(fjz0,tz);
369 /**************************
370 * CALCULATE INTERACTIONS *
371 **************************/
373 if (gmx_mm_any_lt(rsq01,rcutoff2))
376 /* REACTION-FIELD ELECTROSTATICS */
377 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_add_ps(rinv01,_mm_mul_ps(krf,rsq01)),crf));
378 felec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_mul_ps(rinv01,rinvsq01),krf2));
380 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
382 /* Update potential sum for this i atom from the interaction with this j atom. */
383 velec = _mm_and_ps(velec,cutoff_mask);
384 velecsum = _mm_add_ps(velecsum,velec);
388 fscal = _mm_and_ps(fscal,cutoff_mask);
390 /* Calculate temporary vectorial force */
391 tx = _mm_mul_ps(fscal,dx01);
392 ty = _mm_mul_ps(fscal,dy01);
393 tz = _mm_mul_ps(fscal,dz01);
395 /* Update vectorial force */
396 fix0 = _mm_add_ps(fix0,tx);
397 fiy0 = _mm_add_ps(fiy0,ty);
398 fiz0 = _mm_add_ps(fiz0,tz);
400 fjx1 = _mm_add_ps(fjx1,tx);
401 fjy1 = _mm_add_ps(fjy1,ty);
402 fjz1 = _mm_add_ps(fjz1,tz);
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
410 if (gmx_mm_any_lt(rsq02,rcutoff2))
413 /* REACTION-FIELD ELECTROSTATICS */
414 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_add_ps(rinv02,_mm_mul_ps(krf,rsq02)),crf));
415 felec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_mul_ps(rinv02,rinvsq02),krf2));
417 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
419 /* Update potential sum for this i atom from the interaction with this j atom. */
420 velec = _mm_and_ps(velec,cutoff_mask);
421 velecsum = _mm_add_ps(velecsum,velec);
425 fscal = _mm_and_ps(fscal,cutoff_mask);
427 /* Calculate temporary vectorial force */
428 tx = _mm_mul_ps(fscal,dx02);
429 ty = _mm_mul_ps(fscal,dy02);
430 tz = _mm_mul_ps(fscal,dz02);
432 /* Update vectorial force */
433 fix0 = _mm_add_ps(fix0,tx);
434 fiy0 = _mm_add_ps(fiy0,ty);
435 fiz0 = _mm_add_ps(fiz0,tz);
437 fjx2 = _mm_add_ps(fjx2,tx);
438 fjy2 = _mm_add_ps(fjy2,ty);
439 fjz2 = _mm_add_ps(fjz2,tz);
443 /**************************
444 * CALCULATE INTERACTIONS *
445 **************************/
447 if (gmx_mm_any_lt(rsq10,rcutoff2))
450 /* REACTION-FIELD ELECTROSTATICS */
451 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_add_ps(rinv10,_mm_mul_ps(krf,rsq10)),crf));
452 felec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
454 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
456 /* Update potential sum for this i atom from the interaction with this j atom. */
457 velec = _mm_and_ps(velec,cutoff_mask);
458 velecsum = _mm_add_ps(velecsum,velec);
462 fscal = _mm_and_ps(fscal,cutoff_mask);
464 /* Calculate temporary vectorial force */
465 tx = _mm_mul_ps(fscal,dx10);
466 ty = _mm_mul_ps(fscal,dy10);
467 tz = _mm_mul_ps(fscal,dz10);
469 /* Update vectorial force */
470 fix1 = _mm_add_ps(fix1,tx);
471 fiy1 = _mm_add_ps(fiy1,ty);
472 fiz1 = _mm_add_ps(fiz1,tz);
474 fjx0 = _mm_add_ps(fjx0,tx);
475 fjy0 = _mm_add_ps(fjy0,ty);
476 fjz0 = _mm_add_ps(fjz0,tz);
480 /**************************
481 * CALCULATE INTERACTIONS *
482 **************************/
484 if (gmx_mm_any_lt(rsq11,rcutoff2))
487 /* REACTION-FIELD ELECTROSTATICS */
488 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
489 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
491 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
493 /* Update potential sum for this i atom from the interaction with this j atom. */
494 velec = _mm_and_ps(velec,cutoff_mask);
495 velecsum = _mm_add_ps(velecsum,velec);
499 fscal = _mm_and_ps(fscal,cutoff_mask);
501 /* Calculate temporary vectorial force */
502 tx = _mm_mul_ps(fscal,dx11);
503 ty = _mm_mul_ps(fscal,dy11);
504 tz = _mm_mul_ps(fscal,dz11);
506 /* Update vectorial force */
507 fix1 = _mm_add_ps(fix1,tx);
508 fiy1 = _mm_add_ps(fiy1,ty);
509 fiz1 = _mm_add_ps(fiz1,tz);
511 fjx1 = _mm_add_ps(fjx1,tx);
512 fjy1 = _mm_add_ps(fjy1,ty);
513 fjz1 = _mm_add_ps(fjz1,tz);
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
521 if (gmx_mm_any_lt(rsq12,rcutoff2))
524 /* REACTION-FIELD ELECTROSTATICS */
525 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
526 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
528 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
530 /* Update potential sum for this i atom from the interaction with this j atom. */
531 velec = _mm_and_ps(velec,cutoff_mask);
532 velecsum = _mm_add_ps(velecsum,velec);
536 fscal = _mm_and_ps(fscal,cutoff_mask);
538 /* Calculate temporary vectorial force */
539 tx = _mm_mul_ps(fscal,dx12);
540 ty = _mm_mul_ps(fscal,dy12);
541 tz = _mm_mul_ps(fscal,dz12);
543 /* Update vectorial force */
544 fix1 = _mm_add_ps(fix1,tx);
545 fiy1 = _mm_add_ps(fiy1,ty);
546 fiz1 = _mm_add_ps(fiz1,tz);
548 fjx2 = _mm_add_ps(fjx2,tx);
549 fjy2 = _mm_add_ps(fjy2,ty);
550 fjz2 = _mm_add_ps(fjz2,tz);
554 /**************************
555 * CALCULATE INTERACTIONS *
556 **************************/
558 if (gmx_mm_any_lt(rsq20,rcutoff2))
561 /* REACTION-FIELD ELECTROSTATICS */
562 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_add_ps(rinv20,_mm_mul_ps(krf,rsq20)),crf));
563 felec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
565 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
567 /* Update potential sum for this i atom from the interaction with this j atom. */
568 velec = _mm_and_ps(velec,cutoff_mask);
569 velecsum = _mm_add_ps(velecsum,velec);
573 fscal = _mm_and_ps(fscal,cutoff_mask);
575 /* Calculate temporary vectorial force */
576 tx = _mm_mul_ps(fscal,dx20);
577 ty = _mm_mul_ps(fscal,dy20);
578 tz = _mm_mul_ps(fscal,dz20);
580 /* Update vectorial force */
581 fix2 = _mm_add_ps(fix2,tx);
582 fiy2 = _mm_add_ps(fiy2,ty);
583 fiz2 = _mm_add_ps(fiz2,tz);
585 fjx0 = _mm_add_ps(fjx0,tx);
586 fjy0 = _mm_add_ps(fjy0,ty);
587 fjz0 = _mm_add_ps(fjz0,tz);
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
595 if (gmx_mm_any_lt(rsq21,rcutoff2))
598 /* REACTION-FIELD ELECTROSTATICS */
599 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
600 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
602 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
604 /* Update potential sum for this i atom from the interaction with this j atom. */
605 velec = _mm_and_ps(velec,cutoff_mask);
606 velecsum = _mm_add_ps(velecsum,velec);
610 fscal = _mm_and_ps(fscal,cutoff_mask);
612 /* Calculate temporary vectorial force */
613 tx = _mm_mul_ps(fscal,dx21);
614 ty = _mm_mul_ps(fscal,dy21);
615 tz = _mm_mul_ps(fscal,dz21);
617 /* Update vectorial force */
618 fix2 = _mm_add_ps(fix2,tx);
619 fiy2 = _mm_add_ps(fiy2,ty);
620 fiz2 = _mm_add_ps(fiz2,tz);
622 fjx1 = _mm_add_ps(fjx1,tx);
623 fjy1 = _mm_add_ps(fjy1,ty);
624 fjz1 = _mm_add_ps(fjz1,tz);
628 /**************************
629 * CALCULATE INTERACTIONS *
630 **************************/
632 if (gmx_mm_any_lt(rsq22,rcutoff2))
635 /* REACTION-FIELD ELECTROSTATICS */
636 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
637 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
639 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
641 /* Update potential sum for this i atom from the interaction with this j atom. */
642 velec = _mm_and_ps(velec,cutoff_mask);
643 velecsum = _mm_add_ps(velecsum,velec);
647 fscal = _mm_and_ps(fscal,cutoff_mask);
649 /* Calculate temporary vectorial force */
650 tx = _mm_mul_ps(fscal,dx22);
651 ty = _mm_mul_ps(fscal,dy22);
652 tz = _mm_mul_ps(fscal,dz22);
654 /* Update vectorial force */
655 fix2 = _mm_add_ps(fix2,tx);
656 fiy2 = _mm_add_ps(fiy2,ty);
657 fiz2 = _mm_add_ps(fiz2,tz);
659 fjx2 = _mm_add_ps(fjx2,tx);
660 fjy2 = _mm_add_ps(fjy2,ty);
661 fjz2 = _mm_add_ps(fjz2,tz);
665 fjptrA = f+j_coord_offsetA;
666 fjptrB = f+j_coord_offsetB;
667 fjptrC = f+j_coord_offsetC;
668 fjptrD = f+j_coord_offsetD;
670 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
671 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
673 /* Inner loop uses 360 flops */
679 /* Get j neighbor index, and coordinate index */
680 jnrlistA = jjnr[jidx];
681 jnrlistB = jjnr[jidx+1];
682 jnrlistC = jjnr[jidx+2];
683 jnrlistD = jjnr[jidx+3];
684 /* Sign of each element will be negative for non-real atoms.
685 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
686 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
688 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
689 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
690 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
691 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
692 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
693 j_coord_offsetA = DIM*jnrA;
694 j_coord_offsetB = DIM*jnrB;
695 j_coord_offsetC = DIM*jnrC;
696 j_coord_offsetD = DIM*jnrD;
698 /* load j atom coordinates */
699 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
700 x+j_coord_offsetC,x+j_coord_offsetD,
701 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
703 /* Calculate displacement vector */
704 dx00 = _mm_sub_ps(ix0,jx0);
705 dy00 = _mm_sub_ps(iy0,jy0);
706 dz00 = _mm_sub_ps(iz0,jz0);
707 dx01 = _mm_sub_ps(ix0,jx1);
708 dy01 = _mm_sub_ps(iy0,jy1);
709 dz01 = _mm_sub_ps(iz0,jz1);
710 dx02 = _mm_sub_ps(ix0,jx2);
711 dy02 = _mm_sub_ps(iy0,jy2);
712 dz02 = _mm_sub_ps(iz0,jz2);
713 dx10 = _mm_sub_ps(ix1,jx0);
714 dy10 = _mm_sub_ps(iy1,jy0);
715 dz10 = _mm_sub_ps(iz1,jz0);
716 dx11 = _mm_sub_ps(ix1,jx1);
717 dy11 = _mm_sub_ps(iy1,jy1);
718 dz11 = _mm_sub_ps(iz1,jz1);
719 dx12 = _mm_sub_ps(ix1,jx2);
720 dy12 = _mm_sub_ps(iy1,jy2);
721 dz12 = _mm_sub_ps(iz1,jz2);
722 dx20 = _mm_sub_ps(ix2,jx0);
723 dy20 = _mm_sub_ps(iy2,jy0);
724 dz20 = _mm_sub_ps(iz2,jz0);
725 dx21 = _mm_sub_ps(ix2,jx1);
726 dy21 = _mm_sub_ps(iy2,jy1);
727 dz21 = _mm_sub_ps(iz2,jz1);
728 dx22 = _mm_sub_ps(ix2,jx2);
729 dy22 = _mm_sub_ps(iy2,jy2);
730 dz22 = _mm_sub_ps(iz2,jz2);
732 /* Calculate squared distance and things based on it */
733 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
734 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
735 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
736 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
737 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
738 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
739 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
740 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
741 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
743 rinv00 = gmx_mm_invsqrt_ps(rsq00);
744 rinv01 = gmx_mm_invsqrt_ps(rsq01);
745 rinv02 = gmx_mm_invsqrt_ps(rsq02);
746 rinv10 = gmx_mm_invsqrt_ps(rsq10);
747 rinv11 = gmx_mm_invsqrt_ps(rsq11);
748 rinv12 = gmx_mm_invsqrt_ps(rsq12);
749 rinv20 = gmx_mm_invsqrt_ps(rsq20);
750 rinv21 = gmx_mm_invsqrt_ps(rsq21);
751 rinv22 = gmx_mm_invsqrt_ps(rsq22);
753 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
754 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
755 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
756 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
757 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
758 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
759 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
760 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
761 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
763 fjx0 = _mm_setzero_ps();
764 fjy0 = _mm_setzero_ps();
765 fjz0 = _mm_setzero_ps();
766 fjx1 = _mm_setzero_ps();
767 fjy1 = _mm_setzero_ps();
768 fjz1 = _mm_setzero_ps();
769 fjx2 = _mm_setzero_ps();
770 fjy2 = _mm_setzero_ps();
771 fjz2 = _mm_setzero_ps();
773 /**************************
774 * CALCULATE INTERACTIONS *
775 **************************/
777 if (gmx_mm_any_lt(rsq00,rcutoff2))
780 r00 = _mm_mul_ps(rsq00,rinv00);
781 r00 = _mm_andnot_ps(dummy_mask,r00);
783 /* Calculate table index by multiplying r with table scale and truncate to integer */
784 rt = _mm_mul_ps(r00,vftabscale);
785 vfitab = _mm_cvttps_epi32(rt);
786 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
787 vfitab = _mm_slli_epi32(vfitab,3);
789 /* REACTION-FIELD ELECTROSTATICS */
790 velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_add_ps(rinv00,_mm_mul_ps(krf,rsq00)),crf));
791 felec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
793 /* CUBIC SPLINE TABLE DISPERSION */
794 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
795 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
796 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
797 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
798 _MM_TRANSPOSE4_PS(Y,F,G,H);
799 Heps = _mm_mul_ps(vfeps,H);
800 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
801 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
802 vvdw6 = _mm_mul_ps(c6_00,VV);
803 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
804 fvdw6 = _mm_mul_ps(c6_00,FF);
806 /* CUBIC SPLINE TABLE REPULSION */
807 vfitab = _mm_add_epi32(vfitab,ifour);
808 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
809 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
810 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
811 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
812 _MM_TRANSPOSE4_PS(Y,F,G,H);
813 Heps = _mm_mul_ps(vfeps,H);
814 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
815 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
816 vvdw12 = _mm_mul_ps(c12_00,VV);
817 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
818 fvdw12 = _mm_mul_ps(c12_00,FF);
819 vvdw = _mm_add_ps(vvdw12,vvdw6);
820 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
822 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
824 /* Update potential sum for this i atom from the interaction with this j atom. */
825 velec = _mm_and_ps(velec,cutoff_mask);
826 velec = _mm_andnot_ps(dummy_mask,velec);
827 velecsum = _mm_add_ps(velecsum,velec);
828 vvdw = _mm_and_ps(vvdw,cutoff_mask);
829 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
830 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
832 fscal = _mm_add_ps(felec,fvdw);
834 fscal = _mm_and_ps(fscal,cutoff_mask);
836 fscal = _mm_andnot_ps(dummy_mask,fscal);
838 /* Calculate temporary vectorial force */
839 tx = _mm_mul_ps(fscal,dx00);
840 ty = _mm_mul_ps(fscal,dy00);
841 tz = _mm_mul_ps(fscal,dz00);
843 /* Update vectorial force */
844 fix0 = _mm_add_ps(fix0,tx);
845 fiy0 = _mm_add_ps(fiy0,ty);
846 fiz0 = _mm_add_ps(fiz0,tz);
848 fjx0 = _mm_add_ps(fjx0,tx);
849 fjy0 = _mm_add_ps(fjy0,ty);
850 fjz0 = _mm_add_ps(fjz0,tz);
854 /**************************
855 * CALCULATE INTERACTIONS *
856 **************************/
858 if (gmx_mm_any_lt(rsq01,rcutoff2))
861 /* REACTION-FIELD ELECTROSTATICS */
862 velec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_add_ps(rinv01,_mm_mul_ps(krf,rsq01)),crf));
863 felec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_mul_ps(rinv01,rinvsq01),krf2));
865 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
867 /* Update potential sum for this i atom from the interaction with this j atom. */
868 velec = _mm_and_ps(velec,cutoff_mask);
869 velec = _mm_andnot_ps(dummy_mask,velec);
870 velecsum = _mm_add_ps(velecsum,velec);
874 fscal = _mm_and_ps(fscal,cutoff_mask);
876 fscal = _mm_andnot_ps(dummy_mask,fscal);
878 /* Calculate temporary vectorial force */
879 tx = _mm_mul_ps(fscal,dx01);
880 ty = _mm_mul_ps(fscal,dy01);
881 tz = _mm_mul_ps(fscal,dz01);
883 /* Update vectorial force */
884 fix0 = _mm_add_ps(fix0,tx);
885 fiy0 = _mm_add_ps(fiy0,ty);
886 fiz0 = _mm_add_ps(fiz0,tz);
888 fjx1 = _mm_add_ps(fjx1,tx);
889 fjy1 = _mm_add_ps(fjy1,ty);
890 fjz1 = _mm_add_ps(fjz1,tz);
894 /**************************
895 * CALCULATE INTERACTIONS *
896 **************************/
898 if (gmx_mm_any_lt(rsq02,rcutoff2))
901 /* REACTION-FIELD ELECTROSTATICS */
902 velec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_add_ps(rinv02,_mm_mul_ps(krf,rsq02)),crf));
903 felec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_mul_ps(rinv02,rinvsq02),krf2));
905 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
907 /* Update potential sum for this i atom from the interaction with this j atom. */
908 velec = _mm_and_ps(velec,cutoff_mask);
909 velec = _mm_andnot_ps(dummy_mask,velec);
910 velecsum = _mm_add_ps(velecsum,velec);
914 fscal = _mm_and_ps(fscal,cutoff_mask);
916 fscal = _mm_andnot_ps(dummy_mask,fscal);
918 /* Calculate temporary vectorial force */
919 tx = _mm_mul_ps(fscal,dx02);
920 ty = _mm_mul_ps(fscal,dy02);
921 tz = _mm_mul_ps(fscal,dz02);
923 /* Update vectorial force */
924 fix0 = _mm_add_ps(fix0,tx);
925 fiy0 = _mm_add_ps(fiy0,ty);
926 fiz0 = _mm_add_ps(fiz0,tz);
928 fjx2 = _mm_add_ps(fjx2,tx);
929 fjy2 = _mm_add_ps(fjy2,ty);
930 fjz2 = _mm_add_ps(fjz2,tz);
934 /**************************
935 * CALCULATE INTERACTIONS *
936 **************************/
938 if (gmx_mm_any_lt(rsq10,rcutoff2))
941 /* REACTION-FIELD ELECTROSTATICS */
942 velec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_add_ps(rinv10,_mm_mul_ps(krf,rsq10)),crf));
943 felec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
945 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
947 /* Update potential sum for this i atom from the interaction with this j atom. */
948 velec = _mm_and_ps(velec,cutoff_mask);
949 velec = _mm_andnot_ps(dummy_mask,velec);
950 velecsum = _mm_add_ps(velecsum,velec);
954 fscal = _mm_and_ps(fscal,cutoff_mask);
956 fscal = _mm_andnot_ps(dummy_mask,fscal);
958 /* Calculate temporary vectorial force */
959 tx = _mm_mul_ps(fscal,dx10);
960 ty = _mm_mul_ps(fscal,dy10);
961 tz = _mm_mul_ps(fscal,dz10);
963 /* Update vectorial force */
964 fix1 = _mm_add_ps(fix1,tx);
965 fiy1 = _mm_add_ps(fiy1,ty);
966 fiz1 = _mm_add_ps(fiz1,tz);
968 fjx0 = _mm_add_ps(fjx0,tx);
969 fjy0 = _mm_add_ps(fjy0,ty);
970 fjz0 = _mm_add_ps(fjz0,tz);
974 /**************************
975 * CALCULATE INTERACTIONS *
976 **************************/
978 if (gmx_mm_any_lt(rsq11,rcutoff2))
981 /* REACTION-FIELD ELECTROSTATICS */
982 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
983 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
985 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
987 /* Update potential sum for this i atom from the interaction with this j atom. */
988 velec = _mm_and_ps(velec,cutoff_mask);
989 velec = _mm_andnot_ps(dummy_mask,velec);
990 velecsum = _mm_add_ps(velecsum,velec);
994 fscal = _mm_and_ps(fscal,cutoff_mask);
996 fscal = _mm_andnot_ps(dummy_mask,fscal);
998 /* Calculate temporary vectorial force */
999 tx = _mm_mul_ps(fscal,dx11);
1000 ty = _mm_mul_ps(fscal,dy11);
1001 tz = _mm_mul_ps(fscal,dz11);
1003 /* Update vectorial force */
1004 fix1 = _mm_add_ps(fix1,tx);
1005 fiy1 = _mm_add_ps(fiy1,ty);
1006 fiz1 = _mm_add_ps(fiz1,tz);
1008 fjx1 = _mm_add_ps(fjx1,tx);
1009 fjy1 = _mm_add_ps(fjy1,ty);
1010 fjz1 = _mm_add_ps(fjz1,tz);
1014 /**************************
1015 * CALCULATE INTERACTIONS *
1016 **************************/
1018 if (gmx_mm_any_lt(rsq12,rcutoff2))
1021 /* REACTION-FIELD ELECTROSTATICS */
1022 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
1023 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1025 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
1027 /* Update potential sum for this i atom from the interaction with this j atom. */
1028 velec = _mm_and_ps(velec,cutoff_mask);
1029 velec = _mm_andnot_ps(dummy_mask,velec);
1030 velecsum = _mm_add_ps(velecsum,velec);
1034 fscal = _mm_and_ps(fscal,cutoff_mask);
1036 fscal = _mm_andnot_ps(dummy_mask,fscal);
1038 /* Calculate temporary vectorial force */
1039 tx = _mm_mul_ps(fscal,dx12);
1040 ty = _mm_mul_ps(fscal,dy12);
1041 tz = _mm_mul_ps(fscal,dz12);
1043 /* Update vectorial force */
1044 fix1 = _mm_add_ps(fix1,tx);
1045 fiy1 = _mm_add_ps(fiy1,ty);
1046 fiz1 = _mm_add_ps(fiz1,tz);
1048 fjx2 = _mm_add_ps(fjx2,tx);
1049 fjy2 = _mm_add_ps(fjy2,ty);
1050 fjz2 = _mm_add_ps(fjz2,tz);
1054 /**************************
1055 * CALCULATE INTERACTIONS *
1056 **************************/
1058 if (gmx_mm_any_lt(rsq20,rcutoff2))
1061 /* REACTION-FIELD ELECTROSTATICS */
1062 velec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_add_ps(rinv20,_mm_mul_ps(krf,rsq20)),crf));
1063 felec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
1065 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1067 /* Update potential sum for this i atom from the interaction with this j atom. */
1068 velec = _mm_and_ps(velec,cutoff_mask);
1069 velec = _mm_andnot_ps(dummy_mask,velec);
1070 velecsum = _mm_add_ps(velecsum,velec);
1074 fscal = _mm_and_ps(fscal,cutoff_mask);
1076 fscal = _mm_andnot_ps(dummy_mask,fscal);
1078 /* Calculate temporary vectorial force */
1079 tx = _mm_mul_ps(fscal,dx20);
1080 ty = _mm_mul_ps(fscal,dy20);
1081 tz = _mm_mul_ps(fscal,dz20);
1083 /* Update vectorial force */
1084 fix2 = _mm_add_ps(fix2,tx);
1085 fiy2 = _mm_add_ps(fiy2,ty);
1086 fiz2 = _mm_add_ps(fiz2,tz);
1088 fjx0 = _mm_add_ps(fjx0,tx);
1089 fjy0 = _mm_add_ps(fjy0,ty);
1090 fjz0 = _mm_add_ps(fjz0,tz);
1094 /**************************
1095 * CALCULATE INTERACTIONS *
1096 **************************/
1098 if (gmx_mm_any_lt(rsq21,rcutoff2))
1101 /* REACTION-FIELD ELECTROSTATICS */
1102 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
1103 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1105 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1107 /* Update potential sum for this i atom from the interaction with this j atom. */
1108 velec = _mm_and_ps(velec,cutoff_mask);
1109 velec = _mm_andnot_ps(dummy_mask,velec);
1110 velecsum = _mm_add_ps(velecsum,velec);
1114 fscal = _mm_and_ps(fscal,cutoff_mask);
1116 fscal = _mm_andnot_ps(dummy_mask,fscal);
1118 /* Calculate temporary vectorial force */
1119 tx = _mm_mul_ps(fscal,dx21);
1120 ty = _mm_mul_ps(fscal,dy21);
1121 tz = _mm_mul_ps(fscal,dz21);
1123 /* Update vectorial force */
1124 fix2 = _mm_add_ps(fix2,tx);
1125 fiy2 = _mm_add_ps(fiy2,ty);
1126 fiz2 = _mm_add_ps(fiz2,tz);
1128 fjx1 = _mm_add_ps(fjx1,tx);
1129 fjy1 = _mm_add_ps(fjy1,ty);
1130 fjz1 = _mm_add_ps(fjz1,tz);
1134 /**************************
1135 * CALCULATE INTERACTIONS *
1136 **************************/
1138 if (gmx_mm_any_lt(rsq22,rcutoff2))
1141 /* REACTION-FIELD ELECTROSTATICS */
1142 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
1143 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1145 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1147 /* Update potential sum for this i atom from the interaction with this j atom. */
1148 velec = _mm_and_ps(velec,cutoff_mask);
1149 velec = _mm_andnot_ps(dummy_mask,velec);
1150 velecsum = _mm_add_ps(velecsum,velec);
1154 fscal = _mm_and_ps(fscal,cutoff_mask);
1156 fscal = _mm_andnot_ps(dummy_mask,fscal);
1158 /* Calculate temporary vectorial force */
1159 tx = _mm_mul_ps(fscal,dx22);
1160 ty = _mm_mul_ps(fscal,dy22);
1161 tz = _mm_mul_ps(fscal,dz22);
1163 /* Update vectorial force */
1164 fix2 = _mm_add_ps(fix2,tx);
1165 fiy2 = _mm_add_ps(fiy2,ty);
1166 fiz2 = _mm_add_ps(fiz2,tz);
1168 fjx2 = _mm_add_ps(fjx2,tx);
1169 fjy2 = _mm_add_ps(fjy2,ty);
1170 fjz2 = _mm_add_ps(fjz2,tz);
1174 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1175 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1176 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1177 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1179 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1180 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1182 /* Inner loop uses 361 flops */
1185 /* End of innermost loop */
1187 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1188 f+i_coord_offset,fshift+i_shift_offset);
1191 /* Update potential energies */
1192 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1193 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1195 /* Increment number of inner iterations */
1196 inneriter += j_index_end - j_index_start;
1198 /* Outer loop uses 20 flops */
1201 /* Increment number of outer iterations */
1204 /* Update outer/inner flops */
1206 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*361);
1209 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_sse2_single
1210 * Electrostatics interaction: ReactionField
1211 * VdW interaction: CubicSplineTable
1212 * Geometry: Water3-Water3
1213 * Calculate force/pot: Force
1216 nb_kernel_ElecRFCut_VdwCSTab_GeomW3W3_F_sse2_single
1217 (t_nblist * gmx_restrict nlist,
1218 rvec * gmx_restrict xx,
1219 rvec * gmx_restrict ff,
1220 t_forcerec * gmx_restrict fr,
1221 t_mdatoms * gmx_restrict mdatoms,
1222 nb_kernel_data_t * gmx_restrict kernel_data,
1223 t_nrnb * gmx_restrict nrnb)
1225 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1226 * just 0 for non-waters.
1227 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
1228 * jnr indices corresponding to data put in the four positions in the SIMD register.
1230 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1231 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1232 int jnrA,jnrB,jnrC,jnrD;
1233 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1234 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1235 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1236 real rcutoff_scalar;
1237 real *shiftvec,*fshift,*x,*f;
1238 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1239 real scratch[4*DIM];
1240 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1242 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1244 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1246 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1247 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1248 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1249 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1250 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1251 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1252 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1253 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1254 __m128 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1255 __m128 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1256 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1257 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1258 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1259 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1260 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1261 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1262 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
1265 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1268 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
1269 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
1271 __m128i ifour = _mm_set1_epi32(4);
1272 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
1274 __m128 dummy_mask,cutoff_mask;
1275 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1276 __m128 one = _mm_set1_ps(1.0);
1277 __m128 two = _mm_set1_ps(2.0);
1283 jindex = nlist->jindex;
1285 shiftidx = nlist->shift;
1287 shiftvec = fr->shift_vec[0];
1288 fshift = fr->fshift[0];
1289 facel = _mm_set1_ps(fr->epsfac);
1290 charge = mdatoms->chargeA;
1291 krf = _mm_set1_ps(fr->ic->k_rf);
1292 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
1293 crf = _mm_set1_ps(fr->ic->c_rf);
1294 nvdwtype = fr->ntype;
1295 vdwparam = fr->nbfp;
1296 vdwtype = mdatoms->typeA;
1298 vftab = kernel_data->table_vdw->data;
1299 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
1301 /* Setup water-specific parameters */
1302 inr = nlist->iinr[0];
1303 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
1304 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1305 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1306 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
1308 jq0 = _mm_set1_ps(charge[inr+0]);
1309 jq1 = _mm_set1_ps(charge[inr+1]);
1310 jq2 = _mm_set1_ps(charge[inr+2]);
1311 vdwjidx0A = 2*vdwtype[inr+0];
1312 qq00 = _mm_mul_ps(iq0,jq0);
1313 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1314 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1315 qq01 = _mm_mul_ps(iq0,jq1);
1316 qq02 = _mm_mul_ps(iq0,jq2);
1317 qq10 = _mm_mul_ps(iq1,jq0);
1318 qq11 = _mm_mul_ps(iq1,jq1);
1319 qq12 = _mm_mul_ps(iq1,jq2);
1320 qq20 = _mm_mul_ps(iq2,jq0);
1321 qq21 = _mm_mul_ps(iq2,jq1);
1322 qq22 = _mm_mul_ps(iq2,jq2);
1324 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1325 rcutoff_scalar = fr->rcoulomb;
1326 rcutoff = _mm_set1_ps(rcutoff_scalar);
1327 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
1329 /* Avoid stupid compiler warnings */
1330 jnrA = jnrB = jnrC = jnrD = 0;
1331 j_coord_offsetA = 0;
1332 j_coord_offsetB = 0;
1333 j_coord_offsetC = 0;
1334 j_coord_offsetD = 0;
1339 for(iidx=0;iidx<4*DIM;iidx++)
1341 scratch[iidx] = 0.0;
1344 /* Start outer loop over neighborlists */
1345 for(iidx=0; iidx<nri; iidx++)
1347 /* Load shift vector for this list */
1348 i_shift_offset = DIM*shiftidx[iidx];
1350 /* Load limits for loop over neighbors */
1351 j_index_start = jindex[iidx];
1352 j_index_end = jindex[iidx+1];
1354 /* Get outer coordinate index */
1356 i_coord_offset = DIM*inr;
1358 /* Load i particle coords and add shift vector */
1359 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1360 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1362 fix0 = _mm_setzero_ps();
1363 fiy0 = _mm_setzero_ps();
1364 fiz0 = _mm_setzero_ps();
1365 fix1 = _mm_setzero_ps();
1366 fiy1 = _mm_setzero_ps();
1367 fiz1 = _mm_setzero_ps();
1368 fix2 = _mm_setzero_ps();
1369 fiy2 = _mm_setzero_ps();
1370 fiz2 = _mm_setzero_ps();
1372 /* Start inner kernel loop */
1373 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1376 /* Get j neighbor index, and coordinate index */
1378 jnrB = jjnr[jidx+1];
1379 jnrC = jjnr[jidx+2];
1380 jnrD = jjnr[jidx+3];
1381 j_coord_offsetA = DIM*jnrA;
1382 j_coord_offsetB = DIM*jnrB;
1383 j_coord_offsetC = DIM*jnrC;
1384 j_coord_offsetD = DIM*jnrD;
1386 /* load j atom coordinates */
1387 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1388 x+j_coord_offsetC,x+j_coord_offsetD,
1389 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1391 /* Calculate displacement vector */
1392 dx00 = _mm_sub_ps(ix0,jx0);
1393 dy00 = _mm_sub_ps(iy0,jy0);
1394 dz00 = _mm_sub_ps(iz0,jz0);
1395 dx01 = _mm_sub_ps(ix0,jx1);
1396 dy01 = _mm_sub_ps(iy0,jy1);
1397 dz01 = _mm_sub_ps(iz0,jz1);
1398 dx02 = _mm_sub_ps(ix0,jx2);
1399 dy02 = _mm_sub_ps(iy0,jy2);
1400 dz02 = _mm_sub_ps(iz0,jz2);
1401 dx10 = _mm_sub_ps(ix1,jx0);
1402 dy10 = _mm_sub_ps(iy1,jy0);
1403 dz10 = _mm_sub_ps(iz1,jz0);
1404 dx11 = _mm_sub_ps(ix1,jx1);
1405 dy11 = _mm_sub_ps(iy1,jy1);
1406 dz11 = _mm_sub_ps(iz1,jz1);
1407 dx12 = _mm_sub_ps(ix1,jx2);
1408 dy12 = _mm_sub_ps(iy1,jy2);
1409 dz12 = _mm_sub_ps(iz1,jz2);
1410 dx20 = _mm_sub_ps(ix2,jx0);
1411 dy20 = _mm_sub_ps(iy2,jy0);
1412 dz20 = _mm_sub_ps(iz2,jz0);
1413 dx21 = _mm_sub_ps(ix2,jx1);
1414 dy21 = _mm_sub_ps(iy2,jy1);
1415 dz21 = _mm_sub_ps(iz2,jz1);
1416 dx22 = _mm_sub_ps(ix2,jx2);
1417 dy22 = _mm_sub_ps(iy2,jy2);
1418 dz22 = _mm_sub_ps(iz2,jz2);
1420 /* Calculate squared distance and things based on it */
1421 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1422 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1423 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1424 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1425 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1426 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1427 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1428 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1429 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1431 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1432 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1433 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1434 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1435 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1436 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1437 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1438 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1439 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1441 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1442 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1443 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1444 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1445 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1446 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1447 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1448 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1449 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1451 fjx0 = _mm_setzero_ps();
1452 fjy0 = _mm_setzero_ps();
1453 fjz0 = _mm_setzero_ps();
1454 fjx1 = _mm_setzero_ps();
1455 fjy1 = _mm_setzero_ps();
1456 fjz1 = _mm_setzero_ps();
1457 fjx2 = _mm_setzero_ps();
1458 fjy2 = _mm_setzero_ps();
1459 fjz2 = _mm_setzero_ps();
1461 /**************************
1462 * CALCULATE INTERACTIONS *
1463 **************************/
1465 if (gmx_mm_any_lt(rsq00,rcutoff2))
1468 r00 = _mm_mul_ps(rsq00,rinv00);
1470 /* Calculate table index by multiplying r with table scale and truncate to integer */
1471 rt = _mm_mul_ps(r00,vftabscale);
1472 vfitab = _mm_cvttps_epi32(rt);
1473 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
1474 vfitab = _mm_slli_epi32(vfitab,3);
1476 /* REACTION-FIELD ELECTROSTATICS */
1477 felec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
1479 /* CUBIC SPLINE TABLE DISPERSION */
1480 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
1481 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
1482 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
1483 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
1484 _MM_TRANSPOSE4_PS(Y,F,G,H);
1485 Heps = _mm_mul_ps(vfeps,H);
1486 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
1487 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
1488 fvdw6 = _mm_mul_ps(c6_00,FF);
1490 /* CUBIC SPLINE TABLE REPULSION */
1491 vfitab = _mm_add_epi32(vfitab,ifour);
1492 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
1493 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
1494 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
1495 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
1496 _MM_TRANSPOSE4_PS(Y,F,G,H);
1497 Heps = _mm_mul_ps(vfeps,H);
1498 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
1499 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
1500 fvdw12 = _mm_mul_ps(c12_00,FF);
1501 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
1503 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1505 fscal = _mm_add_ps(felec,fvdw);
1507 fscal = _mm_and_ps(fscal,cutoff_mask);
1509 /* Calculate temporary vectorial force */
1510 tx = _mm_mul_ps(fscal,dx00);
1511 ty = _mm_mul_ps(fscal,dy00);
1512 tz = _mm_mul_ps(fscal,dz00);
1514 /* Update vectorial force */
1515 fix0 = _mm_add_ps(fix0,tx);
1516 fiy0 = _mm_add_ps(fiy0,ty);
1517 fiz0 = _mm_add_ps(fiz0,tz);
1519 fjx0 = _mm_add_ps(fjx0,tx);
1520 fjy0 = _mm_add_ps(fjy0,ty);
1521 fjz0 = _mm_add_ps(fjz0,tz);
1525 /**************************
1526 * CALCULATE INTERACTIONS *
1527 **************************/
1529 if (gmx_mm_any_lt(rsq01,rcutoff2))
1532 /* REACTION-FIELD ELECTROSTATICS */
1533 felec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_mul_ps(rinv01,rinvsq01),krf2));
1535 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
1539 fscal = _mm_and_ps(fscal,cutoff_mask);
1541 /* Calculate temporary vectorial force */
1542 tx = _mm_mul_ps(fscal,dx01);
1543 ty = _mm_mul_ps(fscal,dy01);
1544 tz = _mm_mul_ps(fscal,dz01);
1546 /* Update vectorial force */
1547 fix0 = _mm_add_ps(fix0,tx);
1548 fiy0 = _mm_add_ps(fiy0,ty);
1549 fiz0 = _mm_add_ps(fiz0,tz);
1551 fjx1 = _mm_add_ps(fjx1,tx);
1552 fjy1 = _mm_add_ps(fjy1,ty);
1553 fjz1 = _mm_add_ps(fjz1,tz);
1557 /**************************
1558 * CALCULATE INTERACTIONS *
1559 **************************/
1561 if (gmx_mm_any_lt(rsq02,rcutoff2))
1564 /* REACTION-FIELD ELECTROSTATICS */
1565 felec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_mul_ps(rinv02,rinvsq02),krf2));
1567 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
1571 fscal = _mm_and_ps(fscal,cutoff_mask);
1573 /* Calculate temporary vectorial force */
1574 tx = _mm_mul_ps(fscal,dx02);
1575 ty = _mm_mul_ps(fscal,dy02);
1576 tz = _mm_mul_ps(fscal,dz02);
1578 /* Update vectorial force */
1579 fix0 = _mm_add_ps(fix0,tx);
1580 fiy0 = _mm_add_ps(fiy0,ty);
1581 fiz0 = _mm_add_ps(fiz0,tz);
1583 fjx2 = _mm_add_ps(fjx2,tx);
1584 fjy2 = _mm_add_ps(fjy2,ty);
1585 fjz2 = _mm_add_ps(fjz2,tz);
1589 /**************************
1590 * CALCULATE INTERACTIONS *
1591 **************************/
1593 if (gmx_mm_any_lt(rsq10,rcutoff2))
1596 /* REACTION-FIELD ELECTROSTATICS */
1597 felec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
1599 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1603 fscal = _mm_and_ps(fscal,cutoff_mask);
1605 /* Calculate temporary vectorial force */
1606 tx = _mm_mul_ps(fscal,dx10);
1607 ty = _mm_mul_ps(fscal,dy10);
1608 tz = _mm_mul_ps(fscal,dz10);
1610 /* Update vectorial force */
1611 fix1 = _mm_add_ps(fix1,tx);
1612 fiy1 = _mm_add_ps(fiy1,ty);
1613 fiz1 = _mm_add_ps(fiz1,tz);
1615 fjx0 = _mm_add_ps(fjx0,tx);
1616 fjy0 = _mm_add_ps(fjy0,ty);
1617 fjz0 = _mm_add_ps(fjz0,tz);
1621 /**************************
1622 * CALCULATE INTERACTIONS *
1623 **************************/
1625 if (gmx_mm_any_lt(rsq11,rcutoff2))
1628 /* REACTION-FIELD ELECTROSTATICS */
1629 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
1631 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
1635 fscal = _mm_and_ps(fscal,cutoff_mask);
1637 /* Calculate temporary vectorial force */
1638 tx = _mm_mul_ps(fscal,dx11);
1639 ty = _mm_mul_ps(fscal,dy11);
1640 tz = _mm_mul_ps(fscal,dz11);
1642 /* Update vectorial force */
1643 fix1 = _mm_add_ps(fix1,tx);
1644 fiy1 = _mm_add_ps(fiy1,ty);
1645 fiz1 = _mm_add_ps(fiz1,tz);
1647 fjx1 = _mm_add_ps(fjx1,tx);
1648 fjy1 = _mm_add_ps(fjy1,ty);
1649 fjz1 = _mm_add_ps(fjz1,tz);
1653 /**************************
1654 * CALCULATE INTERACTIONS *
1655 **************************/
1657 if (gmx_mm_any_lt(rsq12,rcutoff2))
1660 /* REACTION-FIELD ELECTROSTATICS */
1661 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1663 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
1667 fscal = _mm_and_ps(fscal,cutoff_mask);
1669 /* Calculate temporary vectorial force */
1670 tx = _mm_mul_ps(fscal,dx12);
1671 ty = _mm_mul_ps(fscal,dy12);
1672 tz = _mm_mul_ps(fscal,dz12);
1674 /* Update vectorial force */
1675 fix1 = _mm_add_ps(fix1,tx);
1676 fiy1 = _mm_add_ps(fiy1,ty);
1677 fiz1 = _mm_add_ps(fiz1,tz);
1679 fjx2 = _mm_add_ps(fjx2,tx);
1680 fjy2 = _mm_add_ps(fjy2,ty);
1681 fjz2 = _mm_add_ps(fjz2,tz);
1685 /**************************
1686 * CALCULATE INTERACTIONS *
1687 **************************/
1689 if (gmx_mm_any_lt(rsq20,rcutoff2))
1692 /* REACTION-FIELD ELECTROSTATICS */
1693 felec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
1695 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1699 fscal = _mm_and_ps(fscal,cutoff_mask);
1701 /* Calculate temporary vectorial force */
1702 tx = _mm_mul_ps(fscal,dx20);
1703 ty = _mm_mul_ps(fscal,dy20);
1704 tz = _mm_mul_ps(fscal,dz20);
1706 /* Update vectorial force */
1707 fix2 = _mm_add_ps(fix2,tx);
1708 fiy2 = _mm_add_ps(fiy2,ty);
1709 fiz2 = _mm_add_ps(fiz2,tz);
1711 fjx0 = _mm_add_ps(fjx0,tx);
1712 fjy0 = _mm_add_ps(fjy0,ty);
1713 fjz0 = _mm_add_ps(fjz0,tz);
1717 /**************************
1718 * CALCULATE INTERACTIONS *
1719 **************************/
1721 if (gmx_mm_any_lt(rsq21,rcutoff2))
1724 /* REACTION-FIELD ELECTROSTATICS */
1725 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1727 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1731 fscal = _mm_and_ps(fscal,cutoff_mask);
1733 /* Calculate temporary vectorial force */
1734 tx = _mm_mul_ps(fscal,dx21);
1735 ty = _mm_mul_ps(fscal,dy21);
1736 tz = _mm_mul_ps(fscal,dz21);
1738 /* Update vectorial force */
1739 fix2 = _mm_add_ps(fix2,tx);
1740 fiy2 = _mm_add_ps(fiy2,ty);
1741 fiz2 = _mm_add_ps(fiz2,tz);
1743 fjx1 = _mm_add_ps(fjx1,tx);
1744 fjy1 = _mm_add_ps(fjy1,ty);
1745 fjz1 = _mm_add_ps(fjz1,tz);
1749 /**************************
1750 * CALCULATE INTERACTIONS *
1751 **************************/
1753 if (gmx_mm_any_lt(rsq22,rcutoff2))
1756 /* REACTION-FIELD ELECTROSTATICS */
1757 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1759 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1763 fscal = _mm_and_ps(fscal,cutoff_mask);
1765 /* Calculate temporary vectorial force */
1766 tx = _mm_mul_ps(fscal,dx22);
1767 ty = _mm_mul_ps(fscal,dy22);
1768 tz = _mm_mul_ps(fscal,dz22);
1770 /* Update vectorial force */
1771 fix2 = _mm_add_ps(fix2,tx);
1772 fiy2 = _mm_add_ps(fiy2,ty);
1773 fiz2 = _mm_add_ps(fiz2,tz);
1775 fjx2 = _mm_add_ps(fjx2,tx);
1776 fjy2 = _mm_add_ps(fjy2,ty);
1777 fjz2 = _mm_add_ps(fjz2,tz);
1781 fjptrA = f+j_coord_offsetA;
1782 fjptrB = f+j_coord_offsetB;
1783 fjptrC = f+j_coord_offsetC;
1784 fjptrD = f+j_coord_offsetD;
1786 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1787 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1789 /* Inner loop uses 297 flops */
1792 if(jidx<j_index_end)
1795 /* Get j neighbor index, and coordinate index */
1796 jnrlistA = jjnr[jidx];
1797 jnrlistB = jjnr[jidx+1];
1798 jnrlistC = jjnr[jidx+2];
1799 jnrlistD = jjnr[jidx+3];
1800 /* Sign of each element will be negative for non-real atoms.
1801 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1802 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1804 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1805 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1806 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1807 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1808 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1809 j_coord_offsetA = DIM*jnrA;
1810 j_coord_offsetB = DIM*jnrB;
1811 j_coord_offsetC = DIM*jnrC;
1812 j_coord_offsetD = DIM*jnrD;
1814 /* load j atom coordinates */
1815 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1816 x+j_coord_offsetC,x+j_coord_offsetD,
1817 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1819 /* Calculate displacement vector */
1820 dx00 = _mm_sub_ps(ix0,jx0);
1821 dy00 = _mm_sub_ps(iy0,jy0);
1822 dz00 = _mm_sub_ps(iz0,jz0);
1823 dx01 = _mm_sub_ps(ix0,jx1);
1824 dy01 = _mm_sub_ps(iy0,jy1);
1825 dz01 = _mm_sub_ps(iz0,jz1);
1826 dx02 = _mm_sub_ps(ix0,jx2);
1827 dy02 = _mm_sub_ps(iy0,jy2);
1828 dz02 = _mm_sub_ps(iz0,jz2);
1829 dx10 = _mm_sub_ps(ix1,jx0);
1830 dy10 = _mm_sub_ps(iy1,jy0);
1831 dz10 = _mm_sub_ps(iz1,jz0);
1832 dx11 = _mm_sub_ps(ix1,jx1);
1833 dy11 = _mm_sub_ps(iy1,jy1);
1834 dz11 = _mm_sub_ps(iz1,jz1);
1835 dx12 = _mm_sub_ps(ix1,jx2);
1836 dy12 = _mm_sub_ps(iy1,jy2);
1837 dz12 = _mm_sub_ps(iz1,jz2);
1838 dx20 = _mm_sub_ps(ix2,jx0);
1839 dy20 = _mm_sub_ps(iy2,jy0);
1840 dz20 = _mm_sub_ps(iz2,jz0);
1841 dx21 = _mm_sub_ps(ix2,jx1);
1842 dy21 = _mm_sub_ps(iy2,jy1);
1843 dz21 = _mm_sub_ps(iz2,jz1);
1844 dx22 = _mm_sub_ps(ix2,jx2);
1845 dy22 = _mm_sub_ps(iy2,jy2);
1846 dz22 = _mm_sub_ps(iz2,jz2);
1848 /* Calculate squared distance and things based on it */
1849 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1850 rsq01 = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1851 rsq02 = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1852 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1853 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1854 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1855 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1856 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1857 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1859 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1860 rinv01 = gmx_mm_invsqrt_ps(rsq01);
1861 rinv02 = gmx_mm_invsqrt_ps(rsq02);
1862 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1863 rinv11 = gmx_mm_invsqrt_ps(rsq11);
1864 rinv12 = gmx_mm_invsqrt_ps(rsq12);
1865 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1866 rinv21 = gmx_mm_invsqrt_ps(rsq21);
1867 rinv22 = gmx_mm_invsqrt_ps(rsq22);
1869 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1870 rinvsq01 = _mm_mul_ps(rinv01,rinv01);
1871 rinvsq02 = _mm_mul_ps(rinv02,rinv02);
1872 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1873 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1874 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1875 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1876 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1877 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1879 fjx0 = _mm_setzero_ps();
1880 fjy0 = _mm_setzero_ps();
1881 fjz0 = _mm_setzero_ps();
1882 fjx1 = _mm_setzero_ps();
1883 fjy1 = _mm_setzero_ps();
1884 fjz1 = _mm_setzero_ps();
1885 fjx2 = _mm_setzero_ps();
1886 fjy2 = _mm_setzero_ps();
1887 fjz2 = _mm_setzero_ps();
1889 /**************************
1890 * CALCULATE INTERACTIONS *
1891 **************************/
1893 if (gmx_mm_any_lt(rsq00,rcutoff2))
1896 r00 = _mm_mul_ps(rsq00,rinv00);
1897 r00 = _mm_andnot_ps(dummy_mask,r00);
1899 /* Calculate table index by multiplying r with table scale and truncate to integer */
1900 rt = _mm_mul_ps(r00,vftabscale);
1901 vfitab = _mm_cvttps_epi32(rt);
1902 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
1903 vfitab = _mm_slli_epi32(vfitab,3);
1905 /* REACTION-FIELD ELECTROSTATICS */
1906 felec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
1908 /* CUBIC SPLINE TABLE DISPERSION */
1909 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
1910 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
1911 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
1912 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
1913 _MM_TRANSPOSE4_PS(Y,F,G,H);
1914 Heps = _mm_mul_ps(vfeps,H);
1915 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
1916 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
1917 fvdw6 = _mm_mul_ps(c6_00,FF);
1919 /* CUBIC SPLINE TABLE REPULSION */
1920 vfitab = _mm_add_epi32(vfitab,ifour);
1921 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
1922 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
1923 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
1924 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
1925 _MM_TRANSPOSE4_PS(Y,F,G,H);
1926 Heps = _mm_mul_ps(vfeps,H);
1927 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
1928 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
1929 fvdw12 = _mm_mul_ps(c12_00,FF);
1930 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
1932 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1934 fscal = _mm_add_ps(felec,fvdw);
1936 fscal = _mm_and_ps(fscal,cutoff_mask);
1938 fscal = _mm_andnot_ps(dummy_mask,fscal);
1940 /* Calculate temporary vectorial force */
1941 tx = _mm_mul_ps(fscal,dx00);
1942 ty = _mm_mul_ps(fscal,dy00);
1943 tz = _mm_mul_ps(fscal,dz00);
1945 /* Update vectorial force */
1946 fix0 = _mm_add_ps(fix0,tx);
1947 fiy0 = _mm_add_ps(fiy0,ty);
1948 fiz0 = _mm_add_ps(fiz0,tz);
1950 fjx0 = _mm_add_ps(fjx0,tx);
1951 fjy0 = _mm_add_ps(fjy0,ty);
1952 fjz0 = _mm_add_ps(fjz0,tz);
1956 /**************************
1957 * CALCULATE INTERACTIONS *
1958 **************************/
1960 if (gmx_mm_any_lt(rsq01,rcutoff2))
1963 /* REACTION-FIELD ELECTROSTATICS */
1964 felec = _mm_mul_ps(qq01,_mm_sub_ps(_mm_mul_ps(rinv01,rinvsq01),krf2));
1966 cutoff_mask = _mm_cmplt_ps(rsq01,rcutoff2);
1970 fscal = _mm_and_ps(fscal,cutoff_mask);
1972 fscal = _mm_andnot_ps(dummy_mask,fscal);
1974 /* Calculate temporary vectorial force */
1975 tx = _mm_mul_ps(fscal,dx01);
1976 ty = _mm_mul_ps(fscal,dy01);
1977 tz = _mm_mul_ps(fscal,dz01);
1979 /* Update vectorial force */
1980 fix0 = _mm_add_ps(fix0,tx);
1981 fiy0 = _mm_add_ps(fiy0,ty);
1982 fiz0 = _mm_add_ps(fiz0,tz);
1984 fjx1 = _mm_add_ps(fjx1,tx);
1985 fjy1 = _mm_add_ps(fjy1,ty);
1986 fjz1 = _mm_add_ps(fjz1,tz);
1990 /**************************
1991 * CALCULATE INTERACTIONS *
1992 **************************/
1994 if (gmx_mm_any_lt(rsq02,rcutoff2))
1997 /* REACTION-FIELD ELECTROSTATICS */
1998 felec = _mm_mul_ps(qq02,_mm_sub_ps(_mm_mul_ps(rinv02,rinvsq02),krf2));
2000 cutoff_mask = _mm_cmplt_ps(rsq02,rcutoff2);
2004 fscal = _mm_and_ps(fscal,cutoff_mask);
2006 fscal = _mm_andnot_ps(dummy_mask,fscal);
2008 /* Calculate temporary vectorial force */
2009 tx = _mm_mul_ps(fscal,dx02);
2010 ty = _mm_mul_ps(fscal,dy02);
2011 tz = _mm_mul_ps(fscal,dz02);
2013 /* Update vectorial force */
2014 fix0 = _mm_add_ps(fix0,tx);
2015 fiy0 = _mm_add_ps(fiy0,ty);
2016 fiz0 = _mm_add_ps(fiz0,tz);
2018 fjx2 = _mm_add_ps(fjx2,tx);
2019 fjy2 = _mm_add_ps(fjy2,ty);
2020 fjz2 = _mm_add_ps(fjz2,tz);
2024 /**************************
2025 * CALCULATE INTERACTIONS *
2026 **************************/
2028 if (gmx_mm_any_lt(rsq10,rcutoff2))
2031 /* REACTION-FIELD ELECTROSTATICS */
2032 felec = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
2034 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
2038 fscal = _mm_and_ps(fscal,cutoff_mask);
2040 fscal = _mm_andnot_ps(dummy_mask,fscal);
2042 /* Calculate temporary vectorial force */
2043 tx = _mm_mul_ps(fscal,dx10);
2044 ty = _mm_mul_ps(fscal,dy10);
2045 tz = _mm_mul_ps(fscal,dz10);
2047 /* Update vectorial force */
2048 fix1 = _mm_add_ps(fix1,tx);
2049 fiy1 = _mm_add_ps(fiy1,ty);
2050 fiz1 = _mm_add_ps(fiz1,tz);
2052 fjx0 = _mm_add_ps(fjx0,tx);
2053 fjy0 = _mm_add_ps(fjy0,ty);
2054 fjz0 = _mm_add_ps(fjz0,tz);
2058 /**************************
2059 * CALCULATE INTERACTIONS *
2060 **************************/
2062 if (gmx_mm_any_lt(rsq11,rcutoff2))
2065 /* REACTION-FIELD ELECTROSTATICS */
2066 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
2068 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
2072 fscal = _mm_and_ps(fscal,cutoff_mask);
2074 fscal = _mm_andnot_ps(dummy_mask,fscal);
2076 /* Calculate temporary vectorial force */
2077 tx = _mm_mul_ps(fscal,dx11);
2078 ty = _mm_mul_ps(fscal,dy11);
2079 tz = _mm_mul_ps(fscal,dz11);
2081 /* Update vectorial force */
2082 fix1 = _mm_add_ps(fix1,tx);
2083 fiy1 = _mm_add_ps(fiy1,ty);
2084 fiz1 = _mm_add_ps(fiz1,tz);
2086 fjx1 = _mm_add_ps(fjx1,tx);
2087 fjy1 = _mm_add_ps(fjy1,ty);
2088 fjz1 = _mm_add_ps(fjz1,tz);
2092 /**************************
2093 * CALCULATE INTERACTIONS *
2094 **************************/
2096 if (gmx_mm_any_lt(rsq12,rcutoff2))
2099 /* REACTION-FIELD ELECTROSTATICS */
2100 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
2102 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
2106 fscal = _mm_and_ps(fscal,cutoff_mask);
2108 fscal = _mm_andnot_ps(dummy_mask,fscal);
2110 /* Calculate temporary vectorial force */
2111 tx = _mm_mul_ps(fscal,dx12);
2112 ty = _mm_mul_ps(fscal,dy12);
2113 tz = _mm_mul_ps(fscal,dz12);
2115 /* Update vectorial force */
2116 fix1 = _mm_add_ps(fix1,tx);
2117 fiy1 = _mm_add_ps(fiy1,ty);
2118 fiz1 = _mm_add_ps(fiz1,tz);
2120 fjx2 = _mm_add_ps(fjx2,tx);
2121 fjy2 = _mm_add_ps(fjy2,ty);
2122 fjz2 = _mm_add_ps(fjz2,tz);
2126 /**************************
2127 * CALCULATE INTERACTIONS *
2128 **************************/
2130 if (gmx_mm_any_lt(rsq20,rcutoff2))
2133 /* REACTION-FIELD ELECTROSTATICS */
2134 felec = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
2136 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
2140 fscal = _mm_and_ps(fscal,cutoff_mask);
2142 fscal = _mm_andnot_ps(dummy_mask,fscal);
2144 /* Calculate temporary vectorial force */
2145 tx = _mm_mul_ps(fscal,dx20);
2146 ty = _mm_mul_ps(fscal,dy20);
2147 tz = _mm_mul_ps(fscal,dz20);
2149 /* Update vectorial force */
2150 fix2 = _mm_add_ps(fix2,tx);
2151 fiy2 = _mm_add_ps(fiy2,ty);
2152 fiz2 = _mm_add_ps(fiz2,tz);
2154 fjx0 = _mm_add_ps(fjx0,tx);
2155 fjy0 = _mm_add_ps(fjy0,ty);
2156 fjz0 = _mm_add_ps(fjz0,tz);
2160 /**************************
2161 * CALCULATE INTERACTIONS *
2162 **************************/
2164 if (gmx_mm_any_lt(rsq21,rcutoff2))
2167 /* REACTION-FIELD ELECTROSTATICS */
2168 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
2170 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
2174 fscal = _mm_and_ps(fscal,cutoff_mask);
2176 fscal = _mm_andnot_ps(dummy_mask,fscal);
2178 /* Calculate temporary vectorial force */
2179 tx = _mm_mul_ps(fscal,dx21);
2180 ty = _mm_mul_ps(fscal,dy21);
2181 tz = _mm_mul_ps(fscal,dz21);
2183 /* Update vectorial force */
2184 fix2 = _mm_add_ps(fix2,tx);
2185 fiy2 = _mm_add_ps(fiy2,ty);
2186 fiz2 = _mm_add_ps(fiz2,tz);
2188 fjx1 = _mm_add_ps(fjx1,tx);
2189 fjy1 = _mm_add_ps(fjy1,ty);
2190 fjz1 = _mm_add_ps(fjz1,tz);
2194 /**************************
2195 * CALCULATE INTERACTIONS *
2196 **************************/
2198 if (gmx_mm_any_lt(rsq22,rcutoff2))
2201 /* REACTION-FIELD ELECTROSTATICS */
2202 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
2204 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
2208 fscal = _mm_and_ps(fscal,cutoff_mask);
2210 fscal = _mm_andnot_ps(dummy_mask,fscal);
2212 /* Calculate temporary vectorial force */
2213 tx = _mm_mul_ps(fscal,dx22);
2214 ty = _mm_mul_ps(fscal,dy22);
2215 tz = _mm_mul_ps(fscal,dz22);
2217 /* Update vectorial force */
2218 fix2 = _mm_add_ps(fix2,tx);
2219 fiy2 = _mm_add_ps(fiy2,ty);
2220 fiz2 = _mm_add_ps(fiz2,tz);
2222 fjx2 = _mm_add_ps(fjx2,tx);
2223 fjy2 = _mm_add_ps(fjy2,ty);
2224 fjz2 = _mm_add_ps(fjz2,tz);
2228 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2229 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2230 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2231 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2233 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
2234 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2236 /* Inner loop uses 298 flops */
2239 /* End of innermost loop */
2241 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2242 f+i_coord_offset,fshift+i_shift_offset);
2244 /* Increment number of inner iterations */
2245 inneriter += j_index_end - j_index_start;
2247 /* Outer loop uses 18 flops */
2250 /* Increment number of outer iterations */
2253 /* Update outer/inner flops */
2255 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*298);