2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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 sse2_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse2_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse2_double
51 * Electrostatics interaction: None
52 * VdW interaction: CubicSplineTable
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse2_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81 int vdwjidx0A,vdwjidx0B;
82 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
85 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
88 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
89 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
91 __m128i ifour = _mm_set1_epi32(4);
92 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
94 __m128d dummy_mask,cutoff_mask;
95 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
96 __m128d one = _mm_set1_pd(1.0);
97 __m128d two = _mm_set1_pd(2.0);
103 jindex = nlist->jindex;
105 shiftidx = nlist->shift;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 vftab = kernel_data->table_vdw->data;
114 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
116 /* Avoid stupid compiler warnings */
124 /* Start outer loop over neighborlists */
125 for(iidx=0; iidx<nri; iidx++)
127 /* Load shift vector for this list */
128 i_shift_offset = DIM*shiftidx[iidx];
130 /* Load limits for loop over neighbors */
131 j_index_start = jindex[iidx];
132 j_index_end = jindex[iidx+1];
134 /* Get outer coordinate index */
136 i_coord_offset = DIM*inr;
138 /* Load i particle coords and add shift vector */
139 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
141 fix0 = _mm_setzero_pd();
142 fiy0 = _mm_setzero_pd();
143 fiz0 = _mm_setzero_pd();
145 /* Load parameters for i particles */
146 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
148 /* Reset potential sums */
149 vvdwsum = _mm_setzero_pd();
151 /* Start inner kernel loop */
152 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
155 /* Get j neighbor index, and coordinate index */
158 j_coord_offsetA = DIM*jnrA;
159 j_coord_offsetB = DIM*jnrB;
161 /* load j atom coordinates */
162 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
165 /* Calculate displacement vector */
166 dx00 = _mm_sub_pd(ix0,jx0);
167 dy00 = _mm_sub_pd(iy0,jy0);
168 dz00 = _mm_sub_pd(iz0,jz0);
170 /* Calculate squared distance and things based on it */
171 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
173 rinv00 = sse2_invsqrt_d(rsq00);
175 /* Load parameters for j particles */
176 vdwjidx0A = 2*vdwtype[jnrA+0];
177 vdwjidx0B = 2*vdwtype[jnrB+0];
179 /**************************
180 * CALCULATE INTERACTIONS *
181 **************************/
183 r00 = _mm_mul_pd(rsq00,rinv00);
185 /* Compute parameters for interactions between i and j atoms */
186 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
187 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
189 /* Calculate table index by multiplying r with table scale and truncate to integer */
190 rt = _mm_mul_pd(r00,vftabscale);
191 vfitab = _mm_cvttpd_epi32(rt);
192 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
193 vfitab = _mm_slli_epi32(vfitab,3);
195 /* CUBIC SPLINE TABLE DISPERSION */
196 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
197 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
198 GMX_MM_TRANSPOSE2_PD(Y,F);
199 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
200 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
201 GMX_MM_TRANSPOSE2_PD(G,H);
202 Heps = _mm_mul_pd(vfeps,H);
203 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
204 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
205 vvdw6 = _mm_mul_pd(c6_00,VV);
206 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
207 fvdw6 = _mm_mul_pd(c6_00,FF);
209 /* CUBIC SPLINE TABLE REPULSION */
210 vfitab = _mm_add_epi32(vfitab,ifour);
211 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
212 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
213 GMX_MM_TRANSPOSE2_PD(Y,F);
214 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
215 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
216 GMX_MM_TRANSPOSE2_PD(G,H);
217 Heps = _mm_mul_pd(vfeps,H);
218 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
219 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
220 vvdw12 = _mm_mul_pd(c12_00,VV);
221 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
222 fvdw12 = _mm_mul_pd(c12_00,FF);
223 vvdw = _mm_add_pd(vvdw12,vvdw6);
224 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
226 /* Update potential sum for this i atom from the interaction with this j atom. */
227 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
231 /* Calculate temporary vectorial force */
232 tx = _mm_mul_pd(fscal,dx00);
233 ty = _mm_mul_pd(fscal,dy00);
234 tz = _mm_mul_pd(fscal,dz00);
236 /* Update vectorial force */
237 fix0 = _mm_add_pd(fix0,tx);
238 fiy0 = _mm_add_pd(fiy0,ty);
239 fiz0 = _mm_add_pd(fiz0,tz);
241 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
243 /* Inner loop uses 56 flops */
250 j_coord_offsetA = DIM*jnrA;
252 /* load j atom coordinates */
253 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
256 /* Calculate displacement vector */
257 dx00 = _mm_sub_pd(ix0,jx0);
258 dy00 = _mm_sub_pd(iy0,jy0);
259 dz00 = _mm_sub_pd(iz0,jz0);
261 /* Calculate squared distance and things based on it */
262 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
264 rinv00 = sse2_invsqrt_d(rsq00);
266 /* Load parameters for j particles */
267 vdwjidx0A = 2*vdwtype[jnrA+0];
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
273 r00 = _mm_mul_pd(rsq00,rinv00);
275 /* Compute parameters for interactions between i and j atoms */
276 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
278 /* Calculate table index by multiplying r with table scale and truncate to integer */
279 rt = _mm_mul_pd(r00,vftabscale);
280 vfitab = _mm_cvttpd_epi32(rt);
281 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
282 vfitab = _mm_slli_epi32(vfitab,3);
284 /* CUBIC SPLINE TABLE DISPERSION */
285 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
286 F = _mm_setzero_pd();
287 GMX_MM_TRANSPOSE2_PD(Y,F);
288 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
289 H = _mm_setzero_pd();
290 GMX_MM_TRANSPOSE2_PD(G,H);
291 Heps = _mm_mul_pd(vfeps,H);
292 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
293 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
294 vvdw6 = _mm_mul_pd(c6_00,VV);
295 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
296 fvdw6 = _mm_mul_pd(c6_00,FF);
298 /* CUBIC SPLINE TABLE REPULSION */
299 vfitab = _mm_add_epi32(vfitab,ifour);
300 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
301 F = _mm_setzero_pd();
302 GMX_MM_TRANSPOSE2_PD(Y,F);
303 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
304 H = _mm_setzero_pd();
305 GMX_MM_TRANSPOSE2_PD(G,H);
306 Heps = _mm_mul_pd(vfeps,H);
307 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
308 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
309 vvdw12 = _mm_mul_pd(c12_00,VV);
310 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
311 fvdw12 = _mm_mul_pd(c12_00,FF);
312 vvdw = _mm_add_pd(vvdw12,vvdw6);
313 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
315 /* Update potential sum for this i atom from the interaction with this j atom. */
316 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
317 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
321 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
323 /* Calculate temporary vectorial force */
324 tx = _mm_mul_pd(fscal,dx00);
325 ty = _mm_mul_pd(fscal,dy00);
326 tz = _mm_mul_pd(fscal,dz00);
328 /* Update vectorial force */
329 fix0 = _mm_add_pd(fix0,tx);
330 fiy0 = _mm_add_pd(fiy0,ty);
331 fiz0 = _mm_add_pd(fiz0,tz);
333 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
335 /* Inner loop uses 56 flops */
338 /* End of innermost loop */
340 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
341 f+i_coord_offset,fshift+i_shift_offset);
344 /* Update potential energies */
345 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
347 /* Increment number of inner iterations */
348 inneriter += j_index_end - j_index_start;
350 /* Outer loop uses 7 flops */
353 /* Increment number of outer iterations */
356 /* Update outer/inner flops */
358 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*56);
361 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse2_double
362 * Electrostatics interaction: None
363 * VdW interaction: CubicSplineTable
364 * Geometry: Particle-Particle
365 * Calculate force/pot: Force
368 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse2_double
369 (t_nblist * gmx_restrict nlist,
370 rvec * gmx_restrict xx,
371 rvec * gmx_restrict ff,
372 struct t_forcerec * gmx_restrict fr,
373 t_mdatoms * gmx_restrict mdatoms,
374 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
375 t_nrnb * gmx_restrict nrnb)
377 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
378 * just 0 for non-waters.
379 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
380 * jnr indices corresponding to data put in the four positions in the SIMD register.
382 int i_shift_offset,i_coord_offset,outeriter,inneriter;
383 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
385 int j_coord_offsetA,j_coord_offsetB;
386 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
388 real *shiftvec,*fshift,*x,*f;
389 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
391 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
392 int vdwjidx0A,vdwjidx0B;
393 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
394 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
396 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
399 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
400 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
402 __m128i ifour = _mm_set1_epi32(4);
403 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
405 __m128d dummy_mask,cutoff_mask;
406 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
407 __m128d one = _mm_set1_pd(1.0);
408 __m128d two = _mm_set1_pd(2.0);
414 jindex = nlist->jindex;
416 shiftidx = nlist->shift;
418 shiftvec = fr->shift_vec[0];
419 fshift = fr->fshift[0];
420 nvdwtype = fr->ntype;
422 vdwtype = mdatoms->typeA;
424 vftab = kernel_data->table_vdw->data;
425 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
427 /* Avoid stupid compiler warnings */
435 /* Start outer loop over neighborlists */
436 for(iidx=0; iidx<nri; iidx++)
438 /* Load shift vector for this list */
439 i_shift_offset = DIM*shiftidx[iidx];
441 /* Load limits for loop over neighbors */
442 j_index_start = jindex[iidx];
443 j_index_end = jindex[iidx+1];
445 /* Get outer coordinate index */
447 i_coord_offset = DIM*inr;
449 /* Load i particle coords and add shift vector */
450 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
452 fix0 = _mm_setzero_pd();
453 fiy0 = _mm_setzero_pd();
454 fiz0 = _mm_setzero_pd();
456 /* Load parameters for i particles */
457 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
459 /* Start inner kernel loop */
460 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
463 /* Get j neighbor index, and coordinate index */
466 j_coord_offsetA = DIM*jnrA;
467 j_coord_offsetB = DIM*jnrB;
469 /* load j atom coordinates */
470 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
473 /* Calculate displacement vector */
474 dx00 = _mm_sub_pd(ix0,jx0);
475 dy00 = _mm_sub_pd(iy0,jy0);
476 dz00 = _mm_sub_pd(iz0,jz0);
478 /* Calculate squared distance and things based on it */
479 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
481 rinv00 = sse2_invsqrt_d(rsq00);
483 /* Load parameters for j particles */
484 vdwjidx0A = 2*vdwtype[jnrA+0];
485 vdwjidx0B = 2*vdwtype[jnrB+0];
487 /**************************
488 * CALCULATE INTERACTIONS *
489 **************************/
491 r00 = _mm_mul_pd(rsq00,rinv00);
493 /* Compute parameters for interactions between i and j atoms */
494 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
495 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
497 /* Calculate table index by multiplying r with table scale and truncate to integer */
498 rt = _mm_mul_pd(r00,vftabscale);
499 vfitab = _mm_cvttpd_epi32(rt);
500 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
501 vfitab = _mm_slli_epi32(vfitab,3);
503 /* CUBIC SPLINE TABLE DISPERSION */
504 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
505 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
506 GMX_MM_TRANSPOSE2_PD(Y,F);
507 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
508 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
509 GMX_MM_TRANSPOSE2_PD(G,H);
510 Heps = _mm_mul_pd(vfeps,H);
511 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
512 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
513 fvdw6 = _mm_mul_pd(c6_00,FF);
515 /* CUBIC SPLINE TABLE REPULSION */
516 vfitab = _mm_add_epi32(vfitab,ifour);
517 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
518 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
519 GMX_MM_TRANSPOSE2_PD(Y,F);
520 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
521 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
522 GMX_MM_TRANSPOSE2_PD(G,H);
523 Heps = _mm_mul_pd(vfeps,H);
524 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
525 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
526 fvdw12 = _mm_mul_pd(c12_00,FF);
527 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
531 /* Calculate temporary vectorial force */
532 tx = _mm_mul_pd(fscal,dx00);
533 ty = _mm_mul_pd(fscal,dy00);
534 tz = _mm_mul_pd(fscal,dz00);
536 /* Update vectorial force */
537 fix0 = _mm_add_pd(fix0,tx);
538 fiy0 = _mm_add_pd(fiy0,ty);
539 fiz0 = _mm_add_pd(fiz0,tz);
541 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
543 /* Inner loop uses 48 flops */
550 j_coord_offsetA = DIM*jnrA;
552 /* load j atom coordinates */
553 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
556 /* Calculate displacement vector */
557 dx00 = _mm_sub_pd(ix0,jx0);
558 dy00 = _mm_sub_pd(iy0,jy0);
559 dz00 = _mm_sub_pd(iz0,jz0);
561 /* Calculate squared distance and things based on it */
562 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
564 rinv00 = sse2_invsqrt_d(rsq00);
566 /* Load parameters for j particles */
567 vdwjidx0A = 2*vdwtype[jnrA+0];
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
573 r00 = _mm_mul_pd(rsq00,rinv00);
575 /* Compute parameters for interactions between i and j atoms */
576 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
578 /* Calculate table index by multiplying r with table scale and truncate to integer */
579 rt = _mm_mul_pd(r00,vftabscale);
580 vfitab = _mm_cvttpd_epi32(rt);
581 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
582 vfitab = _mm_slli_epi32(vfitab,3);
584 /* CUBIC SPLINE TABLE DISPERSION */
585 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
586 F = _mm_setzero_pd();
587 GMX_MM_TRANSPOSE2_PD(Y,F);
588 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
589 H = _mm_setzero_pd();
590 GMX_MM_TRANSPOSE2_PD(G,H);
591 Heps = _mm_mul_pd(vfeps,H);
592 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
593 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
594 fvdw6 = _mm_mul_pd(c6_00,FF);
596 /* CUBIC SPLINE TABLE REPULSION */
597 vfitab = _mm_add_epi32(vfitab,ifour);
598 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
599 F = _mm_setzero_pd();
600 GMX_MM_TRANSPOSE2_PD(Y,F);
601 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
602 H = _mm_setzero_pd();
603 GMX_MM_TRANSPOSE2_PD(G,H);
604 Heps = _mm_mul_pd(vfeps,H);
605 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
606 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
607 fvdw12 = _mm_mul_pd(c12_00,FF);
608 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
612 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
614 /* Calculate temporary vectorial force */
615 tx = _mm_mul_pd(fscal,dx00);
616 ty = _mm_mul_pd(fscal,dy00);
617 tz = _mm_mul_pd(fscal,dz00);
619 /* Update vectorial force */
620 fix0 = _mm_add_pd(fix0,tx);
621 fiy0 = _mm_add_pd(fiy0,ty);
622 fiz0 = _mm_add_pd(fiz0,tz);
624 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
626 /* Inner loop uses 48 flops */
629 /* End of innermost loop */
631 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
632 f+i_coord_offset,fshift+i_shift_offset);
634 /* Increment number of inner iterations */
635 inneriter += j_index_end - j_index_start;
637 /* Outer loop uses 6 flops */
640 /* Increment number of outer iterations */
643 /* Update outer/inner flops */
645 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*48);