2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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 "gmx_math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwNone_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: GeneralizedBorn
55 * VdW interaction: None
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecGB_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_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;
90 __m128d vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,twogbeps,dvdatmp;
91 __m128d minushalf = _mm_set1_pd(-0.5);
92 real *invsqrta,*dvda,*gbtab;
94 __m128i ifour = _mm_set1_epi32(4);
95 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
97 __m128d dummy_mask,cutoff_mask;
98 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
99 __m128d one = _mm_set1_pd(1.0);
100 __m128d two = _mm_set1_pd(2.0);
106 jindex = nlist->jindex;
108 shiftidx = nlist->shift;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
112 facel = _mm_set1_pd(fr->epsfac);
113 charge = mdatoms->chargeA;
115 invsqrta = fr->invsqrta;
117 gbtabscale = _mm_set1_pd(fr->gbtab.scale);
118 gbtab = fr->gbtab.data;
119 gbinvepsdiff = _mm_set1_pd((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
121 /* Avoid stupid compiler warnings */
129 /* Start outer loop over neighborlists */
130 for(iidx=0; iidx<nri; iidx++)
132 /* Load shift vector for this list */
133 i_shift_offset = DIM*shiftidx[iidx];
135 /* Load limits for loop over neighbors */
136 j_index_start = jindex[iidx];
137 j_index_end = jindex[iidx+1];
139 /* Get outer coordinate index */
141 i_coord_offset = DIM*inr;
143 /* Load i particle coords and add shift vector */
144 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
146 fix0 = _mm_setzero_pd();
147 fiy0 = _mm_setzero_pd();
148 fiz0 = _mm_setzero_pd();
150 /* Load parameters for i particles */
151 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
152 isai0 = _mm_load1_pd(invsqrta+inr+0);
154 /* Reset potential sums */
155 velecsum = _mm_setzero_pd();
156 vgbsum = _mm_setzero_pd();
157 dvdasum = _mm_setzero_pd();
159 /* Start inner kernel loop */
160 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
163 /* Get j neighbor index, and coordinate index */
166 j_coord_offsetA = DIM*jnrA;
167 j_coord_offsetB = DIM*jnrB;
169 /* load j atom coordinates */
170 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
173 /* Calculate displacement vector */
174 dx00 = _mm_sub_pd(ix0,jx0);
175 dy00 = _mm_sub_pd(iy0,jy0);
176 dz00 = _mm_sub_pd(iz0,jz0);
178 /* Calculate squared distance and things based on it */
179 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
181 rinv00 = gmx_mm_invsqrt_pd(rsq00);
183 /* Load parameters for j particles */
184 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
185 isaj0 = gmx_mm_load_2real_swizzle_pd(invsqrta+jnrA+0,invsqrta+jnrB+0);
187 /**************************
188 * CALCULATE INTERACTIONS *
189 **************************/
191 r00 = _mm_mul_pd(rsq00,rinv00);
193 /* Compute parameters for interactions between i and j atoms */
194 qq00 = _mm_mul_pd(iq0,jq0);
196 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
197 isaprod = _mm_mul_pd(isai0,isaj0);
198 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
199 gbscale = _mm_mul_pd(isaprod,gbtabscale);
201 /* Calculate generalized born table index - this is a separate table from the normal one,
202 * but we use the same procedure by multiplying r with scale and truncating to integer.
204 rt = _mm_mul_pd(r00,gbscale);
205 gbitab = _mm_cvttpd_epi32(rt);
207 gbeps = _mm_frcz_pd(rt);
209 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
211 gbitab = _mm_slli_epi32(gbitab,2);
213 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
214 F = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) );
215 GMX_MM_TRANSPOSE2_PD(Y,F);
216 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
217 H = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) +2);
218 GMX_MM_TRANSPOSE2_PD(G,H);
219 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
220 VV = _mm_macc_pd(gbeps,Fp,Y);
221 vgb = _mm_mul_pd(gbqqfactor,VV);
223 twogbeps = _mm_add_pd(gbeps,gbeps);
224 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
225 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
226 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
227 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
228 gmx_mm_increment_2real_swizzle_pd(dvda+jnrA,dvda+jnrB,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
229 velec = _mm_mul_pd(qq00,rinv00);
230 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
232 /* Update potential sum for this i atom from the interaction with this j atom. */
233 velecsum = _mm_add_pd(velecsum,velec);
234 vgbsum = _mm_add_pd(vgbsum,vgb);
238 /* Update vectorial force */
239 fix0 = _mm_macc_pd(dx00,fscal,fix0);
240 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
241 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
243 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
244 _mm_mul_pd(dx00,fscal),
245 _mm_mul_pd(dy00,fscal),
246 _mm_mul_pd(dz00,fscal));
248 /* Inner loop uses 61 flops */
255 j_coord_offsetA = DIM*jnrA;
257 /* load j atom coordinates */
258 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
261 /* Calculate displacement vector */
262 dx00 = _mm_sub_pd(ix0,jx0);
263 dy00 = _mm_sub_pd(iy0,jy0);
264 dz00 = _mm_sub_pd(iz0,jz0);
266 /* Calculate squared distance and things based on it */
267 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
269 rinv00 = gmx_mm_invsqrt_pd(rsq00);
271 /* Load parameters for j particles */
272 jq0 = _mm_load_sd(charge+jnrA+0);
273 isaj0 = _mm_load_sd(invsqrta+jnrA+0);
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 r00 = _mm_mul_pd(rsq00,rinv00);
281 /* Compute parameters for interactions between i and j atoms */
282 qq00 = _mm_mul_pd(iq0,jq0);
284 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
285 isaprod = _mm_mul_pd(isai0,isaj0);
286 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
287 gbscale = _mm_mul_pd(isaprod,gbtabscale);
289 /* Calculate generalized born table index - this is a separate table from the normal one,
290 * but we use the same procedure by multiplying r with scale and truncating to integer.
292 rt = _mm_mul_pd(r00,gbscale);
293 gbitab = _mm_cvttpd_epi32(rt);
295 gbeps = _mm_frcz_pd(rt);
297 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
299 gbitab = _mm_slli_epi32(gbitab,2);
301 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
302 F = _mm_setzero_pd();
303 GMX_MM_TRANSPOSE2_PD(Y,F);
304 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
305 H = _mm_setzero_pd();
306 GMX_MM_TRANSPOSE2_PD(G,H);
307 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
308 VV = _mm_macc_pd(gbeps,Fp,Y);
309 vgb = _mm_mul_pd(gbqqfactor,VV);
311 twogbeps = _mm_add_pd(gbeps,gbeps);
312 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
313 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
314 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
315 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
316 gmx_mm_increment_1real_pd(dvda+jnrA,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
317 velec = _mm_mul_pd(qq00,rinv00);
318 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
320 /* Update potential sum for this i atom from the interaction with this j atom. */
321 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
322 velecsum = _mm_add_pd(velecsum,velec);
323 vgb = _mm_unpacklo_pd(vgb,_mm_setzero_pd());
324 vgbsum = _mm_add_pd(vgbsum,vgb);
328 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
330 /* Update vectorial force */
331 fix0 = _mm_macc_pd(dx00,fscal,fix0);
332 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
333 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
335 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
336 _mm_mul_pd(dx00,fscal),
337 _mm_mul_pd(dy00,fscal),
338 _mm_mul_pd(dz00,fscal));
340 /* Inner loop uses 61 flops */
343 /* End of innermost loop */
345 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
346 f+i_coord_offset,fshift+i_shift_offset);
349 /* Update potential energies */
350 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
351 gmx_mm_update_1pot_pd(vgbsum,kernel_data->energygrp_polarization+ggid);
352 dvdasum = _mm_mul_pd(dvdasum, _mm_mul_pd(isai0,isai0));
353 gmx_mm_update_1pot_pd(dvdasum,dvda+inr);
355 /* Increment number of inner iterations */
356 inneriter += j_index_end - j_index_start;
358 /* Outer loop uses 9 flops */
361 /* Increment number of outer iterations */
364 /* Update outer/inner flops */
366 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*9 + inneriter*61);
369 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwNone_GeomP1P1_F_avx_128_fma_double
370 * Electrostatics interaction: GeneralizedBorn
371 * VdW interaction: None
372 * Geometry: Particle-Particle
373 * Calculate force/pot: Force
376 nb_kernel_ElecGB_VdwNone_GeomP1P1_F_avx_128_fma_double
377 (t_nblist * gmx_restrict nlist,
378 rvec * gmx_restrict xx,
379 rvec * gmx_restrict ff,
380 t_forcerec * gmx_restrict fr,
381 t_mdatoms * gmx_restrict mdatoms,
382 nb_kernel_data_t * gmx_restrict kernel_data,
383 t_nrnb * gmx_restrict nrnb)
385 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
386 * just 0 for non-waters.
387 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
388 * jnr indices corresponding to data put in the four positions in the SIMD register.
390 int i_shift_offset,i_coord_offset,outeriter,inneriter;
391 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
393 int j_coord_offsetA,j_coord_offsetB;
394 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
396 real *shiftvec,*fshift,*x,*f;
397 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
399 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
400 int vdwjidx0A,vdwjidx0B;
401 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
402 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
403 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
406 __m128d vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,twogbeps,dvdatmp;
407 __m128d minushalf = _mm_set1_pd(-0.5);
408 real *invsqrta,*dvda,*gbtab;
410 __m128i ifour = _mm_set1_epi32(4);
411 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
413 __m128d dummy_mask,cutoff_mask;
414 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
415 __m128d one = _mm_set1_pd(1.0);
416 __m128d two = _mm_set1_pd(2.0);
422 jindex = nlist->jindex;
424 shiftidx = nlist->shift;
426 shiftvec = fr->shift_vec[0];
427 fshift = fr->fshift[0];
428 facel = _mm_set1_pd(fr->epsfac);
429 charge = mdatoms->chargeA;
431 invsqrta = fr->invsqrta;
433 gbtabscale = _mm_set1_pd(fr->gbtab.scale);
434 gbtab = fr->gbtab.data;
435 gbinvepsdiff = _mm_set1_pd((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
437 /* Avoid stupid compiler warnings */
445 /* Start outer loop over neighborlists */
446 for(iidx=0; iidx<nri; iidx++)
448 /* Load shift vector for this list */
449 i_shift_offset = DIM*shiftidx[iidx];
451 /* Load limits for loop over neighbors */
452 j_index_start = jindex[iidx];
453 j_index_end = jindex[iidx+1];
455 /* Get outer coordinate index */
457 i_coord_offset = DIM*inr;
459 /* Load i particle coords and add shift vector */
460 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
462 fix0 = _mm_setzero_pd();
463 fiy0 = _mm_setzero_pd();
464 fiz0 = _mm_setzero_pd();
466 /* Load parameters for i particles */
467 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
468 isai0 = _mm_load1_pd(invsqrta+inr+0);
470 dvdasum = _mm_setzero_pd();
472 /* Start inner kernel loop */
473 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
476 /* Get j neighbor index, and coordinate index */
479 j_coord_offsetA = DIM*jnrA;
480 j_coord_offsetB = DIM*jnrB;
482 /* load j atom coordinates */
483 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
486 /* Calculate displacement vector */
487 dx00 = _mm_sub_pd(ix0,jx0);
488 dy00 = _mm_sub_pd(iy0,jy0);
489 dz00 = _mm_sub_pd(iz0,jz0);
491 /* Calculate squared distance and things based on it */
492 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
494 rinv00 = gmx_mm_invsqrt_pd(rsq00);
496 /* Load parameters for j particles */
497 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
498 isaj0 = gmx_mm_load_2real_swizzle_pd(invsqrta+jnrA+0,invsqrta+jnrB+0);
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
504 r00 = _mm_mul_pd(rsq00,rinv00);
506 /* Compute parameters for interactions between i and j atoms */
507 qq00 = _mm_mul_pd(iq0,jq0);
509 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
510 isaprod = _mm_mul_pd(isai0,isaj0);
511 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
512 gbscale = _mm_mul_pd(isaprod,gbtabscale);
514 /* Calculate generalized born table index - this is a separate table from the normal one,
515 * but we use the same procedure by multiplying r with scale and truncating to integer.
517 rt = _mm_mul_pd(r00,gbscale);
518 gbitab = _mm_cvttpd_epi32(rt);
520 gbeps = _mm_frcz_pd(rt);
522 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
524 gbitab = _mm_slli_epi32(gbitab,2);
526 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
527 F = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) );
528 GMX_MM_TRANSPOSE2_PD(Y,F);
529 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
530 H = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) +2);
531 GMX_MM_TRANSPOSE2_PD(G,H);
532 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
533 VV = _mm_macc_pd(gbeps,Fp,Y);
534 vgb = _mm_mul_pd(gbqqfactor,VV);
536 twogbeps = _mm_add_pd(gbeps,gbeps);
537 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
538 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
539 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
540 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
541 gmx_mm_increment_2real_swizzle_pd(dvda+jnrA,dvda+jnrB,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
542 velec = _mm_mul_pd(qq00,rinv00);
543 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
547 /* Update vectorial force */
548 fix0 = _mm_macc_pd(dx00,fscal,fix0);
549 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
550 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
552 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
553 _mm_mul_pd(dx00,fscal),
554 _mm_mul_pd(dy00,fscal),
555 _mm_mul_pd(dz00,fscal));
557 /* Inner loop uses 59 flops */
564 j_coord_offsetA = DIM*jnrA;
566 /* load j atom coordinates */
567 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
570 /* Calculate displacement vector */
571 dx00 = _mm_sub_pd(ix0,jx0);
572 dy00 = _mm_sub_pd(iy0,jy0);
573 dz00 = _mm_sub_pd(iz0,jz0);
575 /* Calculate squared distance and things based on it */
576 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
578 rinv00 = gmx_mm_invsqrt_pd(rsq00);
580 /* Load parameters for j particles */
581 jq0 = _mm_load_sd(charge+jnrA+0);
582 isaj0 = _mm_load_sd(invsqrta+jnrA+0);
584 /**************************
585 * CALCULATE INTERACTIONS *
586 **************************/
588 r00 = _mm_mul_pd(rsq00,rinv00);
590 /* Compute parameters for interactions between i and j atoms */
591 qq00 = _mm_mul_pd(iq0,jq0);
593 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
594 isaprod = _mm_mul_pd(isai0,isaj0);
595 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
596 gbscale = _mm_mul_pd(isaprod,gbtabscale);
598 /* Calculate generalized born table index - this is a separate table from the normal one,
599 * but we use the same procedure by multiplying r with scale and truncating to integer.
601 rt = _mm_mul_pd(r00,gbscale);
602 gbitab = _mm_cvttpd_epi32(rt);
604 gbeps = _mm_frcz_pd(rt);
606 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
608 gbitab = _mm_slli_epi32(gbitab,2);
610 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
611 F = _mm_setzero_pd();
612 GMX_MM_TRANSPOSE2_PD(Y,F);
613 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
614 H = _mm_setzero_pd();
615 GMX_MM_TRANSPOSE2_PD(G,H);
616 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
617 VV = _mm_macc_pd(gbeps,Fp,Y);
618 vgb = _mm_mul_pd(gbqqfactor,VV);
620 twogbeps = _mm_add_pd(gbeps,gbeps);
621 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
622 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
623 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
624 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
625 gmx_mm_increment_1real_pd(dvda+jnrA,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
626 velec = _mm_mul_pd(qq00,rinv00);
627 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
631 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
633 /* Update vectorial force */
634 fix0 = _mm_macc_pd(dx00,fscal,fix0);
635 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
636 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
638 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
639 _mm_mul_pd(dx00,fscal),
640 _mm_mul_pd(dy00,fscal),
641 _mm_mul_pd(dz00,fscal));
643 /* Inner loop uses 59 flops */
646 /* End of innermost loop */
648 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
649 f+i_coord_offset,fshift+i_shift_offset);
651 dvdasum = _mm_mul_pd(dvdasum, _mm_mul_pd(isai0,isai0));
652 gmx_mm_update_1pot_pd(dvdasum,dvda+inr);
654 /* Increment number of inner iterations */
655 inneriter += j_index_end - j_index_start;
657 /* Outer loop uses 7 flops */
660 /* Increment number of outer iterations */
663 /* Update outer/inner flops */
665 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*59);