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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "gromacs/simd/math_x86_sse4_1_double.h"
50 #include "kernelutil_x86_sse4_1_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_VF_sse4_1_double
54 * Electrostatics interaction: None
55 * VdW interaction: LJEwald
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_VF_sse4_1_double
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_unused * 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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 int vdwjidx0A,vdwjidx0B;
85 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
86 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
91 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
92 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
94 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
96 __m128d one_half = _mm_set1_pd(0.5);
97 __m128d minus_one = _mm_set1_pd(-1.0);
98 __m128d dummy_mask,cutoff_mask;
99 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
100 __m128d one = _mm_set1_pd(1.0);
101 __m128d two = _mm_set1_pd(2.0);
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 nvdwtype = fr->ntype;
115 vdwtype = mdatoms->typeA;
116 vdwgridparam = fr->ljpme_c6grid;
117 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
118 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
119 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
121 rcutoff_scalar = fr->rvdw;
122 rcutoff = _mm_set1_pd(rcutoff_scalar);
123 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
125 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
126 rvdw = _mm_set1_pd(fr->rvdw);
128 /* Avoid stupid compiler warnings */
136 /* Start outer loop over neighborlists */
137 for(iidx=0; iidx<nri; iidx++)
139 /* Load shift vector for this list */
140 i_shift_offset = DIM*shiftidx[iidx];
142 /* Load limits for loop over neighbors */
143 j_index_start = jindex[iidx];
144 j_index_end = jindex[iidx+1];
146 /* Get outer coordinate index */
148 i_coord_offset = DIM*inr;
150 /* Load i particle coords and add shift vector */
151 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
153 fix0 = _mm_setzero_pd();
154 fiy0 = _mm_setzero_pd();
155 fiz0 = _mm_setzero_pd();
157 /* Load parameters for i particles */
158 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
160 /* Reset potential sums */
161 vvdwsum = _mm_setzero_pd();
163 /* Start inner kernel loop */
164 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
167 /* Get j neighbor index, and coordinate index */
170 j_coord_offsetA = DIM*jnrA;
171 j_coord_offsetB = DIM*jnrB;
173 /* load j atom coordinates */
174 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
177 /* Calculate displacement vector */
178 dx00 = _mm_sub_pd(ix0,jx0);
179 dy00 = _mm_sub_pd(iy0,jy0);
180 dz00 = _mm_sub_pd(iz0,jz0);
182 /* Calculate squared distance and things based on it */
183 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
185 rinv00 = gmx_mm_invsqrt_pd(rsq00);
187 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
189 /* Load parameters for j particles */
190 vdwjidx0A = 2*vdwtype[jnrA+0];
191 vdwjidx0B = 2*vdwtype[jnrB+0];
193 /**************************
194 * CALCULATE INTERACTIONS *
195 **************************/
197 if (gmx_mm_any_lt(rsq00,rcutoff2))
200 r00 = _mm_mul_pd(rsq00,rinv00);
202 /* Compute parameters for interactions between i and j atoms */
203 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
204 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
205 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
206 vdwgridparam+vdwioffset0+vdwjidx0B);
208 /* Analytical LJ-PME */
209 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
210 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
211 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
212 exponent = gmx_simd_exp_d(ewcljrsq);
213 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
214 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
215 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
216 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
217 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
218 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),
219 _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));
220 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
221 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);
223 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
225 /* Update potential sum for this i atom from the interaction with this j atom. */
226 vvdw = _mm_and_pd(vvdw,cutoff_mask);
227 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
231 fscal = _mm_and_pd(fscal,cutoff_mask);
233 /* Calculate temporary vectorial force */
234 tx = _mm_mul_pd(fscal,dx00);
235 ty = _mm_mul_pd(fscal,dy00);
236 tz = _mm_mul_pd(fscal,dz00);
238 /* Update vectorial force */
239 fix0 = _mm_add_pd(fix0,tx);
240 fiy0 = _mm_add_pd(fiy0,ty);
241 fiz0 = _mm_add_pd(fiz0,tz);
243 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
247 /* Inner loop uses 61 flops */
254 j_coord_offsetA = DIM*jnrA;
256 /* load j atom coordinates */
257 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
260 /* Calculate displacement vector */
261 dx00 = _mm_sub_pd(ix0,jx0);
262 dy00 = _mm_sub_pd(iy0,jy0);
263 dz00 = _mm_sub_pd(iz0,jz0);
265 /* Calculate squared distance and things based on it */
266 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
268 rinv00 = gmx_mm_invsqrt_pd(rsq00);
270 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
272 /* Load parameters for j particles */
273 vdwjidx0A = 2*vdwtype[jnrA+0];
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 if (gmx_mm_any_lt(rsq00,rcutoff2))
282 r00 = _mm_mul_pd(rsq00,rinv00);
284 /* Compute parameters for interactions between i and j atoms */
285 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
287 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
289 /* Analytical LJ-PME */
290 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
291 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
292 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
293 exponent = gmx_simd_exp_d(ewcljrsq);
294 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
295 poly = _mm_mul_pd(exponent,_mm_add_pd(_mm_sub_pd(one,ewcljrsq),_mm_mul_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half)));
296 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
297 vvdw6 = _mm_mul_pd(_mm_sub_pd(c6_00,_mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly))),rinvsix);
298 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
299 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),
300 _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));
301 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
302 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);
304 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
306 /* Update potential sum for this i atom from the interaction with this j atom. */
307 vvdw = _mm_and_pd(vvdw,cutoff_mask);
308 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
309 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
313 fscal = _mm_and_pd(fscal,cutoff_mask);
315 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
317 /* Calculate temporary vectorial force */
318 tx = _mm_mul_pd(fscal,dx00);
319 ty = _mm_mul_pd(fscal,dy00);
320 tz = _mm_mul_pd(fscal,dz00);
322 /* Update vectorial force */
323 fix0 = _mm_add_pd(fix0,tx);
324 fiy0 = _mm_add_pd(fiy0,ty);
325 fiz0 = _mm_add_pd(fiz0,tz);
327 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
331 /* Inner loop uses 61 flops */
334 /* End of innermost loop */
336 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
337 f+i_coord_offset,fshift+i_shift_offset);
340 /* Update potential energies */
341 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
343 /* Increment number of inner iterations */
344 inneriter += j_index_end - j_index_start;
346 /* Outer loop uses 7 flops */
349 /* Increment number of outer iterations */
352 /* Update outer/inner flops */
354 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*61);
357 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse4_1_double
358 * Electrostatics interaction: None
359 * VdW interaction: LJEwald
360 * Geometry: Particle-Particle
361 * Calculate force/pot: Force
364 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_sse4_1_double
365 (t_nblist * gmx_restrict nlist,
366 rvec * gmx_restrict xx,
367 rvec * gmx_restrict ff,
368 t_forcerec * gmx_restrict fr,
369 t_mdatoms * gmx_restrict mdatoms,
370 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
371 t_nrnb * gmx_restrict nrnb)
373 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
374 * just 0 for non-waters.
375 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
376 * jnr indices corresponding to data put in the four positions in the SIMD register.
378 int i_shift_offset,i_coord_offset,outeriter,inneriter;
379 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
381 int j_coord_offsetA,j_coord_offsetB;
382 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
384 real *shiftvec,*fshift,*x,*f;
385 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
387 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
388 int vdwjidx0A,vdwjidx0B;
389 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
390 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
392 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
395 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
396 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
398 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
400 __m128d one_half = _mm_set1_pd(0.5);
401 __m128d minus_one = _mm_set1_pd(-1.0);
402 __m128d dummy_mask,cutoff_mask;
403 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
404 __m128d one = _mm_set1_pd(1.0);
405 __m128d two = _mm_set1_pd(2.0);
411 jindex = nlist->jindex;
413 shiftidx = nlist->shift;
415 shiftvec = fr->shift_vec[0];
416 fshift = fr->fshift[0];
417 nvdwtype = fr->ntype;
419 vdwtype = mdatoms->typeA;
420 vdwgridparam = fr->ljpme_c6grid;
421 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
422 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
423 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
425 rcutoff_scalar = fr->rvdw;
426 rcutoff = _mm_set1_pd(rcutoff_scalar);
427 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
429 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
430 rvdw = _mm_set1_pd(fr->rvdw);
432 /* Avoid stupid compiler warnings */
440 /* Start outer loop over neighborlists */
441 for(iidx=0; iidx<nri; iidx++)
443 /* Load shift vector for this list */
444 i_shift_offset = DIM*shiftidx[iidx];
446 /* Load limits for loop over neighbors */
447 j_index_start = jindex[iidx];
448 j_index_end = jindex[iidx+1];
450 /* Get outer coordinate index */
452 i_coord_offset = DIM*inr;
454 /* Load i particle coords and add shift vector */
455 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
457 fix0 = _mm_setzero_pd();
458 fiy0 = _mm_setzero_pd();
459 fiz0 = _mm_setzero_pd();
461 /* Load parameters for i particles */
462 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
464 /* Start inner kernel loop */
465 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
468 /* Get j neighbor index, and coordinate index */
471 j_coord_offsetA = DIM*jnrA;
472 j_coord_offsetB = DIM*jnrB;
474 /* load j atom coordinates */
475 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
478 /* Calculate displacement vector */
479 dx00 = _mm_sub_pd(ix0,jx0);
480 dy00 = _mm_sub_pd(iy0,jy0);
481 dz00 = _mm_sub_pd(iz0,jz0);
483 /* Calculate squared distance and things based on it */
484 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
486 rinv00 = gmx_mm_invsqrt_pd(rsq00);
488 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
490 /* Load parameters for j particles */
491 vdwjidx0A = 2*vdwtype[jnrA+0];
492 vdwjidx0B = 2*vdwtype[jnrB+0];
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
498 if (gmx_mm_any_lt(rsq00,rcutoff2))
501 r00 = _mm_mul_pd(rsq00,rinv00);
503 /* Compute parameters for interactions between i and j atoms */
504 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
505 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);