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_ElecCoul_VdwNone_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: None
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwNone_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;
87 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
89 __m128d dummy_mask,cutoff_mask;
90 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
91 __m128d one = _mm_set1_pd(1.0);
92 __m128d two = _mm_set1_pd(2.0);
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
104 facel = _mm_set1_pd(fr->epsfac);
105 charge = mdatoms->chargeA;
107 /* Avoid stupid compiler warnings */
115 /* Start outer loop over neighborlists */
116 for(iidx=0; iidx<nri; iidx++)
118 /* Load shift vector for this list */
119 i_shift_offset = DIM*shiftidx[iidx];
121 /* Load limits for loop over neighbors */
122 j_index_start = jindex[iidx];
123 j_index_end = jindex[iidx+1];
125 /* Get outer coordinate index */
127 i_coord_offset = DIM*inr;
129 /* Load i particle coords and add shift vector */
130 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
132 fix0 = _mm_setzero_pd();
133 fiy0 = _mm_setzero_pd();
134 fiz0 = _mm_setzero_pd();
136 /* Load parameters for i particles */
137 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
139 /* Reset potential sums */
140 velecsum = _mm_setzero_pd();
142 /* Start inner kernel loop */
143 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
146 /* Get j neighbor index, and coordinate index */
149 j_coord_offsetA = DIM*jnrA;
150 j_coord_offsetB = DIM*jnrB;
152 /* load j atom coordinates */
153 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
156 /* Calculate displacement vector */
157 dx00 = _mm_sub_pd(ix0,jx0);
158 dy00 = _mm_sub_pd(iy0,jy0);
159 dz00 = _mm_sub_pd(iz0,jz0);
161 /* Calculate squared distance and things based on it */
162 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
164 rinv00 = gmx_mm_invsqrt_pd(rsq00);
166 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
168 /* Load parameters for j particles */
169 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
171 /**************************
172 * CALCULATE INTERACTIONS *
173 **************************/
175 /* Compute parameters for interactions between i and j atoms */
176 qq00 = _mm_mul_pd(iq0,jq0);
178 /* COULOMB ELECTROSTATICS */
179 velec = _mm_mul_pd(qq00,rinv00);
180 felec = _mm_mul_pd(velec,rinvsq00);
182 /* Update potential sum for this i atom from the interaction with this j atom. */
183 velecsum = _mm_add_pd(velecsum,velec);
187 /* Update vectorial force */
188 fix0 = _mm_macc_pd(dx00,fscal,fix0);
189 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
190 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
192 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
193 _mm_mul_pd(dx00,fscal),
194 _mm_mul_pd(dy00,fscal),
195 _mm_mul_pd(dz00,fscal));
197 /* Inner loop uses 31 flops */
204 j_coord_offsetA = DIM*jnrA;
206 /* load j atom coordinates */
207 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
210 /* Calculate displacement vector */
211 dx00 = _mm_sub_pd(ix0,jx0);
212 dy00 = _mm_sub_pd(iy0,jy0);
213 dz00 = _mm_sub_pd(iz0,jz0);
215 /* Calculate squared distance and things based on it */
216 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
218 rinv00 = gmx_mm_invsqrt_pd(rsq00);
220 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
222 /* Load parameters for j particles */
223 jq0 = _mm_load_sd(charge+jnrA+0);
225 /**************************
226 * CALCULATE INTERACTIONS *
227 **************************/
229 /* Compute parameters for interactions between i and j atoms */
230 qq00 = _mm_mul_pd(iq0,jq0);
232 /* COULOMB ELECTROSTATICS */
233 velec = _mm_mul_pd(qq00,rinv00);
234 felec = _mm_mul_pd(velec,rinvsq00);
236 /* Update potential sum for this i atom from the interaction with this j atom. */
237 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
238 velecsum = _mm_add_pd(velecsum,velec);
242 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
244 /* Update vectorial force */
245 fix0 = _mm_macc_pd(dx00,fscal,fix0);
246 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
247 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
249 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
250 _mm_mul_pd(dx00,fscal),
251 _mm_mul_pd(dy00,fscal),
252 _mm_mul_pd(dz00,fscal));
254 /* Inner loop uses 31 flops */
257 /* End of innermost loop */
259 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
260 f+i_coord_offset,fshift+i_shift_offset);
263 /* Update potential energies */
264 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
266 /* Increment number of inner iterations */
267 inneriter += j_index_end - j_index_start;
269 /* Outer loop uses 8 flops */
272 /* Increment number of outer iterations */
275 /* Update outer/inner flops */
277 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*31);
280 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_avx_128_fma_double
281 * Electrostatics interaction: Coulomb
282 * VdW interaction: None
283 * Geometry: Particle-Particle
284 * Calculate force/pot: Force
287 nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_avx_128_fma_double
288 (t_nblist * gmx_restrict nlist,
289 rvec * gmx_restrict xx,
290 rvec * gmx_restrict ff,
291 t_forcerec * gmx_restrict fr,
292 t_mdatoms * gmx_restrict mdatoms,
293 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
294 t_nrnb * gmx_restrict nrnb)
296 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
297 * just 0 for non-waters.
298 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
299 * jnr indices corresponding to data put in the four positions in the SIMD register.
301 int i_shift_offset,i_coord_offset,outeriter,inneriter;
302 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
304 int j_coord_offsetA,j_coord_offsetB;
305 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
307 real *shiftvec,*fshift,*x,*f;
308 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
310 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
311 int vdwjidx0A,vdwjidx0B;
312 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
313 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
314 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
316 __m128d dummy_mask,cutoff_mask;
317 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
318 __m128d one = _mm_set1_pd(1.0);
319 __m128d two = _mm_set1_pd(2.0);
325 jindex = nlist->jindex;
327 shiftidx = nlist->shift;
329 shiftvec = fr->shift_vec[0];
330 fshift = fr->fshift[0];
331 facel = _mm_set1_pd(fr->epsfac);
332 charge = mdatoms->chargeA;
334 /* Avoid stupid compiler warnings */
342 /* Start outer loop over neighborlists */
343 for(iidx=0; iidx<nri; iidx++)
345 /* Load shift vector for this list */
346 i_shift_offset = DIM*shiftidx[iidx];
348 /* Load limits for loop over neighbors */
349 j_index_start = jindex[iidx];
350 j_index_end = jindex[iidx+1];
352 /* Get outer coordinate index */
354 i_coord_offset = DIM*inr;
356 /* Load i particle coords and add shift vector */
357 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
359 fix0 = _mm_setzero_pd();
360 fiy0 = _mm_setzero_pd();
361 fiz0 = _mm_setzero_pd();
363 /* Load parameters for i particles */
364 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
366 /* Start inner kernel loop */
367 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
370 /* Get j neighbor index, and coordinate index */
373 j_coord_offsetA = DIM*jnrA;
374 j_coord_offsetB = DIM*jnrB;
376 /* load j atom coordinates */
377 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
380 /* Calculate displacement vector */
381 dx00 = _mm_sub_pd(ix0,jx0);
382 dy00 = _mm_sub_pd(iy0,jy0);
383 dz00 = _mm_sub_pd(iz0,jz0);
385 /* Calculate squared distance and things based on it */
386 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
388 rinv00 = gmx_mm_invsqrt_pd(rsq00);
390 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
392 /* Load parameters for j particles */
393 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
395 /**************************
396 * CALCULATE INTERACTIONS *
397 **************************/
399 /* Compute parameters for interactions between i and j atoms */
400 qq00 = _mm_mul_pd(iq0,jq0);
402 /* COULOMB ELECTROSTATICS */
403 velec = _mm_mul_pd(qq00,rinv00);
404 felec = _mm_mul_pd(velec,rinvsq00);
408 /* Update vectorial force */
409 fix0 = _mm_macc_pd(dx00,fscal,fix0);
410 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
411 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
413 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
414 _mm_mul_pd(dx00,fscal),
415 _mm_mul_pd(dy00,fscal),
416 _mm_mul_pd(dz00,fscal));
418 /* Inner loop uses 30 flops */
425 j_coord_offsetA = DIM*jnrA;
427 /* load j atom coordinates */
428 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
431 /* Calculate displacement vector */
432 dx00 = _mm_sub_pd(ix0,jx0);
433 dy00 = _mm_sub_pd(iy0,jy0);
434 dz00 = _mm_sub_pd(iz0,jz0);
436 /* Calculate squared distance and things based on it */
437 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
439 rinv00 = gmx_mm_invsqrt_pd(rsq00);
441 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
443 /* Load parameters for j particles */
444 jq0 = _mm_load_sd(charge+jnrA+0);
446 /**************************
447 * CALCULATE INTERACTIONS *
448 **************************/
450 /* Compute parameters for interactions between i and j atoms */
451 qq00 = _mm_mul_pd(iq0,jq0);
453 /* COULOMB ELECTROSTATICS */
454 velec = _mm_mul_pd(qq00,rinv00);
455 felec = _mm_mul_pd(velec,rinvsq00);
459 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
461 /* Update vectorial force */
462 fix0 = _mm_macc_pd(dx00,fscal,fix0);
463 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
464 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
466 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
467 _mm_mul_pd(dx00,fscal),
468 _mm_mul_pd(dy00,fscal),
469 _mm_mul_pd(dz00,fscal));
471 /* Inner loop uses 30 flops */
474 /* End of innermost loop */
476 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
477 f+i_coord_offset,fshift+i_shift_offset);
479 /* Increment number of inner iterations */
480 inneriter += j_index_end - j_index_start;
482 /* Outer loop uses 7 flops */
485 /* Increment number of outer iterations */
488 /* Update outer/inner flops */
490 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*30);