2 * Note: this file was generated by the Gromacs avx_256_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_256_single.h"
34 #include "kernelutil_x86_avx_256_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW4W4_VF_avx_256_single
38 * Electrostatics interaction: ReactionField
39 * VdW interaction: None
40 * Geometry: Water4-Water4
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecRFCut_VdwNone_GeomW4W4_VF_avx_256_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrE,jnrF,jnrG,jnrH;
62 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
63 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
64 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
65 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
66 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
68 real *shiftvec,*fshift,*x,*f;
69 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
71 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
72 real * vdwioffsetptr1;
73 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 real * vdwioffsetptr2;
75 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76 real * vdwioffsetptr3;
77 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
78 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
79 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
80 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
81 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
83 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
84 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
85 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
86 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
87 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
88 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
89 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
90 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
91 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
92 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
93 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
95 __m256 dummy_mask,cutoff_mask;
96 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
97 __m256 one = _mm256_set1_ps(1.0);
98 __m256 two = _mm256_set1_ps(2.0);
104 jindex = nlist->jindex;
106 shiftidx = nlist->shift;
108 shiftvec = fr->shift_vec[0];
109 fshift = fr->fshift[0];
110 facel = _mm256_set1_ps(fr->epsfac);
111 charge = mdatoms->chargeA;
112 krf = _mm256_set1_ps(fr->ic->k_rf);
113 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
114 crf = _mm256_set1_ps(fr->ic->c_rf);
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
119 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
120 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
122 jq1 = _mm256_set1_ps(charge[inr+1]);
123 jq2 = _mm256_set1_ps(charge[inr+2]);
124 jq3 = _mm256_set1_ps(charge[inr+3]);
125 qq11 = _mm256_mul_ps(iq1,jq1);
126 qq12 = _mm256_mul_ps(iq1,jq2);
127 qq13 = _mm256_mul_ps(iq1,jq3);
128 qq21 = _mm256_mul_ps(iq2,jq1);
129 qq22 = _mm256_mul_ps(iq2,jq2);
130 qq23 = _mm256_mul_ps(iq2,jq3);
131 qq31 = _mm256_mul_ps(iq3,jq1);
132 qq32 = _mm256_mul_ps(iq3,jq2);
133 qq33 = _mm256_mul_ps(iq3,jq3);
135 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
136 rcutoff_scalar = fr->rcoulomb;
137 rcutoff = _mm256_set1_ps(rcutoff_scalar);
138 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
140 /* Avoid stupid compiler warnings */
141 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
154 for(iidx=0;iidx<4*DIM;iidx++)
159 /* Start outer loop over neighborlists */
160 for(iidx=0; iidx<nri; iidx++)
162 /* Load shift vector for this list */
163 i_shift_offset = DIM*shiftidx[iidx];
165 /* Load limits for loop over neighbors */
166 j_index_start = jindex[iidx];
167 j_index_end = jindex[iidx+1];
169 /* Get outer coordinate index */
171 i_coord_offset = DIM*inr;
173 /* Load i particle coords and add shift vector */
174 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
175 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
177 fix1 = _mm256_setzero_ps();
178 fiy1 = _mm256_setzero_ps();
179 fiz1 = _mm256_setzero_ps();
180 fix2 = _mm256_setzero_ps();
181 fiy2 = _mm256_setzero_ps();
182 fiz2 = _mm256_setzero_ps();
183 fix3 = _mm256_setzero_ps();
184 fiy3 = _mm256_setzero_ps();
185 fiz3 = _mm256_setzero_ps();
187 /* Reset potential sums */
188 velecsum = _mm256_setzero_ps();
190 /* Start inner kernel loop */
191 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
194 /* Get j neighbor index, and coordinate index */
203 j_coord_offsetA = DIM*jnrA;
204 j_coord_offsetB = DIM*jnrB;
205 j_coord_offsetC = DIM*jnrC;
206 j_coord_offsetD = DIM*jnrD;
207 j_coord_offsetE = DIM*jnrE;
208 j_coord_offsetF = DIM*jnrF;
209 j_coord_offsetG = DIM*jnrG;
210 j_coord_offsetH = DIM*jnrH;
212 /* load j atom coordinates */
213 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
214 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
215 x+j_coord_offsetE+DIM,x+j_coord_offsetF+DIM,
216 x+j_coord_offsetG+DIM,x+j_coord_offsetH+DIM,
217 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
219 /* Calculate displacement vector */
220 dx11 = _mm256_sub_ps(ix1,jx1);
221 dy11 = _mm256_sub_ps(iy1,jy1);
222 dz11 = _mm256_sub_ps(iz1,jz1);
223 dx12 = _mm256_sub_ps(ix1,jx2);
224 dy12 = _mm256_sub_ps(iy1,jy2);
225 dz12 = _mm256_sub_ps(iz1,jz2);
226 dx13 = _mm256_sub_ps(ix1,jx3);
227 dy13 = _mm256_sub_ps(iy1,jy3);
228 dz13 = _mm256_sub_ps(iz1,jz3);
229 dx21 = _mm256_sub_ps(ix2,jx1);
230 dy21 = _mm256_sub_ps(iy2,jy1);
231 dz21 = _mm256_sub_ps(iz2,jz1);
232 dx22 = _mm256_sub_ps(ix2,jx2);
233 dy22 = _mm256_sub_ps(iy2,jy2);
234 dz22 = _mm256_sub_ps(iz2,jz2);
235 dx23 = _mm256_sub_ps(ix2,jx3);
236 dy23 = _mm256_sub_ps(iy2,jy3);
237 dz23 = _mm256_sub_ps(iz2,jz3);
238 dx31 = _mm256_sub_ps(ix3,jx1);
239 dy31 = _mm256_sub_ps(iy3,jy1);
240 dz31 = _mm256_sub_ps(iz3,jz1);
241 dx32 = _mm256_sub_ps(ix3,jx2);
242 dy32 = _mm256_sub_ps(iy3,jy2);
243 dz32 = _mm256_sub_ps(iz3,jz2);
244 dx33 = _mm256_sub_ps(ix3,jx3);
245 dy33 = _mm256_sub_ps(iy3,jy3);
246 dz33 = _mm256_sub_ps(iz3,jz3);
248 /* Calculate squared distance and things based on it */
249 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
250 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
251 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
252 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
253 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
254 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
255 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
256 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
257 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
259 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
260 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
261 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
262 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
263 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
264 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
265 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
266 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
267 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
269 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
270 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
271 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
272 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
273 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
274 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
275 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
276 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
277 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
279 fjx1 = _mm256_setzero_ps();
280 fjy1 = _mm256_setzero_ps();
281 fjz1 = _mm256_setzero_ps();
282 fjx2 = _mm256_setzero_ps();
283 fjy2 = _mm256_setzero_ps();
284 fjz2 = _mm256_setzero_ps();
285 fjx3 = _mm256_setzero_ps();
286 fjy3 = _mm256_setzero_ps();
287 fjz3 = _mm256_setzero_ps();
289 /**************************
290 * CALCULATE INTERACTIONS *
291 **************************/
293 if (gmx_mm256_any_lt(rsq11,rcutoff2))
296 /* REACTION-FIELD ELECTROSTATICS */
297 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
298 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
300 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
302 /* Update potential sum for this i atom from the interaction with this j atom. */
303 velec = _mm256_and_ps(velec,cutoff_mask);
304 velecsum = _mm256_add_ps(velecsum,velec);
308 fscal = _mm256_and_ps(fscal,cutoff_mask);
310 /* Calculate temporary vectorial force */
311 tx = _mm256_mul_ps(fscal,dx11);
312 ty = _mm256_mul_ps(fscal,dy11);
313 tz = _mm256_mul_ps(fscal,dz11);
315 /* Update vectorial force */
316 fix1 = _mm256_add_ps(fix1,tx);
317 fiy1 = _mm256_add_ps(fiy1,ty);
318 fiz1 = _mm256_add_ps(fiz1,tz);
320 fjx1 = _mm256_add_ps(fjx1,tx);
321 fjy1 = _mm256_add_ps(fjy1,ty);
322 fjz1 = _mm256_add_ps(fjz1,tz);
326 /**************************
327 * CALCULATE INTERACTIONS *
328 **************************/
330 if (gmx_mm256_any_lt(rsq12,rcutoff2))
333 /* REACTION-FIELD ELECTROSTATICS */
334 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
335 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
337 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
339 /* Update potential sum for this i atom from the interaction with this j atom. */
340 velec = _mm256_and_ps(velec,cutoff_mask);
341 velecsum = _mm256_add_ps(velecsum,velec);
345 fscal = _mm256_and_ps(fscal,cutoff_mask);
347 /* Calculate temporary vectorial force */
348 tx = _mm256_mul_ps(fscal,dx12);
349 ty = _mm256_mul_ps(fscal,dy12);
350 tz = _mm256_mul_ps(fscal,dz12);
352 /* Update vectorial force */
353 fix1 = _mm256_add_ps(fix1,tx);
354 fiy1 = _mm256_add_ps(fiy1,ty);
355 fiz1 = _mm256_add_ps(fiz1,tz);
357 fjx2 = _mm256_add_ps(fjx2,tx);
358 fjy2 = _mm256_add_ps(fjy2,ty);
359 fjz2 = _mm256_add_ps(fjz2,tz);
363 /**************************
364 * CALCULATE INTERACTIONS *
365 **************************/
367 if (gmx_mm256_any_lt(rsq13,rcutoff2))
370 /* REACTION-FIELD ELECTROSTATICS */
371 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
372 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
374 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
376 /* Update potential sum for this i atom from the interaction with this j atom. */
377 velec = _mm256_and_ps(velec,cutoff_mask);
378 velecsum = _mm256_add_ps(velecsum,velec);
382 fscal = _mm256_and_ps(fscal,cutoff_mask);
384 /* Calculate temporary vectorial force */
385 tx = _mm256_mul_ps(fscal,dx13);
386 ty = _mm256_mul_ps(fscal,dy13);
387 tz = _mm256_mul_ps(fscal,dz13);
389 /* Update vectorial force */
390 fix1 = _mm256_add_ps(fix1,tx);
391 fiy1 = _mm256_add_ps(fiy1,ty);
392 fiz1 = _mm256_add_ps(fiz1,tz);
394 fjx3 = _mm256_add_ps(fjx3,tx);
395 fjy3 = _mm256_add_ps(fjy3,ty);
396 fjz3 = _mm256_add_ps(fjz3,tz);
400 /**************************
401 * CALCULATE INTERACTIONS *
402 **************************/
404 if (gmx_mm256_any_lt(rsq21,rcutoff2))
407 /* REACTION-FIELD ELECTROSTATICS */
408 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
409 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
411 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
413 /* Update potential sum for this i atom from the interaction with this j atom. */
414 velec = _mm256_and_ps(velec,cutoff_mask);
415 velecsum = _mm256_add_ps(velecsum,velec);
419 fscal = _mm256_and_ps(fscal,cutoff_mask);
421 /* Calculate temporary vectorial force */
422 tx = _mm256_mul_ps(fscal,dx21);
423 ty = _mm256_mul_ps(fscal,dy21);
424 tz = _mm256_mul_ps(fscal,dz21);
426 /* Update vectorial force */
427 fix2 = _mm256_add_ps(fix2,tx);
428 fiy2 = _mm256_add_ps(fiy2,ty);
429 fiz2 = _mm256_add_ps(fiz2,tz);
431 fjx1 = _mm256_add_ps(fjx1,tx);
432 fjy1 = _mm256_add_ps(fjy1,ty);
433 fjz1 = _mm256_add_ps(fjz1,tz);
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
441 if (gmx_mm256_any_lt(rsq22,rcutoff2))
444 /* REACTION-FIELD ELECTROSTATICS */
445 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
446 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
448 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
450 /* Update potential sum for this i atom from the interaction with this j atom. */
451 velec = _mm256_and_ps(velec,cutoff_mask);
452 velecsum = _mm256_add_ps(velecsum,velec);
456 fscal = _mm256_and_ps(fscal,cutoff_mask);
458 /* Calculate temporary vectorial force */
459 tx = _mm256_mul_ps(fscal,dx22);
460 ty = _mm256_mul_ps(fscal,dy22);
461 tz = _mm256_mul_ps(fscal,dz22);
463 /* Update vectorial force */
464 fix2 = _mm256_add_ps(fix2,tx);
465 fiy2 = _mm256_add_ps(fiy2,ty);
466 fiz2 = _mm256_add_ps(fiz2,tz);
468 fjx2 = _mm256_add_ps(fjx2,tx);
469 fjy2 = _mm256_add_ps(fjy2,ty);
470 fjz2 = _mm256_add_ps(fjz2,tz);
474 /**************************
475 * CALCULATE INTERACTIONS *
476 **************************/
478 if (gmx_mm256_any_lt(rsq23,rcutoff2))
481 /* REACTION-FIELD ELECTROSTATICS */
482 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
483 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
485 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
487 /* Update potential sum for this i atom from the interaction with this j atom. */
488 velec = _mm256_and_ps(velec,cutoff_mask);
489 velecsum = _mm256_add_ps(velecsum,velec);
493 fscal = _mm256_and_ps(fscal,cutoff_mask);
495 /* Calculate temporary vectorial force */
496 tx = _mm256_mul_ps(fscal,dx23);
497 ty = _mm256_mul_ps(fscal,dy23);
498 tz = _mm256_mul_ps(fscal,dz23);
500 /* Update vectorial force */
501 fix2 = _mm256_add_ps(fix2,tx);
502 fiy2 = _mm256_add_ps(fiy2,ty);
503 fiz2 = _mm256_add_ps(fiz2,tz);
505 fjx3 = _mm256_add_ps(fjx3,tx);
506 fjy3 = _mm256_add_ps(fjy3,ty);
507 fjz3 = _mm256_add_ps(fjz3,tz);
511 /**************************
512 * CALCULATE INTERACTIONS *
513 **************************/
515 if (gmx_mm256_any_lt(rsq31,rcutoff2))
518 /* REACTION-FIELD ELECTROSTATICS */
519 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
520 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
522 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
524 /* Update potential sum for this i atom from the interaction with this j atom. */
525 velec = _mm256_and_ps(velec,cutoff_mask);
526 velecsum = _mm256_add_ps(velecsum,velec);
530 fscal = _mm256_and_ps(fscal,cutoff_mask);
532 /* Calculate temporary vectorial force */
533 tx = _mm256_mul_ps(fscal,dx31);
534 ty = _mm256_mul_ps(fscal,dy31);
535 tz = _mm256_mul_ps(fscal,dz31);
537 /* Update vectorial force */
538 fix3 = _mm256_add_ps(fix3,tx);
539 fiy3 = _mm256_add_ps(fiy3,ty);
540 fiz3 = _mm256_add_ps(fiz3,tz);
542 fjx1 = _mm256_add_ps(fjx1,tx);
543 fjy1 = _mm256_add_ps(fjy1,ty);
544 fjz1 = _mm256_add_ps(fjz1,tz);
548 /**************************
549 * CALCULATE INTERACTIONS *
550 **************************/
552 if (gmx_mm256_any_lt(rsq32,rcutoff2))
555 /* REACTION-FIELD ELECTROSTATICS */
556 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
557 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
559 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
561 /* Update potential sum for this i atom from the interaction with this j atom. */
562 velec = _mm256_and_ps(velec,cutoff_mask);
563 velecsum = _mm256_add_ps(velecsum,velec);
567 fscal = _mm256_and_ps(fscal,cutoff_mask);
569 /* Calculate temporary vectorial force */
570 tx = _mm256_mul_ps(fscal,dx32);
571 ty = _mm256_mul_ps(fscal,dy32);
572 tz = _mm256_mul_ps(fscal,dz32);
574 /* Update vectorial force */
575 fix3 = _mm256_add_ps(fix3,tx);
576 fiy3 = _mm256_add_ps(fiy3,ty);
577 fiz3 = _mm256_add_ps(fiz3,tz);
579 fjx2 = _mm256_add_ps(fjx2,tx);
580 fjy2 = _mm256_add_ps(fjy2,ty);
581 fjz2 = _mm256_add_ps(fjz2,tz);
585 /**************************
586 * CALCULATE INTERACTIONS *
587 **************************/
589 if (gmx_mm256_any_lt(rsq33,rcutoff2))
592 /* REACTION-FIELD ELECTROSTATICS */
593 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
594 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
596 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
598 /* Update potential sum for this i atom from the interaction with this j atom. */
599 velec = _mm256_and_ps(velec,cutoff_mask);
600 velecsum = _mm256_add_ps(velecsum,velec);
604 fscal = _mm256_and_ps(fscal,cutoff_mask);
606 /* Calculate temporary vectorial force */
607 tx = _mm256_mul_ps(fscal,dx33);
608 ty = _mm256_mul_ps(fscal,dy33);
609 tz = _mm256_mul_ps(fscal,dz33);
611 /* Update vectorial force */
612 fix3 = _mm256_add_ps(fix3,tx);
613 fiy3 = _mm256_add_ps(fiy3,ty);
614 fiz3 = _mm256_add_ps(fiz3,tz);
616 fjx3 = _mm256_add_ps(fjx3,tx);
617 fjy3 = _mm256_add_ps(fjy3,ty);
618 fjz3 = _mm256_add_ps(fjz3,tz);
622 fjptrA = f+j_coord_offsetA;
623 fjptrB = f+j_coord_offsetB;
624 fjptrC = f+j_coord_offsetC;
625 fjptrD = f+j_coord_offsetD;
626 fjptrE = f+j_coord_offsetE;
627 fjptrF = f+j_coord_offsetF;
628 fjptrG = f+j_coord_offsetG;
629 fjptrH = f+j_coord_offsetH;
631 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
632 fjptrE+DIM,fjptrF+DIM,fjptrG+DIM,fjptrH+DIM,
633 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
635 /* Inner loop uses 324 flops */
641 /* Get j neighbor index, and coordinate index */
642 jnrlistA = jjnr[jidx];
643 jnrlistB = jjnr[jidx+1];
644 jnrlistC = jjnr[jidx+2];
645 jnrlistD = jjnr[jidx+3];
646 jnrlistE = jjnr[jidx+4];
647 jnrlistF = jjnr[jidx+5];
648 jnrlistG = jjnr[jidx+6];
649 jnrlistH = jjnr[jidx+7];
650 /* Sign of each element will be negative for non-real atoms.
651 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
652 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
654 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
655 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
657 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
658 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
659 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
660 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
661 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
662 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
663 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
664 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
665 j_coord_offsetA = DIM*jnrA;
666 j_coord_offsetB = DIM*jnrB;
667 j_coord_offsetC = DIM*jnrC;
668 j_coord_offsetD = DIM*jnrD;
669 j_coord_offsetE = DIM*jnrE;
670 j_coord_offsetF = DIM*jnrF;
671 j_coord_offsetG = DIM*jnrG;
672 j_coord_offsetH = DIM*jnrH;
674 /* load j atom coordinates */
675 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
676 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
677 x+j_coord_offsetE+DIM,x+j_coord_offsetF+DIM,
678 x+j_coord_offsetG+DIM,x+j_coord_offsetH+DIM,
679 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
681 /* Calculate displacement vector */
682 dx11 = _mm256_sub_ps(ix1,jx1);
683 dy11 = _mm256_sub_ps(iy1,jy1);
684 dz11 = _mm256_sub_ps(iz1,jz1);
685 dx12 = _mm256_sub_ps(ix1,jx2);
686 dy12 = _mm256_sub_ps(iy1,jy2);
687 dz12 = _mm256_sub_ps(iz1,jz2);
688 dx13 = _mm256_sub_ps(ix1,jx3);
689 dy13 = _mm256_sub_ps(iy1,jy3);
690 dz13 = _mm256_sub_ps(iz1,jz3);
691 dx21 = _mm256_sub_ps(ix2,jx1);
692 dy21 = _mm256_sub_ps(iy2,jy1);
693 dz21 = _mm256_sub_ps(iz2,jz1);
694 dx22 = _mm256_sub_ps(ix2,jx2);
695 dy22 = _mm256_sub_ps(iy2,jy2);
696 dz22 = _mm256_sub_ps(iz2,jz2);
697 dx23 = _mm256_sub_ps(ix2,jx3);
698 dy23 = _mm256_sub_ps(iy2,jy3);
699 dz23 = _mm256_sub_ps(iz2,jz3);
700 dx31 = _mm256_sub_ps(ix3,jx1);
701 dy31 = _mm256_sub_ps(iy3,jy1);
702 dz31 = _mm256_sub_ps(iz3,jz1);
703 dx32 = _mm256_sub_ps(ix3,jx2);
704 dy32 = _mm256_sub_ps(iy3,jy2);
705 dz32 = _mm256_sub_ps(iz3,jz2);
706 dx33 = _mm256_sub_ps(ix3,jx3);
707 dy33 = _mm256_sub_ps(iy3,jy3);
708 dz33 = _mm256_sub_ps(iz3,jz3);
710 /* Calculate squared distance and things based on it */
711 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
712 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
713 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
714 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
715 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
716 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
717 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
718 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
719 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
721 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
722 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
723 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
724 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
725 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
726 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
727 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
728 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
729 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
731 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
732 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
733 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
734 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
735 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
736 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
737 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
738 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
739 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
741 fjx1 = _mm256_setzero_ps();
742 fjy1 = _mm256_setzero_ps();
743 fjz1 = _mm256_setzero_ps();
744 fjx2 = _mm256_setzero_ps();
745 fjy2 = _mm256_setzero_ps();
746 fjz2 = _mm256_setzero_ps();
747 fjx3 = _mm256_setzero_ps();
748 fjy3 = _mm256_setzero_ps();
749 fjz3 = _mm256_setzero_ps();
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 if (gmx_mm256_any_lt(rsq11,rcutoff2))
758 /* REACTION-FIELD ELECTROSTATICS */
759 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
760 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
762 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
764 /* Update potential sum for this i atom from the interaction with this j atom. */
765 velec = _mm256_and_ps(velec,cutoff_mask);
766 velec = _mm256_andnot_ps(dummy_mask,velec);
767 velecsum = _mm256_add_ps(velecsum,velec);
771 fscal = _mm256_and_ps(fscal,cutoff_mask);
773 fscal = _mm256_andnot_ps(dummy_mask,fscal);
775 /* Calculate temporary vectorial force */
776 tx = _mm256_mul_ps(fscal,dx11);
777 ty = _mm256_mul_ps(fscal,dy11);
778 tz = _mm256_mul_ps(fscal,dz11);
780 /* Update vectorial force */
781 fix1 = _mm256_add_ps(fix1,tx);
782 fiy1 = _mm256_add_ps(fiy1,ty);
783 fiz1 = _mm256_add_ps(fiz1,tz);
785 fjx1 = _mm256_add_ps(fjx1,tx);
786 fjy1 = _mm256_add_ps(fjy1,ty);
787 fjz1 = _mm256_add_ps(fjz1,tz);
791 /**************************
792 * CALCULATE INTERACTIONS *
793 **************************/
795 if (gmx_mm256_any_lt(rsq12,rcutoff2))
798 /* REACTION-FIELD ELECTROSTATICS */
799 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
800 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
802 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
804 /* Update potential sum for this i atom from the interaction with this j atom. */
805 velec = _mm256_and_ps(velec,cutoff_mask);
806 velec = _mm256_andnot_ps(dummy_mask,velec);
807 velecsum = _mm256_add_ps(velecsum,velec);
811 fscal = _mm256_and_ps(fscal,cutoff_mask);
813 fscal = _mm256_andnot_ps(dummy_mask,fscal);
815 /* Calculate temporary vectorial force */
816 tx = _mm256_mul_ps(fscal,dx12);
817 ty = _mm256_mul_ps(fscal,dy12);
818 tz = _mm256_mul_ps(fscal,dz12);
820 /* Update vectorial force */
821 fix1 = _mm256_add_ps(fix1,tx);
822 fiy1 = _mm256_add_ps(fiy1,ty);
823 fiz1 = _mm256_add_ps(fiz1,tz);
825 fjx2 = _mm256_add_ps(fjx2,tx);
826 fjy2 = _mm256_add_ps(fjy2,ty);
827 fjz2 = _mm256_add_ps(fjz2,tz);
831 /**************************
832 * CALCULATE INTERACTIONS *
833 **************************/
835 if (gmx_mm256_any_lt(rsq13,rcutoff2))
838 /* REACTION-FIELD ELECTROSTATICS */
839 velec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
840 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
842 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
844 /* Update potential sum for this i atom from the interaction with this j atom. */
845 velec = _mm256_and_ps(velec,cutoff_mask);
846 velec = _mm256_andnot_ps(dummy_mask,velec);
847 velecsum = _mm256_add_ps(velecsum,velec);
851 fscal = _mm256_and_ps(fscal,cutoff_mask);
853 fscal = _mm256_andnot_ps(dummy_mask,fscal);
855 /* Calculate temporary vectorial force */
856 tx = _mm256_mul_ps(fscal,dx13);
857 ty = _mm256_mul_ps(fscal,dy13);
858 tz = _mm256_mul_ps(fscal,dz13);
860 /* Update vectorial force */
861 fix1 = _mm256_add_ps(fix1,tx);
862 fiy1 = _mm256_add_ps(fiy1,ty);
863 fiz1 = _mm256_add_ps(fiz1,tz);
865 fjx3 = _mm256_add_ps(fjx3,tx);
866 fjy3 = _mm256_add_ps(fjy3,ty);
867 fjz3 = _mm256_add_ps(fjz3,tz);
871 /**************************
872 * CALCULATE INTERACTIONS *
873 **************************/
875 if (gmx_mm256_any_lt(rsq21,rcutoff2))
878 /* REACTION-FIELD ELECTROSTATICS */
879 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
880 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
882 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
884 /* Update potential sum for this i atom from the interaction with this j atom. */
885 velec = _mm256_and_ps(velec,cutoff_mask);
886 velec = _mm256_andnot_ps(dummy_mask,velec);
887 velecsum = _mm256_add_ps(velecsum,velec);
891 fscal = _mm256_and_ps(fscal,cutoff_mask);
893 fscal = _mm256_andnot_ps(dummy_mask,fscal);
895 /* Calculate temporary vectorial force */
896 tx = _mm256_mul_ps(fscal,dx21);
897 ty = _mm256_mul_ps(fscal,dy21);
898 tz = _mm256_mul_ps(fscal,dz21);
900 /* Update vectorial force */
901 fix2 = _mm256_add_ps(fix2,tx);
902 fiy2 = _mm256_add_ps(fiy2,ty);
903 fiz2 = _mm256_add_ps(fiz2,tz);
905 fjx1 = _mm256_add_ps(fjx1,tx);
906 fjy1 = _mm256_add_ps(fjy1,ty);
907 fjz1 = _mm256_add_ps(fjz1,tz);
911 /**************************
912 * CALCULATE INTERACTIONS *
913 **************************/
915 if (gmx_mm256_any_lt(rsq22,rcutoff2))
918 /* REACTION-FIELD ELECTROSTATICS */
919 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
920 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
922 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
924 /* Update potential sum for this i atom from the interaction with this j atom. */
925 velec = _mm256_and_ps(velec,cutoff_mask);
926 velec = _mm256_andnot_ps(dummy_mask,velec);
927 velecsum = _mm256_add_ps(velecsum,velec);
931 fscal = _mm256_and_ps(fscal,cutoff_mask);
933 fscal = _mm256_andnot_ps(dummy_mask,fscal);
935 /* Calculate temporary vectorial force */
936 tx = _mm256_mul_ps(fscal,dx22);
937 ty = _mm256_mul_ps(fscal,dy22);
938 tz = _mm256_mul_ps(fscal,dz22);
940 /* Update vectorial force */
941 fix2 = _mm256_add_ps(fix2,tx);
942 fiy2 = _mm256_add_ps(fiy2,ty);
943 fiz2 = _mm256_add_ps(fiz2,tz);
945 fjx2 = _mm256_add_ps(fjx2,tx);
946 fjy2 = _mm256_add_ps(fjy2,ty);
947 fjz2 = _mm256_add_ps(fjz2,tz);
951 /**************************
952 * CALCULATE INTERACTIONS *
953 **************************/
955 if (gmx_mm256_any_lt(rsq23,rcutoff2))
958 /* REACTION-FIELD ELECTROSTATICS */
959 velec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
960 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
962 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
964 /* Update potential sum for this i atom from the interaction with this j atom. */
965 velec = _mm256_and_ps(velec,cutoff_mask);
966 velec = _mm256_andnot_ps(dummy_mask,velec);
967 velecsum = _mm256_add_ps(velecsum,velec);
971 fscal = _mm256_and_ps(fscal,cutoff_mask);
973 fscal = _mm256_andnot_ps(dummy_mask,fscal);
975 /* Calculate temporary vectorial force */
976 tx = _mm256_mul_ps(fscal,dx23);
977 ty = _mm256_mul_ps(fscal,dy23);
978 tz = _mm256_mul_ps(fscal,dz23);
980 /* Update vectorial force */
981 fix2 = _mm256_add_ps(fix2,tx);
982 fiy2 = _mm256_add_ps(fiy2,ty);
983 fiz2 = _mm256_add_ps(fiz2,tz);
985 fjx3 = _mm256_add_ps(fjx3,tx);
986 fjy3 = _mm256_add_ps(fjy3,ty);
987 fjz3 = _mm256_add_ps(fjz3,tz);
991 /**************************
992 * CALCULATE INTERACTIONS *
993 **************************/
995 if (gmx_mm256_any_lt(rsq31,rcutoff2))
998 /* REACTION-FIELD ELECTROSTATICS */
999 velec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
1000 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1002 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1004 /* Update potential sum for this i atom from the interaction with this j atom. */
1005 velec = _mm256_and_ps(velec,cutoff_mask);
1006 velec = _mm256_andnot_ps(dummy_mask,velec);
1007 velecsum = _mm256_add_ps(velecsum,velec);
1011 fscal = _mm256_and_ps(fscal,cutoff_mask);
1013 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1015 /* Calculate temporary vectorial force */
1016 tx = _mm256_mul_ps(fscal,dx31);
1017 ty = _mm256_mul_ps(fscal,dy31);
1018 tz = _mm256_mul_ps(fscal,dz31);
1020 /* Update vectorial force */
1021 fix3 = _mm256_add_ps(fix3,tx);
1022 fiy3 = _mm256_add_ps(fiy3,ty);
1023 fiz3 = _mm256_add_ps(fiz3,tz);
1025 fjx1 = _mm256_add_ps(fjx1,tx);
1026 fjy1 = _mm256_add_ps(fjy1,ty);
1027 fjz1 = _mm256_add_ps(fjz1,tz);
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1035 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1038 /* REACTION-FIELD ELECTROSTATICS */
1039 velec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
1040 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1042 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1044 /* Update potential sum for this i atom from the interaction with this j atom. */
1045 velec = _mm256_and_ps(velec,cutoff_mask);
1046 velec = _mm256_andnot_ps(dummy_mask,velec);
1047 velecsum = _mm256_add_ps(velecsum,velec);
1051 fscal = _mm256_and_ps(fscal,cutoff_mask);
1053 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1055 /* Calculate temporary vectorial force */
1056 tx = _mm256_mul_ps(fscal,dx32);
1057 ty = _mm256_mul_ps(fscal,dy32);
1058 tz = _mm256_mul_ps(fscal,dz32);
1060 /* Update vectorial force */
1061 fix3 = _mm256_add_ps(fix3,tx);
1062 fiy3 = _mm256_add_ps(fiy3,ty);
1063 fiz3 = _mm256_add_ps(fiz3,tz);
1065 fjx2 = _mm256_add_ps(fjx2,tx);
1066 fjy2 = _mm256_add_ps(fjy2,ty);
1067 fjz2 = _mm256_add_ps(fjz2,tz);
1071 /**************************
1072 * CALCULATE INTERACTIONS *
1073 **************************/
1075 if (gmx_mm256_any_lt(rsq33,rcutoff2))
1078 /* REACTION-FIELD ELECTROSTATICS */
1079 velec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
1080 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1082 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1084 /* Update potential sum for this i atom from the interaction with this j atom. */
1085 velec = _mm256_and_ps(velec,cutoff_mask);
1086 velec = _mm256_andnot_ps(dummy_mask,velec);
1087 velecsum = _mm256_add_ps(velecsum,velec);
1091 fscal = _mm256_and_ps(fscal,cutoff_mask);
1093 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1095 /* Calculate temporary vectorial force */
1096 tx = _mm256_mul_ps(fscal,dx33);
1097 ty = _mm256_mul_ps(fscal,dy33);
1098 tz = _mm256_mul_ps(fscal,dz33);
1100 /* Update vectorial force */
1101 fix3 = _mm256_add_ps(fix3,tx);
1102 fiy3 = _mm256_add_ps(fiy3,ty);
1103 fiz3 = _mm256_add_ps(fiz3,tz);
1105 fjx3 = _mm256_add_ps(fjx3,tx);
1106 fjy3 = _mm256_add_ps(fjy3,ty);
1107 fjz3 = _mm256_add_ps(fjz3,tz);
1111 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1112 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1113 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1114 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1115 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1116 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1117 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1118 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1120 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
1121 fjptrE+DIM,fjptrF+DIM,fjptrG+DIM,fjptrH+DIM,
1122 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1124 /* Inner loop uses 324 flops */
1127 /* End of innermost loop */
1129 gmx_mm256_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1130 f+i_coord_offset+DIM,fshift+i_shift_offset);
1133 /* Update potential energies */
1134 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1136 /* Increment number of inner iterations */
1137 inneriter += j_index_end - j_index_start;
1139 /* Outer loop uses 19 flops */
1142 /* Increment number of outer iterations */
1145 /* Update outer/inner flops */
1147 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*19 + inneriter*324);
1150 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW4W4_F_avx_256_single
1151 * Electrostatics interaction: ReactionField
1152 * VdW interaction: None
1153 * Geometry: Water4-Water4
1154 * Calculate force/pot: Force
1157 nb_kernel_ElecRFCut_VdwNone_GeomW4W4_F_avx_256_single
1158 (t_nblist * gmx_restrict nlist,
1159 rvec * gmx_restrict xx,
1160 rvec * gmx_restrict ff,
1161 t_forcerec * gmx_restrict fr,
1162 t_mdatoms * gmx_restrict mdatoms,
1163 nb_kernel_data_t * gmx_restrict kernel_data,
1164 t_nrnb * gmx_restrict nrnb)
1166 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1167 * just 0 for non-waters.
1168 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1169 * jnr indices corresponding to data put in the four positions in the SIMD register.
1171 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1172 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1173 int jnrA,jnrB,jnrC,jnrD;
1174 int jnrE,jnrF,jnrG,jnrH;
1175 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1176 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1177 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1178 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1179 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1180 real rcutoff_scalar;
1181 real *shiftvec,*fshift,*x,*f;
1182 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1183 real scratch[4*DIM];
1184 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1185 real * vdwioffsetptr1;
1186 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1187 real * vdwioffsetptr2;
1188 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1189 real * vdwioffsetptr3;
1190 __m256 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1191 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1192 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1193 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1194 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1195 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
1196 __m256 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1197 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1198 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1199 __m256 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1200 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1201 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1202 __m256 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1203 __m256 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1204 __m256 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1205 __m256 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1206 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1208 __m256 dummy_mask,cutoff_mask;
1209 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1210 __m256 one = _mm256_set1_ps(1.0);
1211 __m256 two = _mm256_set1_ps(2.0);
1217 jindex = nlist->jindex;
1219 shiftidx = nlist->shift;
1221 shiftvec = fr->shift_vec[0];
1222 fshift = fr->fshift[0];
1223 facel = _mm256_set1_ps(fr->epsfac);
1224 charge = mdatoms->chargeA;
1225 krf = _mm256_set1_ps(fr->ic->k_rf);
1226 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1227 crf = _mm256_set1_ps(fr->ic->c_rf);
1229 /* Setup water-specific parameters */
1230 inr = nlist->iinr[0];
1231 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1232 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1233 iq3 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
1235 jq1 = _mm256_set1_ps(charge[inr+1]);
1236 jq2 = _mm256_set1_ps(charge[inr+2]);
1237 jq3 = _mm256_set1_ps(charge[inr+3]);
1238 qq11 = _mm256_mul_ps(iq1,jq1);
1239 qq12 = _mm256_mul_ps(iq1,jq2);
1240 qq13 = _mm256_mul_ps(iq1,jq3);
1241 qq21 = _mm256_mul_ps(iq2,jq1);
1242 qq22 = _mm256_mul_ps(iq2,jq2);
1243 qq23 = _mm256_mul_ps(iq2,jq3);
1244 qq31 = _mm256_mul_ps(iq3,jq1);
1245 qq32 = _mm256_mul_ps(iq3,jq2);
1246 qq33 = _mm256_mul_ps(iq3,jq3);
1248 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1249 rcutoff_scalar = fr->rcoulomb;
1250 rcutoff = _mm256_set1_ps(rcutoff_scalar);
1251 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
1253 /* Avoid stupid compiler warnings */
1254 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1255 j_coord_offsetA = 0;
1256 j_coord_offsetB = 0;
1257 j_coord_offsetC = 0;
1258 j_coord_offsetD = 0;
1259 j_coord_offsetE = 0;
1260 j_coord_offsetF = 0;
1261 j_coord_offsetG = 0;
1262 j_coord_offsetH = 0;
1267 for(iidx=0;iidx<4*DIM;iidx++)
1269 scratch[iidx] = 0.0;
1272 /* Start outer loop over neighborlists */
1273 for(iidx=0; iidx<nri; iidx++)
1275 /* Load shift vector for this list */
1276 i_shift_offset = DIM*shiftidx[iidx];
1278 /* Load limits for loop over neighbors */
1279 j_index_start = jindex[iidx];
1280 j_index_end = jindex[iidx+1];
1282 /* Get outer coordinate index */
1284 i_coord_offset = DIM*inr;
1286 /* Load i particle coords and add shift vector */
1287 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
1288 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1290 fix1 = _mm256_setzero_ps();
1291 fiy1 = _mm256_setzero_ps();
1292 fiz1 = _mm256_setzero_ps();
1293 fix2 = _mm256_setzero_ps();
1294 fiy2 = _mm256_setzero_ps();
1295 fiz2 = _mm256_setzero_ps();
1296 fix3 = _mm256_setzero_ps();
1297 fiy3 = _mm256_setzero_ps();
1298 fiz3 = _mm256_setzero_ps();
1300 /* Start inner kernel loop */
1301 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1304 /* Get j neighbor index, and coordinate index */
1306 jnrB = jjnr[jidx+1];
1307 jnrC = jjnr[jidx+2];
1308 jnrD = jjnr[jidx+3];
1309 jnrE = jjnr[jidx+4];
1310 jnrF = jjnr[jidx+5];
1311 jnrG = jjnr[jidx+6];
1312 jnrH = jjnr[jidx+7];
1313 j_coord_offsetA = DIM*jnrA;
1314 j_coord_offsetB = DIM*jnrB;
1315 j_coord_offsetC = DIM*jnrC;
1316 j_coord_offsetD = DIM*jnrD;
1317 j_coord_offsetE = DIM*jnrE;
1318 j_coord_offsetF = DIM*jnrF;
1319 j_coord_offsetG = DIM*jnrG;
1320 j_coord_offsetH = DIM*jnrH;
1322 /* load j atom coordinates */
1323 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
1324 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
1325 x+j_coord_offsetE+DIM,x+j_coord_offsetF+DIM,
1326 x+j_coord_offsetG+DIM,x+j_coord_offsetH+DIM,
1327 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1329 /* Calculate displacement vector */
1330 dx11 = _mm256_sub_ps(ix1,jx1);
1331 dy11 = _mm256_sub_ps(iy1,jy1);
1332 dz11 = _mm256_sub_ps(iz1,jz1);
1333 dx12 = _mm256_sub_ps(ix1,jx2);
1334 dy12 = _mm256_sub_ps(iy1,jy2);
1335 dz12 = _mm256_sub_ps(iz1,jz2);
1336 dx13 = _mm256_sub_ps(ix1,jx3);
1337 dy13 = _mm256_sub_ps(iy1,jy3);
1338 dz13 = _mm256_sub_ps(iz1,jz3);
1339 dx21 = _mm256_sub_ps(ix2,jx1);
1340 dy21 = _mm256_sub_ps(iy2,jy1);
1341 dz21 = _mm256_sub_ps(iz2,jz1);
1342 dx22 = _mm256_sub_ps(ix2,jx2);
1343 dy22 = _mm256_sub_ps(iy2,jy2);
1344 dz22 = _mm256_sub_ps(iz2,jz2);
1345 dx23 = _mm256_sub_ps(ix2,jx3);
1346 dy23 = _mm256_sub_ps(iy2,jy3);
1347 dz23 = _mm256_sub_ps(iz2,jz3);
1348 dx31 = _mm256_sub_ps(ix3,jx1);
1349 dy31 = _mm256_sub_ps(iy3,jy1);
1350 dz31 = _mm256_sub_ps(iz3,jz1);
1351 dx32 = _mm256_sub_ps(ix3,jx2);
1352 dy32 = _mm256_sub_ps(iy3,jy2);
1353 dz32 = _mm256_sub_ps(iz3,jz2);
1354 dx33 = _mm256_sub_ps(ix3,jx3);
1355 dy33 = _mm256_sub_ps(iy3,jy3);
1356 dz33 = _mm256_sub_ps(iz3,jz3);
1358 /* Calculate squared distance and things based on it */
1359 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1360 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1361 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1362 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1363 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1364 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
1365 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
1366 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
1367 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
1369 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1370 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1371 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
1372 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1373 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1374 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
1375 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
1376 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
1377 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
1379 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1380 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1381 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
1382 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1383 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1384 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
1385 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
1386 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
1387 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
1389 fjx1 = _mm256_setzero_ps();
1390 fjy1 = _mm256_setzero_ps();
1391 fjz1 = _mm256_setzero_ps();
1392 fjx2 = _mm256_setzero_ps();
1393 fjy2 = _mm256_setzero_ps();
1394 fjz2 = _mm256_setzero_ps();
1395 fjx3 = _mm256_setzero_ps();
1396 fjy3 = _mm256_setzero_ps();
1397 fjz3 = _mm256_setzero_ps();
1399 /**************************
1400 * CALCULATE INTERACTIONS *
1401 **************************/
1403 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1406 /* REACTION-FIELD ELECTROSTATICS */
1407 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1409 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1413 fscal = _mm256_and_ps(fscal,cutoff_mask);
1415 /* Calculate temporary vectorial force */
1416 tx = _mm256_mul_ps(fscal,dx11);
1417 ty = _mm256_mul_ps(fscal,dy11);
1418 tz = _mm256_mul_ps(fscal,dz11);
1420 /* Update vectorial force */
1421 fix1 = _mm256_add_ps(fix1,tx);
1422 fiy1 = _mm256_add_ps(fiy1,ty);
1423 fiz1 = _mm256_add_ps(fiz1,tz);
1425 fjx1 = _mm256_add_ps(fjx1,tx);
1426 fjy1 = _mm256_add_ps(fjy1,ty);
1427 fjz1 = _mm256_add_ps(fjz1,tz);
1431 /**************************
1432 * CALCULATE INTERACTIONS *
1433 **************************/
1435 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1438 /* REACTION-FIELD ELECTROSTATICS */
1439 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1441 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1445 fscal = _mm256_and_ps(fscal,cutoff_mask);
1447 /* Calculate temporary vectorial force */
1448 tx = _mm256_mul_ps(fscal,dx12);
1449 ty = _mm256_mul_ps(fscal,dy12);
1450 tz = _mm256_mul_ps(fscal,dz12);
1452 /* Update vectorial force */
1453 fix1 = _mm256_add_ps(fix1,tx);
1454 fiy1 = _mm256_add_ps(fiy1,ty);
1455 fiz1 = _mm256_add_ps(fiz1,tz);
1457 fjx2 = _mm256_add_ps(fjx2,tx);
1458 fjy2 = _mm256_add_ps(fjy2,ty);
1459 fjz2 = _mm256_add_ps(fjz2,tz);
1463 /**************************
1464 * CALCULATE INTERACTIONS *
1465 **************************/
1467 if (gmx_mm256_any_lt(rsq13,rcutoff2))
1470 /* REACTION-FIELD ELECTROSTATICS */
1471 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1473 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1477 fscal = _mm256_and_ps(fscal,cutoff_mask);
1479 /* Calculate temporary vectorial force */
1480 tx = _mm256_mul_ps(fscal,dx13);
1481 ty = _mm256_mul_ps(fscal,dy13);
1482 tz = _mm256_mul_ps(fscal,dz13);
1484 /* Update vectorial force */
1485 fix1 = _mm256_add_ps(fix1,tx);
1486 fiy1 = _mm256_add_ps(fiy1,ty);
1487 fiz1 = _mm256_add_ps(fiz1,tz);
1489 fjx3 = _mm256_add_ps(fjx3,tx);
1490 fjy3 = _mm256_add_ps(fjy3,ty);
1491 fjz3 = _mm256_add_ps(fjz3,tz);
1495 /**************************
1496 * CALCULATE INTERACTIONS *
1497 **************************/
1499 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1502 /* REACTION-FIELD ELECTROSTATICS */
1503 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1505 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1509 fscal = _mm256_and_ps(fscal,cutoff_mask);
1511 /* Calculate temporary vectorial force */
1512 tx = _mm256_mul_ps(fscal,dx21);
1513 ty = _mm256_mul_ps(fscal,dy21);
1514 tz = _mm256_mul_ps(fscal,dz21);
1516 /* Update vectorial force */
1517 fix2 = _mm256_add_ps(fix2,tx);
1518 fiy2 = _mm256_add_ps(fiy2,ty);
1519 fiz2 = _mm256_add_ps(fiz2,tz);
1521 fjx1 = _mm256_add_ps(fjx1,tx);
1522 fjy1 = _mm256_add_ps(fjy1,ty);
1523 fjz1 = _mm256_add_ps(fjz1,tz);
1527 /**************************
1528 * CALCULATE INTERACTIONS *
1529 **************************/
1531 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1534 /* REACTION-FIELD ELECTROSTATICS */
1535 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1537 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1541 fscal = _mm256_and_ps(fscal,cutoff_mask);
1543 /* Calculate temporary vectorial force */
1544 tx = _mm256_mul_ps(fscal,dx22);
1545 ty = _mm256_mul_ps(fscal,dy22);
1546 tz = _mm256_mul_ps(fscal,dz22);
1548 /* Update vectorial force */
1549 fix2 = _mm256_add_ps(fix2,tx);
1550 fiy2 = _mm256_add_ps(fiy2,ty);
1551 fiz2 = _mm256_add_ps(fiz2,tz);
1553 fjx2 = _mm256_add_ps(fjx2,tx);
1554 fjy2 = _mm256_add_ps(fjy2,ty);
1555 fjz2 = _mm256_add_ps(fjz2,tz);
1559 /**************************
1560 * CALCULATE INTERACTIONS *
1561 **************************/
1563 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1566 /* REACTION-FIELD ELECTROSTATICS */
1567 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1569 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1573 fscal = _mm256_and_ps(fscal,cutoff_mask);
1575 /* Calculate temporary vectorial force */
1576 tx = _mm256_mul_ps(fscal,dx23);
1577 ty = _mm256_mul_ps(fscal,dy23);
1578 tz = _mm256_mul_ps(fscal,dz23);
1580 /* Update vectorial force */
1581 fix2 = _mm256_add_ps(fix2,tx);
1582 fiy2 = _mm256_add_ps(fiy2,ty);
1583 fiz2 = _mm256_add_ps(fiz2,tz);
1585 fjx3 = _mm256_add_ps(fjx3,tx);
1586 fjy3 = _mm256_add_ps(fjy3,ty);
1587 fjz3 = _mm256_add_ps(fjz3,tz);
1591 /**************************
1592 * CALCULATE INTERACTIONS *
1593 **************************/
1595 if (gmx_mm256_any_lt(rsq31,rcutoff2))
1598 /* REACTION-FIELD ELECTROSTATICS */
1599 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1601 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1605 fscal = _mm256_and_ps(fscal,cutoff_mask);
1607 /* Calculate temporary vectorial force */
1608 tx = _mm256_mul_ps(fscal,dx31);
1609 ty = _mm256_mul_ps(fscal,dy31);
1610 tz = _mm256_mul_ps(fscal,dz31);
1612 /* Update vectorial force */
1613 fix3 = _mm256_add_ps(fix3,tx);
1614 fiy3 = _mm256_add_ps(fiy3,ty);
1615 fiz3 = _mm256_add_ps(fiz3,tz);
1617 fjx1 = _mm256_add_ps(fjx1,tx);
1618 fjy1 = _mm256_add_ps(fjy1,ty);
1619 fjz1 = _mm256_add_ps(fjz1,tz);
1623 /**************************
1624 * CALCULATE INTERACTIONS *
1625 **************************/
1627 if (gmx_mm256_any_lt(rsq32,rcutoff2))
1630 /* REACTION-FIELD ELECTROSTATICS */
1631 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1633 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1637 fscal = _mm256_and_ps(fscal,cutoff_mask);
1639 /* Calculate temporary vectorial force */
1640 tx = _mm256_mul_ps(fscal,dx32);
1641 ty = _mm256_mul_ps(fscal,dy32);
1642 tz = _mm256_mul_ps(fscal,dz32);
1644 /* Update vectorial force */
1645 fix3 = _mm256_add_ps(fix3,tx);
1646 fiy3 = _mm256_add_ps(fiy3,ty);
1647 fiz3 = _mm256_add_ps(fiz3,tz);
1649 fjx2 = _mm256_add_ps(fjx2,tx);
1650 fjy2 = _mm256_add_ps(fjy2,ty);
1651 fjz2 = _mm256_add_ps(fjz2,tz);
1655 /**************************
1656 * CALCULATE INTERACTIONS *
1657 **************************/
1659 if (gmx_mm256_any_lt(rsq33,rcutoff2))
1662 /* REACTION-FIELD ELECTROSTATICS */
1663 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1665 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1669 fscal = _mm256_and_ps(fscal,cutoff_mask);
1671 /* Calculate temporary vectorial force */
1672 tx = _mm256_mul_ps(fscal,dx33);
1673 ty = _mm256_mul_ps(fscal,dy33);
1674 tz = _mm256_mul_ps(fscal,dz33);
1676 /* Update vectorial force */
1677 fix3 = _mm256_add_ps(fix3,tx);
1678 fiy3 = _mm256_add_ps(fiy3,ty);
1679 fiz3 = _mm256_add_ps(fiz3,tz);
1681 fjx3 = _mm256_add_ps(fjx3,tx);
1682 fjy3 = _mm256_add_ps(fjy3,ty);
1683 fjz3 = _mm256_add_ps(fjz3,tz);
1687 fjptrA = f+j_coord_offsetA;
1688 fjptrB = f+j_coord_offsetB;
1689 fjptrC = f+j_coord_offsetC;
1690 fjptrD = f+j_coord_offsetD;
1691 fjptrE = f+j_coord_offsetE;
1692 fjptrF = f+j_coord_offsetF;
1693 fjptrG = f+j_coord_offsetG;
1694 fjptrH = f+j_coord_offsetH;
1696 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
1697 fjptrE+DIM,fjptrF+DIM,fjptrG+DIM,fjptrH+DIM,
1698 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1700 /* Inner loop uses 270 flops */
1703 if(jidx<j_index_end)
1706 /* Get j neighbor index, and coordinate index */
1707 jnrlistA = jjnr[jidx];
1708 jnrlistB = jjnr[jidx+1];
1709 jnrlistC = jjnr[jidx+2];
1710 jnrlistD = jjnr[jidx+3];
1711 jnrlistE = jjnr[jidx+4];
1712 jnrlistF = jjnr[jidx+5];
1713 jnrlistG = jjnr[jidx+6];
1714 jnrlistH = jjnr[jidx+7];
1715 /* Sign of each element will be negative for non-real atoms.
1716 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1717 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1719 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1720 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1722 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1723 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1724 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1725 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1726 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1727 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1728 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1729 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1730 j_coord_offsetA = DIM*jnrA;
1731 j_coord_offsetB = DIM*jnrB;
1732 j_coord_offsetC = DIM*jnrC;
1733 j_coord_offsetD = DIM*jnrD;
1734 j_coord_offsetE = DIM*jnrE;
1735 j_coord_offsetF = DIM*jnrF;
1736 j_coord_offsetG = DIM*jnrG;
1737 j_coord_offsetH = DIM*jnrH;
1739 /* load j atom coordinates */
1740 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
1741 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
1742 x+j_coord_offsetE+DIM,x+j_coord_offsetF+DIM,
1743 x+j_coord_offsetG+DIM,x+j_coord_offsetH+DIM,
1744 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1746 /* Calculate displacement vector */
1747 dx11 = _mm256_sub_ps(ix1,jx1);
1748 dy11 = _mm256_sub_ps(iy1,jy1);
1749 dz11 = _mm256_sub_ps(iz1,jz1);
1750 dx12 = _mm256_sub_ps(ix1,jx2);
1751 dy12 = _mm256_sub_ps(iy1,jy2);
1752 dz12 = _mm256_sub_ps(iz1,jz2);
1753 dx13 = _mm256_sub_ps(ix1,jx3);
1754 dy13 = _mm256_sub_ps(iy1,jy3);
1755 dz13 = _mm256_sub_ps(iz1,jz3);
1756 dx21 = _mm256_sub_ps(ix2,jx1);
1757 dy21 = _mm256_sub_ps(iy2,jy1);
1758 dz21 = _mm256_sub_ps(iz2,jz1);
1759 dx22 = _mm256_sub_ps(ix2,jx2);
1760 dy22 = _mm256_sub_ps(iy2,jy2);
1761 dz22 = _mm256_sub_ps(iz2,jz2);
1762 dx23 = _mm256_sub_ps(ix2,jx3);
1763 dy23 = _mm256_sub_ps(iy2,jy3);
1764 dz23 = _mm256_sub_ps(iz2,jz3);
1765 dx31 = _mm256_sub_ps(ix3,jx1);
1766 dy31 = _mm256_sub_ps(iy3,jy1);
1767 dz31 = _mm256_sub_ps(iz3,jz1);
1768 dx32 = _mm256_sub_ps(ix3,jx2);
1769 dy32 = _mm256_sub_ps(iy3,jy2);
1770 dz32 = _mm256_sub_ps(iz3,jz2);
1771 dx33 = _mm256_sub_ps(ix3,jx3);
1772 dy33 = _mm256_sub_ps(iy3,jy3);
1773 dz33 = _mm256_sub_ps(iz3,jz3);
1775 /* Calculate squared distance and things based on it */
1776 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1777 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1778 rsq13 = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1779 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1780 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1781 rsq23 = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
1782 rsq31 = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
1783 rsq32 = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
1784 rsq33 = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
1786 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1787 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1788 rinv13 = gmx_mm256_invsqrt_ps(rsq13);
1789 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1790 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1791 rinv23 = gmx_mm256_invsqrt_ps(rsq23);
1792 rinv31 = gmx_mm256_invsqrt_ps(rsq31);
1793 rinv32 = gmx_mm256_invsqrt_ps(rsq32);
1794 rinv33 = gmx_mm256_invsqrt_ps(rsq33);
1796 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1797 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1798 rinvsq13 = _mm256_mul_ps(rinv13,rinv13);
1799 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1800 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1801 rinvsq23 = _mm256_mul_ps(rinv23,rinv23);
1802 rinvsq31 = _mm256_mul_ps(rinv31,rinv31);
1803 rinvsq32 = _mm256_mul_ps(rinv32,rinv32);
1804 rinvsq33 = _mm256_mul_ps(rinv33,rinv33);
1806 fjx1 = _mm256_setzero_ps();
1807 fjy1 = _mm256_setzero_ps();
1808 fjz1 = _mm256_setzero_ps();
1809 fjx2 = _mm256_setzero_ps();
1810 fjy2 = _mm256_setzero_ps();
1811 fjz2 = _mm256_setzero_ps();
1812 fjx3 = _mm256_setzero_ps();
1813 fjy3 = _mm256_setzero_ps();
1814 fjz3 = _mm256_setzero_ps();
1816 /**************************
1817 * CALCULATE INTERACTIONS *
1818 **************************/
1820 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1823 /* REACTION-FIELD ELECTROSTATICS */
1824 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1826 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1830 fscal = _mm256_and_ps(fscal,cutoff_mask);
1832 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1834 /* Calculate temporary vectorial force */
1835 tx = _mm256_mul_ps(fscal,dx11);
1836 ty = _mm256_mul_ps(fscal,dy11);
1837 tz = _mm256_mul_ps(fscal,dz11);
1839 /* Update vectorial force */
1840 fix1 = _mm256_add_ps(fix1,tx);
1841 fiy1 = _mm256_add_ps(fiy1,ty);
1842 fiz1 = _mm256_add_ps(fiz1,tz);
1844 fjx1 = _mm256_add_ps(fjx1,tx);
1845 fjy1 = _mm256_add_ps(fjy1,ty);
1846 fjz1 = _mm256_add_ps(fjz1,tz);
1850 /**************************
1851 * CALCULATE INTERACTIONS *
1852 **************************/
1854 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1857 /* REACTION-FIELD ELECTROSTATICS */
1858 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1860 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1864 fscal = _mm256_and_ps(fscal,cutoff_mask);
1866 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1868 /* Calculate temporary vectorial force */
1869 tx = _mm256_mul_ps(fscal,dx12);
1870 ty = _mm256_mul_ps(fscal,dy12);
1871 tz = _mm256_mul_ps(fscal,dz12);
1873 /* Update vectorial force */
1874 fix1 = _mm256_add_ps(fix1,tx);
1875 fiy1 = _mm256_add_ps(fiy1,ty);
1876 fiz1 = _mm256_add_ps(fiz1,tz);
1878 fjx2 = _mm256_add_ps(fjx2,tx);
1879 fjy2 = _mm256_add_ps(fjy2,ty);
1880 fjz2 = _mm256_add_ps(fjz2,tz);
1884 /**************************
1885 * CALCULATE INTERACTIONS *
1886 **************************/
1888 if (gmx_mm256_any_lt(rsq13,rcutoff2))
1891 /* REACTION-FIELD ELECTROSTATICS */
1892 felec = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1894 cutoff_mask = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1898 fscal = _mm256_and_ps(fscal,cutoff_mask);
1900 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1902 /* Calculate temporary vectorial force */
1903 tx = _mm256_mul_ps(fscal,dx13);
1904 ty = _mm256_mul_ps(fscal,dy13);
1905 tz = _mm256_mul_ps(fscal,dz13);
1907 /* Update vectorial force */
1908 fix1 = _mm256_add_ps(fix1,tx);
1909 fiy1 = _mm256_add_ps(fiy1,ty);
1910 fiz1 = _mm256_add_ps(fiz1,tz);
1912 fjx3 = _mm256_add_ps(fjx3,tx);
1913 fjy3 = _mm256_add_ps(fjy3,ty);
1914 fjz3 = _mm256_add_ps(fjz3,tz);
1918 /**************************
1919 * CALCULATE INTERACTIONS *
1920 **************************/
1922 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1925 /* REACTION-FIELD ELECTROSTATICS */
1926 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1928 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1932 fscal = _mm256_and_ps(fscal,cutoff_mask);
1934 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1936 /* Calculate temporary vectorial force */
1937 tx = _mm256_mul_ps(fscal,dx21);
1938 ty = _mm256_mul_ps(fscal,dy21);
1939 tz = _mm256_mul_ps(fscal,dz21);
1941 /* Update vectorial force */
1942 fix2 = _mm256_add_ps(fix2,tx);
1943 fiy2 = _mm256_add_ps(fiy2,ty);
1944 fiz2 = _mm256_add_ps(fiz2,tz);
1946 fjx1 = _mm256_add_ps(fjx1,tx);
1947 fjy1 = _mm256_add_ps(fjy1,ty);
1948 fjz1 = _mm256_add_ps(fjz1,tz);
1952 /**************************
1953 * CALCULATE INTERACTIONS *
1954 **************************/
1956 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1959 /* REACTION-FIELD ELECTROSTATICS */
1960 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1962 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1966 fscal = _mm256_and_ps(fscal,cutoff_mask);
1968 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1970 /* Calculate temporary vectorial force */
1971 tx = _mm256_mul_ps(fscal,dx22);
1972 ty = _mm256_mul_ps(fscal,dy22);
1973 tz = _mm256_mul_ps(fscal,dz22);
1975 /* Update vectorial force */
1976 fix2 = _mm256_add_ps(fix2,tx);
1977 fiy2 = _mm256_add_ps(fiy2,ty);
1978 fiz2 = _mm256_add_ps(fiz2,tz);
1980 fjx2 = _mm256_add_ps(fjx2,tx);
1981 fjy2 = _mm256_add_ps(fjy2,ty);
1982 fjz2 = _mm256_add_ps(fjz2,tz);
1986 /**************************
1987 * CALCULATE INTERACTIONS *
1988 **************************/
1990 if (gmx_mm256_any_lt(rsq23,rcutoff2))
1993 /* REACTION-FIELD ELECTROSTATICS */
1994 felec = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1996 cutoff_mask = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
2000 fscal = _mm256_and_ps(fscal,cutoff_mask);
2002 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2004 /* Calculate temporary vectorial force */
2005 tx = _mm256_mul_ps(fscal,dx23);
2006 ty = _mm256_mul_ps(fscal,dy23);
2007 tz = _mm256_mul_ps(fscal,dz23);
2009 /* Update vectorial force */
2010 fix2 = _mm256_add_ps(fix2,tx);
2011 fiy2 = _mm256_add_ps(fiy2,ty);
2012 fiz2 = _mm256_add_ps(fiz2,tz);
2014 fjx3 = _mm256_add_ps(fjx3,tx);
2015 fjy3 = _mm256_add_ps(fjy3,ty);
2016 fjz3 = _mm256_add_ps(fjz3,tz);
2020 /**************************
2021 * CALCULATE INTERACTIONS *
2022 **************************/
2024 if (gmx_mm256_any_lt(rsq31,rcutoff2))
2027 /* REACTION-FIELD ELECTROSTATICS */
2028 felec = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
2030 cutoff_mask = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
2034 fscal = _mm256_and_ps(fscal,cutoff_mask);
2036 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2038 /* Calculate temporary vectorial force */
2039 tx = _mm256_mul_ps(fscal,dx31);
2040 ty = _mm256_mul_ps(fscal,dy31);
2041 tz = _mm256_mul_ps(fscal,dz31);
2043 /* Update vectorial force */
2044 fix3 = _mm256_add_ps(fix3,tx);
2045 fiy3 = _mm256_add_ps(fiy3,ty);
2046 fiz3 = _mm256_add_ps(fiz3,tz);
2048 fjx1 = _mm256_add_ps(fjx1,tx);
2049 fjy1 = _mm256_add_ps(fjy1,ty);
2050 fjz1 = _mm256_add_ps(fjz1,tz);
2054 /**************************
2055 * CALCULATE INTERACTIONS *
2056 **************************/
2058 if (gmx_mm256_any_lt(rsq32,rcutoff2))
2061 /* REACTION-FIELD ELECTROSTATICS */
2062 felec = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
2064 cutoff_mask = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
2068 fscal = _mm256_and_ps(fscal,cutoff_mask);
2070 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2072 /* Calculate temporary vectorial force */
2073 tx = _mm256_mul_ps(fscal,dx32);
2074 ty = _mm256_mul_ps(fscal,dy32);
2075 tz = _mm256_mul_ps(fscal,dz32);
2077 /* Update vectorial force */
2078 fix3 = _mm256_add_ps(fix3,tx);
2079 fiy3 = _mm256_add_ps(fiy3,ty);
2080 fiz3 = _mm256_add_ps(fiz3,tz);
2082 fjx2 = _mm256_add_ps(fjx2,tx);
2083 fjy2 = _mm256_add_ps(fjy2,ty);
2084 fjz2 = _mm256_add_ps(fjz2,tz);
2088 /**************************
2089 * CALCULATE INTERACTIONS *
2090 **************************/
2092 if (gmx_mm256_any_lt(rsq33,rcutoff2))
2095 /* REACTION-FIELD ELECTROSTATICS */
2096 felec = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
2098 cutoff_mask = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
2102 fscal = _mm256_and_ps(fscal,cutoff_mask);
2104 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2106 /* Calculate temporary vectorial force */
2107 tx = _mm256_mul_ps(fscal,dx33);
2108 ty = _mm256_mul_ps(fscal,dy33);
2109 tz = _mm256_mul_ps(fscal,dz33);
2111 /* Update vectorial force */
2112 fix3 = _mm256_add_ps(fix3,tx);
2113 fiy3 = _mm256_add_ps(fiy3,ty);
2114 fiz3 = _mm256_add_ps(fiz3,tz);
2116 fjx3 = _mm256_add_ps(fjx3,tx);
2117 fjy3 = _mm256_add_ps(fjy3,ty);
2118 fjz3 = _mm256_add_ps(fjz3,tz);
2122 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2123 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2124 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2125 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2126 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2127 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2128 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2129 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2131 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
2132 fjptrE+DIM,fjptrF+DIM,fjptrG+DIM,fjptrH+DIM,
2133 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2135 /* Inner loop uses 270 flops */
2138 /* End of innermost loop */
2140 gmx_mm256_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2141 f+i_coord_offset+DIM,fshift+i_shift_offset);
2143 /* Increment number of inner iterations */
2144 inneriter += j_index_end - j_index_start;
2146 /* Outer loop uses 18 flops */
2149 /* Increment number of outer iterations */
2152 /* Update outer/inner flops */
2154 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*18 + inneriter*270);