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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.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_ElecCSTab_VdwCSTab_GeomP1P1_VF_avx_128_fma_double
54 * Electrostatics interaction: CubicSplineTable
55 * VdW interaction: CubicSplineTable
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCSTab_VdwCSTab_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;
90 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
93 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
94 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
96 __m128i ifour = _mm_set1_epi32(4);
97 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
99 __m128d dummy_mask,cutoff_mask;
100 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
101 __m128d one = _mm_set1_pd(1.0);
102 __m128d two = _mm_set1_pd(2.0);
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
114 facel = _mm_set1_pd(fr->epsfac);
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 vftab = kernel_data->table_elec_vdw->data;
121 vftabscale = _mm_set1_pd(kernel_data->table_elec_vdw->scale);
123 /* Avoid stupid compiler warnings */
131 /* Start outer loop over neighborlists */
132 for(iidx=0; iidx<nri; iidx++)
134 /* Load shift vector for this list */
135 i_shift_offset = DIM*shiftidx[iidx];
137 /* Load limits for loop over neighbors */
138 j_index_start = jindex[iidx];
139 j_index_end = jindex[iidx+1];
141 /* Get outer coordinate index */
143 i_coord_offset = DIM*inr;
145 /* Load i particle coords and add shift vector */
146 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
148 fix0 = _mm_setzero_pd();
149 fiy0 = _mm_setzero_pd();
150 fiz0 = _mm_setzero_pd();
152 /* Load parameters for i particles */
153 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
154 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
156 /* Reset potential sums */
157 velecsum = _mm_setzero_pd();
158 vvdwsum = _mm_setzero_pd();
160 /* Start inner kernel loop */
161 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
164 /* Get j neighbor index, and coordinate index */
167 j_coord_offsetA = DIM*jnrA;
168 j_coord_offsetB = DIM*jnrB;
170 /* load j atom coordinates */
171 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
174 /* Calculate displacement vector */
175 dx00 = _mm_sub_pd(ix0,jx0);
176 dy00 = _mm_sub_pd(iy0,jy0);
177 dz00 = _mm_sub_pd(iz0,jz0);
179 /* Calculate squared distance and things based on it */
180 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
182 rinv00 = gmx_mm_invsqrt_pd(rsq00);
184 /* Load parameters for j particles */
185 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
186 vdwjidx0A = 2*vdwtype[jnrA+0];
187 vdwjidx0B = 2*vdwtype[jnrB+0];
189 /**************************
190 * CALCULATE INTERACTIONS *
191 **************************/
193 r00 = _mm_mul_pd(rsq00,rinv00);
195 /* Compute parameters for interactions between i and j atoms */
196 qq00 = _mm_mul_pd(iq0,jq0);
197 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
198 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
200 /* Calculate table index by multiplying r with table scale and truncate to integer */
201 rt = _mm_mul_pd(r00,vftabscale);
202 vfitab = _mm_cvttpd_epi32(rt);
204 vfeps = _mm_frcz_pd(rt);
206 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
208 twovfeps = _mm_add_pd(vfeps,vfeps);
209 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
211 /* CUBIC SPLINE TABLE ELECTROSTATICS */
212 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
213 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
214 GMX_MM_TRANSPOSE2_PD(Y,F);
215 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
216 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
217 GMX_MM_TRANSPOSE2_PD(G,H);
218 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
219 VV = _mm_macc_pd(vfeps,Fp,Y);
220 velec = _mm_mul_pd(qq00,VV);
221 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
222 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
224 /* CUBIC SPLINE TABLE DISPERSION */
225 vfitab = _mm_add_epi32(vfitab,ifour);
226 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
227 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
228 GMX_MM_TRANSPOSE2_PD(Y,F);
229 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
230 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
231 GMX_MM_TRANSPOSE2_PD(G,H);
232 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
233 VV = _mm_macc_pd(vfeps,Fp,Y);
234 vvdw6 = _mm_mul_pd(c6_00,VV);
235 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
236 fvdw6 = _mm_mul_pd(c6_00,FF);
238 /* CUBIC SPLINE TABLE REPULSION */
239 vfitab = _mm_add_epi32(vfitab,ifour);
240 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
241 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
242 GMX_MM_TRANSPOSE2_PD(Y,F);
243 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
244 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
245 GMX_MM_TRANSPOSE2_PD(G,H);
246 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
247 VV = _mm_macc_pd(vfeps,Fp,Y);
248 vvdw12 = _mm_mul_pd(c12_00,VV);
249 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
250 fvdw12 = _mm_mul_pd(c12_00,FF);
251 vvdw = _mm_add_pd(vvdw12,vvdw6);
252 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
254 /* Update potential sum for this i atom from the interaction with this j atom. */
255 velecsum = _mm_add_pd(velecsum,velec);
256 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
258 fscal = _mm_add_pd(felec,fvdw);
260 /* Update vectorial force */
261 fix0 = _mm_macc_pd(dx00,fscal,fix0);
262 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
263 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
265 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
266 _mm_mul_pd(dx00,fscal),
267 _mm_mul_pd(dy00,fscal),
268 _mm_mul_pd(dz00,fscal));
270 /* Inner loop uses 76 flops */
277 j_coord_offsetA = DIM*jnrA;
279 /* load j atom coordinates */
280 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
283 /* Calculate displacement vector */
284 dx00 = _mm_sub_pd(ix0,jx0);
285 dy00 = _mm_sub_pd(iy0,jy0);
286 dz00 = _mm_sub_pd(iz0,jz0);
288 /* Calculate squared distance and things based on it */
289 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
291 rinv00 = gmx_mm_invsqrt_pd(rsq00);
293 /* Load parameters for j particles */
294 jq0 = _mm_load_sd(charge+jnrA+0);
295 vdwjidx0A = 2*vdwtype[jnrA+0];
297 /**************************
298 * CALCULATE INTERACTIONS *
299 **************************/
301 r00 = _mm_mul_pd(rsq00,rinv00);
303 /* Compute parameters for interactions between i and j atoms */
304 qq00 = _mm_mul_pd(iq0,jq0);
305 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
307 /* Calculate table index by multiplying r with table scale and truncate to integer */
308 rt = _mm_mul_pd(r00,vftabscale);
309 vfitab = _mm_cvttpd_epi32(rt);
311 vfeps = _mm_frcz_pd(rt);
313 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
315 twovfeps = _mm_add_pd(vfeps,vfeps);
316 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
318 /* CUBIC SPLINE TABLE ELECTROSTATICS */
319 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
320 F = _mm_setzero_pd();
321 GMX_MM_TRANSPOSE2_PD(Y,F);
322 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
323 H = _mm_setzero_pd();
324 GMX_MM_TRANSPOSE2_PD(G,H);
325 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
326 VV = _mm_macc_pd(vfeps,Fp,Y);
327 velec = _mm_mul_pd(qq00,VV);
328 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
329 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
331 /* CUBIC SPLINE TABLE DISPERSION */
332 vfitab = _mm_add_epi32(vfitab,ifour);
333 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
334 F = _mm_setzero_pd();
335 GMX_MM_TRANSPOSE2_PD(Y,F);
336 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
337 H = _mm_setzero_pd();
338 GMX_MM_TRANSPOSE2_PD(G,H);
339 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
340 VV = _mm_macc_pd(vfeps,Fp,Y);
341 vvdw6 = _mm_mul_pd(c6_00,VV);
342 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
343 fvdw6 = _mm_mul_pd(c6_00,FF);
345 /* CUBIC SPLINE TABLE REPULSION */
346 vfitab = _mm_add_epi32(vfitab,ifour);
347 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
348 F = _mm_setzero_pd();
349 GMX_MM_TRANSPOSE2_PD(Y,F);
350 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
351 H = _mm_setzero_pd();
352 GMX_MM_TRANSPOSE2_PD(G,H);
353 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
354 VV = _mm_macc_pd(vfeps,Fp,Y);
355 vvdw12 = _mm_mul_pd(c12_00,VV);
356 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
357 fvdw12 = _mm_mul_pd(c12_00,FF);
358 vvdw = _mm_add_pd(vvdw12,vvdw6);
359 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
361 /* Update potential sum for this i atom from the interaction with this j atom. */
362 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
363 velecsum = _mm_add_pd(velecsum,velec);
364 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
365 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
367 fscal = _mm_add_pd(felec,fvdw);
369 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
371 /* Update vectorial force */
372 fix0 = _mm_macc_pd(dx00,fscal,fix0);
373 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
374 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
376 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
377 _mm_mul_pd(dx00,fscal),
378 _mm_mul_pd(dy00,fscal),
379 _mm_mul_pd(dz00,fscal));
381 /* Inner loop uses 76 flops */
384 /* End of innermost loop */
386 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
387 f+i_coord_offset,fshift+i_shift_offset);
390 /* Update potential energies */
391 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
392 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
394 /* Increment number of inner iterations */
395 inneriter += j_index_end - j_index_start;
397 /* Outer loop uses 9 flops */
400 /* Increment number of outer iterations */
403 /* Update outer/inner flops */
405 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*76);
408 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_avx_128_fma_double
409 * Electrostatics interaction: CubicSplineTable
410 * VdW interaction: CubicSplineTable
411 * Geometry: Particle-Particle
412 * Calculate force/pot: Force
415 nb_kernel_ElecCSTab_VdwCSTab_GeomP1P1_F_avx_128_fma_double
416 (t_nblist * gmx_restrict nlist,
417 rvec * gmx_restrict xx,
418 rvec * gmx_restrict ff,
419 t_forcerec * gmx_restrict fr,
420 t_mdatoms * gmx_restrict mdatoms,
421 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
422 t_nrnb * gmx_restrict nrnb)
424 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
425 * just 0 for non-waters.
426 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
427 * jnr indices corresponding to data put in the four positions in the SIMD register.
429 int i_shift_offset,i_coord_offset,outeriter,inneriter;
430 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
432 int j_coord_offsetA,j_coord_offsetB;
433 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
435 real *shiftvec,*fshift,*x,*f;
436 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
438 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
439 int vdwjidx0A,vdwjidx0B;
440 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
441 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
442 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
445 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
448 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
449 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
451 __m128i ifour = _mm_set1_epi32(4);
452 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
454 __m128d dummy_mask,cutoff_mask;
455 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
456 __m128d one = _mm_set1_pd(1.0);
457 __m128d two = _mm_set1_pd(2.0);
463 jindex = nlist->jindex;
465 shiftidx = nlist->shift;
467 shiftvec = fr->shift_vec[0];
468 fshift = fr->fshift[0];
469 facel = _mm_set1_pd(fr->epsfac);
470 charge = mdatoms->chargeA;
471 nvdwtype = fr->ntype;
473 vdwtype = mdatoms->typeA;
475 vftab = kernel_data->table_elec_vdw->data;
476 vftabscale = _mm_set1_pd(kernel_data->table_elec_vdw->scale);
478 /* Avoid stupid compiler warnings */
486 /* Start outer loop over neighborlists */
487 for(iidx=0; iidx<nri; iidx++)
489 /* Load shift vector for this list */
490 i_shift_offset = DIM*shiftidx[iidx];
492 /* Load limits for loop over neighbors */
493 j_index_start = jindex[iidx];
494 j_index_end = jindex[iidx+1];
496 /* Get outer coordinate index */
498 i_coord_offset = DIM*inr;
500 /* Load i particle coords and add shift vector */
501 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
503 fix0 = _mm_setzero_pd();
504 fiy0 = _mm_setzero_pd();
505 fiz0 = _mm_setzero_pd();
507 /* Load parameters for i particles */
508 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
509 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
511 /* Start inner kernel loop */
512 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
515 /* Get j neighbor index, and coordinate index */
518 j_coord_offsetA = DIM*jnrA;
519 j_coord_offsetB = DIM*jnrB;
521 /* load j atom coordinates */
522 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
525 /* Calculate displacement vector */
526 dx00 = _mm_sub_pd(ix0,jx0);
527 dy00 = _mm_sub_pd(iy0,jy0);
528 dz00 = _mm_sub_pd(iz0,jz0);
530 /* Calculate squared distance and things based on it */
531 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
533 rinv00 = gmx_mm_invsqrt_pd(rsq00);
535 /* Load parameters for j particles */
536 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
537 vdwjidx0A = 2*vdwtype[jnrA+0];
538 vdwjidx0B = 2*vdwtype[jnrB+0];
540 /**************************
541 * CALCULATE INTERACTIONS *
542 **************************/
544 r00 = _mm_mul_pd(rsq00,rinv00);
546 /* Compute parameters for interactions between i and j atoms */
547 qq00 = _mm_mul_pd(iq0,jq0);
548 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
549 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
551 /* Calculate table index by multiplying r with table scale and truncate to integer */
552 rt = _mm_mul_pd(r00,vftabscale);
553 vfitab = _mm_cvttpd_epi32(rt);
555 vfeps = _mm_frcz_pd(rt);
557 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
559 twovfeps = _mm_add_pd(vfeps,vfeps);
560 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
562 /* CUBIC SPLINE TABLE ELECTROSTATICS */
563 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
564 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
565 GMX_MM_TRANSPOSE2_PD(Y,F);
566 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
567 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
568 GMX_MM_TRANSPOSE2_PD(G,H);
569 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
570 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
571 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
573 /* CUBIC SPLINE TABLE DISPERSION */
574 vfitab = _mm_add_epi32(vfitab,ifour);
575 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
576 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
577 GMX_MM_TRANSPOSE2_PD(Y,F);
578 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
579 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
580 GMX_MM_TRANSPOSE2_PD(G,H);
581 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
582 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
583 fvdw6 = _mm_mul_pd(c6_00,FF);
585 /* CUBIC SPLINE TABLE REPULSION */
586 vfitab = _mm_add_epi32(vfitab,ifour);
587 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
588 F = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) );
589 GMX_MM_TRANSPOSE2_PD(Y,F);
590 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
591 H = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,1) +2);
592 GMX_MM_TRANSPOSE2_PD(G,H);
593 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
594 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
595 fvdw12 = _mm_mul_pd(c12_00,FF);
596 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
598 fscal = _mm_add_pd(felec,fvdw);
600 /* Update vectorial force */
601 fix0 = _mm_macc_pd(dx00,fscal,fix0);
602 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
603 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
605 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,
606 _mm_mul_pd(dx00,fscal),
607 _mm_mul_pd(dy00,fscal),
608 _mm_mul_pd(dz00,fscal));
610 /* Inner loop uses 64 flops */
617 j_coord_offsetA = DIM*jnrA;
619 /* load j atom coordinates */
620 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
623 /* Calculate displacement vector */
624 dx00 = _mm_sub_pd(ix0,jx0);
625 dy00 = _mm_sub_pd(iy0,jy0);
626 dz00 = _mm_sub_pd(iz0,jz0);
628 /* Calculate squared distance and things based on it */
629 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
631 rinv00 = gmx_mm_invsqrt_pd(rsq00);
633 /* Load parameters for j particles */
634 jq0 = _mm_load_sd(charge+jnrA+0);
635 vdwjidx0A = 2*vdwtype[jnrA+0];
637 /**************************
638 * CALCULATE INTERACTIONS *
639 **************************/
641 r00 = _mm_mul_pd(rsq00,rinv00);
643 /* Compute parameters for interactions between i and j atoms */
644 qq00 = _mm_mul_pd(iq0,jq0);
645 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
647 /* Calculate table index by multiplying r with table scale and truncate to integer */
648 rt = _mm_mul_pd(r00,vftabscale);
649 vfitab = _mm_cvttpd_epi32(rt);
651 vfeps = _mm_frcz_pd(rt);
653 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
655 twovfeps = _mm_add_pd(vfeps,vfeps);
656 vfitab = _mm_slli_epi32(_mm_add_epi32(vfitab,_mm_slli_epi32(vfitab,1)),2);
658 /* CUBIC SPLINE TABLE ELECTROSTATICS */
659 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
660 F = _mm_setzero_pd();
661 GMX_MM_TRANSPOSE2_PD(Y,F);
662 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
663 H = _mm_setzero_pd();
664 GMX_MM_TRANSPOSE2_PD(G,H);
665 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(vfeps,H,G),F);
666 FF = _mm_macc_pd(_mm_macc_pd(twovfeps,H,G),vfeps,Fp);
667 felec = _mm_xor_pd(signbit,_mm_mul_pd(_mm_mul_pd(qq00,FF),_mm_mul_pd(vftabscale,rinv00)));
669 /* CUBIC SPLINE TABLE DISPERSION */
670 vfitab = _mm_add_epi32(vfitab,ifour);
671 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
672 F = _mm_setzero_pd();
673 GMX_MM_TRANSPOSE2_PD(Y,F);
674 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
675 H = _mm_setzero_pd();
676 GMX_MM_TRANSPOSE2_PD(G,H);
677 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
678 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
679 fvdw6 = _mm_mul_pd(c6_00,FF);
681 /* CUBIC SPLINE TABLE REPULSION */
682 vfitab = _mm_add_epi32(vfitab,ifour);
683 Y = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) );
684 F = _mm_setzero_pd();
685 GMX_MM_TRANSPOSE2_PD(Y,F);
686 G = _mm_load_pd( vftab + _mm_extract_epi32(vfitab,0) +2);
687 H = _mm_setzero_pd();
688 GMX_MM_TRANSPOSE2_PD(G,H);
689 Fp = _mm_macc_pd(vfeps,_mm_macc_pd(H,vfeps,G),F);
690 FF = _mm_macc_pd(vfeps,_mm_macc_pd(twovfeps,H,G),Fp);
691 fvdw12 = _mm_mul_pd(c12_00,FF);
692 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
694 fscal = _mm_add_pd(felec,fvdw);
696 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
698 /* Update vectorial force */
699 fix0 = _mm_macc_pd(dx00,fscal,fix0);
700 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
701 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
703 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,
704 _mm_mul_pd(dx00,fscal),
705 _mm_mul_pd(dy00,fscal),
706 _mm_mul_pd(dz00,fscal));
708 /* Inner loop uses 64 flops */
711 /* End of innermost loop */
713 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
714 f+i_coord_offset,fshift+i_shift_offset);
716 /* Increment number of inner iterations */
717 inneriter += j_index_end - j_index_start;
719 /* Outer loop uses 7 flops */
722 /* Increment number of outer iterations */
725 /* Update outer/inner flops */
727 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*64);