2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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.
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_VF_avx_128_fma_double
52 * Electrostatics interaction: CubicSplineTable
53 * VdW interaction: CubicSplineTable
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_VF_avx_128_fma_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 int vdwjidx0A,vdwjidx0B;
83 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
84 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
85 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
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);
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;
114 nvdwtype = fr->ntype;
116 vdwtype = mdatoms->typeA;
118 vftab = kernel_data->table_elec_vdw->data;
119 vftabscale = _mm_set1_pd(kernel_data->table_elec_vdw->scale);
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 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
154 /* Reset potential sums */
155 velecsum = _mm_setzero_pd();
156 vvdwsum = _mm_setzero_pd();
158 /* Start inner kernel loop */
159 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
162 /* Get j neighbor index, and coordinate index */
165 j_coord_offsetA = DIM*jnrA;
166 j_coord_offsetB = DIM*jnrB;
168 /* load j atom coordinates */
169 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
172 /* Calculate displacement vector */
173 dx00 = _mm_sub_pd(ix0,jx0);
174 dy00 = _mm_sub_pd(iy0,jy0);
175 dz00 = _mm_sub_pd(iz0,jz0);
177 /* Calculate squared distance and things based on it */
178 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
180 rinv00 = gmx_mm_invsqrt_pd(rsq00);
182 /* Load parameters for j particles */
183 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
184 vdwjidx0A = 2*vdwtype[jnrA+0];
185 vdwjidx0B = 2*vdwtype[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);
195 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
196 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
198 /* Calculate table index by multiplying r with table scale and truncate to integer */
199 rt = _mm_mul_pd(r00,vftabscale);
200 vfitab = _mm_cvttpd_epi32(rt);
202 vfeps = _mm_frcz_pd(rt);
204 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
206 twovfeps = _mm_add_pd(vfeps,vfeps);
207 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
209 /* CUBIC SPLINE TABLE ELECTROSTATICS */
210 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
211 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
212 GMX_MM_TRANSPOSE2_PD(Y,F);
213 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
214 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
215 GMX_MM_TRANSPOSE2_PD(G,H);
216 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
217 VV = _mm_macc_pd(vfeps,Fp,Y);
218 velec = _mm_mul_pd(qq00,VV);
219 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
220 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
222 /* CUBIC SPLINE TABLE DISPERSION */
223 vfitab = _mm_add_epi32(vfitab,ifour);
224 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
225 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
226 GMX_MM_TRANSPOSE2_PD(Y,F);
227 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
228 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
229 GMX_MM_TRANSPOSE2_PD(G,H);
230 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
231 VV = _mm_macc_pd(vfeps,Fp,Y);
232 vvdw6 = _mm_mul_pd(c6_00,VV);
233 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
234 fvdw6 = _mm_mul_pd(c6_00,FF);
236 /* CUBIC SPLINE TABLE REPULSION */
237 vfitab = _mm_add_epi32(vfitab,ifour);
238 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
239 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
240 GMX_MM_TRANSPOSE2_PD(Y,F);
241 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
242 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
243 GMX_MM_TRANSPOSE2_PD(G,H);
244 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
245 VV = _mm_macc_pd(vfeps,Fp,Y);
246 vvdw12 = _mm_mul_pd(c12_00,VV);
247 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
248 fvdw12 = _mm_mul_pd(c12_00,FF);
249 vvdw = _mm_add_pd(vvdw12,vvdw6);
250 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
252 /* Update potential sum for this i atom from the interaction with this j atom. */
253 velecsum = _mm_add_pd(velecsum,velec);
254 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
256 fscal = _mm_add_pd(felec,fvdw);
258 /* Update vectorial force */
259 fix0 = _mm_macc_pd(dx00,fscal,fix0);
260 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
261 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
263 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
264 _mm_mul_pd(dx00,fscal),
265 _mm_mul_pd(dy00,fscal),
266 _mm_mul_pd(dz00,fscal));
268 /* Inner loop uses 76 flops */
275 j_coord_offsetA = DIM*jnrA;
277 /* load j atom coordinates */
278 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
281 /* Calculate displacement vector */
282 dx00 = _mm_sub_pd(ix0,jx0);
283 dy00 = _mm_sub_pd(iy0,jy0);
284 dz00 = _mm_sub_pd(iz0,jz0);
286 /* Calculate squared distance and things based on it */
287 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
289 rinv00 = gmx_mm_invsqrt_pd(rsq00);
291 /* Load parameters for j particles */
292 jq0 = _mm_load_sd(charge+jnrA+0);
293 vdwjidx0A = 2*vdwtype[jnrA+0];
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
299 r00 = _mm_mul_pd(rsq00,rinv00);
301 /* Compute parameters for interactions between i and j atoms */
302 qq00 = _mm_mul_pd(iq0,jq0);
303 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
305 /* Calculate table index by multiplying r with table scale and truncate to integer */
306 rt = _mm_mul_pd(r00,vftabscale);
307 vfitab = _mm_cvttpd_epi32(rt);
309 vfeps = _mm_frcz_pd(rt);
311 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
313 twovfeps = _mm_add_pd(vfeps,vfeps);
314 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
316 /* CUBIC SPLINE TABLE ELECTROSTATICS */
317 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
318 F = _mm_setzero_pd();
319 GMX_MM_TRANSPOSE2_PD(Y,F);
320 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
321 H = _mm_setzero_pd();
322 GMX_MM_TRANSPOSE2_PD(G,H);
323 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
324 VV = _mm_macc_pd(vfeps,Fp,Y);
325 velec = _mm_mul_pd(qq00,VV);
326 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
327 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
329 /* CUBIC SPLINE TABLE DISPERSION */
330 vfitab = _mm_add_epi32(vfitab,ifour);
331 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
332 F = _mm_setzero_pd();
333 GMX_MM_TRANSPOSE2_PD(Y,F);
334 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
335 H = _mm_setzero_pd();
336 GMX_MM_TRANSPOSE2_PD(G,H);
337 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
338 VV = _mm_macc_pd(vfeps,Fp,Y);
339 vvdw6 = _mm_mul_pd(c6_00,VV);
340 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
341 fvdw6 = _mm_mul_pd(c6_00,FF);
343 /* CUBIC SPLINE TABLE REPULSION */
344 vfitab = _mm_add_epi32(vfitab,ifour);
345 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
346 F = _mm_setzero_pd();
347 GMX_MM_TRANSPOSE2_PD(Y,F);
348 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
349 H = _mm_setzero_pd();
350 GMX_MM_TRANSPOSE2_PD(G,H);
351 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
352 VV = _mm_macc_pd(vfeps,Fp,Y);
353 vvdw12 = _mm_mul_pd(c12_00,VV);
354 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
355 fvdw12 = _mm_mul_pd(c12_00,FF);
356 vvdw = _mm_add_pd(vvdw12,vvdw6);
357 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
359 /* Update potential sum for this i atom from the interaction with this j atom. */
360 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
361 velecsum = _mm_add_pd(velecsum,velec);
362 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
363 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
365 fscal = _mm_add_pd(felec,fvdw);
367 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
369 /* Update vectorial force */
370 fix0 = _mm_macc_pd(dx00,fscal,fix0);
371 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
372 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
374 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
375 _mm_mul_pd(dx00,fscal),
376 _mm_mul_pd(dy00,fscal),
377 _mm_mul_pd(dz00,fscal));
379 /* Inner loop uses 76 flops */
382 /* End of innermost loop */
384 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
385 f+i_coord_offset,fshift+i_shift_offset);
388 /* Update potential energies */
389 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
390 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
392 /* Increment number of inner iterations */
393 inneriter += j_index_end - j_index_start;
395 /* Outer loop uses 9 flops */
398 /* Increment number of outer iterations */
401 /* Update outer/inner flops */
403 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*76);
406 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_avx_128_fma_double
407 * Electrostatics interaction: CubicSplineTable
408 * VdW interaction: CubicSplineTable
409 * Geometry: Particle-Particle
410 * Calculate force/pot: Force
413 nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_avx_128_fma_double
414 (t_nblist * gmx_restrict nlist,
415 rvec * gmx_restrict xx,
416 rvec * gmx_restrict ff,
417 t_forcerec * gmx_restrict fr,
418 t_mdatoms * gmx_restrict mdatoms,
419 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
420 t_nrnb * gmx_restrict nrnb)
422 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
423 * just 0 for non-waters.
424 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
425 * jnr indices corresponding to data put in the four positions in the SIMD register.
427 int i_shift_offset,i_coord_offset,outeriter,inneriter;
428 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
430 int j_coord_offsetA,j_coord_offsetB;
431 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
433 real *shiftvec,*fshift,*x,*f;
434 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
436 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
437 int vdwjidx0A,vdwjidx0B;
438 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
439 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
440 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
443 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
446 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
447 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
449 __m128i ifour = _mm_set1_epi32(4);
450 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
452 __m128d dummy_mask,cutoff_mask;
453 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
454 __m128d one = _mm_set1_pd(1.0);
455 __m128d two = _mm_set1_pd(2.0);
461 jindex = nlist->jindex;
463 shiftidx = nlist->shift;
465 shiftvec = fr->shift_vec[0];
466 fshift = fr->fshift[0];
467 facel = _mm_set1_pd(fr->epsfac);
468 charge = mdatoms->chargeA;
469 nvdwtype = fr->ntype;
471 vdwtype = mdatoms->typeA;
473 vftab = kernel_data->table_elec_vdw->data;
474 vftabscale = _mm_set1_pd(kernel_data->table_elec_vdw->scale);
476 /* Avoid stupid compiler warnings */
484 /* Start outer loop over neighborlists */
485 for(iidx=0; iidx<nri; iidx++)
487 /* Load shift vector for this list */
488 i_shift_offset = DIM*shiftidx[iidx];
490 /* Load limits for loop over neighbors */
491 j_index_start = jindex[iidx];
492 j_index_end = jindex[iidx+1];
494 /* Get outer coordinate index */
496 i_coord_offset = DIM*inr;
498 /* Load i particle coords and add shift vector */
499 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
501 fix0 = _mm_setzero_pd();
502 fiy0 = _mm_setzero_pd();
503 fiz0 = _mm_setzero_pd();
505 /* Load parameters for i particles */
506 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
507 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
509 /* Start inner kernel loop */
510 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
513 /* Get j neighbor index, and coordinate index */
516 j_coord_offsetA = DIM*jnrA;
517 j_coord_offsetB = DIM*jnrB;
519 /* load j atom coordinates */
520 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
523 /* Calculate displacement vector */
524 dx00 = _mm_sub_pd(ix0,jx0);
525 dy00 = _mm_sub_pd(iy0,jy0);
526 dz00 = _mm_sub_pd(iz0,jz0);
528 /* Calculate squared distance and things based on it */
529 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
531 rinv00 = gmx_mm_invsqrt_pd(rsq00);
533 /* Load parameters for j particles */
534 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
535 vdwjidx0A = 2*vdwtype[jnrA+0];
536 vdwjidx0B = 2*vdwtype[jnrB+0];
538 /**************************
539 * CALCULATE INTERACTIONS *
540 **************************/
542 r00 = _mm_mul_pd(rsq00,rinv00);
544 /* Compute parameters for interactions between i and j atoms */
545 qq00 = _mm_mul_pd(iq0,jq0);
546 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
547 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
549 /* Calculate table index by multiplying r with table scale and truncate to integer */
550 rt = _mm_mul_pd(r00,vftabscale);
551 vfitab = _mm_cvttpd_epi32(rt);
553 vfeps = _mm_frcz_pd(rt);
555 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
557 twovfeps = _mm_add_pd(vfeps,vfeps);
558 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
560 /* CUBIC SPLINE TABLE ELECTROSTATICS */
561 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
562 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
563 GMX_MM_TRANSPOSE2_PD(Y,F);
564 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
565 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
566 GMX_MM_TRANSPOSE2_PD(G,H);
567 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
568 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
569 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
571 /* CUBIC SPLINE TABLE DISPERSION */
572 vfitab = _mm_add_epi32(vfitab,ifour);
573 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
574 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
575 GMX_MM_TRANSPOSE2_PD(Y,F);
576 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
577 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
578 GMX_MM_TRANSPOSE2_PD(G,H);
579 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
580 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
581 fvdw6 = _mm_mul_pd(c6_00,FF);
583 /* CUBIC SPLINE TABLE REPULSION */
584 vfitab = _mm_add_epi32(vfitab,ifour);
585 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
586 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
587 GMX_MM_TRANSPOSE2_PD(Y,F);
588 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
589 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
590 GMX_MM_TRANSPOSE2_PD(G,H);
591 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
592 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
593 fvdw12 = _mm_mul_pd(c12_00,FF);
594 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
596 fscal = _mm_add_pd(felec,fvdw);
598 /* Update vectorial force */
599 fix0 = _mm_macc_pd(dx00,fscal,fix0);
600 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
601 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
603 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
604 _mm_mul_pd(dx00,fscal),
605 _mm_mul_pd(dy00,fscal),
606 _mm_mul_pd(dz00,fscal));
608 /* Inner loop uses 64 flops */
615 j_coord_offsetA = DIM*jnrA;
617 /* load j atom coordinates */
618 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
621 /* Calculate displacement vector */
622 dx00 = _mm_sub_pd(ix0,jx0);
623 dy00 = _mm_sub_pd(iy0,jy0);
624 dz00 = _mm_sub_pd(iz0,jz0);
626 /* Calculate squared distance and things based on it */
627 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
629 rinv00 = gmx_mm_invsqrt_pd(rsq00);
631 /* Load parameters for j particles */
632 jq0 = _mm_load_sd(charge+jnrA+0);
633 vdwjidx0A = 2*vdwtype[jnrA+0];
635 /**************************
636 * CALCULATE INTERACTIONS *
637 **************************/
639 r00 = _mm_mul_pd(rsq00,rinv00);
641 /* Compute parameters for interactions between i and j atoms */
642 qq00 = _mm_mul_pd(iq0,jq0);
643 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
645 /* Calculate table index by multiplying r with table scale and truncate to integer */
646 rt = _mm_mul_pd(r00,vftabscale);
647 vfitab = _mm_cvttpd_epi32(rt);
649 vfeps = _mm_frcz_pd(rt);
651 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
653 twovfeps = _mm_add_pd(vfeps,vfeps);
654 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
656 /* CUBIC SPLINE TABLE ELECTROSTATICS */
657 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
658 F = _mm_setzero_pd();
659 GMX_MM_TRANSPOSE2_PD(Y,F);
660 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
661 H = _mm_setzero_pd();
662 GMX_MM_TRANSPOSE2_PD(G,H);
663 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
664 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
665 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
667 /* CUBIC SPLINE TABLE DISPERSION */
668 vfitab = _mm_add_epi32(vfitab,ifour);
669 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
670 F = _mm_setzero_pd();
671 GMX_MM_TRANSPOSE2_PD(Y,F);
672 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
673 H = _mm_setzero_pd();
674 GMX_MM_TRANSPOSE2_PD(G,H);
675 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
676 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
677 fvdw6 = _mm_mul_pd(c6_00,FF);
679 /* CUBIC SPLINE TABLE REPULSION */
680 vfitab = _mm_add_epi32(vfitab,ifour);
681 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
682 F = _mm_setzero_pd();
683 GMX_MM_TRANSPOSE2_PD(Y,F);
684 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
685 H = _mm_setzero_pd();
686 GMX_MM_TRANSPOSE2_PD(G,H);
687 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
688 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
689 fvdw12 = _mm_mul_pd(c12_00,FF);
690 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
692 fscal = _mm_add_pd(felec,fvdw);
694 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
696 /* Update vectorial force */
697 fix0 = _mm_macc_pd(dx00,fscal,fix0);
698 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
699 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
701 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
702 _mm_mul_pd(dx00,fscal),
703 _mm_mul_pd(dy00,fscal),
704 _mm_mul_pd(dz00,fscal));
706 /* Inner loop uses 64 flops */
709 /* End of innermost loop */
711 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
712 f+i_coord_offset,fshift+i_shift_offset);
714 /* Increment number of inner iterations */
715 inneriter += j_index_end - j_index_start;
717 /* Outer loop uses 7 flops */
720 /* Increment number of outer iterations */
723 /* Update outer/inner flops */
725 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*64);