2 * Note: this file was generated by the Gromacs avx_128_fma_double kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_double.h"
34 #include "kernelutil_x86_avx_128_fma_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_128_fma_double
38 * Electrostatics interaction: None
39 * VdW interaction: LennardJones
40 * Geometry: Particle-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_VF_avx_128_fma_double
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
68 int vdwjidx0A,vdwjidx0B;
69 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
70 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
72 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
75 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
76 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
77 __m128d dummy_mask,cutoff_mask;
78 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
79 __m128d one = _mm_set1_pd(1.0);
80 __m128d two = _mm_set1_pd(2.0);
86 jindex = nlist->jindex;
88 shiftidx = nlist->shift;
90 shiftvec = fr->shift_vec[0];
91 fshift = fr->fshift[0];
94 vdwtype = mdatoms->typeA;
96 rcutoff_scalar = fr->rvdw;
97 rcutoff = _mm_set1_pd(rcutoff_scalar);
98 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
100 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
101 rvdw = _mm_set1_pd(fr->rvdw);
103 /* Avoid stupid compiler warnings */
111 /* Start outer loop over neighborlists */
112 for(iidx=0; iidx<nri; iidx++)
114 /* Load shift vector for this list */
115 i_shift_offset = DIM*shiftidx[iidx];
117 /* Load limits for loop over neighbors */
118 j_index_start = jindex[iidx];
119 j_index_end = jindex[iidx+1];
121 /* Get outer coordinate index */
123 i_coord_offset = DIM*inr;
125 /* Load i particle coords and add shift vector */
126 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
128 fix0 = _mm_setzero_pd();
129 fiy0 = _mm_setzero_pd();
130 fiz0 = _mm_setzero_pd();
132 /* Load parameters for i particles */
133 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 /* Reset potential sums */
136 vvdwsum = _mm_setzero_pd();
138 /* Start inner kernel loop */
139 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
142 /* Get j neighbor index, and coordinate index */
145 j_coord_offsetA = DIM*jnrA;
146 j_coord_offsetB = DIM*jnrB;
148 /* load j atom coordinates */
149 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
152 /* Calculate displacement vector */
153 dx00 = _mm_sub_pd(ix0,jx0);
154 dy00 = _mm_sub_pd(iy0,jy0);
155 dz00 = _mm_sub_pd(iz0,jz0);
157 /* Calculate squared distance and things based on it */
158 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
160 rinvsq00 = gmx_mm_inv_pd(rsq00);
162 /* Load parameters for j particles */
163 vdwjidx0A = 2*vdwtype[jnrA+0];
164 vdwjidx0B = 2*vdwtype[jnrB+0];
166 /**************************
167 * CALCULATE INTERACTIONS *
168 **************************/
170 if (gmx_mm_any_lt(rsq00,rcutoff2))
173 /* Compute parameters for interactions between i and j atoms */
174 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
175 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
177 /* LENNARD-JONES DISPERSION/REPULSION */
179 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
180 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
181 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
182 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
183 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
184 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
186 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
188 /* Update potential sum for this i atom from the interaction with this j atom. */
189 vvdw = _mm_and_pd(vvdw,cutoff_mask);
190 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
194 fscal = _mm_and_pd(fscal,cutoff_mask);
196 /* Update vectorial force */
197 fix0 = _mm_macc_pd(dx00,fscal,fix0);
198 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
199 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
201 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
202 _mm_mul_pd(dx00,fscal),
203 _mm_mul_pd(dy00,fscal),
204 _mm_mul_pd(dz00,fscal));
208 /* Inner loop uses 44 flops */
215 j_coord_offsetA = DIM*jnrA;
217 /* load j atom coordinates */
218 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
221 /* Calculate displacement vector */
222 dx00 = _mm_sub_pd(ix0,jx0);
223 dy00 = _mm_sub_pd(iy0,jy0);
224 dz00 = _mm_sub_pd(iz0,jz0);
226 /* Calculate squared distance and things based on it */
227 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
229 rinvsq00 = gmx_mm_inv_pd(rsq00);
231 /* Load parameters for j particles */
232 vdwjidx0A = 2*vdwtype[jnrA+0];
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
238 if (gmx_mm_any_lt(rsq00,rcutoff2))
241 /* Compute parameters for interactions between i and j atoms */
242 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
244 /* LENNARD-JONES DISPERSION/REPULSION */
246 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
247 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
248 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
249 vvdw = _mm_msub_pd(_mm_nmacc_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
250 _mm_mul_pd(_mm_nmacc_pd( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
251 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
253 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
255 /* Update potential sum for this i atom from the interaction with this j atom. */
256 vvdw = _mm_and_pd(vvdw,cutoff_mask);
257 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
258 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
262 fscal = _mm_and_pd(fscal,cutoff_mask);
264 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
266 /* Update vectorial force */
267 fix0 = _mm_macc_pd(dx00,fscal,fix0);
268 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
269 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
271 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
272 _mm_mul_pd(dx00,fscal),
273 _mm_mul_pd(dy00,fscal),
274 _mm_mul_pd(dz00,fscal));
278 /* Inner loop uses 44 flops */
281 /* End of innermost loop */
283 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
284 f+i_coord_offset,fshift+i_shift_offset);
287 /* Update potential energies */
288 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
290 /* Increment number of inner iterations */
291 inneriter += j_index_end - j_index_start;
293 /* Outer loop uses 7 flops */
296 /* Increment number of outer iterations */
299 /* Update outer/inner flops */
301 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*44);
304 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_128_fma_double
305 * Electrostatics interaction: None
306 * VdW interaction: LennardJones
307 * Geometry: Particle-Particle
308 * Calculate force/pot: Force
311 nb_kernel_ElecNone_VdwLJSh_GeomP1P1_F_avx_128_fma_double
312 (t_nblist * gmx_restrict nlist,
313 rvec * gmx_restrict xx,
314 rvec * gmx_restrict ff,
315 t_forcerec * gmx_restrict fr,
316 t_mdatoms * gmx_restrict mdatoms,
317 nb_kernel_data_t * gmx_restrict kernel_data,
318 t_nrnb * gmx_restrict nrnb)
320 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
321 * just 0 for non-waters.
322 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
323 * jnr indices corresponding to data put in the four positions in the SIMD register.
325 int i_shift_offset,i_coord_offset,outeriter,inneriter;
326 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
328 int j_coord_offsetA,j_coord_offsetB;
329 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
331 real *shiftvec,*fshift,*x,*f;
332 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
334 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
335 int vdwjidx0A,vdwjidx0B;
336 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
337 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
339 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
342 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
343 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
344 __m128d dummy_mask,cutoff_mask;
345 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
346 __m128d one = _mm_set1_pd(1.0);
347 __m128d two = _mm_set1_pd(2.0);
353 jindex = nlist->jindex;
355 shiftidx = nlist->shift;
357 shiftvec = fr->shift_vec[0];
358 fshift = fr->fshift[0];
359 nvdwtype = fr->ntype;
361 vdwtype = mdatoms->typeA;
363 rcutoff_scalar = fr->rvdw;
364 rcutoff = _mm_set1_pd(rcutoff_scalar);
365 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
367 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
368 rvdw = _mm_set1_pd(fr->rvdw);
370 /* Avoid stupid compiler warnings */
378 /* Start outer loop over neighborlists */
379 for(iidx=0; iidx<nri; iidx++)
381 /* Load shift vector for this list */
382 i_shift_offset = DIM*shiftidx[iidx];
384 /* Load limits for loop over neighbors */
385 j_index_start = jindex[iidx];
386 j_index_end = jindex[iidx+1];
388 /* Get outer coordinate index */
390 i_coord_offset = DIM*inr;
392 /* Load i particle coords and add shift vector */
393 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
395 fix0 = _mm_setzero_pd();
396 fiy0 = _mm_setzero_pd();
397 fiz0 = _mm_setzero_pd();
399 /* Load parameters for i particles */
400 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
402 /* Start inner kernel loop */
403 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
406 /* Get j neighbor index, and coordinate index */
409 j_coord_offsetA = DIM*jnrA;
410 j_coord_offsetB = DIM*jnrB;
412 /* load j atom coordinates */
413 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
416 /* Calculate displacement vector */
417 dx00 = _mm_sub_pd(ix0,jx0);
418 dy00 = _mm_sub_pd(iy0,jy0);
419 dz00 = _mm_sub_pd(iz0,jz0);
421 /* Calculate squared distance and things based on it */
422 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
424 rinvsq00 = gmx_mm_inv_pd(rsq00);
426 /* Load parameters for j particles */
427 vdwjidx0A = 2*vdwtype[jnrA+0];
428 vdwjidx0B = 2*vdwtype[jnrB+0];
430 /**************************
431 * CALCULATE INTERACTIONS *
432 **************************/
434 if (gmx_mm_any_lt(rsq00,rcutoff2))
437 /* Compute parameters for interactions between i and j atoms */
438 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
439 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
441 /* LENNARD-JONES DISPERSION/REPULSION */
443 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
444 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
446 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
450 fscal = _mm_and_pd(fscal,cutoff_mask);
452 /* Update vectorial force */
453 fix0 = _mm_macc_pd(dx00,fscal,fix0);
454 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
455 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
457 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
458 _mm_mul_pd(dx00,fscal),
459 _mm_mul_pd(dy00,fscal),
460 _mm_mul_pd(dz00,fscal));
464 /* Inner loop uses 33 flops */
471 j_coord_offsetA = DIM*jnrA;
473 /* load j atom coordinates */
474 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
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 rinvsq00 = gmx_mm_inv_pd(rsq00);
487 /* Load parameters for j particles */
488 vdwjidx0A = 2*vdwtype[jnrA+0];
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
494 if (gmx_mm_any_lt(rsq00,rcutoff2))
497 /* Compute parameters for interactions between i and j atoms */
498 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
500 /* LENNARD-JONES DISPERSION/REPULSION */
502 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
503 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
505 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
509 fscal = _mm_and_pd(fscal,cutoff_mask);
511 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
513 /* Update vectorial force */
514 fix0 = _mm_macc_pd(dx00,fscal,fix0);
515 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
516 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
518 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
519 _mm_mul_pd(dx00,fscal),
520 _mm_mul_pd(dy00,fscal),
521 _mm_mul_pd(dz00,fscal));
525 /* Inner loop uses 33 flops */
528 /* End of innermost loop */
530 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
531 f+i_coord_offset,fshift+i_shift_offset);
533 /* Increment number of inner iterations */
534 inneriter += j_index_end - j_index_start;
536 /* Outer loop uses 6 flops */
539 /* Increment number of outer iterations */
542 /* Update outer/inner flops */
544 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*33);