2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_256_single kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_256_single.h"
48 #include "kernelutil_x86_avx_256_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3W3_VF_avx_256_single
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: None
54 * Geometry: Water3-Water3
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRFCut_VdwNone_GeomW3W3_VF_avx_256_single
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int jnrA,jnrB,jnrC,jnrD;
75 int jnrE,jnrF,jnrG,jnrH;
76 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
77 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
80 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
82 real *shiftvec,*fshift,*x,*f;
83 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
85 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
86 real * vdwioffsetptr0;
87 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 real * vdwioffsetptr1;
89 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 real * vdwioffsetptr2;
91 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
92 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
93 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
94 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
95 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
96 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
97 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
98 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
99 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
100 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
101 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
102 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
103 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
104 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
105 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
106 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
107 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
109 __m256 dummy_mask,cutoff_mask;
110 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
111 __m256 one = _mm256_set1_ps(1.0);
112 __m256 two = _mm256_set1_ps(2.0);
118 jindex = nlist->jindex;
120 shiftidx = nlist->shift;
122 shiftvec = fr->shift_vec[0];
123 fshift = fr->fshift[0];
124 facel = _mm256_set1_ps(fr->epsfac);
125 charge = mdatoms->chargeA;
126 krf = _mm256_set1_ps(fr->ic->k_rf);
127 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
128 crf = _mm256_set1_ps(fr->ic->c_rf);
130 /* Setup water-specific parameters */
131 inr = nlist->iinr[0];
132 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
133 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
134 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
136 jq0 = _mm256_set1_ps(charge[inr+0]);
137 jq1 = _mm256_set1_ps(charge[inr+1]);
138 jq2 = _mm256_set1_ps(charge[inr+2]);
139 qq00 = _mm256_mul_ps(iq0,jq0);
140 qq01 = _mm256_mul_ps(iq0,jq1);
141 qq02 = _mm256_mul_ps(iq0,jq2);
142 qq10 = _mm256_mul_ps(iq1,jq0);
143 qq11 = _mm256_mul_ps(iq1,jq1);
144 qq12 = _mm256_mul_ps(iq1,jq2);
145 qq20 = _mm256_mul_ps(iq2,jq0);
146 qq21 = _mm256_mul_ps(iq2,jq1);
147 qq22 = _mm256_mul_ps(iq2,jq2);
149 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
150 rcutoff_scalar = fr->rcoulomb;
151 rcutoff = _mm256_set1_ps(rcutoff_scalar);
152 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
154 /* Avoid stupid compiler warnings */
155 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
168 for(iidx=0;iidx<4*DIM;iidx++)
173 /* Start outer loop over neighborlists */
174 for(iidx=0; iidx<nri; iidx++)
176 /* Load shift vector for this list */
177 i_shift_offset = DIM*shiftidx[iidx];
179 /* Load limits for loop over neighbors */
180 j_index_start = jindex[iidx];
181 j_index_end = jindex[iidx+1];
183 /* Get outer coordinate index */
185 i_coord_offset = DIM*inr;
187 /* Load i particle coords and add shift vector */
188 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
189 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
191 fix0 = _mm256_setzero_ps();
192 fiy0 = _mm256_setzero_ps();
193 fiz0 = _mm256_setzero_ps();
194 fix1 = _mm256_setzero_ps();
195 fiy1 = _mm256_setzero_ps();
196 fiz1 = _mm256_setzero_ps();
197 fix2 = _mm256_setzero_ps();
198 fiy2 = _mm256_setzero_ps();
199 fiz2 = _mm256_setzero_ps();
201 /* Reset potential sums */
202 velecsum = _mm256_setzero_ps();
204 /* Start inner kernel loop */
205 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
208 /* Get j neighbor index, and coordinate index */
217 j_coord_offsetA = DIM*jnrA;
218 j_coord_offsetB = DIM*jnrB;
219 j_coord_offsetC = DIM*jnrC;
220 j_coord_offsetD = DIM*jnrD;
221 j_coord_offsetE = DIM*jnrE;
222 j_coord_offsetF = DIM*jnrF;
223 j_coord_offsetG = DIM*jnrG;
224 j_coord_offsetH = DIM*jnrH;
226 /* load j atom coordinates */
227 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
228 x+j_coord_offsetC,x+j_coord_offsetD,
229 x+j_coord_offsetE,x+j_coord_offsetF,
230 x+j_coord_offsetG,x+j_coord_offsetH,
231 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
233 /* Calculate displacement vector */
234 dx00 = _mm256_sub_ps(ix0,jx0);
235 dy00 = _mm256_sub_ps(iy0,jy0);
236 dz00 = _mm256_sub_ps(iz0,jz0);
237 dx01 = _mm256_sub_ps(ix0,jx1);
238 dy01 = _mm256_sub_ps(iy0,jy1);
239 dz01 = _mm256_sub_ps(iz0,jz1);
240 dx02 = _mm256_sub_ps(ix0,jx2);
241 dy02 = _mm256_sub_ps(iy0,jy2);
242 dz02 = _mm256_sub_ps(iz0,jz2);
243 dx10 = _mm256_sub_ps(ix1,jx0);
244 dy10 = _mm256_sub_ps(iy1,jy0);
245 dz10 = _mm256_sub_ps(iz1,jz0);
246 dx11 = _mm256_sub_ps(ix1,jx1);
247 dy11 = _mm256_sub_ps(iy1,jy1);
248 dz11 = _mm256_sub_ps(iz1,jz1);
249 dx12 = _mm256_sub_ps(ix1,jx2);
250 dy12 = _mm256_sub_ps(iy1,jy2);
251 dz12 = _mm256_sub_ps(iz1,jz2);
252 dx20 = _mm256_sub_ps(ix2,jx0);
253 dy20 = _mm256_sub_ps(iy2,jy0);
254 dz20 = _mm256_sub_ps(iz2,jz0);
255 dx21 = _mm256_sub_ps(ix2,jx1);
256 dy21 = _mm256_sub_ps(iy2,jy1);
257 dz21 = _mm256_sub_ps(iz2,jz1);
258 dx22 = _mm256_sub_ps(ix2,jx2);
259 dy22 = _mm256_sub_ps(iy2,jy2);
260 dz22 = _mm256_sub_ps(iz2,jz2);
262 /* Calculate squared distance and things based on it */
263 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
264 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
265 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
266 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
267 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
268 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
269 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
270 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
271 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
273 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
274 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
275 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
276 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
277 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
278 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
279 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
280 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
281 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
283 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
284 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
285 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
286 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
287 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
288 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
289 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
290 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
291 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
293 fjx0 = _mm256_setzero_ps();
294 fjy0 = _mm256_setzero_ps();
295 fjz0 = _mm256_setzero_ps();
296 fjx1 = _mm256_setzero_ps();
297 fjy1 = _mm256_setzero_ps();
298 fjz1 = _mm256_setzero_ps();
299 fjx2 = _mm256_setzero_ps();
300 fjy2 = _mm256_setzero_ps();
301 fjz2 = _mm256_setzero_ps();
303 /**************************
304 * CALCULATE INTERACTIONS *
305 **************************/
307 if (gmx_mm256_any_lt(rsq00,rcutoff2))
310 /* REACTION-FIELD ELECTROSTATICS */
311 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
312 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
314 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
316 /* Update potential sum for this i atom from the interaction with this j atom. */
317 velec = _mm256_and_ps(velec,cutoff_mask);
318 velecsum = _mm256_add_ps(velecsum,velec);
322 fscal = _mm256_and_ps(fscal,cutoff_mask);
324 /* Calculate temporary vectorial force */
325 tx = _mm256_mul_ps(fscal,dx00);
326 ty = _mm256_mul_ps(fscal,dy00);
327 tz = _mm256_mul_ps(fscal,dz00);
329 /* Update vectorial force */
330 fix0 = _mm256_add_ps(fix0,tx);
331 fiy0 = _mm256_add_ps(fiy0,ty);
332 fiz0 = _mm256_add_ps(fiz0,tz);
334 fjx0 = _mm256_add_ps(fjx0,tx);
335 fjy0 = _mm256_add_ps(fjy0,ty);
336 fjz0 = _mm256_add_ps(fjz0,tz);
340 /**************************
341 * CALCULATE INTERACTIONS *
342 **************************/
344 if (gmx_mm256_any_lt(rsq01,rcutoff2))
347 /* REACTION-FIELD ELECTROSTATICS */
348 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
349 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
351 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
353 /* Update potential sum for this i atom from the interaction with this j atom. */
354 velec = _mm256_and_ps(velec,cutoff_mask);
355 velecsum = _mm256_add_ps(velecsum,velec);
359 fscal = _mm256_and_ps(fscal,cutoff_mask);
361 /* Calculate temporary vectorial force */
362 tx = _mm256_mul_ps(fscal,dx01);
363 ty = _mm256_mul_ps(fscal,dy01);
364 tz = _mm256_mul_ps(fscal,dz01);
366 /* Update vectorial force */
367 fix0 = _mm256_add_ps(fix0,tx);
368 fiy0 = _mm256_add_ps(fiy0,ty);
369 fiz0 = _mm256_add_ps(fiz0,tz);
371 fjx1 = _mm256_add_ps(fjx1,tx);
372 fjy1 = _mm256_add_ps(fjy1,ty);
373 fjz1 = _mm256_add_ps(fjz1,tz);
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
381 if (gmx_mm256_any_lt(rsq02,rcutoff2))
384 /* REACTION-FIELD ELECTROSTATICS */
385 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
386 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
388 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
390 /* Update potential sum for this i atom from the interaction with this j atom. */
391 velec = _mm256_and_ps(velec,cutoff_mask);
392 velecsum = _mm256_add_ps(velecsum,velec);
396 fscal = _mm256_and_ps(fscal,cutoff_mask);
398 /* Calculate temporary vectorial force */
399 tx = _mm256_mul_ps(fscal,dx02);
400 ty = _mm256_mul_ps(fscal,dy02);
401 tz = _mm256_mul_ps(fscal,dz02);
403 /* Update vectorial force */
404 fix0 = _mm256_add_ps(fix0,tx);
405 fiy0 = _mm256_add_ps(fiy0,ty);
406 fiz0 = _mm256_add_ps(fiz0,tz);
408 fjx2 = _mm256_add_ps(fjx2,tx);
409 fjy2 = _mm256_add_ps(fjy2,ty);
410 fjz2 = _mm256_add_ps(fjz2,tz);
414 /**************************
415 * CALCULATE INTERACTIONS *
416 **************************/
418 if (gmx_mm256_any_lt(rsq10,rcutoff2))
421 /* REACTION-FIELD ELECTROSTATICS */
422 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
423 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
425 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
427 /* Update potential sum for this i atom from the interaction with this j atom. */
428 velec = _mm256_and_ps(velec,cutoff_mask);
429 velecsum = _mm256_add_ps(velecsum,velec);
433 fscal = _mm256_and_ps(fscal,cutoff_mask);
435 /* Calculate temporary vectorial force */
436 tx = _mm256_mul_ps(fscal,dx10);
437 ty = _mm256_mul_ps(fscal,dy10);
438 tz = _mm256_mul_ps(fscal,dz10);
440 /* Update vectorial force */
441 fix1 = _mm256_add_ps(fix1,tx);
442 fiy1 = _mm256_add_ps(fiy1,ty);
443 fiz1 = _mm256_add_ps(fiz1,tz);
445 fjx0 = _mm256_add_ps(fjx0,tx);
446 fjy0 = _mm256_add_ps(fjy0,ty);
447 fjz0 = _mm256_add_ps(fjz0,tz);
451 /**************************
452 * CALCULATE INTERACTIONS *
453 **************************/
455 if (gmx_mm256_any_lt(rsq11,rcutoff2))
458 /* REACTION-FIELD ELECTROSTATICS */
459 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
460 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
462 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
464 /* Update potential sum for this i atom from the interaction with this j atom. */
465 velec = _mm256_and_ps(velec,cutoff_mask);
466 velecsum = _mm256_add_ps(velecsum,velec);
470 fscal = _mm256_and_ps(fscal,cutoff_mask);
472 /* Calculate temporary vectorial force */
473 tx = _mm256_mul_ps(fscal,dx11);
474 ty = _mm256_mul_ps(fscal,dy11);
475 tz = _mm256_mul_ps(fscal,dz11);
477 /* Update vectorial force */
478 fix1 = _mm256_add_ps(fix1,tx);
479 fiy1 = _mm256_add_ps(fiy1,ty);
480 fiz1 = _mm256_add_ps(fiz1,tz);
482 fjx1 = _mm256_add_ps(fjx1,tx);
483 fjy1 = _mm256_add_ps(fjy1,ty);
484 fjz1 = _mm256_add_ps(fjz1,tz);
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
492 if (gmx_mm256_any_lt(rsq12,rcutoff2))
495 /* REACTION-FIELD ELECTROSTATICS */
496 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
497 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
499 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
501 /* Update potential sum for this i atom from the interaction with this j atom. */
502 velec = _mm256_and_ps(velec,cutoff_mask);
503 velecsum = _mm256_add_ps(velecsum,velec);
507 fscal = _mm256_and_ps(fscal,cutoff_mask);
509 /* Calculate temporary vectorial force */
510 tx = _mm256_mul_ps(fscal,dx12);
511 ty = _mm256_mul_ps(fscal,dy12);
512 tz = _mm256_mul_ps(fscal,dz12);
514 /* Update vectorial force */
515 fix1 = _mm256_add_ps(fix1,tx);
516 fiy1 = _mm256_add_ps(fiy1,ty);
517 fiz1 = _mm256_add_ps(fiz1,tz);
519 fjx2 = _mm256_add_ps(fjx2,tx);
520 fjy2 = _mm256_add_ps(fjy2,ty);
521 fjz2 = _mm256_add_ps(fjz2,tz);
525 /**************************
526 * CALCULATE INTERACTIONS *
527 **************************/
529 if (gmx_mm256_any_lt(rsq20,rcutoff2))
532 /* REACTION-FIELD ELECTROSTATICS */
533 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
534 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
536 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
538 /* Update potential sum for this i atom from the interaction with this j atom. */
539 velec = _mm256_and_ps(velec,cutoff_mask);
540 velecsum = _mm256_add_ps(velecsum,velec);
544 fscal = _mm256_and_ps(fscal,cutoff_mask);
546 /* Calculate temporary vectorial force */
547 tx = _mm256_mul_ps(fscal,dx20);
548 ty = _mm256_mul_ps(fscal,dy20);
549 tz = _mm256_mul_ps(fscal,dz20);
551 /* Update vectorial force */
552 fix2 = _mm256_add_ps(fix2,tx);
553 fiy2 = _mm256_add_ps(fiy2,ty);
554 fiz2 = _mm256_add_ps(fiz2,tz);
556 fjx0 = _mm256_add_ps(fjx0,tx);
557 fjy0 = _mm256_add_ps(fjy0,ty);
558 fjz0 = _mm256_add_ps(fjz0,tz);
562 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
566 if (gmx_mm256_any_lt(rsq21,rcutoff2))
569 /* REACTION-FIELD ELECTROSTATICS */
570 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
571 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
573 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
575 /* Update potential sum for this i atom from the interaction with this j atom. */
576 velec = _mm256_and_ps(velec,cutoff_mask);
577 velecsum = _mm256_add_ps(velecsum,velec);
581 fscal = _mm256_and_ps(fscal,cutoff_mask);
583 /* Calculate temporary vectorial force */
584 tx = _mm256_mul_ps(fscal,dx21);
585 ty = _mm256_mul_ps(fscal,dy21);
586 tz = _mm256_mul_ps(fscal,dz21);
588 /* Update vectorial force */
589 fix2 = _mm256_add_ps(fix2,tx);
590 fiy2 = _mm256_add_ps(fiy2,ty);
591 fiz2 = _mm256_add_ps(fiz2,tz);
593 fjx1 = _mm256_add_ps(fjx1,tx);
594 fjy1 = _mm256_add_ps(fjy1,ty);
595 fjz1 = _mm256_add_ps(fjz1,tz);
599 /**************************
600 * CALCULATE INTERACTIONS *
601 **************************/
603 if (gmx_mm256_any_lt(rsq22,rcutoff2))
606 /* REACTION-FIELD ELECTROSTATICS */
607 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
608 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
610 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
612 /* Update potential sum for this i atom from the interaction with this j atom. */
613 velec = _mm256_and_ps(velec,cutoff_mask);
614 velecsum = _mm256_add_ps(velecsum,velec);
618 fscal = _mm256_and_ps(fscal,cutoff_mask);
620 /* Calculate temporary vectorial force */
621 tx = _mm256_mul_ps(fscal,dx22);
622 ty = _mm256_mul_ps(fscal,dy22);
623 tz = _mm256_mul_ps(fscal,dz22);
625 /* Update vectorial force */
626 fix2 = _mm256_add_ps(fix2,tx);
627 fiy2 = _mm256_add_ps(fiy2,ty);
628 fiz2 = _mm256_add_ps(fiz2,tz);
630 fjx2 = _mm256_add_ps(fjx2,tx);
631 fjy2 = _mm256_add_ps(fjy2,ty);
632 fjz2 = _mm256_add_ps(fjz2,tz);
636 fjptrA = f+j_coord_offsetA;
637 fjptrB = f+j_coord_offsetB;
638 fjptrC = f+j_coord_offsetC;
639 fjptrD = f+j_coord_offsetD;
640 fjptrE = f+j_coord_offsetE;
641 fjptrF = f+j_coord_offsetF;
642 fjptrG = f+j_coord_offsetG;
643 fjptrH = f+j_coord_offsetH;
645 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
646 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
648 /* Inner loop uses 324 flops */
654 /* Get j neighbor index, and coordinate index */
655 jnrlistA = jjnr[jidx];
656 jnrlistB = jjnr[jidx+1];
657 jnrlistC = jjnr[jidx+2];
658 jnrlistD = jjnr[jidx+3];
659 jnrlistE = jjnr[jidx+4];
660 jnrlistF = jjnr[jidx+5];
661 jnrlistG = jjnr[jidx+6];
662 jnrlistH = jjnr[jidx+7];
663 /* Sign of each element will be negative for non-real atoms.
664 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
665 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
667 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
668 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
670 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
671 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
672 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
673 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
674 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
675 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
676 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
677 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
678 j_coord_offsetA = DIM*jnrA;
679 j_coord_offsetB = DIM*jnrB;
680 j_coord_offsetC = DIM*jnrC;
681 j_coord_offsetD = DIM*jnrD;
682 j_coord_offsetE = DIM*jnrE;
683 j_coord_offsetF = DIM*jnrF;
684 j_coord_offsetG = DIM*jnrG;
685 j_coord_offsetH = DIM*jnrH;
687 /* load j atom coordinates */
688 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
689 x+j_coord_offsetC,x+j_coord_offsetD,
690 x+j_coord_offsetE,x+j_coord_offsetF,
691 x+j_coord_offsetG,x+j_coord_offsetH,
692 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
694 /* Calculate displacement vector */
695 dx00 = _mm256_sub_ps(ix0,jx0);
696 dy00 = _mm256_sub_ps(iy0,jy0);
697 dz00 = _mm256_sub_ps(iz0,jz0);
698 dx01 = _mm256_sub_ps(ix0,jx1);
699 dy01 = _mm256_sub_ps(iy0,jy1);
700 dz01 = _mm256_sub_ps(iz0,jz1);
701 dx02 = _mm256_sub_ps(ix0,jx2);
702 dy02 = _mm256_sub_ps(iy0,jy2);
703 dz02 = _mm256_sub_ps(iz0,jz2);
704 dx10 = _mm256_sub_ps(ix1,jx0);
705 dy10 = _mm256_sub_ps(iy1,jy0);
706 dz10 = _mm256_sub_ps(iz1,jz0);
707 dx11 = _mm256_sub_ps(ix1,jx1);
708 dy11 = _mm256_sub_ps(iy1,jy1);
709 dz11 = _mm256_sub_ps(iz1,jz1);
710 dx12 = _mm256_sub_ps(ix1,jx2);
711 dy12 = _mm256_sub_ps(iy1,jy2);
712 dz12 = _mm256_sub_ps(iz1,jz2);
713 dx20 = _mm256_sub_ps(ix2,jx0);
714 dy20 = _mm256_sub_ps(iy2,jy0);
715 dz20 = _mm256_sub_ps(iz2,jz0);
716 dx21 = _mm256_sub_ps(ix2,jx1);
717 dy21 = _mm256_sub_ps(iy2,jy1);
718 dz21 = _mm256_sub_ps(iz2,jz1);
719 dx22 = _mm256_sub_ps(ix2,jx2);
720 dy22 = _mm256_sub_ps(iy2,jy2);
721 dz22 = _mm256_sub_ps(iz2,jz2);
723 /* Calculate squared distance and things based on it */
724 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
725 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
726 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
727 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
728 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
729 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
730 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
731 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
732 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
734 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
735 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
736 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
737 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
738 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
739 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
740 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
741 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
742 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
744 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
745 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
746 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
747 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
748 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
749 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
750 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
751 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
752 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
754 fjx0 = _mm256_setzero_ps();
755 fjy0 = _mm256_setzero_ps();
756 fjz0 = _mm256_setzero_ps();
757 fjx1 = _mm256_setzero_ps();
758 fjy1 = _mm256_setzero_ps();
759 fjz1 = _mm256_setzero_ps();
760 fjx2 = _mm256_setzero_ps();
761 fjy2 = _mm256_setzero_ps();
762 fjz2 = _mm256_setzero_ps();
764 /**************************
765 * CALCULATE INTERACTIONS *
766 **************************/
768 if (gmx_mm256_any_lt(rsq00,rcutoff2))
771 /* REACTION-FIELD ELECTROSTATICS */
772 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
773 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
775 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
777 /* Update potential sum for this i atom from the interaction with this j atom. */
778 velec = _mm256_and_ps(velec,cutoff_mask);
779 velec = _mm256_andnot_ps(dummy_mask,velec);
780 velecsum = _mm256_add_ps(velecsum,velec);
784 fscal = _mm256_and_ps(fscal,cutoff_mask);
786 fscal = _mm256_andnot_ps(dummy_mask,fscal);
788 /* Calculate temporary vectorial force */
789 tx = _mm256_mul_ps(fscal,dx00);
790 ty = _mm256_mul_ps(fscal,dy00);
791 tz = _mm256_mul_ps(fscal,dz00);
793 /* Update vectorial force */
794 fix0 = _mm256_add_ps(fix0,tx);
795 fiy0 = _mm256_add_ps(fiy0,ty);
796 fiz0 = _mm256_add_ps(fiz0,tz);
798 fjx0 = _mm256_add_ps(fjx0,tx);
799 fjy0 = _mm256_add_ps(fjy0,ty);
800 fjz0 = _mm256_add_ps(fjz0,tz);
804 /**************************
805 * CALCULATE INTERACTIONS *
806 **************************/
808 if (gmx_mm256_any_lt(rsq01,rcutoff2))
811 /* REACTION-FIELD ELECTROSTATICS */
812 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
813 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
815 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
817 /* Update potential sum for this i atom from the interaction with this j atom. */
818 velec = _mm256_and_ps(velec,cutoff_mask);
819 velec = _mm256_andnot_ps(dummy_mask,velec);
820 velecsum = _mm256_add_ps(velecsum,velec);
824 fscal = _mm256_and_ps(fscal,cutoff_mask);
826 fscal = _mm256_andnot_ps(dummy_mask,fscal);
828 /* Calculate temporary vectorial force */
829 tx = _mm256_mul_ps(fscal,dx01);
830 ty = _mm256_mul_ps(fscal,dy01);
831 tz = _mm256_mul_ps(fscal,dz01);
833 /* Update vectorial force */
834 fix0 = _mm256_add_ps(fix0,tx);
835 fiy0 = _mm256_add_ps(fiy0,ty);
836 fiz0 = _mm256_add_ps(fiz0,tz);
838 fjx1 = _mm256_add_ps(fjx1,tx);
839 fjy1 = _mm256_add_ps(fjy1,ty);
840 fjz1 = _mm256_add_ps(fjz1,tz);
844 /**************************
845 * CALCULATE INTERACTIONS *
846 **************************/
848 if (gmx_mm256_any_lt(rsq02,rcutoff2))
851 /* REACTION-FIELD ELECTROSTATICS */
852 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
853 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
855 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
857 /* Update potential sum for this i atom from the interaction with this j atom. */
858 velec = _mm256_and_ps(velec,cutoff_mask);
859 velec = _mm256_andnot_ps(dummy_mask,velec);
860 velecsum = _mm256_add_ps(velecsum,velec);
864 fscal = _mm256_and_ps(fscal,cutoff_mask);
866 fscal = _mm256_andnot_ps(dummy_mask,fscal);
868 /* Calculate temporary vectorial force */
869 tx = _mm256_mul_ps(fscal,dx02);
870 ty = _mm256_mul_ps(fscal,dy02);
871 tz = _mm256_mul_ps(fscal,dz02);
873 /* Update vectorial force */
874 fix0 = _mm256_add_ps(fix0,tx);
875 fiy0 = _mm256_add_ps(fiy0,ty);
876 fiz0 = _mm256_add_ps(fiz0,tz);
878 fjx2 = _mm256_add_ps(fjx2,tx);
879 fjy2 = _mm256_add_ps(fjy2,ty);
880 fjz2 = _mm256_add_ps(fjz2,tz);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 if (gmx_mm256_any_lt(rsq10,rcutoff2))
891 /* REACTION-FIELD ELECTROSTATICS */
892 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
893 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
895 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
897 /* Update potential sum for this i atom from the interaction with this j atom. */
898 velec = _mm256_and_ps(velec,cutoff_mask);
899 velec = _mm256_andnot_ps(dummy_mask,velec);
900 velecsum = _mm256_add_ps(velecsum,velec);
904 fscal = _mm256_and_ps(fscal,cutoff_mask);
906 fscal = _mm256_andnot_ps(dummy_mask,fscal);
908 /* Calculate temporary vectorial force */
909 tx = _mm256_mul_ps(fscal,dx10);
910 ty = _mm256_mul_ps(fscal,dy10);
911 tz = _mm256_mul_ps(fscal,dz10);
913 /* Update vectorial force */
914 fix1 = _mm256_add_ps(fix1,tx);
915 fiy1 = _mm256_add_ps(fiy1,ty);
916 fiz1 = _mm256_add_ps(fiz1,tz);
918 fjx0 = _mm256_add_ps(fjx0,tx);
919 fjy0 = _mm256_add_ps(fjy0,ty);
920 fjz0 = _mm256_add_ps(fjz0,tz);
924 /**************************
925 * CALCULATE INTERACTIONS *
926 **************************/
928 if (gmx_mm256_any_lt(rsq11,rcutoff2))
931 /* REACTION-FIELD ELECTROSTATICS */
932 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
933 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
935 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
937 /* Update potential sum for this i atom from the interaction with this j atom. */
938 velec = _mm256_and_ps(velec,cutoff_mask);
939 velec = _mm256_andnot_ps(dummy_mask,velec);
940 velecsum = _mm256_add_ps(velecsum,velec);
944 fscal = _mm256_and_ps(fscal,cutoff_mask);
946 fscal = _mm256_andnot_ps(dummy_mask,fscal);
948 /* Calculate temporary vectorial force */
949 tx = _mm256_mul_ps(fscal,dx11);
950 ty = _mm256_mul_ps(fscal,dy11);
951 tz = _mm256_mul_ps(fscal,dz11);
953 /* Update vectorial force */
954 fix1 = _mm256_add_ps(fix1,tx);
955 fiy1 = _mm256_add_ps(fiy1,ty);
956 fiz1 = _mm256_add_ps(fiz1,tz);
958 fjx1 = _mm256_add_ps(fjx1,tx);
959 fjy1 = _mm256_add_ps(fjy1,ty);
960 fjz1 = _mm256_add_ps(fjz1,tz);
964 /**************************
965 * CALCULATE INTERACTIONS *
966 **************************/
968 if (gmx_mm256_any_lt(rsq12,rcutoff2))
971 /* REACTION-FIELD ELECTROSTATICS */
972 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
973 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
975 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
977 /* Update potential sum for this i atom from the interaction with this j atom. */
978 velec = _mm256_and_ps(velec,cutoff_mask);
979 velec = _mm256_andnot_ps(dummy_mask,velec);
980 velecsum = _mm256_add_ps(velecsum,velec);
984 fscal = _mm256_and_ps(fscal,cutoff_mask);
986 fscal = _mm256_andnot_ps(dummy_mask,fscal);
988 /* Calculate temporary vectorial force */
989 tx = _mm256_mul_ps(fscal,dx12);
990 ty = _mm256_mul_ps(fscal,dy12);
991 tz = _mm256_mul_ps(fscal,dz12);
993 /* Update vectorial force */
994 fix1 = _mm256_add_ps(fix1,tx);
995 fiy1 = _mm256_add_ps(fiy1,ty);
996 fiz1 = _mm256_add_ps(fiz1,tz);
998 fjx2 = _mm256_add_ps(fjx2,tx);
999 fjy2 = _mm256_add_ps(fjy2,ty);
1000 fjz2 = _mm256_add_ps(fjz2,tz);
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1008 if (gmx_mm256_any_lt(rsq20,rcutoff2))
1011 /* REACTION-FIELD ELECTROSTATICS */
1012 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
1013 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1015 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
1017 /* Update potential sum for this i atom from the interaction with this j atom. */
1018 velec = _mm256_and_ps(velec,cutoff_mask);
1019 velec = _mm256_andnot_ps(dummy_mask,velec);
1020 velecsum = _mm256_add_ps(velecsum,velec);
1024 fscal = _mm256_and_ps(fscal,cutoff_mask);
1026 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1028 /* Calculate temporary vectorial force */
1029 tx = _mm256_mul_ps(fscal,dx20);
1030 ty = _mm256_mul_ps(fscal,dy20);
1031 tz = _mm256_mul_ps(fscal,dz20);
1033 /* Update vectorial force */
1034 fix2 = _mm256_add_ps(fix2,tx);
1035 fiy2 = _mm256_add_ps(fiy2,ty);
1036 fiz2 = _mm256_add_ps(fiz2,tz);
1038 fjx0 = _mm256_add_ps(fjx0,tx);
1039 fjy0 = _mm256_add_ps(fjy0,ty);
1040 fjz0 = _mm256_add_ps(fjz0,tz);
1044 /**************************
1045 * CALCULATE INTERACTIONS *
1046 **************************/
1048 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1051 /* REACTION-FIELD ELECTROSTATICS */
1052 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1053 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1055 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1057 /* Update potential sum for this i atom from the interaction with this j atom. */
1058 velec = _mm256_and_ps(velec,cutoff_mask);
1059 velec = _mm256_andnot_ps(dummy_mask,velec);
1060 velecsum = _mm256_add_ps(velecsum,velec);
1064 fscal = _mm256_and_ps(fscal,cutoff_mask);
1066 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1068 /* Calculate temporary vectorial force */
1069 tx = _mm256_mul_ps(fscal,dx21);
1070 ty = _mm256_mul_ps(fscal,dy21);
1071 tz = _mm256_mul_ps(fscal,dz21);
1073 /* Update vectorial force */
1074 fix2 = _mm256_add_ps(fix2,tx);
1075 fiy2 = _mm256_add_ps(fiy2,ty);
1076 fiz2 = _mm256_add_ps(fiz2,tz);
1078 fjx1 = _mm256_add_ps(fjx1,tx);
1079 fjy1 = _mm256_add_ps(fjy1,ty);
1080 fjz1 = _mm256_add_ps(fjz1,tz);
1084 /**************************
1085 * CALCULATE INTERACTIONS *
1086 **************************/
1088 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1091 /* REACTION-FIELD ELECTROSTATICS */
1092 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1093 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1095 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1097 /* Update potential sum for this i atom from the interaction with this j atom. */
1098 velec = _mm256_and_ps(velec,cutoff_mask);
1099 velec = _mm256_andnot_ps(dummy_mask,velec);
1100 velecsum = _mm256_add_ps(velecsum,velec);
1104 fscal = _mm256_and_ps(fscal,cutoff_mask);
1106 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1108 /* Calculate temporary vectorial force */
1109 tx = _mm256_mul_ps(fscal,dx22);
1110 ty = _mm256_mul_ps(fscal,dy22);
1111 tz = _mm256_mul_ps(fscal,dz22);
1113 /* Update vectorial force */
1114 fix2 = _mm256_add_ps(fix2,tx);
1115 fiy2 = _mm256_add_ps(fiy2,ty);
1116 fiz2 = _mm256_add_ps(fiz2,tz);
1118 fjx2 = _mm256_add_ps(fjx2,tx);
1119 fjy2 = _mm256_add_ps(fjy2,ty);
1120 fjz2 = _mm256_add_ps(fjz2,tz);
1124 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1125 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1126 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1127 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1128 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1129 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1130 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1131 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1133 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1134 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1136 /* Inner loop uses 324 flops */
1139 /* End of innermost loop */
1141 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1142 f+i_coord_offset,fshift+i_shift_offset);
1145 /* Update potential energies */
1146 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1148 /* Increment number of inner iterations */
1149 inneriter += j_index_end - j_index_start;
1151 /* Outer loop uses 19 flops */
1154 /* Increment number of outer iterations */
1157 /* Update outer/inner flops */
1159 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*324);
1162 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3W3_F_avx_256_single
1163 * Electrostatics interaction: ReactionField
1164 * VdW interaction: None
1165 * Geometry: Water3-Water3
1166 * Calculate force/pot: Force
1169 nb_kernel_ElecRFCut_VdwNone_GeomW3W3_F_avx_256_single
1170 (t_nblist * gmx_restrict nlist,
1171 rvec * gmx_restrict xx,
1172 rvec * gmx_restrict ff,
1173 t_forcerec * gmx_restrict fr,
1174 t_mdatoms * gmx_restrict mdatoms,
1175 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1176 t_nrnb * gmx_restrict nrnb)
1178 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1179 * just 0 for non-waters.
1180 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1181 * jnr indices corresponding to data put in the four positions in the SIMD register.
1183 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1184 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1185 int jnrA,jnrB,jnrC,jnrD;
1186 int jnrE,jnrF,jnrG,jnrH;
1187 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1188 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1189 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1190 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1191 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1192 real rcutoff_scalar;
1193 real *shiftvec,*fshift,*x,*f;
1194 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1195 real scratch[4*DIM];
1196 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1197 real * vdwioffsetptr0;
1198 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1199 real * vdwioffsetptr1;
1200 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1201 real * vdwioffsetptr2;
1202 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1203 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1204 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1205 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1206 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1207 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1208 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1209 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1210 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1211 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1212 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1213 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1214 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1215 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1216 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1217 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1218 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1220 __m256 dummy_mask,cutoff_mask;
1221 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1222 __m256 one = _mm256_set1_ps(1.0);
1223 __m256 two = _mm256_set1_ps(2.0);
1229 jindex = nlist->jindex;
1231 shiftidx = nlist->shift;
1233 shiftvec = fr->shift_vec[0];
1234 fshift = fr->fshift[0];
1235 facel = _mm256_set1_ps(fr->epsfac);
1236 charge = mdatoms->chargeA;
1237 krf = _mm256_set1_ps(fr->ic->k_rf);
1238 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1239 crf = _mm256_set1_ps(fr->ic->c_rf);
1241 /* Setup water-specific parameters */
1242 inr = nlist->iinr[0];
1243 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
1244 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1245 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1247 jq0 = _mm256_set1_ps(charge[inr+0]);
1248 jq1 = _mm256_set1_ps(charge[inr+1]);
1249 jq2 = _mm256_set1_ps(charge[inr+2]);
1250 qq00 = _mm256_mul_ps(iq0,jq0);
1251 qq01 = _mm256_mul_ps(iq0,jq1);
1252 qq02 = _mm256_mul_ps(iq0,jq2);
1253 qq10 = _mm256_mul_ps(iq1,jq0);
1254 qq11 = _mm256_mul_ps(iq1,jq1);
1255 qq12 = _mm256_mul_ps(iq1,jq2);
1256 qq20 = _mm256_mul_ps(iq2,jq0);
1257 qq21 = _mm256_mul_ps(iq2,jq1);
1258 qq22 = _mm256_mul_ps(iq2,jq2);
1260 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1261 rcutoff_scalar = fr->rcoulomb;
1262 rcutoff = _mm256_set1_ps(rcutoff_scalar);
1263 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
1265 /* Avoid stupid compiler warnings */
1266 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1267 j_coord_offsetA = 0;
1268 j_coord_offsetB = 0;
1269 j_coord_offsetC = 0;
1270 j_coord_offsetD = 0;
1271 j_coord_offsetE = 0;
1272 j_coord_offsetF = 0;
1273 j_coord_offsetG = 0;
1274 j_coord_offsetH = 0;
1279 for(iidx=0;iidx<4*DIM;iidx++)
1281 scratch[iidx] = 0.0;
1284 /* Start outer loop over neighborlists */
1285 for(iidx=0; iidx<nri; iidx++)
1287 /* Load shift vector for this list */
1288 i_shift_offset = DIM*shiftidx[iidx];
1290 /* Load limits for loop over neighbors */
1291 j_index_start = jindex[iidx];
1292 j_index_end = jindex[iidx+1];
1294 /* Get outer coordinate index */
1296 i_coord_offset = DIM*inr;
1298 /* Load i particle coords and add shift vector */
1299 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1300 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1302 fix0 = _mm256_setzero_ps();
1303 fiy0 = _mm256_setzero_ps();
1304 fiz0 = _mm256_setzero_ps();
1305 fix1 = _mm256_setzero_ps();
1306 fiy1 = _mm256_setzero_ps();
1307 fiz1 = _mm256_setzero_ps();
1308 fix2 = _mm256_setzero_ps();
1309 fiy2 = _mm256_setzero_ps();
1310 fiz2 = _mm256_setzero_ps();
1312 /* Start inner kernel loop */
1313 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1316 /* Get j neighbor index, and coordinate index */
1318 jnrB = jjnr[jidx+1];
1319 jnrC = jjnr[jidx+2];
1320 jnrD = jjnr[jidx+3];
1321 jnrE = jjnr[jidx+4];
1322 jnrF = jjnr[jidx+5];
1323 jnrG = jjnr[jidx+6];
1324 jnrH = jjnr[jidx+7];
1325 j_coord_offsetA = DIM*jnrA;
1326 j_coord_offsetB = DIM*jnrB;
1327 j_coord_offsetC = DIM*jnrC;
1328 j_coord_offsetD = DIM*jnrD;
1329 j_coord_offsetE = DIM*jnrE;
1330 j_coord_offsetF = DIM*jnrF;
1331 j_coord_offsetG = DIM*jnrG;
1332 j_coord_offsetH = DIM*jnrH;
1334 /* load j atom coordinates */
1335 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1336 x+j_coord_offsetC,x+j_coord_offsetD,
1337 x+j_coord_offsetE,x+j_coord_offsetF,
1338 x+j_coord_offsetG,x+j_coord_offsetH,
1339 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1341 /* Calculate displacement vector */
1342 dx00 = _mm256_sub_ps(ix0,jx0);
1343 dy00 = _mm256_sub_ps(iy0,jy0);
1344 dz00 = _mm256_sub_ps(iz0,jz0);
1345 dx01 = _mm256_sub_ps(ix0,jx1);
1346 dy01 = _mm256_sub_ps(iy0,jy1);
1347 dz01 = _mm256_sub_ps(iz0,jz1);
1348 dx02 = _mm256_sub_ps(ix0,jx2);
1349 dy02 = _mm256_sub_ps(iy0,jy2);
1350 dz02 = _mm256_sub_ps(iz0,jz2);
1351 dx10 = _mm256_sub_ps(ix1,jx0);
1352 dy10 = _mm256_sub_ps(iy1,jy0);
1353 dz10 = _mm256_sub_ps(iz1,jz0);
1354 dx11 = _mm256_sub_ps(ix1,jx1);
1355 dy11 = _mm256_sub_ps(iy1,jy1);
1356 dz11 = _mm256_sub_ps(iz1,jz1);
1357 dx12 = _mm256_sub_ps(ix1,jx2);
1358 dy12 = _mm256_sub_ps(iy1,jy2);
1359 dz12 = _mm256_sub_ps(iz1,jz2);
1360 dx20 = _mm256_sub_ps(ix2,jx0);
1361 dy20 = _mm256_sub_ps(iy2,jy0);
1362 dz20 = _mm256_sub_ps(iz2,jz0);
1363 dx21 = _mm256_sub_ps(ix2,jx1);
1364 dy21 = _mm256_sub_ps(iy2,jy1);
1365 dz21 = _mm256_sub_ps(iz2,jz1);
1366 dx22 = _mm256_sub_ps(ix2,jx2);
1367 dy22 = _mm256_sub_ps(iy2,jy2);
1368 dz22 = _mm256_sub_ps(iz2,jz2);
1370 /* Calculate squared distance and things based on it */
1371 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1372 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1373 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1374 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1375 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1376 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1377 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1378 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1379 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1381 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1382 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1383 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1384 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1385 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1386 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1387 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1388 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1389 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1391 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1392 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1393 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1394 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1395 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1396 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1397 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1398 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1399 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1401 fjx0 = _mm256_setzero_ps();
1402 fjy0 = _mm256_setzero_ps();
1403 fjz0 = _mm256_setzero_ps();
1404 fjx1 = _mm256_setzero_ps();
1405 fjy1 = _mm256_setzero_ps();
1406 fjz1 = _mm256_setzero_ps();
1407 fjx2 = _mm256_setzero_ps();
1408 fjy2 = _mm256_setzero_ps();
1409 fjz2 = _mm256_setzero_ps();
1411 /**************************
1412 * CALCULATE INTERACTIONS *
1413 **************************/
1415 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1418 /* REACTION-FIELD ELECTROSTATICS */
1419 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1421 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1425 fscal = _mm256_and_ps(fscal,cutoff_mask);
1427 /* Calculate temporary vectorial force */
1428 tx = _mm256_mul_ps(fscal,dx00);
1429 ty = _mm256_mul_ps(fscal,dy00);
1430 tz = _mm256_mul_ps(fscal,dz00);
1432 /* Update vectorial force */
1433 fix0 = _mm256_add_ps(fix0,tx);
1434 fiy0 = _mm256_add_ps(fiy0,ty);
1435 fiz0 = _mm256_add_ps(fiz0,tz);
1437 fjx0 = _mm256_add_ps(fjx0,tx);
1438 fjy0 = _mm256_add_ps(fjy0,ty);
1439 fjz0 = _mm256_add_ps(fjz0,tz);
1443 /**************************
1444 * CALCULATE INTERACTIONS *
1445 **************************/
1447 if (gmx_mm256_any_lt(rsq01,rcutoff2))
1450 /* REACTION-FIELD ELECTROSTATICS */
1451 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1453 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
1457 fscal = _mm256_and_ps(fscal,cutoff_mask);
1459 /* Calculate temporary vectorial force */
1460 tx = _mm256_mul_ps(fscal,dx01);
1461 ty = _mm256_mul_ps(fscal,dy01);
1462 tz = _mm256_mul_ps(fscal,dz01);
1464 /* Update vectorial force */
1465 fix0 = _mm256_add_ps(fix0,tx);
1466 fiy0 = _mm256_add_ps(fiy0,ty);
1467 fiz0 = _mm256_add_ps(fiz0,tz);
1469 fjx1 = _mm256_add_ps(fjx1,tx);
1470 fjy1 = _mm256_add_ps(fjy1,ty);
1471 fjz1 = _mm256_add_ps(fjz1,tz);
1475 /**************************
1476 * CALCULATE INTERACTIONS *
1477 **************************/
1479 if (gmx_mm256_any_lt(rsq02,rcutoff2))
1482 /* REACTION-FIELD ELECTROSTATICS */
1483 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1485 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
1489 fscal = _mm256_and_ps(fscal,cutoff_mask);
1491 /* Calculate temporary vectorial force */
1492 tx = _mm256_mul_ps(fscal,dx02);
1493 ty = _mm256_mul_ps(fscal,dy02);
1494 tz = _mm256_mul_ps(fscal,dz02);
1496 /* Update vectorial force */
1497 fix0 = _mm256_add_ps(fix0,tx);
1498 fiy0 = _mm256_add_ps(fiy0,ty);
1499 fiz0 = _mm256_add_ps(fiz0,tz);
1501 fjx2 = _mm256_add_ps(fjx2,tx);
1502 fjy2 = _mm256_add_ps(fjy2,ty);
1503 fjz2 = _mm256_add_ps(fjz2,tz);
1507 /**************************
1508 * CALCULATE INTERACTIONS *
1509 **************************/
1511 if (gmx_mm256_any_lt(rsq10,rcutoff2))
1514 /* REACTION-FIELD ELECTROSTATICS */
1515 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1517 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
1521 fscal = _mm256_and_ps(fscal,cutoff_mask);
1523 /* Calculate temporary vectorial force */
1524 tx = _mm256_mul_ps(fscal,dx10);
1525 ty = _mm256_mul_ps(fscal,dy10);
1526 tz = _mm256_mul_ps(fscal,dz10);
1528 /* Update vectorial force */
1529 fix1 = _mm256_add_ps(fix1,tx);
1530 fiy1 = _mm256_add_ps(fiy1,ty);
1531 fiz1 = _mm256_add_ps(fiz1,tz);
1533 fjx0 = _mm256_add_ps(fjx0,tx);
1534 fjy0 = _mm256_add_ps(fjy0,ty);
1535 fjz0 = _mm256_add_ps(fjz0,tz);
1539 /**************************
1540 * CALCULATE INTERACTIONS *
1541 **************************/
1543 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1546 /* REACTION-FIELD ELECTROSTATICS */
1547 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1549 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1553 fscal = _mm256_and_ps(fscal,cutoff_mask);
1555 /* Calculate temporary vectorial force */
1556 tx = _mm256_mul_ps(fscal,dx11);
1557 ty = _mm256_mul_ps(fscal,dy11);
1558 tz = _mm256_mul_ps(fscal,dz11);
1560 /* Update vectorial force */
1561 fix1 = _mm256_add_ps(fix1,tx);
1562 fiy1 = _mm256_add_ps(fiy1,ty);
1563 fiz1 = _mm256_add_ps(fiz1,tz);
1565 fjx1 = _mm256_add_ps(fjx1,tx);
1566 fjy1 = _mm256_add_ps(fjy1,ty);
1567 fjz1 = _mm256_add_ps(fjz1,tz);
1571 /**************************
1572 * CALCULATE INTERACTIONS *
1573 **************************/
1575 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1578 /* REACTION-FIELD ELECTROSTATICS */
1579 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1581 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1585 fscal = _mm256_and_ps(fscal,cutoff_mask);
1587 /* Calculate temporary vectorial force */
1588 tx = _mm256_mul_ps(fscal,dx12);
1589 ty = _mm256_mul_ps(fscal,dy12);
1590 tz = _mm256_mul_ps(fscal,dz12);
1592 /* Update vectorial force */
1593 fix1 = _mm256_add_ps(fix1,tx);
1594 fiy1 = _mm256_add_ps(fiy1,ty);
1595 fiz1 = _mm256_add_ps(fiz1,tz);
1597 fjx2 = _mm256_add_ps(fjx2,tx);
1598 fjy2 = _mm256_add_ps(fjy2,ty);
1599 fjz2 = _mm256_add_ps(fjz2,tz);
1603 /**************************
1604 * CALCULATE INTERACTIONS *
1605 **************************/
1607 if (gmx_mm256_any_lt(rsq20,rcutoff2))
1610 /* REACTION-FIELD ELECTROSTATICS */
1611 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1613 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
1617 fscal = _mm256_and_ps(fscal,cutoff_mask);
1619 /* Calculate temporary vectorial force */
1620 tx = _mm256_mul_ps(fscal,dx20);
1621 ty = _mm256_mul_ps(fscal,dy20);
1622 tz = _mm256_mul_ps(fscal,dz20);
1624 /* Update vectorial force */
1625 fix2 = _mm256_add_ps(fix2,tx);
1626 fiy2 = _mm256_add_ps(fiy2,ty);
1627 fiz2 = _mm256_add_ps(fiz2,tz);
1629 fjx0 = _mm256_add_ps(fjx0,tx);
1630 fjy0 = _mm256_add_ps(fjy0,ty);
1631 fjz0 = _mm256_add_ps(fjz0,tz);
1635 /**************************
1636 * CALCULATE INTERACTIONS *
1637 **************************/
1639 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1642 /* REACTION-FIELD ELECTROSTATICS */
1643 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1645 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1649 fscal = _mm256_and_ps(fscal,cutoff_mask);
1651 /* Calculate temporary vectorial force */
1652 tx = _mm256_mul_ps(fscal,dx21);
1653 ty = _mm256_mul_ps(fscal,dy21);
1654 tz = _mm256_mul_ps(fscal,dz21);
1656 /* Update vectorial force */
1657 fix2 = _mm256_add_ps(fix2,tx);
1658 fiy2 = _mm256_add_ps(fiy2,ty);
1659 fiz2 = _mm256_add_ps(fiz2,tz);
1661 fjx1 = _mm256_add_ps(fjx1,tx);
1662 fjy1 = _mm256_add_ps(fjy1,ty);
1663 fjz1 = _mm256_add_ps(fjz1,tz);
1667 /**************************
1668 * CALCULATE INTERACTIONS *
1669 **************************/
1671 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1674 /* REACTION-FIELD ELECTROSTATICS */
1675 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1677 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1681 fscal = _mm256_and_ps(fscal,cutoff_mask);
1683 /* Calculate temporary vectorial force */
1684 tx = _mm256_mul_ps(fscal,dx22);
1685 ty = _mm256_mul_ps(fscal,dy22);
1686 tz = _mm256_mul_ps(fscal,dz22);
1688 /* Update vectorial force */
1689 fix2 = _mm256_add_ps(fix2,tx);
1690 fiy2 = _mm256_add_ps(fiy2,ty);
1691 fiz2 = _mm256_add_ps(fiz2,tz);
1693 fjx2 = _mm256_add_ps(fjx2,tx);
1694 fjy2 = _mm256_add_ps(fjy2,ty);
1695 fjz2 = _mm256_add_ps(fjz2,tz);
1699 fjptrA = f+j_coord_offsetA;
1700 fjptrB = f+j_coord_offsetB;
1701 fjptrC = f+j_coord_offsetC;
1702 fjptrD = f+j_coord_offsetD;
1703 fjptrE = f+j_coord_offsetE;
1704 fjptrF = f+j_coord_offsetF;
1705 fjptrG = f+j_coord_offsetG;
1706 fjptrH = f+j_coord_offsetH;
1708 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1709 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1711 /* Inner loop uses 270 flops */
1714 if(jidx<j_index_end)
1717 /* Get j neighbor index, and coordinate index */
1718 jnrlistA = jjnr[jidx];
1719 jnrlistB = jjnr[jidx+1];
1720 jnrlistC = jjnr[jidx+2];
1721 jnrlistD = jjnr[jidx+3];
1722 jnrlistE = jjnr[jidx+4];
1723 jnrlistF = jjnr[jidx+5];
1724 jnrlistG = jjnr[jidx+6];
1725 jnrlistH = jjnr[jidx+7];
1726 /* Sign of each element will be negative for non-real atoms.
1727 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1728 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1730 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1731 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1733 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1734 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1735 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1736 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1737 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1738 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1739 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1740 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1741 j_coord_offsetA = DIM*jnrA;
1742 j_coord_offsetB = DIM*jnrB;
1743 j_coord_offsetC = DIM*jnrC;
1744 j_coord_offsetD = DIM*jnrD;
1745 j_coord_offsetE = DIM*jnrE;
1746 j_coord_offsetF = DIM*jnrF;
1747 j_coord_offsetG = DIM*jnrG;
1748 j_coord_offsetH = DIM*jnrH;
1750 /* load j atom coordinates */
1751 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1752 x+j_coord_offsetC,x+j_coord_offsetD,
1753 x+j_coord_offsetE,x+j_coord_offsetF,
1754 x+j_coord_offsetG,x+j_coord_offsetH,
1755 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1757 /* Calculate displacement vector */
1758 dx00 = _mm256_sub_ps(ix0,jx0);
1759 dy00 = _mm256_sub_ps(iy0,jy0);
1760 dz00 = _mm256_sub_ps(iz0,jz0);
1761 dx01 = _mm256_sub_ps(ix0,jx1);
1762 dy01 = _mm256_sub_ps(iy0,jy1);
1763 dz01 = _mm256_sub_ps(iz0,jz1);
1764 dx02 = _mm256_sub_ps(ix0,jx2);
1765 dy02 = _mm256_sub_ps(iy0,jy2);
1766 dz02 = _mm256_sub_ps(iz0,jz2);
1767 dx10 = _mm256_sub_ps(ix1,jx0);
1768 dy10 = _mm256_sub_ps(iy1,jy0);
1769 dz10 = _mm256_sub_ps(iz1,jz0);
1770 dx11 = _mm256_sub_ps(ix1,jx1);
1771 dy11 = _mm256_sub_ps(iy1,jy1);
1772 dz11 = _mm256_sub_ps(iz1,jz1);
1773 dx12 = _mm256_sub_ps(ix1,jx2);
1774 dy12 = _mm256_sub_ps(iy1,jy2);
1775 dz12 = _mm256_sub_ps(iz1,jz2);
1776 dx20 = _mm256_sub_ps(ix2,jx0);
1777 dy20 = _mm256_sub_ps(iy2,jy0);
1778 dz20 = _mm256_sub_ps(iz2,jz0);
1779 dx21 = _mm256_sub_ps(ix2,jx1);
1780 dy21 = _mm256_sub_ps(iy2,jy1);
1781 dz21 = _mm256_sub_ps(iz2,jz1);
1782 dx22 = _mm256_sub_ps(ix2,jx2);
1783 dy22 = _mm256_sub_ps(iy2,jy2);
1784 dz22 = _mm256_sub_ps(iz2,jz2);
1786 /* Calculate squared distance and things based on it */
1787 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1788 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1789 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1790 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1791 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1792 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1793 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1794 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1795 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1797 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1798 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1799 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1800 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1801 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1802 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1803 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1804 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1805 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1807 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1808 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1809 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1810 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1811 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1812 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1813 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1814 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1815 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1817 fjx0 = _mm256_setzero_ps();
1818 fjy0 = _mm256_setzero_ps();
1819 fjz0 = _mm256_setzero_ps();
1820 fjx1 = _mm256_setzero_ps();
1821 fjy1 = _mm256_setzero_ps();
1822 fjz1 = _mm256_setzero_ps();
1823 fjx2 = _mm256_setzero_ps();
1824 fjy2 = _mm256_setzero_ps();
1825 fjz2 = _mm256_setzero_ps();
1827 /**************************
1828 * CALCULATE INTERACTIONS *
1829 **************************/
1831 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1834 /* REACTION-FIELD ELECTROSTATICS */
1835 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1837 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1841 fscal = _mm256_and_ps(fscal,cutoff_mask);
1843 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1845 /* Calculate temporary vectorial force */
1846 tx = _mm256_mul_ps(fscal,dx00);
1847 ty = _mm256_mul_ps(fscal,dy00);
1848 tz = _mm256_mul_ps(fscal,dz00);
1850 /* Update vectorial force */
1851 fix0 = _mm256_add_ps(fix0,tx);
1852 fiy0 = _mm256_add_ps(fiy0,ty);
1853 fiz0 = _mm256_add_ps(fiz0,tz);
1855 fjx0 = _mm256_add_ps(fjx0,tx);
1856 fjy0 = _mm256_add_ps(fjy0,ty);
1857 fjz0 = _mm256_add_ps(fjz0,tz);
1861 /**************************
1862 * CALCULATE INTERACTIONS *
1863 **************************/
1865 if (gmx_mm256_any_lt(rsq01,rcutoff2))
1868 /* REACTION-FIELD ELECTROSTATICS */
1869 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1871 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
1875 fscal = _mm256_and_ps(fscal,cutoff_mask);
1877 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1879 /* Calculate temporary vectorial force */
1880 tx = _mm256_mul_ps(fscal,dx01);
1881 ty = _mm256_mul_ps(fscal,dy01);
1882 tz = _mm256_mul_ps(fscal,dz01);
1884 /* Update vectorial force */
1885 fix0 = _mm256_add_ps(fix0,tx);
1886 fiy0 = _mm256_add_ps(fiy0,ty);
1887 fiz0 = _mm256_add_ps(fiz0,tz);
1889 fjx1 = _mm256_add_ps(fjx1,tx);
1890 fjy1 = _mm256_add_ps(fjy1,ty);
1891 fjz1 = _mm256_add_ps(fjz1,tz);
1895 /**************************
1896 * CALCULATE INTERACTIONS *
1897 **************************/
1899 if (gmx_mm256_any_lt(rsq02,rcutoff2))
1902 /* REACTION-FIELD ELECTROSTATICS */
1903 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1905 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
1909 fscal = _mm256_and_ps(fscal,cutoff_mask);
1911 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1913 /* Calculate temporary vectorial force */
1914 tx = _mm256_mul_ps(fscal,dx02);
1915 ty = _mm256_mul_ps(fscal,dy02);
1916 tz = _mm256_mul_ps(fscal,dz02);
1918 /* Update vectorial force */
1919 fix0 = _mm256_add_ps(fix0,tx);
1920 fiy0 = _mm256_add_ps(fiy0,ty);
1921 fiz0 = _mm256_add_ps(fiz0,tz);
1923 fjx2 = _mm256_add_ps(fjx2,tx);
1924 fjy2 = _mm256_add_ps(fjy2,ty);
1925 fjz2 = _mm256_add_ps(fjz2,tz);
1929 /**************************
1930 * CALCULATE INTERACTIONS *
1931 **************************/
1933 if (gmx_mm256_any_lt(rsq10,rcutoff2))
1936 /* REACTION-FIELD ELECTROSTATICS */
1937 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1939 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
1943 fscal = _mm256_and_ps(fscal,cutoff_mask);
1945 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1947 /* Calculate temporary vectorial force */
1948 tx = _mm256_mul_ps(fscal,dx10);
1949 ty = _mm256_mul_ps(fscal,dy10);
1950 tz = _mm256_mul_ps(fscal,dz10);
1952 /* Update vectorial force */
1953 fix1 = _mm256_add_ps(fix1,tx);
1954 fiy1 = _mm256_add_ps(fiy1,ty);
1955 fiz1 = _mm256_add_ps(fiz1,tz);
1957 fjx0 = _mm256_add_ps(fjx0,tx);
1958 fjy0 = _mm256_add_ps(fjy0,ty);
1959 fjz0 = _mm256_add_ps(fjz0,tz);
1963 /**************************
1964 * CALCULATE INTERACTIONS *
1965 **************************/
1967 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1970 /* REACTION-FIELD ELECTROSTATICS */
1971 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1973 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1977 fscal = _mm256_and_ps(fscal,cutoff_mask);
1979 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1981 /* Calculate temporary vectorial force */
1982 tx = _mm256_mul_ps(fscal,dx11);
1983 ty = _mm256_mul_ps(fscal,dy11);
1984 tz = _mm256_mul_ps(fscal,dz11);
1986 /* Update vectorial force */
1987 fix1 = _mm256_add_ps(fix1,tx);
1988 fiy1 = _mm256_add_ps(fiy1,ty);
1989 fiz1 = _mm256_add_ps(fiz1,tz);
1991 fjx1 = _mm256_add_ps(fjx1,tx);
1992 fjy1 = _mm256_add_ps(fjy1,ty);
1993 fjz1 = _mm256_add_ps(fjz1,tz);
1997 /**************************
1998 * CALCULATE INTERACTIONS *
1999 **************************/
2001 if (gmx_mm256_any_lt(rsq12,rcutoff2))
2004 /* REACTION-FIELD ELECTROSTATICS */
2005 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
2007 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
2011 fscal = _mm256_and_ps(fscal,cutoff_mask);
2013 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2015 /* Calculate temporary vectorial force */
2016 tx = _mm256_mul_ps(fscal,dx12);
2017 ty = _mm256_mul_ps(fscal,dy12);
2018 tz = _mm256_mul_ps(fscal,dz12);
2020 /* Update vectorial force */
2021 fix1 = _mm256_add_ps(fix1,tx);
2022 fiy1 = _mm256_add_ps(fiy1,ty);
2023 fiz1 = _mm256_add_ps(fiz1,tz);
2025 fjx2 = _mm256_add_ps(fjx2,tx);
2026 fjy2 = _mm256_add_ps(fjy2,ty);
2027 fjz2 = _mm256_add_ps(fjz2,tz);
2031 /**************************
2032 * CALCULATE INTERACTIONS *
2033 **************************/
2035 if (gmx_mm256_any_lt(rsq20,rcutoff2))
2038 /* REACTION-FIELD ELECTROSTATICS */
2039 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
2041 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
2045 fscal = _mm256_and_ps(fscal,cutoff_mask);
2047 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2049 /* Calculate temporary vectorial force */
2050 tx = _mm256_mul_ps(fscal,dx20);
2051 ty = _mm256_mul_ps(fscal,dy20);
2052 tz = _mm256_mul_ps(fscal,dz20);
2054 /* Update vectorial force */
2055 fix2 = _mm256_add_ps(fix2,tx);
2056 fiy2 = _mm256_add_ps(fiy2,ty);
2057 fiz2 = _mm256_add_ps(fiz2,tz);
2059 fjx0 = _mm256_add_ps(fjx0,tx);
2060 fjy0 = _mm256_add_ps(fjy0,ty);
2061 fjz0 = _mm256_add_ps(fjz0,tz);
2065 /**************************
2066 * CALCULATE INTERACTIONS *
2067 **************************/
2069 if (gmx_mm256_any_lt(rsq21,rcutoff2))
2072 /* REACTION-FIELD ELECTROSTATICS */
2073 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
2075 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
2079 fscal = _mm256_and_ps(fscal,cutoff_mask);
2081 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2083 /* Calculate temporary vectorial force */
2084 tx = _mm256_mul_ps(fscal,dx21);
2085 ty = _mm256_mul_ps(fscal,dy21);
2086 tz = _mm256_mul_ps(fscal,dz21);
2088 /* Update vectorial force */
2089 fix2 = _mm256_add_ps(fix2,tx);
2090 fiy2 = _mm256_add_ps(fiy2,ty);
2091 fiz2 = _mm256_add_ps(fiz2,tz);
2093 fjx1 = _mm256_add_ps(fjx1,tx);
2094 fjy1 = _mm256_add_ps(fjy1,ty);
2095 fjz1 = _mm256_add_ps(fjz1,tz);
2099 /**************************
2100 * CALCULATE INTERACTIONS *
2101 **************************/
2103 if (gmx_mm256_any_lt(rsq22,rcutoff2))
2106 /* REACTION-FIELD ELECTROSTATICS */
2107 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2109 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
2113 fscal = _mm256_and_ps(fscal,cutoff_mask);
2115 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2117 /* Calculate temporary vectorial force */
2118 tx = _mm256_mul_ps(fscal,dx22);
2119 ty = _mm256_mul_ps(fscal,dy22);
2120 tz = _mm256_mul_ps(fscal,dz22);
2122 /* Update vectorial force */
2123 fix2 = _mm256_add_ps(fix2,tx);
2124 fiy2 = _mm256_add_ps(fiy2,ty);
2125 fiz2 = _mm256_add_ps(fiz2,tz);
2127 fjx2 = _mm256_add_ps(fjx2,tx);
2128 fjy2 = _mm256_add_ps(fjy2,ty);
2129 fjz2 = _mm256_add_ps(fjz2,tz);
2133 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2134 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2135 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2136 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2137 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2138 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2139 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2140 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2142 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2143 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2145 /* Inner loop uses 270 flops */
2148 /* End of innermost loop */
2150 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2151 f+i_coord_offset,fshift+i_shift_offset);
2153 /* Increment number of inner iterations */
2154 inneriter += j_index_end - j_index_start;
2156 /* Outer loop uses 18 flops */
2159 /* Increment number of outer iterations */
2162 /* Update outer/inner flops */
2164 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*270);