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 sse4_1_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_sse4_1_double.h"
50 #include "kernelutil_x86_sse4_1_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse4_1_double
54 * Electrostatics interaction: None
55 * VdW interaction: CubicSplineTable
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse4_1_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;
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;
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 nvdwtype = fr->ntype;
114 vdwtype = mdatoms->typeA;
116 vftab = kernel_data->table_vdw->data;
117 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
119 /* Avoid stupid compiler warnings */
127 /* Start outer loop over neighborlists */
128 for(iidx=0; iidx<nri; iidx++)
130 /* Load shift vector for this list */
131 i_shift_offset = DIM*shiftidx[iidx];
133 /* Load limits for loop over neighbors */
134 j_index_start = jindex[iidx];
135 j_index_end = jindex[iidx+1];
137 /* Get outer coordinate index */
139 i_coord_offset = DIM*inr;
141 /* Load i particle coords and add shift vector */
142 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
144 fix0 = _mm_setzero_pd();
145 fiy0 = _mm_setzero_pd();
146 fiz0 = _mm_setzero_pd();
148 /* Load parameters for i particles */
149 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
151 /* Reset potential sums */
152 vvdwsum = _mm_setzero_pd();
154 /* Start inner kernel loop */
155 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
158 /* Get j neighbor index, and coordinate index */
161 j_coord_offsetA = DIM*jnrA;
162 j_coord_offsetB = DIM*jnrB;
164 /* load j atom coordinates */
165 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
168 /* Calculate displacement vector */
169 dx00 = _mm_sub_pd(ix0,jx0);
170 dy00 = _mm_sub_pd(iy0,jy0);
171 dz00 = _mm_sub_pd(iz0,jz0);
173 /* Calculate squared distance and things based on it */
174 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
176 rinv00 = gmx_mm_invsqrt_pd(rsq00);
178 /* Load parameters for j particles */
179 vdwjidx0A = 2*vdwtype[jnrA+0];
180 vdwjidx0B = 2*vdwtype[jnrB+0];
182 /**************************
183 * CALCULATE INTERACTIONS *
184 **************************/
186 r00 = _mm_mul_pd(rsq00,rinv00);
188 /* Compute parameters for interactions between i and j atoms */
189 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
190 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
192 /* Calculate table index by multiplying r with table scale and truncate to integer */
193 rt = _mm_mul_pd(r00,vftabscale);
194 vfitab = _mm_cvttpd_epi32(rt);
195 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
196 vfitab = _mm_slli_epi32(vfitab,3);
198 /* CUBIC SPLINE TABLE DISPERSION */
199 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
200 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
201 GMX_MM_TRANSPOSE2_PD(Y,F);
202 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
203 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
204 GMX_MM_TRANSPOSE2_PD(G,H);
205 Heps = _mm_mul_pd(vfeps,H);
206 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
207 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
208 vvdw6 = _mm_mul_pd(c6_00,VV);
209 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
210 fvdw6 = _mm_mul_pd(c6_00,FF);
212 /* CUBIC SPLINE TABLE REPULSION */
213 vfitab = _mm_add_epi32(vfitab,ifour);
214 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
215 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
216 GMX_MM_TRANSPOSE2_PD(Y,F);
217 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
218 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
219 GMX_MM_TRANSPOSE2_PD(G,H);
220 Heps = _mm_mul_pd(vfeps,H);
221 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
222 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
223 vvdw12 = _mm_mul_pd(c12_00,VV);
224 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
225 fvdw12 = _mm_mul_pd(c12_00,FF);
226 vvdw = _mm_add_pd(vvdw12,vvdw6);
227 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
229 /* Update potential sum for this i atom from the interaction with this j atom. */
230 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
234 /* Calculate temporary vectorial force */
235 tx = _mm_mul_pd(fscal,dx00);
236 ty = _mm_mul_pd(fscal,dy00);
237 tz = _mm_mul_pd(fscal,dz00);
239 /* Update vectorial force */
240 fix0 = _mm_add_pd(fix0,tx);
241 fiy0 = _mm_add_pd(fiy0,ty);
242 fiz0 = _mm_add_pd(fiz0,tz);
244 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
246 /* Inner loop uses 56 flops */
253 j_coord_offsetA = DIM*jnrA;
255 /* load j atom coordinates */
256 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
259 /* Calculate displacement vector */
260 dx00 = _mm_sub_pd(ix0,jx0);
261 dy00 = _mm_sub_pd(iy0,jy0);
262 dz00 = _mm_sub_pd(iz0,jz0);
264 /* Calculate squared distance and things based on it */
265 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
267 rinv00 = gmx_mm_invsqrt_pd(rsq00);
269 /* Load parameters for j particles */
270 vdwjidx0A = 2*vdwtype[jnrA+0];
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
276 r00 = _mm_mul_pd(rsq00,rinv00);
278 /* Compute parameters for interactions between i and j atoms */
279 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
281 /* Calculate table index by multiplying r with table scale and truncate to integer */
282 rt = _mm_mul_pd(r00,vftabscale);
283 vfitab = _mm_cvttpd_epi32(rt);
284 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
285 vfitab = _mm_slli_epi32(vfitab,3);
287 /* CUBIC SPLINE TABLE DISPERSION */
288 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
289 F = _mm_setzero_pd();
290 GMX_MM_TRANSPOSE2_PD(Y,F);
291 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
292 H = _mm_setzero_pd();
293 GMX_MM_TRANSPOSE2_PD(G,H);
294 Heps = _mm_mul_pd(vfeps,H);
295 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
296 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
297 vvdw6 = _mm_mul_pd(c6_00,VV);
298 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
299 fvdw6 = _mm_mul_pd(c6_00,FF);
301 /* CUBIC SPLINE TABLE REPULSION */
302 vfitab = _mm_add_epi32(vfitab,ifour);
303 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
304 F = _mm_setzero_pd();
305 GMX_MM_TRANSPOSE2_PD(Y,F);
306 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
307 H = _mm_setzero_pd();
308 GMX_MM_TRANSPOSE2_PD(G,H);
309 Heps = _mm_mul_pd(vfeps,H);
310 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
311 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
312 vvdw12 = _mm_mul_pd(c12_00,VV);
313 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
314 fvdw12 = _mm_mul_pd(c12_00,FF);
315 vvdw = _mm_add_pd(vvdw12,vvdw6);
316 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
320 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
324 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
326 /* Calculate temporary vectorial force */
327 tx = _mm_mul_pd(fscal,dx00);
328 ty = _mm_mul_pd(fscal,dy00);
329 tz = _mm_mul_pd(fscal,dz00);
331 /* Update vectorial force */
332 fix0 = _mm_add_pd(fix0,tx);
333 fiy0 = _mm_add_pd(fiy0,ty);
334 fiz0 = _mm_add_pd(fiz0,tz);
336 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
338 /* Inner loop uses 56 flops */
341 /* End of innermost loop */
343 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
344 f+i_coord_offset,fshift+i_shift_offset);
347 /* Update potential energies */
348 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
350 /* Increment number of inner iterations */
351 inneriter += j_index_end - j_index_start;
353 /* Outer loop uses 7 flops */
356 /* Increment number of outer iterations */
359 /* Update outer/inner flops */
361 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*56);
364 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse4_1_double
365 * Electrostatics interaction: None
366 * VdW interaction: CubicSplineTable
367 * Geometry: Particle-Particle
368 * Calculate force/pot: Force
371 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse4_1_double
372 (t_nblist * gmx_restrict nlist,
373 rvec * gmx_restrict xx,
374 rvec * gmx_restrict ff,
375 t_forcerec * gmx_restrict fr,
376 t_mdatoms * gmx_restrict mdatoms,
377 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
378 t_nrnb * gmx_restrict nrnb)
380 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
381 * just 0 for non-waters.
382 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
383 * jnr indices corresponding to data put in the four positions in the SIMD register.
385 int i_shift_offset,i_coord_offset,outeriter,inneriter;
386 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
388 int j_coord_offsetA,j_coord_offsetB;
389 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
391 real *shiftvec,*fshift,*x,*f;
392 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
394 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
395 int vdwjidx0A,vdwjidx0B;
396 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
397 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
399 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
402 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
403 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
405 __m128i ifour = _mm_set1_epi32(4);
406 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
408 __m128d dummy_mask,cutoff_mask;
409 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
410 __m128d one = _mm_set1_pd(1.0);
411 __m128d two = _mm_set1_pd(2.0);
417 jindex = nlist->jindex;
419 shiftidx = nlist->shift;
421 shiftvec = fr->shift_vec[0];
422 fshift = fr->fshift[0];
423 nvdwtype = fr->ntype;
425 vdwtype = mdatoms->typeA;
427 vftab = kernel_data->table_vdw->data;
428 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
430 /* Avoid stupid compiler warnings */
438 /* Start outer loop over neighborlists */
439 for(iidx=0; iidx<nri; iidx++)
441 /* Load shift vector for this list */
442 i_shift_offset = DIM*shiftidx[iidx];
444 /* Load limits for loop over neighbors */
445 j_index_start = jindex[iidx];
446 j_index_end = jindex[iidx+1];
448 /* Get outer coordinate index */
450 i_coord_offset = DIM*inr;
452 /* Load i particle coords and add shift vector */
453 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
455 fix0 = _mm_setzero_pd();
456 fiy0 = _mm_setzero_pd();
457 fiz0 = _mm_setzero_pd();
459 /* Load parameters for i particles */
460 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
462 /* Start inner kernel loop */
463 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
466 /* Get j neighbor index, and coordinate index */
469 j_coord_offsetA = DIM*jnrA;
470 j_coord_offsetB = DIM*jnrB;
472 /* load j atom coordinates */
473 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
476 /* Calculate displacement vector */
477 dx00 = _mm_sub_pd(ix0,jx0);
478 dy00 = _mm_sub_pd(iy0,jy0);
479 dz00 = _mm_sub_pd(iz0,jz0);
481 /* Calculate squared distance and things based on it */
482 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
484 rinv00 = gmx_mm_invsqrt_pd(rsq00);
486 /* Load parameters for j particles */
487 vdwjidx0A = 2*vdwtype[jnrA+0];
488 vdwjidx0B = 2*vdwtype[jnrB+0];
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
494 r00 = _mm_mul_pd(rsq00,rinv00);
496 /* Compute parameters for interactions between i and j atoms */
497 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
498 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
500 /* Calculate table index by multiplying r with table scale and truncate to integer */
501 rt = _mm_mul_pd(r00,vftabscale);
502 vfitab = _mm_cvttpd_epi32(rt);
503 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
504 vfitab = _mm_slli_epi32(vfitab,3);
506 /* CUBIC SPLINE TABLE DISPERSION */
507 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
508 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
509 GMX_MM_TRANSPOSE2_PD(Y,F);
510 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
511 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
512 GMX_MM_TRANSPOSE2_PD(G,H);
513 Heps = _mm_mul_pd(vfeps,H);
514 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
515 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
516 fvdw6 = _mm_mul_pd(c6_00,FF);
518 /* CUBIC SPLINE TABLE REPULSION */
519 vfitab = _mm_add_epi32(vfitab,ifour);
520 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
521 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
522 GMX_MM_TRANSPOSE2_PD(Y,F);
523 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
524 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
525 GMX_MM_TRANSPOSE2_PD(G,H);
526 Heps = _mm_mul_pd(vfeps,H);
527 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
528 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
529 fvdw12 = _mm_mul_pd(c12_00,FF);
530 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
534 /* Calculate temporary vectorial force */
535 tx = _mm_mul_pd(fscal,dx00);
536 ty = _mm_mul_pd(fscal,dy00);
537 tz = _mm_mul_pd(fscal,dz00);
539 /* Update vectorial force */
540 fix0 = _mm_add_pd(fix0,tx);
541 fiy0 = _mm_add_pd(fiy0,ty);
542 fiz0 = _mm_add_pd(fiz0,tz);
544 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
546 /* Inner loop uses 48 flops */
553 j_coord_offsetA = DIM*jnrA;
555 /* load j atom coordinates */
556 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
559 /* Calculate displacement vector */
560 dx00 = _mm_sub_pd(ix0,jx0);
561 dy00 = _mm_sub_pd(iy0,jy0);
562 dz00 = _mm_sub_pd(iz0,jz0);
564 /* Calculate squared distance and things based on it */
565 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
567 rinv00 = gmx_mm_invsqrt_pd(rsq00);
569 /* Load parameters for j particles */
570 vdwjidx0A = 2*vdwtype[jnrA+0];
572 /**************************
573 * CALCULATE INTERACTIONS *
574 **************************/
576 r00 = _mm_mul_pd(rsq00,rinv00);
578 /* Compute parameters for interactions between i and j atoms */
579 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
581 /* Calculate table index by multiplying r with table scale and truncate to integer */
582 rt = _mm_mul_pd(r00,vftabscale);
583 vfitab = _mm_cvttpd_epi32(rt);
584 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
585 vfitab = _mm_slli_epi32(vfitab,3);
587 /* CUBIC SPLINE TABLE DISPERSION */
588 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
589 F = _mm_setzero_pd();
590 GMX_MM_TRANSPOSE2_PD(Y,F);
591 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
592 H = _mm_setzero_pd();
593 GMX_MM_TRANSPOSE2_PD(G,H);
594 Heps = _mm_mul_pd(vfeps,H);
595 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
596 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
597 fvdw6 = _mm_mul_pd(c6_00,FF);
599 /* CUBIC SPLINE TABLE REPULSION */
600 vfitab = _mm_add_epi32(vfitab,ifour);
601 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
602 F = _mm_setzero_pd();
603 GMX_MM_TRANSPOSE2_PD(Y,F);
604 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
605 H = _mm_setzero_pd();
606 GMX_MM_TRANSPOSE2_PD(G,H);
607 Heps = _mm_mul_pd(vfeps,H);
608 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
609 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
610 fvdw12 = _mm_mul_pd(c12_00,FF);
611 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
615 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
617 /* Calculate temporary vectorial force */
618 tx = _mm_mul_pd(fscal,dx00);
619 ty = _mm_mul_pd(fscal,dy00);
620 tz = _mm_mul_pd(fscal,dz00);
622 /* Update vectorial force */
623 fix0 = _mm_add_pd(fix0,tx);
624 fiy0 = _mm_add_pd(fiy0,ty);
625 fiz0 = _mm_add_pd(fiz0,tz);
627 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
629 /* Inner loop uses 48 flops */
632 /* End of innermost loop */
634 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
635 f+i_coord_offset,fshift+i_shift_offset);
637 /* Increment number of inner iterations */
638 inneriter += j_index_end - j_index_start;
640 /* Outer loop uses 6 flops */
643 /* Increment number of outer iterations */
646 /* Update outer/inner flops */
648 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*48);