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_VdwLJEwSh_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_VdwLJEwSh_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 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);
204 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
205 vdwgridparam+vdwioffset0+vdwjidx0B);
207 /* Analytical LJ-PME */
208 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
209 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
210 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
211 exponent = gmx_simd_exp_d(ewcljrsq);
212 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
213 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
214 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
215 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
216 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
217 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),
218 _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));
219 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
220 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);
222 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
224 /* Update potential sum for this i atom from the interaction with this j atom. */
225 vvdw = _mm_and_pd(vvdw,cutoff_mask);
226 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
230 fscal = _mm_and_pd(fscal,cutoff_mask);
232 /* Calculate temporary vectorial force */
233 tx = _mm_mul_pd(fscal,dx00);
234 ty = _mm_mul_pd(fscal,dy00);
235 tz = _mm_mul_pd(fscal,dz00);
237 /* Update vectorial force */
238 fix0 = _mm_add_pd(fix0,tx);
239 fiy0 = _mm_add_pd(fiy0,ty);
240 fiz0 = _mm_add_pd(fiz0,tz);
242 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
246 /* Inner loop uses 62 flops */
253 j_coord_offsetA = DIM*jnrA;
255 /* load j atom coordinates */
256 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
259 /* Calculate displacement vector */
260 dx00 = _mm_sub_pd(ix0,jx0);
261 dy00 = _mm_sub_pd(iy0,jy0);
262 dz00 = _mm_sub_pd(iz0,jz0);
264 /* Calculate squared distance and things based on it */
265 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
267 rinv00 = gmx_mm_invsqrt_pd(rsq00);
269 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
271 /* Load parameters for j particles */
272 vdwjidx0A = 2*vdwtype[jnrA+0];
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 if (gmx_mm_any_lt(rsq00,rcutoff2))
281 r00 = _mm_mul_pd(rsq00,rinv00);
283 /* Compute parameters for interactions between i and j atoms */
284 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
286 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
288 /* Analytical LJ-PME */
289 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
290 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
291 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
292 exponent = gmx_simd_exp_d(ewcljrsq);
293 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
294 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
295 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
296 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
297 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
298 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),
299 _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));
300 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
301 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);
303 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
305 /* Update potential sum for this i atom from the interaction with this j atom. */
306 vvdw = _mm_and_pd(vvdw,cutoff_mask);
307 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
308 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
312 fscal = _mm_and_pd(fscal,cutoff_mask);
314 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
316 /* Calculate temporary vectorial force */
317 tx = _mm_mul_pd(fscal,dx00);
318 ty = _mm_mul_pd(fscal,dy00);
319 tz = _mm_mul_pd(fscal,dz00);
321 /* Update vectorial force */
322 fix0 = _mm_add_pd(fix0,tx);
323 fiy0 = _mm_add_pd(fiy0,ty);
324 fiz0 = _mm_add_pd(fiz0,tz);
326 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
330 /* Inner loop uses 62 flops */
333 /* End of innermost loop */
335 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
336 f+i_coord_offset,fshift+i_shift_offset);
339 /* Update potential energies */
340 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
342 /* Increment number of inner iterations */
343 inneriter += j_index_end - j_index_start;
345 /* Outer loop uses 7 flops */
348 /* Increment number of outer iterations */
351 /* Update outer/inner flops */
353 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*62);
356 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse2_double
357 * Electrostatics interaction: None
358 * VdW interaction: LJEwald
359 * Geometry: Particle-Particle
360 * Calculate force/pot: Force
363 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse2_double
364 (t_nblist * gmx_restrict nlist,
365 rvec * gmx_restrict xx,
366 rvec * gmx_restrict ff,
367 t_forcerec * gmx_restrict fr,
368 t_mdatoms * gmx_restrict mdatoms,
369 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
370 t_nrnb * gmx_restrict nrnb)
372 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
373 * just 0 for non-waters.
374 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
375 * jnr indices corresponding to data put in the four positions in the SIMD register.
377 int i_shift_offset,i_coord_offset,outeriter,inneriter;
378 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
380 int j_coord_offsetA,j_coord_offsetB;
381 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
383 real *shiftvec,*fshift,*x,*f;
384 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
386 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
387 int vdwjidx0A,vdwjidx0B;
388 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
389 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
391 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
394 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
395 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
397 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
399 __m128d one_half = _mm_set1_pd(0.5);
400 __m128d minus_one = _mm_set1_pd(-1.0);
401 __m128d dummy_mask,cutoff_mask;
402 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
403 __m128d one = _mm_set1_pd(1.0);
404 __m128d two = _mm_set1_pd(2.0);
410 jindex = nlist->jindex;
412 shiftidx = nlist->shift;
414 shiftvec = fr->shift_vec[0];
415 fshift = fr->fshift[0];
416 nvdwtype = fr->ntype;
418 vdwtype = mdatoms->typeA;
419 vdwgridparam = fr->ljpme_c6grid;
420 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
421 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
422 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
424 rcutoff_scalar = fr->rvdw;
425 rcutoff = _mm_set1_pd(rcutoff_scalar);
426 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
428 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
429 rvdw = _mm_set1_pd(fr->rvdw);
431 /* Avoid stupid compiler warnings */
439 /* Start outer loop over neighborlists */
440 for(iidx=0; iidx<nri; iidx++)
442 /* Load shift vector for this list */
443 i_shift_offset = DIM*shiftidx[iidx];
445 /* Load limits for loop over neighbors */
446 j_index_start = jindex[iidx];
447 j_index_end = jindex[iidx+1];
449 /* Get outer coordinate index */
451 i_coord_offset = DIM*inr;
453 /* Load i particle coords and add shift vector */
454 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
456 fix0 = _mm_setzero_pd();
457 fiy0 = _mm_setzero_pd();
458 fiz0 = _mm_setzero_pd();
460 /* Load parameters for i particles */
461 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
463 /* Start inner kernel loop */
464 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
467 /* Get j neighbor index, and coordinate index */
470 j_coord_offsetA = DIM*jnrA;
471 j_coord_offsetB = DIM*jnrB;
473 /* load j atom coordinates */
474 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
477 /* Calculate displacement vector */
478 dx00 = _mm_sub_pd(ix0,jx0);
479 dy00 = _mm_sub_pd(iy0,jy0);
480 dz00 = _mm_sub_pd(iz0,jz0);
482 /* Calculate squared distance and things based on it */
483 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
485 rinv00 = gmx_mm_invsqrt_pd(rsq00);
487 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
489 /* Load parameters for j particles */
490 vdwjidx0A = 2*vdwtype[jnrA+0];
491 vdwjidx0B = 2*vdwtype[jnrB+0];
493 /**************************
494 * CALCULATE INTERACTIONS *
495 **************************/
497 if (gmx_mm_any_lt(rsq00,rcutoff2))
500 r00 = _mm_mul_pd(rsq00,rinv00);
502 /* Compute parameters for interactions between i and j atoms */
503 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
504 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
506 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
507 vdwgridparam+vdwioffset0+vdwjidx0B);
509 /* Analytical LJ-PME */
510 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
511 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
512 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
513 exponent = gmx_simd_exp_d(ewcljrsq);
514 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
515 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
516 /* f6A = 6 * C6grid * (1 - poly) */
517 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
518 /* f6B = C6grid * exponent * beta^6 */
519 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
520 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
521 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);
523 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
527 fscal = _mm_and_pd(fscal,cutoff_mask);
529 /* Calculate temporary vectorial force */
530 tx = _mm_mul_pd(fscal,dx00);
531 ty = _mm_mul_pd(fscal,dy00);
532 tz = _mm_mul_pd(fscal,dz00);
534 /* Update vectorial force */
535 fix0 = _mm_add_pd(fix0,tx);
536 fiy0 = _mm_add_pd(fiy0,ty);
537 fiz0 = _mm_add_pd(fiz0,tz);
539 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
543 /* Inner loop uses 49 flops */
550 j_coord_offsetA = DIM*jnrA;
552 /* load j atom coordinates */
553 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
556 /* Calculate displacement vector */
557 dx00 = _mm_sub_pd(ix0,jx0);
558 dy00 = _mm_sub_pd(iy0,jy0);
559 dz00 = _mm_sub_pd(iz0,jz0);
561 /* Calculate squared distance and things based on it */
562 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
564 rinv00 = gmx_mm_invsqrt_pd(rsq00);
566 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
568 /* Load parameters for j particles */
569 vdwjidx0A = 2*vdwtype[jnrA+0];
571 /**************************
572 * CALCULATE INTERACTIONS *
573 **************************/
575 if (gmx_mm_any_lt(rsq00,rcutoff2))
578 r00 = _mm_mul_pd(rsq00,rinv00);
580 /* Compute parameters for interactions between i and j atoms */
581 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
583 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
585 /* Analytical LJ-PME */
586 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
587 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
588 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
589 exponent = gmx_simd_exp_d(ewcljrsq);
590 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
591 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
592 /* f6A = 6 * C6grid * (1 - poly) */
593 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
594 /* f6B = C6grid * exponent * beta^6 */
595 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
596 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
597 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);
599 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
603 fscal = _mm_and_pd(fscal,cutoff_mask);
605 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
607 /* Calculate temporary vectorial force */
608 tx = _mm_mul_pd(fscal,dx00);
609 ty = _mm_mul_pd(fscal,dy00);
610 tz = _mm_mul_pd(fscal,dz00);
612 /* Update vectorial force */
613 fix0 = _mm_add_pd(fix0,tx);
614 fiy0 = _mm_add_pd(fiy0,ty);
615 fiz0 = _mm_add_pd(fiz0,tz);
617 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
621 /* Inner loop uses 49 flops */
624 /* End of innermost loop */
626 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
627 f+i_coord_offset,fshift+i_shift_offset);
629 /* Increment number of inner iterations */
630 inneriter += j_index_end - j_index_start;
632 /* Outer loop uses 6 flops */
635 /* Increment number of outer iterations */
638 /* Update outer/inner flops */
640 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*49);