2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: None
55 * VdW interaction: LennardJones
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_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);
93 __m128d dummy_mask,cutoff_mask;
94 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
95 __m128d one = _mm_set1_pd(1.0);
96 __m128d two = _mm_set1_pd(2.0);
102 jindex = nlist->jindex;
104 shiftidx = nlist->shift;
106 shiftvec = fr->shift_vec[0];
107 fshift = fr->fshift[0];
108 nvdwtype = fr->ntype;
110 vdwtype = mdatoms->typeA;
112 /* Avoid stupid compiler warnings */
120 /* Start outer loop over neighborlists */
121 for(iidx=0; iidx<nri; iidx++)
123 /* Load shift vector for this list */
124 i_shift_offset = DIM*shiftidx[iidx];
126 /* Load limits for loop over neighbors */
127 j_index_start = jindex[iidx];
128 j_index_end = jindex[iidx+1];
130 /* Get outer coordinate index */
132 i_coord_offset = DIM*inr;
134 /* Load i particle coords and add shift vector */
135 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
137 fix0 = _mm_setzero_pd();
138 fiy0 = _mm_setzero_pd();
139 fiz0 = _mm_setzero_pd();
141 /* Load parameters for i particles */
142 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
144 /* Reset potential sums */
145 vvdwsum = _mm_setzero_pd();
147 /* Start inner kernel loop */
148 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
151 /* Get j neighbor index, and coordinate index */
154 j_coord_offsetA = DIM*jnrA;
155 j_coord_offsetB = DIM*jnrB;
157 /* load j atom coordinates */
158 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
161 /* Calculate displacement vector */
162 dx00 = _mm_sub_pd(ix0,jx0);
163 dy00 = _mm_sub_pd(iy0,jy0);
164 dz00 = _mm_sub_pd(iz0,jz0);
166 /* Calculate squared distance and things based on it */
167 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
169 rinvsq00 = gmx_mm_inv_pd(rsq00);
171 /* Load parameters for j particles */
172 vdwjidx0A = 2*vdwtype[jnrA+0];
173 vdwjidx0B = 2*vdwtype[jnrB+0];
175 /**************************
176 * CALCULATE INTERACTIONS *
177 **************************/
179 /* Compute parameters for interactions between i and j atoms */
180 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
181 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
183 /* LENNARD-JONES DISPERSION/REPULSION */
185 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
186 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
187 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
188 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
189 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
191 /* Update potential sum for this i atom from the interaction with this j atom. */
192 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
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));
206 /* Inner loop uses 35 flops */
213 j_coord_offsetA = DIM*jnrA;
215 /* load j atom coordinates */
216 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
219 /* Calculate displacement vector */
220 dx00 = _mm_sub_pd(ix0,jx0);
221 dy00 = _mm_sub_pd(iy0,jy0);
222 dz00 = _mm_sub_pd(iz0,jz0);
224 /* Calculate squared distance and things based on it */
225 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
227 rinvsq00 = gmx_mm_inv_pd(rsq00);
229 /* Load parameters for j particles */
230 vdwjidx0A = 2*vdwtype[jnrA+0];
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
236 /* Compute parameters for interactions between i and j atoms */
237 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
239 /* LENNARD-JONES DISPERSION/REPULSION */
241 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
242 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
243 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
244 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
245 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
247 /* Update potential sum for this i atom from the interaction with this j atom. */
248 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
249 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
253 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
255 /* Update vectorial force */
256 fix0 = _mm_macc_pd(dx00,fscal,fix0);
257 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
258 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
260 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
261 _mm_mul_pd(dx00,fscal),
262 _mm_mul_pd(dy00,fscal),
263 _mm_mul_pd(dz00,fscal));
265 /* Inner loop uses 35 flops */
268 /* End of innermost loop */
270 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
271 f+i_coord_offset,fshift+i_shift_offset);
274 /* Update potential energies */
275 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
277 /* Increment number of inner iterations */
278 inneriter += j_index_end - j_index_start;
280 /* Outer loop uses 7 flops */
283 /* Increment number of outer iterations */
286 /* Update outer/inner flops */
288 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*35);
291 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double
292 * Electrostatics interaction: None
293 * VdW interaction: LennardJones
294 * Geometry: Particle-Particle
295 * Calculate force/pot: Force
298 nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double
299 (t_nblist * gmx_restrict nlist,
300 rvec * gmx_restrict xx,
301 rvec * gmx_restrict ff,
302 t_forcerec * gmx_restrict fr,
303 t_mdatoms * gmx_restrict mdatoms,
304 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
305 t_nrnb * gmx_restrict nrnb)
307 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
308 * just 0 for non-waters.
309 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
310 * jnr indices corresponding to data put in the four positions in the SIMD register.
312 int i_shift_offset,i_coord_offset,outeriter,inneriter;
313 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
315 int j_coord_offsetA,j_coord_offsetB;
316 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
318 real *shiftvec,*fshift,*x,*f;
319 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
321 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
322 int vdwjidx0A,vdwjidx0B;
323 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
324 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
326 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
329 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
330 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
331 __m128d dummy_mask,cutoff_mask;
332 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
333 __m128d one = _mm_set1_pd(1.0);
334 __m128d two = _mm_set1_pd(2.0);
340 jindex = nlist->jindex;
342 shiftidx = nlist->shift;
344 shiftvec = fr->shift_vec[0];
345 fshift = fr->fshift[0];
346 nvdwtype = fr->ntype;
348 vdwtype = mdatoms->typeA;
350 /* Avoid stupid compiler warnings */
358 /* Start outer loop over neighborlists */
359 for(iidx=0; iidx<nri; iidx++)
361 /* Load shift vector for this list */
362 i_shift_offset = DIM*shiftidx[iidx];
364 /* Load limits for loop over neighbors */
365 j_index_start = jindex[iidx];
366 j_index_end = jindex[iidx+1];
368 /* Get outer coordinate index */
370 i_coord_offset = DIM*inr;
372 /* Load i particle coords and add shift vector */
373 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
375 fix0 = _mm_setzero_pd();
376 fiy0 = _mm_setzero_pd();
377 fiz0 = _mm_setzero_pd();
379 /* Load parameters for i particles */
380 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
382 /* Start inner kernel loop */
383 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
386 /* Get j neighbor index, and coordinate index */
389 j_coord_offsetA = DIM*jnrA;
390 j_coord_offsetB = DIM*jnrB;
392 /* load j atom coordinates */
393 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
396 /* Calculate displacement vector */
397 dx00 = _mm_sub_pd(ix0,jx0);
398 dy00 = _mm_sub_pd(iy0,jy0);
399 dz00 = _mm_sub_pd(iz0,jz0);
401 /* Calculate squared distance and things based on it */
402 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
404 rinvsq00 = gmx_mm_inv_pd(rsq00);
406 /* Load parameters for j particles */
407 vdwjidx0A = 2*vdwtype[jnrA+0];
408 vdwjidx0B = 2*vdwtype[jnrB+0];
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
414 /* Compute parameters for interactions between i and j atoms */
415 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
416 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
418 /* LENNARD-JONES DISPERSION/REPULSION */
420 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
421 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
425 /* Update vectorial force */
426 fix0 = _mm_macc_pd(dx00,fscal,fix0);
427 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
428 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
430 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
431 _mm_mul_pd(dx00,fscal),
432 _mm_mul_pd(dy00,fscal),
433 _mm_mul_pd(dz00,fscal));
435 /* Inner loop uses 30 flops */
442 j_coord_offsetA = DIM*jnrA;
444 /* load j atom coordinates */
445 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
448 /* Calculate displacement vector */
449 dx00 = _mm_sub_pd(ix0,jx0);
450 dy00 = _mm_sub_pd(iy0,jy0);
451 dz00 = _mm_sub_pd(iz0,jz0);
453 /* Calculate squared distance and things based on it */
454 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
456 rinvsq00 = gmx_mm_inv_pd(rsq00);
458 /* Load parameters for j particles */
459 vdwjidx0A = 2*vdwtype[jnrA+0];
461 /**************************
462 * CALCULATE INTERACTIONS *
463 **************************/
465 /* Compute parameters for interactions between i and j atoms */
466 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
468 /* LENNARD-JONES DISPERSION/REPULSION */
470 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
471 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
475 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
477 /* Update vectorial force */
478 fix0 = _mm_macc_pd(dx00,fscal,fix0);
479 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
480 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
482 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
483 _mm_mul_pd(dx00,fscal),
484 _mm_mul_pd(dy00,fscal),
485 _mm_mul_pd(dz00,fscal));
487 /* Inner loop uses 30 flops */
490 /* End of innermost loop */
492 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
493 f+i_coord_offset,fshift+i_shift_offset);
495 /* Increment number of inner iterations */
496 inneriter += j_index_end - j_index_start;
498 /* Outer loop uses 6 flops */
501 /* Increment number of outer iterations */
504 /* Update outer/inner flops */
506 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*30);