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 sse2_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse2_double.h"
48 #include "kernelutil_x86_sse2_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse2_double
52 * Electrostatics interaction: None
53 * VdW interaction: CubicSplineTable
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_VF_sse2_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;
86 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
89 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
90 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
92 __m128i ifour = _mm_set1_epi32(4);
93 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
95 __m128d dummy_mask,cutoff_mask;
96 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
97 __m128d one = _mm_set1_pd(1.0);
98 __m128d two = _mm_set1_pd(2.0);
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
110 nvdwtype = fr->ntype;
112 vdwtype = mdatoms->typeA;
114 vftab = kernel_data->table_vdw->data;
115 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
117 /* Avoid stupid compiler warnings */
125 /* Start outer loop over neighborlists */
126 for(iidx=0; iidx<nri; iidx++)
128 /* Load shift vector for this list */
129 i_shift_offset = DIM*shiftidx[iidx];
131 /* Load limits for loop over neighbors */
132 j_index_start = jindex[iidx];
133 j_index_end = jindex[iidx+1];
135 /* Get outer coordinate index */
137 i_coord_offset = DIM*inr;
139 /* Load i particle coords and add shift vector */
140 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
142 fix0 = _mm_setzero_pd();
143 fiy0 = _mm_setzero_pd();
144 fiz0 = _mm_setzero_pd();
146 /* Load parameters for i particles */
147 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
149 /* Reset potential sums */
150 vvdwsum = _mm_setzero_pd();
152 /* Start inner kernel loop */
153 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
156 /* Get j neighbor index, and coordinate index */
159 j_coord_offsetA = DIM*jnrA;
160 j_coord_offsetB = DIM*jnrB;
162 /* load j atom coordinates */
163 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
166 /* Calculate displacement vector */
167 dx00 = _mm_sub_pd(ix0,jx0);
168 dy00 = _mm_sub_pd(iy0,jy0);
169 dz00 = _mm_sub_pd(iz0,jz0);
171 /* Calculate squared distance and things based on it */
172 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
174 rinv00 = gmx_mm_invsqrt_pd(rsq00);
176 /* Load parameters for j particles */
177 vdwjidx0A = 2*vdwtype[jnrA+0];
178 vdwjidx0B = 2*vdwtype[jnrB+0];
180 /**************************
181 * CALCULATE INTERACTIONS *
182 **************************/
184 r00 = _mm_mul_pd(rsq00,rinv00);
186 /* Compute parameters for interactions between i and j atoms */
187 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
188 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
190 /* Calculate table index by multiplying r with table scale and truncate to integer */
191 rt = _mm_mul_pd(r00,vftabscale);
192 vfitab = _mm_cvttpd_epi32(rt);
193 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
194 vfitab = _mm_slli_epi32(vfitab,3);
196 /* CUBIC SPLINE TABLE DISPERSION */
197 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
198 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
199 GMX_MM_TRANSPOSE2_PD(Y,F);
200 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
201 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
202 GMX_MM_TRANSPOSE2_PD(G,H);
203 Heps = _mm_mul_pd(vfeps,H);
204 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
205 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
206 vvdw6 = _mm_mul_pd(c6_00,VV);
207 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
208 fvdw6 = _mm_mul_pd(c6_00,FF);
210 /* CUBIC SPLINE TABLE REPULSION */
211 vfitab = _mm_add_epi32(vfitab,ifour);
212 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
213 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
214 GMX_MM_TRANSPOSE2_PD(Y,F);
215 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
216 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
217 GMX_MM_TRANSPOSE2_PD(G,H);
218 Heps = _mm_mul_pd(vfeps,H);
219 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
220 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
221 vvdw12 = _mm_mul_pd(c12_00,VV);
222 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
223 fvdw12 = _mm_mul_pd(c12_00,FF);
224 vvdw = _mm_add_pd(vvdw12,vvdw6);
225 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
227 /* Update potential sum for this i atom from the interaction with this j atom. */
228 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
232 /* Calculate temporary vectorial force */
233 tx = _mm_mul_pd(fscal,dx00);
234 ty = _mm_mul_pd(fscal,dy00);
235 tz = _mm_mul_pd(fscal,dz00);
237 /* Update vectorial force */
238 fix0 = _mm_add_pd(fix0,tx);
239 fiy0 = _mm_add_pd(fiy0,ty);
240 fiz0 = _mm_add_pd(fiz0,tz);
242 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
244 /* Inner loop uses 56 flops */
251 j_coord_offsetA = DIM*jnrA;
253 /* load j atom coordinates */
254 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
257 /* Calculate displacement vector */
258 dx00 = _mm_sub_pd(ix0,jx0);
259 dy00 = _mm_sub_pd(iy0,jy0);
260 dz00 = _mm_sub_pd(iz0,jz0);
262 /* Calculate squared distance and things based on it */
263 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
265 rinv00 = gmx_mm_invsqrt_pd(rsq00);
267 /* Load parameters for j particles */
268 vdwjidx0A = 2*vdwtype[jnrA+0];
270 /**************************
271 * CALCULATE INTERACTIONS *
272 **************************/
274 r00 = _mm_mul_pd(rsq00,rinv00);
276 /* Compute parameters for interactions between i and j atoms */
277 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
279 /* Calculate table index by multiplying r with table scale and truncate to integer */
280 rt = _mm_mul_pd(r00,vftabscale);
281 vfitab = _mm_cvttpd_epi32(rt);
282 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
283 vfitab = _mm_slli_epi32(vfitab,3);
285 /* CUBIC SPLINE TABLE DISPERSION */
286 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
287 F = _mm_setzero_pd();
288 GMX_MM_TRANSPOSE2_PD(Y,F);
289 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
290 H = _mm_setzero_pd();
291 GMX_MM_TRANSPOSE2_PD(G,H);
292 Heps = _mm_mul_pd(vfeps,H);
293 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
294 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
295 vvdw6 = _mm_mul_pd(c6_00,VV);
296 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
297 fvdw6 = _mm_mul_pd(c6_00,FF);
299 /* CUBIC SPLINE TABLE REPULSION */
300 vfitab = _mm_add_epi32(vfitab,ifour);
301 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
302 F = _mm_setzero_pd();
303 GMX_MM_TRANSPOSE2_PD(Y,F);
304 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
305 H = _mm_setzero_pd();
306 GMX_MM_TRANSPOSE2_PD(G,H);
307 Heps = _mm_mul_pd(vfeps,H);
308 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
309 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
310 vvdw12 = _mm_mul_pd(c12_00,VV);
311 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
312 fvdw12 = _mm_mul_pd(c12_00,FF);
313 vvdw = _mm_add_pd(vvdw12,vvdw6);
314 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
316 /* Update potential sum for this i atom from the interaction with this j atom. */
317 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
318 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
322 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
324 /* Calculate temporary vectorial force */
325 tx = _mm_mul_pd(fscal,dx00);
326 ty = _mm_mul_pd(fscal,dy00);
327 tz = _mm_mul_pd(fscal,dz00);
329 /* Update vectorial force */
330 fix0 = _mm_add_pd(fix0,tx);
331 fiy0 = _mm_add_pd(fiy0,ty);
332 fiz0 = _mm_add_pd(fiz0,tz);
334 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
336 /* Inner loop uses 56 flops */
339 /* End of innermost loop */
341 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
342 f+i_coord_offset,fshift+i_shift_offset);
345 /* Update potential energies */
346 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
348 /* Increment number of inner iterations */
349 inneriter += j_index_end - j_index_start;
351 /* Outer loop uses 7 flops */
354 /* Increment number of outer iterations */
357 /* Update outer/inner flops */
359 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_VF,outeriter*7 + inneriter*56);
362 * Gromacs nonbonded kernel: nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse2_double
363 * Electrostatics interaction: None
364 * VdW interaction: CubicSplineTable
365 * Geometry: Particle-Particle
366 * Calculate force/pot: Force
369 nb_kernel_ElecNone_VdwCSTab_GeomP1P1_F_sse2_double
370 (t_nblist * gmx_restrict nlist,
371 rvec * gmx_restrict xx,
372 rvec * gmx_restrict ff,
373 t_forcerec * gmx_restrict fr,
374 t_mdatoms * gmx_restrict mdatoms,
375 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
376 t_nrnb * gmx_restrict nrnb)
378 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
379 * just 0 for non-waters.
380 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
381 * jnr indices corresponding to data put in the four positions in the SIMD register.
383 int i_shift_offset,i_coord_offset,outeriter,inneriter;
384 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
386 int j_coord_offsetA,j_coord_offsetB;
387 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
389 real *shiftvec,*fshift,*x,*f;
390 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
392 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
393 int vdwjidx0A,vdwjidx0B;
394 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
395 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
397 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
400 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
401 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
403 __m128i ifour = _mm_set1_epi32(4);
404 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
406 __m128d dummy_mask,cutoff_mask;
407 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
408 __m128d one = _mm_set1_pd(1.0);
409 __m128d two = _mm_set1_pd(2.0);
415 jindex = nlist->jindex;
417 shiftidx = nlist->shift;
419 shiftvec = fr->shift_vec[0];
420 fshift = fr->fshift[0];
421 nvdwtype = fr->ntype;
423 vdwtype = mdatoms->typeA;
425 vftab = kernel_data->table_vdw->data;
426 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
428 /* Avoid stupid compiler warnings */
436 /* Start outer loop over neighborlists */
437 for(iidx=0; iidx<nri; iidx++)
439 /* Load shift vector for this list */
440 i_shift_offset = DIM*shiftidx[iidx];
442 /* Load limits for loop over neighbors */
443 j_index_start = jindex[iidx];
444 j_index_end = jindex[iidx+1];
446 /* Get outer coordinate index */
448 i_coord_offset = DIM*inr;
450 /* Load i particle coords and add shift vector */
451 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
453 fix0 = _mm_setzero_pd();
454 fiy0 = _mm_setzero_pd();
455 fiz0 = _mm_setzero_pd();
457 /* Load parameters for i particles */
458 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
460 /* Start inner kernel loop */
461 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
464 /* Get j neighbor index, and coordinate index */
467 j_coord_offsetA = DIM*jnrA;
468 j_coord_offsetB = DIM*jnrB;
470 /* load j atom coordinates */
471 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
474 /* Calculate displacement vector */
475 dx00 = _mm_sub_pd(ix0,jx0);
476 dy00 = _mm_sub_pd(iy0,jy0);
477 dz00 = _mm_sub_pd(iz0,jz0);
479 /* Calculate squared distance and things based on it */
480 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
482 rinv00 = gmx_mm_invsqrt_pd(rsq00);
484 /* Load parameters for j particles */
485 vdwjidx0A = 2*vdwtype[jnrA+0];
486 vdwjidx0B = 2*vdwtype[jnrB+0];
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
492 r00 = _mm_mul_pd(rsq00,rinv00);
494 /* Compute parameters for interactions between i and j atoms */
495 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
496 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
498 /* Calculate table index by multiplying r with table scale and truncate to integer */
499 rt = _mm_mul_pd(r00,vftabscale);
500 vfitab = _mm_cvttpd_epi32(rt);
501 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
502 vfitab = _mm_slli_epi32(vfitab,3);
504 /* CUBIC SPLINE TABLE DISPERSION */
505 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
506 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
507 GMX_MM_TRANSPOSE2_PD(Y,F);
508 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
509 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
510 GMX_MM_TRANSPOSE2_PD(G,H);
511 Heps = _mm_mul_pd(vfeps,H);
512 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
513 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
514 fvdw6 = _mm_mul_pd(c6_00,FF);
516 /* CUBIC SPLINE TABLE REPULSION */
517 vfitab = _mm_add_epi32(vfitab,ifour);
518 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
519 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
520 GMX_MM_TRANSPOSE2_PD(Y,F);
521 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
522 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
523 GMX_MM_TRANSPOSE2_PD(G,H);
524 Heps = _mm_mul_pd(vfeps,H);
525 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
526 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
527 fvdw12 = _mm_mul_pd(c12_00,FF);
528 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
532 /* Calculate temporary vectorial force */
533 tx = _mm_mul_pd(fscal,dx00);
534 ty = _mm_mul_pd(fscal,dy00);
535 tz = _mm_mul_pd(fscal,dz00);
537 /* Update vectorial force */
538 fix0 = _mm_add_pd(fix0,tx);
539 fiy0 = _mm_add_pd(fiy0,ty);
540 fiz0 = _mm_add_pd(fiz0,tz);
542 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
544 /* Inner loop uses 48 flops */
551 j_coord_offsetA = DIM*jnrA;
553 /* load j atom coordinates */
554 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
557 /* Calculate displacement vector */
558 dx00 = _mm_sub_pd(ix0,jx0);
559 dy00 = _mm_sub_pd(iy0,jy0);
560 dz00 = _mm_sub_pd(iz0,jz0);
562 /* Calculate squared distance and things based on it */
563 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
565 rinv00 = gmx_mm_invsqrt_pd(rsq00);
567 /* Load parameters for j particles */
568 vdwjidx0A = 2*vdwtype[jnrA+0];
570 /**************************
571 * CALCULATE INTERACTIONS *
572 **************************/
574 r00 = _mm_mul_pd(rsq00,rinv00);
576 /* Compute parameters for interactions between i and j atoms */
577 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
579 /* Calculate table index by multiplying r with table scale and truncate to integer */
580 rt = _mm_mul_pd(r00,vftabscale);
581 vfitab = _mm_cvttpd_epi32(rt);
582 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
583 vfitab = _mm_slli_epi32(vfitab,3);
585 /* CUBIC SPLINE TABLE DISPERSION */
586 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
587 F = _mm_setzero_pd();
588 GMX_MM_TRANSPOSE2_PD(Y,F);
589 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
590 H = _mm_setzero_pd();
591 GMX_MM_TRANSPOSE2_PD(G,H);
592 Heps = _mm_mul_pd(vfeps,H);
593 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
594 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
595 fvdw6 = _mm_mul_pd(c6_00,FF);
597 /* CUBIC SPLINE TABLE REPULSION */
598 vfitab = _mm_add_epi32(vfitab,ifour);
599 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
600 F = _mm_setzero_pd();
601 GMX_MM_TRANSPOSE2_PD(Y,F);
602 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
603 H = _mm_setzero_pd();
604 GMX_MM_TRANSPOSE2_PD(G,H);
605 Heps = _mm_mul_pd(vfeps,H);
606 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
607 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
608 fvdw12 = _mm_mul_pd(c12_00,FF);
609 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
613 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
615 /* Calculate temporary vectorial force */
616 tx = _mm_mul_pd(fscal,dx00);
617 ty = _mm_mul_pd(fscal,dy00);
618 tz = _mm_mul_pd(fscal,dz00);
620 /* Update vectorial force */
621 fix0 = _mm_add_pd(fix0,tx);
622 fiy0 = _mm_add_pd(fiy0,ty);
623 fiz0 = _mm_add_pd(fiz0,tz);
625 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
627 /* Inner loop uses 48 flops */
630 /* End of innermost loop */
632 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
633 f+i_coord_offset,fshift+i_shift_offset);
635 /* Increment number of inner iterations */
636 inneriter += j_index_end - j_index_start;
638 /* Outer loop uses 6 flops */
641 /* Increment number of outer iterations */
644 /* Update outer/inner flops */
646 inc_nrnb(nrnb,eNR_NBKERNEL_VDW_F,outeriter*6 + inneriter*48);