2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_256_single kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_256_single.h"
48 #include "kernelutil_x86_avx_256_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_avx_256_single
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: CubicSplineTable
54 * Geometry: Water4-Water4
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_VF_avx_256_single
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,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight 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;
74 int jnrA,jnrB,jnrC,jnrD;
75 int jnrE,jnrF,jnrG,jnrH;
76 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
77 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
80 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
82 real *shiftvec,*fshift,*x,*f;
83 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
85 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
86 real * vdwioffsetptr0;
87 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 real * vdwioffsetptr1;
89 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 real * vdwioffsetptr2;
91 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
92 real * vdwioffsetptr3;
93 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
94 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
95 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
96 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
97 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
98 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
99 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
100 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
101 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
102 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
103 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
104 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
105 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
106 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
107 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
108 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
109 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
110 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
111 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
112 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
115 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
118 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
119 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
121 __m128i vfitab_lo,vfitab_hi;
122 __m128i ifour = _mm_set1_epi32(4);
123 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
125 __m256 dummy_mask,cutoff_mask;
126 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
127 __m256 one = _mm256_set1_ps(1.0);
128 __m256 two = _mm256_set1_ps(2.0);
134 jindex = nlist->jindex;
136 shiftidx = nlist->shift;
138 shiftvec = fr->shift_vec[0];
139 fshift = fr->fshift[0];
140 facel = _mm256_set1_ps(fr->epsfac);
141 charge = mdatoms->chargeA;
142 krf = _mm256_set1_ps(fr->ic->k_rf);
143 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
144 crf = _mm256_set1_ps(fr->ic->c_rf);
145 nvdwtype = fr->ntype;
147 vdwtype = mdatoms->typeA;
149 vftab = kernel_data->table_vdw->data;
150 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
152 /* Setup water-specific parameters */
153 inr = nlist->iinr[0];
154 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
155 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
156 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
157 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
159 jq1 = _mm256_set1_ps(charge[inr+1]);
160 jq2 = _mm256_set1_ps(charge[inr+2]);
161 jq3 = _mm256_set1_ps(charge[inr+3]);
162 vdwjidx0A = 2*vdwtype[inr+0];
163 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
164 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
165 qq11 = _mm256_mul_ps(iq1,jq1);
166 qq12 = _mm256_mul_ps(iq1,jq2);
167 qq13 = _mm256_mul_ps(iq1,jq3);
168 qq21 = _mm256_mul_ps(iq2,jq1);
169 qq22 = _mm256_mul_ps(iq2,jq2);
170 qq23 = _mm256_mul_ps(iq2,jq3);
171 qq31 = _mm256_mul_ps(iq3,jq1);
172 qq32 = _mm256_mul_ps(iq3,jq2);
173 qq33 = _mm256_mul_ps(iq3,jq3);
175 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
176 rcutoff_scalar = fr->rcoulomb;
177 rcutoff = _mm256_set1_ps(rcutoff_scalar);
178 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
180 /* Avoid stupid compiler warnings */
181 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
194 for(iidx=0;iidx<4*DIM;iidx++)
199 /* Start outer loop over neighborlists */
200 for(iidx=0; iidx<nri; iidx++)
202 /* Load shift vector for this list */
203 i_shift_offset = DIM*shiftidx[iidx];
205 /* Load limits for loop over neighbors */
206 j_index_start = jindex[iidx];
207 j_index_end = jindex[iidx+1];
209 /* Get outer coordinate index */
211 i_coord_offset = DIM*inr;
213 /* Load i particle coords and add shift vector */
214 gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
215 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
217 fix0 = _mm256_setzero_ps();
218 fiy0 = _mm256_setzero_ps();
219 fiz0 = _mm256_setzero_ps();
220 fix1 = _mm256_setzero_ps();
221 fiy1 = _mm256_setzero_ps();
222 fiz1 = _mm256_setzero_ps();
223 fix2 = _mm256_setzero_ps();
224 fiy2 = _mm256_setzero_ps();
225 fiz2 = _mm256_setzero_ps();
226 fix3 = _mm256_setzero_ps();
227 fiy3 = _mm256_setzero_ps();
228 fiz3 = _mm256_setzero_ps();
230 /* Reset potential sums */
231 velecsum = _mm256_setzero_ps();
232 vvdwsum = _mm256_setzero_ps();
234 /* Start inner kernel loop */
235 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
238 /* Get j neighbor index, and coordinate index */
247 j_coord_offsetA = DIM*jnrA;
248 j_coord_offsetB = DIM*jnrB;
249 j_coord_offsetC = DIM*jnrC;
250 j_coord_offsetD = DIM*jnrD;
251 j_coord_offsetE = DIM*jnrE;
252 j_coord_offsetF = DIM*jnrF;
253 j_coord_offsetG = DIM*jnrG;
254 j_coord_offsetH = DIM*jnrH;
256 /* load j atom coordinates */
257 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
258 x+j_coord_offsetC,x+j_coord_offsetD,
259 x+j_coord_offsetE,x+j_coord_offsetF,
260 x+j_coord_offsetG,x+j_coord_offsetH,
261 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
262 &jy2,&jz2,&jx3,&jy3,&jz3);
264 /* Calculate displacement vector */
265 dx00 = _mm256_sub_ps(ix0,jx0);
266 dy00 = _mm256_sub_ps(iy0,jy0);
267 dz00 = _mm256_sub_ps(iz0,jz0);
268 dx11 = _mm256_sub_ps(ix1,jx1);
269 dy11 = _mm256_sub_ps(iy1,jy1);
270 dz11 = _mm256_sub_ps(iz1,jz1);
271 dx12 = _mm256_sub_ps(ix1,jx2);
272 dy12 = _mm256_sub_ps(iy1,jy2);
273 dz12 = _mm256_sub_ps(iz1,jz2);
274 dx13 = _mm256_sub_ps(ix1,jx3);
275 dy13 = _mm256_sub_ps(iy1,jy3);
276 dz13 = _mm256_sub_ps(iz1,jz3);
277 dx21 = _mm256_sub_ps(ix2,jx1);
278 dy21 = _mm256_sub_ps(iy2,jy1);
279 dz21 = _mm256_sub_ps(iz2,jz1);
280 dx22 = _mm256_sub_ps(ix2,jx2);
281 dy22 = _mm256_sub_ps(iy2,jy2);
282 dz22 = _mm256_sub_ps(iz2,jz2);
283 dx23 = _mm256_sub_ps(ix2,jx3);
284 dy23 = _mm256_sub_ps(iy2,jy3);
285 dz23 = _mm256_sub_ps(iz2,jz3);
286 dx31 = _mm256_sub_ps(ix3,jx1);
287 dy31 = _mm256_sub_ps(iy3,jy1);
288 dz31 = _mm256_sub_ps(iz3,jz1);
289 dx32 = _mm256_sub_ps(ix3,jx2);
290 dy32 = _mm256_sub_ps(iy3,jy2);
291 dz32 = _mm256_sub_ps(iz3,jz2);
292 dx33 = _mm256_sub_ps(ix3,jx3);
293 dy33 = _mm256_sub_ps(iy3,jy3);
294 dz33 = _mm256_sub_ps(iz3,jz3);
296 /* Calculate squared distance and things based on it */
297 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
298 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
299 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
300 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
301 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
302 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
303 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
304 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
305 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
306 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
308 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
309 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
310 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
311 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
312 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
313 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
314 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
315 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
316 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
317 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
319 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
320 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
321 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
322 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
323 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
324 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
325 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
326 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
327 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
329 fjx0 = _mm256_setzero_ps();
330 fjy0 = _mm256_setzero_ps();
331 fjz0 = _mm256_setzero_ps();
332 fjx1 = _mm256_setzero_ps();
333 fjy1 = _mm256_setzero_ps();
334 fjz1 = _mm256_setzero_ps();
335 fjx2 = _mm256_setzero_ps();
336 fjy2 = _mm256_setzero_ps();
337 fjz2 = _mm256_setzero_ps();
338 fjx3 = _mm256_setzero_ps();
339 fjy3 = _mm256_setzero_ps();
340 fjz3 = _mm256_setzero_ps();
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
346 if (gmx_mm256_any_lt(rsq00,rcutoff2))
349 r00 = _mm256_mul_ps(rsq00,rinv00);
351 /* Calculate table index by multiplying r with table scale and truncate to integer */
352 rt = _mm256_mul_ps(r00,vftabscale);
353 vfitab = _mm256_cvttps_epi32(rt);
354 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
355 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
356 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
357 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
358 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
359 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
361 /* CUBIC SPLINE TABLE DISPERSION */
362 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
363 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
364 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
365 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
366 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
367 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
368 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
369 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
370 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
371 Heps = _mm256_mul_ps(vfeps,H);
372 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
373 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
374 vvdw6 = _mm256_mul_ps(c6_00,VV);
375 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
376 fvdw6 = _mm256_mul_ps(c6_00,FF);
378 /* CUBIC SPLINE TABLE REPULSION */
379 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
380 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
381 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
382 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
383 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
384 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
385 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
386 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
387 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
388 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
389 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
390 Heps = _mm256_mul_ps(vfeps,H);
391 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
392 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
393 vvdw12 = _mm256_mul_ps(c12_00,VV);
394 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
395 fvdw12 = _mm256_mul_ps(c12_00,FF);
396 vvdw = _mm256_add_ps(vvdw12,vvdw6);
397 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
399 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
401 /* Update potential sum for this i atom from the interaction with this j atom. */
402 vvdw = _mm256_and_ps(vvdw,cutoff_mask);
403 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
407 fscal = _mm256_and_ps(fscal,cutoff_mask);
409 /* Calculate temporary vectorial force */
410 tx = _mm256_mul_ps(fscal,dx00);
411 ty = _mm256_mul_ps(fscal,dy00);
412 tz = _mm256_mul_ps(fscal,dz00);
414 /* Update vectorial force */
415 fix0 = _mm256_add_ps(fix0,tx);
416 fiy0 = _mm256_add_ps(fiy0,ty);
417 fiz0 = _mm256_add_ps(fiz0,tz);
419 fjx0 = _mm256_add_ps(fjx0,tx);
420 fjy0 = _mm256_add_ps(fjy0,ty);
421 fjz0 = _mm256_add_ps(fjz0,tz);
425 /**************************
426 * CALCULATE INTERACTIONS *
427 **************************/
429 if (gmx_mm256_any_lt(rsq11,rcutoff2))
432 /* REACTION-FIELD ELECTROSTATICS */
433 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
434 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
436 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
438 /* Update potential sum for this i atom from the interaction with this j atom. */
439 velec = _mm256_and_ps(velec,cutoff_mask);
440 velecsum = _mm256_add_ps(velecsum,velec);
444 fscal = _mm256_and_ps(fscal,cutoff_mask);
446 /* Calculate temporary vectorial force */
447 tx = _mm256_mul_ps(fscal,dx11);
448 ty = _mm256_mul_ps(fscal,dy11);
449 tz = _mm256_mul_ps(fscal,dz11);
451 /* Update vectorial force */
452 fix1 = _mm256_add_ps(fix1,tx);
453 fiy1 = _mm256_add_ps(fiy1,ty);
454 fiz1 = _mm256_add_ps(fiz1,tz);
456 fjx1 = _mm256_add_ps(fjx1,tx);
457 fjy1 = _mm256_add_ps(fjy1,ty);
458 fjz1 = _mm256_add_ps(fjz1,tz);
462 /**************************
463 * CALCULATE INTERACTIONS *
464 **************************/
466 if (gmx_mm256_any_lt(rsq12,rcutoff2))
469 /* REACTION-FIELD ELECTROSTATICS */
470 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
471 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
473 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
475 /* Update potential sum for this i atom from the interaction with this j atom. */
476 velec = _mm256_and_ps(velec,cutoff_mask);
477 velecsum = _mm256_add_ps(velecsum,velec);
481 fscal = _mm256_and_ps(fscal,cutoff_mask);
483 /* Calculate temporary vectorial force */
484 tx = _mm256_mul_ps(fscal,dx12);
485 ty = _mm256_mul_ps(fscal,dy12);
486 tz = _mm256_mul_ps(fscal,dz12);
488 /* Update vectorial force */
489 fix1 = _mm256_add_ps(fix1,tx);
490 fiy1 = _mm256_add_ps(fiy1,ty);
491 fiz1 = _mm256_add_ps(fiz1,tz);
493 fjx2 = _mm256_add_ps(fjx2,tx);
494 fjy2 = _mm256_add_ps(fjy2,ty);
495 fjz2 = _mm256_add_ps(fjz2,tz);
499 /**************************
500 * CALCULATE INTERACTIONS *
501 **************************/
503 if (gmx_mm256_any_lt(rsq13,rcutoff2))
506 /* REACTION-FIELD ELECTROSTATICS */
507 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
508 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
510 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
512 /* Update potential sum for this i atom from the interaction with this j atom. */
513 velec = _mm256_and_ps(velec,cutoff_mask);
514 velecsum = _mm256_add_ps(velecsum,velec);
518 fscal = _mm256_and_ps(fscal,cutoff_mask);
520 /* Calculate temporary vectorial force */
521 tx = _mm256_mul_ps(fscal,dx13);
522 ty = _mm256_mul_ps(fscal,dy13);
523 tz = _mm256_mul_ps(fscal,dz13);
525 /* Update vectorial force */
526 fix1 = _mm256_add_ps(fix1,tx);
527 fiy1 = _mm256_add_ps(fiy1,ty);
528 fiz1 = _mm256_add_ps(fiz1,tz);
530 fjx3 = _mm256_add_ps(fjx3,tx);
531 fjy3 = _mm256_add_ps(fjy3,ty);
532 fjz3 = _mm256_add_ps(fjz3,tz);
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
540 if (gmx_mm256_any_lt(rsq21,rcutoff2))
543 /* REACTION-FIELD ELECTROSTATICS */
544 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
545 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
547 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
549 /* Update potential sum for this i atom from the interaction with this j atom. */
550 velec = _mm256_and_ps(velec,cutoff_mask);
551 velecsum = _mm256_add_ps(velecsum,velec);
555 fscal = _mm256_and_ps(fscal,cutoff_mask);
557 /* Calculate temporary vectorial force */
558 tx = _mm256_mul_ps(fscal,dx21);
559 ty = _mm256_mul_ps(fscal,dy21);
560 tz = _mm256_mul_ps(fscal,dz21);
562 /* Update vectorial force */
563 fix2 = _mm256_add_ps(fix2,tx);
564 fiy2 = _mm256_add_ps(fiy2,ty);
565 fiz2 = _mm256_add_ps(fiz2,tz);
567 fjx1 = _mm256_add_ps(fjx1,tx);
568 fjy1 = _mm256_add_ps(fjy1,ty);
569 fjz1 = _mm256_add_ps(fjz1,tz);
573 /**************************
574 * CALCULATE INTERACTIONS *
575 **************************/
577 if (gmx_mm256_any_lt(rsq22,rcutoff2))
580 /* REACTION-FIELD ELECTROSTATICS */
581 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
582 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
584 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
586 /* Update potential sum for this i atom from the interaction with this j atom. */
587 velec = _mm256_and_ps(velec,cutoff_mask);
588 velecsum = _mm256_add_ps(velecsum,velec);
592 fscal = _mm256_and_ps(fscal,cutoff_mask);
594 /* Calculate temporary vectorial force */
595 tx = _mm256_mul_ps(fscal,dx22);
596 ty = _mm256_mul_ps(fscal,dy22);
597 tz = _mm256_mul_ps(fscal,dz22);
599 /* Update vectorial force */
600 fix2 = _mm256_add_ps(fix2,tx);
601 fiy2 = _mm256_add_ps(fiy2,ty);
602 fiz2 = _mm256_add_ps(fiz2,tz);
604 fjx2 = _mm256_add_ps(fjx2,tx);
605 fjy2 = _mm256_add_ps(fjy2,ty);
606 fjz2 = _mm256_add_ps(fjz2,tz);
610 /**************************
611 * CALCULATE INTERACTIONS *
612 **************************/
614 if (gmx_mm256_any_lt(rsq23,rcutoff2))
617 /* REACTION-FIELD ELECTROSTATICS */
618 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
619 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
621 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
623 /* Update potential sum for this i atom from the interaction with this j atom. */
624 velec = _mm256_and_ps(velec,cutoff_mask);
625 velecsum = _mm256_add_ps(velecsum,velec);
629 fscal = _mm256_and_ps(fscal,cutoff_mask);
631 /* Calculate temporary vectorial force */
632 tx = _mm256_mul_ps(fscal,dx23);
633 ty = _mm256_mul_ps(fscal,dy23);
634 tz = _mm256_mul_ps(fscal,dz23);
636 /* Update vectorial force */
637 fix2 = _mm256_add_ps(fix2,tx);
638 fiy2 = _mm256_add_ps(fiy2,ty);
639 fiz2 = _mm256_add_ps(fiz2,tz);
641 fjx3 = _mm256_add_ps(fjx3,tx);
642 fjy3 = _mm256_add_ps(fjy3,ty);
643 fjz3 = _mm256_add_ps(fjz3,tz);
647 /**************************
648 * CALCULATE INTERACTIONS *
649 **************************/
651 if (gmx_mm256_any_lt(rsq31,rcutoff2))
654 /* REACTION-FIELD ELECTROSTATICS */
655 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
656 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
658 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
660 /* Update potential sum for this i atom from the interaction with this j atom. */
661 velec = _mm256_and_ps(velec,cutoff_mask);
662 velecsum = _mm256_add_ps(velecsum,velec);
666 fscal = _mm256_and_ps(fscal,cutoff_mask);
668 /* Calculate temporary vectorial force */
669 tx = _mm256_mul_ps(fscal,dx31);
670 ty = _mm256_mul_ps(fscal,dy31);
671 tz = _mm256_mul_ps(fscal,dz31);
673 /* Update vectorial force */
674 fix3 = _mm256_add_ps(fix3,tx);
675 fiy3 = _mm256_add_ps(fiy3,ty);
676 fiz3 = _mm256_add_ps(fiz3,tz);
678 fjx1 = _mm256_add_ps(fjx1,tx);
679 fjy1 = _mm256_add_ps(fjy1,ty);
680 fjz1 = _mm256_add_ps(fjz1,tz);
684 /**************************
685 * CALCULATE INTERACTIONS *
686 **************************/
688 if (gmx_mm256_any_lt(rsq32,rcutoff2))
691 /* REACTION-FIELD ELECTROSTATICS */
692 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
693 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
695 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
697 /* Update potential sum for this i atom from the interaction with this j atom. */
698 velec = _mm256_and_ps(velec,cutoff_mask);
699 velecsum = _mm256_add_ps(velecsum,velec);
703 fscal = _mm256_and_ps(fscal,cutoff_mask);
705 /* Calculate temporary vectorial force */
706 tx = _mm256_mul_ps(fscal,dx32);
707 ty = _mm256_mul_ps(fscal,dy32);
708 tz = _mm256_mul_ps(fscal,dz32);
710 /* Update vectorial force */
711 fix3 = _mm256_add_ps(fix3,tx);
712 fiy3 = _mm256_add_ps(fiy3,ty);
713 fiz3 = _mm256_add_ps(fiz3,tz);
715 fjx2 = _mm256_add_ps(fjx2,tx);
716 fjy2 = _mm256_add_ps(fjy2,ty);
717 fjz2 = _mm256_add_ps(fjz2,tz);
721 /**************************
722 * CALCULATE INTERACTIONS *
723 **************************/
725 if (gmx_mm256_any_lt(rsq33,rcutoff2))
728 /* REACTION-FIELD ELECTROSTATICS */
729 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
730 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
732 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
734 /* Update potential sum for this i atom from the interaction with this j atom. */
735 velec = _mm256_and_ps(velec,cutoff_mask);
736 velecsum = _mm256_add_ps(velecsum,velec);
740 fscal = _mm256_and_ps(fscal,cutoff_mask);
742 /* Calculate temporary vectorial force */
743 tx = _mm256_mul_ps(fscal,dx33);
744 ty = _mm256_mul_ps(fscal,dy33);
745 tz = _mm256_mul_ps(fscal,dz33);
747 /* Update vectorial force */
748 fix3 = _mm256_add_ps(fix3,tx);
749 fiy3 = _mm256_add_ps(fiy3,ty);
750 fiz3 = _mm256_add_ps(fiz3,tz);
752 fjx3 = _mm256_add_ps(fjx3,tx);
753 fjy3 = _mm256_add_ps(fjy3,ty);
754 fjz3 = _mm256_add_ps(fjz3,tz);
758 fjptrA = f+j_coord_offsetA;
759 fjptrB = f+j_coord_offsetB;
760 fjptrC = f+j_coord_offsetC;
761 fjptrD = f+j_coord_offsetD;
762 fjptrE = f+j_coord_offsetE;
763 fjptrF = f+j_coord_offsetF;
764 fjptrG = f+j_coord_offsetG;
765 fjptrH = f+j_coord_offsetH;
767 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
768 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
769 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
771 /* Inner loop uses 387 flops */
777 /* Get j neighbor index, and coordinate index */
778 jnrlistA = jjnr[jidx];
779 jnrlistB = jjnr[jidx+1];
780 jnrlistC = jjnr[jidx+2];
781 jnrlistD = jjnr[jidx+3];
782 jnrlistE = jjnr[jidx+4];
783 jnrlistF = jjnr[jidx+5];
784 jnrlistG = jjnr[jidx+6];
785 jnrlistH = jjnr[jidx+7];
786 /* Sign of each element will be negative for non-real atoms.
787 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
788 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
790 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
791 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
793 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
794 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
795 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
796 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
797 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
798 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
799 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
800 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
801 j_coord_offsetA = DIM*jnrA;
802 j_coord_offsetB = DIM*jnrB;
803 j_coord_offsetC = DIM*jnrC;
804 j_coord_offsetD = DIM*jnrD;
805 j_coord_offsetE = DIM*jnrE;
806 j_coord_offsetF = DIM*jnrF;
807 j_coord_offsetG = DIM*jnrG;
808 j_coord_offsetH = DIM*jnrH;
810 /* load j atom coordinates */
811 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
812 x+j_coord_offsetC,x+j_coord_offsetD,
813 x+j_coord_offsetE,x+j_coord_offsetF,
814 x+j_coord_offsetG,x+j_coord_offsetH,
815 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
816 &jy2,&jz2,&jx3,&jy3,&jz3);
818 /* Calculate displacement vector */
819 dx00 = _mm256_sub_ps(ix0,jx0);
820 dy00 = _mm256_sub_ps(iy0,jy0);
821 dz00 = _mm256_sub_ps(iz0,jz0);
822 dx11 = _mm256_sub_ps(ix1,jx1);
823 dy11 = _mm256_sub_ps(iy1,jy1);
824 dz11 = _mm256_sub_ps(iz1,jz1);
825 dx12 = _mm256_sub_ps(ix1,jx2);
826 dy12 = _mm256_sub_ps(iy1,jy2);
827 dz12 = _mm256_sub_ps(iz1,jz2);
828 dx13 = _mm256_sub_ps(ix1,jx3);
829 dy13 = _mm256_sub_ps(iy1,jy3);
830 dz13 = _mm256_sub_ps(iz1,jz3);
831 dx21 = _mm256_sub_ps(ix2,jx1);
832 dy21 = _mm256_sub_ps(iy2,jy1);
833 dz21 = _mm256_sub_ps(iz2,jz1);
834 dx22 = _mm256_sub_ps(ix2,jx2);
835 dy22 = _mm256_sub_ps(iy2,jy2);
836 dz22 = _mm256_sub_ps(iz2,jz2);
837 dx23 = _mm256_sub_ps(ix2,jx3);
838 dy23 = _mm256_sub_ps(iy2,jy3);
839 dz23 = _mm256_sub_ps(iz2,jz3);
840 dx31 = _mm256_sub_ps(ix3,jx1);
841 dy31 = _mm256_sub_ps(iy3,jy1);
842 dz31 = _mm256_sub_ps(iz3,jz1);
843 dx32 = _mm256_sub_ps(ix3,jx2);
844 dy32 = _mm256_sub_ps(iy3,jy2);
845 dz32 = _mm256_sub_ps(iz3,jz2);
846 dx33 = _mm256_sub_ps(ix3,jx3);
847 dy33 = _mm256_sub_ps(iy3,jy3);
848 dz33 = _mm256_sub_ps(iz3,jz3);
850 /* Calculate squared distance and things based on it */
851 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
852 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
853 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
854 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
855 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
856 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
857 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
858 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
859 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
860 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
862 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
863 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
864 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
865 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
866 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
867 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
868 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
869 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
870 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
871 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
873 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
874 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
875 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
876 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
877 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
878 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
879 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
880 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
881 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
883 fjx0 = _mm256_setzero_ps();
884 fjy0 = _mm256_setzero_ps();
885 fjz0 = _mm256_setzero_ps();
886 fjx1 = _mm256_setzero_ps();
887 fjy1 = _mm256_setzero_ps();
888 fjz1 = _mm256_setzero_ps();
889 fjx2 = _mm256_setzero_ps();
890 fjy2 = _mm256_setzero_ps();
891 fjz2 = _mm256_setzero_ps();
892 fjx3 = _mm256_setzero_ps();
893 fjy3 = _mm256_setzero_ps();
894 fjz3 = _mm256_setzero_ps();
896 /**************************
897 * CALCULATE INTERACTIONS *
898 **************************/
900 if (gmx_mm256_any_lt(rsq00,rcutoff2))
903 r00 = _mm256_mul_ps(rsq00,rinv00);
904 r00 = _mm256_andnot_ps(dummy_mask,r00);
906 /* Calculate table index by multiplying r with table scale and truncate to integer */
907 rt = _mm256_mul_ps(r00,vftabscale);
908 vfitab = _mm256_cvttps_epi32(rt);
909 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
910 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
911 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
912 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
913 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
914 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
916 /* CUBIC SPLINE TABLE DISPERSION */
917 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
918 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
919 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
920 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
921 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
922 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
923 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
924 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
925 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
926 Heps = _mm256_mul_ps(vfeps,H);
927 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
928 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
929 vvdw6 = _mm256_mul_ps(c6_00,VV);
930 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
931 fvdw6 = _mm256_mul_ps(c6_00,FF);
933 /* CUBIC SPLINE TABLE REPULSION */
934 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
935 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
936 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
937 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
938 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
939 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
940 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
941 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
942 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
943 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
944 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
945 Heps = _mm256_mul_ps(vfeps,H);
946 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
947 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
948 vvdw12 = _mm256_mul_ps(c12_00,VV);
949 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
950 fvdw12 = _mm256_mul_ps(c12_00,FF);
951 vvdw = _mm256_add_ps(vvdw12,vvdw6);
952 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
954 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
956 /* Update potential sum for this i atom from the interaction with this j atom. */
957 vvdw = _mm256_and_ps(vvdw,cutoff_mask);
958 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
959 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
963 fscal = _mm256_and_ps(fscal,cutoff_mask);
965 fscal = _mm256_andnot_ps(dummy_mask,fscal);
967 /* Calculate temporary vectorial force */
968 tx = _mm256_mul_ps(fscal,dx00);
969 ty = _mm256_mul_ps(fscal,dy00);
970 tz = _mm256_mul_ps(fscal,dz00);
972 /* Update vectorial force */
973 fix0 = _mm256_add_ps(fix0,tx);
974 fiy0 = _mm256_add_ps(fiy0,ty);
975 fiz0 = _mm256_add_ps(fiz0,tz);
977 fjx0 = _mm256_add_ps(fjx0,tx);
978 fjy0 = _mm256_add_ps(fjy0,ty);
979 fjz0 = _mm256_add_ps(fjz0,tz);
983 /**************************
984 * CALCULATE INTERACTIONS *
985 **************************/
987 if (gmx_mm256_any_lt(rsq11,rcutoff2))
990 /* REACTION-FIELD ELECTROSTATICS */
991 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
992 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
994 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
996 /* Update potential sum for this i atom from the interaction with this j atom. */
997 velec = _mm256_and_ps(velec,cutoff_mask);
998 velec = _mm256_andnot_ps(dummy_mask,velec);
999 velecsum = _mm256_add_ps(velecsum,velec);
1003 fscal = _mm256_and_ps(fscal,cutoff_mask);
1005 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1007 /* Calculate temporary vectorial force */
1008 tx = _mm256_mul_ps(fscal,dx11);
1009 ty = _mm256_mul_ps(fscal,dy11);
1010 tz = _mm256_mul_ps(fscal,dz11);
1012 /* Update vectorial force */
1013 fix1 = _mm256_add_ps(fix1,tx);
1014 fiy1 = _mm256_add_ps(fiy1,ty);
1015 fiz1 = _mm256_add_ps(fiz1,tz);
1017 fjx1 = _mm256_add_ps(fjx1,tx);
1018 fjy1 = _mm256_add_ps(fjy1,ty);
1019 fjz1 = _mm256_add_ps(fjz1,tz);
1023 /**************************
1024 * CALCULATE INTERACTIONS *
1025 **************************/
1027 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1030 /* REACTION-FIELD ELECTROSTATICS */
1031 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
1032 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1034 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1036 /* Update potential sum for this i atom from the interaction with this j atom. */
1037 velec = _mm256_and_ps(velec,cutoff_mask);
1038 velec = _mm256_andnot_ps(dummy_mask,velec);
1039 velecsum = _mm256_add_ps(velecsum,velec);
1043 fscal = _mm256_and_ps(fscal,cutoff_mask);
1045 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1047 /* Calculate temporary vectorial force */
1048 tx = _mm256_mul_ps(fscal,dx12);
1049 ty = _mm256_mul_ps(fscal,dy12);
1050 tz = _mm256_mul_ps(fscal,dz12);
1052 /* Update vectorial force */
1053 fix1 = _mm256_add_ps(fix1,tx);
1054 fiy1 = _mm256_add_ps(fiy1,ty);
1055 fiz1 = _mm256_add_ps(fiz1,tz);
1057 fjx2 = _mm256_add_ps(fjx2,tx);
1058 fjy2 = _mm256_add_ps(fjy2,ty);
1059 fjz2 = _mm256_add_ps(fjz2,tz);
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1067 if (gmx_mm256_any_lt(rsq13,rcutoff2))
1070 /* REACTION-FIELD ELECTROSTATICS */
1071 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
1072 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1074 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1076 /* Update potential sum for this i atom from the interaction with this j atom. */
1077 velec = _mm256_and_ps(velec,cutoff_mask);
1078 velec = _mm256_andnot_ps(dummy_mask,velec);
1079 velecsum = _mm256_add_ps(velecsum,velec);
1083 fscal = _mm256_and_ps(fscal,cutoff_mask);
1085 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1087 /* Calculate temporary vectorial force */
1088 tx = _mm256_mul_ps(fscal,dx13);
1089 ty = _mm256_mul_ps(fscal,dy13);
1090 tz = _mm256_mul_ps(fscal,dz13);
1092 /* Update vectorial force */
1093 fix1 = _mm256_add_ps(fix1,tx);
1094 fiy1 = _mm256_add_ps(fiy1,ty);
1095 fiz1 = _mm256_add_ps(fiz1,tz);
1097 fjx3 = _mm256_add_ps(fjx3,tx);
1098 fjy3 = _mm256_add_ps(fjy3,ty);
1099 fjz3 = _mm256_add_ps(fjz3,tz);
1103 /**************************
1104 * CALCULATE INTERACTIONS *
1105 **************************/
1107 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1110 /* REACTION-FIELD ELECTROSTATICS */
1111 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1112 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1114 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1116 /* Update potential sum for this i atom from the interaction with this j atom. */
1117 velec = _mm256_and_ps(velec,cutoff_mask);
1118 velec = _mm256_andnot_ps(dummy_mask,velec);
1119 velecsum = _mm256_add_ps(velecsum,velec);
1123 fscal = _mm256_and_ps(fscal,cutoff_mask);
1125 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1127 /* Calculate temporary vectorial force */
1128 tx = _mm256_mul_ps(fscal,dx21);
1129 ty = _mm256_mul_ps(fscal,dy21);
1130 tz = _mm256_mul_ps(fscal,dz21);
1132 /* Update vectorial force */
1133 fix2 = _mm256_add_ps(fix2,tx);
1134 fiy2 = _mm256_add_ps(fiy2,ty);
1135 fiz2 = _mm256_add_ps(fiz2,tz);
1137 fjx1 = _mm256_add_ps(fjx1,tx);
1138 fjy1 = _mm256_add_ps(fjy1,ty);
1139 fjz1 = _mm256_add_ps(fjz1,tz);
1143 /**************************
1144 * CALCULATE INTERACTIONS *
1145 **************************/
1147 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1150 /* REACTION-FIELD ELECTROSTATICS */
1151 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1152 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1154 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1156 /* Update potential sum for this i atom from the interaction with this j atom. */
1157 velec = _mm256_and_ps(velec,cutoff_mask);
1158 velec = _mm256_andnot_ps(dummy_mask,velec);
1159 velecsum = _mm256_add_ps(velecsum,velec);
1163 fscal = _mm256_and_ps(fscal,cutoff_mask);
1165 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1167 /* Calculate temporary vectorial force */
1168 tx = _mm256_mul_ps(fscal,dx22);
1169 ty = _mm256_mul_ps(fscal,dy22);
1170 tz = _mm256_mul_ps(fscal,dz22);
1172 /* Update vectorial force */
1173 fix2 = _mm256_add_ps(fix2,tx);
1174 fiy2 = _mm256_add_ps(fiy2,ty);
1175 fiz2 = _mm256_add_ps(fiz2,tz);
1177 fjx2 = _mm256_add_ps(fjx2,tx);
1178 fjy2 = _mm256_add_ps(fjy2,ty);
1179 fjz2 = _mm256_add_ps(fjz2,tz);
1183 /**************************
1184 * CALCULATE INTERACTIONS *
1185 **************************/
1187 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1190 /* REACTION-FIELD ELECTROSTATICS */
1191 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
1192 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1194 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1196 /* Update potential sum for this i atom from the interaction with this j atom. */
1197 velec = _mm256_and_ps(velec,cutoff_mask);
1198 velec = _mm256_andnot_ps(dummy_mask,velec);
1199 velecsum = _mm256_add_ps(velecsum,velec);
1203 fscal = _mm256_and_ps(fscal,cutoff_mask);
1205 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1207 /* Calculate temporary vectorial force */
1208 tx = _mm256_mul_ps(fscal,dx23);
1209 ty = _mm256_mul_ps(fscal,dy23);
1210 tz = _mm256_mul_ps(fscal,dz23);
1212 /* Update vectorial force */
1213 fix2 = _mm256_add_ps(fix2,tx);
1214 fiy2 = _mm256_add_ps(fiy2,ty);
1215 fiz2 = _mm256_add_ps(fiz2,tz);
1217 fjx3 = _mm256_add_ps(fjx3,tx);
1218 fjy3 = _mm256_add_ps(fjy3,ty);
1219 fjz3 = _mm256_add_ps(fjz3,tz);
1223 /**************************
1224 * CALCULATE INTERACTIONS *
1225 **************************/
1227 if (gmx_mm256_any_lt(rsq31,rcutoff2))
1230 /* REACTION-FIELD ELECTROSTATICS */
1231 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
1232 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1234 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1236 /* Update potential sum for this i atom from the interaction with this j atom. */
1237 velec = _mm256_and_ps(velec,cutoff_mask);
1238 velec = _mm256_andnot_ps(dummy_mask,velec);
1239 velecsum = _mm256_add_ps(velecsum,velec);
1243 fscal = _mm256_and_ps(fscal,cutoff_mask);
1245 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1247 /* Calculate temporary vectorial force */
1248 tx = _mm256_mul_ps(fscal,dx31);
1249 ty = _mm256_mul_ps(fscal,dy31);
1250 tz = _mm256_mul_ps(fscal,dz31);
1252 /* Update vectorial force */
1253 fix3 = _mm256_add_ps(fix3,tx);
1254 fiy3 = _mm256_add_ps(fiy3,ty);
1255 fiz3 = _mm256_add_ps(fiz3,tz);
1257 fjx1 = _mm256_add_ps(fjx1,tx);
1258 fjy1 = _mm256_add_ps(fjy1,ty);
1259 fjz1 = _mm256_add_ps(fjz1,tz);
1263 /**************************
1264 * CALCULATE INTERACTIONS *
1265 **************************/
1267 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1270 /* REACTION-FIELD ELECTROSTATICS */
1271 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
1272 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1274 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1276 /* Update potential sum for this i atom from the interaction with this j atom. */
1277 velec = _mm256_and_ps(velec,cutoff_mask);
1278 velec = _mm256_andnot_ps(dummy_mask,velec);
1279 velecsum = _mm256_add_ps(velecsum,velec);
1283 fscal = _mm256_and_ps(fscal,cutoff_mask);
1285 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1287 /* Calculate temporary vectorial force */
1288 tx = _mm256_mul_ps(fscal,dx32);
1289 ty = _mm256_mul_ps(fscal,dy32);
1290 tz = _mm256_mul_ps(fscal,dz32);
1292 /* Update vectorial force */
1293 fix3 = _mm256_add_ps(fix3,tx);
1294 fiy3 = _mm256_add_ps(fiy3,ty);
1295 fiz3 = _mm256_add_ps(fiz3,tz);
1297 fjx2 = _mm256_add_ps(fjx2,tx);
1298 fjy2 = _mm256_add_ps(fjy2,ty);
1299 fjz2 = _mm256_add_ps(fjz2,tz);
1303 /**************************
1304 * CALCULATE INTERACTIONS *
1305 **************************/
1307 if (gmx_mm256_any_lt(rsq33,rcutoff2))
1310 /* REACTION-FIELD ELECTROSTATICS */
1311 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
1312 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1314 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1316 /* Update potential sum for this i atom from the interaction with this j atom. */
1317 velec = _mm256_and_ps(velec,cutoff_mask);
1318 velec = _mm256_andnot_ps(dummy_mask,velec);
1319 velecsum = _mm256_add_ps(velecsum,velec);
1323 fscal = _mm256_and_ps(fscal,cutoff_mask);
1325 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1327 /* Calculate temporary vectorial force */
1328 tx = _mm256_mul_ps(fscal,dx33);
1329 ty = _mm256_mul_ps(fscal,dy33);
1330 tz = _mm256_mul_ps(fscal,dz33);
1332 /* Update vectorial force */
1333 fix3 = _mm256_add_ps(fix3,tx);
1334 fiy3 = _mm256_add_ps(fiy3,ty);
1335 fiz3 = _mm256_add_ps(fiz3,tz);
1337 fjx3 = _mm256_add_ps(fjx3,tx);
1338 fjy3 = _mm256_add_ps(fjy3,ty);
1339 fjz3 = _mm256_add_ps(fjz3,tz);
1343 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1344 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1345 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1346 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1347 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1348 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1349 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1350 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1352 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1353 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1354 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1356 /* Inner loop uses 388 flops */
1359 /* End of innermost loop */
1361 gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1362 f+i_coord_offset,fshift+i_shift_offset);
1365 /* Update potential energies */
1366 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1367 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1369 /* Increment number of inner iterations */
1370 inneriter += j_index_end - j_index_start;
1372 /* Outer loop uses 26 flops */
1375 /* Increment number of outer iterations */
1378 /* Update outer/inner flops */
1380 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*388);
1383 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_avx_256_single
1384 * Electrostatics interaction: ReactionField
1385 * VdW interaction: CubicSplineTable
1386 * Geometry: Water4-Water4
1387 * Calculate force/pot: Force
1390 nb_kernel_ElecRFCut_VdwCSTab_GeomW4W4_F_avx_256_single
1391 (t_nblist * gmx_restrict nlist,
1392 rvec * gmx_restrict xx,
1393 rvec * gmx_restrict ff,
1394 t_forcerec * gmx_restrict fr,
1395 t_mdatoms * gmx_restrict mdatoms,
1396 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1397 t_nrnb * gmx_restrict nrnb)
1399 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1400 * just 0 for non-waters.
1401 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1402 * jnr indices corresponding to data put in the four positions in the SIMD register.
1404 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1405 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1406 int jnrA,jnrB,jnrC,jnrD;
1407 int jnrE,jnrF,jnrG,jnrH;
1408 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1409 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1410 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1411 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1412 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1413 real rcutoff_scalar;
1414 real *shiftvec,*fshift,*x,*f;
1415 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1416 real scratch[4*DIM];
1417 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1418 real * vdwioffsetptr0;
1419 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1420 real * vdwioffsetptr1;
1421 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1422 real * vdwioffsetptr2;
1423 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1424 real * vdwioffsetptr3;
1425 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1426 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1427 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1428 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1429 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1430 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1431 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1432 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
1433 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1434 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1435 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1436 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1437 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1438 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1439 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1440 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1441 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1442 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1443 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1444 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1447 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1450 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
1451 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
1453 __m128i vfitab_lo,vfitab_hi;
1454 __m128i ifour = _mm_set1_epi32(4);
1455 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
1457 __m256 dummy_mask,cutoff_mask;
1458 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1459 __m256 one = _mm256_set1_ps(1.0);
1460 __m256 two = _mm256_set1_ps(2.0);
1466 jindex = nlist->jindex;
1468 shiftidx = nlist->shift;
1470 shiftvec = fr->shift_vec[0];
1471 fshift = fr->fshift[0];
1472 facel = _mm256_set1_ps(fr->epsfac);
1473 charge = mdatoms->chargeA;
1474 krf = _mm256_set1_ps(fr->ic->k_rf);
1475 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1476 crf = _mm256_set1_ps(fr->ic->c_rf);
1477 nvdwtype = fr->ntype;
1478 vdwparam = fr->nbfp;
1479 vdwtype = mdatoms->typeA;
1481 vftab = kernel_data->table_vdw->data;
1482 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
1484 /* Setup water-specific parameters */
1485 inr = nlist->iinr[0];
1486 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1487 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1488 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
1489 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
1491 jq1 = _mm256_set1_ps(charge[inr+1]);
1492 jq2 = _mm256_set1_ps(charge[inr+2]);
1493 jq3 = _mm256_set1_ps(charge[inr+3]);
1494 vdwjidx0A = 2*vdwtype[inr+0];
1495 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1496 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1497 qq11 = _mm256_mul_ps(iq1,jq1);
1498 qq12 = _mm256_mul_ps(iq1,jq2);
1499 qq13 = _mm256_mul_ps(iq1,jq3);
1500 qq21 = _mm256_mul_ps(iq2,jq1);
1501 qq22 = _mm256_mul_ps(iq2,jq2);
1502 qq23 = _mm256_mul_ps(iq2,jq3);
1503 qq31 = _mm256_mul_ps(iq3,jq1);
1504 qq32 = _mm256_mul_ps(iq3,jq2);
1505 qq33 = _mm256_mul_ps(iq3,jq3);
1507 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1508 rcutoff_scalar = fr->rcoulomb;
1509 rcutoff = _mm256_set1_ps(rcutoff_scalar);
1510 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
1512 /* Avoid stupid compiler warnings */
1513 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1514 j_coord_offsetA = 0;
1515 j_coord_offsetB = 0;
1516 j_coord_offsetC = 0;
1517 j_coord_offsetD = 0;
1518 j_coord_offsetE = 0;
1519 j_coord_offsetF = 0;
1520 j_coord_offsetG = 0;
1521 j_coord_offsetH = 0;
1526 for(iidx=0;iidx<4*DIM;iidx++)
1528 scratch[iidx] = 0.0;
1531 /* Start outer loop over neighborlists */
1532 for(iidx=0; iidx<nri; iidx++)
1534 /* Load shift vector for this list */
1535 i_shift_offset = DIM*shiftidx[iidx];
1537 /* Load limits for loop over neighbors */
1538 j_index_start = jindex[iidx];
1539 j_index_end = jindex[iidx+1];
1541 /* Get outer coordinate index */
1543 i_coord_offset = DIM*inr;
1545 /* Load i particle coords and add shift vector */
1546 gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1547 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1549 fix0 = _mm256_setzero_ps();
1550 fiy0 = _mm256_setzero_ps();
1551 fiz0 = _mm256_setzero_ps();
1552 fix1 = _mm256_setzero_ps();
1553 fiy1 = _mm256_setzero_ps();
1554 fiz1 = _mm256_setzero_ps();
1555 fix2 = _mm256_setzero_ps();
1556 fiy2 = _mm256_setzero_ps();
1557 fiz2 = _mm256_setzero_ps();
1558 fix3 = _mm256_setzero_ps();
1559 fiy3 = _mm256_setzero_ps();
1560 fiz3 = _mm256_setzero_ps();
1562 /* Start inner kernel loop */
1563 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1566 /* Get j neighbor index, and coordinate index */
1568 jnrB = jjnr[jidx+1];
1569 jnrC = jjnr[jidx+2];
1570 jnrD = jjnr[jidx+3];
1571 jnrE = jjnr[jidx+4];
1572 jnrF = jjnr[jidx+5];
1573 jnrG = jjnr[jidx+6];
1574 jnrH = jjnr[jidx+7];
1575 j_coord_offsetA = DIM*jnrA;
1576 j_coord_offsetB = DIM*jnrB;
1577 j_coord_offsetC = DIM*jnrC;
1578 j_coord_offsetD = DIM*jnrD;
1579 j_coord_offsetE = DIM*jnrE;
1580 j_coord_offsetF = DIM*jnrF;
1581 j_coord_offsetG = DIM*jnrG;
1582 j_coord_offsetH = DIM*jnrH;
1584 /* load j atom coordinates */
1585 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1586 x+j_coord_offsetC,x+j_coord_offsetD,
1587 x+j_coord_offsetE,x+j_coord_offsetF,
1588 x+j_coord_offsetG,x+j_coord_offsetH,
1589 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1590 &jy2,&jz2,&jx3,&jy3,&jz3);
1592 /* Calculate displacement vector */
1593 dx00 = _mm256_sub_ps(ix0,jx0);
1594 dy00 = _mm256_sub_ps(iy0,jy0);
1595 dz00 = _mm256_sub_ps(iz0,jz0);
1596 dx11 = _mm256_sub_ps(ix1,jx1);
1597 dy11 = _mm256_sub_ps(iy1,jy1);
1598 dz11 = _mm256_sub_ps(iz1,jz1);
1599 dx12 = _mm256_sub_ps(ix1,jx2);
1600 dy12 = _mm256_sub_ps(iy1,jy2);
1601 dz12 = _mm256_sub_ps(iz1,jz2);
1602 dx13 = _mm256_sub_ps(ix1,jx3);
1603 dy13 = _mm256_sub_ps(iy1,jy3);
1604 dz13 = _mm256_sub_ps(iz1,jz3);
1605 dx21 = _mm256_sub_ps(ix2,jx1);
1606 dy21 = _mm256_sub_ps(iy2,jy1);
1607 dz21 = _mm256_sub_ps(iz2,jz1);
1608 dx22 = _mm256_sub_ps(ix2,jx2);
1609 dy22 = _mm256_sub_ps(iy2,jy2);
1610 dz22 = _mm256_sub_ps(iz2,jz2);
1611 dx23 = _mm256_sub_ps(ix2,jx3);
1612 dy23 = _mm256_sub_ps(iy2,jy3);
1613 dz23 = _mm256_sub_ps(iz2,jz3);
1614 dx31 = _mm256_sub_ps(ix3,jx1);
1615 dy31 = _mm256_sub_ps(iy3,jy1);
1616 dz31 = _mm256_sub_ps(iz3,jz1);
1617 dx32 = _mm256_sub_ps(ix3,jx2);
1618 dy32 = _mm256_sub_ps(iy3,jy2);
1619 dz32 = _mm256_sub_ps(iz3,jz2);
1620 dx33 = _mm256_sub_ps(ix3,jx3);
1621 dy33 = _mm256_sub_ps(iy3,jy3);
1622 dz33 = _mm256_sub_ps(iz3,jz3);
1624 /* Calculate squared distance and things based on it */
1625 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1626 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1627 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1628 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1629 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1630 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1631 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
1632 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
1633 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
1634 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
1636 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1637 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1638 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1639 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
1640 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1641 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1642 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
1643 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
1644 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
1645 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
1647 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1648 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1649 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
1650 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1651 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1652 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
1653 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
1654 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
1655 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
1657 fjx0 = _mm256_setzero_ps();
1658 fjy0 = _mm256_setzero_ps();
1659 fjz0 = _mm256_setzero_ps();
1660 fjx1 = _mm256_setzero_ps();
1661 fjy1 = _mm256_setzero_ps();
1662 fjz1 = _mm256_setzero_ps();
1663 fjx2 = _mm256_setzero_ps();
1664 fjy2 = _mm256_setzero_ps();
1665 fjz2 = _mm256_setzero_ps();
1666 fjx3 = _mm256_setzero_ps();
1667 fjy3 = _mm256_setzero_ps();
1668 fjz3 = _mm256_setzero_ps();
1670 /**************************
1671 * CALCULATE INTERACTIONS *
1672 **************************/
1674 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1677 r00 = _mm256_mul_ps(rsq00,rinv00);
1679 /* Calculate table index by multiplying r with table scale and truncate to integer */
1680 rt = _mm256_mul_ps(r00,vftabscale);
1681 vfitab = _mm256_cvttps_epi32(rt);
1682 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1683 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1684 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1685 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1686 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1687 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1689 /* CUBIC SPLINE TABLE DISPERSION */
1690 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1691 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1692 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1693 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1694 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1695 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1696 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1697 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1698 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1699 Heps = _mm256_mul_ps(vfeps,H);
1700 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1701 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1702 fvdw6 = _mm256_mul_ps(c6_00,FF);
1704 /* CUBIC SPLINE TABLE REPULSION */
1705 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1706 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1707 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1708 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1709 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1710 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1711 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1712 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1713 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1714 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1715 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1716 Heps = _mm256_mul_ps(vfeps,H);
1717 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1718 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1719 fvdw12 = _mm256_mul_ps(c12_00,FF);
1720 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1722 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1726 fscal = _mm256_and_ps(fscal,cutoff_mask);
1728 /* Calculate temporary vectorial force */
1729 tx = _mm256_mul_ps(fscal,dx00);
1730 ty = _mm256_mul_ps(fscal,dy00);
1731 tz = _mm256_mul_ps(fscal,dz00);
1733 /* Update vectorial force */
1734 fix0 = _mm256_add_ps(fix0,tx);
1735 fiy0 = _mm256_add_ps(fiy0,ty);
1736 fiz0 = _mm256_add_ps(fiz0,tz);
1738 fjx0 = _mm256_add_ps(fjx0,tx);
1739 fjy0 = _mm256_add_ps(fjy0,ty);
1740 fjz0 = _mm256_add_ps(fjz0,tz);
1744 /**************************
1745 * CALCULATE INTERACTIONS *
1746 **************************/
1748 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1751 /* REACTION-FIELD ELECTROSTATICS */
1752 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1754 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1758 fscal = _mm256_and_ps(fscal,cutoff_mask);
1760 /* Calculate temporary vectorial force */
1761 tx = _mm256_mul_ps(fscal,dx11);
1762 ty = _mm256_mul_ps(fscal,dy11);
1763 tz = _mm256_mul_ps(fscal,dz11);
1765 /* Update vectorial force */
1766 fix1 = _mm256_add_ps(fix1,tx);
1767 fiy1 = _mm256_add_ps(fiy1,ty);
1768 fiz1 = _mm256_add_ps(fiz1,tz);
1770 fjx1 = _mm256_add_ps(fjx1,tx);
1771 fjy1 = _mm256_add_ps(fjy1,ty);
1772 fjz1 = _mm256_add_ps(fjz1,tz);
1776 /**************************
1777 * CALCULATE INTERACTIONS *
1778 **************************/
1780 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1783 /* REACTION-FIELD ELECTROSTATICS */
1784 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1786 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1790 fscal = _mm256_and_ps(fscal,cutoff_mask);
1792 /* Calculate temporary vectorial force */
1793 tx = _mm256_mul_ps(fscal,dx12);
1794 ty = _mm256_mul_ps(fscal,dy12);
1795 tz = _mm256_mul_ps(fscal,dz12);
1797 /* Update vectorial force */
1798 fix1 = _mm256_add_ps(fix1,tx);
1799 fiy1 = _mm256_add_ps(fiy1,ty);
1800 fiz1 = _mm256_add_ps(fiz1,tz);
1802 fjx2 = _mm256_add_ps(fjx2,tx);
1803 fjy2 = _mm256_add_ps(fjy2,ty);
1804 fjz2 = _mm256_add_ps(fjz2,tz);
1808 /**************************
1809 * CALCULATE INTERACTIONS *
1810 **************************/
1812 if (gmx_mm256_any_lt(rsq13,rcutoff2))
1815 /* REACTION-FIELD ELECTROSTATICS */
1816 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1818 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1822 fscal = _mm256_and_ps(fscal,cutoff_mask);
1824 /* Calculate temporary vectorial force */
1825 tx = _mm256_mul_ps(fscal,dx13);
1826 ty = _mm256_mul_ps(fscal,dy13);
1827 tz = _mm256_mul_ps(fscal,dz13);
1829 /* Update vectorial force */
1830 fix1 = _mm256_add_ps(fix1,tx);
1831 fiy1 = _mm256_add_ps(fiy1,ty);
1832 fiz1 = _mm256_add_ps(fiz1,tz);
1834 fjx3 = _mm256_add_ps(fjx3,tx);
1835 fjy3 = _mm256_add_ps(fjy3,ty);
1836 fjz3 = _mm256_add_ps(fjz3,tz);
1840 /**************************
1841 * CALCULATE INTERACTIONS *
1842 **************************/
1844 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1847 /* REACTION-FIELD ELECTROSTATICS */
1848 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1850 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1854 fscal = _mm256_and_ps(fscal,cutoff_mask);
1856 /* Calculate temporary vectorial force */
1857 tx = _mm256_mul_ps(fscal,dx21);
1858 ty = _mm256_mul_ps(fscal,dy21);
1859 tz = _mm256_mul_ps(fscal,dz21);
1861 /* Update vectorial force */
1862 fix2 = _mm256_add_ps(fix2,tx);
1863 fiy2 = _mm256_add_ps(fiy2,ty);
1864 fiz2 = _mm256_add_ps(fiz2,tz);
1866 fjx1 = _mm256_add_ps(fjx1,tx);
1867 fjy1 = _mm256_add_ps(fjy1,ty);
1868 fjz1 = _mm256_add_ps(fjz1,tz);
1872 /**************************
1873 * CALCULATE INTERACTIONS *
1874 **************************/
1876 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1879 /* REACTION-FIELD ELECTROSTATICS */
1880 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1882 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1886 fscal = _mm256_and_ps(fscal,cutoff_mask);
1888 /* Calculate temporary vectorial force */
1889 tx = _mm256_mul_ps(fscal,dx22);
1890 ty = _mm256_mul_ps(fscal,dy22);
1891 tz = _mm256_mul_ps(fscal,dz22);
1893 /* Update vectorial force */
1894 fix2 = _mm256_add_ps(fix2,tx);
1895 fiy2 = _mm256_add_ps(fiy2,ty);
1896 fiz2 = _mm256_add_ps(fiz2,tz);
1898 fjx2 = _mm256_add_ps(fjx2,tx);
1899 fjy2 = _mm256_add_ps(fjy2,ty);
1900 fjz2 = _mm256_add_ps(fjz2,tz);
1904 /**************************
1905 * CALCULATE INTERACTIONS *
1906 **************************/
1908 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1911 /* REACTION-FIELD ELECTROSTATICS */
1912 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1914 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1918 fscal = _mm256_and_ps(fscal,cutoff_mask);
1920 /* Calculate temporary vectorial force */
1921 tx = _mm256_mul_ps(fscal,dx23);
1922 ty = _mm256_mul_ps(fscal,dy23);
1923 tz = _mm256_mul_ps(fscal,dz23);
1925 /* Update vectorial force */
1926 fix2 = _mm256_add_ps(fix2,tx);
1927 fiy2 = _mm256_add_ps(fiy2,ty);
1928 fiz2 = _mm256_add_ps(fiz2,tz);
1930 fjx3 = _mm256_add_ps(fjx3,tx);
1931 fjy3 = _mm256_add_ps(fjy3,ty);
1932 fjz3 = _mm256_add_ps(fjz3,tz);
1936 /**************************
1937 * CALCULATE INTERACTIONS *
1938 **************************/
1940 if (gmx_mm256_any_lt(rsq31,rcutoff2))
1943 /* REACTION-FIELD ELECTROSTATICS */
1944 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1946 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1950 fscal = _mm256_and_ps(fscal,cutoff_mask);
1952 /* Calculate temporary vectorial force */
1953 tx = _mm256_mul_ps(fscal,dx31);
1954 ty = _mm256_mul_ps(fscal,dy31);
1955 tz = _mm256_mul_ps(fscal,dz31);
1957 /* Update vectorial force */
1958 fix3 = _mm256_add_ps(fix3,tx);
1959 fiy3 = _mm256_add_ps(fiy3,ty);
1960 fiz3 = _mm256_add_ps(fiz3,tz);
1962 fjx1 = _mm256_add_ps(fjx1,tx);
1963 fjy1 = _mm256_add_ps(fjy1,ty);
1964 fjz1 = _mm256_add_ps(fjz1,tz);
1968 /**************************
1969 * CALCULATE INTERACTIONS *
1970 **************************/
1972 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1975 /* REACTION-FIELD ELECTROSTATICS */
1976 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1978 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1982 fscal = _mm256_and_ps(fscal,cutoff_mask);
1984 /* Calculate temporary vectorial force */
1985 tx = _mm256_mul_ps(fscal,dx32);
1986 ty = _mm256_mul_ps(fscal,dy32);
1987 tz = _mm256_mul_ps(fscal,dz32);
1989 /* Update vectorial force */
1990 fix3 = _mm256_add_ps(fix3,tx);
1991 fiy3 = _mm256_add_ps(fiy3,ty);
1992 fiz3 = _mm256_add_ps(fiz3,tz);
1994 fjx2 = _mm256_add_ps(fjx2,tx);
1995 fjy2 = _mm256_add_ps(fjy2,ty);
1996 fjz2 = _mm256_add_ps(fjz2,tz);
2000 /**************************
2001 * CALCULATE INTERACTIONS *
2002 **************************/
2004 if (gmx_mm256_any_lt(rsq33,rcutoff2))
2007 /* REACTION-FIELD ELECTROSTATICS */
2008 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
2010 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
2014 fscal = _mm256_and_ps(fscal,cutoff_mask);
2016 /* Calculate temporary vectorial force */
2017 tx = _mm256_mul_ps(fscal,dx33);
2018 ty = _mm256_mul_ps(fscal,dy33);
2019 tz = _mm256_mul_ps(fscal,dz33);
2021 /* Update vectorial force */
2022 fix3 = _mm256_add_ps(fix3,tx);
2023 fiy3 = _mm256_add_ps(fiy3,ty);
2024 fiz3 = _mm256_add_ps(fiz3,tz);
2026 fjx3 = _mm256_add_ps(fjx3,tx);
2027 fjy3 = _mm256_add_ps(fjy3,ty);
2028 fjz3 = _mm256_add_ps(fjz3,tz);
2032 fjptrA = f+j_coord_offsetA;
2033 fjptrB = f+j_coord_offsetB;
2034 fjptrC = f+j_coord_offsetC;
2035 fjptrD = f+j_coord_offsetD;
2036 fjptrE = f+j_coord_offsetE;
2037 fjptrF = f+j_coord_offsetF;
2038 fjptrG = f+j_coord_offsetG;
2039 fjptrH = f+j_coord_offsetH;
2041 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2042 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2043 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2045 /* Inner loop uses 324 flops */
2048 if(jidx<j_index_end)
2051 /* Get j neighbor index, and coordinate index */
2052 jnrlistA = jjnr[jidx];
2053 jnrlistB = jjnr[jidx+1];
2054 jnrlistC = jjnr[jidx+2];
2055 jnrlistD = jjnr[jidx+3];
2056 jnrlistE = jjnr[jidx+4];
2057 jnrlistF = jjnr[jidx+5];
2058 jnrlistG = jjnr[jidx+6];
2059 jnrlistH = jjnr[jidx+7];
2060 /* Sign of each element will be negative for non-real atoms.
2061 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
2062 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
2064 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
2065 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
2067 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
2068 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
2069 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
2070 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
2071 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
2072 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
2073 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
2074 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
2075 j_coord_offsetA = DIM*jnrA;
2076 j_coord_offsetB = DIM*jnrB;
2077 j_coord_offsetC = DIM*jnrC;
2078 j_coord_offsetD = DIM*jnrD;
2079 j_coord_offsetE = DIM*jnrE;
2080 j_coord_offsetF = DIM*jnrF;
2081 j_coord_offsetG = DIM*jnrG;
2082 j_coord_offsetH = DIM*jnrH;
2084 /* load j atom coordinates */
2085 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
2086 x+j_coord_offsetC,x+j_coord_offsetD,
2087 x+j_coord_offsetE,x+j_coord_offsetF,
2088 x+j_coord_offsetG,x+j_coord_offsetH,
2089 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
2090 &jy2,&jz2,&jx3,&jy3,&jz3);
2092 /* Calculate displacement vector */
2093 dx00 = _mm256_sub_ps(ix0,jx0);
2094 dy00 = _mm256_sub_ps(iy0,jy0);
2095 dz00 = _mm256_sub_ps(iz0,jz0);
2096 dx11 = _mm256_sub_ps(ix1,jx1);
2097 dy11 = _mm256_sub_ps(iy1,jy1);
2098 dz11 = _mm256_sub_ps(iz1,jz1);
2099 dx12 = _mm256_sub_ps(ix1,jx2);
2100 dy12 = _mm256_sub_ps(iy1,jy2);
2101 dz12 = _mm256_sub_ps(iz1,jz2);
2102 dx13 = _mm256_sub_ps(ix1,jx3);
2103 dy13 = _mm256_sub_ps(iy1,jy3);
2104 dz13 = _mm256_sub_ps(iz1,jz3);
2105 dx21 = _mm256_sub_ps(ix2,jx1);
2106 dy21 = _mm256_sub_ps(iy2,jy1);
2107 dz21 = _mm256_sub_ps(iz2,jz1);
2108 dx22 = _mm256_sub_ps(ix2,jx2);
2109 dy22 = _mm256_sub_ps(iy2,jy2);
2110 dz22 = _mm256_sub_ps(iz2,jz2);
2111 dx23 = _mm256_sub_ps(ix2,jx3);
2112 dy23 = _mm256_sub_ps(iy2,jy3);
2113 dz23 = _mm256_sub_ps(iz2,jz3);
2114 dx31 = _mm256_sub_ps(ix3,jx1);
2115 dy31 = _mm256_sub_ps(iy3,jy1);
2116 dz31 = _mm256_sub_ps(iz3,jz1);
2117 dx32 = _mm256_sub_ps(ix3,jx2);
2118 dy32 = _mm256_sub_ps(iy3,jy2);
2119 dz32 = _mm256_sub_ps(iz3,jz2);
2120 dx33 = _mm256_sub_ps(ix3,jx3);
2121 dy33 = _mm256_sub_ps(iy3,jy3);
2122 dz33 = _mm256_sub_ps(iz3,jz3);
2124 /* Calculate squared distance and things based on it */
2125 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
2126 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
2127 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
2128 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
2129 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
2130 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
2131 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
2132 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
2133 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
2134 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
2136 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
2137 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
2138 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
2139 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
2140 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
2141 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
2142 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
2143 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
2144 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
2145 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
2147 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
2148 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
2149 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
2150 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
2151 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
2152 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
2153 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
2154 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
2155 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
2157 fjx0 = _mm256_setzero_ps();
2158 fjy0 = _mm256_setzero_ps();
2159 fjz0 = _mm256_setzero_ps();
2160 fjx1 = _mm256_setzero_ps();
2161 fjy1 = _mm256_setzero_ps();
2162 fjz1 = _mm256_setzero_ps();
2163 fjx2 = _mm256_setzero_ps();
2164 fjy2 = _mm256_setzero_ps();
2165 fjz2 = _mm256_setzero_ps();
2166 fjx3 = _mm256_setzero_ps();
2167 fjy3 = _mm256_setzero_ps();
2168 fjz3 = _mm256_setzero_ps();
2170 /**************************
2171 * CALCULATE INTERACTIONS *
2172 **************************/
2174 if (gmx_mm256_any_lt(rsq00,rcutoff2))
2177 r00 = _mm256_mul_ps(rsq00,rinv00);
2178 r00 = _mm256_andnot_ps(dummy_mask,r00);
2180 /* Calculate table index by multiplying r with table scale and truncate to integer */
2181 rt = _mm256_mul_ps(r00,vftabscale);
2182 vfitab = _mm256_cvttps_epi32(rt);
2183 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
2184 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
2185 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
2186 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
2187 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
2188 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
2190 /* CUBIC SPLINE TABLE DISPERSION */
2191 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
2192 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
2193 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
2194 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
2195 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
2196 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
2197 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
2198 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
2199 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
2200 Heps = _mm256_mul_ps(vfeps,H);
2201 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
2202 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
2203 fvdw6 = _mm256_mul_ps(c6_00,FF);
2205 /* CUBIC SPLINE TABLE REPULSION */
2206 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
2207 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
2208 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
2209 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
2210 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
2211 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
2212 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
2213 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
2214 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
2215 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
2216 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
2217 Heps = _mm256_mul_ps(vfeps,H);
2218 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
2219 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
2220 fvdw12 = _mm256_mul_ps(c12_00,FF);
2221 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
2223 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
2227 fscal = _mm256_and_ps(fscal,cutoff_mask);
2229 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2231 /* Calculate temporary vectorial force */
2232 tx = _mm256_mul_ps(fscal,dx00);
2233 ty = _mm256_mul_ps(fscal,dy00);
2234 tz = _mm256_mul_ps(fscal,dz00);
2236 /* Update vectorial force */
2237 fix0 = _mm256_add_ps(fix0,tx);
2238 fiy0 = _mm256_add_ps(fiy0,ty);
2239 fiz0 = _mm256_add_ps(fiz0,tz);
2241 fjx0 = _mm256_add_ps(fjx0,tx);
2242 fjy0 = _mm256_add_ps(fjy0,ty);
2243 fjz0 = _mm256_add_ps(fjz0,tz);
2247 /**************************
2248 * CALCULATE INTERACTIONS *
2249 **************************/
2251 if (gmx_mm256_any_lt(rsq11,rcutoff2))
2254 /* REACTION-FIELD ELECTROSTATICS */
2255 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
2257 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
2261 fscal = _mm256_and_ps(fscal,cutoff_mask);
2263 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2265 /* Calculate temporary vectorial force */
2266 tx = _mm256_mul_ps(fscal,dx11);
2267 ty = _mm256_mul_ps(fscal,dy11);
2268 tz = _mm256_mul_ps(fscal,dz11);
2270 /* Update vectorial force */
2271 fix1 = _mm256_add_ps(fix1,tx);
2272 fiy1 = _mm256_add_ps(fiy1,ty);
2273 fiz1 = _mm256_add_ps(fiz1,tz);
2275 fjx1 = _mm256_add_ps(fjx1,tx);
2276 fjy1 = _mm256_add_ps(fjy1,ty);
2277 fjz1 = _mm256_add_ps(fjz1,tz);
2281 /**************************
2282 * CALCULATE INTERACTIONS *
2283 **************************/
2285 if (gmx_mm256_any_lt(rsq12,rcutoff2))
2288 /* REACTION-FIELD ELECTROSTATICS */
2289 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
2291 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
2295 fscal = _mm256_and_ps(fscal,cutoff_mask);
2297 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2299 /* Calculate temporary vectorial force */
2300 tx = _mm256_mul_ps(fscal,dx12);
2301 ty = _mm256_mul_ps(fscal,dy12);
2302 tz = _mm256_mul_ps(fscal,dz12);
2304 /* Update vectorial force */
2305 fix1 = _mm256_add_ps(fix1,tx);
2306 fiy1 = _mm256_add_ps(fiy1,ty);
2307 fiz1 = _mm256_add_ps(fiz1,tz);
2309 fjx2 = _mm256_add_ps(fjx2,tx);
2310 fjy2 = _mm256_add_ps(fjy2,ty);
2311 fjz2 = _mm256_add_ps(fjz2,tz);
2315 /**************************
2316 * CALCULATE INTERACTIONS *
2317 **************************/
2319 if (gmx_mm256_any_lt(rsq13,rcutoff2))
2322 /* REACTION-FIELD ELECTROSTATICS */
2323 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
2325 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
2329 fscal = _mm256_and_ps(fscal,cutoff_mask);
2331 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2333 /* Calculate temporary vectorial force */
2334 tx = _mm256_mul_ps(fscal,dx13);
2335 ty = _mm256_mul_ps(fscal,dy13);
2336 tz = _mm256_mul_ps(fscal,dz13);
2338 /* Update vectorial force */
2339 fix1 = _mm256_add_ps(fix1,tx);
2340 fiy1 = _mm256_add_ps(fiy1,ty);
2341 fiz1 = _mm256_add_ps(fiz1,tz);
2343 fjx3 = _mm256_add_ps(fjx3,tx);
2344 fjy3 = _mm256_add_ps(fjy3,ty);
2345 fjz3 = _mm256_add_ps(fjz3,tz);
2349 /**************************
2350 * CALCULATE INTERACTIONS *
2351 **************************/
2353 if (gmx_mm256_any_lt(rsq21,rcutoff2))
2356 /* REACTION-FIELD ELECTROSTATICS */
2357 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
2359 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
2363 fscal = _mm256_and_ps(fscal,cutoff_mask);
2365 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2367 /* Calculate temporary vectorial force */
2368 tx = _mm256_mul_ps(fscal,dx21);
2369 ty = _mm256_mul_ps(fscal,dy21);
2370 tz = _mm256_mul_ps(fscal,dz21);
2372 /* Update vectorial force */
2373 fix2 = _mm256_add_ps(fix2,tx);
2374 fiy2 = _mm256_add_ps(fiy2,ty);
2375 fiz2 = _mm256_add_ps(fiz2,tz);
2377 fjx1 = _mm256_add_ps(fjx1,tx);
2378 fjy1 = _mm256_add_ps(fjy1,ty);
2379 fjz1 = _mm256_add_ps(fjz1,tz);
2383 /**************************
2384 * CALCULATE INTERACTIONS *
2385 **************************/
2387 if (gmx_mm256_any_lt(rsq22,rcutoff2))
2390 /* REACTION-FIELD ELECTROSTATICS */
2391 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2393 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
2397 fscal = _mm256_and_ps(fscal,cutoff_mask);
2399 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2401 /* Calculate temporary vectorial force */
2402 tx = _mm256_mul_ps(fscal,dx22);
2403 ty = _mm256_mul_ps(fscal,dy22);
2404 tz = _mm256_mul_ps(fscal,dz22);
2406 /* Update vectorial force */
2407 fix2 = _mm256_add_ps(fix2,tx);
2408 fiy2 = _mm256_add_ps(fiy2,ty);
2409 fiz2 = _mm256_add_ps(fiz2,tz);
2411 fjx2 = _mm256_add_ps(fjx2,tx);
2412 fjy2 = _mm256_add_ps(fjy2,ty);
2413 fjz2 = _mm256_add_ps(fjz2,tz);
2417 /**************************
2418 * CALCULATE INTERACTIONS *
2419 **************************/
2421 if (gmx_mm256_any_lt(rsq23,rcutoff2))
2424 /* REACTION-FIELD ELECTROSTATICS */
2425 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
2427 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
2431 fscal = _mm256_and_ps(fscal,cutoff_mask);
2433 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2435 /* Calculate temporary vectorial force */
2436 tx = _mm256_mul_ps(fscal,dx23);
2437 ty = _mm256_mul_ps(fscal,dy23);
2438 tz = _mm256_mul_ps(fscal,dz23);
2440 /* Update vectorial force */
2441 fix2 = _mm256_add_ps(fix2,tx);
2442 fiy2 = _mm256_add_ps(fiy2,ty);
2443 fiz2 = _mm256_add_ps(fiz2,tz);
2445 fjx3 = _mm256_add_ps(fjx3,tx);
2446 fjy3 = _mm256_add_ps(fjy3,ty);
2447 fjz3 = _mm256_add_ps(fjz3,tz);
2451 /**************************
2452 * CALCULATE INTERACTIONS *
2453 **************************/
2455 if (gmx_mm256_any_lt(rsq31,rcutoff2))
2458 /* REACTION-FIELD ELECTROSTATICS */
2459 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
2461 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
2465 fscal = _mm256_and_ps(fscal,cutoff_mask);
2467 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2469 /* Calculate temporary vectorial force */
2470 tx = _mm256_mul_ps(fscal,dx31);
2471 ty = _mm256_mul_ps(fscal,dy31);
2472 tz = _mm256_mul_ps(fscal,dz31);
2474 /* Update vectorial force */
2475 fix3 = _mm256_add_ps(fix3,tx);
2476 fiy3 = _mm256_add_ps(fiy3,ty);
2477 fiz3 = _mm256_add_ps(fiz3,tz);
2479 fjx1 = _mm256_add_ps(fjx1,tx);
2480 fjy1 = _mm256_add_ps(fjy1,ty);
2481 fjz1 = _mm256_add_ps(fjz1,tz);
2485 /**************************
2486 * CALCULATE INTERACTIONS *
2487 **************************/
2489 if (gmx_mm256_any_lt(rsq32,rcutoff2))
2492 /* REACTION-FIELD ELECTROSTATICS */
2493 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
2495 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
2499 fscal = _mm256_and_ps(fscal,cutoff_mask);
2501 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2503 /* Calculate temporary vectorial force */
2504 tx = _mm256_mul_ps(fscal,dx32);
2505 ty = _mm256_mul_ps(fscal,dy32);
2506 tz = _mm256_mul_ps(fscal,dz32);
2508 /* Update vectorial force */
2509 fix3 = _mm256_add_ps(fix3,tx);
2510 fiy3 = _mm256_add_ps(fiy3,ty);
2511 fiz3 = _mm256_add_ps(fiz3,tz);
2513 fjx2 = _mm256_add_ps(fjx2,tx);
2514 fjy2 = _mm256_add_ps(fjy2,ty);
2515 fjz2 = _mm256_add_ps(fjz2,tz);
2519 /**************************
2520 * CALCULATE INTERACTIONS *
2521 **************************/
2523 if (gmx_mm256_any_lt(rsq33,rcutoff2))
2526 /* REACTION-FIELD ELECTROSTATICS */
2527 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
2529 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
2533 fscal = _mm256_and_ps(fscal,cutoff_mask);
2535 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2537 /* Calculate temporary vectorial force */
2538 tx = _mm256_mul_ps(fscal,dx33);
2539 ty = _mm256_mul_ps(fscal,dy33);
2540 tz = _mm256_mul_ps(fscal,dz33);
2542 /* Update vectorial force */
2543 fix3 = _mm256_add_ps(fix3,tx);
2544 fiy3 = _mm256_add_ps(fiy3,ty);
2545 fiz3 = _mm256_add_ps(fiz3,tz);
2547 fjx3 = _mm256_add_ps(fjx3,tx);
2548 fjy3 = _mm256_add_ps(fjy3,ty);
2549 fjz3 = _mm256_add_ps(fjz3,tz);
2553 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2554 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2555 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2556 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2557 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2558 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2559 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2560 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2562 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2563 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2564 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2566 /* Inner loop uses 325 flops */
2569 /* End of innermost loop */
2571 gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2572 f+i_coord_offset,fshift+i_shift_offset);
2574 /* Increment number of inner iterations */
2575 inneriter += j_index_end - j_index_start;
2577 /* Outer loop uses 24 flops */
2580 /* Increment number of outer iterations */
2583 /* Update outer/inner flops */
2585 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*325);