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 avx_128_fma_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_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_VF_avx_128_fma_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_avx_128_fma_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);
93 __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_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
213 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
214 vvdw6 = _mm_mul_pd(_mm_macc_pd(-c6grid_00,_mm_sub_pd(one,poly),c6_00),rinvsix);
215 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
216 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
217 _mm_mul_pd(_mm_sub_pd(vvdw6,_mm_macc_pd(c6grid_00,sh_lj_ewald,_mm_mul_pd(c6_00,sh_vdw_invrcut6))),one_sixth));
218 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
219 fvdw = _mm_mul_pd(_mm_add_pd(vvdw12,_mm_msub_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6),vvdw6)),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 /* Update vectorial force */
232 fix0 = _mm_macc_pd(dx00,fscal,fix0);
233 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
234 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
236 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
237 _mm_mul_pd(dx00,fscal),
238 _mm_mul_pd(dy00,fscal),
239 _mm_mul_pd(dz00,fscal));
243 /* Inner loop uses 58 flops */
250 j_coord_offsetA = DIM*jnrA;
252 /* load j atom coordinates */
253 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
256 /* Calculate displacement vector */
257 dx00 = _mm_sub_pd(ix0,jx0);
258 dy00 = _mm_sub_pd(iy0,jy0);
259 dz00 = _mm_sub_pd(iz0,jz0);
261 /* Calculate squared distance and things based on it */
262 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
264 rinv00 = gmx_mm_invsqrt_pd(rsq00);
266 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
268 /* Load parameters for j particles */
269 vdwjidx0A = 2*vdwtype[jnrA+0];
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
275 if (gmx_mm_any_lt(rsq00,rcutoff2))
278 r00 = _mm_mul_pd(rsq00,rinv00);
280 /* Compute parameters for interactions between i and j atoms */
281 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
282 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
284 /* Analytical LJ-PME */
285 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
286 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
287 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
288 exponent = gmx_simd_exp_d(ewcljrsq);
289 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
290 poly = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
291 /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */
292 vvdw6 = _mm_mul_pd(_mm_macc_pd(-c6grid_00,_mm_sub_pd(one,poly),c6_00),rinvsix);
293 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
294 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
295 _mm_mul_pd(_mm_sub_pd(vvdw6,_mm_macc_pd(c6grid_00,sh_lj_ewald,_mm_mul_pd(c6_00,sh_vdw_invrcut6))),one_sixth));
296 /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */
297 fvdw = _mm_mul_pd(_mm_add_pd(vvdw12,_mm_msub_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6),vvdw6)),rinvsq00);
299 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
301 /* Update potential sum for this i atom from the interaction with this j atom. */
302 vvdw = _mm_and_pd(vvdw,cutoff_mask);
303 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
304 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
308 fscal = _mm_and_pd(fscal,cutoff_mask);
310 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
312 /* Update vectorial force */
313 fix0 = _mm_macc_pd(dx00,fscal,fix0);
314 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
315 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
317 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
318 _mm_mul_pd(dx00,fscal),
319 _mm_mul_pd(dy00,fscal),
320 _mm_mul_pd(dz00,fscal));
324 /* Inner loop uses 58 flops */
327 /* End of innermost loop */
329 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
330 f+i_coord_offset,fshift+i_shift_offset);
333 /* Update potential energies */
334 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
336 /* Increment number of inner iterations */
337 inneriter += j_index_end - j_index_start;
339 /* Outer loop uses 7 flops */
342 /* Increment number of outer iterations */
345 /* Update outer/inner flops */
347 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*58);
350 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_avx_128_fma_double
351 * Electrostatics interaction: None
352 * VdW interaction: LJEwald
353 * Geometry: Particle-Particle
354 * Calculate force/pot: Force
357 nb_kernel_ElecNone_VdwLJEwSh_GeomP1P1_F_avx_128_fma_double
358 (t_nblist * gmx_restrict nlist,
359 rvec * gmx_restrict xx,
360 rvec * gmx_restrict ff,
361 t_forcerec * gmx_restrict fr,
362 t_mdatoms * gmx_restrict mdatoms,
363 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
364 t_nrnb * gmx_restrict nrnb)
366 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
367 * just 0 for non-waters.
368 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
369 * jnr indices corresponding to data put in the four positions in the SIMD register.
371 int i_shift_offset,i_coord_offset,outeriter,inneriter;
372 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
374 int j_coord_offsetA,j_coord_offsetB;
375 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
377 real *shiftvec,*fshift,*x,*f;
378 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
380 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
381 int vdwjidx0A,vdwjidx0B;
382 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
383 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
385 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
388 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
389 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
392 __m128d ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald;
393 __m128d one_half = _mm_set1_pd(0.5);
394 __m128d minus_one = _mm_set1_pd(-1.0);
395 __m128d dummy_mask,cutoff_mask;
396 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
397 __m128d one = _mm_set1_pd(1.0);
398 __m128d two = _mm_set1_pd(2.0);
404 jindex = nlist->jindex;
406 shiftidx = nlist->shift;
408 shiftvec = fr->shift_vec[0];
409 fshift = fr->fshift[0];
410 nvdwtype = fr->ntype;
412 vdwtype = mdatoms->typeA;
413 vdwgridparam = fr->ljpme_c6grid;
414 sh_lj_ewald = _mm_set1_pd(fr->ic->sh_lj_ewald);
415 ewclj = _mm_set1_pd(fr->ewaldcoeff_lj);
416 ewclj2 = _mm_mul_pd(minus_one,_mm_mul_pd(ewclj,ewclj));
418 rcutoff_scalar = fr->rvdw;
419 rcutoff = _mm_set1_pd(rcutoff_scalar);
420 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
422 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
423 rvdw = _mm_set1_pd(fr->rvdw);
425 /* Avoid stupid compiler warnings */
433 /* Start outer loop over neighborlists */
434 for(iidx=0; iidx<nri; iidx++)
436 /* Load shift vector for this list */
437 i_shift_offset = DIM*shiftidx[iidx];
439 /* Load limits for loop over neighbors */
440 j_index_start = jindex[iidx];
441 j_index_end = jindex[iidx+1];
443 /* Get outer coordinate index */
445 i_coord_offset = DIM*inr;
447 /* Load i particle coords and add shift vector */
448 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
450 fix0 = _mm_setzero_pd();
451 fiy0 = _mm_setzero_pd();
452 fiz0 = _mm_setzero_pd();
454 /* Load parameters for i particles */
455 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
457 /* Start inner kernel loop */
458 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
461 /* Get j neighbor index, and coordinate index */
464 j_coord_offsetA = DIM*jnrA;
465 j_coord_offsetB = DIM*jnrB;
467 /* load j atom coordinates */
468 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
471 /* Calculate displacement vector */
472 dx00 = _mm_sub_pd(ix0,jx0);
473 dy00 = _mm_sub_pd(iy0,jy0);
474 dz00 = _mm_sub_pd(iz0,jz0);
476 /* Calculate squared distance and things based on it */
477 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
479 rinv00 = gmx_mm_invsqrt_pd(rsq00);
481 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
483 /* Load parameters for j particles */
484 vdwjidx0A = 2*vdwtype[jnrA+0];
485 vdwjidx0B = 2*vdwtype[jnrB+0];
487 /**************************
488 * CALCULATE INTERACTIONS *
489 **************************/
491 if (gmx_mm_any_lt(rsq00,rcutoff2))
494 r00 = _mm_mul_pd(rsq00,rinv00);
496 /* Compute parameters for interactions between i and j atoms */
497 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
498 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
499 c6grid_00 = gmx_mm_load_2real_swizzle_pd(vdwgridparam+vdwioffset0+vdwjidx0A,
500 vdwgridparam+vdwioffset0+vdwjidx0B);
502 /* Analytical LJ-PME */
503 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
504 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
505 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
506 exponent = gmx_simd_exp_d(ewcljrsq);
507 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
508 poly = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
509 /* f6A = 6 * C6grid * (1 - poly) */
510 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
511 /* f6B = C6grid * exponent * beta^6 */
512 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
513 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
514 fvdw = _mm_mul_pd(_mm_macc_pd(_mm_msub_pd(c12_00,rinvsix,_mm_sub_pd(c6_00,f6A)),rinvsix,f6B),rinvsq00);
516 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
520 fscal = _mm_and_pd(fscal,cutoff_mask);
522 /* Update vectorial force */
523 fix0 = _mm_macc_pd(dx00,fscal,fix0);
524 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
525 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
527 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
528 _mm_mul_pd(dx00,fscal),
529 _mm_mul_pd(dy00,fscal),
530 _mm_mul_pd(dz00,fscal));
534 /* Inner loop uses 50 flops */
541 j_coord_offsetA = DIM*jnrA;
543 /* load j atom coordinates */
544 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
547 /* Calculate displacement vector */
548 dx00 = _mm_sub_pd(ix0,jx0);
549 dy00 = _mm_sub_pd(iy0,jy0);
550 dz00 = _mm_sub_pd(iz0,jz0);
552 /* Calculate squared distance and things based on it */
553 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
555 rinv00 = gmx_mm_invsqrt_pd(rsq00);
557 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
559 /* Load parameters for j particles */
560 vdwjidx0A = 2*vdwtype[jnrA+0];
562 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
566 if (gmx_mm_any_lt(rsq00,rcutoff2))
569 r00 = _mm_mul_pd(rsq00,rinv00);
571 /* Compute parameters for interactions between i and j atoms */
572 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
573 c6grid_00 = gmx_mm_load_1real_pd(vdwgridparam+vdwioffset0+vdwjidx0A);
575 /* Analytical LJ-PME */
576 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
577 ewcljrsq = _mm_mul_pd(ewclj2,rsq00);
578 ewclj6 = _mm_mul_pd(ewclj2,_mm_mul_pd(ewclj2,ewclj2));
579 exponent = gmx_simd_exp_d(ewcljrsq);
580 /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */
581 poly = _mm_mul_pd(exponent,_mm_macc_pd(_mm_mul_pd(ewcljrsq,ewcljrsq),one_half,_mm_sub_pd(one,ewcljrsq)));
582 /* f6A = 6 * C6grid * (1 - poly) */
583 f6A = _mm_mul_pd(c6grid_00,_mm_sub_pd(one,poly));
584 /* f6B = C6grid * exponent * beta^6 */
585 f6B = _mm_mul_pd(_mm_mul_pd(c6grid_00,one_sixth),_mm_mul_pd(exponent,ewclj6));
586 /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */
587 fvdw = _mm_mul_pd(_mm_macc_pd(_mm_msub_pd(c12_00,rinvsix,_mm_sub_pd(c6_00,f6A)),rinvsix,f6B),rinvsq00);
589 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
593 fscal = _mm_and_pd(fscal,cutoff_mask);
595 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
597 /* Update vectorial force */
598 fix0 = _mm_macc_pd(dx00,fscal,fix0);
599 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
600 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
602 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
603 _mm_mul_pd(dx00,fscal),
604 _mm_mul_pd(dy00,fscal),
605 _mm_mul_pd(dz00,fscal));
609 /* Inner loop uses 50 flops */
612 /* End of innermost loop */
614 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
615 f+i_coord_offset,fshift+i_shift_offset);
617 /* Increment number of inner iterations */
618 inneriter += j_index_end - j_index_start;
620 /* Outer loop uses 6 flops */
623 /* Increment number of outer iterations */
626 /* Update outer/inner flops */
628 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*50);