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.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.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_ElecCoul_VdwCSTab_GeomW3W3_VF_avx_256_single
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: CubicSplineTable
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_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 nvdwtype = fr->ntype;
141 vdwtype = mdatoms->typeA;
143 vftab = kernel_data->table_vdw->data;
144 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
146 /* Setup water-specific parameters */
147 inr = nlist->iinr[0];
148 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
149 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
150 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
151 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
153 jq0 = _mm256_set1_ps(charge[inr+0]);
154 jq1 = _mm256_set1_ps(charge[inr+1]);
155 jq2 = _mm256_set1_ps(charge[inr+2]);
156 vdwjidx0A = 2*vdwtype[inr+0];
157 qq00 = _mm256_mul_ps(iq0,jq0);
158 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
159 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
160 qq01 = _mm256_mul_ps(iq0,jq1);
161 qq02 = _mm256_mul_ps(iq0,jq2);
162 qq10 = _mm256_mul_ps(iq1,jq0);
163 qq11 = _mm256_mul_ps(iq1,jq1);
164 qq12 = _mm256_mul_ps(iq1,jq2);
165 qq20 = _mm256_mul_ps(iq2,jq0);
166 qq21 = _mm256_mul_ps(iq2,jq1);
167 qq22 = _mm256_mul_ps(iq2,jq2);
169 /* Avoid stupid compiler warnings */
170 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
183 for(iidx=0;iidx<4*DIM;iidx++)
188 /* Start outer loop over neighborlists */
189 for(iidx=0; iidx<nri; iidx++)
191 /* Load shift vector for this list */
192 i_shift_offset = DIM*shiftidx[iidx];
194 /* Load limits for loop over neighbors */
195 j_index_start = jindex[iidx];
196 j_index_end = jindex[iidx+1];
198 /* Get outer coordinate index */
200 i_coord_offset = DIM*inr;
202 /* Load i particle coords and add shift vector */
203 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
204 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
206 fix0 = _mm256_setzero_ps();
207 fiy0 = _mm256_setzero_ps();
208 fiz0 = _mm256_setzero_ps();
209 fix1 = _mm256_setzero_ps();
210 fiy1 = _mm256_setzero_ps();
211 fiz1 = _mm256_setzero_ps();
212 fix2 = _mm256_setzero_ps();
213 fiy2 = _mm256_setzero_ps();
214 fiz2 = _mm256_setzero_ps();
216 /* Reset potential sums */
217 velecsum = _mm256_setzero_ps();
218 vvdwsum = _mm256_setzero_ps();
220 /* Start inner kernel loop */
221 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
224 /* Get j neighbor index, and coordinate index */
233 j_coord_offsetA = DIM*jnrA;
234 j_coord_offsetB = DIM*jnrB;
235 j_coord_offsetC = DIM*jnrC;
236 j_coord_offsetD = DIM*jnrD;
237 j_coord_offsetE = DIM*jnrE;
238 j_coord_offsetF = DIM*jnrF;
239 j_coord_offsetG = DIM*jnrG;
240 j_coord_offsetH = DIM*jnrH;
242 /* load j atom coordinates */
243 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
244 x+j_coord_offsetC,x+j_coord_offsetD,
245 x+j_coord_offsetE,x+j_coord_offsetF,
246 x+j_coord_offsetG,x+j_coord_offsetH,
247 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
249 /* Calculate displacement vector */
250 dx00 = _mm256_sub_ps(ix0,jx0);
251 dy00 = _mm256_sub_ps(iy0,jy0);
252 dz00 = _mm256_sub_ps(iz0,jz0);
253 dx01 = _mm256_sub_ps(ix0,jx1);
254 dy01 = _mm256_sub_ps(iy0,jy1);
255 dz01 = _mm256_sub_ps(iz0,jz1);
256 dx02 = _mm256_sub_ps(ix0,jx2);
257 dy02 = _mm256_sub_ps(iy0,jy2);
258 dz02 = _mm256_sub_ps(iz0,jz2);
259 dx10 = _mm256_sub_ps(ix1,jx0);
260 dy10 = _mm256_sub_ps(iy1,jy0);
261 dz10 = _mm256_sub_ps(iz1,jz0);
262 dx11 = _mm256_sub_ps(ix1,jx1);
263 dy11 = _mm256_sub_ps(iy1,jy1);
264 dz11 = _mm256_sub_ps(iz1,jz1);
265 dx12 = _mm256_sub_ps(ix1,jx2);
266 dy12 = _mm256_sub_ps(iy1,jy2);
267 dz12 = _mm256_sub_ps(iz1,jz2);
268 dx20 = _mm256_sub_ps(ix2,jx0);
269 dy20 = _mm256_sub_ps(iy2,jy0);
270 dz20 = _mm256_sub_ps(iz2,jz0);
271 dx21 = _mm256_sub_ps(ix2,jx1);
272 dy21 = _mm256_sub_ps(iy2,jy1);
273 dz21 = _mm256_sub_ps(iz2,jz1);
274 dx22 = _mm256_sub_ps(ix2,jx2);
275 dy22 = _mm256_sub_ps(iy2,jy2);
276 dz22 = _mm256_sub_ps(iz2,jz2);
278 /* Calculate squared distance and things based on it */
279 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
280 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
281 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
282 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
283 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
284 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
285 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
286 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
287 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
289 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
290 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
291 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
292 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
293 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
294 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
295 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
296 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
297 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
299 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
300 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
301 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
302 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
303 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
304 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
305 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
306 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
307 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
309 fjx0 = _mm256_setzero_ps();
310 fjy0 = _mm256_setzero_ps();
311 fjz0 = _mm256_setzero_ps();
312 fjx1 = _mm256_setzero_ps();
313 fjy1 = _mm256_setzero_ps();
314 fjz1 = _mm256_setzero_ps();
315 fjx2 = _mm256_setzero_ps();
316 fjy2 = _mm256_setzero_ps();
317 fjz2 = _mm256_setzero_ps();
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
323 r00 = _mm256_mul_ps(rsq00,rinv00);
325 /* Calculate table index by multiplying r with table scale and truncate to integer */
326 rt = _mm256_mul_ps(r00,vftabscale);
327 vfitab = _mm256_cvttps_epi32(rt);
328 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
329 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
330 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
331 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
332 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
333 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
335 /* COULOMB ELECTROSTATICS */
336 velec = _mm256_mul_ps(qq00,rinv00);
337 felec = _mm256_mul_ps(velec,rinvsq00);
339 /* CUBIC SPLINE TABLE DISPERSION */
340 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
341 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
342 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
343 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
344 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
345 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
346 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
347 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
348 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
349 Heps = _mm256_mul_ps(vfeps,H);
350 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
351 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
352 vvdw6 = _mm256_mul_ps(c6_00,VV);
353 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
354 fvdw6 = _mm256_mul_ps(c6_00,FF);
356 /* CUBIC SPLINE TABLE REPULSION */
357 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
358 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
359 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
360 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
361 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
362 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
363 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
364 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
365 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
366 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
367 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
368 Heps = _mm256_mul_ps(vfeps,H);
369 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
370 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
371 vvdw12 = _mm256_mul_ps(c12_00,VV);
372 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
373 fvdw12 = _mm256_mul_ps(c12_00,FF);
374 vvdw = _mm256_add_ps(vvdw12,vvdw6);
375 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
377 /* Update potential sum for this i atom from the interaction with this j atom. */
378 velecsum = _mm256_add_ps(velecsum,velec);
379 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
381 fscal = _mm256_add_ps(felec,fvdw);
383 /* Calculate temporary vectorial force */
384 tx = _mm256_mul_ps(fscal,dx00);
385 ty = _mm256_mul_ps(fscal,dy00);
386 tz = _mm256_mul_ps(fscal,dz00);
388 /* Update vectorial force */
389 fix0 = _mm256_add_ps(fix0,tx);
390 fiy0 = _mm256_add_ps(fiy0,ty);
391 fiz0 = _mm256_add_ps(fiz0,tz);
393 fjx0 = _mm256_add_ps(fjx0,tx);
394 fjy0 = _mm256_add_ps(fjy0,ty);
395 fjz0 = _mm256_add_ps(fjz0,tz);
397 /**************************
398 * CALCULATE INTERACTIONS *
399 **************************/
401 /* COULOMB ELECTROSTATICS */
402 velec = _mm256_mul_ps(qq01,rinv01);
403 felec = _mm256_mul_ps(velec,rinvsq01);
405 /* Update potential sum for this i atom from the interaction with this j atom. */
406 velecsum = _mm256_add_ps(velecsum,velec);
410 /* Calculate temporary vectorial force */
411 tx = _mm256_mul_ps(fscal,dx01);
412 ty = _mm256_mul_ps(fscal,dy01);
413 tz = _mm256_mul_ps(fscal,dz01);
415 /* Update vectorial force */
416 fix0 = _mm256_add_ps(fix0,tx);
417 fiy0 = _mm256_add_ps(fiy0,ty);
418 fiz0 = _mm256_add_ps(fiz0,tz);
420 fjx1 = _mm256_add_ps(fjx1,tx);
421 fjy1 = _mm256_add_ps(fjy1,ty);
422 fjz1 = _mm256_add_ps(fjz1,tz);
424 /**************************
425 * CALCULATE INTERACTIONS *
426 **************************/
428 /* COULOMB ELECTROSTATICS */
429 velec = _mm256_mul_ps(qq02,rinv02);
430 felec = _mm256_mul_ps(velec,rinvsq02);
432 /* Update potential sum for this i atom from the interaction with this j atom. */
433 velecsum = _mm256_add_ps(velecsum,velec);
437 /* Calculate temporary vectorial force */
438 tx = _mm256_mul_ps(fscal,dx02);
439 ty = _mm256_mul_ps(fscal,dy02);
440 tz = _mm256_mul_ps(fscal,dz02);
442 /* Update vectorial force */
443 fix0 = _mm256_add_ps(fix0,tx);
444 fiy0 = _mm256_add_ps(fiy0,ty);
445 fiz0 = _mm256_add_ps(fiz0,tz);
447 fjx2 = _mm256_add_ps(fjx2,tx);
448 fjy2 = _mm256_add_ps(fjy2,ty);
449 fjz2 = _mm256_add_ps(fjz2,tz);
451 /**************************
452 * CALCULATE INTERACTIONS *
453 **************************/
455 /* COULOMB ELECTROSTATICS */
456 velec = _mm256_mul_ps(qq10,rinv10);
457 felec = _mm256_mul_ps(velec,rinvsq10);
459 /* Update potential sum for this i atom from the interaction with this j atom. */
460 velecsum = _mm256_add_ps(velecsum,velec);
464 /* Calculate temporary vectorial force */
465 tx = _mm256_mul_ps(fscal,dx10);
466 ty = _mm256_mul_ps(fscal,dy10);
467 tz = _mm256_mul_ps(fscal,dz10);
469 /* Update vectorial force */
470 fix1 = _mm256_add_ps(fix1,tx);
471 fiy1 = _mm256_add_ps(fiy1,ty);
472 fiz1 = _mm256_add_ps(fiz1,tz);
474 fjx0 = _mm256_add_ps(fjx0,tx);
475 fjy0 = _mm256_add_ps(fjy0,ty);
476 fjz0 = _mm256_add_ps(fjz0,tz);
478 /**************************
479 * CALCULATE INTERACTIONS *
480 **************************/
482 /* COULOMB ELECTROSTATICS */
483 velec = _mm256_mul_ps(qq11,rinv11);
484 felec = _mm256_mul_ps(velec,rinvsq11);
486 /* Update potential sum for this i atom from the interaction with this j atom. */
487 velecsum = _mm256_add_ps(velecsum,velec);
491 /* Calculate temporary vectorial force */
492 tx = _mm256_mul_ps(fscal,dx11);
493 ty = _mm256_mul_ps(fscal,dy11);
494 tz = _mm256_mul_ps(fscal,dz11);
496 /* Update vectorial force */
497 fix1 = _mm256_add_ps(fix1,tx);
498 fiy1 = _mm256_add_ps(fiy1,ty);
499 fiz1 = _mm256_add_ps(fiz1,tz);
501 fjx1 = _mm256_add_ps(fjx1,tx);
502 fjy1 = _mm256_add_ps(fjy1,ty);
503 fjz1 = _mm256_add_ps(fjz1,tz);
505 /**************************
506 * CALCULATE INTERACTIONS *
507 **************************/
509 /* COULOMB ELECTROSTATICS */
510 velec = _mm256_mul_ps(qq12,rinv12);
511 felec = _mm256_mul_ps(velec,rinvsq12);
513 /* Update potential sum for this i atom from the interaction with this j atom. */
514 velecsum = _mm256_add_ps(velecsum,velec);
518 /* Calculate temporary vectorial force */
519 tx = _mm256_mul_ps(fscal,dx12);
520 ty = _mm256_mul_ps(fscal,dy12);
521 tz = _mm256_mul_ps(fscal,dz12);
523 /* Update vectorial force */
524 fix1 = _mm256_add_ps(fix1,tx);
525 fiy1 = _mm256_add_ps(fiy1,ty);
526 fiz1 = _mm256_add_ps(fiz1,tz);
528 fjx2 = _mm256_add_ps(fjx2,tx);
529 fjy2 = _mm256_add_ps(fjy2,ty);
530 fjz2 = _mm256_add_ps(fjz2,tz);
532 /**************************
533 * CALCULATE INTERACTIONS *
534 **************************/
536 /* COULOMB ELECTROSTATICS */
537 velec = _mm256_mul_ps(qq20,rinv20);
538 felec = _mm256_mul_ps(velec,rinvsq20);
540 /* Update potential sum for this i atom from the interaction with this j atom. */
541 velecsum = _mm256_add_ps(velecsum,velec);
545 /* Calculate temporary vectorial force */
546 tx = _mm256_mul_ps(fscal,dx20);
547 ty = _mm256_mul_ps(fscal,dy20);
548 tz = _mm256_mul_ps(fscal,dz20);
550 /* Update vectorial force */
551 fix2 = _mm256_add_ps(fix2,tx);
552 fiy2 = _mm256_add_ps(fiy2,ty);
553 fiz2 = _mm256_add_ps(fiz2,tz);
555 fjx0 = _mm256_add_ps(fjx0,tx);
556 fjy0 = _mm256_add_ps(fjy0,ty);
557 fjz0 = _mm256_add_ps(fjz0,tz);
559 /**************************
560 * CALCULATE INTERACTIONS *
561 **************************/
563 /* COULOMB ELECTROSTATICS */
564 velec = _mm256_mul_ps(qq21,rinv21);
565 felec = _mm256_mul_ps(velec,rinvsq21);
567 /* Update potential sum for this i atom from the interaction with this j atom. */
568 velecsum = _mm256_add_ps(velecsum,velec);
572 /* Calculate temporary vectorial force */
573 tx = _mm256_mul_ps(fscal,dx21);
574 ty = _mm256_mul_ps(fscal,dy21);
575 tz = _mm256_mul_ps(fscal,dz21);
577 /* Update vectorial force */
578 fix2 = _mm256_add_ps(fix2,tx);
579 fiy2 = _mm256_add_ps(fiy2,ty);
580 fiz2 = _mm256_add_ps(fiz2,tz);
582 fjx1 = _mm256_add_ps(fjx1,tx);
583 fjy1 = _mm256_add_ps(fjy1,ty);
584 fjz1 = _mm256_add_ps(fjz1,tz);
586 /**************************
587 * CALCULATE INTERACTIONS *
588 **************************/
590 /* COULOMB ELECTROSTATICS */
591 velec = _mm256_mul_ps(qq22,rinv22);
592 felec = _mm256_mul_ps(velec,rinvsq22);
594 /* Update potential sum for this i atom from the interaction with this j atom. */
595 velecsum = _mm256_add_ps(velecsum,velec);
599 /* Calculate temporary vectorial force */
600 tx = _mm256_mul_ps(fscal,dx22);
601 ty = _mm256_mul_ps(fscal,dy22);
602 tz = _mm256_mul_ps(fscal,dz22);
604 /* Update vectorial force */
605 fix2 = _mm256_add_ps(fix2,tx);
606 fiy2 = _mm256_add_ps(fiy2,ty);
607 fiz2 = _mm256_add_ps(fiz2,tz);
609 fjx2 = _mm256_add_ps(fjx2,tx);
610 fjy2 = _mm256_add_ps(fjy2,ty);
611 fjz2 = _mm256_add_ps(fjz2,tz);
613 fjptrA = f+j_coord_offsetA;
614 fjptrB = f+j_coord_offsetB;
615 fjptrC = f+j_coord_offsetC;
616 fjptrD = f+j_coord_offsetD;
617 fjptrE = f+j_coord_offsetE;
618 fjptrF = f+j_coord_offsetF;
619 fjptrG = f+j_coord_offsetG;
620 fjptrH = f+j_coord_offsetH;
622 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
623 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
625 /* Inner loop uses 278 flops */
631 /* Get j neighbor index, and coordinate index */
632 jnrlistA = jjnr[jidx];
633 jnrlistB = jjnr[jidx+1];
634 jnrlistC = jjnr[jidx+2];
635 jnrlistD = jjnr[jidx+3];
636 jnrlistE = jjnr[jidx+4];
637 jnrlistF = jjnr[jidx+5];
638 jnrlistG = jjnr[jidx+6];
639 jnrlistH = jjnr[jidx+7];
640 /* Sign of each element will be negative for non-real atoms.
641 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
642 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
644 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
645 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
647 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
648 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
649 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
650 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
651 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
652 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
653 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
654 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
655 j_coord_offsetA = DIM*jnrA;
656 j_coord_offsetB = DIM*jnrB;
657 j_coord_offsetC = DIM*jnrC;
658 j_coord_offsetD = DIM*jnrD;
659 j_coord_offsetE = DIM*jnrE;
660 j_coord_offsetF = DIM*jnrF;
661 j_coord_offsetG = DIM*jnrG;
662 j_coord_offsetH = DIM*jnrH;
664 /* load j atom coordinates */
665 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
666 x+j_coord_offsetC,x+j_coord_offsetD,
667 x+j_coord_offsetE,x+j_coord_offsetF,
668 x+j_coord_offsetG,x+j_coord_offsetH,
669 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
671 /* Calculate displacement vector */
672 dx00 = _mm256_sub_ps(ix0,jx0);
673 dy00 = _mm256_sub_ps(iy0,jy0);
674 dz00 = _mm256_sub_ps(iz0,jz0);
675 dx01 = _mm256_sub_ps(ix0,jx1);
676 dy01 = _mm256_sub_ps(iy0,jy1);
677 dz01 = _mm256_sub_ps(iz0,jz1);
678 dx02 = _mm256_sub_ps(ix0,jx2);
679 dy02 = _mm256_sub_ps(iy0,jy2);
680 dz02 = _mm256_sub_ps(iz0,jz2);
681 dx10 = _mm256_sub_ps(ix1,jx0);
682 dy10 = _mm256_sub_ps(iy1,jy0);
683 dz10 = _mm256_sub_ps(iz1,jz0);
684 dx11 = _mm256_sub_ps(ix1,jx1);
685 dy11 = _mm256_sub_ps(iy1,jy1);
686 dz11 = _mm256_sub_ps(iz1,jz1);
687 dx12 = _mm256_sub_ps(ix1,jx2);
688 dy12 = _mm256_sub_ps(iy1,jy2);
689 dz12 = _mm256_sub_ps(iz1,jz2);
690 dx20 = _mm256_sub_ps(ix2,jx0);
691 dy20 = _mm256_sub_ps(iy2,jy0);
692 dz20 = _mm256_sub_ps(iz2,jz0);
693 dx21 = _mm256_sub_ps(ix2,jx1);
694 dy21 = _mm256_sub_ps(iy2,jy1);
695 dz21 = _mm256_sub_ps(iz2,jz1);
696 dx22 = _mm256_sub_ps(ix2,jx2);
697 dy22 = _mm256_sub_ps(iy2,jy2);
698 dz22 = _mm256_sub_ps(iz2,jz2);
700 /* Calculate squared distance and things based on it */
701 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
702 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
703 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
704 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
705 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
706 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
707 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
708 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
709 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
711 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
712 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
713 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
714 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
715 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
716 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
717 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
718 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
719 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
721 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
722 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
723 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
724 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
725 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
726 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
727 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
728 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
729 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
731 fjx0 = _mm256_setzero_ps();
732 fjy0 = _mm256_setzero_ps();
733 fjz0 = _mm256_setzero_ps();
734 fjx1 = _mm256_setzero_ps();
735 fjy1 = _mm256_setzero_ps();
736 fjz1 = _mm256_setzero_ps();
737 fjx2 = _mm256_setzero_ps();
738 fjy2 = _mm256_setzero_ps();
739 fjz2 = _mm256_setzero_ps();
741 /**************************
742 * CALCULATE INTERACTIONS *
743 **************************/
745 r00 = _mm256_mul_ps(rsq00,rinv00);
746 r00 = _mm256_andnot_ps(dummy_mask,r00);
748 /* Calculate table index by multiplying r with table scale and truncate to integer */
749 rt = _mm256_mul_ps(r00,vftabscale);
750 vfitab = _mm256_cvttps_epi32(rt);
751 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
752 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
753 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
754 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
755 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
756 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
758 /* COULOMB ELECTROSTATICS */
759 velec = _mm256_mul_ps(qq00,rinv00);
760 felec = _mm256_mul_ps(velec,rinvsq00);
762 /* CUBIC SPLINE TABLE DISPERSION */
763 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
764 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
765 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
766 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
767 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
768 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
769 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
770 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
771 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
772 Heps = _mm256_mul_ps(vfeps,H);
773 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
774 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
775 vvdw6 = _mm256_mul_ps(c6_00,VV);
776 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
777 fvdw6 = _mm256_mul_ps(c6_00,FF);
779 /* CUBIC SPLINE TABLE REPULSION */
780 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
781 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
782 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
783 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
784 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
785 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
786 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
787 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
788 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
789 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
790 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
791 Heps = _mm256_mul_ps(vfeps,H);
792 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
793 VV = _mm256_add_ps(Y,_mm256_mul_ps(vfeps,Fp));
794 vvdw12 = _mm256_mul_ps(c12_00,VV);
795 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
796 fvdw12 = _mm256_mul_ps(c12_00,FF);
797 vvdw = _mm256_add_ps(vvdw12,vvdw6);
798 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
800 /* Update potential sum for this i atom from the interaction with this j atom. */
801 velec = _mm256_andnot_ps(dummy_mask,velec);
802 velecsum = _mm256_add_ps(velecsum,velec);
803 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
804 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
806 fscal = _mm256_add_ps(felec,fvdw);
808 fscal = _mm256_andnot_ps(dummy_mask,fscal);
810 /* Calculate temporary vectorial force */
811 tx = _mm256_mul_ps(fscal,dx00);
812 ty = _mm256_mul_ps(fscal,dy00);
813 tz = _mm256_mul_ps(fscal,dz00);
815 /* Update vectorial force */
816 fix0 = _mm256_add_ps(fix0,tx);
817 fiy0 = _mm256_add_ps(fiy0,ty);
818 fiz0 = _mm256_add_ps(fiz0,tz);
820 fjx0 = _mm256_add_ps(fjx0,tx);
821 fjy0 = _mm256_add_ps(fjy0,ty);
822 fjz0 = _mm256_add_ps(fjz0,tz);
824 /**************************
825 * CALCULATE INTERACTIONS *
826 **************************/
828 /* COULOMB ELECTROSTATICS */
829 velec = _mm256_mul_ps(qq01,rinv01);
830 felec = _mm256_mul_ps(velec,rinvsq01);
832 /* Update potential sum for this i atom from the interaction with this j atom. */
833 velec = _mm256_andnot_ps(dummy_mask,velec);
834 velecsum = _mm256_add_ps(velecsum,velec);
838 fscal = _mm256_andnot_ps(dummy_mask,fscal);
840 /* Calculate temporary vectorial force */
841 tx = _mm256_mul_ps(fscal,dx01);
842 ty = _mm256_mul_ps(fscal,dy01);
843 tz = _mm256_mul_ps(fscal,dz01);
845 /* Update vectorial force */
846 fix0 = _mm256_add_ps(fix0,tx);
847 fiy0 = _mm256_add_ps(fiy0,ty);
848 fiz0 = _mm256_add_ps(fiz0,tz);
850 fjx1 = _mm256_add_ps(fjx1,tx);
851 fjy1 = _mm256_add_ps(fjy1,ty);
852 fjz1 = _mm256_add_ps(fjz1,tz);
854 /**************************
855 * CALCULATE INTERACTIONS *
856 **************************/
858 /* COULOMB ELECTROSTATICS */
859 velec = _mm256_mul_ps(qq02,rinv02);
860 felec = _mm256_mul_ps(velec,rinvsq02);
862 /* Update potential sum for this i atom from the interaction with this j atom. */
863 velec = _mm256_andnot_ps(dummy_mask,velec);
864 velecsum = _mm256_add_ps(velecsum,velec);
868 fscal = _mm256_andnot_ps(dummy_mask,fscal);
870 /* Calculate temporary vectorial force */
871 tx = _mm256_mul_ps(fscal,dx02);
872 ty = _mm256_mul_ps(fscal,dy02);
873 tz = _mm256_mul_ps(fscal,dz02);
875 /* Update vectorial force */
876 fix0 = _mm256_add_ps(fix0,tx);
877 fiy0 = _mm256_add_ps(fiy0,ty);
878 fiz0 = _mm256_add_ps(fiz0,tz);
880 fjx2 = _mm256_add_ps(fjx2,tx);
881 fjy2 = _mm256_add_ps(fjy2,ty);
882 fjz2 = _mm256_add_ps(fjz2,tz);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 /* COULOMB ELECTROSTATICS */
889 velec = _mm256_mul_ps(qq10,rinv10);
890 felec = _mm256_mul_ps(velec,rinvsq10);
892 /* Update potential sum for this i atom from the interaction with this j atom. */
893 velec = _mm256_andnot_ps(dummy_mask,velec);
894 velecsum = _mm256_add_ps(velecsum,velec);
898 fscal = _mm256_andnot_ps(dummy_mask,fscal);
900 /* Calculate temporary vectorial force */
901 tx = _mm256_mul_ps(fscal,dx10);
902 ty = _mm256_mul_ps(fscal,dy10);
903 tz = _mm256_mul_ps(fscal,dz10);
905 /* Update vectorial force */
906 fix1 = _mm256_add_ps(fix1,tx);
907 fiy1 = _mm256_add_ps(fiy1,ty);
908 fiz1 = _mm256_add_ps(fiz1,tz);
910 fjx0 = _mm256_add_ps(fjx0,tx);
911 fjy0 = _mm256_add_ps(fjy0,ty);
912 fjz0 = _mm256_add_ps(fjz0,tz);
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
918 /* COULOMB ELECTROSTATICS */
919 velec = _mm256_mul_ps(qq11,rinv11);
920 felec = _mm256_mul_ps(velec,rinvsq11);
922 /* Update potential sum for this i atom from the interaction with this j atom. */
923 velec = _mm256_andnot_ps(dummy_mask,velec);
924 velecsum = _mm256_add_ps(velecsum,velec);
928 fscal = _mm256_andnot_ps(dummy_mask,fscal);
930 /* Calculate temporary vectorial force */
931 tx = _mm256_mul_ps(fscal,dx11);
932 ty = _mm256_mul_ps(fscal,dy11);
933 tz = _mm256_mul_ps(fscal,dz11);
935 /* Update vectorial force */
936 fix1 = _mm256_add_ps(fix1,tx);
937 fiy1 = _mm256_add_ps(fiy1,ty);
938 fiz1 = _mm256_add_ps(fiz1,tz);
940 fjx1 = _mm256_add_ps(fjx1,tx);
941 fjy1 = _mm256_add_ps(fjy1,ty);
942 fjz1 = _mm256_add_ps(fjz1,tz);
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
948 /* COULOMB ELECTROSTATICS */
949 velec = _mm256_mul_ps(qq12,rinv12);
950 felec = _mm256_mul_ps(velec,rinvsq12);
952 /* Update potential sum for this i atom from the interaction with this j atom. */
953 velec = _mm256_andnot_ps(dummy_mask,velec);
954 velecsum = _mm256_add_ps(velecsum,velec);
958 fscal = _mm256_andnot_ps(dummy_mask,fscal);
960 /* Calculate temporary vectorial force */
961 tx = _mm256_mul_ps(fscal,dx12);
962 ty = _mm256_mul_ps(fscal,dy12);
963 tz = _mm256_mul_ps(fscal,dz12);
965 /* Update vectorial force */
966 fix1 = _mm256_add_ps(fix1,tx);
967 fiy1 = _mm256_add_ps(fiy1,ty);
968 fiz1 = _mm256_add_ps(fiz1,tz);
970 fjx2 = _mm256_add_ps(fjx2,tx);
971 fjy2 = _mm256_add_ps(fjy2,ty);
972 fjz2 = _mm256_add_ps(fjz2,tz);
974 /**************************
975 * CALCULATE INTERACTIONS *
976 **************************/
978 /* COULOMB ELECTROSTATICS */
979 velec = _mm256_mul_ps(qq20,rinv20);
980 felec = _mm256_mul_ps(velec,rinvsq20);
982 /* Update potential sum for this i atom from the interaction with this j atom. */
983 velec = _mm256_andnot_ps(dummy_mask,velec);
984 velecsum = _mm256_add_ps(velecsum,velec);
988 fscal = _mm256_andnot_ps(dummy_mask,fscal);
990 /* Calculate temporary vectorial force */
991 tx = _mm256_mul_ps(fscal,dx20);
992 ty = _mm256_mul_ps(fscal,dy20);
993 tz = _mm256_mul_ps(fscal,dz20);
995 /* Update vectorial force */
996 fix2 = _mm256_add_ps(fix2,tx);
997 fiy2 = _mm256_add_ps(fiy2,ty);
998 fiz2 = _mm256_add_ps(fiz2,tz);
1000 fjx0 = _mm256_add_ps(fjx0,tx);
1001 fjy0 = _mm256_add_ps(fjy0,ty);
1002 fjz0 = _mm256_add_ps(fjz0,tz);
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1008 /* COULOMB ELECTROSTATICS */
1009 velec = _mm256_mul_ps(qq21,rinv21);
1010 felec = _mm256_mul_ps(velec,rinvsq21);
1012 /* Update potential sum for this i atom from the interaction with this j atom. */
1013 velec = _mm256_andnot_ps(dummy_mask,velec);
1014 velecsum = _mm256_add_ps(velecsum,velec);
1018 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1020 /* Calculate temporary vectorial force */
1021 tx = _mm256_mul_ps(fscal,dx21);
1022 ty = _mm256_mul_ps(fscal,dy21);
1023 tz = _mm256_mul_ps(fscal,dz21);
1025 /* Update vectorial force */
1026 fix2 = _mm256_add_ps(fix2,tx);
1027 fiy2 = _mm256_add_ps(fiy2,ty);
1028 fiz2 = _mm256_add_ps(fiz2,tz);
1030 fjx1 = _mm256_add_ps(fjx1,tx);
1031 fjy1 = _mm256_add_ps(fjy1,ty);
1032 fjz1 = _mm256_add_ps(fjz1,tz);
1034 /**************************
1035 * CALCULATE INTERACTIONS *
1036 **************************/
1038 /* COULOMB ELECTROSTATICS */
1039 velec = _mm256_mul_ps(qq22,rinv22);
1040 felec = _mm256_mul_ps(velec,rinvsq22);
1042 /* Update potential sum for this i atom from the interaction with this j atom. */
1043 velec = _mm256_andnot_ps(dummy_mask,velec);
1044 velecsum = _mm256_add_ps(velecsum,velec);
1048 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1050 /* Calculate temporary vectorial force */
1051 tx = _mm256_mul_ps(fscal,dx22);
1052 ty = _mm256_mul_ps(fscal,dy22);
1053 tz = _mm256_mul_ps(fscal,dz22);
1055 /* Update vectorial force */
1056 fix2 = _mm256_add_ps(fix2,tx);
1057 fiy2 = _mm256_add_ps(fiy2,ty);
1058 fiz2 = _mm256_add_ps(fiz2,tz);
1060 fjx2 = _mm256_add_ps(fjx2,tx);
1061 fjy2 = _mm256_add_ps(fjy2,ty);
1062 fjz2 = _mm256_add_ps(fjz2,tz);
1064 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1065 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1066 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1067 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1068 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1069 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1070 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1071 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1073 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1074 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1076 /* Inner loop uses 279 flops */
1079 /* End of innermost loop */
1081 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1082 f+i_coord_offset,fshift+i_shift_offset);
1085 /* Update potential energies */
1086 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1087 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1089 /* Increment number of inner iterations */
1090 inneriter += j_index_end - j_index_start;
1092 /* Outer loop uses 20 flops */
1095 /* Increment number of outer iterations */
1098 /* Update outer/inner flops */
1100 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*279);
1103 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_F_avx_256_single
1104 * Electrostatics interaction: Coulomb
1105 * VdW interaction: CubicSplineTable
1106 * Geometry: Water3-Water3
1107 * Calculate force/pot: Force
1110 nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_F_avx_256_single
1111 (t_nblist * gmx_restrict nlist,
1112 rvec * gmx_restrict xx,
1113 rvec * gmx_restrict ff,
1114 t_forcerec * gmx_restrict fr,
1115 t_mdatoms * gmx_restrict mdatoms,
1116 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1117 t_nrnb * gmx_restrict nrnb)
1119 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1120 * just 0 for non-waters.
1121 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1122 * jnr indices corresponding to data put in the four positions in the SIMD register.
1124 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1125 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1126 int jnrA,jnrB,jnrC,jnrD;
1127 int jnrE,jnrF,jnrG,jnrH;
1128 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1129 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1130 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1131 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1132 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1133 real rcutoff_scalar;
1134 real *shiftvec,*fshift,*x,*f;
1135 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1136 real scratch[4*DIM];
1137 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1138 real * vdwioffsetptr0;
1139 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1140 real * vdwioffsetptr1;
1141 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1142 real * vdwioffsetptr2;
1143 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1144 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1145 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1146 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1147 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1148 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1149 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1150 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1151 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1152 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1153 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1154 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1155 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1156 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1157 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1158 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1159 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1162 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1165 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
1166 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
1168 __m128i vfitab_lo,vfitab_hi;
1169 __m128i ifour = _mm_set1_epi32(4);
1170 __m256 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
1172 __m256 dummy_mask,cutoff_mask;
1173 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1174 __m256 one = _mm256_set1_ps(1.0);
1175 __m256 two = _mm256_set1_ps(2.0);
1181 jindex = nlist->jindex;
1183 shiftidx = nlist->shift;
1185 shiftvec = fr->shift_vec[0];
1186 fshift = fr->fshift[0];
1187 facel = _mm256_set1_ps(fr->epsfac);
1188 charge = mdatoms->chargeA;
1189 nvdwtype = fr->ntype;
1190 vdwparam = fr->nbfp;
1191 vdwtype = mdatoms->typeA;
1193 vftab = kernel_data->table_vdw->data;
1194 vftabscale = _mm256_set1_ps(kernel_data->table_vdw->scale);
1196 /* Setup water-specific parameters */
1197 inr = nlist->iinr[0];
1198 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
1199 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1200 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1201 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
1203 jq0 = _mm256_set1_ps(charge[inr+0]);
1204 jq1 = _mm256_set1_ps(charge[inr+1]);
1205 jq2 = _mm256_set1_ps(charge[inr+2]);
1206 vdwjidx0A = 2*vdwtype[inr+0];
1207 qq00 = _mm256_mul_ps(iq0,jq0);
1208 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1209 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1210 qq01 = _mm256_mul_ps(iq0,jq1);
1211 qq02 = _mm256_mul_ps(iq0,jq2);
1212 qq10 = _mm256_mul_ps(iq1,jq0);
1213 qq11 = _mm256_mul_ps(iq1,jq1);
1214 qq12 = _mm256_mul_ps(iq1,jq2);
1215 qq20 = _mm256_mul_ps(iq2,jq0);
1216 qq21 = _mm256_mul_ps(iq2,jq1);
1217 qq22 = _mm256_mul_ps(iq2,jq2);
1219 /* Avoid stupid compiler warnings */
1220 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1221 j_coord_offsetA = 0;
1222 j_coord_offsetB = 0;
1223 j_coord_offsetC = 0;
1224 j_coord_offsetD = 0;
1225 j_coord_offsetE = 0;
1226 j_coord_offsetF = 0;
1227 j_coord_offsetG = 0;
1228 j_coord_offsetH = 0;
1233 for(iidx=0;iidx<4*DIM;iidx++)
1235 scratch[iidx] = 0.0;
1238 /* Start outer loop over neighborlists */
1239 for(iidx=0; iidx<nri; iidx++)
1241 /* Load shift vector for this list */
1242 i_shift_offset = DIM*shiftidx[iidx];
1244 /* Load limits for loop over neighbors */
1245 j_index_start = jindex[iidx];
1246 j_index_end = jindex[iidx+1];
1248 /* Get outer coordinate index */
1250 i_coord_offset = DIM*inr;
1252 /* Load i particle coords and add shift vector */
1253 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1254 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1256 fix0 = _mm256_setzero_ps();
1257 fiy0 = _mm256_setzero_ps();
1258 fiz0 = _mm256_setzero_ps();
1259 fix1 = _mm256_setzero_ps();
1260 fiy1 = _mm256_setzero_ps();
1261 fiz1 = _mm256_setzero_ps();
1262 fix2 = _mm256_setzero_ps();
1263 fiy2 = _mm256_setzero_ps();
1264 fiz2 = _mm256_setzero_ps();
1266 /* Start inner kernel loop */
1267 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1270 /* Get j neighbor index, and coordinate index */
1272 jnrB = jjnr[jidx+1];
1273 jnrC = jjnr[jidx+2];
1274 jnrD = jjnr[jidx+3];
1275 jnrE = jjnr[jidx+4];
1276 jnrF = jjnr[jidx+5];
1277 jnrG = jjnr[jidx+6];
1278 jnrH = jjnr[jidx+7];
1279 j_coord_offsetA = DIM*jnrA;
1280 j_coord_offsetB = DIM*jnrB;
1281 j_coord_offsetC = DIM*jnrC;
1282 j_coord_offsetD = DIM*jnrD;
1283 j_coord_offsetE = DIM*jnrE;
1284 j_coord_offsetF = DIM*jnrF;
1285 j_coord_offsetG = DIM*jnrG;
1286 j_coord_offsetH = DIM*jnrH;
1288 /* load j atom coordinates */
1289 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1290 x+j_coord_offsetC,x+j_coord_offsetD,
1291 x+j_coord_offsetE,x+j_coord_offsetF,
1292 x+j_coord_offsetG,x+j_coord_offsetH,
1293 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1295 /* Calculate displacement vector */
1296 dx00 = _mm256_sub_ps(ix0,jx0);
1297 dy00 = _mm256_sub_ps(iy0,jy0);
1298 dz00 = _mm256_sub_ps(iz0,jz0);
1299 dx01 = _mm256_sub_ps(ix0,jx1);
1300 dy01 = _mm256_sub_ps(iy0,jy1);
1301 dz01 = _mm256_sub_ps(iz0,jz1);
1302 dx02 = _mm256_sub_ps(ix0,jx2);
1303 dy02 = _mm256_sub_ps(iy0,jy2);
1304 dz02 = _mm256_sub_ps(iz0,jz2);
1305 dx10 = _mm256_sub_ps(ix1,jx0);
1306 dy10 = _mm256_sub_ps(iy1,jy0);
1307 dz10 = _mm256_sub_ps(iz1,jz0);
1308 dx11 = _mm256_sub_ps(ix1,jx1);
1309 dy11 = _mm256_sub_ps(iy1,jy1);
1310 dz11 = _mm256_sub_ps(iz1,jz1);
1311 dx12 = _mm256_sub_ps(ix1,jx2);
1312 dy12 = _mm256_sub_ps(iy1,jy2);
1313 dz12 = _mm256_sub_ps(iz1,jz2);
1314 dx20 = _mm256_sub_ps(ix2,jx0);
1315 dy20 = _mm256_sub_ps(iy2,jy0);
1316 dz20 = _mm256_sub_ps(iz2,jz0);
1317 dx21 = _mm256_sub_ps(ix2,jx1);
1318 dy21 = _mm256_sub_ps(iy2,jy1);
1319 dz21 = _mm256_sub_ps(iz2,jz1);
1320 dx22 = _mm256_sub_ps(ix2,jx2);
1321 dy22 = _mm256_sub_ps(iy2,jy2);
1322 dz22 = _mm256_sub_ps(iz2,jz2);
1324 /* Calculate squared distance and things based on it */
1325 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1326 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1327 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1328 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1329 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1330 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1331 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1332 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1333 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1335 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1336 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1337 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1338 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1339 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1340 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1341 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1342 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1343 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1345 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1346 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1347 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1348 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1349 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1350 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1351 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1352 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1353 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1355 fjx0 = _mm256_setzero_ps();
1356 fjy0 = _mm256_setzero_ps();
1357 fjz0 = _mm256_setzero_ps();
1358 fjx1 = _mm256_setzero_ps();
1359 fjy1 = _mm256_setzero_ps();
1360 fjz1 = _mm256_setzero_ps();
1361 fjx2 = _mm256_setzero_ps();
1362 fjy2 = _mm256_setzero_ps();
1363 fjz2 = _mm256_setzero_ps();
1365 /**************************
1366 * CALCULATE INTERACTIONS *
1367 **************************/
1369 r00 = _mm256_mul_ps(rsq00,rinv00);
1371 /* Calculate table index by multiplying r with table scale and truncate to integer */
1372 rt = _mm256_mul_ps(r00,vftabscale);
1373 vfitab = _mm256_cvttps_epi32(rt);
1374 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1375 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1376 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1377 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1378 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1379 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1381 /* COULOMB ELECTROSTATICS */
1382 velec = _mm256_mul_ps(qq00,rinv00);
1383 felec = _mm256_mul_ps(velec,rinvsq00);
1385 /* CUBIC SPLINE TABLE DISPERSION */
1386 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1387 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1388 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1389 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1390 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1391 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1392 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1393 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1394 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1395 Heps = _mm256_mul_ps(vfeps,H);
1396 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1397 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1398 fvdw6 = _mm256_mul_ps(c6_00,FF);
1400 /* CUBIC SPLINE TABLE REPULSION */
1401 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1402 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1403 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1404 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1405 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1406 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1407 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1408 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1409 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1410 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1411 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1412 Heps = _mm256_mul_ps(vfeps,H);
1413 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1414 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1415 fvdw12 = _mm256_mul_ps(c12_00,FF);
1416 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1418 fscal = _mm256_add_ps(felec,fvdw);
1420 /* Calculate temporary vectorial force */
1421 tx = _mm256_mul_ps(fscal,dx00);
1422 ty = _mm256_mul_ps(fscal,dy00);
1423 tz = _mm256_mul_ps(fscal,dz00);
1425 /* Update vectorial force */
1426 fix0 = _mm256_add_ps(fix0,tx);
1427 fiy0 = _mm256_add_ps(fiy0,ty);
1428 fiz0 = _mm256_add_ps(fiz0,tz);
1430 fjx0 = _mm256_add_ps(fjx0,tx);
1431 fjy0 = _mm256_add_ps(fjy0,ty);
1432 fjz0 = _mm256_add_ps(fjz0,tz);
1434 /**************************
1435 * CALCULATE INTERACTIONS *
1436 **************************/
1438 /* COULOMB ELECTROSTATICS */
1439 velec = _mm256_mul_ps(qq01,rinv01);
1440 felec = _mm256_mul_ps(velec,rinvsq01);
1444 /* Calculate temporary vectorial force */
1445 tx = _mm256_mul_ps(fscal,dx01);
1446 ty = _mm256_mul_ps(fscal,dy01);
1447 tz = _mm256_mul_ps(fscal,dz01);
1449 /* Update vectorial force */
1450 fix0 = _mm256_add_ps(fix0,tx);
1451 fiy0 = _mm256_add_ps(fiy0,ty);
1452 fiz0 = _mm256_add_ps(fiz0,tz);
1454 fjx1 = _mm256_add_ps(fjx1,tx);
1455 fjy1 = _mm256_add_ps(fjy1,ty);
1456 fjz1 = _mm256_add_ps(fjz1,tz);
1458 /**************************
1459 * CALCULATE INTERACTIONS *
1460 **************************/
1462 /* COULOMB ELECTROSTATICS */
1463 velec = _mm256_mul_ps(qq02,rinv02);
1464 felec = _mm256_mul_ps(velec,rinvsq02);
1468 /* Calculate temporary vectorial force */
1469 tx = _mm256_mul_ps(fscal,dx02);
1470 ty = _mm256_mul_ps(fscal,dy02);
1471 tz = _mm256_mul_ps(fscal,dz02);
1473 /* Update vectorial force */
1474 fix0 = _mm256_add_ps(fix0,tx);
1475 fiy0 = _mm256_add_ps(fiy0,ty);
1476 fiz0 = _mm256_add_ps(fiz0,tz);
1478 fjx2 = _mm256_add_ps(fjx2,tx);
1479 fjy2 = _mm256_add_ps(fjy2,ty);
1480 fjz2 = _mm256_add_ps(fjz2,tz);
1482 /**************************
1483 * CALCULATE INTERACTIONS *
1484 **************************/
1486 /* COULOMB ELECTROSTATICS */
1487 velec = _mm256_mul_ps(qq10,rinv10);
1488 felec = _mm256_mul_ps(velec,rinvsq10);
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 /* COULOMB ELECTROSTATICS */
1511 velec = _mm256_mul_ps(qq11,rinv11);
1512 felec = _mm256_mul_ps(velec,rinvsq11);
1516 /* Calculate temporary vectorial force */
1517 tx = _mm256_mul_ps(fscal,dx11);
1518 ty = _mm256_mul_ps(fscal,dy11);
1519 tz = _mm256_mul_ps(fscal,dz11);
1521 /* Update vectorial force */
1522 fix1 = _mm256_add_ps(fix1,tx);
1523 fiy1 = _mm256_add_ps(fiy1,ty);
1524 fiz1 = _mm256_add_ps(fiz1,tz);
1526 fjx1 = _mm256_add_ps(fjx1,tx);
1527 fjy1 = _mm256_add_ps(fjy1,ty);
1528 fjz1 = _mm256_add_ps(fjz1,tz);
1530 /**************************
1531 * CALCULATE INTERACTIONS *
1532 **************************/
1534 /* COULOMB ELECTROSTATICS */
1535 velec = _mm256_mul_ps(qq12,rinv12);
1536 felec = _mm256_mul_ps(velec,rinvsq12);
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 /* COULOMB ELECTROSTATICS */
1559 velec = _mm256_mul_ps(qq20,rinv20);
1560 felec = _mm256_mul_ps(velec,rinvsq20);
1564 /* Calculate temporary vectorial force */
1565 tx = _mm256_mul_ps(fscal,dx20);
1566 ty = _mm256_mul_ps(fscal,dy20);
1567 tz = _mm256_mul_ps(fscal,dz20);
1569 /* Update vectorial force */
1570 fix2 = _mm256_add_ps(fix2,tx);
1571 fiy2 = _mm256_add_ps(fiy2,ty);
1572 fiz2 = _mm256_add_ps(fiz2,tz);
1574 fjx0 = _mm256_add_ps(fjx0,tx);
1575 fjy0 = _mm256_add_ps(fjy0,ty);
1576 fjz0 = _mm256_add_ps(fjz0,tz);
1578 /**************************
1579 * CALCULATE INTERACTIONS *
1580 **************************/
1582 /* COULOMB ELECTROSTATICS */
1583 velec = _mm256_mul_ps(qq21,rinv21);
1584 felec = _mm256_mul_ps(velec,rinvsq21);
1588 /* Calculate temporary vectorial force */
1589 tx = _mm256_mul_ps(fscal,dx21);
1590 ty = _mm256_mul_ps(fscal,dy21);
1591 tz = _mm256_mul_ps(fscal,dz21);
1593 /* Update vectorial force */
1594 fix2 = _mm256_add_ps(fix2,tx);
1595 fiy2 = _mm256_add_ps(fiy2,ty);
1596 fiz2 = _mm256_add_ps(fiz2,tz);
1598 fjx1 = _mm256_add_ps(fjx1,tx);
1599 fjy1 = _mm256_add_ps(fjy1,ty);
1600 fjz1 = _mm256_add_ps(fjz1,tz);
1602 /**************************
1603 * CALCULATE INTERACTIONS *
1604 **************************/
1606 /* COULOMB ELECTROSTATICS */
1607 velec = _mm256_mul_ps(qq22,rinv22);
1608 felec = _mm256_mul_ps(velec,rinvsq22);
1612 /* Calculate temporary vectorial force */
1613 tx = _mm256_mul_ps(fscal,dx22);
1614 ty = _mm256_mul_ps(fscal,dy22);
1615 tz = _mm256_mul_ps(fscal,dz22);
1617 /* Update vectorial force */
1618 fix2 = _mm256_add_ps(fix2,tx);
1619 fiy2 = _mm256_add_ps(fiy2,ty);
1620 fiz2 = _mm256_add_ps(fiz2,tz);
1622 fjx2 = _mm256_add_ps(fjx2,tx);
1623 fjy2 = _mm256_add_ps(fjy2,ty);
1624 fjz2 = _mm256_add_ps(fjz2,tz);
1626 fjptrA = f+j_coord_offsetA;
1627 fjptrB = f+j_coord_offsetB;
1628 fjptrC = f+j_coord_offsetC;
1629 fjptrD = f+j_coord_offsetD;
1630 fjptrE = f+j_coord_offsetE;
1631 fjptrF = f+j_coord_offsetF;
1632 fjptrG = f+j_coord_offsetG;
1633 fjptrH = f+j_coord_offsetH;
1635 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1636 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1638 /* Inner loop uses 261 flops */
1641 if(jidx<j_index_end)
1644 /* Get j neighbor index, and coordinate index */
1645 jnrlistA = jjnr[jidx];
1646 jnrlistB = jjnr[jidx+1];
1647 jnrlistC = jjnr[jidx+2];
1648 jnrlistD = jjnr[jidx+3];
1649 jnrlistE = jjnr[jidx+4];
1650 jnrlistF = jjnr[jidx+5];
1651 jnrlistG = jjnr[jidx+6];
1652 jnrlistH = jjnr[jidx+7];
1653 /* Sign of each element will be negative for non-real atoms.
1654 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1655 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1657 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1658 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1660 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1661 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1662 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1663 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1664 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1665 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1666 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1667 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1668 j_coord_offsetA = DIM*jnrA;
1669 j_coord_offsetB = DIM*jnrB;
1670 j_coord_offsetC = DIM*jnrC;
1671 j_coord_offsetD = DIM*jnrD;
1672 j_coord_offsetE = DIM*jnrE;
1673 j_coord_offsetF = DIM*jnrF;
1674 j_coord_offsetG = DIM*jnrG;
1675 j_coord_offsetH = DIM*jnrH;
1677 /* load j atom coordinates */
1678 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1679 x+j_coord_offsetC,x+j_coord_offsetD,
1680 x+j_coord_offsetE,x+j_coord_offsetF,
1681 x+j_coord_offsetG,x+j_coord_offsetH,
1682 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1684 /* Calculate displacement vector */
1685 dx00 = _mm256_sub_ps(ix0,jx0);
1686 dy00 = _mm256_sub_ps(iy0,jy0);
1687 dz00 = _mm256_sub_ps(iz0,jz0);
1688 dx01 = _mm256_sub_ps(ix0,jx1);
1689 dy01 = _mm256_sub_ps(iy0,jy1);
1690 dz01 = _mm256_sub_ps(iz0,jz1);
1691 dx02 = _mm256_sub_ps(ix0,jx2);
1692 dy02 = _mm256_sub_ps(iy0,jy2);
1693 dz02 = _mm256_sub_ps(iz0,jz2);
1694 dx10 = _mm256_sub_ps(ix1,jx0);
1695 dy10 = _mm256_sub_ps(iy1,jy0);
1696 dz10 = _mm256_sub_ps(iz1,jz0);
1697 dx11 = _mm256_sub_ps(ix1,jx1);
1698 dy11 = _mm256_sub_ps(iy1,jy1);
1699 dz11 = _mm256_sub_ps(iz1,jz1);
1700 dx12 = _mm256_sub_ps(ix1,jx2);
1701 dy12 = _mm256_sub_ps(iy1,jy2);
1702 dz12 = _mm256_sub_ps(iz1,jz2);
1703 dx20 = _mm256_sub_ps(ix2,jx0);
1704 dy20 = _mm256_sub_ps(iy2,jy0);
1705 dz20 = _mm256_sub_ps(iz2,jz0);
1706 dx21 = _mm256_sub_ps(ix2,jx1);
1707 dy21 = _mm256_sub_ps(iy2,jy1);
1708 dz21 = _mm256_sub_ps(iz2,jz1);
1709 dx22 = _mm256_sub_ps(ix2,jx2);
1710 dy22 = _mm256_sub_ps(iy2,jy2);
1711 dz22 = _mm256_sub_ps(iz2,jz2);
1713 /* Calculate squared distance and things based on it */
1714 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1715 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1716 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1717 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1718 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1719 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1720 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1721 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1722 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1724 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1725 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1726 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1727 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1728 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1729 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1730 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1731 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1732 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1734 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1735 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1736 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1737 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1738 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1739 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1740 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1741 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1742 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1744 fjx0 = _mm256_setzero_ps();
1745 fjy0 = _mm256_setzero_ps();
1746 fjz0 = _mm256_setzero_ps();
1747 fjx1 = _mm256_setzero_ps();
1748 fjy1 = _mm256_setzero_ps();
1749 fjz1 = _mm256_setzero_ps();
1750 fjx2 = _mm256_setzero_ps();
1751 fjy2 = _mm256_setzero_ps();
1752 fjz2 = _mm256_setzero_ps();
1754 /**************************
1755 * CALCULATE INTERACTIONS *
1756 **************************/
1758 r00 = _mm256_mul_ps(rsq00,rinv00);
1759 r00 = _mm256_andnot_ps(dummy_mask,r00);
1761 /* Calculate table index by multiplying r with table scale and truncate to integer */
1762 rt = _mm256_mul_ps(r00,vftabscale);
1763 vfitab = _mm256_cvttps_epi32(rt);
1764 vfeps = _mm256_sub_ps(rt,_mm256_round_ps(rt, _MM_FROUND_FLOOR));
1765 /* AVX1 does not support 256-bit integer operations, so now we go to 128-bit mode... */
1766 vfitab_lo = _mm256_extractf128_si256(vfitab,0x0);
1767 vfitab_hi = _mm256_extractf128_si256(vfitab,0x1);
1768 vfitab_lo = _mm_slli_epi32(vfitab_lo,3);
1769 vfitab_hi = _mm_slli_epi32(vfitab_hi,3);
1771 /* COULOMB ELECTROSTATICS */
1772 velec = _mm256_mul_ps(qq00,rinv00);
1773 felec = _mm256_mul_ps(velec,rinvsq00);
1775 /* CUBIC SPLINE TABLE DISPERSION */
1776 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1777 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1778 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1779 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1780 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1781 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1782 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1783 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1784 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1785 Heps = _mm256_mul_ps(vfeps,H);
1786 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1787 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1788 fvdw6 = _mm256_mul_ps(c6_00,FF);
1790 /* CUBIC SPLINE TABLE REPULSION */
1791 vfitab_lo = _mm_add_epi32(vfitab_lo,ifour);
1792 vfitab_hi = _mm_add_epi32(vfitab_hi,ifour);
1793 Y = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,0)),
1794 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,0)));
1795 F = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,1)),
1796 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,1)));
1797 G = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,2)),
1798 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,2)));
1799 H = gmx_mm256_set_m128(_mm_load_ps(vftab + _mm_extract_epi32(vfitab_hi,3)),
1800 _mm_load_ps(vftab + _mm_extract_epi32(vfitab_lo,3)));
1801 GMX_MM256_HALFTRANSPOSE4_PS(Y,F,G,H);
1802 Heps = _mm256_mul_ps(vfeps,H);
1803 Fp = _mm256_add_ps(F,_mm256_mul_ps(vfeps,_mm256_add_ps(G,Heps)));
1804 FF = _mm256_add_ps(Fp,_mm256_mul_ps(vfeps,_mm256_add_ps(G,_mm256_add_ps(Heps,Heps))));
1805 fvdw12 = _mm256_mul_ps(c12_00,FF);
1806 fvdw = _mm256_xor_ps(signbit,_mm256_mul_ps(_mm256_add_ps(fvdw6,fvdw12),_mm256_mul_ps(vftabscale,rinv00)));
1808 fscal = _mm256_add_ps(felec,fvdw);
1810 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1812 /* Calculate temporary vectorial force */
1813 tx = _mm256_mul_ps(fscal,dx00);
1814 ty = _mm256_mul_ps(fscal,dy00);
1815 tz = _mm256_mul_ps(fscal,dz00);
1817 /* Update vectorial force */
1818 fix0 = _mm256_add_ps(fix0,tx);
1819 fiy0 = _mm256_add_ps(fiy0,ty);
1820 fiz0 = _mm256_add_ps(fiz0,tz);
1822 fjx0 = _mm256_add_ps(fjx0,tx);
1823 fjy0 = _mm256_add_ps(fjy0,ty);
1824 fjz0 = _mm256_add_ps(fjz0,tz);
1826 /**************************
1827 * CALCULATE INTERACTIONS *
1828 **************************/
1830 /* COULOMB ELECTROSTATICS */
1831 velec = _mm256_mul_ps(qq01,rinv01);
1832 felec = _mm256_mul_ps(velec,rinvsq01);
1836 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1838 /* Calculate temporary vectorial force */
1839 tx = _mm256_mul_ps(fscal,dx01);
1840 ty = _mm256_mul_ps(fscal,dy01);
1841 tz = _mm256_mul_ps(fscal,dz01);
1843 /* Update vectorial force */
1844 fix0 = _mm256_add_ps(fix0,tx);
1845 fiy0 = _mm256_add_ps(fiy0,ty);
1846 fiz0 = _mm256_add_ps(fiz0,tz);
1848 fjx1 = _mm256_add_ps(fjx1,tx);
1849 fjy1 = _mm256_add_ps(fjy1,ty);
1850 fjz1 = _mm256_add_ps(fjz1,tz);
1852 /**************************
1853 * CALCULATE INTERACTIONS *
1854 **************************/
1856 /* COULOMB ELECTROSTATICS */
1857 velec = _mm256_mul_ps(qq02,rinv02);
1858 felec = _mm256_mul_ps(velec,rinvsq02);
1862 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1864 /* Calculate temporary vectorial force */
1865 tx = _mm256_mul_ps(fscal,dx02);
1866 ty = _mm256_mul_ps(fscal,dy02);
1867 tz = _mm256_mul_ps(fscal,dz02);
1869 /* Update vectorial force */
1870 fix0 = _mm256_add_ps(fix0,tx);
1871 fiy0 = _mm256_add_ps(fiy0,ty);
1872 fiz0 = _mm256_add_ps(fiz0,tz);
1874 fjx2 = _mm256_add_ps(fjx2,tx);
1875 fjy2 = _mm256_add_ps(fjy2,ty);
1876 fjz2 = _mm256_add_ps(fjz2,tz);
1878 /**************************
1879 * CALCULATE INTERACTIONS *
1880 **************************/
1882 /* COULOMB ELECTROSTATICS */
1883 velec = _mm256_mul_ps(qq10,rinv10);
1884 felec = _mm256_mul_ps(velec,rinvsq10);
1888 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1890 /* Calculate temporary vectorial force */
1891 tx = _mm256_mul_ps(fscal,dx10);
1892 ty = _mm256_mul_ps(fscal,dy10);
1893 tz = _mm256_mul_ps(fscal,dz10);
1895 /* Update vectorial force */
1896 fix1 = _mm256_add_ps(fix1,tx);
1897 fiy1 = _mm256_add_ps(fiy1,ty);
1898 fiz1 = _mm256_add_ps(fiz1,tz);
1900 fjx0 = _mm256_add_ps(fjx0,tx);
1901 fjy0 = _mm256_add_ps(fjy0,ty);
1902 fjz0 = _mm256_add_ps(fjz0,tz);
1904 /**************************
1905 * CALCULATE INTERACTIONS *
1906 **************************/
1908 /* COULOMB ELECTROSTATICS */
1909 velec = _mm256_mul_ps(qq11,rinv11);
1910 felec = _mm256_mul_ps(velec,rinvsq11);
1914 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1916 /* Calculate temporary vectorial force */
1917 tx = _mm256_mul_ps(fscal,dx11);
1918 ty = _mm256_mul_ps(fscal,dy11);
1919 tz = _mm256_mul_ps(fscal,dz11);
1921 /* Update vectorial force */
1922 fix1 = _mm256_add_ps(fix1,tx);
1923 fiy1 = _mm256_add_ps(fiy1,ty);
1924 fiz1 = _mm256_add_ps(fiz1,tz);
1926 fjx1 = _mm256_add_ps(fjx1,tx);
1927 fjy1 = _mm256_add_ps(fjy1,ty);
1928 fjz1 = _mm256_add_ps(fjz1,tz);
1930 /**************************
1931 * CALCULATE INTERACTIONS *
1932 **************************/
1934 /* COULOMB ELECTROSTATICS */
1935 velec = _mm256_mul_ps(qq12,rinv12);
1936 felec = _mm256_mul_ps(velec,rinvsq12);
1940 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1942 /* Calculate temporary vectorial force */
1943 tx = _mm256_mul_ps(fscal,dx12);
1944 ty = _mm256_mul_ps(fscal,dy12);
1945 tz = _mm256_mul_ps(fscal,dz12);
1947 /* Update vectorial force */
1948 fix1 = _mm256_add_ps(fix1,tx);
1949 fiy1 = _mm256_add_ps(fiy1,ty);
1950 fiz1 = _mm256_add_ps(fiz1,tz);
1952 fjx2 = _mm256_add_ps(fjx2,tx);
1953 fjy2 = _mm256_add_ps(fjy2,ty);
1954 fjz2 = _mm256_add_ps(fjz2,tz);
1956 /**************************
1957 * CALCULATE INTERACTIONS *
1958 **************************/
1960 /* COULOMB ELECTROSTATICS */
1961 velec = _mm256_mul_ps(qq20,rinv20);
1962 felec = _mm256_mul_ps(velec,rinvsq20);
1966 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1968 /* Calculate temporary vectorial force */
1969 tx = _mm256_mul_ps(fscal,dx20);
1970 ty = _mm256_mul_ps(fscal,dy20);
1971 tz = _mm256_mul_ps(fscal,dz20);
1973 /* Update vectorial force */
1974 fix2 = _mm256_add_ps(fix2,tx);
1975 fiy2 = _mm256_add_ps(fiy2,ty);
1976 fiz2 = _mm256_add_ps(fiz2,tz);
1978 fjx0 = _mm256_add_ps(fjx0,tx);
1979 fjy0 = _mm256_add_ps(fjy0,ty);
1980 fjz0 = _mm256_add_ps(fjz0,tz);
1982 /**************************
1983 * CALCULATE INTERACTIONS *
1984 **************************/
1986 /* COULOMB ELECTROSTATICS */
1987 velec = _mm256_mul_ps(qq21,rinv21);
1988 felec = _mm256_mul_ps(velec,rinvsq21);
1992 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1994 /* Calculate temporary vectorial force */
1995 tx = _mm256_mul_ps(fscal,dx21);
1996 ty = _mm256_mul_ps(fscal,dy21);
1997 tz = _mm256_mul_ps(fscal,dz21);
1999 /* Update vectorial force */
2000 fix2 = _mm256_add_ps(fix2,tx);
2001 fiy2 = _mm256_add_ps(fiy2,ty);
2002 fiz2 = _mm256_add_ps(fiz2,tz);
2004 fjx1 = _mm256_add_ps(fjx1,tx);
2005 fjy1 = _mm256_add_ps(fjy1,ty);
2006 fjz1 = _mm256_add_ps(fjz1,tz);
2008 /**************************
2009 * CALCULATE INTERACTIONS *
2010 **************************/
2012 /* COULOMB ELECTROSTATICS */
2013 velec = _mm256_mul_ps(qq22,rinv22);
2014 felec = _mm256_mul_ps(velec,rinvsq22);
2018 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2020 /* Calculate temporary vectorial force */
2021 tx = _mm256_mul_ps(fscal,dx22);
2022 ty = _mm256_mul_ps(fscal,dy22);
2023 tz = _mm256_mul_ps(fscal,dz22);
2025 /* Update vectorial force */
2026 fix2 = _mm256_add_ps(fix2,tx);
2027 fiy2 = _mm256_add_ps(fiy2,ty);
2028 fiz2 = _mm256_add_ps(fiz2,tz);
2030 fjx2 = _mm256_add_ps(fjx2,tx);
2031 fjy2 = _mm256_add_ps(fjy2,ty);
2032 fjz2 = _mm256_add_ps(fjz2,tz);
2034 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2035 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2036 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2037 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2038 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2039 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2040 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2041 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2043 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2044 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2046 /* Inner loop uses 262 flops */
2049 /* End of innermost loop */
2051 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2052 f+i_coord_offset,fshift+i_shift_offset);
2054 /* Increment number of inner iterations */
2055 inneriter += j_index_end - j_index_start;
2057 /* Outer loop uses 18 flops */
2060 /* Increment number of outer iterations */
2063 /* Update outer/inner flops */
2065 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*262);