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_ElecRF_VdwCSTab_GeomW3W3_VF_avx_256_single
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: CubicSplineTable
54 * Geometry: Water3-Water3
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRF_VdwCSTab_GeomW3W3_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 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
93 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
94 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
95 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
96 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
97 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
98 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
99 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
100 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
101 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
102 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
103 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
104 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
105 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
106 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
107 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
110 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
113 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
114 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
116 __m128i vfitab_lo,vfitab_hi;
117 __m128i ifour = _mm_set1_epi32(4);
118 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
120 __m256 dummy_mask,cutoff_mask;
121 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
122 __m256 one = _mm256_set1_ps(1.0);
123 __m256 two = _mm256_set1_ps(2.0);
129 jindex = nlist->jindex;
131 shiftidx = nlist->shift;
133 shiftvec = fr->shift_vec[0];
134 fshift = fr->fshift[0];
135 facel = _mm256_set1_ps(fr->epsfac);
136 charge = mdatoms->chargeA;
137 krf = _mm256_set1_ps(fr->ic->k_rf);
138 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
139 crf = _mm256_set1_ps(fr->ic->c_rf);
140 nvdwtype = fr->ntype;
142 vdwtype = mdatoms->typeA;
144 vftab = kernel_data->table_vdw->data;
145 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
147 /* Setup water-specific parameters */
148 inr = nlist->iinr[0];
149 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
150 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
151 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
152 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
154 jq0 = _mm256_set1_ps(charge[inr+0]);
155 jq1 = _mm256_set1_ps(charge[inr+1]);
156 jq2 = _mm256_set1_ps(charge[inr+2]);
157 vdwjidx0A = 2*vdwtype[inr+0];
158 qq00 = _mm256_mul_ps(iq0,jq0);
159 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
160 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
161 qq01 = _mm256_mul_ps(iq0,jq1);
162 qq02 = _mm256_mul_ps(iq0,jq2);
163 qq10 = _mm256_mul_ps(iq1,jq0);
164 qq11 = _mm256_mul_ps(iq1,jq1);
165 qq12 = _mm256_mul_ps(iq1,jq2);
166 qq20 = _mm256_mul_ps(iq2,jq0);
167 qq21 = _mm256_mul_ps(iq2,jq1);
168 qq22 = _mm256_mul_ps(iq2,jq2);
170 /* Avoid stupid compiler warnings */
171 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
184 for(iidx=0;iidx<4*DIM;iidx++)
189 /* Start outer loop over neighborlists */
190 for(iidx=0; iidx<nri; iidx++)
192 /* Load shift vector for this list */
193 i_shift_offset = DIM*shiftidx[iidx];
195 /* Load limits for loop over neighbors */
196 j_index_start = jindex[iidx];
197 j_index_end = jindex[iidx+1];
199 /* Get outer coordinate index */
201 i_coord_offset = DIM*inr;
203 /* Load i particle coords and add shift vector */
204 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
205 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
207 fix0 = _mm256_setzero_ps();
208 fiy0 = _mm256_setzero_ps();
209 fiz0 = _mm256_setzero_ps();
210 fix1 = _mm256_setzero_ps();
211 fiy1 = _mm256_setzero_ps();
212 fiz1 = _mm256_setzero_ps();
213 fix2 = _mm256_setzero_ps();
214 fiy2 = _mm256_setzero_ps();
215 fiz2 = _mm256_setzero_ps();
217 /* Reset potential sums */
218 velecsum = _mm256_setzero_ps();
219 vvdwsum = _mm256_setzero_ps();
221 /* Start inner kernel loop */
222 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
225 /* Get j neighbor index, and coordinate index */
234 j_coord_offsetA = DIM*jnrA;
235 j_coord_offsetB = DIM*jnrB;
236 j_coord_offsetC = DIM*jnrC;
237 j_coord_offsetD = DIM*jnrD;
238 j_coord_offsetE = DIM*jnrE;
239 j_coord_offsetF = DIM*jnrF;
240 j_coord_offsetG = DIM*jnrG;
241 j_coord_offsetH = DIM*jnrH;
243 /* load j atom coordinates */
244 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
245 x+j_coord_offsetC,x+j_coord_offsetD,
246 x+j_coord_offsetE,x+j_coord_offsetF,
247 x+j_coord_offsetG,x+j_coord_offsetH,
248 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
250 /* Calculate displacement vector */
251 dx00 = _mm256_sub_ps(ix0,jx0);
252 dy00 = _mm256_sub_ps(iy0,jy0);
253 dz00 = _mm256_sub_ps(iz0,jz0);
254 dx01 = _mm256_sub_ps(ix0,jx1);
255 dy01 = _mm256_sub_ps(iy0,jy1);
256 dz01 = _mm256_sub_ps(iz0,jz1);
257 dx02 = _mm256_sub_ps(ix0,jx2);
258 dy02 = _mm256_sub_ps(iy0,jy2);
259 dz02 = _mm256_sub_ps(iz0,jz2);
260 dx10 = _mm256_sub_ps(ix1,jx0);
261 dy10 = _mm256_sub_ps(iy1,jy0);
262 dz10 = _mm256_sub_ps(iz1,jz0);
263 dx11 = _mm256_sub_ps(ix1,jx1);
264 dy11 = _mm256_sub_ps(iy1,jy1);
265 dz11 = _mm256_sub_ps(iz1,jz1);
266 dx12 = _mm256_sub_ps(ix1,jx2);
267 dy12 = _mm256_sub_ps(iy1,jy2);
268 dz12 = _mm256_sub_ps(iz1,jz2);
269 dx20 = _mm256_sub_ps(ix2,jx0);
270 dy20 = _mm256_sub_ps(iy2,jy0);
271 dz20 = _mm256_sub_ps(iz2,jz0);
272 dx21 = _mm256_sub_ps(ix2,jx1);
273 dy21 = _mm256_sub_ps(iy2,jy1);
274 dz21 = _mm256_sub_ps(iz2,jz1);
275 dx22 = _mm256_sub_ps(ix2,jx2);
276 dy22 = _mm256_sub_ps(iy2,jy2);
277 dz22 = _mm256_sub_ps(iz2,jz2);
279 /* Calculate squared distance and things based on it */
280 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
281 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
282 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
283 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
284 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
285 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
286 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
287 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
288 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
290 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
291 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
292 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
293 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
294 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
295 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
296 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
297 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
298 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
300 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
301 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
302 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
303 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
304 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
305 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
306 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
307 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
308 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
310 fjx0 = _mm256_setzero_ps();
311 fjy0 = _mm256_setzero_ps();
312 fjz0 = _mm256_setzero_ps();
313 fjx1 = _mm256_setzero_ps();
314 fjy1 = _mm256_setzero_ps();
315 fjz1 = _mm256_setzero_ps();
316 fjx2 = _mm256_setzero_ps();
317 fjy2 = _mm256_setzero_ps();
318 fjz2 = _mm256_setzero_ps();
320 /**************************
321 * CALCULATE INTERACTIONS *
322 **************************/
324 r00 = _mm256_mul_ps(rsq00,rinv00);
326 /* Calculate table index by multiplying r with table scale and truncate to integer */
327 rt = _mm256_mul_ps(r00,vftabscale);
328 vfitab = _mm256_cvttps_epi32(rt);
329 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
330 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
331 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
332 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
333 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
334 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
336 /* REACTION-FIELD ELECTROSTATICS */
337 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
338 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
340 /* CUBIC SPLINE TABLE DISPERSION */
341 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
342 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
343 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
344 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
345 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
346 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
347 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
348 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
349 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
350 Heps = _mm256_mul_ps(vfeps,H);
351 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
352 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
353 vvdw6 = _mm256_mul_ps(c6_00,VV);
354 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
355 fvdw6 = _mm256_mul_ps(c6_00,FF);
357 /* CUBIC SPLINE TABLE REPULSION */
358 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
359 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
360 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
361 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
362 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
363 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
364 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
365 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
366 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
367 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
368 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
369 Heps = _mm256_mul_ps(vfeps,H);
370 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
371 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
372 vvdw12 = _mm256_mul_ps(c12_00,VV);
373 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
374 fvdw12 = _mm256_mul_ps(c12_00,FF);
375 vvdw = _mm256_add_ps(vvdw12,vvdw6);
376 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
378 /* Update potential sum for this i atom from the interaction with this j atom. */
379 velecsum = _mm256_add_ps(velecsum,velec);
380 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
382 fscal = _mm256_add_ps(felec,fvdw);
384 /* Calculate temporary vectorial force */
385 tx = _mm256_mul_ps(fscal,dx00);
386 ty = _mm256_mul_ps(fscal,dy00);
387 tz = _mm256_mul_ps(fscal,dz00);
389 /* Update vectorial force */
390 fix0 = _mm256_add_ps(fix0,tx);
391 fiy0 = _mm256_add_ps(fiy0,ty);
392 fiz0 = _mm256_add_ps(fiz0,tz);
394 fjx0 = _mm256_add_ps(fjx0,tx);
395 fjy0 = _mm256_add_ps(fjy0,ty);
396 fjz0 = _mm256_add_ps(fjz0,tz);
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
402 /* REACTION-FIELD ELECTROSTATICS */
403 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
404 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
406 /* Update potential sum for this i atom from the interaction with this j atom. */
407 velecsum = _mm256_add_ps(velecsum,velec);
411 /* Calculate temporary vectorial force */
412 tx = _mm256_mul_ps(fscal,dx01);
413 ty = _mm256_mul_ps(fscal,dy01);
414 tz = _mm256_mul_ps(fscal,dz01);
416 /* Update vectorial force */
417 fix0 = _mm256_add_ps(fix0,tx);
418 fiy0 = _mm256_add_ps(fiy0,ty);
419 fiz0 = _mm256_add_ps(fiz0,tz);
421 fjx1 = _mm256_add_ps(fjx1,tx);
422 fjy1 = _mm256_add_ps(fjy1,ty);
423 fjz1 = _mm256_add_ps(fjz1,tz);
425 /**************************
426 * CALCULATE INTERACTIONS *
427 **************************/
429 /* REACTION-FIELD ELECTROSTATICS */
430 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
431 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
433 /* Update potential sum for this i atom from the interaction with this j atom. */
434 velecsum = _mm256_add_ps(velecsum,velec);
438 /* Calculate temporary vectorial force */
439 tx = _mm256_mul_ps(fscal,dx02);
440 ty = _mm256_mul_ps(fscal,dy02);
441 tz = _mm256_mul_ps(fscal,dz02);
443 /* Update vectorial force */
444 fix0 = _mm256_add_ps(fix0,tx);
445 fiy0 = _mm256_add_ps(fiy0,ty);
446 fiz0 = _mm256_add_ps(fiz0,tz);
448 fjx2 = _mm256_add_ps(fjx2,tx);
449 fjy2 = _mm256_add_ps(fjy2,ty);
450 fjz2 = _mm256_add_ps(fjz2,tz);
452 /**************************
453 * CALCULATE INTERACTIONS *
454 **************************/
456 /* REACTION-FIELD ELECTROSTATICS */
457 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
458 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
460 /* Update potential sum for this i atom from the interaction with this j atom. */
461 velecsum = _mm256_add_ps(velecsum,velec);
465 /* Calculate temporary vectorial force */
466 tx = _mm256_mul_ps(fscal,dx10);
467 ty = _mm256_mul_ps(fscal,dy10);
468 tz = _mm256_mul_ps(fscal,dz10);
470 /* Update vectorial force */
471 fix1 = _mm256_add_ps(fix1,tx);
472 fiy1 = _mm256_add_ps(fiy1,ty);
473 fiz1 = _mm256_add_ps(fiz1,tz);
475 fjx0 = _mm256_add_ps(fjx0,tx);
476 fjy0 = _mm256_add_ps(fjy0,ty);
477 fjz0 = _mm256_add_ps(fjz0,tz);
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
483 /* REACTION-FIELD ELECTROSTATICS */
484 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
485 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
487 /* Update potential sum for this i atom from the interaction with this j atom. */
488 velecsum = _mm256_add_ps(velecsum,velec);
492 /* Calculate temporary vectorial force */
493 tx = _mm256_mul_ps(fscal,dx11);
494 ty = _mm256_mul_ps(fscal,dy11);
495 tz = _mm256_mul_ps(fscal,dz11);
497 /* Update vectorial force */
498 fix1 = _mm256_add_ps(fix1,tx);
499 fiy1 = _mm256_add_ps(fiy1,ty);
500 fiz1 = _mm256_add_ps(fiz1,tz);
502 fjx1 = _mm256_add_ps(fjx1,tx);
503 fjy1 = _mm256_add_ps(fjy1,ty);
504 fjz1 = _mm256_add_ps(fjz1,tz);
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
510 /* REACTION-FIELD ELECTROSTATICS */
511 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
512 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
514 /* Update potential sum for this i atom from the interaction with this j atom. */
515 velecsum = _mm256_add_ps(velecsum,velec);
519 /* Calculate temporary vectorial force */
520 tx = _mm256_mul_ps(fscal,dx12);
521 ty = _mm256_mul_ps(fscal,dy12);
522 tz = _mm256_mul_ps(fscal,dz12);
524 /* Update vectorial force */
525 fix1 = _mm256_add_ps(fix1,tx);
526 fiy1 = _mm256_add_ps(fiy1,ty);
527 fiz1 = _mm256_add_ps(fiz1,tz);
529 fjx2 = _mm256_add_ps(fjx2,tx);
530 fjy2 = _mm256_add_ps(fjy2,ty);
531 fjz2 = _mm256_add_ps(fjz2,tz);
533 /**************************
534 * CALCULATE INTERACTIONS *
535 **************************/
537 /* REACTION-FIELD ELECTROSTATICS */
538 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
539 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
541 /* Update potential sum for this i atom from the interaction with this j atom. */
542 velecsum = _mm256_add_ps(velecsum,velec);
546 /* Calculate temporary vectorial force */
547 tx = _mm256_mul_ps(fscal,dx20);
548 ty = _mm256_mul_ps(fscal,dy20);
549 tz = _mm256_mul_ps(fscal,dz20);
551 /* Update vectorial force */
552 fix2 = _mm256_add_ps(fix2,tx);
553 fiy2 = _mm256_add_ps(fiy2,ty);
554 fiz2 = _mm256_add_ps(fiz2,tz);
556 fjx0 = _mm256_add_ps(fjx0,tx);
557 fjy0 = _mm256_add_ps(fjy0,ty);
558 fjz0 = _mm256_add_ps(fjz0,tz);
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* REACTION-FIELD ELECTROSTATICS */
565 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
566 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
568 /* Update potential sum for this i atom from the interaction with this j atom. */
569 velecsum = _mm256_add_ps(velecsum,velec);
573 /* Calculate temporary vectorial force */
574 tx = _mm256_mul_ps(fscal,dx21);
575 ty = _mm256_mul_ps(fscal,dy21);
576 tz = _mm256_mul_ps(fscal,dz21);
578 /* Update vectorial force */
579 fix2 = _mm256_add_ps(fix2,tx);
580 fiy2 = _mm256_add_ps(fiy2,ty);
581 fiz2 = _mm256_add_ps(fiz2,tz);
583 fjx1 = _mm256_add_ps(fjx1,tx);
584 fjy1 = _mm256_add_ps(fjy1,ty);
585 fjz1 = _mm256_add_ps(fjz1,tz);
587 /**************************
588 * CALCULATE INTERACTIONS *
589 **************************/
591 /* REACTION-FIELD ELECTROSTATICS */
592 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
593 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
595 /* Update potential sum for this i atom from the interaction with this j atom. */
596 velecsum = _mm256_add_ps(velecsum,velec);
600 /* Calculate temporary vectorial force */
601 tx = _mm256_mul_ps(fscal,dx22);
602 ty = _mm256_mul_ps(fscal,dy22);
603 tz = _mm256_mul_ps(fscal,dz22);
605 /* Update vectorial force */
606 fix2 = _mm256_add_ps(fix2,tx);
607 fiy2 = _mm256_add_ps(fiy2,ty);
608 fiz2 = _mm256_add_ps(fiz2,tz);
610 fjx2 = _mm256_add_ps(fjx2,tx);
611 fjy2 = _mm256_add_ps(fjy2,ty);
612 fjz2 = _mm256_add_ps(fjz2,tz);
614 fjptrA = f+j_coord_offsetA;
615 fjptrB = f+j_coord_offsetB;
616 fjptrC = f+j_coord_offsetC;
617 fjptrD = f+j_coord_offsetD;
618 fjptrE = f+j_coord_offsetE;
619 fjptrF = f+j_coord_offsetF;
620 fjptrG = f+j_coord_offsetG;
621 fjptrH = f+j_coord_offsetH;
623 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
624 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
626 /* Inner loop uses 323 flops */
632 /* Get j neighbor index, and coordinate index */
633 jnrlistA = jjnr[jidx];
634 jnrlistB = jjnr[jidx+1];
635 jnrlistC = jjnr[jidx+2];
636 jnrlistD = jjnr[jidx+3];
637 jnrlistE = jjnr[jidx+4];
638 jnrlistF = jjnr[jidx+5];
639 jnrlistG = jjnr[jidx+6];
640 jnrlistH = jjnr[jidx+7];
641 /* Sign of each element will be negative for non-real atoms.
642 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
643 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
645 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
646 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
648 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
649 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
650 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
651 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
652 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
653 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
654 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
655 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
656 j_coord_offsetA = DIM*jnrA;
657 j_coord_offsetB = DIM*jnrB;
658 j_coord_offsetC = DIM*jnrC;
659 j_coord_offsetD = DIM*jnrD;
660 j_coord_offsetE = DIM*jnrE;
661 j_coord_offsetF = DIM*jnrF;
662 j_coord_offsetG = DIM*jnrG;
663 j_coord_offsetH = DIM*jnrH;
665 /* load j atom coordinates */
666 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
667 x+j_coord_offsetC,x+j_coord_offsetD,
668 x+j_coord_offsetE,x+j_coord_offsetF,
669 x+j_coord_offsetG,x+j_coord_offsetH,
670 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
672 /* Calculate displacement vector */
673 dx00 = _mm256_sub_ps(ix0,jx0);
674 dy00 = _mm256_sub_ps(iy0,jy0);
675 dz00 = _mm256_sub_ps(iz0,jz0);
676 dx01 = _mm256_sub_ps(ix0,jx1);
677 dy01 = _mm256_sub_ps(iy0,jy1);
678 dz01 = _mm256_sub_ps(iz0,jz1);
679 dx02 = _mm256_sub_ps(ix0,jx2);
680 dy02 = _mm256_sub_ps(iy0,jy2);
681 dz02 = _mm256_sub_ps(iz0,jz2);
682 dx10 = _mm256_sub_ps(ix1,jx0);
683 dy10 = _mm256_sub_ps(iy1,jy0);
684 dz10 = _mm256_sub_ps(iz1,jz0);
685 dx11 = _mm256_sub_ps(ix1,jx1);
686 dy11 = _mm256_sub_ps(iy1,jy1);
687 dz11 = _mm256_sub_ps(iz1,jz1);
688 dx12 = _mm256_sub_ps(ix1,jx2);
689 dy12 = _mm256_sub_ps(iy1,jy2);
690 dz12 = _mm256_sub_ps(iz1,jz2);
691 dx20 = _mm256_sub_ps(ix2,jx0);
692 dy20 = _mm256_sub_ps(iy2,jy0);
693 dz20 = _mm256_sub_ps(iz2,jz0);
694 dx21 = _mm256_sub_ps(ix2,jx1);
695 dy21 = _mm256_sub_ps(iy2,jy1);
696 dz21 = _mm256_sub_ps(iz2,jz1);
697 dx22 = _mm256_sub_ps(ix2,jx2);
698 dy22 = _mm256_sub_ps(iy2,jy2);
699 dz22 = _mm256_sub_ps(iz2,jz2);
701 /* Calculate squared distance and things based on it */
702 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
703 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
704 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
705 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
706 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
707 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
708 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
709 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
710 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
712 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
713 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
714 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
715 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
716 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
717 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
718 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
719 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
720 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
722 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
723 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
724 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
725 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
726 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
727 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
728 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
729 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
730 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
732 fjx0 = _mm256_setzero_ps();
733 fjy0 = _mm256_setzero_ps();
734 fjz0 = _mm256_setzero_ps();
735 fjx1 = _mm256_setzero_ps();
736 fjy1 = _mm256_setzero_ps();
737 fjz1 = _mm256_setzero_ps();
738 fjx2 = _mm256_setzero_ps();
739 fjy2 = _mm256_setzero_ps();
740 fjz2 = _mm256_setzero_ps();
742 /**************************
743 * CALCULATE INTERACTIONS *
744 **************************/
746 r00 = _mm256_mul_ps(rsq00,rinv00);
747 r00 = _mm256_andnot_ps(dummy_mask,r00);
749 /* Calculate table index by multiplying r with table scale and truncate to integer */
750 rt = _mm256_mul_ps(r00,vftabscale);
751 vfitab = _mm256_cvttps_epi32(rt);
752 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
753 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
754 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
755 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
756 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
757 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
759 /* REACTION-FIELD ELECTROSTATICS */
760 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
761 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
763 /* CUBIC SPLINE TABLE DISPERSION */
764 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
765 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
766 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
767 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
768 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
769 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
770 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
771 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
772 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
773 Heps = _mm256_mul_ps(vfeps,H);
774 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
775 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
776 vvdw6 = _mm256_mul_ps(c6_00,VV);
777 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
778 fvdw6 = _mm256_mul_ps(c6_00,FF);
780 /* CUBIC SPLINE TABLE REPULSION */
781 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
782 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
783 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
784 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
785 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
786 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
787 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
788 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
789 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
790 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
791 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
792 Heps = _mm256_mul_ps(vfeps,H);
793 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
794 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
795 vvdw12 = _mm256_mul_ps(c12_00,VV);
796 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
797 fvdw12 = _mm256_mul_ps(c12_00,FF);
798 vvdw = _mm256_add_ps(vvdw12,vvdw6);
799 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
801 /* Update potential sum for this i atom from the interaction with this j atom. */
802 velec = _mm256_andnot_ps(dummy_mask,velec);
803 velecsum = _mm256_add_ps(velecsum,velec);
804 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
805 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
807 fscal = _mm256_add_ps(felec,fvdw);
809 fscal = _mm256_andnot_ps(dummy_mask,fscal);
811 /* Calculate temporary vectorial force */
812 tx = _mm256_mul_ps(fscal,dx00);
813 ty = _mm256_mul_ps(fscal,dy00);
814 tz = _mm256_mul_ps(fscal,dz00);
816 /* Update vectorial force */
817 fix0 = _mm256_add_ps(fix0,tx);
818 fiy0 = _mm256_add_ps(fiy0,ty);
819 fiz0 = _mm256_add_ps(fiz0,tz);
821 fjx0 = _mm256_add_ps(fjx0,tx);
822 fjy0 = _mm256_add_ps(fjy0,ty);
823 fjz0 = _mm256_add_ps(fjz0,tz);
825 /**************************
826 * CALCULATE INTERACTIONS *
827 **************************/
829 /* REACTION-FIELD ELECTROSTATICS */
830 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
831 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
833 /* Update potential sum for this i atom from the interaction with this j atom. */
834 velec = _mm256_andnot_ps(dummy_mask,velec);
835 velecsum = _mm256_add_ps(velecsum,velec);
839 fscal = _mm256_andnot_ps(dummy_mask,fscal);
841 /* Calculate temporary vectorial force */
842 tx = _mm256_mul_ps(fscal,dx01);
843 ty = _mm256_mul_ps(fscal,dy01);
844 tz = _mm256_mul_ps(fscal,dz01);
846 /* Update vectorial force */
847 fix0 = _mm256_add_ps(fix0,tx);
848 fiy0 = _mm256_add_ps(fiy0,ty);
849 fiz0 = _mm256_add_ps(fiz0,tz);
851 fjx1 = _mm256_add_ps(fjx1,tx);
852 fjy1 = _mm256_add_ps(fjy1,ty);
853 fjz1 = _mm256_add_ps(fjz1,tz);
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
859 /* REACTION-FIELD ELECTROSTATICS */
860 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
861 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
863 /* Update potential sum for this i atom from the interaction with this j atom. */
864 velec = _mm256_andnot_ps(dummy_mask,velec);
865 velecsum = _mm256_add_ps(velecsum,velec);
869 fscal = _mm256_andnot_ps(dummy_mask,fscal);
871 /* Calculate temporary vectorial force */
872 tx = _mm256_mul_ps(fscal,dx02);
873 ty = _mm256_mul_ps(fscal,dy02);
874 tz = _mm256_mul_ps(fscal,dz02);
876 /* Update vectorial force */
877 fix0 = _mm256_add_ps(fix0,tx);
878 fiy0 = _mm256_add_ps(fiy0,ty);
879 fiz0 = _mm256_add_ps(fiz0,tz);
881 fjx2 = _mm256_add_ps(fjx2,tx);
882 fjy2 = _mm256_add_ps(fjy2,ty);
883 fjz2 = _mm256_add_ps(fjz2,tz);
885 /**************************
886 * CALCULATE INTERACTIONS *
887 **************************/
889 /* REACTION-FIELD ELECTROSTATICS */
890 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
891 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
893 /* Update potential sum for this i atom from the interaction with this j atom. */
894 velec = _mm256_andnot_ps(dummy_mask,velec);
895 velecsum = _mm256_add_ps(velecsum,velec);
899 fscal = _mm256_andnot_ps(dummy_mask,fscal);
901 /* Calculate temporary vectorial force */
902 tx = _mm256_mul_ps(fscal,dx10);
903 ty = _mm256_mul_ps(fscal,dy10);
904 tz = _mm256_mul_ps(fscal,dz10);
906 /* Update vectorial force */
907 fix1 = _mm256_add_ps(fix1,tx);
908 fiy1 = _mm256_add_ps(fiy1,ty);
909 fiz1 = _mm256_add_ps(fiz1,tz);
911 fjx0 = _mm256_add_ps(fjx0,tx);
912 fjy0 = _mm256_add_ps(fjy0,ty);
913 fjz0 = _mm256_add_ps(fjz0,tz);
915 /**************************
916 * CALCULATE INTERACTIONS *
917 **************************/
919 /* REACTION-FIELD ELECTROSTATICS */
920 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
921 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
923 /* Update potential sum for this i atom from the interaction with this j atom. */
924 velec = _mm256_andnot_ps(dummy_mask,velec);
925 velecsum = _mm256_add_ps(velecsum,velec);
929 fscal = _mm256_andnot_ps(dummy_mask,fscal);
931 /* Calculate temporary vectorial force */
932 tx = _mm256_mul_ps(fscal,dx11);
933 ty = _mm256_mul_ps(fscal,dy11);
934 tz = _mm256_mul_ps(fscal,dz11);
936 /* Update vectorial force */
937 fix1 = _mm256_add_ps(fix1,tx);
938 fiy1 = _mm256_add_ps(fiy1,ty);
939 fiz1 = _mm256_add_ps(fiz1,tz);
941 fjx1 = _mm256_add_ps(fjx1,tx);
942 fjy1 = _mm256_add_ps(fjy1,ty);
943 fjz1 = _mm256_add_ps(fjz1,tz);
945 /**************************
946 * CALCULATE INTERACTIONS *
947 **************************/
949 /* REACTION-FIELD ELECTROSTATICS */
950 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
951 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
953 /* Update potential sum for this i atom from the interaction with this j atom. */
954 velec = _mm256_andnot_ps(dummy_mask,velec);
955 velecsum = _mm256_add_ps(velecsum,velec);
959 fscal = _mm256_andnot_ps(dummy_mask,fscal);
961 /* Calculate temporary vectorial force */
962 tx = _mm256_mul_ps(fscal,dx12);
963 ty = _mm256_mul_ps(fscal,dy12);
964 tz = _mm256_mul_ps(fscal,dz12);
966 /* Update vectorial force */
967 fix1 = _mm256_add_ps(fix1,tx);
968 fiy1 = _mm256_add_ps(fiy1,ty);
969 fiz1 = _mm256_add_ps(fiz1,tz);
971 fjx2 = _mm256_add_ps(fjx2,tx);
972 fjy2 = _mm256_add_ps(fjy2,ty);
973 fjz2 = _mm256_add_ps(fjz2,tz);
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
979 /* REACTION-FIELD ELECTROSTATICS */
980 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
981 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
983 /* Update potential sum for this i atom from the interaction with this j atom. */
984 velec = _mm256_andnot_ps(dummy_mask,velec);
985 velecsum = _mm256_add_ps(velecsum,velec);
989 fscal = _mm256_andnot_ps(dummy_mask,fscal);
991 /* Calculate temporary vectorial force */
992 tx = _mm256_mul_ps(fscal,dx20);
993 ty = _mm256_mul_ps(fscal,dy20);
994 tz = _mm256_mul_ps(fscal,dz20);
996 /* Update vectorial force */
997 fix2 = _mm256_add_ps(fix2,tx);
998 fiy2 = _mm256_add_ps(fiy2,ty);
999 fiz2 = _mm256_add_ps(fiz2,tz);
1001 fjx0 = _mm256_add_ps(fjx0,tx);
1002 fjy0 = _mm256_add_ps(fjy0,ty);
1003 fjz0 = _mm256_add_ps(fjz0,tz);
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1009 /* REACTION-FIELD ELECTROSTATICS */
1010 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1011 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1013 /* Update potential sum for this i atom from the interaction with this j atom. */
1014 velec = _mm256_andnot_ps(dummy_mask,velec);
1015 velecsum = _mm256_add_ps(velecsum,velec);
1019 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1021 /* Calculate temporary vectorial force */
1022 tx = _mm256_mul_ps(fscal,dx21);
1023 ty = _mm256_mul_ps(fscal,dy21);
1024 tz = _mm256_mul_ps(fscal,dz21);
1026 /* Update vectorial force */
1027 fix2 = _mm256_add_ps(fix2,tx);
1028 fiy2 = _mm256_add_ps(fiy2,ty);
1029 fiz2 = _mm256_add_ps(fiz2,tz);
1031 fjx1 = _mm256_add_ps(fjx1,tx);
1032 fjy1 = _mm256_add_ps(fjy1,ty);
1033 fjz1 = _mm256_add_ps(fjz1,tz);
1035 /**************************
1036 * CALCULATE INTERACTIONS *
1037 **************************/
1039 /* REACTION-FIELD ELECTROSTATICS */
1040 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1041 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1043 /* Update potential sum for this i atom from the interaction with this j atom. */
1044 velec = _mm256_andnot_ps(dummy_mask,velec);
1045 velecsum = _mm256_add_ps(velecsum,velec);
1049 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1051 /* Calculate temporary vectorial force */
1052 tx = _mm256_mul_ps(fscal,dx22);
1053 ty = _mm256_mul_ps(fscal,dy22);
1054 tz = _mm256_mul_ps(fscal,dz22);
1056 /* Update vectorial force */
1057 fix2 = _mm256_add_ps(fix2,tx);
1058 fiy2 = _mm256_add_ps(fiy2,ty);
1059 fiz2 = _mm256_add_ps(fiz2,tz);
1061 fjx2 = _mm256_add_ps(fjx2,tx);
1062 fjy2 = _mm256_add_ps(fjy2,ty);
1063 fjz2 = _mm256_add_ps(fjz2,tz);
1065 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1066 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1067 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1068 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1069 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1070 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1071 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1072 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1074 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1075 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1077 /* Inner loop uses 324 flops */
1080 /* End of innermost loop */
1082 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1083 f+i_coord_offset,fshift+i_shift_offset);
1086 /* Update potential energies */
1087 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1088 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1090 /* Increment number of inner iterations */
1091 inneriter += j_index_end - j_index_start;
1093 /* Outer loop uses 20 flops */
1096 /* Increment number of outer iterations */
1099 /* Update outer/inner flops */
1101 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*324);
1104 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_avx_256_single
1105 * Electrostatics interaction: ReactionField
1106 * VdW interaction: CubicSplineTable
1107 * Geometry: Water3-Water3
1108 * Calculate force/pot: Force
1111 nb_kernel_ElecRF_VdwCSTab_GeomW3W3_F_avx_256_single
1112 (t_nblist * gmx_restrict nlist,
1113 rvec * gmx_restrict xx,
1114 rvec * gmx_restrict ff,
1115 t_forcerec * gmx_restrict fr,
1116 t_mdatoms * gmx_restrict mdatoms,
1117 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1118 t_nrnb * gmx_restrict nrnb)
1120 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1121 * just 0 for non-waters.
1122 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1123 * jnr indices corresponding to data put in the four positions in the SIMD register.
1125 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1126 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1127 int jnrA,jnrB,jnrC,jnrD;
1128 int jnrE,jnrF,jnrG,jnrH;
1129 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1130 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1131 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1132 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1133 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1134 real rcutoff_scalar;
1135 real *shiftvec,*fshift,*x,*f;
1136 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1137 real scratch[4*DIM];
1138 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1139 real * vdwioffsetptr0;
1140 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1141 real * vdwioffsetptr1;
1142 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1143 real * vdwioffsetptr2;
1144 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1145 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1146 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1147 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1148 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1149 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1150 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1151 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1152 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1153 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1154 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1155 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1156 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1157 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1158 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1159 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1160 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1163 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1166 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
1167 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
1169 __m128i vfitab_lo,vfitab_hi;
1170 __m128i ifour = _mm_set1_epi32(4);
1171 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
1173 __m256 dummy_mask,cutoff_mask;
1174 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1175 __m256 one = _mm256_set1_ps(1.0);
1176 __m256 two = _mm256_set1_ps(2.0);
1182 jindex = nlist->jindex;
1184 shiftidx = nlist->shift;
1186 shiftvec = fr->shift_vec[0];
1187 fshift = fr->fshift[0];
1188 facel = _mm256_set1_ps(fr->epsfac);
1189 charge = mdatoms->chargeA;
1190 krf = _mm256_set1_ps(fr->ic->k_rf);
1191 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1192 crf = _mm256_set1_ps(fr->ic->c_rf);
1193 nvdwtype = fr->ntype;
1194 vdwparam = fr->nbfp;
1195 vdwtype = mdatoms->typeA;
1197 vftab = kernel_data->table_vdw->data;
1198 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
1200 /* Setup water-specific parameters */
1201 inr = nlist->iinr[0];
1202 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
1203 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1204 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1205 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
1207 jq0 = _mm256_set1_ps(charge[inr+0]);
1208 jq1 = _mm256_set1_ps(charge[inr+1]);
1209 jq2 = _mm256_set1_ps(charge[inr+2]);
1210 vdwjidx0A = 2*vdwtype[inr+0];
1211 qq00 = _mm256_mul_ps(iq0,jq0);
1212 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1213 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1214 qq01 = _mm256_mul_ps(iq0,jq1);
1215 qq02 = _mm256_mul_ps(iq0,jq2);
1216 qq10 = _mm256_mul_ps(iq1,jq0);
1217 qq11 = _mm256_mul_ps(iq1,jq1);
1218 qq12 = _mm256_mul_ps(iq1,jq2);
1219 qq20 = _mm256_mul_ps(iq2,jq0);
1220 qq21 = _mm256_mul_ps(iq2,jq1);
1221 qq22 = _mm256_mul_ps(iq2,jq2);
1223 /* Avoid stupid compiler warnings */
1224 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1225 j_coord_offsetA = 0;
1226 j_coord_offsetB = 0;
1227 j_coord_offsetC = 0;
1228 j_coord_offsetD = 0;
1229 j_coord_offsetE = 0;
1230 j_coord_offsetF = 0;
1231 j_coord_offsetG = 0;
1232 j_coord_offsetH = 0;
1237 for(iidx=0;iidx<4*DIM;iidx++)
1239 scratch[iidx] = 0.0;
1242 /* Start outer loop over neighborlists */
1243 for(iidx=0; iidx<nri; iidx++)
1245 /* Load shift vector for this list */
1246 i_shift_offset = DIM*shiftidx[iidx];
1248 /* Load limits for loop over neighbors */
1249 j_index_start = jindex[iidx];
1250 j_index_end = jindex[iidx+1];
1252 /* Get outer coordinate index */
1254 i_coord_offset = DIM*inr;
1256 /* Load i particle coords and add shift vector */
1257 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1258 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1260 fix0 = _mm256_setzero_ps();
1261 fiy0 = _mm256_setzero_ps();
1262 fiz0 = _mm256_setzero_ps();
1263 fix1 = _mm256_setzero_ps();
1264 fiy1 = _mm256_setzero_ps();
1265 fiz1 = _mm256_setzero_ps();
1266 fix2 = _mm256_setzero_ps();
1267 fiy2 = _mm256_setzero_ps();
1268 fiz2 = _mm256_setzero_ps();
1270 /* Start inner kernel loop */
1271 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1274 /* Get j neighbor index, and coordinate index */
1276 jnrB = jjnr[jidx+1];
1277 jnrC = jjnr[jidx+2];
1278 jnrD = jjnr[jidx+3];
1279 jnrE = jjnr[jidx+4];
1280 jnrF = jjnr[jidx+5];
1281 jnrG = jjnr[jidx+6];
1282 jnrH = jjnr[jidx+7];
1283 j_coord_offsetA = DIM*jnrA;
1284 j_coord_offsetB = DIM*jnrB;
1285 j_coord_offsetC = DIM*jnrC;
1286 j_coord_offsetD = DIM*jnrD;
1287 j_coord_offsetE = DIM*jnrE;
1288 j_coord_offsetF = DIM*jnrF;
1289 j_coord_offsetG = DIM*jnrG;
1290 j_coord_offsetH = DIM*jnrH;
1292 /* load j atom coordinates */
1293 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1294 x+j_coord_offsetC,x+j_coord_offsetD,
1295 x+j_coord_offsetE,x+j_coord_offsetF,
1296 x+j_coord_offsetG,x+j_coord_offsetH,
1297 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1299 /* Calculate displacement vector */
1300 dx00 = _mm256_sub_ps(ix0,jx0);
1301 dy00 = _mm256_sub_ps(iy0,jy0);
1302 dz00 = _mm256_sub_ps(iz0,jz0);
1303 dx01 = _mm256_sub_ps(ix0,jx1);
1304 dy01 = _mm256_sub_ps(iy0,jy1);
1305 dz01 = _mm256_sub_ps(iz0,jz1);
1306 dx02 = _mm256_sub_ps(ix0,jx2);
1307 dy02 = _mm256_sub_ps(iy0,jy2);
1308 dz02 = _mm256_sub_ps(iz0,jz2);
1309 dx10 = _mm256_sub_ps(ix1,jx0);
1310 dy10 = _mm256_sub_ps(iy1,jy0);
1311 dz10 = _mm256_sub_ps(iz1,jz0);
1312 dx11 = _mm256_sub_ps(ix1,jx1);
1313 dy11 = _mm256_sub_ps(iy1,jy1);
1314 dz11 = _mm256_sub_ps(iz1,jz1);
1315 dx12 = _mm256_sub_ps(ix1,jx2);
1316 dy12 = _mm256_sub_ps(iy1,jy2);
1317 dz12 = _mm256_sub_ps(iz1,jz2);
1318 dx20 = _mm256_sub_ps(ix2,jx0);
1319 dy20 = _mm256_sub_ps(iy2,jy0);
1320 dz20 = _mm256_sub_ps(iz2,jz0);
1321 dx21 = _mm256_sub_ps(ix2,jx1);
1322 dy21 = _mm256_sub_ps(iy2,jy1);
1323 dz21 = _mm256_sub_ps(iz2,jz1);
1324 dx22 = _mm256_sub_ps(ix2,jx2);
1325 dy22 = _mm256_sub_ps(iy2,jy2);
1326 dz22 = _mm256_sub_ps(iz2,jz2);
1328 /* Calculate squared distance and things based on it */
1329 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1330 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1331 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1332 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1333 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1334 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1335 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1336 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1337 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1339 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1340 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1341 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1342 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1343 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1344 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1345 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1346 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1347 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1349 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1350 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1351 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1352 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1353 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1354 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1355 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1356 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1357 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1359 fjx0 = _mm256_setzero_ps();
1360 fjy0 = _mm256_setzero_ps();
1361 fjz0 = _mm256_setzero_ps();
1362 fjx1 = _mm256_setzero_ps();
1363 fjy1 = _mm256_setzero_ps();
1364 fjz1 = _mm256_setzero_ps();
1365 fjx2 = _mm256_setzero_ps();
1366 fjy2 = _mm256_setzero_ps();
1367 fjz2 = _mm256_setzero_ps();
1369 /**************************
1370 * CALCULATE INTERACTIONS *
1371 **************************/
1373 r00 = _mm256_mul_ps(rsq00,rinv00);
1375 /* Calculate table index by multiplying r with table scale and truncate to integer */
1376 rt = _mm256_mul_ps(r00,vftabscale);
1377 vfitab = _mm256_cvttps_epi32(rt);
1378 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1379 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1380 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1381 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1382 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1383 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1385 /* REACTION-FIELD ELECTROSTATICS */
1386 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1388 /* CUBIC SPLINE TABLE DISPERSION */
1389 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1390 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1391 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1392 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1393 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1394 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1395 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1396 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1397 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1398 Heps = _mm256_mul_ps(vfeps,H);
1399 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1400 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1401 fvdw6 = _mm256_mul_ps(c6_00,FF);
1403 /* CUBIC SPLINE TABLE REPULSION */
1404 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1405 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1406 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1407 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1408 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1409 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1410 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1411 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1412 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1413 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1414 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1415 Heps = _mm256_mul_ps(vfeps,H);
1416 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1417 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1418 fvdw12 = _mm256_mul_ps(c12_00,FF);
1419 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1421 fscal = _mm256_add_ps(felec,fvdw);
1423 /* Calculate temporary vectorial force */
1424 tx = _mm256_mul_ps(fscal,dx00);
1425 ty = _mm256_mul_ps(fscal,dy00);
1426 tz = _mm256_mul_ps(fscal,dz00);
1428 /* Update vectorial force */
1429 fix0 = _mm256_add_ps(fix0,tx);
1430 fiy0 = _mm256_add_ps(fiy0,ty);
1431 fiz0 = _mm256_add_ps(fiz0,tz);
1433 fjx0 = _mm256_add_ps(fjx0,tx);
1434 fjy0 = _mm256_add_ps(fjy0,ty);
1435 fjz0 = _mm256_add_ps(fjz0,tz);
1437 /**************************
1438 * CALCULATE INTERACTIONS *
1439 **************************/
1441 /* REACTION-FIELD ELECTROSTATICS */
1442 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1446 /* Calculate temporary vectorial force */
1447 tx = _mm256_mul_ps(fscal,dx01);
1448 ty = _mm256_mul_ps(fscal,dy01);
1449 tz = _mm256_mul_ps(fscal,dz01);
1451 /* Update vectorial force */
1452 fix0 = _mm256_add_ps(fix0,tx);
1453 fiy0 = _mm256_add_ps(fiy0,ty);
1454 fiz0 = _mm256_add_ps(fiz0,tz);
1456 fjx1 = _mm256_add_ps(fjx1,tx);
1457 fjy1 = _mm256_add_ps(fjy1,ty);
1458 fjz1 = _mm256_add_ps(fjz1,tz);
1460 /**************************
1461 * CALCULATE INTERACTIONS *
1462 **************************/
1464 /* REACTION-FIELD ELECTROSTATICS */
1465 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1469 /* Calculate temporary vectorial force */
1470 tx = _mm256_mul_ps(fscal,dx02);
1471 ty = _mm256_mul_ps(fscal,dy02);
1472 tz = _mm256_mul_ps(fscal,dz02);
1474 /* Update vectorial force */
1475 fix0 = _mm256_add_ps(fix0,tx);
1476 fiy0 = _mm256_add_ps(fiy0,ty);
1477 fiz0 = _mm256_add_ps(fiz0,tz);
1479 fjx2 = _mm256_add_ps(fjx2,tx);
1480 fjy2 = _mm256_add_ps(fjy2,ty);
1481 fjz2 = _mm256_add_ps(fjz2,tz);
1483 /**************************
1484 * CALCULATE INTERACTIONS *
1485 **************************/
1487 /* REACTION-FIELD ELECTROSTATICS */
1488 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1492 /* Calculate temporary vectorial force */
1493 tx = _mm256_mul_ps(fscal,dx10);
1494 ty = _mm256_mul_ps(fscal,dy10);
1495 tz = _mm256_mul_ps(fscal,dz10);
1497 /* Update vectorial force */
1498 fix1 = _mm256_add_ps(fix1,tx);
1499 fiy1 = _mm256_add_ps(fiy1,ty);
1500 fiz1 = _mm256_add_ps(fiz1,tz);
1502 fjx0 = _mm256_add_ps(fjx0,tx);
1503 fjy0 = _mm256_add_ps(fjy0,ty);
1504 fjz0 = _mm256_add_ps(fjz0,tz);
1506 /**************************
1507 * CALCULATE INTERACTIONS *
1508 **************************/
1510 /* REACTION-FIELD ELECTROSTATICS */
1511 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1515 /* Calculate temporary vectorial force */
1516 tx = _mm256_mul_ps(fscal,dx11);
1517 ty = _mm256_mul_ps(fscal,dy11);
1518 tz = _mm256_mul_ps(fscal,dz11);
1520 /* Update vectorial force */
1521 fix1 = _mm256_add_ps(fix1,tx);
1522 fiy1 = _mm256_add_ps(fiy1,ty);
1523 fiz1 = _mm256_add_ps(fiz1,tz);
1525 fjx1 = _mm256_add_ps(fjx1,tx);
1526 fjy1 = _mm256_add_ps(fjy1,ty);
1527 fjz1 = _mm256_add_ps(fjz1,tz);
1529 /**************************
1530 * CALCULATE INTERACTIONS *
1531 **************************/
1533 /* REACTION-FIELD ELECTROSTATICS */
1534 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1538 /* Calculate temporary vectorial force */
1539 tx = _mm256_mul_ps(fscal,dx12);
1540 ty = _mm256_mul_ps(fscal,dy12);
1541 tz = _mm256_mul_ps(fscal,dz12);
1543 /* Update vectorial force */
1544 fix1 = _mm256_add_ps(fix1,tx);
1545 fiy1 = _mm256_add_ps(fiy1,ty);
1546 fiz1 = _mm256_add_ps(fiz1,tz);
1548 fjx2 = _mm256_add_ps(fjx2,tx);
1549 fjy2 = _mm256_add_ps(fjy2,ty);
1550 fjz2 = _mm256_add_ps(fjz2,tz);
1552 /**************************
1553 * CALCULATE INTERACTIONS *
1554 **************************/
1556 /* REACTION-FIELD ELECTROSTATICS */
1557 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1561 /* Calculate temporary vectorial force */
1562 tx = _mm256_mul_ps(fscal,dx20);
1563 ty = _mm256_mul_ps(fscal,dy20);
1564 tz = _mm256_mul_ps(fscal,dz20);
1566 /* Update vectorial force */
1567 fix2 = _mm256_add_ps(fix2,tx);
1568 fiy2 = _mm256_add_ps(fiy2,ty);
1569 fiz2 = _mm256_add_ps(fiz2,tz);
1571 fjx0 = _mm256_add_ps(fjx0,tx);
1572 fjy0 = _mm256_add_ps(fjy0,ty);
1573 fjz0 = _mm256_add_ps(fjz0,tz);
1575 /**************************
1576 * CALCULATE INTERACTIONS *
1577 **************************/
1579 /* REACTION-FIELD ELECTROSTATICS */
1580 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1584 /* Calculate temporary vectorial force */
1585 tx = _mm256_mul_ps(fscal,dx21);
1586 ty = _mm256_mul_ps(fscal,dy21);
1587 tz = _mm256_mul_ps(fscal,dz21);
1589 /* Update vectorial force */
1590 fix2 = _mm256_add_ps(fix2,tx);
1591 fiy2 = _mm256_add_ps(fiy2,ty);
1592 fiz2 = _mm256_add_ps(fiz2,tz);
1594 fjx1 = _mm256_add_ps(fjx1,tx);
1595 fjy1 = _mm256_add_ps(fjy1,ty);
1596 fjz1 = _mm256_add_ps(fjz1,tz);
1598 /**************************
1599 * CALCULATE INTERACTIONS *
1600 **************************/
1602 /* REACTION-FIELD ELECTROSTATICS */
1603 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1607 /* Calculate temporary vectorial force */
1608 tx = _mm256_mul_ps(fscal,dx22);
1609 ty = _mm256_mul_ps(fscal,dy22);
1610 tz = _mm256_mul_ps(fscal,dz22);
1612 /* Update vectorial force */
1613 fix2 = _mm256_add_ps(fix2,tx);
1614 fiy2 = _mm256_add_ps(fiy2,ty);
1615 fiz2 = _mm256_add_ps(fiz2,tz);
1617 fjx2 = _mm256_add_ps(fjx2,tx);
1618 fjy2 = _mm256_add_ps(fjy2,ty);
1619 fjz2 = _mm256_add_ps(fjz2,tz);
1621 fjptrA = f+j_coord_offsetA;
1622 fjptrB = f+j_coord_offsetB;
1623 fjptrC = f+j_coord_offsetC;
1624 fjptrD = f+j_coord_offsetD;
1625 fjptrE = f+j_coord_offsetE;
1626 fjptrF = f+j_coord_offsetF;
1627 fjptrG = f+j_coord_offsetG;
1628 fjptrH = f+j_coord_offsetH;
1630 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1631 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1633 /* Inner loop uses 270 flops */
1636 if(jidx<j_index_end)
1639 /* Get j neighbor index, and coordinate index */
1640 jnrlistA = jjnr[jidx];
1641 jnrlistB = jjnr[jidx+1];
1642 jnrlistC = jjnr[jidx+2];
1643 jnrlistD = jjnr[jidx+3];
1644 jnrlistE = jjnr[jidx+4];
1645 jnrlistF = jjnr[jidx+5];
1646 jnrlistG = jjnr[jidx+6];
1647 jnrlistH = jjnr[jidx+7];
1648 /* Sign of each element will be negative for non-real atoms.
1649 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1650 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1652 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1653 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1655 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1656 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1657 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1658 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1659 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1660 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1661 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1662 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1663 j_coord_offsetA = DIM*jnrA;
1664 j_coord_offsetB = DIM*jnrB;
1665 j_coord_offsetC = DIM*jnrC;
1666 j_coord_offsetD = DIM*jnrD;
1667 j_coord_offsetE = DIM*jnrE;
1668 j_coord_offsetF = DIM*jnrF;
1669 j_coord_offsetG = DIM*jnrG;
1670 j_coord_offsetH = DIM*jnrH;
1672 /* load j atom coordinates */
1673 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1674 x+j_coord_offsetC,x+j_coord_offsetD,
1675 x+j_coord_offsetE,x+j_coord_offsetF,
1676 x+j_coord_offsetG,x+j_coord_offsetH,
1677 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1679 /* Calculate displacement vector */
1680 dx00 = _mm256_sub_ps(ix0,jx0);
1681 dy00 = _mm256_sub_ps(iy0,jy0);
1682 dz00 = _mm256_sub_ps(iz0,jz0);
1683 dx01 = _mm256_sub_ps(ix0,jx1);
1684 dy01 = _mm256_sub_ps(iy0,jy1);
1685 dz01 = _mm256_sub_ps(iz0,jz1);
1686 dx02 = _mm256_sub_ps(ix0,jx2);
1687 dy02 = _mm256_sub_ps(iy0,jy2);
1688 dz02 = _mm256_sub_ps(iz0,jz2);
1689 dx10 = _mm256_sub_ps(ix1,jx0);
1690 dy10 = _mm256_sub_ps(iy1,jy0);
1691 dz10 = _mm256_sub_ps(iz1,jz0);
1692 dx11 = _mm256_sub_ps(ix1,jx1);
1693 dy11 = _mm256_sub_ps(iy1,jy1);
1694 dz11 = _mm256_sub_ps(iz1,jz1);
1695 dx12 = _mm256_sub_ps(ix1,jx2);
1696 dy12 = _mm256_sub_ps(iy1,jy2);
1697 dz12 = _mm256_sub_ps(iz1,jz2);
1698 dx20 = _mm256_sub_ps(ix2,jx0);
1699 dy20 = _mm256_sub_ps(iy2,jy0);
1700 dz20 = _mm256_sub_ps(iz2,jz0);
1701 dx21 = _mm256_sub_ps(ix2,jx1);
1702 dy21 = _mm256_sub_ps(iy2,jy1);
1703 dz21 = _mm256_sub_ps(iz2,jz1);
1704 dx22 = _mm256_sub_ps(ix2,jx2);
1705 dy22 = _mm256_sub_ps(iy2,jy2);
1706 dz22 = _mm256_sub_ps(iz2,jz2);
1708 /* Calculate squared distance and things based on it */
1709 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1710 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1711 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1712 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1713 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1714 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1715 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1716 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1717 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1719 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1720 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1721 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1722 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1723 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1724 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1725 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1726 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1727 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1729 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1730 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1731 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1732 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1733 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1734 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1735 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1736 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1737 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1739 fjx0 = _mm256_setzero_ps();
1740 fjy0 = _mm256_setzero_ps();
1741 fjz0 = _mm256_setzero_ps();
1742 fjx1 = _mm256_setzero_ps();
1743 fjy1 = _mm256_setzero_ps();
1744 fjz1 = _mm256_setzero_ps();
1745 fjx2 = _mm256_setzero_ps();
1746 fjy2 = _mm256_setzero_ps();
1747 fjz2 = _mm256_setzero_ps();
1749 /**************************
1750 * CALCULATE INTERACTIONS *
1751 **************************/
1753 r00 = _mm256_mul_ps(rsq00,rinv00);
1754 r00 = _mm256_andnot_ps(dummy_mask,r00);
1756 /* Calculate table index by multiplying r with table scale and truncate to integer */
1757 rt = _mm256_mul_ps(r00,vftabscale);
1758 vfitab = _mm256_cvttps_epi32(rt);
1759 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1760 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1761 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1762 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1763 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1764 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1766 /* REACTION-FIELD ELECTROSTATICS */
1767 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1769 /* CUBIC SPLINE TABLE DISPERSION */
1770 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1771 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1772 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1773 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1774 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1775 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1776 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1777 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1778 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1779 Heps = _mm256_mul_ps(vfeps,H);
1780 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1781 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1782 fvdw6 = _mm256_mul_ps(c6_00,FF);
1784 /* CUBIC SPLINE TABLE REPULSION */
1785 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1786 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1787 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1788 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1789 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1790 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1791 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1792 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1793 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1794 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1795 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1796 Heps = _mm256_mul_ps(vfeps,H);
1797 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1798 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1799 fvdw12 = _mm256_mul_ps(c12_00,FF);
1800 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1802 fscal = _mm256_add_ps(felec,fvdw);
1804 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1806 /* Calculate temporary vectorial force */
1807 tx = _mm256_mul_ps(fscal,dx00);
1808 ty = _mm256_mul_ps(fscal,dy00);
1809 tz = _mm256_mul_ps(fscal,dz00);
1811 /* Update vectorial force */
1812 fix0 = _mm256_add_ps(fix0,tx);
1813 fiy0 = _mm256_add_ps(fiy0,ty);
1814 fiz0 = _mm256_add_ps(fiz0,tz);
1816 fjx0 = _mm256_add_ps(fjx0,tx);
1817 fjy0 = _mm256_add_ps(fjy0,ty);
1818 fjz0 = _mm256_add_ps(fjz0,tz);
1820 /**************************
1821 * CALCULATE INTERACTIONS *
1822 **************************/
1824 /* REACTION-FIELD ELECTROSTATICS */
1825 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1829 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1831 /* Calculate temporary vectorial force */
1832 tx = _mm256_mul_ps(fscal,dx01);
1833 ty = _mm256_mul_ps(fscal,dy01);
1834 tz = _mm256_mul_ps(fscal,dz01);
1836 /* Update vectorial force */
1837 fix0 = _mm256_add_ps(fix0,tx);
1838 fiy0 = _mm256_add_ps(fiy0,ty);
1839 fiz0 = _mm256_add_ps(fiz0,tz);
1841 fjx1 = _mm256_add_ps(fjx1,tx);
1842 fjy1 = _mm256_add_ps(fjy1,ty);
1843 fjz1 = _mm256_add_ps(fjz1,tz);
1845 /**************************
1846 * CALCULATE INTERACTIONS *
1847 **************************/
1849 /* REACTION-FIELD ELECTROSTATICS */
1850 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1854 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1856 /* Calculate temporary vectorial force */
1857 tx = _mm256_mul_ps(fscal,dx02);
1858 ty = _mm256_mul_ps(fscal,dy02);
1859 tz = _mm256_mul_ps(fscal,dz02);
1861 /* Update vectorial force */
1862 fix0 = _mm256_add_ps(fix0,tx);
1863 fiy0 = _mm256_add_ps(fiy0,ty);
1864 fiz0 = _mm256_add_ps(fiz0,tz);
1866 fjx2 = _mm256_add_ps(fjx2,tx);
1867 fjy2 = _mm256_add_ps(fjy2,ty);
1868 fjz2 = _mm256_add_ps(fjz2,tz);
1870 /**************************
1871 * CALCULATE INTERACTIONS *
1872 **************************/
1874 /* REACTION-FIELD ELECTROSTATICS */
1875 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1879 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1881 /* Calculate temporary vectorial force */
1882 tx = _mm256_mul_ps(fscal,dx10);
1883 ty = _mm256_mul_ps(fscal,dy10);
1884 tz = _mm256_mul_ps(fscal,dz10);
1886 /* Update vectorial force */
1887 fix1 = _mm256_add_ps(fix1,tx);
1888 fiy1 = _mm256_add_ps(fiy1,ty);
1889 fiz1 = _mm256_add_ps(fiz1,tz);
1891 fjx0 = _mm256_add_ps(fjx0,tx);
1892 fjy0 = _mm256_add_ps(fjy0,ty);
1893 fjz0 = _mm256_add_ps(fjz0,tz);
1895 /**************************
1896 * CALCULATE INTERACTIONS *
1897 **************************/
1899 /* REACTION-FIELD ELECTROSTATICS */
1900 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1904 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1906 /* Calculate temporary vectorial force */
1907 tx = _mm256_mul_ps(fscal,dx11);
1908 ty = _mm256_mul_ps(fscal,dy11);
1909 tz = _mm256_mul_ps(fscal,dz11);
1911 /* Update vectorial force */
1912 fix1 = _mm256_add_ps(fix1,tx);
1913 fiy1 = _mm256_add_ps(fiy1,ty);
1914 fiz1 = _mm256_add_ps(fiz1,tz);
1916 fjx1 = _mm256_add_ps(fjx1,tx);
1917 fjy1 = _mm256_add_ps(fjy1,ty);
1918 fjz1 = _mm256_add_ps(fjz1,tz);
1920 /**************************
1921 * CALCULATE INTERACTIONS *
1922 **************************/
1924 /* REACTION-FIELD ELECTROSTATICS */
1925 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1929 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1931 /* Calculate temporary vectorial force */
1932 tx = _mm256_mul_ps(fscal,dx12);
1933 ty = _mm256_mul_ps(fscal,dy12);
1934 tz = _mm256_mul_ps(fscal,dz12);
1936 /* Update vectorial force */
1937 fix1 = _mm256_add_ps(fix1,tx);
1938 fiy1 = _mm256_add_ps(fiy1,ty);
1939 fiz1 = _mm256_add_ps(fiz1,tz);
1941 fjx2 = _mm256_add_ps(fjx2,tx);
1942 fjy2 = _mm256_add_ps(fjy2,ty);
1943 fjz2 = _mm256_add_ps(fjz2,tz);
1945 /**************************
1946 * CALCULATE INTERACTIONS *
1947 **************************/
1949 /* REACTION-FIELD ELECTROSTATICS */
1950 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1954 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1956 /* Calculate temporary vectorial force */
1957 tx = _mm256_mul_ps(fscal,dx20);
1958 ty = _mm256_mul_ps(fscal,dy20);
1959 tz = _mm256_mul_ps(fscal,dz20);
1961 /* Update vectorial force */
1962 fix2 = _mm256_add_ps(fix2,tx);
1963 fiy2 = _mm256_add_ps(fiy2,ty);
1964 fiz2 = _mm256_add_ps(fiz2,tz);
1966 fjx0 = _mm256_add_ps(fjx0,tx);
1967 fjy0 = _mm256_add_ps(fjy0,ty);
1968 fjz0 = _mm256_add_ps(fjz0,tz);
1970 /**************************
1971 * CALCULATE INTERACTIONS *
1972 **************************/
1974 /* REACTION-FIELD ELECTROSTATICS */
1975 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1979 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1981 /* Calculate temporary vectorial force */
1982 tx = _mm256_mul_ps(fscal,dx21);
1983 ty = _mm256_mul_ps(fscal,dy21);
1984 tz = _mm256_mul_ps(fscal,dz21);
1986 /* Update vectorial force */
1987 fix2 = _mm256_add_ps(fix2,tx);
1988 fiy2 = _mm256_add_ps(fiy2,ty);
1989 fiz2 = _mm256_add_ps(fiz2,tz);
1991 fjx1 = _mm256_add_ps(fjx1,tx);
1992 fjy1 = _mm256_add_ps(fjy1,ty);
1993 fjz1 = _mm256_add_ps(fjz1,tz);
1995 /**************************
1996 * CALCULATE INTERACTIONS *
1997 **************************/
1999 /* REACTION-FIELD ELECTROSTATICS */
2000 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2004 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2006 /* Calculate temporary vectorial force */
2007 tx = _mm256_mul_ps(fscal,dx22);
2008 ty = _mm256_mul_ps(fscal,dy22);
2009 tz = _mm256_mul_ps(fscal,dz22);
2011 /* Update vectorial force */
2012 fix2 = _mm256_add_ps(fix2,tx);
2013 fiy2 = _mm256_add_ps(fiy2,ty);
2014 fiz2 = _mm256_add_ps(fiz2,tz);
2016 fjx2 = _mm256_add_ps(fjx2,tx);
2017 fjy2 = _mm256_add_ps(fjy2,ty);
2018 fjz2 = _mm256_add_ps(fjz2,tz);
2020 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2021 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2022 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2023 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2024 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2025 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2026 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2027 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2029 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2030 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2032 /* Inner loop uses 271 flops */
2035 /* End of innermost loop */
2037 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2038 f+i_coord_offset,fshift+i_shift_offset);
2040 /* Increment number of inner iterations */
2041 inneriter += j_index_end - j_index_start;
2043 /* Outer loop uses 18 flops */
2046 /* Increment number of outer iterations */
2049 /* Update outer/inner flops */
2051 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*271);