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 sse4_1_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse4_1_double.h"
48 #include "kernelutil_x86_sse4_1_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_VF_sse4_1_double
52 * Electrostatics interaction: None
53 * VdW interaction: LJEwald
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_VF_sse4_1_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 rcutoff_scalar = fr->rvdw;
120 rcutoff = _mm_set1_pd(rcutoff_scalar);
121 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
123 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
124 rvdw = _mm_set1_pd(fr->rvdw);
126 /* Avoid stupid compiler warnings */
134 /* Start outer loop over neighborlists */
135 for(iidx=0; iidx<nri; iidx++)
137 /* Load shift vector for this list */
138 i_shift_offset = DIM*shiftidx[iidx];
140 /* Load limits for loop over neighbors */
141 j_index_start = jindex[iidx];
142 j_index_end = jindex[iidx+1];
144 /* Get outer coordinate index */
146 i_coord_offset = DIM*inr;
148 /* Load i particle coords and add shift vector */
149 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
151 fix0 = _mm_setzero_pd();
152 fiy0 = _mm_setzero_pd();
153 fiz0 = _mm_setzero_pd();
155 /* Load parameters for i particles */
156 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
158 /* Reset potential sums */
159 vvdwsum = _mm_setzero_pd();
161 /* Start inner kernel loop */
162 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
165 /* Get j neighbor index, and coordinate index */
168 j_coord_offsetA = DIM*jnrA;
169 j_coord_offsetB = DIM*jnrB;
171 /* load j atom coordinates */
172 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
175 /* Calculate displacement vector */
176 dx00 = _mm_sub_pd(ix0,jx0);
177 dy00 = _mm_sub_pd(iy0,jy0);
178 dz00 = _mm_sub_pd(iz0,jz0);
180 /* Calculate squared distance and things based on it */
181 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
183 rinv00 = gmx_mm_invsqrt_pd(rsq00);
185 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
187 /* Load parameters for j particles */
188 vdwjidx0A = 2*vdwtype[jnrA+0];
189 vdwjidx0B = 2*vdwtype[jnrB+0];
191 /**************************
192 * CALCULATE INTERACTIONS *
193 **************************/
195 if (gmx_mm_any_lt(rsq00,rcutoff2))
198 r00 = _mm_mul_pd(rsq00,rinv00);
200 /* Compute parameters for interactions between i and j atoms */
201 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
202 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
203 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
204 vdwgridparam+vdwioffset0+vdwjidx0B);
206 /* Analytical LJ-PME */
207 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
208 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
209 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
210 exponent = gmx_simd_exp_d(ewcljrsq);
211 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
212 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
213 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
214 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
215 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
216 vvdw = _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12 , _mm_mul_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))),one_twelfth),
217 _mm_mul_pd( _mm_sub_pd(vvdw6,_mm_add_pd(_mm_mul_pd(c6_00,sh_vdw_invrcut6),_mm_mul_pd(c6grid_00,sh_lj_ewald))),one_sixth));
218 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
219 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);
221 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
223 /* Update potential sum for this i atom from the interaction with this j atom. */
224 vvdw = _mm_and_pd(vvdw,cutoff_mask);
225 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
229 fscal = _mm_and_pd(fscal,cutoff_mask);
231 /* Calculate temporary vectorial force */
232 tx = _mm_mul_pd(fscal,dx00);
233 ty = _mm_mul_pd(fscal,dy00);
234 tz = _mm_mul_pd(fscal,dz00);
236 /* Update vectorial force */
237 fix0 = _mm_add_pd(fix0,tx);
238 fiy0 = _mm_add_pd(fiy0,ty);
239 fiz0 = _mm_add_pd(fiz0,tz);
241 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
245 /* Inner loop uses 61 flops */
252 j_coord_offsetA = DIM*jnrA;
254 /* load j atom coordinates */
255 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
258 /* Calculate displacement vector */
259 dx00 = _mm_sub_pd(ix0,jx0);
260 dy00 = _mm_sub_pd(iy0,jy0);
261 dz00 = _mm_sub_pd(iz0,jz0);
263 /* Calculate squared distance and things based on it */
264 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
266 rinv00 = gmx_mm_invsqrt_pd(rsq00);
268 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
270 /* Load parameters for j particles */
271 vdwjidx0A = 2*vdwtype[jnrA+0];
273 /**************************
274 * CALCULATE INTERACTIONS *
275 **************************/
277 if (gmx_mm_any_lt(rsq00,rcutoff2))
280 r00 = _mm_mul_pd(rsq00,rinv00);
282 /* Compute parameters for interactions between i and j atoms */
283 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
285 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
287 /* Analytical LJ-PME */
288 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
289 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
290 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
291 exponent = gmx_simd_exp_d(ewcljrsq);
292 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
293 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
294 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
295 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
296 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
297 vvdw = _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12 , _mm_mul_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))),one_twelfth),
298 _mm_mul_pd( _mm_sub_pd(vvdw6,_mm_add_pd(_mm_mul_pd(c6_00,sh_vdw_invrcut6),_mm_mul_pd(c6grid_00,sh_lj_ewald))),one_sixth));
299 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
300 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);
302 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
304 /* Update potential sum for this i atom from the interaction with this j atom. */
305 vvdw = _mm_and_pd(vvdw,cutoff_mask);
306 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
307 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
311 fscal = _mm_and_pd(fscal,cutoff_mask);
313 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
315 /* Calculate temporary vectorial force */
316 tx = _mm_mul_pd(fscal,dx00);
317 ty = _mm_mul_pd(fscal,dy00);
318 tz = _mm_mul_pd(fscal,dz00);
320 /* Update vectorial force */
321 fix0 = _mm_add_pd(fix0,tx);
322 fiy0 = _mm_add_pd(fiy0,ty);
323 fiz0 = _mm_add_pd(fiz0,tz);
325 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
329 /* Inner loop uses 61 flops */
332 /* End of innermost loop */
334 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
335 f+i_coord_offset,fshift+i_shift_offset);
338 /* Update potential energies */
339 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
341 /* Increment number of inner iterations */
342 inneriter += j_index_end - j_index_start;
344 /* Outer loop uses 7 flops */
347 /* Increment number of outer iterations */
350 /* Update outer/inner flops */
352 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*61);
355 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse4_1_double
356 * Electrostatics interaction: None
357 * VdW interaction: LJEwald
358 * Geometry: Particle-Particle
359 * Calculate force/pot: Force
362 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse4_1_double
363 (t_nblist * gmx_restrict nlist,
364 rvec * gmx_restrict xx,
365 rvec * gmx_restrict ff,
366 t_forcerec * gmx_restrict fr,
367 t_mdatoms * gmx_restrict mdatoms,
368 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
369 t_nrnb * gmx_restrict nrnb)
371 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
372 * just 0 for non-waters.
373 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
374 * jnr indices corresponding to data put in the four positions in the SIMD register.
376 int i_shift_offset,i_coord_offset,outeriter,inneriter;
377 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
379 int j_coord_offsetA,j_coord_offsetB;
380 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
382 real *shiftvec,*fshift,*x,*f;
383 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
385 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
386 int vdwjidx0A,vdwjidx0B;
387 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
388 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
390 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
393 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
394 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
396 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
398 __m128d one_half = _mm_set1_pd(0.5);
399 __m128d minus_one = _mm_set1_pd(-1.0);
400 __m128d dummy_mask,cutoff_mask;
401 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
402 __m128d one = _mm_set1_pd(1.0);
403 __m128d two = _mm_set1_pd(2.0);
409 jindex = nlist->jindex;
411 shiftidx = nlist->shift;
413 shiftvec = fr->shift_vec[0];
414 fshift = fr->fshift[0];
415 nvdwtype = fr->ntype;
417 vdwtype = mdatoms->typeA;
418 vdwgridparam = fr->ljpme_c6grid;
419 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
420 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
421 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
423 rcutoff_scalar = fr->rvdw;
424 rcutoff = _mm_set1_pd(rcutoff_scalar);
425 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
427 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
428 rvdw = _mm_set1_pd(fr->rvdw);
430 /* Avoid stupid compiler warnings */
438 /* Start outer loop over neighborlists */
439 for(iidx=0; iidx<nri; iidx++)
441 /* Load shift vector for this list */
442 i_shift_offset = DIM*shiftidx[iidx];
444 /* Load limits for loop over neighbors */
445 j_index_start = jindex[iidx];
446 j_index_end = jindex[iidx+1];
448 /* Get outer coordinate index */
450 i_coord_offset = DIM*inr;
452 /* Load i particle coords and add shift vector */
453 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
455 fix0 = _mm_setzero_pd();
456 fiy0 = _mm_setzero_pd();
457 fiz0 = _mm_setzero_pd();
459 /* Load parameters for i particles */
460 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
462 /* Start inner kernel loop */
463 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
466 /* Get j neighbor index, and coordinate index */
469 j_coord_offsetA = DIM*jnrA;
470 j_coord_offsetB = DIM*jnrB;
472 /* load j atom coordinates */
473 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
476 /* Calculate displacement vector */
477 dx00 = _mm_sub_pd(ix0,jx0);
478 dy00 = _mm_sub_pd(iy0,jy0);
479 dz00 = _mm_sub_pd(iz0,jz0);
481 /* Calculate squared distance and things based on it */
482 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
484 rinv00 = gmx_mm_invsqrt_pd(rsq00);
486 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
488 /* Load parameters for j particles */
489 vdwjidx0A = 2*vdwtype[jnrA+0];
490 vdwjidx0B = 2*vdwtype[jnrB+0];
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
496 if (gmx_mm_any_lt(rsq00,rcutoff2))
499 r00 = _mm_mul_pd(rsq00,rinv00);
501 /* Compute parameters for interactions between i and j atoms */
502 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
503 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
504 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
505 vdwgridparam+vdwioffset0+vdwjidx0B);
507 /* Analytical LJ-PME */
508 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
509 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
510 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
511 exponent = gmx_simd_exp_d(ewcljrsq);
512 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
513 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
514 /* f6A = 6 * C6grid * (1 - poly) */
515 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
516 /* f6B = C6grid * exponent * beta^6 */
517 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
518 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
519 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);
521 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
525 fscal = _mm_and_pd(fscal,cutoff_mask);
527 /* Calculate temporary vectorial force */
528 tx = _mm_mul_pd(fscal,dx00);
529 ty = _mm_mul_pd(fscal,dy00);
530 tz = _mm_mul_pd(fscal,dz00);
532 /* Update vectorial force */
533 fix0 = _mm_add_pd(fix0,tx);
534 fiy0 = _mm_add_pd(fiy0,ty);
535 fiz0 = _mm_add_pd(fiz0,tz);
537 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
541 /* Inner loop uses 49 flops */
548 j_coord_offsetA = DIM*jnrA;
550 /* load j atom coordinates */
551 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
554 /* Calculate displacement vector */
555 dx00 = _mm_sub_pd(ix0,jx0);
556 dy00 = _mm_sub_pd(iy0,jy0);
557 dz00 = _mm_sub_pd(iz0,jz0);
559 /* Calculate squared distance and things based on it */
560 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
562 rinv00 = gmx_mm_invsqrt_pd(rsq00);
564 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
566 /* Load parameters for j particles */
567 vdwjidx0A = 2*vdwtype[jnrA+0];
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
573 if (gmx_mm_any_lt(rsq00,rcutoff2))
576 r00 = _mm_mul_pd(rsq00,rinv00);
578 /* Compute parameters for interactions between i and j atoms */
579 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
581 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
583 /* Analytical LJ-PME */
584 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
585 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
586 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
587 exponent = gmx_simd_exp_d(ewcljrsq);
588 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
589 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
590 /* f6A = 6 * C6grid * (1 - poly) */
591 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
592 /* f6B = C6grid * exponent * beta^6 */
593 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
594 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
595 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);
597 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
601 fscal = _mm_and_pd(fscal,cutoff_mask);
603 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
605 /* Calculate temporary vectorial force */
606 tx = _mm_mul_pd(fscal,dx00);
607 ty = _mm_mul_pd(fscal,dy00);
608 tz = _mm_mul_pd(fscal,dz00);
610 /* Update vectorial force */
611 fix0 = _mm_add_pd(fix0,tx);
612 fiy0 = _mm_add_pd(fiy0,ty);
613 fiz0 = _mm_add_pd(fiz0,tz);
615 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
619 /* Inner loop uses 49 flops */
622 /* End of innermost loop */
624 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
625 f+i_coord_offset,fshift+i_shift_offset);
627 /* Increment number of inner iterations */
628 inneriter += j_index_end - j_index_start;
630 /* Outer loop uses 6 flops */
633 /* Increment number of outer iterations */
636 /* Update outer/inner flops */
638 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*49);