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_ElecRFCut_VdwLJSh_GeomW4W4_VF_avx_256_single
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: LennardJones
56 * Geometry: Water4-Water4
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_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 real * vdwioffsetptr3;
95 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
96 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
97 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
98 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
99 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
100 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
101 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
102 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
103 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
104 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
105 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
106 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
107 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
108 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
109 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
110 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
111 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
112 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
113 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
114 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
117 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
120 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
121 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
122 __m256 dummy_mask,cutoff_mask;
123 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
124 __m256 one = _mm256_set1_ps(1.0);
125 __m256 two = _mm256_set1_ps(2.0);
131 jindex = nlist->jindex;
133 shiftidx = nlist->shift;
135 shiftvec = fr->shift_vec[0];
136 fshift = fr->fshift[0];
137 facel = _mm256_set1_ps(fr->epsfac);
138 charge = mdatoms->chargeA;
139 krf = _mm256_set1_ps(fr->ic->k_rf);
140 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
141 crf = _mm256_set1_ps(fr->ic->c_rf);
142 nvdwtype = fr->ntype;
144 vdwtype = mdatoms->typeA;
146 /* Setup water-specific parameters */
147 inr = nlist->iinr[0];
148 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
149 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
150 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
151 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
153 jq1 = _mm256_set1_ps(charge[inr+1]);
154 jq2 = _mm256_set1_ps(charge[inr+2]);
155 jq3 = _mm256_set1_ps(charge[inr+3]);
156 vdwjidx0A = 2*vdwtype[inr+0];
157 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
158 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
159 qq11 = _mm256_mul_ps(iq1,jq1);
160 qq12 = _mm256_mul_ps(iq1,jq2);
161 qq13 = _mm256_mul_ps(iq1,jq3);
162 qq21 = _mm256_mul_ps(iq2,jq1);
163 qq22 = _mm256_mul_ps(iq2,jq2);
164 qq23 = _mm256_mul_ps(iq2,jq3);
165 qq31 = _mm256_mul_ps(iq3,jq1);
166 qq32 = _mm256_mul_ps(iq3,jq2);
167 qq33 = _mm256_mul_ps(iq3,jq3);
169 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
170 rcutoff_scalar = fr->rcoulomb;
171 rcutoff = _mm256_set1_ps(rcutoff_scalar);
172 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
174 sh_vdw_invrcut6 = _mm256_set1_ps(fr->ic->sh_invrc6);
175 rvdw = _mm256_set1_ps(fr->rvdw);
177 /* Avoid stupid compiler warnings */
178 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
191 for(iidx=0;iidx<4*DIM;iidx++)
196 /* Start outer loop over neighborlists */
197 for(iidx=0; iidx<nri; iidx++)
199 /* Load shift vector for this list */
200 i_shift_offset = DIM*shiftidx[iidx];
202 /* Load limits for loop over neighbors */
203 j_index_start = jindex[iidx];
204 j_index_end = jindex[iidx+1];
206 /* Get outer coordinate index */
208 i_coord_offset = DIM*inr;
210 /* Load i particle coords and add shift vector */
211 gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
212 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
214 fix0 = _mm256_setzero_ps();
215 fiy0 = _mm256_setzero_ps();
216 fiz0 = _mm256_setzero_ps();
217 fix1 = _mm256_setzero_ps();
218 fiy1 = _mm256_setzero_ps();
219 fiz1 = _mm256_setzero_ps();
220 fix2 = _mm256_setzero_ps();
221 fiy2 = _mm256_setzero_ps();
222 fiz2 = _mm256_setzero_ps();
223 fix3 = _mm256_setzero_ps();
224 fiy3 = _mm256_setzero_ps();
225 fiz3 = _mm256_setzero_ps();
227 /* Reset potential sums */
228 velecsum = _mm256_setzero_ps();
229 vvdwsum = _mm256_setzero_ps();
231 /* Start inner kernel loop */
232 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
235 /* Get j neighbor index, and coordinate index */
244 j_coord_offsetA = DIM*jnrA;
245 j_coord_offsetB = DIM*jnrB;
246 j_coord_offsetC = DIM*jnrC;
247 j_coord_offsetD = DIM*jnrD;
248 j_coord_offsetE = DIM*jnrE;
249 j_coord_offsetF = DIM*jnrF;
250 j_coord_offsetG = DIM*jnrG;
251 j_coord_offsetH = DIM*jnrH;
253 /* load j atom coordinates */
254 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
255 x+j_coord_offsetC,x+j_coord_offsetD,
256 x+j_coord_offsetE,x+j_coord_offsetF,
257 x+j_coord_offsetG,x+j_coord_offsetH,
258 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
259 &jy2,&jz2,&jx3,&jy3,&jz3);
261 /* Calculate displacement vector */
262 dx00 = _mm256_sub_ps(ix0,jx0);
263 dy00 = _mm256_sub_ps(iy0,jy0);
264 dz00 = _mm256_sub_ps(iz0,jz0);
265 dx11 = _mm256_sub_ps(ix1,jx1);
266 dy11 = _mm256_sub_ps(iy1,jy1);
267 dz11 = _mm256_sub_ps(iz1,jz1);
268 dx12 = _mm256_sub_ps(ix1,jx2);
269 dy12 = _mm256_sub_ps(iy1,jy2);
270 dz12 = _mm256_sub_ps(iz1,jz2);
271 dx13 = _mm256_sub_ps(ix1,jx3);
272 dy13 = _mm256_sub_ps(iy1,jy3);
273 dz13 = _mm256_sub_ps(iz1,jz3);
274 dx21 = _mm256_sub_ps(ix2,jx1);
275 dy21 = _mm256_sub_ps(iy2,jy1);
276 dz21 = _mm256_sub_ps(iz2,jz1);
277 dx22 = _mm256_sub_ps(ix2,jx2);
278 dy22 = _mm256_sub_ps(iy2,jy2);
279 dz22 = _mm256_sub_ps(iz2,jz2);
280 dx23 = _mm256_sub_ps(ix2,jx3);
281 dy23 = _mm256_sub_ps(iy2,jy3);
282 dz23 = _mm256_sub_ps(iz2,jz3);
283 dx31 = _mm256_sub_ps(ix3,jx1);
284 dy31 = _mm256_sub_ps(iy3,jy1);
285 dz31 = _mm256_sub_ps(iz3,jz1);
286 dx32 = _mm256_sub_ps(ix3,jx2);
287 dy32 = _mm256_sub_ps(iy3,jy2);
288 dz32 = _mm256_sub_ps(iz3,jz2);
289 dx33 = _mm256_sub_ps(ix3,jx3);
290 dy33 = _mm256_sub_ps(iy3,jy3);
291 dz33 = _mm256_sub_ps(iz3,jz3);
293 /* Calculate squared distance and things based on it */
294 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
295 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
296 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
297 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
298 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
299 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
300 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
301 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
302 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
303 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
305 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
306 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
307 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
308 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
309 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
310 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
311 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
312 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
313 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
315 rinvsq00 = gmx_mm256_inv_ps(rsq00);
316 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
317 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
318 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
319 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
320 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
321 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
322 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
323 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
324 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
326 fjx0 = _mm256_setzero_ps();
327 fjy0 = _mm256_setzero_ps();
328 fjz0 = _mm256_setzero_ps();
329 fjx1 = _mm256_setzero_ps();
330 fjy1 = _mm256_setzero_ps();
331 fjz1 = _mm256_setzero_ps();
332 fjx2 = _mm256_setzero_ps();
333 fjy2 = _mm256_setzero_ps();
334 fjz2 = _mm256_setzero_ps();
335 fjx3 = _mm256_setzero_ps();
336 fjy3 = _mm256_setzero_ps();
337 fjz3 = _mm256_setzero_ps();
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
343 if (gmx_mm256_any_lt(rsq00,rcutoff2))
346 /* LENNARD-JONES DISPERSION/REPULSION */
348 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
349 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
350 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
351 vvdw = _mm256_sub_ps(_mm256_mul_ps( _mm256_sub_ps(vvdw12 , _mm256_mul_ps(c12_00,_mm256_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
352 _mm256_mul_ps( _mm256_sub_ps(vvdw6,_mm256_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
353 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
355 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
357 /* Update potential sum for this i atom from the interaction with this j atom. */
358 vvdw = _mm256_and_ps(vvdw,cutoff_mask);
359 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
363 fscal = _mm256_and_ps(fscal,cutoff_mask);
365 /* Calculate temporary vectorial force */
366 tx = _mm256_mul_ps(fscal,dx00);
367 ty = _mm256_mul_ps(fscal,dy00);
368 tz = _mm256_mul_ps(fscal,dz00);
370 /* Update vectorial force */
371 fix0 = _mm256_add_ps(fix0,tx);
372 fiy0 = _mm256_add_ps(fiy0,ty);
373 fiz0 = _mm256_add_ps(fiz0,tz);
375 fjx0 = _mm256_add_ps(fjx0,tx);
376 fjy0 = _mm256_add_ps(fjy0,ty);
377 fjz0 = _mm256_add_ps(fjz0,tz);
381 /**************************
382 * CALCULATE INTERACTIONS *
383 **************************/
385 if (gmx_mm256_any_lt(rsq11,rcutoff2))
388 /* REACTION-FIELD ELECTROSTATICS */
389 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
390 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
392 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
394 /* Update potential sum for this i atom from the interaction with this j atom. */
395 velec = _mm256_and_ps(velec,cutoff_mask);
396 velecsum = _mm256_add_ps(velecsum,velec);
400 fscal = _mm256_and_ps(fscal,cutoff_mask);
402 /* Calculate temporary vectorial force */
403 tx = _mm256_mul_ps(fscal,dx11);
404 ty = _mm256_mul_ps(fscal,dy11);
405 tz = _mm256_mul_ps(fscal,dz11);
407 /* Update vectorial force */
408 fix1 = _mm256_add_ps(fix1,tx);
409 fiy1 = _mm256_add_ps(fiy1,ty);
410 fiz1 = _mm256_add_ps(fiz1,tz);
412 fjx1 = _mm256_add_ps(fjx1,tx);
413 fjy1 = _mm256_add_ps(fjy1,ty);
414 fjz1 = _mm256_add_ps(fjz1,tz);
418 /**************************
419 * CALCULATE INTERACTIONS *
420 **************************/
422 if (gmx_mm256_any_lt(rsq12,rcutoff2))
425 /* REACTION-FIELD ELECTROSTATICS */
426 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
427 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
429 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
431 /* Update potential sum for this i atom from the interaction with this j atom. */
432 velec = _mm256_and_ps(velec,cutoff_mask);
433 velecsum = _mm256_add_ps(velecsum,velec);
437 fscal = _mm256_and_ps(fscal,cutoff_mask);
439 /* Calculate temporary vectorial force */
440 tx = _mm256_mul_ps(fscal,dx12);
441 ty = _mm256_mul_ps(fscal,dy12);
442 tz = _mm256_mul_ps(fscal,dz12);
444 /* Update vectorial force */
445 fix1 = _mm256_add_ps(fix1,tx);
446 fiy1 = _mm256_add_ps(fiy1,ty);
447 fiz1 = _mm256_add_ps(fiz1,tz);
449 fjx2 = _mm256_add_ps(fjx2,tx);
450 fjy2 = _mm256_add_ps(fjy2,ty);
451 fjz2 = _mm256_add_ps(fjz2,tz);
455 /**************************
456 * CALCULATE INTERACTIONS *
457 **************************/
459 if (gmx_mm256_any_lt(rsq13,rcutoff2))
462 /* REACTION-FIELD ELECTROSTATICS */
463 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
464 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
466 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
468 /* Update potential sum for this i atom from the interaction with this j atom. */
469 velec = _mm256_and_ps(velec,cutoff_mask);
470 velecsum = _mm256_add_ps(velecsum,velec);
474 fscal = _mm256_and_ps(fscal,cutoff_mask);
476 /* Calculate temporary vectorial force */
477 tx = _mm256_mul_ps(fscal,dx13);
478 ty = _mm256_mul_ps(fscal,dy13);
479 tz = _mm256_mul_ps(fscal,dz13);
481 /* Update vectorial force */
482 fix1 = _mm256_add_ps(fix1,tx);
483 fiy1 = _mm256_add_ps(fiy1,ty);
484 fiz1 = _mm256_add_ps(fiz1,tz);
486 fjx3 = _mm256_add_ps(fjx3,tx);
487 fjy3 = _mm256_add_ps(fjy3,ty);
488 fjz3 = _mm256_add_ps(fjz3,tz);
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
496 if (gmx_mm256_any_lt(rsq21,rcutoff2))
499 /* REACTION-FIELD ELECTROSTATICS */
500 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
501 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
503 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
505 /* Update potential sum for this i atom from the interaction with this j atom. */
506 velec = _mm256_and_ps(velec,cutoff_mask);
507 velecsum = _mm256_add_ps(velecsum,velec);
511 fscal = _mm256_and_ps(fscal,cutoff_mask);
513 /* Calculate temporary vectorial force */
514 tx = _mm256_mul_ps(fscal,dx21);
515 ty = _mm256_mul_ps(fscal,dy21);
516 tz = _mm256_mul_ps(fscal,dz21);
518 /* Update vectorial force */
519 fix2 = _mm256_add_ps(fix2,tx);
520 fiy2 = _mm256_add_ps(fiy2,ty);
521 fiz2 = _mm256_add_ps(fiz2,tz);
523 fjx1 = _mm256_add_ps(fjx1,tx);
524 fjy1 = _mm256_add_ps(fjy1,ty);
525 fjz1 = _mm256_add_ps(fjz1,tz);
529 /**************************
530 * CALCULATE INTERACTIONS *
531 **************************/
533 if (gmx_mm256_any_lt(rsq22,rcutoff2))
536 /* REACTION-FIELD ELECTROSTATICS */
537 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
538 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
540 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
542 /* Update potential sum for this i atom from the interaction with this j atom. */
543 velec = _mm256_and_ps(velec,cutoff_mask);
544 velecsum = _mm256_add_ps(velecsum,velec);
548 fscal = _mm256_and_ps(fscal,cutoff_mask);
550 /* Calculate temporary vectorial force */
551 tx = _mm256_mul_ps(fscal,dx22);
552 ty = _mm256_mul_ps(fscal,dy22);
553 tz = _mm256_mul_ps(fscal,dz22);
555 /* Update vectorial force */
556 fix2 = _mm256_add_ps(fix2,tx);
557 fiy2 = _mm256_add_ps(fiy2,ty);
558 fiz2 = _mm256_add_ps(fiz2,tz);
560 fjx2 = _mm256_add_ps(fjx2,tx);
561 fjy2 = _mm256_add_ps(fjy2,ty);
562 fjz2 = _mm256_add_ps(fjz2,tz);
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
570 if (gmx_mm256_any_lt(rsq23,rcutoff2))
573 /* REACTION-FIELD ELECTROSTATICS */
574 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
575 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
577 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
579 /* Update potential sum for this i atom from the interaction with this j atom. */
580 velec = _mm256_and_ps(velec,cutoff_mask);
581 velecsum = _mm256_add_ps(velecsum,velec);
585 fscal = _mm256_and_ps(fscal,cutoff_mask);
587 /* Calculate temporary vectorial force */
588 tx = _mm256_mul_ps(fscal,dx23);
589 ty = _mm256_mul_ps(fscal,dy23);
590 tz = _mm256_mul_ps(fscal,dz23);
592 /* Update vectorial force */
593 fix2 = _mm256_add_ps(fix2,tx);
594 fiy2 = _mm256_add_ps(fiy2,ty);
595 fiz2 = _mm256_add_ps(fiz2,tz);
597 fjx3 = _mm256_add_ps(fjx3,tx);
598 fjy3 = _mm256_add_ps(fjy3,ty);
599 fjz3 = _mm256_add_ps(fjz3,tz);
603 /**************************
604 * CALCULATE INTERACTIONS *
605 **************************/
607 if (gmx_mm256_any_lt(rsq31,rcutoff2))
610 /* REACTION-FIELD ELECTROSTATICS */
611 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
612 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
614 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
616 /* Update potential sum for this i atom from the interaction with this j atom. */
617 velec = _mm256_and_ps(velec,cutoff_mask);
618 velecsum = _mm256_add_ps(velecsum,velec);
622 fscal = _mm256_and_ps(fscal,cutoff_mask);
624 /* Calculate temporary vectorial force */
625 tx = _mm256_mul_ps(fscal,dx31);
626 ty = _mm256_mul_ps(fscal,dy31);
627 tz = _mm256_mul_ps(fscal,dz31);
629 /* Update vectorial force */
630 fix3 = _mm256_add_ps(fix3,tx);
631 fiy3 = _mm256_add_ps(fiy3,ty);
632 fiz3 = _mm256_add_ps(fiz3,tz);
634 fjx1 = _mm256_add_ps(fjx1,tx);
635 fjy1 = _mm256_add_ps(fjy1,ty);
636 fjz1 = _mm256_add_ps(fjz1,tz);
640 /**************************
641 * CALCULATE INTERACTIONS *
642 **************************/
644 if (gmx_mm256_any_lt(rsq32,rcutoff2))
647 /* REACTION-FIELD ELECTROSTATICS */
648 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
649 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
651 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
653 /* Update potential sum for this i atom from the interaction with this j atom. */
654 velec = _mm256_and_ps(velec,cutoff_mask);
655 velecsum = _mm256_add_ps(velecsum,velec);
659 fscal = _mm256_and_ps(fscal,cutoff_mask);
661 /* Calculate temporary vectorial force */
662 tx = _mm256_mul_ps(fscal,dx32);
663 ty = _mm256_mul_ps(fscal,dy32);
664 tz = _mm256_mul_ps(fscal,dz32);
666 /* Update vectorial force */
667 fix3 = _mm256_add_ps(fix3,tx);
668 fiy3 = _mm256_add_ps(fiy3,ty);
669 fiz3 = _mm256_add_ps(fiz3,tz);
671 fjx2 = _mm256_add_ps(fjx2,tx);
672 fjy2 = _mm256_add_ps(fjy2,ty);
673 fjz2 = _mm256_add_ps(fjz2,tz);
677 /**************************
678 * CALCULATE INTERACTIONS *
679 **************************/
681 if (gmx_mm256_any_lt(rsq33,rcutoff2))
684 /* REACTION-FIELD ELECTROSTATICS */
685 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
686 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
688 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
690 /* Update potential sum for this i atom from the interaction with this j atom. */
691 velec = _mm256_and_ps(velec,cutoff_mask);
692 velecsum = _mm256_add_ps(velecsum,velec);
696 fscal = _mm256_and_ps(fscal,cutoff_mask);
698 /* Calculate temporary vectorial force */
699 tx = _mm256_mul_ps(fscal,dx33);
700 ty = _mm256_mul_ps(fscal,dy33);
701 tz = _mm256_mul_ps(fscal,dz33);
703 /* Update vectorial force */
704 fix3 = _mm256_add_ps(fix3,tx);
705 fiy3 = _mm256_add_ps(fiy3,ty);
706 fiz3 = _mm256_add_ps(fiz3,tz);
708 fjx3 = _mm256_add_ps(fjx3,tx);
709 fjy3 = _mm256_add_ps(fjy3,ty);
710 fjz3 = _mm256_add_ps(fjz3,tz);
714 fjptrA = f+j_coord_offsetA;
715 fjptrB = f+j_coord_offsetB;
716 fjptrC = f+j_coord_offsetC;
717 fjptrD = f+j_coord_offsetD;
718 fjptrE = f+j_coord_offsetE;
719 fjptrF = f+j_coord_offsetF;
720 fjptrG = f+j_coord_offsetG;
721 fjptrH = f+j_coord_offsetH;
723 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
724 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
725 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
727 /* Inner loop uses 368 flops */
733 /* Get j neighbor index, and coordinate index */
734 jnrlistA = jjnr[jidx];
735 jnrlistB = jjnr[jidx+1];
736 jnrlistC = jjnr[jidx+2];
737 jnrlistD = jjnr[jidx+3];
738 jnrlistE = jjnr[jidx+4];
739 jnrlistF = jjnr[jidx+5];
740 jnrlistG = jjnr[jidx+6];
741 jnrlistH = jjnr[jidx+7];
742 /* Sign of each element will be negative for non-real atoms.
743 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
744 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
746 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
747 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
749 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
750 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
751 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
752 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
753 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
754 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
755 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
756 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
757 j_coord_offsetA = DIM*jnrA;
758 j_coord_offsetB = DIM*jnrB;
759 j_coord_offsetC = DIM*jnrC;
760 j_coord_offsetD = DIM*jnrD;
761 j_coord_offsetE = DIM*jnrE;
762 j_coord_offsetF = DIM*jnrF;
763 j_coord_offsetG = DIM*jnrG;
764 j_coord_offsetH = DIM*jnrH;
766 /* load j atom coordinates */
767 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
768 x+j_coord_offsetC,x+j_coord_offsetD,
769 x+j_coord_offsetE,x+j_coord_offsetF,
770 x+j_coord_offsetG,x+j_coord_offsetH,
771 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
772 &jy2,&jz2,&jx3,&jy3,&jz3);
774 /* Calculate displacement vector */
775 dx00 = _mm256_sub_ps(ix0,jx0);
776 dy00 = _mm256_sub_ps(iy0,jy0);
777 dz00 = _mm256_sub_ps(iz0,jz0);
778 dx11 = _mm256_sub_ps(ix1,jx1);
779 dy11 = _mm256_sub_ps(iy1,jy1);
780 dz11 = _mm256_sub_ps(iz1,jz1);
781 dx12 = _mm256_sub_ps(ix1,jx2);
782 dy12 = _mm256_sub_ps(iy1,jy2);
783 dz12 = _mm256_sub_ps(iz1,jz2);
784 dx13 = _mm256_sub_ps(ix1,jx3);
785 dy13 = _mm256_sub_ps(iy1,jy3);
786 dz13 = _mm256_sub_ps(iz1,jz3);
787 dx21 = _mm256_sub_ps(ix2,jx1);
788 dy21 = _mm256_sub_ps(iy2,jy1);
789 dz21 = _mm256_sub_ps(iz2,jz1);
790 dx22 = _mm256_sub_ps(ix2,jx2);
791 dy22 = _mm256_sub_ps(iy2,jy2);
792 dz22 = _mm256_sub_ps(iz2,jz2);
793 dx23 = _mm256_sub_ps(ix2,jx3);
794 dy23 = _mm256_sub_ps(iy2,jy3);
795 dz23 = _mm256_sub_ps(iz2,jz3);
796 dx31 = _mm256_sub_ps(ix3,jx1);
797 dy31 = _mm256_sub_ps(iy3,jy1);
798 dz31 = _mm256_sub_ps(iz3,jz1);
799 dx32 = _mm256_sub_ps(ix3,jx2);
800 dy32 = _mm256_sub_ps(iy3,jy2);
801 dz32 = _mm256_sub_ps(iz3,jz2);
802 dx33 = _mm256_sub_ps(ix3,jx3);
803 dy33 = _mm256_sub_ps(iy3,jy3);
804 dz33 = _mm256_sub_ps(iz3,jz3);
806 /* Calculate squared distance and things based on it */
807 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
808 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
809 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
810 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
811 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
812 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
813 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
814 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
815 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
816 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
818 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
819 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
820 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
821 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
822 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
823 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
824 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
825 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
826 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
828 rinvsq00 = gmx_mm256_inv_ps(rsq00);
829 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
830 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
831 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
832 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
833 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
834 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
835 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
836 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
837 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
839 fjx0 = _mm256_setzero_ps();
840 fjy0 = _mm256_setzero_ps();
841 fjz0 = _mm256_setzero_ps();
842 fjx1 = _mm256_setzero_ps();
843 fjy1 = _mm256_setzero_ps();
844 fjz1 = _mm256_setzero_ps();
845 fjx2 = _mm256_setzero_ps();
846 fjy2 = _mm256_setzero_ps();
847 fjz2 = _mm256_setzero_ps();
848 fjx3 = _mm256_setzero_ps();
849 fjy3 = _mm256_setzero_ps();
850 fjz3 = _mm256_setzero_ps();
852 /**************************
853 * CALCULATE INTERACTIONS *
854 **************************/
856 if (gmx_mm256_any_lt(rsq00,rcutoff2))
859 /* LENNARD-JONES DISPERSION/REPULSION */
861 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
862 vvdw6 = _mm256_mul_ps(c6_00,rinvsix);
863 vvdw12 = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
864 vvdw = _mm256_sub_ps(_mm256_mul_ps( _mm256_sub_ps(vvdw12 , _mm256_mul_ps(c12_00,_mm256_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
865 _mm256_mul_ps( _mm256_sub_ps(vvdw6,_mm256_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
866 fvdw = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
868 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
870 /* Update potential sum for this i atom from the interaction with this j atom. */
871 vvdw = _mm256_and_ps(vvdw,cutoff_mask);
872 vvdw = _mm256_andnot_ps(dummy_mask,vvdw);
873 vvdwsum = _mm256_add_ps(vvdwsum,vvdw);
877 fscal = _mm256_and_ps(fscal,cutoff_mask);
879 fscal = _mm256_andnot_ps(dummy_mask,fscal);
881 /* Calculate temporary vectorial force */
882 tx = _mm256_mul_ps(fscal,dx00);
883 ty = _mm256_mul_ps(fscal,dy00);
884 tz = _mm256_mul_ps(fscal,dz00);
886 /* Update vectorial force */
887 fix0 = _mm256_add_ps(fix0,tx);
888 fiy0 = _mm256_add_ps(fiy0,ty);
889 fiz0 = _mm256_add_ps(fiz0,tz);
891 fjx0 = _mm256_add_ps(fjx0,tx);
892 fjy0 = _mm256_add_ps(fjy0,ty);
893 fjz0 = _mm256_add_ps(fjz0,tz);
897 /**************************
898 * CALCULATE INTERACTIONS *
899 **************************/
901 if (gmx_mm256_any_lt(rsq11,rcutoff2))
904 /* REACTION-FIELD ELECTROSTATICS */
905 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
906 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
908 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
910 /* Update potential sum for this i atom from the interaction with this j atom. */
911 velec = _mm256_and_ps(velec,cutoff_mask);
912 velec = _mm256_andnot_ps(dummy_mask,velec);
913 velecsum = _mm256_add_ps(velecsum,velec);
917 fscal = _mm256_and_ps(fscal,cutoff_mask);
919 fscal = _mm256_andnot_ps(dummy_mask,fscal);
921 /* Calculate temporary vectorial force */
922 tx = _mm256_mul_ps(fscal,dx11);
923 ty = _mm256_mul_ps(fscal,dy11);
924 tz = _mm256_mul_ps(fscal,dz11);
926 /* Update vectorial force */
927 fix1 = _mm256_add_ps(fix1,tx);
928 fiy1 = _mm256_add_ps(fiy1,ty);
929 fiz1 = _mm256_add_ps(fiz1,tz);
931 fjx1 = _mm256_add_ps(fjx1,tx);
932 fjy1 = _mm256_add_ps(fjy1,ty);
933 fjz1 = _mm256_add_ps(fjz1,tz);
937 /**************************
938 * CALCULATE INTERACTIONS *
939 **************************/
941 if (gmx_mm256_any_lt(rsq12,rcutoff2))
944 /* REACTION-FIELD ELECTROSTATICS */
945 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
946 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
948 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
950 /* Update potential sum for this i atom from the interaction with this j atom. */
951 velec = _mm256_and_ps(velec,cutoff_mask);
952 velec = _mm256_andnot_ps(dummy_mask,velec);
953 velecsum = _mm256_add_ps(velecsum,velec);
957 fscal = _mm256_and_ps(fscal,cutoff_mask);
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);
977 /**************************
978 * CALCULATE INTERACTIONS *
979 **************************/
981 if (gmx_mm256_any_lt(rsq13,rcutoff2))
984 /* REACTION-FIELD ELECTROSTATICS */
985 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
986 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
988 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
990 /* Update potential sum for this i atom from the interaction with this j atom. */
991 velec = _mm256_and_ps(velec,cutoff_mask);
992 velec = _mm256_andnot_ps(dummy_mask,velec);
993 velecsum = _mm256_add_ps(velecsum,velec);
997 fscal = _mm256_and_ps(fscal,cutoff_mask);
999 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1001 /* Calculate temporary vectorial force */
1002 tx = _mm256_mul_ps(fscal,dx13);
1003 ty = _mm256_mul_ps(fscal,dy13);
1004 tz = _mm256_mul_ps(fscal,dz13);
1006 /* Update vectorial force */
1007 fix1 = _mm256_add_ps(fix1,tx);
1008 fiy1 = _mm256_add_ps(fiy1,ty);
1009 fiz1 = _mm256_add_ps(fiz1,tz);
1011 fjx3 = _mm256_add_ps(fjx3,tx);
1012 fjy3 = _mm256_add_ps(fjy3,ty);
1013 fjz3 = _mm256_add_ps(fjz3,tz);
1017 /**************************
1018 * CALCULATE INTERACTIONS *
1019 **************************/
1021 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1024 /* REACTION-FIELD ELECTROSTATICS */
1025 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1026 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1028 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1030 /* Update potential sum for this i atom from the interaction with this j atom. */
1031 velec = _mm256_and_ps(velec,cutoff_mask);
1032 velec = _mm256_andnot_ps(dummy_mask,velec);
1033 velecsum = _mm256_add_ps(velecsum,velec);
1037 fscal = _mm256_and_ps(fscal,cutoff_mask);
1039 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1041 /* Calculate temporary vectorial force */
1042 tx = _mm256_mul_ps(fscal,dx21);
1043 ty = _mm256_mul_ps(fscal,dy21);
1044 tz = _mm256_mul_ps(fscal,dz21);
1046 /* Update vectorial force */
1047 fix2 = _mm256_add_ps(fix2,tx);
1048 fiy2 = _mm256_add_ps(fiy2,ty);
1049 fiz2 = _mm256_add_ps(fiz2,tz);
1051 fjx1 = _mm256_add_ps(fjx1,tx);
1052 fjy1 = _mm256_add_ps(fjy1,ty);
1053 fjz1 = _mm256_add_ps(fjz1,tz);
1057 /**************************
1058 * CALCULATE INTERACTIONS *
1059 **************************/
1061 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1064 /* REACTION-FIELD ELECTROSTATICS */
1065 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1066 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1068 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1070 /* Update potential sum for this i atom from the interaction with this j atom. */
1071 velec = _mm256_and_ps(velec,cutoff_mask);
1072 velec = _mm256_andnot_ps(dummy_mask,velec);
1073 velecsum = _mm256_add_ps(velecsum,velec);
1077 fscal = _mm256_and_ps(fscal,cutoff_mask);
1079 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1081 /* Calculate temporary vectorial force */
1082 tx = _mm256_mul_ps(fscal,dx22);
1083 ty = _mm256_mul_ps(fscal,dy22);
1084 tz = _mm256_mul_ps(fscal,dz22);
1086 /* Update vectorial force */
1087 fix2 = _mm256_add_ps(fix2,tx);
1088 fiy2 = _mm256_add_ps(fiy2,ty);
1089 fiz2 = _mm256_add_ps(fiz2,tz);
1091 fjx2 = _mm256_add_ps(fjx2,tx);
1092 fjy2 = _mm256_add_ps(fjy2,ty);
1093 fjz2 = _mm256_add_ps(fjz2,tz);
1097 /**************************
1098 * CALCULATE INTERACTIONS *
1099 **************************/
1101 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1104 /* REACTION-FIELD ELECTROSTATICS */
1105 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
1106 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1108 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1110 /* Update potential sum for this i atom from the interaction with this j atom. */
1111 velec = _mm256_and_ps(velec,cutoff_mask);
1112 velec = _mm256_andnot_ps(dummy_mask,velec);
1113 velecsum = _mm256_add_ps(velecsum,velec);
1117 fscal = _mm256_and_ps(fscal,cutoff_mask);
1119 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1121 /* Calculate temporary vectorial force */
1122 tx = _mm256_mul_ps(fscal,dx23);
1123 ty = _mm256_mul_ps(fscal,dy23);
1124 tz = _mm256_mul_ps(fscal,dz23);
1126 /* Update vectorial force */
1127 fix2 = _mm256_add_ps(fix2,tx);
1128 fiy2 = _mm256_add_ps(fiy2,ty);
1129 fiz2 = _mm256_add_ps(fiz2,tz);
1131 fjx3 = _mm256_add_ps(fjx3,tx);
1132 fjy3 = _mm256_add_ps(fjy3,ty);
1133 fjz3 = _mm256_add_ps(fjz3,tz);
1137 /**************************
1138 * CALCULATE INTERACTIONS *
1139 **************************/
1141 if (gmx_mm256_any_lt(rsq31,rcutoff2))
1144 /* REACTION-FIELD ELECTROSTATICS */
1145 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
1146 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1148 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1150 /* Update potential sum for this i atom from the interaction with this j atom. */
1151 velec = _mm256_and_ps(velec,cutoff_mask);
1152 velec = _mm256_andnot_ps(dummy_mask,velec);
1153 velecsum = _mm256_add_ps(velecsum,velec);
1157 fscal = _mm256_and_ps(fscal,cutoff_mask);
1159 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1161 /* Calculate temporary vectorial force */
1162 tx = _mm256_mul_ps(fscal,dx31);
1163 ty = _mm256_mul_ps(fscal,dy31);
1164 tz = _mm256_mul_ps(fscal,dz31);
1166 /* Update vectorial force */
1167 fix3 = _mm256_add_ps(fix3,tx);
1168 fiy3 = _mm256_add_ps(fiy3,ty);
1169 fiz3 = _mm256_add_ps(fiz3,tz);
1171 fjx1 = _mm256_add_ps(fjx1,tx);
1172 fjy1 = _mm256_add_ps(fjy1,ty);
1173 fjz1 = _mm256_add_ps(fjz1,tz);
1177 /**************************
1178 * CALCULATE INTERACTIONS *
1179 **************************/
1181 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1184 /* REACTION-FIELD ELECTROSTATICS */
1185 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
1186 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1188 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1190 /* Update potential sum for this i atom from the interaction with this j atom. */
1191 velec = _mm256_and_ps(velec,cutoff_mask);
1192 velec = _mm256_andnot_ps(dummy_mask,velec);
1193 velecsum = _mm256_add_ps(velecsum,velec);
1197 fscal = _mm256_and_ps(fscal,cutoff_mask);
1199 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1201 /* Calculate temporary vectorial force */
1202 tx = _mm256_mul_ps(fscal,dx32);
1203 ty = _mm256_mul_ps(fscal,dy32);
1204 tz = _mm256_mul_ps(fscal,dz32);
1206 /* Update vectorial force */
1207 fix3 = _mm256_add_ps(fix3,tx);
1208 fiy3 = _mm256_add_ps(fiy3,ty);
1209 fiz3 = _mm256_add_ps(fiz3,tz);
1211 fjx2 = _mm256_add_ps(fjx2,tx);
1212 fjy2 = _mm256_add_ps(fjy2,ty);
1213 fjz2 = _mm256_add_ps(fjz2,tz);
1217 /**************************
1218 * CALCULATE INTERACTIONS *
1219 **************************/
1221 if (gmx_mm256_any_lt(rsq33,rcutoff2))
1224 /* REACTION-FIELD ELECTROSTATICS */
1225 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
1226 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1228 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1230 /* Update potential sum for this i atom from the interaction with this j atom. */
1231 velec = _mm256_and_ps(velec,cutoff_mask);
1232 velec = _mm256_andnot_ps(dummy_mask,velec);
1233 velecsum = _mm256_add_ps(velecsum,velec);
1237 fscal = _mm256_and_ps(fscal,cutoff_mask);
1239 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1241 /* Calculate temporary vectorial force */
1242 tx = _mm256_mul_ps(fscal,dx33);
1243 ty = _mm256_mul_ps(fscal,dy33);
1244 tz = _mm256_mul_ps(fscal,dz33);
1246 /* Update vectorial force */
1247 fix3 = _mm256_add_ps(fix3,tx);
1248 fiy3 = _mm256_add_ps(fiy3,ty);
1249 fiz3 = _mm256_add_ps(fiz3,tz);
1251 fjx3 = _mm256_add_ps(fjx3,tx);
1252 fjy3 = _mm256_add_ps(fjy3,ty);
1253 fjz3 = _mm256_add_ps(fjz3,tz);
1257 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1258 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1259 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1260 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1261 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1262 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1263 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1264 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1266 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1267 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1268 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1270 /* Inner loop uses 368 flops */
1273 /* End of innermost loop */
1275 gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1276 f+i_coord_offset,fshift+i_shift_offset);
1279 /* Update potential energies */
1280 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1281 gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1283 /* Increment number of inner iterations */
1284 inneriter += j_index_end - j_index_start;
1286 /* Outer loop uses 26 flops */
1289 /* Increment number of outer iterations */
1292 /* Update outer/inner flops */
1294 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*368);
1297 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_avx_256_single
1298 * Electrostatics interaction: ReactionField
1299 * VdW interaction: LennardJones
1300 * Geometry: Water4-Water4
1301 * Calculate force/pot: Force
1304 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_avx_256_single
1305 (t_nblist * gmx_restrict nlist,
1306 rvec * gmx_restrict xx,
1307 rvec * gmx_restrict ff,
1308 t_forcerec * gmx_restrict fr,
1309 t_mdatoms * gmx_restrict mdatoms,
1310 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1311 t_nrnb * gmx_restrict nrnb)
1313 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1314 * just 0 for non-waters.
1315 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1316 * jnr indices corresponding to data put in the four positions in the SIMD register.
1318 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1319 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1320 int jnrA,jnrB,jnrC,jnrD;
1321 int jnrE,jnrF,jnrG,jnrH;
1322 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1323 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1324 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1325 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1326 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1327 real rcutoff_scalar;
1328 real *shiftvec,*fshift,*x,*f;
1329 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1330 real scratch[4*DIM];
1331 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1332 real * vdwioffsetptr0;
1333 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1334 real * vdwioffsetptr1;
1335 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1336 real * vdwioffsetptr2;
1337 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1338 real * vdwioffsetptr3;
1339 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1340 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1341 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1342 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1343 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1344 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1345 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1346 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
1347 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1348 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1349 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1350 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1351 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1352 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1353 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1354 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1355 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1356 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1357 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1358 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1361 __m256 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1364 __m256 one_sixth = _mm256_set1_ps(1.0/6.0);
1365 __m256 one_twelfth = _mm256_set1_ps(1.0/12.0);
1366 __m256 dummy_mask,cutoff_mask;
1367 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1368 __m256 one = _mm256_set1_ps(1.0);
1369 __m256 two = _mm256_set1_ps(2.0);
1375 jindex = nlist->jindex;
1377 shiftidx = nlist->shift;
1379 shiftvec = fr->shift_vec[0];
1380 fshift = fr->fshift[0];
1381 facel = _mm256_set1_ps(fr->epsfac);
1382 charge = mdatoms->chargeA;
1383 krf = _mm256_set1_ps(fr->ic->k_rf);
1384 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1385 crf = _mm256_set1_ps(fr->ic->c_rf);
1386 nvdwtype = fr->ntype;
1387 vdwparam = fr->nbfp;
1388 vdwtype = mdatoms->typeA;
1390 /* Setup water-specific parameters */
1391 inr = nlist->iinr[0];
1392 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1393 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1394 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
1395 vdwioffsetptr0 = vdwparam+2*nvdwtype*vdwtype[inr+0];
1397 jq1 = _mm256_set1_ps(charge[inr+1]);
1398 jq2 = _mm256_set1_ps(charge[inr+2]);
1399 jq3 = _mm256_set1_ps(charge[inr+3]);
1400 vdwjidx0A = 2*vdwtype[inr+0];
1401 c6_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1402 c12_00 = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1403 qq11 = _mm256_mul_ps(iq1,jq1);
1404 qq12 = _mm256_mul_ps(iq1,jq2);
1405 qq13 = _mm256_mul_ps(iq1,jq3);
1406 qq21 = _mm256_mul_ps(iq2,jq1);
1407 qq22 = _mm256_mul_ps(iq2,jq2);
1408 qq23 = _mm256_mul_ps(iq2,jq3);
1409 qq31 = _mm256_mul_ps(iq3,jq1);
1410 qq32 = _mm256_mul_ps(iq3,jq2);
1411 qq33 = _mm256_mul_ps(iq3,jq3);
1413 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1414 rcutoff_scalar = fr->rcoulomb;
1415 rcutoff = _mm256_set1_ps(rcutoff_scalar);
1416 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
1418 sh_vdw_invrcut6 = _mm256_set1_ps(fr->ic->sh_invrc6);
1419 rvdw = _mm256_set1_ps(fr->rvdw);
1421 /* Avoid stupid compiler warnings */
1422 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1423 j_coord_offsetA = 0;
1424 j_coord_offsetB = 0;
1425 j_coord_offsetC = 0;
1426 j_coord_offsetD = 0;
1427 j_coord_offsetE = 0;
1428 j_coord_offsetF = 0;
1429 j_coord_offsetG = 0;
1430 j_coord_offsetH = 0;
1435 for(iidx=0;iidx<4*DIM;iidx++)
1437 scratch[iidx] = 0.0;
1440 /* Start outer loop over neighborlists */
1441 for(iidx=0; iidx<nri; iidx++)
1443 /* Load shift vector for this list */
1444 i_shift_offset = DIM*shiftidx[iidx];
1446 /* Load limits for loop over neighbors */
1447 j_index_start = jindex[iidx];
1448 j_index_end = jindex[iidx+1];
1450 /* Get outer coordinate index */
1452 i_coord_offset = DIM*inr;
1454 /* Load i particle coords and add shift vector */
1455 gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1456 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1458 fix0 = _mm256_setzero_ps();
1459 fiy0 = _mm256_setzero_ps();
1460 fiz0 = _mm256_setzero_ps();
1461 fix1 = _mm256_setzero_ps();
1462 fiy1 = _mm256_setzero_ps();
1463 fiz1 = _mm256_setzero_ps();
1464 fix2 = _mm256_setzero_ps();
1465 fiy2 = _mm256_setzero_ps();
1466 fiz2 = _mm256_setzero_ps();
1467 fix3 = _mm256_setzero_ps();
1468 fiy3 = _mm256_setzero_ps();
1469 fiz3 = _mm256_setzero_ps();
1471 /* Start inner kernel loop */
1472 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1475 /* Get j neighbor index, and coordinate index */
1477 jnrB = jjnr[jidx+1];
1478 jnrC = jjnr[jidx+2];
1479 jnrD = jjnr[jidx+3];
1480 jnrE = jjnr[jidx+4];
1481 jnrF = jjnr[jidx+5];
1482 jnrG = jjnr[jidx+6];
1483 jnrH = jjnr[jidx+7];
1484 j_coord_offsetA = DIM*jnrA;
1485 j_coord_offsetB = DIM*jnrB;
1486 j_coord_offsetC = DIM*jnrC;
1487 j_coord_offsetD = DIM*jnrD;
1488 j_coord_offsetE = DIM*jnrE;
1489 j_coord_offsetF = DIM*jnrF;
1490 j_coord_offsetG = DIM*jnrG;
1491 j_coord_offsetH = DIM*jnrH;
1493 /* load j atom coordinates */
1494 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1495 x+j_coord_offsetC,x+j_coord_offsetD,
1496 x+j_coord_offsetE,x+j_coord_offsetF,
1497 x+j_coord_offsetG,x+j_coord_offsetH,
1498 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1499 &jy2,&jz2,&jx3,&jy3,&jz3);
1501 /* Calculate displacement vector */
1502 dx00 = _mm256_sub_ps(ix0,jx0);
1503 dy00 = _mm256_sub_ps(iy0,jy0);
1504 dz00 = _mm256_sub_ps(iz0,jz0);
1505 dx11 = _mm256_sub_ps(ix1,jx1);
1506 dy11 = _mm256_sub_ps(iy1,jy1);
1507 dz11 = _mm256_sub_ps(iz1,jz1);
1508 dx12 = _mm256_sub_ps(ix1,jx2);
1509 dy12 = _mm256_sub_ps(iy1,jy2);
1510 dz12 = _mm256_sub_ps(iz1,jz2);
1511 dx13 = _mm256_sub_ps(ix1,jx3);
1512 dy13 = _mm256_sub_ps(iy1,jy3);
1513 dz13 = _mm256_sub_ps(iz1,jz3);
1514 dx21 = _mm256_sub_ps(ix2,jx1);
1515 dy21 = _mm256_sub_ps(iy2,jy1);
1516 dz21 = _mm256_sub_ps(iz2,jz1);
1517 dx22 = _mm256_sub_ps(ix2,jx2);
1518 dy22 = _mm256_sub_ps(iy2,jy2);
1519 dz22 = _mm256_sub_ps(iz2,jz2);
1520 dx23 = _mm256_sub_ps(ix2,jx3);
1521 dy23 = _mm256_sub_ps(iy2,jy3);
1522 dz23 = _mm256_sub_ps(iz2,jz3);
1523 dx31 = _mm256_sub_ps(ix3,jx1);
1524 dy31 = _mm256_sub_ps(iy3,jy1);
1525 dz31 = _mm256_sub_ps(iz3,jz1);
1526 dx32 = _mm256_sub_ps(ix3,jx2);
1527 dy32 = _mm256_sub_ps(iy3,jy2);
1528 dz32 = _mm256_sub_ps(iz3,jz2);
1529 dx33 = _mm256_sub_ps(ix3,jx3);
1530 dy33 = _mm256_sub_ps(iy3,jy3);
1531 dz33 = _mm256_sub_ps(iz3,jz3);
1533 /* Calculate squared distance and things based on it */
1534 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1535 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1536 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1537 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1538 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1539 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1540 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
1541 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
1542 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
1543 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
1545 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1546 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1547 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
1548 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1549 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1550 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
1551 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
1552 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
1553 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
1555 rinvsq00 = gmx_mm256_inv_ps(rsq00);
1556 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1557 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1558 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
1559 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1560 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1561 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
1562 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
1563 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
1564 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
1566 fjx0 = _mm256_setzero_ps();
1567 fjy0 = _mm256_setzero_ps();
1568 fjz0 = _mm256_setzero_ps();
1569 fjx1 = _mm256_setzero_ps();
1570 fjy1 = _mm256_setzero_ps();
1571 fjz1 = _mm256_setzero_ps();
1572 fjx2 = _mm256_setzero_ps();
1573 fjy2 = _mm256_setzero_ps();
1574 fjz2 = _mm256_setzero_ps();
1575 fjx3 = _mm256_setzero_ps();
1576 fjy3 = _mm256_setzero_ps();
1577 fjz3 = _mm256_setzero_ps();
1579 /**************************
1580 * CALCULATE INTERACTIONS *
1581 **************************/
1583 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1586 /* LENNARD-JONES DISPERSION/REPULSION */
1588 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1589 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
1591 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1595 fscal = _mm256_and_ps(fscal,cutoff_mask);
1597 /* Calculate temporary vectorial force */
1598 tx = _mm256_mul_ps(fscal,dx00);
1599 ty = _mm256_mul_ps(fscal,dy00);
1600 tz = _mm256_mul_ps(fscal,dz00);
1602 /* Update vectorial force */
1603 fix0 = _mm256_add_ps(fix0,tx);
1604 fiy0 = _mm256_add_ps(fiy0,ty);
1605 fiz0 = _mm256_add_ps(fiz0,tz);
1607 fjx0 = _mm256_add_ps(fjx0,tx);
1608 fjy0 = _mm256_add_ps(fjy0,ty);
1609 fjz0 = _mm256_add_ps(fjz0,tz);
1613 /**************************
1614 * CALCULATE INTERACTIONS *
1615 **************************/
1617 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1620 /* REACTION-FIELD ELECTROSTATICS */
1621 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1623 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1627 fscal = _mm256_and_ps(fscal,cutoff_mask);
1629 /* Calculate temporary vectorial force */
1630 tx = _mm256_mul_ps(fscal,dx11);
1631 ty = _mm256_mul_ps(fscal,dy11);
1632 tz = _mm256_mul_ps(fscal,dz11);
1634 /* Update vectorial force */
1635 fix1 = _mm256_add_ps(fix1,tx);
1636 fiy1 = _mm256_add_ps(fiy1,ty);
1637 fiz1 = _mm256_add_ps(fiz1,tz);
1639 fjx1 = _mm256_add_ps(fjx1,tx);
1640 fjy1 = _mm256_add_ps(fjy1,ty);
1641 fjz1 = _mm256_add_ps(fjz1,tz);
1645 /**************************
1646 * CALCULATE INTERACTIONS *
1647 **************************/
1649 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1652 /* REACTION-FIELD ELECTROSTATICS */
1653 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1655 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1659 fscal = _mm256_and_ps(fscal,cutoff_mask);
1661 /* Calculate temporary vectorial force */
1662 tx = _mm256_mul_ps(fscal,dx12);
1663 ty = _mm256_mul_ps(fscal,dy12);
1664 tz = _mm256_mul_ps(fscal,dz12);
1666 /* Update vectorial force */
1667 fix1 = _mm256_add_ps(fix1,tx);
1668 fiy1 = _mm256_add_ps(fiy1,ty);
1669 fiz1 = _mm256_add_ps(fiz1,tz);
1671 fjx2 = _mm256_add_ps(fjx2,tx);
1672 fjy2 = _mm256_add_ps(fjy2,ty);
1673 fjz2 = _mm256_add_ps(fjz2,tz);
1677 /**************************
1678 * CALCULATE INTERACTIONS *
1679 **************************/
1681 if (gmx_mm256_any_lt(rsq13,rcutoff2))
1684 /* REACTION-FIELD ELECTROSTATICS */
1685 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1687 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1691 fscal = _mm256_and_ps(fscal,cutoff_mask);
1693 /* Calculate temporary vectorial force */
1694 tx = _mm256_mul_ps(fscal,dx13);
1695 ty = _mm256_mul_ps(fscal,dy13);
1696 tz = _mm256_mul_ps(fscal,dz13);
1698 /* Update vectorial force */
1699 fix1 = _mm256_add_ps(fix1,tx);
1700 fiy1 = _mm256_add_ps(fiy1,ty);
1701 fiz1 = _mm256_add_ps(fiz1,tz);
1703 fjx3 = _mm256_add_ps(fjx3,tx);
1704 fjy3 = _mm256_add_ps(fjy3,ty);
1705 fjz3 = _mm256_add_ps(fjz3,tz);
1709 /**************************
1710 * CALCULATE INTERACTIONS *
1711 **************************/
1713 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1716 /* REACTION-FIELD ELECTROSTATICS */
1717 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1719 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1723 fscal = _mm256_and_ps(fscal,cutoff_mask);
1725 /* Calculate temporary vectorial force */
1726 tx = _mm256_mul_ps(fscal,dx21);
1727 ty = _mm256_mul_ps(fscal,dy21);
1728 tz = _mm256_mul_ps(fscal,dz21);
1730 /* Update vectorial force */
1731 fix2 = _mm256_add_ps(fix2,tx);
1732 fiy2 = _mm256_add_ps(fiy2,ty);
1733 fiz2 = _mm256_add_ps(fiz2,tz);
1735 fjx1 = _mm256_add_ps(fjx1,tx);
1736 fjy1 = _mm256_add_ps(fjy1,ty);
1737 fjz1 = _mm256_add_ps(fjz1,tz);
1741 /**************************
1742 * CALCULATE INTERACTIONS *
1743 **************************/
1745 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1748 /* REACTION-FIELD ELECTROSTATICS */
1749 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1751 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1755 fscal = _mm256_and_ps(fscal,cutoff_mask);
1757 /* Calculate temporary vectorial force */
1758 tx = _mm256_mul_ps(fscal,dx22);
1759 ty = _mm256_mul_ps(fscal,dy22);
1760 tz = _mm256_mul_ps(fscal,dz22);
1762 /* Update vectorial force */
1763 fix2 = _mm256_add_ps(fix2,tx);
1764 fiy2 = _mm256_add_ps(fiy2,ty);
1765 fiz2 = _mm256_add_ps(fiz2,tz);
1767 fjx2 = _mm256_add_ps(fjx2,tx);
1768 fjy2 = _mm256_add_ps(fjy2,ty);
1769 fjz2 = _mm256_add_ps(fjz2,tz);
1773 /**************************
1774 * CALCULATE INTERACTIONS *
1775 **************************/
1777 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1780 /* REACTION-FIELD ELECTROSTATICS */
1781 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1783 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1787 fscal = _mm256_and_ps(fscal,cutoff_mask);
1789 /* Calculate temporary vectorial force */
1790 tx = _mm256_mul_ps(fscal,dx23);
1791 ty = _mm256_mul_ps(fscal,dy23);
1792 tz = _mm256_mul_ps(fscal,dz23);
1794 /* Update vectorial force */
1795 fix2 = _mm256_add_ps(fix2,tx);
1796 fiy2 = _mm256_add_ps(fiy2,ty);
1797 fiz2 = _mm256_add_ps(fiz2,tz);
1799 fjx3 = _mm256_add_ps(fjx3,tx);
1800 fjy3 = _mm256_add_ps(fjy3,ty);
1801 fjz3 = _mm256_add_ps(fjz3,tz);
1805 /**************************
1806 * CALCULATE INTERACTIONS *
1807 **************************/
1809 if (gmx_mm256_any_lt(rsq31,rcutoff2))
1812 /* REACTION-FIELD ELECTROSTATICS */
1813 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1815 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1819 fscal = _mm256_and_ps(fscal,cutoff_mask);
1821 /* Calculate temporary vectorial force */
1822 tx = _mm256_mul_ps(fscal,dx31);
1823 ty = _mm256_mul_ps(fscal,dy31);
1824 tz = _mm256_mul_ps(fscal,dz31);
1826 /* Update vectorial force */
1827 fix3 = _mm256_add_ps(fix3,tx);
1828 fiy3 = _mm256_add_ps(fiy3,ty);
1829 fiz3 = _mm256_add_ps(fiz3,tz);
1831 fjx1 = _mm256_add_ps(fjx1,tx);
1832 fjy1 = _mm256_add_ps(fjy1,ty);
1833 fjz1 = _mm256_add_ps(fjz1,tz);
1837 /**************************
1838 * CALCULATE INTERACTIONS *
1839 **************************/
1841 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1844 /* REACTION-FIELD ELECTROSTATICS */
1845 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1847 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1851 fscal = _mm256_and_ps(fscal,cutoff_mask);
1853 /* Calculate temporary vectorial force */
1854 tx = _mm256_mul_ps(fscal,dx32);
1855 ty = _mm256_mul_ps(fscal,dy32);
1856 tz = _mm256_mul_ps(fscal,dz32);
1858 /* Update vectorial force */
1859 fix3 = _mm256_add_ps(fix3,tx);
1860 fiy3 = _mm256_add_ps(fiy3,ty);
1861 fiz3 = _mm256_add_ps(fiz3,tz);
1863 fjx2 = _mm256_add_ps(fjx2,tx);
1864 fjy2 = _mm256_add_ps(fjy2,ty);
1865 fjz2 = _mm256_add_ps(fjz2,tz);
1869 /**************************
1870 * CALCULATE INTERACTIONS *
1871 **************************/
1873 if (gmx_mm256_any_lt(rsq33,rcutoff2))
1876 /* REACTION-FIELD ELECTROSTATICS */
1877 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1879 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1883 fscal = _mm256_and_ps(fscal,cutoff_mask);
1885 /* Calculate temporary vectorial force */
1886 tx = _mm256_mul_ps(fscal,dx33);
1887 ty = _mm256_mul_ps(fscal,dy33);
1888 tz = _mm256_mul_ps(fscal,dz33);
1890 /* Update vectorial force */
1891 fix3 = _mm256_add_ps(fix3,tx);
1892 fiy3 = _mm256_add_ps(fiy3,ty);
1893 fiz3 = _mm256_add_ps(fiz3,tz);
1895 fjx3 = _mm256_add_ps(fjx3,tx);
1896 fjy3 = _mm256_add_ps(fjy3,ty);
1897 fjz3 = _mm256_add_ps(fjz3,tz);
1901 fjptrA = f+j_coord_offsetA;
1902 fjptrB = f+j_coord_offsetB;
1903 fjptrC = f+j_coord_offsetC;
1904 fjptrD = f+j_coord_offsetD;
1905 fjptrE = f+j_coord_offsetE;
1906 fjptrF = f+j_coord_offsetF;
1907 fjptrG = f+j_coord_offsetG;
1908 fjptrH = f+j_coord_offsetH;
1910 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1911 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1912 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1914 /* Inner loop uses 303 flops */
1917 if(jidx<j_index_end)
1920 /* Get j neighbor index, and coordinate index */
1921 jnrlistA = jjnr[jidx];
1922 jnrlistB = jjnr[jidx+1];
1923 jnrlistC = jjnr[jidx+2];
1924 jnrlistD = jjnr[jidx+3];
1925 jnrlistE = jjnr[jidx+4];
1926 jnrlistF = jjnr[jidx+5];
1927 jnrlistG = jjnr[jidx+6];
1928 jnrlistH = jjnr[jidx+7];
1929 /* Sign of each element will be negative for non-real atoms.
1930 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1931 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1933 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1934 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1936 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1937 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1938 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1939 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1940 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1941 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1942 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1943 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1944 j_coord_offsetA = DIM*jnrA;
1945 j_coord_offsetB = DIM*jnrB;
1946 j_coord_offsetC = DIM*jnrC;
1947 j_coord_offsetD = DIM*jnrD;
1948 j_coord_offsetE = DIM*jnrE;
1949 j_coord_offsetF = DIM*jnrF;
1950 j_coord_offsetG = DIM*jnrG;
1951 j_coord_offsetH = DIM*jnrH;
1953 /* load j atom coordinates */
1954 gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1955 x+j_coord_offsetC,x+j_coord_offsetD,
1956 x+j_coord_offsetE,x+j_coord_offsetF,
1957 x+j_coord_offsetG,x+j_coord_offsetH,
1958 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1959 &jy2,&jz2,&jx3,&jy3,&jz3);
1961 /* Calculate displacement vector */
1962 dx00 = _mm256_sub_ps(ix0,jx0);
1963 dy00 = _mm256_sub_ps(iy0,jy0);
1964 dz00 = _mm256_sub_ps(iz0,jz0);
1965 dx11 = _mm256_sub_ps(ix1,jx1);
1966 dy11 = _mm256_sub_ps(iy1,jy1);
1967 dz11 = _mm256_sub_ps(iz1,jz1);
1968 dx12 = _mm256_sub_ps(ix1,jx2);
1969 dy12 = _mm256_sub_ps(iy1,jy2);
1970 dz12 = _mm256_sub_ps(iz1,jz2);
1971 dx13 = _mm256_sub_ps(ix1,jx3);
1972 dy13 = _mm256_sub_ps(iy1,jy3);
1973 dz13 = _mm256_sub_ps(iz1,jz3);
1974 dx21 = _mm256_sub_ps(ix2,jx1);
1975 dy21 = _mm256_sub_ps(iy2,jy1);
1976 dz21 = _mm256_sub_ps(iz2,jz1);
1977 dx22 = _mm256_sub_ps(ix2,jx2);
1978 dy22 = _mm256_sub_ps(iy2,jy2);
1979 dz22 = _mm256_sub_ps(iz2,jz2);
1980 dx23 = _mm256_sub_ps(ix2,jx3);
1981 dy23 = _mm256_sub_ps(iy2,jy3);
1982 dz23 = _mm256_sub_ps(iz2,jz3);
1983 dx31 = _mm256_sub_ps(ix3,jx1);
1984 dy31 = _mm256_sub_ps(iy3,jy1);
1985 dz31 = _mm256_sub_ps(iz3,jz1);
1986 dx32 = _mm256_sub_ps(ix3,jx2);
1987 dy32 = _mm256_sub_ps(iy3,jy2);
1988 dz32 = _mm256_sub_ps(iz3,jz2);
1989 dx33 = _mm256_sub_ps(ix3,jx3);
1990 dy33 = _mm256_sub_ps(iy3,jy3);
1991 dz33 = _mm256_sub_ps(iz3,jz3);
1993 /* Calculate squared distance and things based on it */
1994 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1995 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1996 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1997 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1998 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1999 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
2000 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
2001 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
2002 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
2003 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
2005 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
2006 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
2007 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
2008 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
2009 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
2010 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
2011 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
2012 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
2013 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
2015 rinvsq00 = gmx_mm256_inv_ps(rsq00);
2016 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
2017 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
2018 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
2019 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
2020 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
2021 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
2022 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
2023 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
2024 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
2026 fjx0 = _mm256_setzero_ps();
2027 fjy0 = _mm256_setzero_ps();
2028 fjz0 = _mm256_setzero_ps();
2029 fjx1 = _mm256_setzero_ps();
2030 fjy1 = _mm256_setzero_ps();
2031 fjz1 = _mm256_setzero_ps();
2032 fjx2 = _mm256_setzero_ps();
2033 fjy2 = _mm256_setzero_ps();
2034 fjz2 = _mm256_setzero_ps();
2035 fjx3 = _mm256_setzero_ps();
2036 fjy3 = _mm256_setzero_ps();
2037 fjz3 = _mm256_setzero_ps();
2039 /**************************
2040 * CALCULATE INTERACTIONS *
2041 **************************/
2043 if (gmx_mm256_any_lt(rsq00,rcutoff2))
2046 /* LENNARD-JONES DISPERSION/REPULSION */
2048 rinvsix = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
2049 fvdw = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
2051 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
2055 fscal = _mm256_and_ps(fscal,cutoff_mask);
2057 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2059 /* Calculate temporary vectorial force */
2060 tx = _mm256_mul_ps(fscal,dx00);
2061 ty = _mm256_mul_ps(fscal,dy00);
2062 tz = _mm256_mul_ps(fscal,dz00);
2064 /* Update vectorial force */
2065 fix0 = _mm256_add_ps(fix0,tx);
2066 fiy0 = _mm256_add_ps(fiy0,ty);
2067 fiz0 = _mm256_add_ps(fiz0,tz);
2069 fjx0 = _mm256_add_ps(fjx0,tx);
2070 fjy0 = _mm256_add_ps(fjy0,ty);
2071 fjz0 = _mm256_add_ps(fjz0,tz);
2075 /**************************
2076 * CALCULATE INTERACTIONS *
2077 **************************/
2079 if (gmx_mm256_any_lt(rsq11,rcutoff2))
2082 /* REACTION-FIELD ELECTROSTATICS */
2083 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
2085 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
2089 fscal = _mm256_and_ps(fscal,cutoff_mask);
2091 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2093 /* Calculate temporary vectorial force */
2094 tx = _mm256_mul_ps(fscal,dx11);
2095 ty = _mm256_mul_ps(fscal,dy11);
2096 tz = _mm256_mul_ps(fscal,dz11);
2098 /* Update vectorial force */
2099 fix1 = _mm256_add_ps(fix1,tx);
2100 fiy1 = _mm256_add_ps(fiy1,ty);
2101 fiz1 = _mm256_add_ps(fiz1,tz);
2103 fjx1 = _mm256_add_ps(fjx1,tx);
2104 fjy1 = _mm256_add_ps(fjy1,ty);
2105 fjz1 = _mm256_add_ps(fjz1,tz);
2109 /**************************
2110 * CALCULATE INTERACTIONS *
2111 **************************/
2113 if (gmx_mm256_any_lt(rsq12,rcutoff2))
2116 /* REACTION-FIELD ELECTROSTATICS */
2117 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
2119 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
2123 fscal = _mm256_and_ps(fscal,cutoff_mask);
2125 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2127 /* Calculate temporary vectorial force */
2128 tx = _mm256_mul_ps(fscal,dx12);
2129 ty = _mm256_mul_ps(fscal,dy12);
2130 tz = _mm256_mul_ps(fscal,dz12);
2132 /* Update vectorial force */
2133 fix1 = _mm256_add_ps(fix1,tx);
2134 fiy1 = _mm256_add_ps(fiy1,ty);
2135 fiz1 = _mm256_add_ps(fiz1,tz);
2137 fjx2 = _mm256_add_ps(fjx2,tx);
2138 fjy2 = _mm256_add_ps(fjy2,ty);
2139 fjz2 = _mm256_add_ps(fjz2,tz);
2143 /**************************
2144 * CALCULATE INTERACTIONS *
2145 **************************/
2147 if (gmx_mm256_any_lt(rsq13,rcutoff2))
2150 /* REACTION-FIELD ELECTROSTATICS */
2151 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
2153 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
2157 fscal = _mm256_and_ps(fscal,cutoff_mask);
2159 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2161 /* Calculate temporary vectorial force */
2162 tx = _mm256_mul_ps(fscal,dx13);
2163 ty = _mm256_mul_ps(fscal,dy13);
2164 tz = _mm256_mul_ps(fscal,dz13);
2166 /* Update vectorial force */
2167 fix1 = _mm256_add_ps(fix1,tx);
2168 fiy1 = _mm256_add_ps(fiy1,ty);
2169 fiz1 = _mm256_add_ps(fiz1,tz);
2171 fjx3 = _mm256_add_ps(fjx3,tx);
2172 fjy3 = _mm256_add_ps(fjy3,ty);
2173 fjz3 = _mm256_add_ps(fjz3,tz);
2177 /**************************
2178 * CALCULATE INTERACTIONS *
2179 **************************/
2181 if (gmx_mm256_any_lt(rsq21,rcutoff2))
2184 /* REACTION-FIELD ELECTROSTATICS */
2185 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
2187 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
2191 fscal = _mm256_and_ps(fscal,cutoff_mask);
2193 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2195 /* Calculate temporary vectorial force */
2196 tx = _mm256_mul_ps(fscal,dx21);
2197 ty = _mm256_mul_ps(fscal,dy21);
2198 tz = _mm256_mul_ps(fscal,dz21);
2200 /* Update vectorial force */
2201 fix2 = _mm256_add_ps(fix2,tx);
2202 fiy2 = _mm256_add_ps(fiy2,ty);
2203 fiz2 = _mm256_add_ps(fiz2,tz);
2205 fjx1 = _mm256_add_ps(fjx1,tx);
2206 fjy1 = _mm256_add_ps(fjy1,ty);
2207 fjz1 = _mm256_add_ps(fjz1,tz);
2211 /**************************
2212 * CALCULATE INTERACTIONS *
2213 **************************/
2215 if (gmx_mm256_any_lt(rsq22,rcutoff2))
2218 /* REACTION-FIELD ELECTROSTATICS */
2219 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2221 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
2225 fscal = _mm256_and_ps(fscal,cutoff_mask);
2227 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2229 /* Calculate temporary vectorial force */
2230 tx = _mm256_mul_ps(fscal,dx22);
2231 ty = _mm256_mul_ps(fscal,dy22);
2232 tz = _mm256_mul_ps(fscal,dz22);
2234 /* Update vectorial force */
2235 fix2 = _mm256_add_ps(fix2,tx);
2236 fiy2 = _mm256_add_ps(fiy2,ty);
2237 fiz2 = _mm256_add_ps(fiz2,tz);
2239 fjx2 = _mm256_add_ps(fjx2,tx);
2240 fjy2 = _mm256_add_ps(fjy2,ty);
2241 fjz2 = _mm256_add_ps(fjz2,tz);
2245 /**************************
2246 * CALCULATE INTERACTIONS *
2247 **************************/
2249 if (gmx_mm256_any_lt(rsq23,rcutoff2))
2252 /* REACTION-FIELD ELECTROSTATICS */
2253 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
2255 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
2259 fscal = _mm256_and_ps(fscal,cutoff_mask);
2261 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2263 /* Calculate temporary vectorial force */
2264 tx = _mm256_mul_ps(fscal,dx23);
2265 ty = _mm256_mul_ps(fscal,dy23);
2266 tz = _mm256_mul_ps(fscal,dz23);
2268 /* Update vectorial force */
2269 fix2 = _mm256_add_ps(fix2,tx);
2270 fiy2 = _mm256_add_ps(fiy2,ty);
2271 fiz2 = _mm256_add_ps(fiz2,tz);
2273 fjx3 = _mm256_add_ps(fjx3,tx);
2274 fjy3 = _mm256_add_ps(fjy3,ty);
2275 fjz3 = _mm256_add_ps(fjz3,tz);
2279 /**************************
2280 * CALCULATE INTERACTIONS *
2281 **************************/
2283 if (gmx_mm256_any_lt(rsq31,rcutoff2))
2286 /* REACTION-FIELD ELECTROSTATICS */
2287 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
2289 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
2293 fscal = _mm256_and_ps(fscal,cutoff_mask);
2295 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2297 /* Calculate temporary vectorial force */
2298 tx = _mm256_mul_ps(fscal,dx31);
2299 ty = _mm256_mul_ps(fscal,dy31);
2300 tz = _mm256_mul_ps(fscal,dz31);
2302 /* Update vectorial force */
2303 fix3 = _mm256_add_ps(fix3,tx);
2304 fiy3 = _mm256_add_ps(fiy3,ty);
2305 fiz3 = _mm256_add_ps(fiz3,tz);
2307 fjx1 = _mm256_add_ps(fjx1,tx);
2308 fjy1 = _mm256_add_ps(fjy1,ty);
2309 fjz1 = _mm256_add_ps(fjz1,tz);
2313 /**************************
2314 * CALCULATE INTERACTIONS *
2315 **************************/
2317 if (gmx_mm256_any_lt(rsq32,rcutoff2))
2320 /* REACTION-FIELD ELECTROSTATICS */
2321 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
2323 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
2327 fscal = _mm256_and_ps(fscal,cutoff_mask);
2329 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2331 /* Calculate temporary vectorial force */
2332 tx = _mm256_mul_ps(fscal,dx32);
2333 ty = _mm256_mul_ps(fscal,dy32);
2334 tz = _mm256_mul_ps(fscal,dz32);
2336 /* Update vectorial force */
2337 fix3 = _mm256_add_ps(fix3,tx);
2338 fiy3 = _mm256_add_ps(fiy3,ty);
2339 fiz3 = _mm256_add_ps(fiz3,tz);
2341 fjx2 = _mm256_add_ps(fjx2,tx);
2342 fjy2 = _mm256_add_ps(fjy2,ty);
2343 fjz2 = _mm256_add_ps(fjz2,tz);
2347 /**************************
2348 * CALCULATE INTERACTIONS *
2349 **************************/
2351 if (gmx_mm256_any_lt(rsq33,rcutoff2))
2354 /* REACTION-FIELD ELECTROSTATICS */
2355 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
2357 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
2361 fscal = _mm256_and_ps(fscal,cutoff_mask);
2363 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2365 /* Calculate temporary vectorial force */
2366 tx = _mm256_mul_ps(fscal,dx33);
2367 ty = _mm256_mul_ps(fscal,dy33);
2368 tz = _mm256_mul_ps(fscal,dz33);
2370 /* Update vectorial force */
2371 fix3 = _mm256_add_ps(fix3,tx);
2372 fiy3 = _mm256_add_ps(fiy3,ty);
2373 fiz3 = _mm256_add_ps(fiz3,tz);
2375 fjx3 = _mm256_add_ps(fjx3,tx);
2376 fjy3 = _mm256_add_ps(fjy3,ty);
2377 fjz3 = _mm256_add_ps(fjz3,tz);
2381 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2382 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2383 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2384 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2385 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2386 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2387 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2388 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2390 gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2391 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2392 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2394 /* Inner loop uses 303 flops */
2397 /* End of innermost loop */
2399 gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2400 f+i_coord_offset,fshift+i_shift_offset);
2402 /* Increment number of inner iterations */
2403 inneriter += j_index_end - j_index_start;
2405 /* Outer loop uses 24 flops */
2408 /* Increment number of outer iterations */
2411 /* Update outer/inner flops */
2413 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*303);