2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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 sse2_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gmx_math_x86_sse2_single.h"
50 #include "kernelutil_x86_sse2_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_sse2_single
54 * Electrostatics interaction: GeneralizedBorn
55 * VdW interaction: CubicSplineTable
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_sse2_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_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 SSE, 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 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
88 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128 vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,gbeps,dvdatmp;
94 __m128 minushalf = _mm_set1_ps(-0.5);
95 real *invsqrta,*dvda,*gbtab;
97 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
100 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
101 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
103 __m128i ifour = _mm_set1_epi32(4);
104 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
106 __m128 dummy_mask,cutoff_mask;
107 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
108 __m128 one = _mm_set1_ps(1.0);
109 __m128 two = _mm_set1_ps(2.0);
115 jindex = nlist->jindex;
117 shiftidx = nlist->shift;
119 shiftvec = fr->shift_vec[0];
120 fshift = fr->fshift[0];
121 facel = _mm_set1_ps(fr->epsfac);
122 charge = mdatoms->chargeA;
123 nvdwtype = fr->ntype;
125 vdwtype = mdatoms->typeA;
127 vftab = kernel_data->table_vdw->data;
128 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
130 invsqrta = fr->invsqrta;
132 gbtabscale = _mm_set1_ps(fr->gbtab.scale);
133 gbtab = fr->gbtab.data;
134 gbinvepsdiff = _mm_set1_ps((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
136 /* Avoid stupid compiler warnings */
137 jnrA = jnrB = jnrC = jnrD = 0;
146 for(iidx=0;iidx<4*DIM;iidx++)
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
157 /* Load limits for loop over neighbors */
158 j_index_start = jindex[iidx];
159 j_index_end = jindex[iidx+1];
161 /* Get outer coordinate index */
163 i_coord_offset = DIM*inr;
165 /* Load i particle coords and add shift vector */
166 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
168 fix0 = _mm_setzero_ps();
169 fiy0 = _mm_setzero_ps();
170 fiz0 = _mm_setzero_ps();
172 /* Load parameters for i particles */
173 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
174 isai0 = _mm_load1_ps(invsqrta+inr+0);
175 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
177 /* Reset potential sums */
178 velecsum = _mm_setzero_ps();
179 vgbsum = _mm_setzero_ps();
180 vvdwsum = _mm_setzero_ps();
181 dvdasum = _mm_setzero_ps();
183 /* Start inner kernel loop */
184 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
187 /* Get j neighbor index, and coordinate index */
192 j_coord_offsetA = DIM*jnrA;
193 j_coord_offsetB = DIM*jnrB;
194 j_coord_offsetC = DIM*jnrC;
195 j_coord_offsetD = DIM*jnrD;
197 /* load j atom coordinates */
198 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
199 x+j_coord_offsetC,x+j_coord_offsetD,
202 /* Calculate displacement vector */
203 dx00 = _mm_sub_ps(ix0,jx0);
204 dy00 = _mm_sub_ps(iy0,jy0);
205 dz00 = _mm_sub_ps(iz0,jz0);
207 /* Calculate squared distance and things based on it */
208 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
210 rinv00 = gmx_mm_invsqrt_ps(rsq00);
212 /* Load parameters for j particles */
213 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
214 charge+jnrC+0,charge+jnrD+0);
215 isaj0 = gmx_mm_load_4real_swizzle_ps(invsqrta+jnrA+0,invsqrta+jnrB+0,
216 invsqrta+jnrC+0,invsqrta+jnrD+0);
217 vdwjidx0A = 2*vdwtype[jnrA+0];
218 vdwjidx0B = 2*vdwtype[jnrB+0];
219 vdwjidx0C = 2*vdwtype[jnrC+0];
220 vdwjidx0D = 2*vdwtype[jnrD+0];
222 /**************************
223 * CALCULATE INTERACTIONS *
224 **************************/
226 r00 = _mm_mul_ps(rsq00,rinv00);
228 /* Compute parameters for interactions between i and j atoms */
229 qq00 = _mm_mul_ps(iq0,jq0);
230 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
231 vdwparam+vdwioffset0+vdwjidx0B,
232 vdwparam+vdwioffset0+vdwjidx0C,
233 vdwparam+vdwioffset0+vdwjidx0D,
236 /* Calculate table index by multiplying r with table scale and truncate to integer */
237 rt = _mm_mul_ps(r00,vftabscale);
238 vfitab = _mm_cvttps_epi32(rt);
239 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
240 vfitab = _mm_slli_epi32(vfitab,3);
242 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
243 isaprod = _mm_mul_ps(isai0,isaj0);
244 gbqqfactor = _mm_xor_ps(signbit,_mm_mul_ps(qq00,_mm_mul_ps(isaprod,gbinvepsdiff)));
245 gbscale = _mm_mul_ps(isaprod,gbtabscale);
247 /* Calculate generalized born table index - this is a separate table from the normal one,
248 * but we use the same procedure by multiplying r with scale and truncating to integer.
250 rt = _mm_mul_ps(r00,gbscale);
251 gbitab = _mm_cvttps_epi32(rt);
252 gbeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(gbitab));
253 gbitab = _mm_slli_epi32(gbitab,2);
255 Y = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,0) );
256 F = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,1) );
257 G = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,2) );
258 H = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,3) );
259 _MM_TRANSPOSE4_PS(Y,F,G,H);
260 Heps = _mm_mul_ps(gbeps,H);
261 Fp = _mm_add_ps(F,_mm_mul_ps(gbeps,_mm_add_ps(G,Heps)));
262 VV = _mm_add_ps(Y,_mm_mul_ps(gbeps,Fp));
263 vgb = _mm_mul_ps(gbqqfactor,VV);
265 FF = _mm_add_ps(Fp,_mm_mul_ps(gbeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
266 fgb = _mm_mul_ps(gbqqfactor,_mm_mul_ps(FF,gbscale));
267 dvdatmp = _mm_mul_ps(minushalf,_mm_add_ps(vgb,_mm_mul_ps(fgb,r00)));
268 dvdasum = _mm_add_ps(dvdasum,dvdatmp);
273 gmx_mm_increment_4real_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,_mm_mul_ps(dvdatmp,_mm_mul_ps(isaj0,isaj0)));
274 velec = _mm_mul_ps(qq00,rinv00);
275 felec = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(velec,rinv00),fgb),rinv00);
277 /* CUBIC SPLINE TABLE DISPERSION */
278 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
279 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
280 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
281 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
282 _MM_TRANSPOSE4_PS(Y,F,G,H);
283 Heps = _mm_mul_ps(vfeps,H);
284 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
285 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
286 vvdw6 = _mm_mul_ps(c6_00,VV);
287 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
288 fvdw6 = _mm_mul_ps(c6_00,FF);
290 /* CUBIC SPLINE TABLE REPULSION */
291 vfitab = _mm_add_epi32(vfitab,ifour);
292 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
293 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
294 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
295 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
296 _MM_TRANSPOSE4_PS(Y,F,G,H);
297 Heps = _mm_mul_ps(vfeps,H);
298 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
299 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
300 vvdw12 = _mm_mul_ps(c12_00,VV);
301 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
302 fvdw12 = _mm_mul_ps(c12_00,FF);
303 vvdw = _mm_add_ps(vvdw12,vvdw6);
304 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
306 /* Update potential sum for this i atom from the interaction with this j atom. */
307 velecsum = _mm_add_ps(velecsum,velec);
308 vgbsum = _mm_add_ps(vgbsum,vgb);
309 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
311 fscal = _mm_add_ps(felec,fvdw);
313 /* Calculate temporary vectorial force */
314 tx = _mm_mul_ps(fscal,dx00);
315 ty = _mm_mul_ps(fscal,dy00);
316 tz = _mm_mul_ps(fscal,dz00);
318 /* Update vectorial force */
319 fix0 = _mm_add_ps(fix0,tx);
320 fiy0 = _mm_add_ps(fiy0,ty);
321 fiz0 = _mm_add_ps(fiz0,tz);
323 fjptrA = f+j_coord_offsetA;
324 fjptrB = f+j_coord_offsetB;
325 fjptrC = f+j_coord_offsetC;
326 fjptrD = f+j_coord_offsetD;
327 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
329 /* Inner loop uses 92 flops */
335 /* Get j neighbor index, and coordinate index */
336 jnrlistA = jjnr[jidx];
337 jnrlistB = jjnr[jidx+1];
338 jnrlistC = jjnr[jidx+2];
339 jnrlistD = jjnr[jidx+3];
340 /* Sign of each element will be negative for non-real atoms.
341 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
342 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
344 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
345 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
346 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
347 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
348 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
349 j_coord_offsetA = DIM*jnrA;
350 j_coord_offsetB = DIM*jnrB;
351 j_coord_offsetC = DIM*jnrC;
352 j_coord_offsetD = DIM*jnrD;
354 /* load j atom coordinates */
355 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
356 x+j_coord_offsetC,x+j_coord_offsetD,
359 /* Calculate displacement vector */
360 dx00 = _mm_sub_ps(ix0,jx0);
361 dy00 = _mm_sub_ps(iy0,jy0);
362 dz00 = _mm_sub_ps(iz0,jz0);
364 /* Calculate squared distance and things based on it */
365 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
367 rinv00 = gmx_mm_invsqrt_ps(rsq00);
369 /* Load parameters for j particles */
370 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
371 charge+jnrC+0,charge+jnrD+0);
372 isaj0 = gmx_mm_load_4real_swizzle_ps(invsqrta+jnrA+0,invsqrta+jnrB+0,
373 invsqrta+jnrC+0,invsqrta+jnrD+0);
374 vdwjidx0A = 2*vdwtype[jnrA+0];
375 vdwjidx0B = 2*vdwtype[jnrB+0];
376 vdwjidx0C = 2*vdwtype[jnrC+0];
377 vdwjidx0D = 2*vdwtype[jnrD+0];
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
383 r00 = _mm_mul_ps(rsq00,rinv00);
384 r00 = _mm_andnot_ps(dummy_mask,r00);
386 /* Compute parameters for interactions between i and j atoms */
387 qq00 = _mm_mul_ps(iq0,jq0);
388 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
389 vdwparam+vdwioffset0+vdwjidx0B,
390 vdwparam+vdwioffset0+vdwjidx0C,
391 vdwparam+vdwioffset0+vdwjidx0D,
394 /* Calculate table index by multiplying r with table scale and truncate to integer */
395 rt = _mm_mul_ps(r00,vftabscale);
396 vfitab = _mm_cvttps_epi32(rt);
397 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
398 vfitab = _mm_slli_epi32(vfitab,3);
400 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
401 isaprod = _mm_mul_ps(isai0,isaj0);
402 gbqqfactor = _mm_xor_ps(signbit,_mm_mul_ps(qq00,_mm_mul_ps(isaprod,gbinvepsdiff)));
403 gbscale = _mm_mul_ps(isaprod,gbtabscale);
405 /* Calculate generalized born table index - this is a separate table from the normal one,
406 * but we use the same procedure by multiplying r with scale and truncating to integer.
408 rt = _mm_mul_ps(r00,gbscale);
409 gbitab = _mm_cvttps_epi32(rt);
410 gbeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(gbitab));
411 gbitab = _mm_slli_epi32(gbitab,2);
413 Y = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,0) );
414 F = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,1) );
415 G = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,2) );
416 H = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,3) );
417 _MM_TRANSPOSE4_PS(Y,F,G,H);
418 Heps = _mm_mul_ps(gbeps,H);
419 Fp = _mm_add_ps(F,_mm_mul_ps(gbeps,_mm_add_ps(G,Heps)));
420 VV = _mm_add_ps(Y,_mm_mul_ps(gbeps,Fp));
421 vgb = _mm_mul_ps(gbqqfactor,VV);
423 FF = _mm_add_ps(Fp,_mm_mul_ps(gbeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
424 fgb = _mm_mul_ps(gbqqfactor,_mm_mul_ps(FF,gbscale));
425 dvdatmp = _mm_mul_ps(minushalf,_mm_add_ps(vgb,_mm_mul_ps(fgb,r00)));
426 dvdasum = _mm_add_ps(dvdasum,dvdatmp);
427 /* The pointers to scratch make sure that this code with compilers that take gmx_restrict seriously (e.g. icc 13) really can't screw things up. */
428 fjptrA = (jnrlistA>=0) ? dvda+jnrA : scratch;
429 fjptrB = (jnrlistB>=0) ? dvda+jnrB : scratch;
430 fjptrC = (jnrlistC>=0) ? dvda+jnrC : scratch;
431 fjptrD = (jnrlistD>=0) ? dvda+jnrD : scratch;
432 gmx_mm_increment_4real_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,_mm_mul_ps(dvdatmp,_mm_mul_ps(isaj0,isaj0)));
433 velec = _mm_mul_ps(qq00,rinv00);
434 felec = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(velec,rinv00),fgb),rinv00);
436 /* CUBIC SPLINE TABLE DISPERSION */
437 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
438 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
439 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
440 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
441 _MM_TRANSPOSE4_PS(Y,F,G,H);
442 Heps = _mm_mul_ps(vfeps,H);
443 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
444 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
445 vvdw6 = _mm_mul_ps(c6_00,VV);
446 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
447 fvdw6 = _mm_mul_ps(c6_00,FF);
449 /* CUBIC SPLINE TABLE REPULSION */
450 vfitab = _mm_add_epi32(vfitab,ifour);
451 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
452 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
453 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
454 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
455 _MM_TRANSPOSE4_PS(Y,F,G,H);
456 Heps = _mm_mul_ps(vfeps,H);
457 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
458 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
459 vvdw12 = _mm_mul_ps(c12_00,VV);
460 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
461 fvdw12 = _mm_mul_ps(c12_00,FF);
462 vvdw = _mm_add_ps(vvdw12,vvdw6);
463 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
465 /* Update potential sum for this i atom from the interaction with this j atom. */
466 velec = _mm_andnot_ps(dummy_mask,velec);
467 velecsum = _mm_add_ps(velecsum,velec);
468 vgb = _mm_andnot_ps(dummy_mask,vgb);
469 vgbsum = _mm_add_ps(vgbsum,vgb);
470 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
471 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
473 fscal = _mm_add_ps(felec,fvdw);
475 fscal = _mm_andnot_ps(dummy_mask,fscal);
477 /* Calculate temporary vectorial force */
478 tx = _mm_mul_ps(fscal,dx00);
479 ty = _mm_mul_ps(fscal,dy00);
480 tz = _mm_mul_ps(fscal,dz00);
482 /* Update vectorial force */
483 fix0 = _mm_add_ps(fix0,tx);
484 fiy0 = _mm_add_ps(fiy0,ty);
485 fiz0 = _mm_add_ps(fiz0,tz);
487 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
488 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
489 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
490 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
491 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
493 /* Inner loop uses 93 flops */
496 /* End of innermost loop */
498 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
499 f+i_coord_offset,fshift+i_shift_offset);
502 /* Update potential energies */
503 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
504 gmx_mm_update_1pot_ps(vgbsum,kernel_data->energygrp_polarization+ggid);
505 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
506 dvdasum = _mm_mul_ps(dvdasum, _mm_mul_ps(isai0,isai0));
507 gmx_mm_update_1pot_ps(dvdasum,dvda+inr);
509 /* Increment number of inner iterations */
510 inneriter += j_index_end - j_index_start;
512 /* Outer loop uses 10 flops */
515 /* Increment number of outer iterations */
518 /* Update outer/inner flops */
520 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*10 + inneriter*93);
523 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_sse2_single
524 * Electrostatics interaction: GeneralizedBorn
525 * VdW interaction: CubicSplineTable
526 * Geometry: Particle-Particle
527 * Calculate force/pot: Force
530 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_sse2_single
531 (t_nblist * gmx_restrict nlist,
532 rvec * gmx_restrict xx,
533 rvec * gmx_restrict ff,
534 t_forcerec * gmx_restrict fr,
535 t_mdatoms * gmx_restrict mdatoms,
536 nb_kernel_data_t * gmx_restrict kernel_data,
537 t_nrnb * gmx_restrict nrnb)
539 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
540 * just 0 for non-waters.
541 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
542 * jnr indices corresponding to data put in the four positions in the SIMD register.
544 int i_shift_offset,i_coord_offset,outeriter,inneriter;
545 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
546 int jnrA,jnrB,jnrC,jnrD;
547 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
548 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
549 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
551 real *shiftvec,*fshift,*x,*f;
552 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
554 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
556 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
557 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
558 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
559 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
560 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
563 __m128 vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,gbeps,dvdatmp;
564 __m128 minushalf = _mm_set1_ps(-0.5);
565 real *invsqrta,*dvda,*gbtab;
567 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
570 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
571 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
573 __m128i ifour = _mm_set1_epi32(4);
574 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
576 __m128 dummy_mask,cutoff_mask;
577 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
578 __m128 one = _mm_set1_ps(1.0);
579 __m128 two = _mm_set1_ps(2.0);
585 jindex = nlist->jindex;
587 shiftidx = nlist->shift;
589 shiftvec = fr->shift_vec[0];
590 fshift = fr->fshift[0];
591 facel = _mm_set1_ps(fr->epsfac);
592 charge = mdatoms->chargeA;
593 nvdwtype = fr->ntype;
595 vdwtype = mdatoms->typeA;
597 vftab = kernel_data->table_vdw->data;
598 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
600 invsqrta = fr->invsqrta;
602 gbtabscale = _mm_set1_ps(fr->gbtab.scale);
603 gbtab = fr->gbtab.data;
604 gbinvepsdiff = _mm_set1_ps((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
606 /* Avoid stupid compiler warnings */
607 jnrA = jnrB = jnrC = jnrD = 0;
616 for(iidx=0;iidx<4*DIM;iidx++)
621 /* Start outer loop over neighborlists */
622 for(iidx=0; iidx<nri; iidx++)
624 /* Load shift vector for this list */
625 i_shift_offset = DIM*shiftidx[iidx];
627 /* Load limits for loop over neighbors */
628 j_index_start = jindex[iidx];
629 j_index_end = jindex[iidx+1];
631 /* Get outer coordinate index */
633 i_coord_offset = DIM*inr;
635 /* Load i particle coords and add shift vector */
636 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
638 fix0 = _mm_setzero_ps();
639 fiy0 = _mm_setzero_ps();
640 fiz0 = _mm_setzero_ps();
642 /* Load parameters for i particles */
643 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
644 isai0 = _mm_load1_ps(invsqrta+inr+0);
645 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
647 dvdasum = _mm_setzero_ps();
649 /* Start inner kernel loop */
650 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
653 /* Get j neighbor index, and coordinate index */
658 j_coord_offsetA = DIM*jnrA;
659 j_coord_offsetB = DIM*jnrB;
660 j_coord_offsetC = DIM*jnrC;
661 j_coord_offsetD = DIM*jnrD;
663 /* load j atom coordinates */
664 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
665 x+j_coord_offsetC,x+j_coord_offsetD,
668 /* Calculate displacement vector */
669 dx00 = _mm_sub_ps(ix0,jx0);
670 dy00 = _mm_sub_ps(iy0,jy0);
671 dz00 = _mm_sub_ps(iz0,jz0);
673 /* Calculate squared distance and things based on it */
674 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
676 rinv00 = gmx_mm_invsqrt_ps(rsq00);
678 /* Load parameters for j particles */
679 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
680 charge+jnrC+0,charge+jnrD+0);
681 isaj0 = gmx_mm_load_4real_swizzle_ps(invsqrta+jnrA+0,invsqrta+jnrB+0,
682 invsqrta+jnrC+0,invsqrta+jnrD+0);
683 vdwjidx0A = 2*vdwtype[jnrA+0];
684 vdwjidx0B = 2*vdwtype[jnrB+0];
685 vdwjidx0C = 2*vdwtype[jnrC+0];
686 vdwjidx0D = 2*vdwtype[jnrD+0];
688 /**************************
689 * CALCULATE INTERACTIONS *
690 **************************/
692 r00 = _mm_mul_ps(rsq00,rinv00);
694 /* Compute parameters for interactions between i and j atoms */
695 qq00 = _mm_mul_ps(iq0,jq0);
696 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
697 vdwparam+vdwioffset0+vdwjidx0B,
698 vdwparam+vdwioffset0+vdwjidx0C,
699 vdwparam+vdwioffset0+vdwjidx0D,
702 /* Calculate table index by multiplying r with table scale and truncate to integer */
703 rt = _mm_mul_ps(r00,vftabscale);
704 vfitab = _mm_cvttps_epi32(rt);
705 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
706 vfitab = _mm_slli_epi32(vfitab,3);
708 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
709 isaprod = _mm_mul_ps(isai0,isaj0);
710 gbqqfactor = _mm_xor_ps(signbit,_mm_mul_ps(qq00,_mm_mul_ps(isaprod,gbinvepsdiff)));
711 gbscale = _mm_mul_ps(isaprod,gbtabscale);
713 /* Calculate generalized born table index - this is a separate table from the normal one,
714 * but we use the same procedure by multiplying r with scale and truncating to integer.
716 rt = _mm_mul_ps(r00,gbscale);
717 gbitab = _mm_cvttps_epi32(rt);
718 gbeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(gbitab));
719 gbitab = _mm_slli_epi32(gbitab,2);
721 Y = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,0) );
722 F = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,1) );
723 G = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,2) );
724 H = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,3) );
725 _MM_TRANSPOSE4_PS(Y,F,G,H);
726 Heps = _mm_mul_ps(gbeps,H);
727 Fp = _mm_add_ps(F,_mm_mul_ps(gbeps,_mm_add_ps(G,Heps)));
728 VV = _mm_add_ps(Y,_mm_mul_ps(gbeps,Fp));
729 vgb = _mm_mul_ps(gbqqfactor,VV);
731 FF = _mm_add_ps(Fp,_mm_mul_ps(gbeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
732 fgb = _mm_mul_ps(gbqqfactor,_mm_mul_ps(FF,gbscale));
733 dvdatmp = _mm_mul_ps(minushalf,_mm_add_ps(vgb,_mm_mul_ps(fgb,r00)));
734 dvdasum = _mm_add_ps(dvdasum,dvdatmp);
739 gmx_mm_increment_4real_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,_mm_mul_ps(dvdatmp,_mm_mul_ps(isaj0,isaj0)));
740 velec = _mm_mul_ps(qq00,rinv00);
741 felec = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(velec,rinv00),fgb),rinv00);
743 /* CUBIC SPLINE TABLE DISPERSION */
744 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
745 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
746 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
747 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
748 _MM_TRANSPOSE4_PS(Y,F,G,H);
749 Heps = _mm_mul_ps(vfeps,H);
750 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
751 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
752 fvdw6 = _mm_mul_ps(c6_00,FF);
754 /* CUBIC SPLINE TABLE REPULSION */
755 vfitab = _mm_add_epi32(vfitab,ifour);
756 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
757 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
758 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
759 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
760 _MM_TRANSPOSE4_PS(Y,F,G,H);
761 Heps = _mm_mul_ps(vfeps,H);
762 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
763 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
764 fvdw12 = _mm_mul_ps(c12_00,FF);
765 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
767 fscal = _mm_add_ps(felec,fvdw);
769 /* Calculate temporary vectorial force */
770 tx = _mm_mul_ps(fscal,dx00);
771 ty = _mm_mul_ps(fscal,dy00);
772 tz = _mm_mul_ps(fscal,dz00);
774 /* Update vectorial force */
775 fix0 = _mm_add_ps(fix0,tx);
776 fiy0 = _mm_add_ps(fiy0,ty);
777 fiz0 = _mm_add_ps(fiz0,tz);
779 fjptrA = f+j_coord_offsetA;
780 fjptrB = f+j_coord_offsetB;
781 fjptrC = f+j_coord_offsetC;
782 fjptrD = f+j_coord_offsetD;
783 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
785 /* Inner loop uses 82 flops */
791 /* Get j neighbor index, and coordinate index */
792 jnrlistA = jjnr[jidx];
793 jnrlistB = jjnr[jidx+1];
794 jnrlistC = jjnr[jidx+2];
795 jnrlistD = jjnr[jidx+3];
796 /* Sign of each element will be negative for non-real atoms.
797 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
798 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
800 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
801 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
802 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
803 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
804 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
805 j_coord_offsetA = DIM*jnrA;
806 j_coord_offsetB = DIM*jnrB;
807 j_coord_offsetC = DIM*jnrC;
808 j_coord_offsetD = DIM*jnrD;
810 /* load j atom coordinates */
811 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
812 x+j_coord_offsetC,x+j_coord_offsetD,
815 /* Calculate displacement vector */
816 dx00 = _mm_sub_ps(ix0,jx0);
817 dy00 = _mm_sub_ps(iy0,jy0);
818 dz00 = _mm_sub_ps(iz0,jz0);
820 /* Calculate squared distance and things based on it */
821 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
823 rinv00 = gmx_mm_invsqrt_ps(rsq00);
825 /* Load parameters for j particles */
826 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
827 charge+jnrC+0,charge+jnrD+0);
828 isaj0 = gmx_mm_load_4real_swizzle_ps(invsqrta+jnrA+0,invsqrta+jnrB+0,
829 invsqrta+jnrC+0,invsqrta+jnrD+0);
830 vdwjidx0A = 2*vdwtype[jnrA+0];
831 vdwjidx0B = 2*vdwtype[jnrB+0];
832 vdwjidx0C = 2*vdwtype[jnrC+0];
833 vdwjidx0D = 2*vdwtype[jnrD+0];
835 /**************************
836 * CALCULATE INTERACTIONS *
837 **************************/
839 r00 = _mm_mul_ps(rsq00,rinv00);
840 r00 = _mm_andnot_ps(dummy_mask,r00);
842 /* Compute parameters for interactions between i and j atoms */
843 qq00 = _mm_mul_ps(iq0,jq0);
844 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
845 vdwparam+vdwioffset0+vdwjidx0B,
846 vdwparam+vdwioffset0+vdwjidx0C,
847 vdwparam+vdwioffset0+vdwjidx0D,
850 /* Calculate table index by multiplying r with table scale and truncate to integer */
851 rt = _mm_mul_ps(r00,vftabscale);
852 vfitab = _mm_cvttps_epi32(rt);
853 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
854 vfitab = _mm_slli_epi32(vfitab,3);
856 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
857 isaprod = _mm_mul_ps(isai0,isaj0);
858 gbqqfactor = _mm_xor_ps(signbit,_mm_mul_ps(qq00,_mm_mul_ps(isaprod,gbinvepsdiff)));
859 gbscale = _mm_mul_ps(isaprod,gbtabscale);
861 /* Calculate generalized born table index - this is a separate table from the normal one,
862 * but we use the same procedure by multiplying r with scale and truncating to integer.
864 rt = _mm_mul_ps(r00,gbscale);
865 gbitab = _mm_cvttps_epi32(rt);
866 gbeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(gbitab));
867 gbitab = _mm_slli_epi32(gbitab,2);
869 Y = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,0) );
870 F = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,1) );
871 G = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,2) );
872 H = _mm_load_ps( gbtab + gmx_mm_extract_epi32(gbitab,3) );
873 _MM_TRANSPOSE4_PS(Y,F,G,H);
874 Heps = _mm_mul_ps(gbeps,H);
875 Fp = _mm_add_ps(F,_mm_mul_ps(gbeps,_mm_add_ps(G,Heps)));
876 VV = _mm_add_ps(Y,_mm_mul_ps(gbeps,Fp));
877 vgb = _mm_mul_ps(gbqqfactor,VV);
879 FF = _mm_add_ps(Fp,_mm_mul_ps(gbeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
880 fgb = _mm_mul_ps(gbqqfactor,_mm_mul_ps(FF,gbscale));
881 dvdatmp = _mm_mul_ps(minushalf,_mm_add_ps(vgb,_mm_mul_ps(fgb,r00)));
882 dvdasum = _mm_add_ps(dvdasum,dvdatmp);
883 /* The pointers to scratch make sure that this code with compilers that take gmx_restrict seriously (e.g. icc 13) really can't screw things up. */
884 fjptrA = (jnrlistA>=0) ? dvda+jnrA : scratch;
885 fjptrB = (jnrlistB>=0) ? dvda+jnrB : scratch;
886 fjptrC = (jnrlistC>=0) ? dvda+jnrC : scratch;
887 fjptrD = (jnrlistD>=0) ? dvda+jnrD : scratch;
888 gmx_mm_increment_4real_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,_mm_mul_ps(dvdatmp,_mm_mul_ps(isaj0,isaj0)));
889 velec = _mm_mul_ps(qq00,rinv00);
890 felec = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(velec,rinv00),fgb),rinv00);
892 /* CUBIC SPLINE TABLE DISPERSION */
893 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
894 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
895 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
896 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
897 _MM_TRANSPOSE4_PS(Y,F,G,H);
898 Heps = _mm_mul_ps(vfeps,H);
899 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
900 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
901 fvdw6 = _mm_mul_ps(c6_00,FF);
903 /* CUBIC SPLINE TABLE REPULSION */
904 vfitab = _mm_add_epi32(vfitab,ifour);
905 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
906 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
907 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
908 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
909 _MM_TRANSPOSE4_PS(Y,F,G,H);
910 Heps = _mm_mul_ps(vfeps,H);
911 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
912 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
913 fvdw12 = _mm_mul_ps(c12_00,FF);
914 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
916 fscal = _mm_add_ps(felec,fvdw);
918 fscal = _mm_andnot_ps(dummy_mask,fscal);
920 /* Calculate temporary vectorial force */
921 tx = _mm_mul_ps(fscal,dx00);
922 ty = _mm_mul_ps(fscal,dy00);
923 tz = _mm_mul_ps(fscal,dz00);
925 /* Update vectorial force */
926 fix0 = _mm_add_ps(fix0,tx);
927 fiy0 = _mm_add_ps(fiy0,ty);
928 fiz0 = _mm_add_ps(fiz0,tz);
930 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
931 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
932 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
933 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
934 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
936 /* Inner loop uses 83 flops */
939 /* End of innermost loop */
941 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
942 f+i_coord_offset,fshift+i_shift_offset);
944 dvdasum = _mm_mul_ps(dvdasum, _mm_mul_ps(isai0,isai0));
945 gmx_mm_update_1pot_ps(dvdasum,dvda+inr);
947 /* Increment number of inner iterations */
948 inneriter += j_index_end - j_index_start;
950 /* Outer loop uses 7 flops */
953 /* Increment number of outer iterations */
956 /* Update outer/inner flops */
958 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*83);