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_256_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_256_single.h"
50 #include "kernelutil_x86_avx_256_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3W3_VF_avx_256_single
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: CubicSplineTable
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRF_VdwCSTab_GeomW3W3_VF_avx_256_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,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight 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 jnrE,jnrF,jnrG,jnrH;
78 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
79 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
80 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
81 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
82 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
84 real *shiftvec,*fshift,*x,*f;
85 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
87 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
88 real * vdwioffsetptr0;
89 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
90 real * vdwioffsetptr1;
91 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
92 real * vdwioffsetptr2;
93 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
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 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
101 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
102 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
103 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
104 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
105 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
106 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
107 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
108 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
109 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
112 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
115 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
116 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
118 __m128i vfitab_lo,vfitab_hi;
119 __m128i ifour = _mm_set1_epi32(4);
120 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
122 __m256 dummy_mask,cutoff_mask;
123 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
124 __m256 one = _mm256_set1_ps(1.0);
125 __m256 two = _mm256_set1_ps(2.0);
131 jindex = nlist->jindex;
133 shiftidx = nlist->shift;
135 shiftvec = fr->shift_vec[0];
136 fshift = fr->fshift[0];
137 facel = _mm256_set1_ps(fr->epsfac);
138 charge = mdatoms->chargeA;
139 krf = _mm256_set1_ps(fr->ic->k_rf);
140 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
141 crf = _mm256_set1_ps(fr->ic->c_rf);
142 nvdwtype = fr->ntype;
144 vdwtype = mdatoms->typeA;
146 vftab = kernel_data->table_vdw->data;
147 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
149 /* Setup water-specific parameters */
150 inr = nlist->iinr[0];
151 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
152 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
153 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
154 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
156 jq0 = _mm256_set1_ps(charge[inr+0]);
157 jq1 = _mm256_set1_ps(charge[inr+1]);
158 jq2 = _mm256_set1_ps(charge[inr+2]);
159 vdwjidx0A = 2*vdwtype[inr+0];
160 qq00 = _mm256_mul_ps(iq0,jq0);
161 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
162 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
163 qq01 = _mm256_mul_ps(iq0,jq1);
164 qq02 = _mm256_mul_ps(iq0,jq2);
165 qq10 = _mm256_mul_ps(iq1,jq0);
166 qq11 = _mm256_mul_ps(iq1,jq1);
167 qq12 = _mm256_mul_ps(iq1,jq2);
168 qq20 = _mm256_mul_ps(iq2,jq0);
169 qq21 = _mm256_mul_ps(iq2,jq1);
170 qq22 = _mm256_mul_ps(iq2,jq2);
172 /* Avoid stupid compiler warnings */
173 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
186 for(iidx=0;iidx<4*DIM;iidx++)
191 /* Start outer loop over neighborlists */
192 for(iidx=0; iidx<nri; iidx++)
194 /* Load shift vector for this list */
195 i_shift_offset = DIM*shiftidx[iidx];
197 /* Load limits for loop over neighbors */
198 j_index_start = jindex[iidx];
199 j_index_end = jindex[iidx+1];
201 /* Get outer coordinate index */
203 i_coord_offset = DIM*inr;
205 /* Load i particle coords and add shift vector */
206 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
207 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
209 fix0 = _mm256_setzero_ps();
210 fiy0 = _mm256_setzero_ps();
211 fiz0 = _mm256_setzero_ps();
212 fix1 = _mm256_setzero_ps();
213 fiy1 = _mm256_setzero_ps();
214 fiz1 = _mm256_setzero_ps();
215 fix2 = _mm256_setzero_ps();
216 fiy2 = _mm256_setzero_ps();
217 fiz2 = _mm256_setzero_ps();
219 /* Reset potential sums */
220 velecsum = _mm256_setzero_ps();
221 vvdwsum = _mm256_setzero_ps();
223 /* Start inner kernel loop */
224 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
227 /* Get j neighbor index, and coordinate index */
236 j_coord_offsetA = DIM*jnrA;
237 j_coord_offsetB = DIM*jnrB;
238 j_coord_offsetC = DIM*jnrC;
239 j_coord_offsetD = DIM*jnrD;
240 j_coord_offsetE = DIM*jnrE;
241 j_coord_offsetF = DIM*jnrF;
242 j_coord_offsetG = DIM*jnrG;
243 j_coord_offsetH = DIM*jnrH;
245 /* load j atom coordinates */
246 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
247 x+j_coord_offsetC,x+j_coord_offsetD,
248 x+j_coord_offsetE,x+j_coord_offsetF,
249 x+j_coord_offsetG,x+j_coord_offsetH,
250 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
252 /* Calculate displacement vector */
253 dx00 = _mm256_sub_ps(ix0,jx0);
254 dy00 = _mm256_sub_ps(iy0,jy0);
255 dz00 = _mm256_sub_ps(iz0,jz0);
256 dx01 = _mm256_sub_ps(ix0,jx1);
257 dy01 = _mm256_sub_ps(iy0,jy1);
258 dz01 = _mm256_sub_ps(iz0,jz1);
259 dx02 = _mm256_sub_ps(ix0,jx2);
260 dy02 = _mm256_sub_ps(iy0,jy2);
261 dz02 = _mm256_sub_ps(iz0,jz2);
262 dx10 = _mm256_sub_ps(ix1,jx0);
263 dy10 = _mm256_sub_ps(iy1,jy0);
264 dz10 = _mm256_sub_ps(iz1,jz0);
265 dx11 = _mm256_sub_ps(ix1,jx1);
266 dy11 = _mm256_sub_ps(iy1,jy1);
267 dz11 = _mm256_sub_ps(iz1,jz1);
268 dx12 = _mm256_sub_ps(ix1,jx2);
269 dy12 = _mm256_sub_ps(iy1,jy2);
270 dz12 = _mm256_sub_ps(iz1,jz2);
271 dx20 = _mm256_sub_ps(ix2,jx0);
272 dy20 = _mm256_sub_ps(iy2,jy0);
273 dz20 = _mm256_sub_ps(iz2,jz0);
274 dx21 = _mm256_sub_ps(ix2,jx1);
275 dy21 = _mm256_sub_ps(iy2,jy1);
276 dz21 = _mm256_sub_ps(iz2,jz1);
277 dx22 = _mm256_sub_ps(ix2,jx2);
278 dy22 = _mm256_sub_ps(iy2,jy2);
279 dz22 = _mm256_sub_ps(iz2,jz2);
281 /* Calculate squared distance and things based on it */
282 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
283 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
284 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
285 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
286 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
287 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
288 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
289 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
290 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
292 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
293 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
294 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
295 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
296 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
297 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
298 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
299 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
300 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
302 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
303 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
304 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
305 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
306 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
307 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
308 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
309 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
310 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
312 fjx0 = _mm256_setzero_ps();
313 fjy0 = _mm256_setzero_ps();
314 fjz0 = _mm256_setzero_ps();
315 fjx1 = _mm256_setzero_ps();
316 fjy1 = _mm256_setzero_ps();
317 fjz1 = _mm256_setzero_ps();
318 fjx2 = _mm256_setzero_ps();
319 fjy2 = _mm256_setzero_ps();
320 fjz2 = _mm256_setzero_ps();
322 /**************************
323 * CALCULATE INTERACTIONS *
324 **************************/
326 r00 = _mm256_mul_ps(rsq00,rinv00);
328 /* Calculate table index by multiplying r with table scale and truncate to integer */
329 rt = _mm256_mul_ps(r00,vftabscale);
330 vfitab = _mm256_cvttps_epi32(rt);
331 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
332 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
333 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
334 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
335 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
336 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
340 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
342 /* CUBIC SPLINE TABLE DISPERSION */
343 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
344 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
345 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
346 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
347 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
348 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
349 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
350 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
351 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
352 Heps = _mm256_mul_ps(vfeps,H);
353 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
354 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
355 vvdw6 = _mm256_mul_ps(c6_00,VV);
356 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
357 fvdw6 = _mm256_mul_ps(c6_00,FF);
359 /* CUBIC SPLINE TABLE REPULSION */
360 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
361 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
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 vvdw12 = _mm256_mul_ps(c12_00,VV);
375 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
376 fvdw12 = _mm256_mul_ps(c12_00,FF);
377 vvdw = _mm256_add_ps(vvdw12,vvdw6);
378 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
380 /* Update potential sum for this i atom from the interaction with this j atom. */
381 velecsum = _mm256_add_ps(velecsum,velec);
382 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
384 fscal = _mm256_add_ps(felec,fvdw);
386 /* Calculate temporary vectorial force */
387 tx = _mm256_mul_ps(fscal,dx00);
388 ty = _mm256_mul_ps(fscal,dy00);
389 tz = _mm256_mul_ps(fscal,dz00);
391 /* Update vectorial force */
392 fix0 = _mm256_add_ps(fix0,tx);
393 fiy0 = _mm256_add_ps(fiy0,ty);
394 fiz0 = _mm256_add_ps(fiz0,tz);
396 fjx0 = _mm256_add_ps(fjx0,tx);
397 fjy0 = _mm256_add_ps(fjy0,ty);
398 fjz0 = _mm256_add_ps(fjz0,tz);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 /* REACTION-FIELD ELECTROSTATICS */
405 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
406 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
408 /* Update potential sum for this i atom from the interaction with this j atom. */
409 velecsum = _mm256_add_ps(velecsum,velec);
413 /* Calculate temporary vectorial force */
414 tx = _mm256_mul_ps(fscal,dx01);
415 ty = _mm256_mul_ps(fscal,dy01);
416 tz = _mm256_mul_ps(fscal,dz01);
418 /* Update vectorial force */
419 fix0 = _mm256_add_ps(fix0,tx);
420 fiy0 = _mm256_add_ps(fiy0,ty);
421 fiz0 = _mm256_add_ps(fiz0,tz);
423 fjx1 = _mm256_add_ps(fjx1,tx);
424 fjy1 = _mm256_add_ps(fjy1,ty);
425 fjz1 = _mm256_add_ps(fjz1,tz);
427 /**************************
428 * CALCULATE INTERACTIONS *
429 **************************/
431 /* REACTION-FIELD ELECTROSTATICS */
432 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
433 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
435 /* Update potential sum for this i atom from the interaction with this j atom. */
436 velecsum = _mm256_add_ps(velecsum,velec);
440 /* Calculate temporary vectorial force */
441 tx = _mm256_mul_ps(fscal,dx02);
442 ty = _mm256_mul_ps(fscal,dy02);
443 tz = _mm256_mul_ps(fscal,dz02);
445 /* Update vectorial force */
446 fix0 = _mm256_add_ps(fix0,tx);
447 fiy0 = _mm256_add_ps(fiy0,ty);
448 fiz0 = _mm256_add_ps(fiz0,tz);
450 fjx2 = _mm256_add_ps(fjx2,tx);
451 fjy2 = _mm256_add_ps(fjy2,ty);
452 fjz2 = _mm256_add_ps(fjz2,tz);
454 /**************************
455 * CALCULATE INTERACTIONS *
456 **************************/
458 /* REACTION-FIELD ELECTROSTATICS */
459 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
460 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
462 /* Update potential sum for this i atom from the interaction with this j atom. */
463 velecsum = _mm256_add_ps(velecsum,velec);
467 /* Calculate temporary vectorial force */
468 tx = _mm256_mul_ps(fscal,dx10);
469 ty = _mm256_mul_ps(fscal,dy10);
470 tz = _mm256_mul_ps(fscal,dz10);
472 /* Update vectorial force */
473 fix1 = _mm256_add_ps(fix1,tx);
474 fiy1 = _mm256_add_ps(fiy1,ty);
475 fiz1 = _mm256_add_ps(fiz1,tz);
477 fjx0 = _mm256_add_ps(fjx0,tx);
478 fjy0 = _mm256_add_ps(fjy0,ty);
479 fjz0 = _mm256_add_ps(fjz0,tz);
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
485 /* REACTION-FIELD ELECTROSTATICS */
486 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
487 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
489 /* Update potential sum for this i atom from the interaction with this j atom. */
490 velecsum = _mm256_add_ps(velecsum,velec);
494 /* Calculate temporary vectorial force */
495 tx = _mm256_mul_ps(fscal,dx11);
496 ty = _mm256_mul_ps(fscal,dy11);
497 tz = _mm256_mul_ps(fscal,dz11);
499 /* Update vectorial force */
500 fix1 = _mm256_add_ps(fix1,tx);
501 fiy1 = _mm256_add_ps(fiy1,ty);
502 fiz1 = _mm256_add_ps(fiz1,tz);
504 fjx1 = _mm256_add_ps(fjx1,tx);
505 fjy1 = _mm256_add_ps(fjy1,ty);
506 fjz1 = _mm256_add_ps(fjz1,tz);
508 /**************************
509 * CALCULATE INTERACTIONS *
510 **************************/
512 /* REACTION-FIELD ELECTROSTATICS */
513 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
514 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
516 /* Update potential sum for this i atom from the interaction with this j atom. */
517 velecsum = _mm256_add_ps(velecsum,velec);
521 /* Calculate temporary vectorial force */
522 tx = _mm256_mul_ps(fscal,dx12);
523 ty = _mm256_mul_ps(fscal,dy12);
524 tz = _mm256_mul_ps(fscal,dz12);
526 /* Update vectorial force */
527 fix1 = _mm256_add_ps(fix1,tx);
528 fiy1 = _mm256_add_ps(fiy1,ty);
529 fiz1 = _mm256_add_ps(fiz1,tz);
531 fjx2 = _mm256_add_ps(fjx2,tx);
532 fjy2 = _mm256_add_ps(fjy2,ty);
533 fjz2 = _mm256_add_ps(fjz2,tz);
535 /**************************
536 * CALCULATE INTERACTIONS *
537 **************************/
539 /* REACTION-FIELD ELECTROSTATICS */
540 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
541 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
543 /* Update potential sum for this i atom from the interaction with this j atom. */
544 velecsum = _mm256_add_ps(velecsum,velec);
548 /* Calculate temporary vectorial force */
549 tx = _mm256_mul_ps(fscal,dx20);
550 ty = _mm256_mul_ps(fscal,dy20);
551 tz = _mm256_mul_ps(fscal,dz20);
553 /* Update vectorial force */
554 fix2 = _mm256_add_ps(fix2,tx);
555 fiy2 = _mm256_add_ps(fiy2,ty);
556 fiz2 = _mm256_add_ps(fiz2,tz);
558 fjx0 = _mm256_add_ps(fjx0,tx);
559 fjy0 = _mm256_add_ps(fjy0,ty);
560 fjz0 = _mm256_add_ps(fjz0,tz);
562 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
566 /* REACTION-FIELD ELECTROSTATICS */
567 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
568 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
570 /* Update potential sum for this i atom from the interaction with this j atom. */
571 velecsum = _mm256_add_ps(velecsum,velec);
575 /* Calculate temporary vectorial force */
576 tx = _mm256_mul_ps(fscal,dx21);
577 ty = _mm256_mul_ps(fscal,dy21);
578 tz = _mm256_mul_ps(fscal,dz21);
580 /* Update vectorial force */
581 fix2 = _mm256_add_ps(fix2,tx);
582 fiy2 = _mm256_add_ps(fiy2,ty);
583 fiz2 = _mm256_add_ps(fiz2,tz);
585 fjx1 = _mm256_add_ps(fjx1,tx);
586 fjy1 = _mm256_add_ps(fjy1,ty);
587 fjz1 = _mm256_add_ps(fjz1,tz);
589 /**************************
590 * CALCULATE INTERACTIONS *
591 **************************/
593 /* REACTION-FIELD ELECTROSTATICS */
594 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
595 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
597 /* Update potential sum for this i atom from the interaction with this j atom. */
598 velecsum = _mm256_add_ps(velecsum,velec);
602 /* Calculate temporary vectorial force */
603 tx = _mm256_mul_ps(fscal,dx22);
604 ty = _mm256_mul_ps(fscal,dy22);
605 tz = _mm256_mul_ps(fscal,dz22);
607 /* Update vectorial force */
608 fix2 = _mm256_add_ps(fix2,tx);
609 fiy2 = _mm256_add_ps(fiy2,ty);
610 fiz2 = _mm256_add_ps(fiz2,tz);
612 fjx2 = _mm256_add_ps(fjx2,tx);
613 fjy2 = _mm256_add_ps(fjy2,ty);
614 fjz2 = _mm256_add_ps(fjz2,tz);
616 fjptrA = f+j_coord_offsetA;
617 fjptrB = f+j_coord_offsetB;
618 fjptrC = f+j_coord_offsetC;
619 fjptrD = f+j_coord_offsetD;
620 fjptrE = f+j_coord_offsetE;
621 fjptrF = f+j_coord_offsetF;
622 fjptrG = f+j_coord_offsetG;
623 fjptrH = f+j_coord_offsetH;
625 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
626 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
628 /* Inner loop uses 323 flops */
634 /* Get j neighbor index, and coordinate index */
635 jnrlistA = jjnr[jidx];
636 jnrlistB = jjnr[jidx+1];
637 jnrlistC = jjnr[jidx+2];
638 jnrlistD = jjnr[jidx+3];
639 jnrlistE = jjnr[jidx+4];
640 jnrlistF = jjnr[jidx+5];
641 jnrlistG = jjnr[jidx+6];
642 jnrlistH = jjnr[jidx+7];
643 /* Sign of each element will be negative for non-real atoms.
644 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
645 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
647 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
648 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
650 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
651 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
652 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
653 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
654 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
655 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
656 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
657 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
658 j_coord_offsetA = DIM*jnrA;
659 j_coord_offsetB = DIM*jnrB;
660 j_coord_offsetC = DIM*jnrC;
661 j_coord_offsetD = DIM*jnrD;
662 j_coord_offsetE = DIM*jnrE;
663 j_coord_offsetF = DIM*jnrF;
664 j_coord_offsetG = DIM*jnrG;
665 j_coord_offsetH = DIM*jnrH;
667 /* load j atom coordinates */
668 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
669 x+j_coord_offsetC,x+j_coord_offsetD,
670 x+j_coord_offsetE,x+j_coord_offsetF,
671 x+j_coord_offsetG,x+j_coord_offsetH,
672 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
674 /* Calculate displacement vector */
675 dx00 = _mm256_sub_ps(ix0,jx0);
676 dy00 = _mm256_sub_ps(iy0,jy0);
677 dz00 = _mm256_sub_ps(iz0,jz0);
678 dx01 = _mm256_sub_ps(ix0,jx1);
679 dy01 = _mm256_sub_ps(iy0,jy1);
680 dz01 = _mm256_sub_ps(iz0,jz1);
681 dx02 = _mm256_sub_ps(ix0,jx2);
682 dy02 = _mm256_sub_ps(iy0,jy2);
683 dz02 = _mm256_sub_ps(iz0,jz2);
684 dx10 = _mm256_sub_ps(ix1,jx0);
685 dy10 = _mm256_sub_ps(iy1,jy0);
686 dz10 = _mm256_sub_ps(iz1,jz0);
687 dx11 = _mm256_sub_ps(ix1,jx1);
688 dy11 = _mm256_sub_ps(iy1,jy1);
689 dz11 = _mm256_sub_ps(iz1,jz1);
690 dx12 = _mm256_sub_ps(ix1,jx2);
691 dy12 = _mm256_sub_ps(iy1,jy2);
692 dz12 = _mm256_sub_ps(iz1,jz2);
693 dx20 = _mm256_sub_ps(ix2,jx0);
694 dy20 = _mm256_sub_ps(iy2,jy0);
695 dz20 = _mm256_sub_ps(iz2,jz0);
696 dx21 = _mm256_sub_ps(ix2,jx1);
697 dy21 = _mm256_sub_ps(iy2,jy1);
698 dz21 = _mm256_sub_ps(iz2,jz1);
699 dx22 = _mm256_sub_ps(ix2,jx2);
700 dy22 = _mm256_sub_ps(iy2,jy2);
701 dz22 = _mm256_sub_ps(iz2,jz2);
703 /* Calculate squared distance and things based on it */
704 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
705 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
706 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
707 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
708 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
709 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
710 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
711 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
712 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
714 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
715 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
716 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
717 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
718 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
719 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
720 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
721 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
722 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
724 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
725 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
726 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
727 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
728 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
729 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
730 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
731 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
732 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
734 fjx0 = _mm256_setzero_ps();
735 fjy0 = _mm256_setzero_ps();
736 fjz0 = _mm256_setzero_ps();
737 fjx1 = _mm256_setzero_ps();
738 fjy1 = _mm256_setzero_ps();
739 fjz1 = _mm256_setzero_ps();
740 fjx2 = _mm256_setzero_ps();
741 fjy2 = _mm256_setzero_ps();
742 fjz2 = _mm256_setzero_ps();
744 /**************************
745 * CALCULATE INTERACTIONS *
746 **************************/
748 r00 = _mm256_mul_ps(rsq00,rinv00);
749 r00 = _mm256_andnot_ps(dummy_mask,r00);
751 /* Calculate table index by multiplying r with table scale and truncate to integer */
752 rt = _mm256_mul_ps(r00,vftabscale);
753 vfitab = _mm256_cvttps_epi32(rt);
754 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
755 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
756 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
757 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
758 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
759 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
761 /* REACTION-FIELD ELECTROSTATICS */
762 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
763 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
765 /* CUBIC SPLINE TABLE DISPERSION */
766 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
767 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
768 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
769 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
770 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
771 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
772 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
773 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
774 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
775 Heps = _mm256_mul_ps(vfeps,H);
776 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
777 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
778 vvdw6 = _mm256_mul_ps(c6_00,VV);
779 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
780 fvdw6 = _mm256_mul_ps(c6_00,FF);
782 /* CUBIC SPLINE TABLE REPULSION */
783 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
784 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
785 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
786 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
787 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
788 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
789 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
790 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
791 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
792 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
793 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
794 Heps = _mm256_mul_ps(vfeps,H);
795 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
796 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
797 vvdw12 = _mm256_mul_ps(c12_00,VV);
798 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
799 fvdw12 = _mm256_mul_ps(c12_00,FF);
800 vvdw = _mm256_add_ps(vvdw12,vvdw6);
801 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
803 /* Update potential sum for this i atom from the interaction with this j atom. */
804 velec = _mm256_andnot_ps(dummy_mask,velec);
805 velecsum = _mm256_add_ps(velecsum,velec);
806 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
807 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
809 fscal = _mm256_add_ps(felec,fvdw);
811 fscal = _mm256_andnot_ps(dummy_mask,fscal);
813 /* Calculate temporary vectorial force */
814 tx = _mm256_mul_ps(fscal,dx00);
815 ty = _mm256_mul_ps(fscal,dy00);
816 tz = _mm256_mul_ps(fscal,dz00);
818 /* Update vectorial force */
819 fix0 = _mm256_add_ps(fix0,tx);
820 fiy0 = _mm256_add_ps(fiy0,ty);
821 fiz0 = _mm256_add_ps(fiz0,tz);
823 fjx0 = _mm256_add_ps(fjx0,tx);
824 fjy0 = _mm256_add_ps(fjy0,ty);
825 fjz0 = _mm256_add_ps(fjz0,tz);
827 /**************************
828 * CALCULATE INTERACTIONS *
829 **************************/
831 /* REACTION-FIELD ELECTROSTATICS */
832 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
833 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
835 /* Update potential sum for this i atom from the interaction with this j atom. */
836 velec = _mm256_andnot_ps(dummy_mask,velec);
837 velecsum = _mm256_add_ps(velecsum,velec);
841 fscal = _mm256_andnot_ps(dummy_mask,fscal);
843 /* Calculate temporary vectorial force */
844 tx = _mm256_mul_ps(fscal,dx01);
845 ty = _mm256_mul_ps(fscal,dy01);
846 tz = _mm256_mul_ps(fscal,dz01);
848 /* Update vectorial force */
849 fix0 = _mm256_add_ps(fix0,tx);
850 fiy0 = _mm256_add_ps(fiy0,ty);
851 fiz0 = _mm256_add_ps(fiz0,tz);
853 fjx1 = _mm256_add_ps(fjx1,tx);
854 fjy1 = _mm256_add_ps(fjy1,ty);
855 fjz1 = _mm256_add_ps(fjz1,tz);
857 /**************************
858 * CALCULATE INTERACTIONS *
859 **************************/
861 /* REACTION-FIELD ELECTROSTATICS */
862 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
863 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
865 /* Update potential sum for this i atom from the interaction with this j atom. */
866 velec = _mm256_andnot_ps(dummy_mask,velec);
867 velecsum = _mm256_add_ps(velecsum,velec);
871 fscal = _mm256_andnot_ps(dummy_mask,fscal);
873 /* Calculate temporary vectorial force */
874 tx = _mm256_mul_ps(fscal,dx02);
875 ty = _mm256_mul_ps(fscal,dy02);
876 tz = _mm256_mul_ps(fscal,dz02);
878 /* Update vectorial force */
879 fix0 = _mm256_add_ps(fix0,tx);
880 fiy0 = _mm256_add_ps(fiy0,ty);
881 fiz0 = _mm256_add_ps(fiz0,tz);
883 fjx2 = _mm256_add_ps(fjx2,tx);
884 fjy2 = _mm256_add_ps(fjy2,ty);
885 fjz2 = _mm256_add_ps(fjz2,tz);
887 /**************************
888 * CALCULATE INTERACTIONS *
889 **************************/
891 /* REACTION-FIELD ELECTROSTATICS */
892 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
893 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
895 /* Update potential sum for this i atom from the interaction with this j atom. */
896 velec = _mm256_andnot_ps(dummy_mask,velec);
897 velecsum = _mm256_add_ps(velecsum,velec);
901 fscal = _mm256_andnot_ps(dummy_mask,fscal);
903 /* Calculate temporary vectorial force */
904 tx = _mm256_mul_ps(fscal,dx10);
905 ty = _mm256_mul_ps(fscal,dy10);
906 tz = _mm256_mul_ps(fscal,dz10);
908 /* Update vectorial force */
909 fix1 = _mm256_add_ps(fix1,tx);
910 fiy1 = _mm256_add_ps(fiy1,ty);
911 fiz1 = _mm256_add_ps(fiz1,tz);
913 fjx0 = _mm256_add_ps(fjx0,tx);
914 fjy0 = _mm256_add_ps(fjy0,ty);
915 fjz0 = _mm256_add_ps(fjz0,tz);
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
921 /* REACTION-FIELD ELECTROSTATICS */
922 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
923 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
925 /* Update potential sum for this i atom from the interaction with this j atom. */
926 velec = _mm256_andnot_ps(dummy_mask,velec);
927 velecsum = _mm256_add_ps(velecsum,velec);
931 fscal = _mm256_andnot_ps(dummy_mask,fscal);
933 /* Calculate temporary vectorial force */
934 tx = _mm256_mul_ps(fscal,dx11);
935 ty = _mm256_mul_ps(fscal,dy11);
936 tz = _mm256_mul_ps(fscal,dz11);
938 /* Update vectorial force */
939 fix1 = _mm256_add_ps(fix1,tx);
940 fiy1 = _mm256_add_ps(fiy1,ty);
941 fiz1 = _mm256_add_ps(fiz1,tz);
943 fjx1 = _mm256_add_ps(fjx1,tx);
944 fjy1 = _mm256_add_ps(fjy1,ty);
945 fjz1 = _mm256_add_ps(fjz1,tz);
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
951 /* REACTION-FIELD ELECTROSTATICS */
952 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
953 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
955 /* Update potential sum for this i atom from the interaction with this j atom. */
956 velec = _mm256_andnot_ps(dummy_mask,velec);
957 velecsum = _mm256_add_ps(velecsum,velec);
961 fscal = _mm256_andnot_ps(dummy_mask,fscal);
963 /* Calculate temporary vectorial force */
964 tx = _mm256_mul_ps(fscal,dx12);
965 ty = _mm256_mul_ps(fscal,dy12);
966 tz = _mm256_mul_ps(fscal,dz12);
968 /* Update vectorial force */
969 fix1 = _mm256_add_ps(fix1,tx);
970 fiy1 = _mm256_add_ps(fiy1,ty);
971 fiz1 = _mm256_add_ps(fiz1,tz);
973 fjx2 = _mm256_add_ps(fjx2,tx);
974 fjy2 = _mm256_add_ps(fjy2,ty);
975 fjz2 = _mm256_add_ps(fjz2,tz);
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
981 /* REACTION-FIELD ELECTROSTATICS */
982 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
983 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
985 /* Update potential sum for this i atom from the interaction with this j atom. */
986 velec = _mm256_andnot_ps(dummy_mask,velec);
987 velecsum = _mm256_add_ps(velecsum,velec);
991 fscal = _mm256_andnot_ps(dummy_mask,fscal);
993 /* Calculate temporary vectorial force */
994 tx = _mm256_mul_ps(fscal,dx20);
995 ty = _mm256_mul_ps(fscal,dy20);
996 tz = _mm256_mul_ps(fscal,dz20);
998 /* Update vectorial force */
999 fix2 = _mm256_add_ps(fix2,tx);
1000 fiy2 = _mm256_add_ps(fiy2,ty);
1001 fiz2 = _mm256_add_ps(fiz2,tz);
1003 fjx0 = _mm256_add_ps(fjx0,tx);
1004 fjy0 = _mm256_add_ps(fjy0,ty);
1005 fjz0 = _mm256_add_ps(fjz0,tz);
1007 /**************************
1008 * CALCULATE INTERACTIONS *
1009 **************************/
1011 /* REACTION-FIELD ELECTROSTATICS */
1012 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1013 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1015 /* Update potential sum for this i atom from the interaction with this j atom. */
1016 velec = _mm256_andnot_ps(dummy_mask,velec);
1017 velecsum = _mm256_add_ps(velecsum,velec);
1021 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1023 /* Calculate temporary vectorial force */
1024 tx = _mm256_mul_ps(fscal,dx21);
1025 ty = _mm256_mul_ps(fscal,dy21);
1026 tz = _mm256_mul_ps(fscal,dz21);
1028 /* Update vectorial force */
1029 fix2 = _mm256_add_ps(fix2,tx);
1030 fiy2 = _mm256_add_ps(fiy2,ty);
1031 fiz2 = _mm256_add_ps(fiz2,tz);
1033 fjx1 = _mm256_add_ps(fjx1,tx);
1034 fjy1 = _mm256_add_ps(fjy1,ty);
1035 fjz1 = _mm256_add_ps(fjz1,tz);
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1041 /* REACTION-FIELD ELECTROSTATICS */
1042 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1043 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1045 /* Update potential sum for this i atom from the interaction with this j atom. */
1046 velec = _mm256_andnot_ps(dummy_mask,velec);
1047 velecsum = _mm256_add_ps(velecsum,velec);
1051 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1053 /* Calculate temporary vectorial force */
1054 tx = _mm256_mul_ps(fscal,dx22);
1055 ty = _mm256_mul_ps(fscal,dy22);
1056 tz = _mm256_mul_ps(fscal,dz22);
1058 /* Update vectorial force */
1059 fix2 = _mm256_add_ps(fix2,tx);
1060 fiy2 = _mm256_add_ps(fiy2,ty);
1061 fiz2 = _mm256_add_ps(fiz2,tz);
1063 fjx2 = _mm256_add_ps(fjx2,tx);
1064 fjy2 = _mm256_add_ps(fjy2,ty);
1065 fjz2 = _mm256_add_ps(fjz2,tz);
1067 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1068 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1069 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1070 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1071 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1072 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1073 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1074 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1076 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1077 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1079 /* Inner loop uses 324 flops */
1082 /* End of innermost loop */
1084 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1085 f+i_coord_offset,fshift+i_shift_offset);
1088 /* Update potential energies */
1089 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1090 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1092 /* Increment number of inner iterations */
1093 inneriter += j_index_end - j_index_start;
1095 /* Outer loop uses 20 flops */
1098 /* Increment number of outer iterations */
1101 /* Update outer/inner flops */
1103 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*324);
1106 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_avx_256_single
1107 * Electrostatics interaction: ReactionField
1108 * VdW interaction: CubicSplineTable
1109 * Geometry: Water3-Water3
1110 * Calculate force/pot: Force
1113 nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_avx_256_single
1114 (t_nblist * gmx_restrict nlist,
1115 rvec * gmx_restrict xx,
1116 rvec * gmx_restrict ff,
1117 t_forcerec * gmx_restrict fr,
1118 t_mdatoms * gmx_restrict mdatoms,
1119 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1120 t_nrnb * gmx_restrict nrnb)
1122 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1123 * just 0 for non-waters.
1124 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1125 * jnr indices corresponding to data put in the four positions in the SIMD register.
1127 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1128 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1129 int jnrA,jnrB,jnrC,jnrD;
1130 int jnrE,jnrF,jnrG,jnrH;
1131 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1132 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1133 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1134 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1135 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1136 real rcutoff_scalar;
1137 real *shiftvec,*fshift,*x,*f;
1138 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1139 real scratch[4*DIM];
1140 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1141 real * vdwioffsetptr0;
1142 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1143 real * vdwioffsetptr1;
1144 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1145 real * vdwioffsetptr2;
1146 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1147 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1148 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1149 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1150 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1151 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1152 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1153 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1154 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1155 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1156 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1157 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1158 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1159 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1160 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1161 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1162 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1165 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1168 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
1169 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
1171 __m128i vfitab_lo,vfitab_hi;
1172 __m128i ifour = _mm_set1_epi32(4);
1173 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
1175 __m256 dummy_mask,cutoff_mask;
1176 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1177 __m256 one = _mm256_set1_ps(1.0);
1178 __m256 two = _mm256_set1_ps(2.0);
1184 jindex = nlist->jindex;
1186 shiftidx = nlist->shift;
1188 shiftvec = fr->shift_vec[0];
1189 fshift = fr->fshift[0];
1190 facel = _mm256_set1_ps(fr->epsfac);
1191 charge = mdatoms->chargeA;
1192 krf = _mm256_set1_ps(fr->ic->k_rf);
1193 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1194 crf = _mm256_set1_ps(fr->ic->c_rf);
1195 nvdwtype = fr->ntype;
1196 vdwparam = fr->nbfp;
1197 vdwtype = mdatoms->typeA;
1199 vftab = kernel_data->table_vdw->data;
1200 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
1202 /* Setup water-specific parameters */
1203 inr = nlist->iinr[0];
1204 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
1205 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1206 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1207 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
1209 jq0 = _mm256_set1_ps(charge[inr+0]);
1210 jq1 = _mm256_set1_ps(charge[inr+1]);
1211 jq2 = _mm256_set1_ps(charge[inr+2]);
1212 vdwjidx0A = 2*vdwtype[inr+0];
1213 qq00 = _mm256_mul_ps(iq0,jq0);
1214 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1215 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1216 qq01 = _mm256_mul_ps(iq0,jq1);
1217 qq02 = _mm256_mul_ps(iq0,jq2);
1218 qq10 = _mm256_mul_ps(iq1,jq0);
1219 qq11 = _mm256_mul_ps(iq1,jq1);
1220 qq12 = _mm256_mul_ps(iq1,jq2);
1221 qq20 = _mm256_mul_ps(iq2,jq0);
1222 qq21 = _mm256_mul_ps(iq2,jq1);
1223 qq22 = _mm256_mul_ps(iq2,jq2);
1225 /* Avoid stupid compiler warnings */
1226 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1227 j_coord_offsetA = 0;
1228 j_coord_offsetB = 0;
1229 j_coord_offsetC = 0;
1230 j_coord_offsetD = 0;
1231 j_coord_offsetE = 0;
1232 j_coord_offsetF = 0;
1233 j_coord_offsetG = 0;
1234 j_coord_offsetH = 0;
1239 for(iidx=0;iidx<4*DIM;iidx++)
1241 scratch[iidx] = 0.0;
1244 /* Start outer loop over neighborlists */
1245 for(iidx=0; iidx<nri; iidx++)
1247 /* Load shift vector for this list */
1248 i_shift_offset = DIM*shiftidx[iidx];
1250 /* Load limits for loop over neighbors */
1251 j_index_start = jindex[iidx];
1252 j_index_end = jindex[iidx+1];
1254 /* Get outer coordinate index */
1256 i_coord_offset = DIM*inr;
1258 /* Load i particle coords and add shift vector */
1259 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1260 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1262 fix0 = _mm256_setzero_ps();
1263 fiy0 = _mm256_setzero_ps();
1264 fiz0 = _mm256_setzero_ps();
1265 fix1 = _mm256_setzero_ps();
1266 fiy1 = _mm256_setzero_ps();
1267 fiz1 = _mm256_setzero_ps();
1268 fix2 = _mm256_setzero_ps();
1269 fiy2 = _mm256_setzero_ps();
1270 fiz2 = _mm256_setzero_ps();
1272 /* Start inner kernel loop */
1273 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1276 /* Get j neighbor index, and coordinate index */
1278 jnrB = jjnr[jidx+1];
1279 jnrC = jjnr[jidx+2];
1280 jnrD = jjnr[jidx+3];
1281 jnrE = jjnr[jidx+4];
1282 jnrF = jjnr[jidx+5];
1283 jnrG = jjnr[jidx+6];
1284 jnrH = jjnr[jidx+7];
1285 j_coord_offsetA = DIM*jnrA;
1286 j_coord_offsetB = DIM*jnrB;
1287 j_coord_offsetC = DIM*jnrC;
1288 j_coord_offsetD = DIM*jnrD;
1289 j_coord_offsetE = DIM*jnrE;
1290 j_coord_offsetF = DIM*jnrF;
1291 j_coord_offsetG = DIM*jnrG;
1292 j_coord_offsetH = DIM*jnrH;
1294 /* load j atom coordinates */
1295 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1296 x+j_coord_offsetC,x+j_coord_offsetD,
1297 x+j_coord_offsetE,x+j_coord_offsetF,
1298 x+j_coord_offsetG,x+j_coord_offsetH,
1299 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1301 /* Calculate displacement vector */
1302 dx00 = _mm256_sub_ps(ix0,jx0);
1303 dy00 = _mm256_sub_ps(iy0,jy0);
1304 dz00 = _mm256_sub_ps(iz0,jz0);
1305 dx01 = _mm256_sub_ps(ix0,jx1);
1306 dy01 = _mm256_sub_ps(iy0,jy1);
1307 dz01 = _mm256_sub_ps(iz0,jz1);
1308 dx02 = _mm256_sub_ps(ix0,jx2);
1309 dy02 = _mm256_sub_ps(iy0,jy2);
1310 dz02 = _mm256_sub_ps(iz0,jz2);
1311 dx10 = _mm256_sub_ps(ix1,jx0);
1312 dy10 = _mm256_sub_ps(iy1,jy0);
1313 dz10 = _mm256_sub_ps(iz1,jz0);
1314 dx11 = _mm256_sub_ps(ix1,jx1);
1315 dy11 = _mm256_sub_ps(iy1,jy1);
1316 dz11 = _mm256_sub_ps(iz1,jz1);
1317 dx12 = _mm256_sub_ps(ix1,jx2);
1318 dy12 = _mm256_sub_ps(iy1,jy2);
1319 dz12 = _mm256_sub_ps(iz1,jz2);
1320 dx20 = _mm256_sub_ps(ix2,jx0);
1321 dy20 = _mm256_sub_ps(iy2,jy0);
1322 dz20 = _mm256_sub_ps(iz2,jz0);
1323 dx21 = _mm256_sub_ps(ix2,jx1);
1324 dy21 = _mm256_sub_ps(iy2,jy1);
1325 dz21 = _mm256_sub_ps(iz2,jz1);
1326 dx22 = _mm256_sub_ps(ix2,jx2);
1327 dy22 = _mm256_sub_ps(iy2,jy2);
1328 dz22 = _mm256_sub_ps(iz2,jz2);
1330 /* Calculate squared distance and things based on it */
1331 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1332 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1333 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1334 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1335 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1336 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1337 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1338 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1339 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1341 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1342 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1343 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1344 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1345 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1346 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1347 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1348 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1349 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1351 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1352 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1353 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1354 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1355 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1356 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1357 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1358 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1359 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1361 fjx0 = _mm256_setzero_ps();
1362 fjy0 = _mm256_setzero_ps();
1363 fjz0 = _mm256_setzero_ps();
1364 fjx1 = _mm256_setzero_ps();
1365 fjy1 = _mm256_setzero_ps();
1366 fjz1 = _mm256_setzero_ps();
1367 fjx2 = _mm256_setzero_ps();
1368 fjy2 = _mm256_setzero_ps();
1369 fjz2 = _mm256_setzero_ps();
1371 /**************************
1372 * CALCULATE INTERACTIONS *
1373 **************************/
1375 r00 = _mm256_mul_ps(rsq00,rinv00);
1377 /* Calculate table index by multiplying r with table scale and truncate to integer */
1378 rt = _mm256_mul_ps(r00,vftabscale);
1379 vfitab = _mm256_cvttps_epi32(rt);
1380 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1381 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1382 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1383 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1384 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1385 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1387 /* REACTION-FIELD ELECTROSTATICS */
1388 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1390 /* CUBIC SPLINE TABLE DISPERSION */
1391 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1392 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1393 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1394 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1395 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1396 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1397 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1398 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1399 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1400 Heps = _mm256_mul_ps(vfeps,H);
1401 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1402 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1403 fvdw6 = _mm256_mul_ps(c6_00,FF);
1405 /* CUBIC SPLINE TABLE REPULSION */
1406 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1407 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1408 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1409 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1410 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1411 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1412 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1413 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1414 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1415 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1416 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1417 Heps = _mm256_mul_ps(vfeps,H);
1418 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1419 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1420 fvdw12 = _mm256_mul_ps(c12_00,FF);
1421 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1423 fscal = _mm256_add_ps(felec,fvdw);
1425 /* Calculate temporary vectorial force */
1426 tx = _mm256_mul_ps(fscal,dx00);
1427 ty = _mm256_mul_ps(fscal,dy00);
1428 tz = _mm256_mul_ps(fscal,dz00);
1430 /* Update vectorial force */
1431 fix0 = _mm256_add_ps(fix0,tx);
1432 fiy0 = _mm256_add_ps(fiy0,ty);
1433 fiz0 = _mm256_add_ps(fiz0,tz);
1435 fjx0 = _mm256_add_ps(fjx0,tx);
1436 fjy0 = _mm256_add_ps(fjy0,ty);
1437 fjz0 = _mm256_add_ps(fjz0,tz);
1439 /**************************
1440 * CALCULATE INTERACTIONS *
1441 **************************/
1443 /* REACTION-FIELD ELECTROSTATICS */
1444 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1448 /* Calculate temporary vectorial force */
1449 tx = _mm256_mul_ps(fscal,dx01);
1450 ty = _mm256_mul_ps(fscal,dy01);
1451 tz = _mm256_mul_ps(fscal,dz01);
1453 /* Update vectorial force */
1454 fix0 = _mm256_add_ps(fix0,tx);
1455 fiy0 = _mm256_add_ps(fiy0,ty);
1456 fiz0 = _mm256_add_ps(fiz0,tz);
1458 fjx1 = _mm256_add_ps(fjx1,tx);
1459 fjy1 = _mm256_add_ps(fjy1,ty);
1460 fjz1 = _mm256_add_ps(fjz1,tz);
1462 /**************************
1463 * CALCULATE INTERACTIONS *
1464 **************************/
1466 /* REACTION-FIELD ELECTROSTATICS */
1467 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1471 /* Calculate temporary vectorial force */
1472 tx = _mm256_mul_ps(fscal,dx02);
1473 ty = _mm256_mul_ps(fscal,dy02);
1474 tz = _mm256_mul_ps(fscal,dz02);
1476 /* Update vectorial force */
1477 fix0 = _mm256_add_ps(fix0,tx);
1478 fiy0 = _mm256_add_ps(fiy0,ty);
1479 fiz0 = _mm256_add_ps(fiz0,tz);
1481 fjx2 = _mm256_add_ps(fjx2,tx);
1482 fjy2 = _mm256_add_ps(fjy2,ty);
1483 fjz2 = _mm256_add_ps(fjz2,tz);
1485 /**************************
1486 * CALCULATE INTERACTIONS *
1487 **************************/
1489 /* REACTION-FIELD ELECTROSTATICS */
1490 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1494 /* Calculate temporary vectorial force */
1495 tx = _mm256_mul_ps(fscal,dx10);
1496 ty = _mm256_mul_ps(fscal,dy10);
1497 tz = _mm256_mul_ps(fscal,dz10);
1499 /* Update vectorial force */
1500 fix1 = _mm256_add_ps(fix1,tx);
1501 fiy1 = _mm256_add_ps(fiy1,ty);
1502 fiz1 = _mm256_add_ps(fiz1,tz);
1504 fjx0 = _mm256_add_ps(fjx0,tx);
1505 fjy0 = _mm256_add_ps(fjy0,ty);
1506 fjz0 = _mm256_add_ps(fjz0,tz);
1508 /**************************
1509 * CALCULATE INTERACTIONS *
1510 **************************/
1512 /* REACTION-FIELD ELECTROSTATICS */
1513 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1517 /* Calculate temporary vectorial force */
1518 tx = _mm256_mul_ps(fscal,dx11);
1519 ty = _mm256_mul_ps(fscal,dy11);
1520 tz = _mm256_mul_ps(fscal,dz11);
1522 /* Update vectorial force */
1523 fix1 = _mm256_add_ps(fix1,tx);
1524 fiy1 = _mm256_add_ps(fiy1,ty);
1525 fiz1 = _mm256_add_ps(fiz1,tz);
1527 fjx1 = _mm256_add_ps(fjx1,tx);
1528 fjy1 = _mm256_add_ps(fjy1,ty);
1529 fjz1 = _mm256_add_ps(fjz1,tz);
1531 /**************************
1532 * CALCULATE INTERACTIONS *
1533 **************************/
1535 /* REACTION-FIELD ELECTROSTATICS */
1536 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1540 /* Calculate temporary vectorial force */
1541 tx = _mm256_mul_ps(fscal,dx12);
1542 ty = _mm256_mul_ps(fscal,dy12);
1543 tz = _mm256_mul_ps(fscal,dz12);
1545 /* Update vectorial force */
1546 fix1 = _mm256_add_ps(fix1,tx);
1547 fiy1 = _mm256_add_ps(fiy1,ty);
1548 fiz1 = _mm256_add_ps(fiz1,tz);
1550 fjx2 = _mm256_add_ps(fjx2,tx);
1551 fjy2 = _mm256_add_ps(fjy2,ty);
1552 fjz2 = _mm256_add_ps(fjz2,tz);
1554 /**************************
1555 * CALCULATE INTERACTIONS *
1556 **************************/
1558 /* REACTION-FIELD ELECTROSTATICS */
1559 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1563 /* Calculate temporary vectorial force */
1564 tx = _mm256_mul_ps(fscal,dx20);
1565 ty = _mm256_mul_ps(fscal,dy20);
1566 tz = _mm256_mul_ps(fscal,dz20);
1568 /* Update vectorial force */
1569 fix2 = _mm256_add_ps(fix2,tx);
1570 fiy2 = _mm256_add_ps(fiy2,ty);
1571 fiz2 = _mm256_add_ps(fiz2,tz);
1573 fjx0 = _mm256_add_ps(fjx0,tx);
1574 fjy0 = _mm256_add_ps(fjy0,ty);
1575 fjz0 = _mm256_add_ps(fjz0,tz);
1577 /**************************
1578 * CALCULATE INTERACTIONS *
1579 **************************/
1581 /* REACTION-FIELD ELECTROSTATICS */
1582 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1586 /* Calculate temporary vectorial force */
1587 tx = _mm256_mul_ps(fscal,dx21);
1588 ty = _mm256_mul_ps(fscal,dy21);
1589 tz = _mm256_mul_ps(fscal,dz21);
1591 /* Update vectorial force */
1592 fix2 = _mm256_add_ps(fix2,tx);
1593 fiy2 = _mm256_add_ps(fiy2,ty);
1594 fiz2 = _mm256_add_ps(fiz2,tz);
1596 fjx1 = _mm256_add_ps(fjx1,tx);
1597 fjy1 = _mm256_add_ps(fjy1,ty);
1598 fjz1 = _mm256_add_ps(fjz1,tz);
1600 /**************************
1601 * CALCULATE INTERACTIONS *
1602 **************************/
1604 /* REACTION-FIELD ELECTROSTATICS */
1605 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1609 /* Calculate temporary vectorial force */
1610 tx = _mm256_mul_ps(fscal,dx22);
1611 ty = _mm256_mul_ps(fscal,dy22);
1612 tz = _mm256_mul_ps(fscal,dz22);
1614 /* Update vectorial force */
1615 fix2 = _mm256_add_ps(fix2,tx);
1616 fiy2 = _mm256_add_ps(fiy2,ty);
1617 fiz2 = _mm256_add_ps(fiz2,tz);
1619 fjx2 = _mm256_add_ps(fjx2,tx);
1620 fjy2 = _mm256_add_ps(fjy2,ty);
1621 fjz2 = _mm256_add_ps(fjz2,tz);
1623 fjptrA = f+j_coord_offsetA;
1624 fjptrB = f+j_coord_offsetB;
1625 fjptrC = f+j_coord_offsetC;
1626 fjptrD = f+j_coord_offsetD;
1627 fjptrE = f+j_coord_offsetE;
1628 fjptrF = f+j_coord_offsetF;
1629 fjptrG = f+j_coord_offsetG;
1630 fjptrH = f+j_coord_offsetH;
1632 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1633 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1635 /* Inner loop uses 270 flops */
1638 if(jidx<j_index_end)
1641 /* Get j neighbor index, and coordinate index */
1642 jnrlistA = jjnr[jidx];
1643 jnrlistB = jjnr[jidx+1];
1644 jnrlistC = jjnr[jidx+2];
1645 jnrlistD = jjnr[jidx+3];
1646 jnrlistE = jjnr[jidx+4];
1647 jnrlistF = jjnr[jidx+5];
1648 jnrlistG = jjnr[jidx+6];
1649 jnrlistH = jjnr[jidx+7];
1650 /* Sign of each element will be negative for non-real atoms.
1651 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1652 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1654 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1655 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1657 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1658 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1659 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1660 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1661 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1662 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1663 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1664 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1665 j_coord_offsetA = DIM*jnrA;
1666 j_coord_offsetB = DIM*jnrB;
1667 j_coord_offsetC = DIM*jnrC;
1668 j_coord_offsetD = DIM*jnrD;
1669 j_coord_offsetE = DIM*jnrE;
1670 j_coord_offsetF = DIM*jnrF;
1671 j_coord_offsetG = DIM*jnrG;
1672 j_coord_offsetH = DIM*jnrH;
1674 /* load j atom coordinates */
1675 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1676 x+j_coord_offsetC,x+j_coord_offsetD,
1677 x+j_coord_offsetE,x+j_coord_offsetF,
1678 x+j_coord_offsetG,x+j_coord_offsetH,
1679 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1681 /* Calculate displacement vector */
1682 dx00 = _mm256_sub_ps(ix0,jx0);
1683 dy00 = _mm256_sub_ps(iy0,jy0);
1684 dz00 = _mm256_sub_ps(iz0,jz0);
1685 dx01 = _mm256_sub_ps(ix0,jx1);
1686 dy01 = _mm256_sub_ps(iy0,jy1);
1687 dz01 = _mm256_sub_ps(iz0,jz1);
1688 dx02 = _mm256_sub_ps(ix0,jx2);
1689 dy02 = _mm256_sub_ps(iy0,jy2);
1690 dz02 = _mm256_sub_ps(iz0,jz2);
1691 dx10 = _mm256_sub_ps(ix1,jx0);
1692 dy10 = _mm256_sub_ps(iy1,jy0);
1693 dz10 = _mm256_sub_ps(iz1,jz0);
1694 dx11 = _mm256_sub_ps(ix1,jx1);
1695 dy11 = _mm256_sub_ps(iy1,jy1);
1696 dz11 = _mm256_sub_ps(iz1,jz1);
1697 dx12 = _mm256_sub_ps(ix1,jx2);
1698 dy12 = _mm256_sub_ps(iy1,jy2);
1699 dz12 = _mm256_sub_ps(iz1,jz2);
1700 dx20 = _mm256_sub_ps(ix2,jx0);
1701 dy20 = _mm256_sub_ps(iy2,jy0);
1702 dz20 = _mm256_sub_ps(iz2,jz0);
1703 dx21 = _mm256_sub_ps(ix2,jx1);
1704 dy21 = _mm256_sub_ps(iy2,jy1);
1705 dz21 = _mm256_sub_ps(iz2,jz1);
1706 dx22 = _mm256_sub_ps(ix2,jx2);
1707 dy22 = _mm256_sub_ps(iy2,jy2);
1708 dz22 = _mm256_sub_ps(iz2,jz2);
1710 /* Calculate squared distance and things based on it */
1711 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1712 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1713 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1714 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1715 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1716 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1717 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1718 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1719 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1721 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1722 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1723 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1724 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1725 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1726 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1727 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1728 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1729 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1731 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1732 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1733 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1734 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1735 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1736 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1737 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1738 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1739 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1741 fjx0 = _mm256_setzero_ps();
1742 fjy0 = _mm256_setzero_ps();
1743 fjz0 = _mm256_setzero_ps();
1744 fjx1 = _mm256_setzero_ps();
1745 fjy1 = _mm256_setzero_ps();
1746 fjz1 = _mm256_setzero_ps();
1747 fjx2 = _mm256_setzero_ps();
1748 fjy2 = _mm256_setzero_ps();
1749 fjz2 = _mm256_setzero_ps();
1751 /**************************
1752 * CALCULATE INTERACTIONS *
1753 **************************/
1755 r00 = _mm256_mul_ps(rsq00,rinv00);
1756 r00 = _mm256_andnot_ps(dummy_mask,r00);
1758 /* Calculate table index by multiplying r with table scale and truncate to integer */
1759 rt = _mm256_mul_ps(r00,vftabscale);
1760 vfitab = _mm256_cvttps_epi32(rt);
1761 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1762 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1763 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1764 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1765 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1766 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1768 /* REACTION-FIELD ELECTROSTATICS */
1769 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1771 /* CUBIC SPLINE TABLE DISPERSION */
1772 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1773 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1774 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1775 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1776 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1777 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1778 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1779 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1780 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1781 Heps = _mm256_mul_ps(vfeps,H);
1782 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1783 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1784 fvdw6 = _mm256_mul_ps(c6_00,FF);
1786 /* CUBIC SPLINE TABLE REPULSION */
1787 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1788 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1789 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1790 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1791 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1792 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1793 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1794 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1795 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1796 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1797 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1798 Heps = _mm256_mul_ps(vfeps,H);
1799 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1800 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1801 fvdw12 = _mm256_mul_ps(c12_00,FF);
1802 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1804 fscal = _mm256_add_ps(felec,fvdw);
1806 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1808 /* Calculate temporary vectorial force */
1809 tx = _mm256_mul_ps(fscal,dx00);
1810 ty = _mm256_mul_ps(fscal,dy00);
1811 tz = _mm256_mul_ps(fscal,dz00);
1813 /* Update vectorial force */
1814 fix0 = _mm256_add_ps(fix0,tx);
1815 fiy0 = _mm256_add_ps(fiy0,ty);
1816 fiz0 = _mm256_add_ps(fiz0,tz);
1818 fjx0 = _mm256_add_ps(fjx0,tx);
1819 fjy0 = _mm256_add_ps(fjy0,ty);
1820 fjz0 = _mm256_add_ps(fjz0,tz);
1822 /**************************
1823 * CALCULATE INTERACTIONS *
1824 **************************/
1826 /* REACTION-FIELD ELECTROSTATICS */
1827 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1831 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1833 /* Calculate temporary vectorial force */
1834 tx = _mm256_mul_ps(fscal,dx01);
1835 ty = _mm256_mul_ps(fscal,dy01);
1836 tz = _mm256_mul_ps(fscal,dz01);
1838 /* Update vectorial force */
1839 fix0 = _mm256_add_ps(fix0,tx);
1840 fiy0 = _mm256_add_ps(fiy0,ty);
1841 fiz0 = _mm256_add_ps(fiz0,tz);
1843 fjx1 = _mm256_add_ps(fjx1,tx);
1844 fjy1 = _mm256_add_ps(fjy1,ty);
1845 fjz1 = _mm256_add_ps(fjz1,tz);
1847 /**************************
1848 * CALCULATE INTERACTIONS *
1849 **************************/
1851 /* REACTION-FIELD ELECTROSTATICS */
1852 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1856 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1858 /* Calculate temporary vectorial force */
1859 tx = _mm256_mul_ps(fscal,dx02);
1860 ty = _mm256_mul_ps(fscal,dy02);
1861 tz = _mm256_mul_ps(fscal,dz02);
1863 /* Update vectorial force */
1864 fix0 = _mm256_add_ps(fix0,tx);
1865 fiy0 = _mm256_add_ps(fiy0,ty);
1866 fiz0 = _mm256_add_ps(fiz0,tz);
1868 fjx2 = _mm256_add_ps(fjx2,tx);
1869 fjy2 = _mm256_add_ps(fjy2,ty);
1870 fjz2 = _mm256_add_ps(fjz2,tz);
1872 /**************************
1873 * CALCULATE INTERACTIONS *
1874 **************************/
1876 /* REACTION-FIELD ELECTROSTATICS */
1877 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1881 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1883 /* Calculate temporary vectorial force */
1884 tx = _mm256_mul_ps(fscal,dx10);
1885 ty = _mm256_mul_ps(fscal,dy10);
1886 tz = _mm256_mul_ps(fscal,dz10);
1888 /* Update vectorial force */
1889 fix1 = _mm256_add_ps(fix1,tx);
1890 fiy1 = _mm256_add_ps(fiy1,ty);
1891 fiz1 = _mm256_add_ps(fiz1,tz);
1893 fjx0 = _mm256_add_ps(fjx0,tx);
1894 fjy0 = _mm256_add_ps(fjy0,ty);
1895 fjz0 = _mm256_add_ps(fjz0,tz);
1897 /**************************
1898 * CALCULATE INTERACTIONS *
1899 **************************/
1901 /* REACTION-FIELD ELECTROSTATICS */
1902 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1906 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1908 /* Calculate temporary vectorial force */
1909 tx = _mm256_mul_ps(fscal,dx11);
1910 ty = _mm256_mul_ps(fscal,dy11);
1911 tz = _mm256_mul_ps(fscal,dz11);
1913 /* Update vectorial force */
1914 fix1 = _mm256_add_ps(fix1,tx);
1915 fiy1 = _mm256_add_ps(fiy1,ty);
1916 fiz1 = _mm256_add_ps(fiz1,tz);
1918 fjx1 = _mm256_add_ps(fjx1,tx);
1919 fjy1 = _mm256_add_ps(fjy1,ty);
1920 fjz1 = _mm256_add_ps(fjz1,tz);
1922 /**************************
1923 * CALCULATE INTERACTIONS *
1924 **************************/
1926 /* REACTION-FIELD ELECTROSTATICS */
1927 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1931 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1933 /* Calculate temporary vectorial force */
1934 tx = _mm256_mul_ps(fscal,dx12);
1935 ty = _mm256_mul_ps(fscal,dy12);
1936 tz = _mm256_mul_ps(fscal,dz12);
1938 /* Update vectorial force */
1939 fix1 = _mm256_add_ps(fix1,tx);
1940 fiy1 = _mm256_add_ps(fiy1,ty);
1941 fiz1 = _mm256_add_ps(fiz1,tz);
1943 fjx2 = _mm256_add_ps(fjx2,tx);
1944 fjy2 = _mm256_add_ps(fjy2,ty);
1945 fjz2 = _mm256_add_ps(fjz2,tz);
1947 /**************************
1948 * CALCULATE INTERACTIONS *
1949 **************************/
1951 /* REACTION-FIELD ELECTROSTATICS */
1952 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1956 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1958 /* Calculate temporary vectorial force */
1959 tx = _mm256_mul_ps(fscal,dx20);
1960 ty = _mm256_mul_ps(fscal,dy20);
1961 tz = _mm256_mul_ps(fscal,dz20);
1963 /* Update vectorial force */
1964 fix2 = _mm256_add_ps(fix2,tx);
1965 fiy2 = _mm256_add_ps(fiy2,ty);
1966 fiz2 = _mm256_add_ps(fiz2,tz);
1968 fjx0 = _mm256_add_ps(fjx0,tx);
1969 fjy0 = _mm256_add_ps(fjy0,ty);
1970 fjz0 = _mm256_add_ps(fjz0,tz);
1972 /**************************
1973 * CALCULATE INTERACTIONS *
1974 **************************/
1976 /* REACTION-FIELD ELECTROSTATICS */
1977 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1981 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1983 /* Calculate temporary vectorial force */
1984 tx = _mm256_mul_ps(fscal,dx21);
1985 ty = _mm256_mul_ps(fscal,dy21);
1986 tz = _mm256_mul_ps(fscal,dz21);
1988 /* Update vectorial force */
1989 fix2 = _mm256_add_ps(fix2,tx);
1990 fiy2 = _mm256_add_ps(fiy2,ty);
1991 fiz2 = _mm256_add_ps(fiz2,tz);
1993 fjx1 = _mm256_add_ps(fjx1,tx);
1994 fjy1 = _mm256_add_ps(fjy1,ty);
1995 fjz1 = _mm256_add_ps(fjz1,tz);
1997 /**************************
1998 * CALCULATE INTERACTIONS *
1999 **************************/
2001 /* REACTION-FIELD ELECTROSTATICS */
2002 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2006 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2008 /* Calculate temporary vectorial force */
2009 tx = _mm256_mul_ps(fscal,dx22);
2010 ty = _mm256_mul_ps(fscal,dy22);
2011 tz = _mm256_mul_ps(fscal,dz22);
2013 /* Update vectorial force */
2014 fix2 = _mm256_add_ps(fix2,tx);
2015 fiy2 = _mm256_add_ps(fiy2,ty);
2016 fiz2 = _mm256_add_ps(fiz2,tz);
2018 fjx2 = _mm256_add_ps(fjx2,tx);
2019 fjy2 = _mm256_add_ps(fjy2,ty);
2020 fjz2 = _mm256_add_ps(fjz2,tz);
2022 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2023 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2024 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2025 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2026 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2027 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2028 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2029 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2031 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2032 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2034 /* Inner loop uses 271 flops */
2037 /* End of innermost loop */
2039 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2040 f+i_coord_offset,fshift+i_shift_offset);
2042 /* Increment number of inner iterations */
2043 inneriter += j_index_end - j_index_start;
2045 /* Outer loop uses 18 flops */
2048 /* Increment number of outer iterations */
2051 /* Update outer/inner flops */
2053 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*271);