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_ElecEw_VdwNone_GeomP1P1_VF_avx_128_fma_double
38 * Electrostatics interaction: Ewald
39 * VdW interaction: None
40 * Geometry: Particle-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecEw_VdwNone_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;
71 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
74 __m128d ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
76 __m128d dummy_mask,cutoff_mask;
77 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
78 __m128d one = _mm_set1_pd(1.0);
79 __m128d two = _mm_set1_pd(2.0);
85 jindex = nlist->jindex;
87 shiftidx = nlist->shift;
89 shiftvec = fr->shift_vec[0];
90 fshift = fr->fshift[0];
91 facel = _mm_set1_pd(fr->epsfac);
92 charge = mdatoms->chargeA;
94 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
95 ewtab = fr->ic->tabq_coul_FDV0;
96 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
97 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
99 /* Avoid stupid compiler warnings */
107 /* Start outer loop over neighborlists */
108 for(iidx=0; iidx<nri; iidx++)
110 /* Load shift vector for this list */
111 i_shift_offset = DIM*shiftidx[iidx];
113 /* Load limits for loop over neighbors */
114 j_index_start = jindex[iidx];
115 j_index_end = jindex[iidx+1];
117 /* Get outer coordinate index */
119 i_coord_offset = DIM*inr;
121 /* Load i particle coords and add shift vector */
122 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
124 fix0 = _mm_setzero_pd();
125 fiy0 = _mm_setzero_pd();
126 fiz0 = _mm_setzero_pd();
128 /* Load parameters for i particles */
129 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
131 /* Reset potential sums */
132 velecsum = _mm_setzero_pd();
134 /* Start inner kernel loop */
135 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
138 /* Get j neighbor index, and coordinate index */
141 j_coord_offsetA = DIM*jnrA;
142 j_coord_offsetB = DIM*jnrB;
144 /* load j atom coordinates */
145 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
148 /* Calculate displacement vector */
149 dx00 = _mm_sub_pd(ix0,jx0);
150 dy00 = _mm_sub_pd(iy0,jy0);
151 dz00 = _mm_sub_pd(iz0,jz0);
153 /* Calculate squared distance and things based on it */
154 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
156 rinv00 = gmx_mm_invsqrt_pd(rsq00);
158 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
160 /* Load parameters for j particles */
161 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
163 /**************************
164 * CALCULATE INTERACTIONS *
165 **************************/
167 r00 = _mm_mul_pd(rsq00,rinv00);
169 /* Compute parameters for interactions between i and j atoms */
170 qq00 = _mm_mul_pd(iq0,jq0);
172 /* EWALD ELECTROSTATICS */
174 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
175 ewrt = _mm_mul_pd(r00,ewtabscale);
176 ewitab = _mm_cvttpd_epi32(ewrt);
178 eweps = _mm_frcz_pd(ewrt);
180 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
182 twoeweps = _mm_add_pd(eweps,eweps);
183 ewitab = _mm_slli_epi32(ewitab,2);
184 ewtabF = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,0) );
185 ewtabD = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,1) );
186 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
187 ewtabV = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,0) +2);
188 ewtabFn = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,1) +2);
189 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
190 felec = _mm_macc_pd(eweps,ewtabD,ewtabF);
191 velec = _mm_nmacc_pd(_mm_mul_pd(ewtabhalfspace,eweps) ,_mm_add_pd(ewtabF,felec), ewtabV);
192 velec = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
193 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
195 /* Update potential sum for this i atom from the interaction with this j atom. */
196 velecsum = _mm_add_pd(velecsum,velec);
200 /* Update vectorial force */
201 fix0 = _mm_macc_pd(dx00,fscal,fix0);
202 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
203 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
205 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
206 _mm_mul_pd(dx00,fscal),
207 _mm_mul_pd(dy00,fscal),
208 _mm_mul_pd(dz00,fscal));
210 /* Inner loop uses 44 flops */
217 j_coord_offsetA = DIM*jnrA;
219 /* load j atom coordinates */
220 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
223 /* Calculate displacement vector */
224 dx00 = _mm_sub_pd(ix0,jx0);
225 dy00 = _mm_sub_pd(iy0,jy0);
226 dz00 = _mm_sub_pd(iz0,jz0);
228 /* Calculate squared distance and things based on it */
229 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
231 rinv00 = gmx_mm_invsqrt_pd(rsq00);
233 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
235 /* Load parameters for j particles */
236 jq0 = _mm_load_sd(charge+jnrA+0);
238 /**************************
239 * CALCULATE INTERACTIONS *
240 **************************/
242 r00 = _mm_mul_pd(rsq00,rinv00);
244 /* Compute parameters for interactions between i and j atoms */
245 qq00 = _mm_mul_pd(iq0,jq0);
247 /* EWALD ELECTROSTATICS */
249 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
250 ewrt = _mm_mul_pd(r00,ewtabscale);
251 ewitab = _mm_cvttpd_epi32(ewrt);
253 eweps = _mm_frcz_pd(ewrt);
255 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
257 twoeweps = _mm_add_pd(eweps,eweps);
258 ewitab = _mm_slli_epi32(ewitab,2);
259 ewtabF = _mm_load_pd( ewtab + _mm_extract_epi32(ewitab,0) );
260 ewtabD = _mm_setzero_pd();
261 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
262 ewtabV = _mm_load_sd( ewtab + _mm_extract_epi32(ewitab,0) +2);
263 ewtabFn = _mm_setzero_pd();
264 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
265 felec = _mm_macc_pd(eweps,ewtabD,ewtabF);
266 velec = _mm_nmacc_pd(_mm_mul_pd(ewtabhalfspace,eweps) ,_mm_add_pd(ewtabF,felec), ewtabV);
267 velec = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
268 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
270 /* Update potential sum for this i atom from the interaction with this j atom. */
271 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
272 velecsum = _mm_add_pd(velecsum,velec);
276 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
278 /* Update vectorial force */
279 fix0 = _mm_macc_pd(dx00,fscal,fix0);
280 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
281 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
283 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
284 _mm_mul_pd(dx00,fscal),
285 _mm_mul_pd(dy00,fscal),
286 _mm_mul_pd(dz00,fscal));
288 /* Inner loop uses 44 flops */
291 /* End of innermost loop */
293 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
294 f+i_coord_offset,fshift+i_shift_offset);
297 /* Update potential energies */
298 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
300 /* Increment number of inner iterations */
301 inneriter += j_index_end - j_index_start;
303 /* Outer loop uses 8 flops */
306 /* Increment number of outer iterations */
309 /* Update outer/inner flops */
311 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*44);
314 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomP1P1_F_avx_128_fma_double
315 * Electrostatics interaction: Ewald
316 * VdW interaction: None
317 * Geometry: Particle-Particle
318 * Calculate force/pot: Force
321 nb_kernel_ElecEw_VdwNone_GeomP1P1_F_avx_128_fma_double
322 (t_nblist * gmx_restrict nlist,
323 rvec * gmx_restrict xx,
324 rvec * gmx_restrict ff,
325 t_forcerec * gmx_restrict fr,
326 t_mdatoms * gmx_restrict mdatoms,
327 nb_kernel_data_t * gmx_restrict kernel_data,
328 t_nrnb * gmx_restrict nrnb)
330 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
331 * just 0 for non-waters.
332 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
333 * jnr indices corresponding to data put in the four positions in the SIMD register.
335 int i_shift_offset,i_coord_offset,outeriter,inneriter;
336 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
338 int j_coord_offsetA,j_coord_offsetB;
339 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
341 real *shiftvec,*fshift,*x,*f;
342 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
344 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
345 int vdwjidx0A,vdwjidx0B;
346 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
347 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
348 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
351 __m128d ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
353 __m128d dummy_mask,cutoff_mask;
354 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
355 __m128d one = _mm_set1_pd(1.0);
356 __m128d two = _mm_set1_pd(2.0);
362 jindex = nlist->jindex;
364 shiftidx = nlist->shift;
366 shiftvec = fr->shift_vec[0];
367 fshift = fr->fshift[0];
368 facel = _mm_set1_pd(fr->epsfac);
369 charge = mdatoms->chargeA;
371 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
372 ewtab = fr->ic->tabq_coul_F;
373 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
374 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
376 /* Avoid stupid compiler warnings */
384 /* Start outer loop over neighborlists */
385 for(iidx=0; iidx<nri; iidx++)
387 /* Load shift vector for this list */
388 i_shift_offset = DIM*shiftidx[iidx];
390 /* Load limits for loop over neighbors */
391 j_index_start = jindex[iidx];
392 j_index_end = jindex[iidx+1];
394 /* Get outer coordinate index */
396 i_coord_offset = DIM*inr;
398 /* Load i particle coords and add shift vector */
399 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
401 fix0 = _mm_setzero_pd();
402 fiy0 = _mm_setzero_pd();
403 fiz0 = _mm_setzero_pd();
405 /* Load parameters for i particles */
406 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
408 /* Start inner kernel loop */
409 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
412 /* Get j neighbor index, and coordinate index */
415 j_coord_offsetA = DIM*jnrA;
416 j_coord_offsetB = DIM*jnrB;
418 /* load j atom coordinates */
419 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
422 /* Calculate displacement vector */
423 dx00 = _mm_sub_pd(ix0,jx0);
424 dy00 = _mm_sub_pd(iy0,jy0);
425 dz00 = _mm_sub_pd(iz0,jz0);
427 /* Calculate squared distance and things based on it */
428 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
430 rinv00 = gmx_mm_invsqrt_pd(rsq00);
432 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
434 /* Load parameters for j particles */
435 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
441 r00 = _mm_mul_pd(rsq00,rinv00);
443 /* Compute parameters for interactions between i and j atoms */
444 qq00 = _mm_mul_pd(iq0,jq0);
446 /* EWALD ELECTROSTATICS */
448 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
449 ewrt = _mm_mul_pd(r00,ewtabscale);
450 ewitab = _mm_cvttpd_epi32(ewrt);
452 eweps = _mm_frcz_pd(ewrt);
454 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
456 twoeweps = _mm_add_pd(eweps,eweps);
457 gmx_mm_load_2pair_swizzle_pd(ewtab+_mm_extract_epi32(ewitab,0),ewtab+_mm_extract_epi32(ewitab,1),
459 felec = _mm_macc_pd(eweps,ewtabFn,_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF));
460 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
464 /* Update vectorial force */
465 fix0 = _mm_macc_pd(dx00,fscal,fix0);
466 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
467 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
469 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
470 _mm_mul_pd(dx00,fscal),
471 _mm_mul_pd(dy00,fscal),
472 _mm_mul_pd(dz00,fscal));
474 /* Inner loop uses 39 flops */
481 j_coord_offsetA = DIM*jnrA;
483 /* load j atom coordinates */
484 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
487 /* Calculate displacement vector */
488 dx00 = _mm_sub_pd(ix0,jx0);
489 dy00 = _mm_sub_pd(iy0,jy0);
490 dz00 = _mm_sub_pd(iz0,jz0);
492 /* Calculate squared distance and things based on it */
493 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
495 rinv00 = gmx_mm_invsqrt_pd(rsq00);
497 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
499 /* Load parameters for j particles */
500 jq0 = _mm_load_sd(charge+jnrA+0);
502 /**************************
503 * CALCULATE INTERACTIONS *
504 **************************/
506 r00 = _mm_mul_pd(rsq00,rinv00);
508 /* Compute parameters for interactions between i and j atoms */
509 qq00 = _mm_mul_pd(iq0,jq0);
511 /* EWALD ELECTROSTATICS */
513 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
514 ewrt = _mm_mul_pd(r00,ewtabscale);
515 ewitab = _mm_cvttpd_epi32(ewrt);
517 eweps = _mm_frcz_pd(ewrt);
519 eweps = _mm_sub_pd(ewrt,_mm_round_pd(ewrt, _MM_FROUND_FLOOR));
521 twoeweps = _mm_add_pd(eweps,eweps);
522 gmx_mm_load_1pair_swizzle_pd(ewtab+_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
523 felec = _mm_macc_pd(eweps,ewtabFn,_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF));
524 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
528 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
530 /* Update vectorial force */
531 fix0 = _mm_macc_pd(dx00,fscal,fix0);
532 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
533 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
535 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
536 _mm_mul_pd(dx00,fscal),
537 _mm_mul_pd(dy00,fscal),
538 _mm_mul_pd(dz00,fscal));
540 /* Inner loop uses 39 flops */
543 /* End of innermost loop */
545 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
546 f+i_coord_offset,fshift+i_shift_offset);
548 /* Increment number of inner iterations */
549 inneriter += j_index_end - j_index_start;
551 /* Outer loop uses 7 flops */
554 /* Increment number of outer iterations */
557 /* Update outer/inner flops */
559 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*39);