2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS sse2_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "gromacs/simd/math_x86_sse2_double.h"
48 #include "kernelutil_x86_sse2_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEw_GeomP1P1_VF_sse2_double
52 * Electrostatics interaction: None
53 * VdW interaction: LJEwald
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwLJEw_GeomP1P1_VF_sse2_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 int vdwjidx0A,vdwjidx0B;
83 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
84 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
89 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
90 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
92 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
94 __m128d one_half = _mm_set1_pd(0.5);
95 __m128d minus_one = _mm_set1_pd(-1.0);
96 __m128d dummy_mask,cutoff_mask;
97 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
98 __m128d one = _mm_set1_pd(1.0);
99 __m128d two = _mm_set1_pd(2.0);
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
111 nvdwtype = fr->ntype;
113 vdwtype = mdatoms->typeA;
114 vdwgridparam = fr->ljpme_c6grid;
115 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
116 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
117 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
119 /* Avoid stupid compiler warnings */
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
144 fix0 = _mm_setzero_pd();
145 fiy0 = _mm_setzero_pd();
146 fiz0 = _mm_setzero_pd();
148 /* Load parameters for i particles */
149 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
151 /* Reset potential sums */
152 vvdwsum = _mm_setzero_pd();
154 /* Start inner kernel loop */
155 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
158 /* Get j neighbor index, and coordinate index */
161 j_coord_offsetA = DIM*jnrA;
162 j_coord_offsetB = DIM*jnrB;
164 /* load j atom coordinates */
165 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
168 /* Calculate displacement vector */
169 dx00 = _mm_sub_pd(ix0,jx0);
170 dy00 = _mm_sub_pd(iy0,jy0);
171 dz00 = _mm_sub_pd(iz0,jz0);
173 /* Calculate squared distance and things based on it */
174 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
176 rinv00 = gmx_mm_invsqrt_pd(rsq00);
178 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
180 /* Load parameters for j particles */
181 vdwjidx0A = 2*vdwtype[jnrA+0];
182 vdwjidx0B = 2*vdwtype[jnrB+0];
184 /**************************
185 * CALCULATE INTERACTIONS *
186 **************************/
188 r00 = _mm_mul_pd(rsq00,rinv00);
190 /* Compute parameters for interactions between i and j atoms */
191 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
192 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
194 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
195 vdwgridparam+vdwioffset0+vdwjidx0B);
197 /* Analytical LJ-PME */
198 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
199 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
200 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
201 exponent = gmx_simd_exp_d(ewcljrsq);
202 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
203 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
204 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
205 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
206 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
207 vvdw = _mm_sub_pd(_mm_mul_pd(vvdw12,one_twelfth),_mm_mul_pd(vvdw6,one_sixth));
208 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
209 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,_mm_sub_pd(vvdw6,_mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6)))),rinvsq00);
211 /* Update potential sum for this i atom from the interaction with this j atom. */
212 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
216 /* Calculate temporary vectorial force */
217 tx = _mm_mul_pd(fscal,dx00);
218 ty = _mm_mul_pd(fscal,dy00);
219 tz = _mm_mul_pd(fscal,dz00);
221 /* Update vectorial force */
222 fix0 = _mm_add_pd(fix0,tx);
223 fiy0 = _mm_add_pd(fiy0,ty);
224 fiz0 = _mm_add_pd(fiz0,tz);
226 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
228 /* Inner loop uses 51 flops */
235 j_coord_offsetA = DIM*jnrA;
237 /* load j atom coordinates */
238 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
241 /* Calculate displacement vector */
242 dx00 = _mm_sub_pd(ix0,jx0);
243 dy00 = _mm_sub_pd(iy0,jy0);
244 dz00 = _mm_sub_pd(iz0,jz0);
246 /* Calculate squared distance and things based on it */
247 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
249 rinv00 = gmx_mm_invsqrt_pd(rsq00);
251 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
253 /* Load parameters for j particles */
254 vdwjidx0A = 2*vdwtype[jnrA+0];
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
260 r00 = _mm_mul_pd(rsq00,rinv00);
262 /* Compute parameters for interactions between i and j atoms */
263 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
265 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
267 /* Analytical LJ-PME */
268 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
269 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
270 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
271 exponent = gmx_simd_exp_d(ewcljrsq);
272 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
273 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
274 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
275 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
276 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
277 vvdw = _mm_sub_pd(_mm_mul_pd(vvdw12,one_twelfth),_mm_mul_pd(vvdw6,one_sixth));
278 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
279 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,_mm_sub_pd(vvdw6,_mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6)))),rinvsq00);
281 /* Update potential sum for this i atom from the interaction with this j atom. */
282 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
283 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
287 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
289 /* Calculate temporary vectorial force */
290 tx = _mm_mul_pd(fscal,dx00);
291 ty = _mm_mul_pd(fscal,dy00);
292 tz = _mm_mul_pd(fscal,dz00);
294 /* Update vectorial force */
295 fix0 = _mm_add_pd(fix0,tx);
296 fiy0 = _mm_add_pd(fiy0,ty);
297 fiz0 = _mm_add_pd(fiz0,tz);
299 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
301 /* Inner loop uses 51 flops */
304 /* End of innermost loop */
306 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
307 f+i_coord_offset,fshift+i_shift_offset);
310 /* Update potential energies */
311 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
313 /* Increment number of inner iterations */
314 inneriter += j_index_end - j_index_start;
316 /* Outer loop uses 7 flops */
319 /* Increment number of outer iterations */
322 /* Update outer/inner flops */
324 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*51);
327 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEw_GeomP1P1_F_sse2_double
328 * Electrostatics interaction: None
329 * VdW interaction: LJEwald
330 * Geometry: Particle-Particle
331 * Calculate force/pot: Force
334 nb_kernel_ElecNone_VdwLJEw_GeomP1P1_F_sse2_double
335 (t_nblist * gmx_restrict nlist,
336 rvec * gmx_restrict xx,
337 rvec * gmx_restrict ff,
338 t_forcerec * gmx_restrict fr,
339 t_mdatoms * gmx_restrict mdatoms,
340 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
341 t_nrnb * gmx_restrict nrnb)
343 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
344 * just 0 for non-waters.
345 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
346 * jnr indices corresponding to data put in the four positions in the SIMD register.
348 int i_shift_offset,i_coord_offset,outeriter,inneriter;
349 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
351 int j_coord_offsetA,j_coord_offsetB;
352 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
354 real *shiftvec,*fshift,*x,*f;
355 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
357 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
358 int vdwjidx0A,vdwjidx0B;
359 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
360 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
362 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
365 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
366 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
368 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
370 __m128d one_half = _mm_set1_pd(0.5);
371 __m128d minus_one = _mm_set1_pd(-1.0);
372 __m128d dummy_mask,cutoff_mask;
373 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
374 __m128d one = _mm_set1_pd(1.0);
375 __m128d two = _mm_set1_pd(2.0);
381 jindex = nlist->jindex;
383 shiftidx = nlist->shift;
385 shiftvec = fr->shift_vec[0];
386 fshift = fr->fshift[0];
387 nvdwtype = fr->ntype;
389 vdwtype = mdatoms->typeA;
390 vdwgridparam = fr->ljpme_c6grid;
391 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
392 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
393 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
395 /* Avoid stupid compiler warnings */
403 /* Start outer loop over neighborlists */
404 for(iidx=0; iidx<nri; iidx++)
406 /* Load shift vector for this list */
407 i_shift_offset = DIM*shiftidx[iidx];
409 /* Load limits for loop over neighbors */
410 j_index_start = jindex[iidx];
411 j_index_end = jindex[iidx+1];
413 /* Get outer coordinate index */
415 i_coord_offset = DIM*inr;
417 /* Load i particle coords and add shift vector */
418 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
420 fix0 = _mm_setzero_pd();
421 fiy0 = _mm_setzero_pd();
422 fiz0 = _mm_setzero_pd();
424 /* Load parameters for i particles */
425 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
427 /* Start inner kernel loop */
428 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
431 /* Get j neighbor index, and coordinate index */
434 j_coord_offsetA = DIM*jnrA;
435 j_coord_offsetB = DIM*jnrB;
437 /* load j atom coordinates */
438 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
441 /* Calculate displacement vector */
442 dx00 = _mm_sub_pd(ix0,jx0);
443 dy00 = _mm_sub_pd(iy0,jy0);
444 dz00 = _mm_sub_pd(iz0,jz0);
446 /* Calculate squared distance and things based on it */
447 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
449 rinv00 = gmx_mm_invsqrt_pd(rsq00);
451 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
453 /* Load parameters for j particles */
454 vdwjidx0A = 2*vdwtype[jnrA+0];
455 vdwjidx0B = 2*vdwtype[jnrB+0];
457 /**************************
458 * CALCULATE INTERACTIONS *
459 **************************/
461 r00 = _mm_mul_pd(rsq00,rinv00);
463 /* Compute parameters for interactions between i and j atoms */
464 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
465 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
467 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
468 vdwgridparam+vdwioffset0+vdwjidx0B);
470 /* Analytical LJ-PME */
471 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
472 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
473 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
474 exponent = gmx_simd_exp_d(ewcljrsq);
475 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
476 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
477 /* f6A = 6 * C6grid * (1 - poly) */
478 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
479 /* f6B = C6grid * exponent * beta^6 */
480 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
481 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
482 fvdw = _mm_mul_pd(_mm_add_pd(_mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),_mm_sub_pd(c6_00,f6A)),rinvsix),f6B),rinvsq00);
486 /* Calculate temporary vectorial force */
487 tx = _mm_mul_pd(fscal,dx00);
488 ty = _mm_mul_pd(fscal,dy00);
489 tz = _mm_mul_pd(fscal,dz00);
491 /* Update vectorial force */
492 fix0 = _mm_add_pd(fix0,tx);
493 fiy0 = _mm_add_pd(fiy0,ty);
494 fiz0 = _mm_add_pd(fiz0,tz);
496 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
498 /* Inner loop uses 46 flops */
505 j_coord_offsetA = DIM*jnrA;
507 /* load j atom coordinates */
508 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
511 /* Calculate displacement vector */
512 dx00 = _mm_sub_pd(ix0,jx0);
513 dy00 = _mm_sub_pd(iy0,jy0);
514 dz00 = _mm_sub_pd(iz0,jz0);
516 /* Calculate squared distance and things based on it */
517 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
519 rinv00 = gmx_mm_invsqrt_pd(rsq00);
521 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
523 /* Load parameters for j particles */
524 vdwjidx0A = 2*vdwtype[jnrA+0];
526 /**************************
527 * CALCULATE INTERACTIONS *
528 **************************/
530 r00 = _mm_mul_pd(rsq00,rinv00);
532 /* Compute parameters for interactions between i and j atoms */
533 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
535 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
537 /* Analytical LJ-PME */
538 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
539 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
540 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
541 exponent = gmx_simd_exp_d(ewcljrsq);
542 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
543 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
544 /* f6A = 6 * C6grid * (1 - poly) */
545 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
546 /* f6B = C6grid * exponent * beta^6 */
547 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
548 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
549 fvdw = _mm_mul_pd(_mm_add_pd(_mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),_mm_sub_pd(c6_00,f6A)),rinvsix),f6B),rinvsq00);
553 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
555 /* Calculate temporary vectorial force */
556 tx = _mm_mul_pd(fscal,dx00);
557 ty = _mm_mul_pd(fscal,dy00);
558 tz = _mm_mul_pd(fscal,dz00);
560 /* Update vectorial force */
561 fix0 = _mm_add_pd(fix0,tx);
562 fiy0 = _mm_add_pd(fiy0,ty);
563 fiz0 = _mm_add_pd(fiz0,tz);
565 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
567 /* Inner loop uses 46 flops */
570 /* End of innermost loop */
572 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
573 f+i_coord_offset,fshift+i_shift_offset);
575 /* Increment number of inner iterations */
576 inneriter += j_index_end - j_index_start;
578 /* Outer loop uses 6 flops */
581 /* Increment number of outer iterations */
584 /* Update outer/inner flops */
586 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*46);