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_VdwLJ_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: GeneralizedBorn
55 * VdW interaction: LennardJones
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecGB_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_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 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
97 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
98 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
100 __m128i ifour = _mm_set1_epi32(4);
101 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
103 __m128d dummy_mask,cutoff_mask;
104 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
105 __m128d one = _mm_set1_pd(1.0);
106 __m128d two = _mm_set1_pd(2.0);
112 jindex = nlist->jindex;
114 shiftidx = nlist->shift;
116 shiftvec = fr->shift_vec[0];
117 fshift = fr->fshift[0];
118 facel = _mm_set1_pd(fr->epsfac);
119 charge = mdatoms->chargeA;
120 nvdwtype = fr->ntype;
122 vdwtype = mdatoms->typeA;
124 invsqrta = fr->invsqrta;
126 gbtabscale = _mm_set1_pd(fr->gbtab.scale);
127 gbtab = fr->gbtab.data;
128 gbinvepsdiff = _mm_set1_pd((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
130 /* Avoid stupid compiler warnings */
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
155 fix0 = _mm_setzero_pd();
156 fiy0 = _mm_setzero_pd();
157 fiz0 = _mm_setzero_pd();
159 /* Load parameters for i particles */
160 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
161 isai0 = _mm_load1_pd(invsqrta+inr+0);
162 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
164 /* Reset potential sums */
165 velecsum = _mm_setzero_pd();
166 vgbsum = _mm_setzero_pd();
167 vvdwsum = _mm_setzero_pd();
168 dvdasum = _mm_setzero_pd();
170 /* Start inner kernel loop */
171 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
174 /* Get j neighbor index, and coordinate index */
177 j_coord_offsetA = DIM*jnrA;
178 j_coord_offsetB = DIM*jnrB;
180 /* load j atom coordinates */
181 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
184 /* Calculate displacement vector */
185 dx00 = _mm_sub_pd(ix0,jx0);
186 dy00 = _mm_sub_pd(iy0,jy0);
187 dz00 = _mm_sub_pd(iz0,jz0);
189 /* Calculate squared distance and things based on it */
190 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
192 rinv00 = gmx_mm_invsqrt_pd(rsq00);
194 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
196 /* Load parameters for j particles */
197 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
198 isaj0 = gmx_mm_load_2real_swizzle_pd(invsqrta+jnrA+0,invsqrta+jnrB+0);
199 vdwjidx0A = 2*vdwtype[jnrA+0];
200 vdwjidx0B = 2*vdwtype[jnrB+0];
202 /**************************
203 * CALCULATE INTERACTIONS *
204 **************************/
206 r00 = _mm_mul_pd(rsq00,rinv00);
208 /* Compute parameters for interactions between i and j atoms */
209 qq00 = _mm_mul_pd(iq0,jq0);
210 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
211 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
213 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
214 isaprod = _mm_mul_pd(isai0,isaj0);
215 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
216 gbscale = _mm_mul_pd(isaprod,gbtabscale);
218 /* Calculate generalized born table index - this is a separate table from the normal one,
219 * but we use the same procedure by multiplying r with scale and truncating to integer.
221 rt = _mm_mul_pd(r00,gbscale);
222 gbitab = _mm_cvttpd_epi32(rt);
224 gbeps = _mm_frcz_pd(rt);
226 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
228 gbitab = _mm_slli_epi32(gbitab,2);
230 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
231 F = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) );
232 GMX_MM_TRANSPOSE2_PD(Y,F);
233 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
234 H = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) +2);
235 GMX_MM_TRANSPOSE2_PD(G,H);
236 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
237 VV = _mm_macc_pd(gbeps,Fp,Y);
238 vgb = _mm_mul_pd(gbqqfactor,VV);
240 twogbeps = _mm_add_pd(gbeps,gbeps);
241 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
242 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
243 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
244 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
245 gmx_mm_increment_2real_swizzle_pd(dvda+jnrA,dvda+jnrB,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
246 velec = _mm_mul_pd(qq00,rinv00);
247 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
249 /* LENNARD-JONES DISPERSION/REPULSION */
251 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
252 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
253 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
254 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
255 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
257 /* Update potential sum for this i atom from the interaction with this j atom. */
258 velecsum = _mm_add_pd(velecsum,velec);
259 vgbsum = _mm_add_pd(vgbsum,vgb);
260 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
262 fscal = _mm_add_pd(felec,fvdw);
264 /* Update vectorial force */
265 fix0 = _mm_macc_pd(dx00,fscal,fix0);
266 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
267 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
269 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
270 _mm_mul_pd(dx00,fscal),
271 _mm_mul_pd(dy00,fscal),
272 _mm_mul_pd(dz00,fscal));
274 /* Inner loop uses 74 flops */
281 j_coord_offsetA = DIM*jnrA;
283 /* load j atom coordinates */
284 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
287 /* Calculate displacement vector */
288 dx00 = _mm_sub_pd(ix0,jx0);
289 dy00 = _mm_sub_pd(iy0,jy0);
290 dz00 = _mm_sub_pd(iz0,jz0);
292 /* Calculate squared distance and things based on it */
293 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
295 rinv00 = gmx_mm_invsqrt_pd(rsq00);
297 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
299 /* Load parameters for j particles */
300 jq0 = _mm_load_sd(charge+jnrA+0);
301 isaj0 = _mm_load_sd(invsqrta+jnrA+0);
302 vdwjidx0A = 2*vdwtype[jnrA+0];
304 /**************************
305 * CALCULATE INTERACTIONS *
306 **************************/
308 r00 = _mm_mul_pd(rsq00,rinv00);
310 /* Compute parameters for interactions between i and j atoms */
311 qq00 = _mm_mul_pd(iq0,jq0);
312 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
314 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
315 isaprod = _mm_mul_pd(isai0,isaj0);
316 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
317 gbscale = _mm_mul_pd(isaprod,gbtabscale);
319 /* Calculate generalized born table index - this is a separate table from the normal one,
320 * but we use the same procedure by multiplying r with scale and truncating to integer.
322 rt = _mm_mul_pd(r00,gbscale);
323 gbitab = _mm_cvttpd_epi32(rt);
325 gbeps = _mm_frcz_pd(rt);
327 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
329 gbitab = _mm_slli_epi32(gbitab,2);
331 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
332 F = _mm_setzero_pd();
333 GMX_MM_TRANSPOSE2_PD(Y,F);
334 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
335 H = _mm_setzero_pd();
336 GMX_MM_TRANSPOSE2_PD(G,H);
337 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
338 VV = _mm_macc_pd(gbeps,Fp,Y);
339 vgb = _mm_mul_pd(gbqqfactor,VV);
341 twogbeps = _mm_add_pd(gbeps,gbeps);
342 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
343 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
344 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
345 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
346 gmx_mm_increment_1real_pd(dvda+jnrA,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
347 velec = _mm_mul_pd(qq00,rinv00);
348 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
350 /* LENNARD-JONES DISPERSION/REPULSION */
352 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
353 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
354 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
355 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
356 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
358 /* Update potential sum for this i atom from the interaction with this j atom. */
359 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
360 velecsum = _mm_add_pd(velecsum,velec);
361 vgb = _mm_unpacklo_pd(vgb,_mm_setzero_pd());
362 vgbsum = _mm_add_pd(vgbsum,vgb);
363 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
364 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
366 fscal = _mm_add_pd(felec,fvdw);
368 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
370 /* Update vectorial force */
371 fix0 = _mm_macc_pd(dx00,fscal,fix0);
372 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
373 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
375 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
376 _mm_mul_pd(dx00,fscal),
377 _mm_mul_pd(dy00,fscal),
378 _mm_mul_pd(dz00,fscal));
380 /* Inner loop uses 74 flops */
383 /* End of innermost loop */
385 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
386 f+i_coord_offset,fshift+i_shift_offset);
389 /* Update potential energies */
390 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
391 gmx_mm_update_1pot_pd(vgbsum,kernel_data->energygrp_polarization+ggid);
392 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
393 dvdasum = _mm_mul_pd(dvdasum, _mm_mul_pd(isai0,isai0));
394 gmx_mm_update_1pot_pd(dvdasum,dvda+inr);
396 /* Increment number of inner iterations */
397 inneriter += j_index_end - j_index_start;
399 /* Outer loop uses 10 flops */
402 /* Increment number of outer iterations */
405 /* Update outer/inner flops */
407 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*10 + inneriter*74);
410 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_avx_128_fma_double
411 * Electrostatics interaction: GeneralizedBorn
412 * VdW interaction: LennardJones
413 * Geometry: Particle-Particle
414 * Calculate force/pot: Force
417 nb_kernel_ElecGB_VdwLJ_GeomP1P1_F_avx_128_fma_double
418 (t_nblist * gmx_restrict nlist,
419 rvec * gmx_restrict xx,
420 rvec * gmx_restrict ff,
421 t_forcerec * gmx_restrict fr,
422 t_mdatoms * gmx_restrict mdatoms,
423 nb_kernel_data_t * gmx_restrict kernel_data,
424 t_nrnb * gmx_restrict nrnb)
426 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
427 * just 0 for non-waters.
428 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
429 * jnr indices corresponding to data put in the four positions in the SIMD register.
431 int i_shift_offset,i_coord_offset,outeriter,inneriter;
432 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
434 int j_coord_offsetA,j_coord_offsetB;
435 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
437 real *shiftvec,*fshift,*x,*f;
438 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
440 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
441 int vdwjidx0A,vdwjidx0B;
442 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
443 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
444 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
447 __m128d vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,twogbeps,dvdatmp;
448 __m128d minushalf = _mm_set1_pd(-0.5);
449 real *invsqrta,*dvda,*gbtab;
451 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
454 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
455 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
457 __m128i ifour = _mm_set1_epi32(4);
458 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
460 __m128d dummy_mask,cutoff_mask;
461 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
462 __m128d one = _mm_set1_pd(1.0);
463 __m128d two = _mm_set1_pd(2.0);
469 jindex = nlist->jindex;
471 shiftidx = nlist->shift;
473 shiftvec = fr->shift_vec[0];
474 fshift = fr->fshift[0];
475 facel = _mm_set1_pd(fr->epsfac);
476 charge = mdatoms->chargeA;
477 nvdwtype = fr->ntype;
479 vdwtype = mdatoms->typeA;
481 invsqrta = fr->invsqrta;
483 gbtabscale = _mm_set1_pd(fr->gbtab.scale);
484 gbtab = fr->gbtab.data;
485 gbinvepsdiff = _mm_set1_pd((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
487 /* Avoid stupid compiler warnings */
495 /* Start outer loop over neighborlists */
496 for(iidx=0; iidx<nri; iidx++)
498 /* Load shift vector for this list */
499 i_shift_offset = DIM*shiftidx[iidx];
501 /* Load limits for loop over neighbors */
502 j_index_start = jindex[iidx];
503 j_index_end = jindex[iidx+1];
505 /* Get outer coordinate index */
507 i_coord_offset = DIM*inr;
509 /* Load i particle coords and add shift vector */
510 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
512 fix0 = _mm_setzero_pd();
513 fiy0 = _mm_setzero_pd();
514 fiz0 = _mm_setzero_pd();
516 /* Load parameters for i particles */
517 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
518 isai0 = _mm_load1_pd(invsqrta+inr+0);
519 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
521 dvdasum = _mm_setzero_pd();
523 /* Start inner kernel loop */
524 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
527 /* Get j neighbor index, and coordinate index */
530 j_coord_offsetA = DIM*jnrA;
531 j_coord_offsetB = DIM*jnrB;
533 /* load j atom coordinates */
534 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
537 /* Calculate displacement vector */
538 dx00 = _mm_sub_pd(ix0,jx0);
539 dy00 = _mm_sub_pd(iy0,jy0);
540 dz00 = _mm_sub_pd(iz0,jz0);
542 /* Calculate squared distance and things based on it */
543 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
545 rinv00 = gmx_mm_invsqrt_pd(rsq00);
547 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
549 /* Load parameters for j particles */
550 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
551 isaj0 = gmx_mm_load_2real_swizzle_pd(invsqrta+jnrA+0,invsqrta+jnrB+0);
552 vdwjidx0A = 2*vdwtype[jnrA+0];
553 vdwjidx0B = 2*vdwtype[jnrB+0];
555 /**************************
556 * CALCULATE INTERACTIONS *
557 **************************/
559 r00 = _mm_mul_pd(rsq00,rinv00);
561 /* Compute parameters for interactions between i and j atoms */
562 qq00 = _mm_mul_pd(iq0,jq0);
563 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
564 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
566 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
567 isaprod = _mm_mul_pd(isai0,isaj0);
568 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
569 gbscale = _mm_mul_pd(isaprod,gbtabscale);
571 /* Calculate generalized born table index - this is a separate table from the normal one,
572 * but we use the same procedure by multiplying r with scale and truncating to integer.
574 rt = _mm_mul_pd(r00,gbscale);
575 gbitab = _mm_cvttpd_epi32(rt);
577 gbeps = _mm_frcz_pd(rt);
579 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
581 gbitab = _mm_slli_epi32(gbitab,2);
583 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
584 F = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) );
585 GMX_MM_TRANSPOSE2_PD(Y,F);
586 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
587 H = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,1) +2);
588 GMX_MM_TRANSPOSE2_PD(G,H);
589 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
590 VV = _mm_macc_pd(gbeps,Fp,Y);
591 vgb = _mm_mul_pd(gbqqfactor,VV);
593 twogbeps = _mm_add_pd(gbeps,gbeps);
594 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
595 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
596 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
597 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
598 gmx_mm_increment_2real_swizzle_pd(dvda+jnrA,dvda+jnrB,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
599 velec = _mm_mul_pd(qq00,rinv00);
600 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
602 /* LENNARD-JONES DISPERSION/REPULSION */
604 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
605 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
607 fscal = _mm_add_pd(felec,fvdw);
609 /* Update vectorial force */
610 fix0 = _mm_macc_pd(dx00,fscal,fix0);
611 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
612 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
614 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
615 _mm_mul_pd(dx00,fscal),
616 _mm_mul_pd(dy00,fscal),
617 _mm_mul_pd(dz00,fscal));
619 /* Inner loop uses 67 flops */
626 j_coord_offsetA = DIM*jnrA;
628 /* load j atom coordinates */
629 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
632 /* Calculate displacement vector */
633 dx00 = _mm_sub_pd(ix0,jx0);
634 dy00 = _mm_sub_pd(iy0,jy0);
635 dz00 = _mm_sub_pd(iz0,jz0);
637 /* Calculate squared distance and things based on it */
638 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
640 rinv00 = gmx_mm_invsqrt_pd(rsq00);
642 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
644 /* Load parameters for j particles */
645 jq0 = _mm_load_sd(charge+jnrA+0);
646 isaj0 = _mm_load_sd(invsqrta+jnrA+0);
647 vdwjidx0A = 2*vdwtype[jnrA+0];
649 /**************************
650 * CALCULATE INTERACTIONS *
651 **************************/
653 r00 = _mm_mul_pd(rsq00,rinv00);
655 /* Compute parameters for interactions between i and j atoms */
656 qq00 = _mm_mul_pd(iq0,jq0);
657 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
659 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
660 isaprod = _mm_mul_pd(isai0,isaj0);
661 gbqqfactor = _mm_xor_pd(signbit,_mm_mul_pd(qq00,_mm_mul_pd(isaprod,gbinvepsdiff)));
662 gbscale = _mm_mul_pd(isaprod,gbtabscale);
664 /* Calculate generalized born table index - this is a separate table from the normal one,
665 * but we use the same procedure by multiplying r with scale and truncating to integer.
667 rt = _mm_mul_pd(r00,gbscale);
668 gbitab = _mm_cvttpd_epi32(rt);
670 gbeps = _mm_frcz_pd(rt);
672 gbeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
674 gbitab = _mm_slli_epi32(gbitab,2);
676 Y = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) );
677 F = _mm_setzero_pd();
678 GMX_MM_TRANSPOSE2_PD(Y,F);
679 G = _mm_load_pd( gbtab + _mm_extract_epi32(gbitab,0) +2);
680 H = _mm_setzero_pd();
681 GMX_MM_TRANSPOSE2_PD(G,H);
682 Fp = _mm_macc_pd(gbeps,_mm_macc_pd(gbeps,H,G),F);
683 VV = _mm_macc_pd(gbeps,Fp,Y);
684 vgb = _mm_mul_pd(gbqqfactor,VV);
686 twogbeps = _mm_add_pd(gbeps,gbeps);
687 FF = _mm_macc_pd(_mm_macc_pd(twogbeps,H,G),gbeps,Fp);
688 fgb = _mm_mul_pd(gbqqfactor,_mm_mul_pd(FF,gbscale));
689 dvdatmp = _mm_mul_pd(minushalf,_mm_macc_pd(fgb,r00,vgb));
690 dvdasum = _mm_add_pd(dvdasum,dvdatmp);
691 gmx_mm_increment_1real_pd(dvda+jnrA,_mm_mul_pd(dvdatmp,_mm_mul_pd(isaj0,isaj0)));
692 velec = _mm_mul_pd(qq00,rinv00);
693 felec = _mm_mul_pd(_mm_msub_pd(velec,rinv00,fgb),rinv00);
695 /* LENNARD-JONES DISPERSION/REPULSION */
697 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
698 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
700 fscal = _mm_add_pd(felec,fvdw);
702 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
704 /* Update vectorial force */
705 fix0 = _mm_macc_pd(dx00,fscal,fix0);
706 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
707 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
709 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
710 _mm_mul_pd(dx00,fscal),
711 _mm_mul_pd(dy00,fscal),
712 _mm_mul_pd(dz00,fscal));
714 /* Inner loop uses 67 flops */
717 /* End of innermost loop */
719 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
720 f+i_coord_offset,fshift+i_shift_offset);
722 dvdasum = _mm_mul_pd(dvdasum, _mm_mul_pd(isai0,isai0));
723 gmx_mm_update_1pot_pd(dvdasum,dvda+inr);
725 /* Increment number of inner iterations */
726 inneriter += j_index_end - j_index_start;
728 /* Outer loop uses 7 flops */
731 /* Increment number of outer iterations */
734 /* Update outer/inner flops */
736 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*67);