2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_avx_128_fma_single
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: CubicSplineTable
56 * Geometry: Water4-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
92 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
93 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
94 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
95 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
96 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
97 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
98 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
99 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
102 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
105 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
106 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
108 __m128i ifour = _mm_set1_epi32(4);
109 __m128 rt,vfeps,twovfeps,vftabscale,Y,F,G,H,Fp,VV,FF;
111 __m128 dummy_mask,cutoff_mask;
112 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
113 __m128 one = _mm_set1_ps(1.0);
114 __m128 two = _mm_set1_ps(2.0);
120 jindex = nlist->jindex;
122 shiftidx = nlist->shift;
124 shiftvec = fr->shift_vec[0];
125 fshift = fr->fshift[0];
126 facel = _mm_set1_ps(fr->epsfac);
127 charge = mdatoms->chargeA;
128 nvdwtype = fr->ntype;
130 vdwtype = mdatoms->typeA;
132 vftab = kernel_data->table_vdw->data;
133 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
135 /* Setup water-specific parameters */
136 inr = nlist->iinr[0];
137 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
138 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
139 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
140 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
142 /* Avoid stupid compiler warnings */
143 jnrA = jnrB = jnrC = jnrD = 0;
152 for(iidx=0;iidx<4*DIM;iidx++)
157 /* Start outer loop over neighborlists */
158 for(iidx=0; iidx<nri; iidx++)
160 /* Load shift vector for this list */
161 i_shift_offset = DIM*shiftidx[iidx];
163 /* Load limits for loop over neighbors */
164 j_index_start = jindex[iidx];
165 j_index_end = jindex[iidx+1];
167 /* Get outer coordinate index */
169 i_coord_offset = DIM*inr;
171 /* Load i particle coords and add shift vector */
172 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
173 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
175 fix0 = _mm_setzero_ps();
176 fiy0 = _mm_setzero_ps();
177 fiz0 = _mm_setzero_ps();
178 fix1 = _mm_setzero_ps();
179 fiy1 = _mm_setzero_ps();
180 fiz1 = _mm_setzero_ps();
181 fix2 = _mm_setzero_ps();
182 fiy2 = _mm_setzero_ps();
183 fiz2 = _mm_setzero_ps();
184 fix3 = _mm_setzero_ps();
185 fiy3 = _mm_setzero_ps();
186 fiz3 = _mm_setzero_ps();
188 /* Reset potential sums */
189 velecsum = _mm_setzero_ps();
190 vvdwsum = _mm_setzero_ps();
192 /* Start inner kernel loop */
193 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
196 /* Get j neighbor index, and coordinate index */
201 j_coord_offsetA = DIM*jnrA;
202 j_coord_offsetB = DIM*jnrB;
203 j_coord_offsetC = DIM*jnrC;
204 j_coord_offsetD = DIM*jnrD;
206 /* load j atom coordinates */
207 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
208 x+j_coord_offsetC,x+j_coord_offsetD,
211 /* Calculate displacement vector */
212 dx00 = _mm_sub_ps(ix0,jx0);
213 dy00 = _mm_sub_ps(iy0,jy0);
214 dz00 = _mm_sub_ps(iz0,jz0);
215 dx10 = _mm_sub_ps(ix1,jx0);
216 dy10 = _mm_sub_ps(iy1,jy0);
217 dz10 = _mm_sub_ps(iz1,jz0);
218 dx20 = _mm_sub_ps(ix2,jx0);
219 dy20 = _mm_sub_ps(iy2,jy0);
220 dz20 = _mm_sub_ps(iz2,jz0);
221 dx30 = _mm_sub_ps(ix3,jx0);
222 dy30 = _mm_sub_ps(iy3,jy0);
223 dz30 = _mm_sub_ps(iz3,jz0);
225 /* Calculate squared distance and things based on it */
226 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
227 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
228 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
229 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
231 rinv00 = gmx_mm_invsqrt_ps(rsq00);
232 rinv10 = gmx_mm_invsqrt_ps(rsq10);
233 rinv20 = gmx_mm_invsqrt_ps(rsq20);
234 rinv30 = gmx_mm_invsqrt_ps(rsq30);
236 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
237 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
238 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
240 /* Load parameters for j particles */
241 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
242 charge+jnrC+0,charge+jnrD+0);
243 vdwjidx0A = 2*vdwtype[jnrA+0];
244 vdwjidx0B = 2*vdwtype[jnrB+0];
245 vdwjidx0C = 2*vdwtype[jnrC+0];
246 vdwjidx0D = 2*vdwtype[jnrD+0];
248 fjx0 = _mm_setzero_ps();
249 fjy0 = _mm_setzero_ps();
250 fjz0 = _mm_setzero_ps();
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 r00 = _mm_mul_ps(rsq00,rinv00);
258 /* Compute parameters for interactions between i and j atoms */
259 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
260 vdwparam+vdwioffset0+vdwjidx0B,
261 vdwparam+vdwioffset0+vdwjidx0C,
262 vdwparam+vdwioffset0+vdwjidx0D,
265 /* Calculate table index by multiplying r with table scale and truncate to integer */
266 rt = _mm_mul_ps(r00,vftabscale);
267 vfitab = _mm_cvttps_epi32(rt);
269 vfeps = _mm_frcz_ps(rt);
271 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
273 twovfeps = _mm_add_ps(vfeps,vfeps);
274 vfitab = _mm_slli_epi32(vfitab,3);
276 /* CUBIC SPLINE TABLE DISPERSION */
277 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
278 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
279 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
280 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
281 _MM_TRANSPOSE4_PS(Y,F,G,H);
282 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
283 VV = _mm_macc_ps(vfeps,Fp,Y);
284 vvdw6 = _mm_mul_ps(c6_00,VV);
285 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
286 fvdw6 = _mm_mul_ps(c6_00,FF);
288 /* CUBIC SPLINE TABLE REPULSION */
289 vfitab = _mm_add_epi32(vfitab,ifour);
290 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
291 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
292 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
293 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
294 _MM_TRANSPOSE4_PS(Y,F,G,H);
295 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
296 VV = _mm_macc_ps(vfeps,Fp,Y);
297 vvdw12 = _mm_mul_ps(c12_00,VV);
298 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
299 fvdw12 = _mm_mul_ps(c12_00,FF);
300 vvdw = _mm_add_ps(vvdw12,vvdw6);
301 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
303 /* Update potential sum for this i atom from the interaction with this j atom. */
304 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
308 /* Update vectorial force */
309 fix0 = _mm_macc_ps(dx00,fscal,fix0);
310 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
311 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
313 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
314 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
315 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
317 /**************************
318 * CALCULATE INTERACTIONS *
319 **************************/
321 /* Compute parameters for interactions between i and j atoms */
322 qq10 = _mm_mul_ps(iq1,jq0);
324 /* COULOMB ELECTROSTATICS */
325 velec = _mm_mul_ps(qq10,rinv10);
326 felec = _mm_mul_ps(velec,rinvsq10);
328 /* Update potential sum for this i atom from the interaction with this j atom. */
329 velecsum = _mm_add_ps(velecsum,velec);
333 /* Update vectorial force */
334 fix1 = _mm_macc_ps(dx10,fscal,fix1);
335 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
336 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
338 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
339 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
340 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
346 /* Compute parameters for interactions between i and j atoms */
347 qq20 = _mm_mul_ps(iq2,jq0);
349 /* COULOMB ELECTROSTATICS */
350 velec = _mm_mul_ps(qq20,rinv20);
351 felec = _mm_mul_ps(velec,rinvsq20);
353 /* Update potential sum for this i atom from the interaction with this j atom. */
354 velecsum = _mm_add_ps(velecsum,velec);
358 /* Update vectorial force */
359 fix2 = _mm_macc_ps(dx20,fscal,fix2);
360 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
361 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
363 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
364 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
365 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
371 /* Compute parameters for interactions between i and j atoms */
372 qq30 = _mm_mul_ps(iq3,jq0);
374 /* COULOMB ELECTROSTATICS */
375 velec = _mm_mul_ps(qq30,rinv30);
376 felec = _mm_mul_ps(velec,rinvsq30);
378 /* Update potential sum for this i atom from the interaction with this j atom. */
379 velecsum = _mm_add_ps(velecsum,velec);
383 /* Update vectorial force */
384 fix3 = _mm_macc_ps(dx30,fscal,fix3);
385 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
386 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
388 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
389 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
390 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
392 fjptrA = f+j_coord_offsetA;
393 fjptrB = f+j_coord_offsetB;
394 fjptrC = f+j_coord_offsetC;
395 fjptrD = f+j_coord_offsetD;
397 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
399 /* Inner loop uses 152 flops */
405 /* Get j neighbor index, and coordinate index */
406 jnrlistA = jjnr[jidx];
407 jnrlistB = jjnr[jidx+1];
408 jnrlistC = jjnr[jidx+2];
409 jnrlistD = jjnr[jidx+3];
410 /* Sign of each element will be negative for non-real atoms.
411 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
412 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
414 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
415 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
416 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
417 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
418 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
419 j_coord_offsetA = DIM*jnrA;
420 j_coord_offsetB = DIM*jnrB;
421 j_coord_offsetC = DIM*jnrC;
422 j_coord_offsetD = DIM*jnrD;
424 /* load j atom coordinates */
425 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
426 x+j_coord_offsetC,x+j_coord_offsetD,
429 /* Calculate displacement vector */
430 dx00 = _mm_sub_ps(ix0,jx0);
431 dy00 = _mm_sub_ps(iy0,jy0);
432 dz00 = _mm_sub_ps(iz0,jz0);
433 dx10 = _mm_sub_ps(ix1,jx0);
434 dy10 = _mm_sub_ps(iy1,jy0);
435 dz10 = _mm_sub_ps(iz1,jz0);
436 dx20 = _mm_sub_ps(ix2,jx0);
437 dy20 = _mm_sub_ps(iy2,jy0);
438 dz20 = _mm_sub_ps(iz2,jz0);
439 dx30 = _mm_sub_ps(ix3,jx0);
440 dy30 = _mm_sub_ps(iy3,jy0);
441 dz30 = _mm_sub_ps(iz3,jz0);
443 /* Calculate squared distance and things based on it */
444 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
445 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
446 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
447 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
449 rinv00 = gmx_mm_invsqrt_ps(rsq00);
450 rinv10 = gmx_mm_invsqrt_ps(rsq10);
451 rinv20 = gmx_mm_invsqrt_ps(rsq20);
452 rinv30 = gmx_mm_invsqrt_ps(rsq30);
454 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
455 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
456 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
458 /* Load parameters for j particles */
459 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
460 charge+jnrC+0,charge+jnrD+0);
461 vdwjidx0A = 2*vdwtype[jnrA+0];
462 vdwjidx0B = 2*vdwtype[jnrB+0];
463 vdwjidx0C = 2*vdwtype[jnrC+0];
464 vdwjidx0D = 2*vdwtype[jnrD+0];
466 fjx0 = _mm_setzero_ps();
467 fjy0 = _mm_setzero_ps();
468 fjz0 = _mm_setzero_ps();
470 /**************************
471 * CALCULATE INTERACTIONS *
472 **************************/
474 r00 = _mm_mul_ps(rsq00,rinv00);
475 r00 = _mm_andnot_ps(dummy_mask,r00);
477 /* Compute parameters for interactions between i and j atoms */
478 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
479 vdwparam+vdwioffset0+vdwjidx0B,
480 vdwparam+vdwioffset0+vdwjidx0C,
481 vdwparam+vdwioffset0+vdwjidx0D,
484 /* Calculate table index by multiplying r with table scale and truncate to integer */
485 rt = _mm_mul_ps(r00,vftabscale);
486 vfitab = _mm_cvttps_epi32(rt);
488 vfeps = _mm_frcz_ps(rt);
490 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
492 twovfeps = _mm_add_ps(vfeps,vfeps);
493 vfitab = _mm_slli_epi32(vfitab,3);
495 /* CUBIC SPLINE TABLE DISPERSION */
496 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
497 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
498 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
499 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
500 _MM_TRANSPOSE4_PS(Y,F,G,H);
501 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
502 VV = _mm_macc_ps(vfeps,Fp,Y);
503 vvdw6 = _mm_mul_ps(c6_00,VV);
504 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
505 fvdw6 = _mm_mul_ps(c6_00,FF);
507 /* CUBIC SPLINE TABLE REPULSION */
508 vfitab = _mm_add_epi32(vfitab,ifour);
509 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
510 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
511 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
512 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
513 _MM_TRANSPOSE4_PS(Y,F,G,H);
514 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
515 VV = _mm_macc_ps(vfeps,Fp,Y);
516 vvdw12 = _mm_mul_ps(c12_00,VV);
517 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
518 fvdw12 = _mm_mul_ps(c12_00,FF);
519 vvdw = _mm_add_ps(vvdw12,vvdw6);
520 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
522 /* Update potential sum for this i atom from the interaction with this j atom. */
523 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
524 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
528 fscal = _mm_andnot_ps(dummy_mask,fscal);
530 /* Update vectorial force */
531 fix0 = _mm_macc_ps(dx00,fscal,fix0);
532 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
533 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
535 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
536 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
537 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
543 /* Compute parameters for interactions between i and j atoms */
544 qq10 = _mm_mul_ps(iq1,jq0);
546 /* COULOMB ELECTROSTATICS */
547 velec = _mm_mul_ps(qq10,rinv10);
548 felec = _mm_mul_ps(velec,rinvsq10);
550 /* Update potential sum for this i atom from the interaction with this j atom. */
551 velec = _mm_andnot_ps(dummy_mask,velec);
552 velecsum = _mm_add_ps(velecsum,velec);
556 fscal = _mm_andnot_ps(dummy_mask,fscal);
558 /* Update vectorial force */
559 fix1 = _mm_macc_ps(dx10,fscal,fix1);
560 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
561 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
563 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
564 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
565 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
567 /**************************
568 * CALCULATE INTERACTIONS *
569 **************************/
571 /* Compute parameters for interactions between i and j atoms */
572 qq20 = _mm_mul_ps(iq2,jq0);
574 /* COULOMB ELECTROSTATICS */
575 velec = _mm_mul_ps(qq20,rinv20);
576 felec = _mm_mul_ps(velec,rinvsq20);
578 /* Update potential sum for this i atom from the interaction with this j atom. */
579 velec = _mm_andnot_ps(dummy_mask,velec);
580 velecsum = _mm_add_ps(velecsum,velec);
584 fscal = _mm_andnot_ps(dummy_mask,fscal);
586 /* Update vectorial force */
587 fix2 = _mm_macc_ps(dx20,fscal,fix2);
588 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
589 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
591 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
592 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
593 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
595 /**************************
596 * CALCULATE INTERACTIONS *
597 **************************/
599 /* Compute parameters for interactions between i and j atoms */
600 qq30 = _mm_mul_ps(iq3,jq0);
602 /* COULOMB ELECTROSTATICS */
603 velec = _mm_mul_ps(qq30,rinv30);
604 felec = _mm_mul_ps(velec,rinvsq30);
606 /* Update potential sum for this i atom from the interaction with this j atom. */
607 velec = _mm_andnot_ps(dummy_mask,velec);
608 velecsum = _mm_add_ps(velecsum,velec);
612 fscal = _mm_andnot_ps(dummy_mask,fscal);
614 /* Update vectorial force */
615 fix3 = _mm_macc_ps(dx30,fscal,fix3);
616 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
617 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
619 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
620 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
621 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
623 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
624 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
625 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
626 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
628 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
630 /* Inner loop uses 153 flops */
633 /* End of innermost loop */
635 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
636 f+i_coord_offset,fshift+i_shift_offset);
639 /* Update potential energies */
640 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
641 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
643 /* Increment number of inner iterations */
644 inneriter += j_index_end - j_index_start;
646 /* Outer loop uses 26 flops */
649 /* Increment number of outer iterations */
652 /* Update outer/inner flops */
654 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*153);
657 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_avx_128_fma_single
658 * Electrostatics interaction: Coulomb
659 * VdW interaction: CubicSplineTable
660 * Geometry: Water4-Particle
661 * Calculate force/pot: Force
664 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_avx_128_fma_single
665 (t_nblist * gmx_restrict nlist,
666 rvec * gmx_restrict xx,
667 rvec * gmx_restrict ff,
668 t_forcerec * gmx_restrict fr,
669 t_mdatoms * gmx_restrict mdatoms,
670 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
671 t_nrnb * gmx_restrict nrnb)
673 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
674 * just 0 for non-waters.
675 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
676 * jnr indices corresponding to data put in the four positions in the SIMD register.
678 int i_shift_offset,i_coord_offset,outeriter,inneriter;
679 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
680 int jnrA,jnrB,jnrC,jnrD;
681 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
682 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
683 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
685 real *shiftvec,*fshift,*x,*f;
686 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
688 __m128 fscal,rcutoff,rcutoff2,jidxall;
690 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
692 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
694 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
696 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
697 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
698 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
699 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
700 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
701 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
702 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
703 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
706 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
709 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
710 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
712 __m128i ifour = _mm_set1_epi32(4);
713 __m128 rt,vfeps,twovfeps,vftabscale,Y,F,G,H,Fp,VV,FF;
715 __m128 dummy_mask,cutoff_mask;
716 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
717 __m128 one = _mm_set1_ps(1.0);
718 __m128 two = _mm_set1_ps(2.0);
724 jindex = nlist->jindex;
726 shiftidx = nlist->shift;
728 shiftvec = fr->shift_vec[0];
729 fshift = fr->fshift[0];
730 facel = _mm_set1_ps(fr->epsfac);
731 charge = mdatoms->chargeA;
732 nvdwtype = fr->ntype;
734 vdwtype = mdatoms->typeA;
736 vftab = kernel_data->table_vdw->data;
737 vftabscale = _mm_set1_ps(kernel_data->table_vdw->scale);
739 /* Setup water-specific parameters */
740 inr = nlist->iinr[0];
741 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
742 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
743 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
744 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
746 /* Avoid stupid compiler warnings */
747 jnrA = jnrB = jnrC = jnrD = 0;
756 for(iidx=0;iidx<4*DIM;iidx++)
761 /* Start outer loop over neighborlists */
762 for(iidx=0; iidx<nri; iidx++)
764 /* Load shift vector for this list */
765 i_shift_offset = DIM*shiftidx[iidx];
767 /* Load limits for loop over neighbors */
768 j_index_start = jindex[iidx];
769 j_index_end = jindex[iidx+1];
771 /* Get outer coordinate index */
773 i_coord_offset = DIM*inr;
775 /* Load i particle coords and add shift vector */
776 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
777 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
779 fix0 = _mm_setzero_ps();
780 fiy0 = _mm_setzero_ps();
781 fiz0 = _mm_setzero_ps();
782 fix1 = _mm_setzero_ps();
783 fiy1 = _mm_setzero_ps();
784 fiz1 = _mm_setzero_ps();
785 fix2 = _mm_setzero_ps();
786 fiy2 = _mm_setzero_ps();
787 fiz2 = _mm_setzero_ps();
788 fix3 = _mm_setzero_ps();
789 fiy3 = _mm_setzero_ps();
790 fiz3 = _mm_setzero_ps();
792 /* Start inner kernel loop */
793 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
796 /* Get j neighbor index, and coordinate index */
801 j_coord_offsetA = DIM*jnrA;
802 j_coord_offsetB = DIM*jnrB;
803 j_coord_offsetC = DIM*jnrC;
804 j_coord_offsetD = DIM*jnrD;
806 /* load j atom coordinates */
807 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
808 x+j_coord_offsetC,x+j_coord_offsetD,
811 /* Calculate displacement vector */
812 dx00 = _mm_sub_ps(ix0,jx0);
813 dy00 = _mm_sub_ps(iy0,jy0);
814 dz00 = _mm_sub_ps(iz0,jz0);
815 dx10 = _mm_sub_ps(ix1,jx0);
816 dy10 = _mm_sub_ps(iy1,jy0);
817 dz10 = _mm_sub_ps(iz1,jz0);
818 dx20 = _mm_sub_ps(ix2,jx0);
819 dy20 = _mm_sub_ps(iy2,jy0);
820 dz20 = _mm_sub_ps(iz2,jz0);
821 dx30 = _mm_sub_ps(ix3,jx0);
822 dy30 = _mm_sub_ps(iy3,jy0);
823 dz30 = _mm_sub_ps(iz3,jz0);
825 /* Calculate squared distance and things based on it */
826 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
827 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
828 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
829 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
831 rinv00 = gmx_mm_invsqrt_ps(rsq00);
832 rinv10 = gmx_mm_invsqrt_ps(rsq10);
833 rinv20 = gmx_mm_invsqrt_ps(rsq20);
834 rinv30 = gmx_mm_invsqrt_ps(rsq30);
836 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
837 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
838 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
840 /* Load parameters for j particles */
841 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
842 charge+jnrC+0,charge+jnrD+0);
843 vdwjidx0A = 2*vdwtype[jnrA+0];
844 vdwjidx0B = 2*vdwtype[jnrB+0];
845 vdwjidx0C = 2*vdwtype[jnrC+0];
846 vdwjidx0D = 2*vdwtype[jnrD+0];
848 fjx0 = _mm_setzero_ps();
849 fjy0 = _mm_setzero_ps();
850 fjz0 = _mm_setzero_ps();
852 /**************************
853 * CALCULATE INTERACTIONS *
854 **************************/
856 r00 = _mm_mul_ps(rsq00,rinv00);
858 /* Compute parameters for interactions between i and j atoms */
859 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
860 vdwparam+vdwioffset0+vdwjidx0B,
861 vdwparam+vdwioffset0+vdwjidx0C,
862 vdwparam+vdwioffset0+vdwjidx0D,
865 /* Calculate table index by multiplying r with table scale and truncate to integer */
866 rt = _mm_mul_ps(r00,vftabscale);
867 vfitab = _mm_cvttps_epi32(rt);
869 vfeps = _mm_frcz_ps(rt);
871 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
873 twovfeps = _mm_add_ps(vfeps,vfeps);
874 vfitab = _mm_slli_epi32(vfitab,3);
876 /* CUBIC SPLINE TABLE DISPERSION */
877 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
878 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
879 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
880 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
881 _MM_TRANSPOSE4_PS(Y,F,G,H);
882 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
883 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
884 fvdw6 = _mm_mul_ps(c6_00,FF);
886 /* CUBIC SPLINE TABLE REPULSION */
887 vfitab = _mm_add_epi32(vfitab,ifour);
888 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
889 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
890 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
891 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
892 _MM_TRANSPOSE4_PS(Y,F,G,H);
893 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
894 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
895 fvdw12 = _mm_mul_ps(c12_00,FF);
896 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
900 /* Update vectorial force */
901 fix0 = _mm_macc_ps(dx00,fscal,fix0);
902 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
903 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
905 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
906 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
907 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
909 /**************************
910 * CALCULATE INTERACTIONS *
911 **************************/
913 /* Compute parameters for interactions between i and j atoms */
914 qq10 = _mm_mul_ps(iq1,jq0);
916 /* COULOMB ELECTROSTATICS */
917 velec = _mm_mul_ps(qq10,rinv10);
918 felec = _mm_mul_ps(velec,rinvsq10);
922 /* Update vectorial force */
923 fix1 = _mm_macc_ps(dx10,fscal,fix1);
924 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
925 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
927 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
928 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
929 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
931 /**************************
932 * CALCULATE INTERACTIONS *
933 **************************/
935 /* Compute parameters for interactions between i and j atoms */
936 qq20 = _mm_mul_ps(iq2,jq0);
938 /* COULOMB ELECTROSTATICS */
939 velec = _mm_mul_ps(qq20,rinv20);
940 felec = _mm_mul_ps(velec,rinvsq20);
944 /* Update vectorial force */
945 fix2 = _mm_macc_ps(dx20,fscal,fix2);
946 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
947 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
949 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
950 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
951 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
953 /**************************
954 * CALCULATE INTERACTIONS *
955 **************************/
957 /* Compute parameters for interactions between i and j atoms */
958 qq30 = _mm_mul_ps(iq3,jq0);
960 /* COULOMB ELECTROSTATICS */
961 velec = _mm_mul_ps(qq30,rinv30);
962 felec = _mm_mul_ps(velec,rinvsq30);
966 /* Update vectorial force */
967 fix3 = _mm_macc_ps(dx30,fscal,fix3);
968 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
969 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
971 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
972 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
973 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
975 fjptrA = f+j_coord_offsetA;
976 fjptrB = f+j_coord_offsetB;
977 fjptrC = f+j_coord_offsetC;
978 fjptrD = f+j_coord_offsetD;
980 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
982 /* Inner loop uses 141 flops */
988 /* Get j neighbor index, and coordinate index */
989 jnrlistA = jjnr[jidx];
990 jnrlistB = jjnr[jidx+1];
991 jnrlistC = jjnr[jidx+2];
992 jnrlistD = jjnr[jidx+3];
993 /* Sign of each element will be negative for non-real atoms.
994 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
995 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
997 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
998 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
999 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1000 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1001 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1002 j_coord_offsetA = DIM*jnrA;
1003 j_coord_offsetB = DIM*jnrB;
1004 j_coord_offsetC = DIM*jnrC;
1005 j_coord_offsetD = DIM*jnrD;
1007 /* load j atom coordinates */
1008 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1009 x+j_coord_offsetC,x+j_coord_offsetD,
1012 /* Calculate displacement vector */
1013 dx00 = _mm_sub_ps(ix0,jx0);
1014 dy00 = _mm_sub_ps(iy0,jy0);
1015 dz00 = _mm_sub_ps(iz0,jz0);
1016 dx10 = _mm_sub_ps(ix1,jx0);
1017 dy10 = _mm_sub_ps(iy1,jy0);
1018 dz10 = _mm_sub_ps(iz1,jz0);
1019 dx20 = _mm_sub_ps(ix2,jx0);
1020 dy20 = _mm_sub_ps(iy2,jy0);
1021 dz20 = _mm_sub_ps(iz2,jz0);
1022 dx30 = _mm_sub_ps(ix3,jx0);
1023 dy30 = _mm_sub_ps(iy3,jy0);
1024 dz30 = _mm_sub_ps(iz3,jz0);
1026 /* Calculate squared distance and things based on it */
1027 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1028 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1029 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1030 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
1032 rinv00 = gmx_mm_invsqrt_ps(rsq00);
1033 rinv10 = gmx_mm_invsqrt_ps(rsq10);
1034 rinv20 = gmx_mm_invsqrt_ps(rsq20);
1035 rinv30 = gmx_mm_invsqrt_ps(rsq30);
1037 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1038 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1039 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
1041 /* Load parameters for j particles */
1042 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1043 charge+jnrC+0,charge+jnrD+0);
1044 vdwjidx0A = 2*vdwtype[jnrA+0];
1045 vdwjidx0B = 2*vdwtype[jnrB+0];
1046 vdwjidx0C = 2*vdwtype[jnrC+0];
1047 vdwjidx0D = 2*vdwtype[jnrD+0];
1049 fjx0 = _mm_setzero_ps();
1050 fjy0 = _mm_setzero_ps();
1051 fjz0 = _mm_setzero_ps();
1053 /**************************
1054 * CALCULATE INTERACTIONS *
1055 **************************/
1057 r00 = _mm_mul_ps(rsq00,rinv00);
1058 r00 = _mm_andnot_ps(dummy_mask,r00);
1060 /* Compute parameters for interactions between i and j atoms */
1061 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1062 vdwparam+vdwioffset0+vdwjidx0B,
1063 vdwparam+vdwioffset0+vdwjidx0C,
1064 vdwparam+vdwioffset0+vdwjidx0D,
1067 /* Calculate table index by multiplying r with table scale and truncate to integer */
1068 rt = _mm_mul_ps(r00,vftabscale);
1069 vfitab = _mm_cvttps_epi32(rt);
1071 vfeps = _mm_frcz_ps(rt);
1073 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR));
1075 twovfeps = _mm_add_ps(vfeps,vfeps);
1076 vfitab = _mm_slli_epi32(vfitab,3);
1078 /* CUBIC SPLINE TABLE DISPERSION */
1079 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1080 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1081 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1082 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1083 _MM_TRANSPOSE4_PS(Y,F,G,H);
1084 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1085 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1086 fvdw6 = _mm_mul_ps(c6_00,FF);
1088 /* CUBIC SPLINE TABLE REPULSION */
1089 vfitab = _mm_add_epi32(vfitab,ifour);
1090 Y = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,0) );
1091 F = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,1) );
1092 G = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,2) );
1093 H = _mm_load_ps( vftab + _mm_extract_epi32(vfitab,3) );
1094 _MM_TRANSPOSE4_PS(Y,F,G,H);
1095 Fp = _mm_macc_ps(vfeps,_mm_macc_ps(H,vfeps,G),F);
1096 FF = _mm_macc_ps(vfeps,_mm_macc_ps(twovfeps,H,G),Fp);
1097 fvdw12 = _mm_mul_ps(c12_00,FF);
1098 fvdw = _mm_xor_ps(signbit,_mm_mul_ps(_mm_add_ps(fvdw6,fvdw12),_mm_mul_ps(vftabscale,rinv00)));
1102 fscal = _mm_andnot_ps(dummy_mask,fscal);
1104 /* Update vectorial force */
1105 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1106 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1107 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1109 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1110 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1111 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1113 /**************************
1114 * CALCULATE INTERACTIONS *
1115 **************************/
1117 /* Compute parameters for interactions between i and j atoms */
1118 qq10 = _mm_mul_ps(iq1,jq0);
1120 /* COULOMB ELECTROSTATICS */
1121 velec = _mm_mul_ps(qq10,rinv10);
1122 felec = _mm_mul_ps(velec,rinvsq10);
1126 fscal = _mm_andnot_ps(dummy_mask,fscal);
1128 /* Update vectorial force */
1129 fix1 = _mm_macc_ps(dx10,fscal,fix1);
1130 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
1131 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
1133 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
1134 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
1135 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1141 /* Compute parameters for interactions between i and j atoms */
1142 qq20 = _mm_mul_ps(iq2,jq0);
1144 /* COULOMB ELECTROSTATICS */
1145 velec = _mm_mul_ps(qq20,rinv20);
1146 felec = _mm_mul_ps(velec,rinvsq20);
1150 fscal = _mm_andnot_ps(dummy_mask,fscal);
1152 /* Update vectorial force */
1153 fix2 = _mm_macc_ps(dx20,fscal,fix2);
1154 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
1155 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
1157 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
1158 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
1159 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
1161 /**************************
1162 * CALCULATE INTERACTIONS *
1163 **************************/
1165 /* Compute parameters for interactions between i and j atoms */
1166 qq30 = _mm_mul_ps(iq3,jq0);
1168 /* COULOMB ELECTROSTATICS */
1169 velec = _mm_mul_ps(qq30,rinv30);
1170 felec = _mm_mul_ps(velec,rinvsq30);
1174 fscal = _mm_andnot_ps(dummy_mask,fscal);
1176 /* Update vectorial force */
1177 fix3 = _mm_macc_ps(dx30,fscal,fix3);
1178 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
1179 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
1181 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
1182 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
1183 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
1185 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1186 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1187 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1188 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1190 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1192 /* Inner loop uses 142 flops */
1195 /* End of innermost loop */
1197 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1198 f+i_coord_offset,fshift+i_shift_offset);
1200 /* Increment number of inner iterations */
1201 inneriter += j_index_end - j_index_start;
1203 /* Outer loop uses 24 flops */
1206 /* Increment number of outer iterations */
1209 /* Update outer/inner flops */
1211 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*142);