2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS avx_256_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gromacs/simd/math_x86_avx_256_single.h"
50 #include "kernelutil_x86_avx_256_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3W3_VF_avx_256_single
54 * Electrostatics interaction: ReactionField
55 * VdW interaction: None
56 * Geometry: Water3-Water3
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecRFCut_VdwNone_GeomW3W3_VF_avx_256_single
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrE,jnrF,jnrG,jnrH;
78 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
79 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
80 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
81 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
82 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
84 real *shiftvec,*fshift,*x,*f;
85 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
87 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
88 real * vdwioffsetptr0;
89 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
90 real * vdwioffsetptr1;
91 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
92 real * vdwioffsetptr2;
93 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
94 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
95 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
96 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
97 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
98 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
99 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
100 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
101 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
102 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
103 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
104 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
105 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
106 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
107 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
108 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
109 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
111 __m256 dummy_mask,cutoff_mask;
112 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
113 __m256 one = _mm256_set1_ps(1.0);
114 __m256 two = _mm256_set1_ps(2.0);
120 jindex = nlist->jindex;
122 shiftidx = nlist->shift;
124 shiftvec = fr->shift_vec[0];
125 fshift = fr->fshift[0];
126 facel = _mm256_set1_ps(fr->epsfac);
127 charge = mdatoms->chargeA;
128 krf = _mm256_set1_ps(fr->ic->k_rf);
129 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
130 crf = _mm256_set1_ps(fr->ic->c_rf);
132 /* Setup water-specific parameters */
133 inr = nlist->iinr[0];
134 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
135 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
136 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
138 jq0 = _mm256_set1_ps(charge[inr+0]);
139 jq1 = _mm256_set1_ps(charge[inr+1]);
140 jq2 = _mm256_set1_ps(charge[inr+2]);
141 qq00 = _mm256_mul_ps(iq0,jq0);
142 qq01 = _mm256_mul_ps(iq0,jq1);
143 qq02 = _mm256_mul_ps(iq0,jq2);
144 qq10 = _mm256_mul_ps(iq1,jq0);
145 qq11 = _mm256_mul_ps(iq1,jq1);
146 qq12 = _mm256_mul_ps(iq1,jq2);
147 qq20 = _mm256_mul_ps(iq2,jq0);
148 qq21 = _mm256_mul_ps(iq2,jq1);
149 qq22 = _mm256_mul_ps(iq2,jq2);
151 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
152 rcutoff_scalar = fr->rcoulomb;
153 rcutoff = _mm256_set1_ps(rcutoff_scalar);
154 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
156 /* Avoid stupid compiler warnings */
157 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
170 for(iidx=0;iidx<4*DIM;iidx++)
175 /* Start outer loop over neighborlists */
176 for(iidx=0; iidx<nri; iidx++)
178 /* Load shift vector for this list */
179 i_shift_offset = DIM*shiftidx[iidx];
181 /* Load limits for loop over neighbors */
182 j_index_start = jindex[iidx];
183 j_index_end = jindex[iidx+1];
185 /* Get outer coordinate index */
187 i_coord_offset = DIM*inr;
189 /* Load i particle coords and add shift vector */
190 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
191 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
193 fix0 = _mm256_setzero_ps();
194 fiy0 = _mm256_setzero_ps();
195 fiz0 = _mm256_setzero_ps();
196 fix1 = _mm256_setzero_ps();
197 fiy1 = _mm256_setzero_ps();
198 fiz1 = _mm256_setzero_ps();
199 fix2 = _mm256_setzero_ps();
200 fiy2 = _mm256_setzero_ps();
201 fiz2 = _mm256_setzero_ps();
203 /* Reset potential sums */
204 velecsum = _mm256_setzero_ps();
206 /* Start inner kernel loop */
207 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
210 /* Get j neighbor index, and coordinate index */
219 j_coord_offsetA = DIM*jnrA;
220 j_coord_offsetB = DIM*jnrB;
221 j_coord_offsetC = DIM*jnrC;
222 j_coord_offsetD = DIM*jnrD;
223 j_coord_offsetE = DIM*jnrE;
224 j_coord_offsetF = DIM*jnrF;
225 j_coord_offsetG = DIM*jnrG;
226 j_coord_offsetH = DIM*jnrH;
228 /* load j atom coordinates */
229 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
230 x+j_coord_offsetC,x+j_coord_offsetD,
231 x+j_coord_offsetE,x+j_coord_offsetF,
232 x+j_coord_offsetG,x+j_coord_offsetH,
233 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
235 /* Calculate displacement vector */
236 dx00 = _mm256_sub_ps(ix0,jx0);
237 dy00 = _mm256_sub_ps(iy0,jy0);
238 dz00 = _mm256_sub_ps(iz0,jz0);
239 dx01 = _mm256_sub_ps(ix0,jx1);
240 dy01 = _mm256_sub_ps(iy0,jy1);
241 dz01 = _mm256_sub_ps(iz0,jz1);
242 dx02 = _mm256_sub_ps(ix0,jx2);
243 dy02 = _mm256_sub_ps(iy0,jy2);
244 dz02 = _mm256_sub_ps(iz0,jz2);
245 dx10 = _mm256_sub_ps(ix1,jx0);
246 dy10 = _mm256_sub_ps(iy1,jy0);
247 dz10 = _mm256_sub_ps(iz1,jz0);
248 dx11 = _mm256_sub_ps(ix1,jx1);
249 dy11 = _mm256_sub_ps(iy1,jy1);
250 dz11 = _mm256_sub_ps(iz1,jz1);
251 dx12 = _mm256_sub_ps(ix1,jx2);
252 dy12 = _mm256_sub_ps(iy1,jy2);
253 dz12 = _mm256_sub_ps(iz1,jz2);
254 dx20 = _mm256_sub_ps(ix2,jx0);
255 dy20 = _mm256_sub_ps(iy2,jy0);
256 dz20 = _mm256_sub_ps(iz2,jz0);
257 dx21 = _mm256_sub_ps(ix2,jx1);
258 dy21 = _mm256_sub_ps(iy2,jy1);
259 dz21 = _mm256_sub_ps(iz2,jz1);
260 dx22 = _mm256_sub_ps(ix2,jx2);
261 dy22 = _mm256_sub_ps(iy2,jy2);
262 dz22 = _mm256_sub_ps(iz2,jz2);
264 /* Calculate squared distance and things based on it */
265 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
266 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
267 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
268 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
269 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
270 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
271 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
272 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
273 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
275 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
276 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
277 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
278 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
279 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
280 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
281 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
282 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
283 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
285 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
286 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
287 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
288 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
289 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
290 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
291 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
292 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
293 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
295 fjx0 = _mm256_setzero_ps();
296 fjy0 = _mm256_setzero_ps();
297 fjz0 = _mm256_setzero_ps();
298 fjx1 = _mm256_setzero_ps();
299 fjy1 = _mm256_setzero_ps();
300 fjz1 = _mm256_setzero_ps();
301 fjx2 = _mm256_setzero_ps();
302 fjy2 = _mm256_setzero_ps();
303 fjz2 = _mm256_setzero_ps();
305 /**************************
306 * CALCULATE INTERACTIONS *
307 **************************/
309 if (gmx_mm256_any_lt(rsq00,rcutoff2))
312 /* REACTION-FIELD ELECTROSTATICS */
313 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
314 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
316 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 velec = _mm256_and_ps(velec,cutoff_mask);
320 velecsum = _mm256_add_ps(velecsum,velec);
324 fscal = _mm256_and_ps(fscal,cutoff_mask);
326 /* Calculate temporary vectorial force */
327 tx = _mm256_mul_ps(fscal,dx00);
328 ty = _mm256_mul_ps(fscal,dy00);
329 tz = _mm256_mul_ps(fscal,dz00);
331 /* Update vectorial force */
332 fix0 = _mm256_add_ps(fix0,tx);
333 fiy0 = _mm256_add_ps(fiy0,ty);
334 fiz0 = _mm256_add_ps(fiz0,tz);
336 fjx0 = _mm256_add_ps(fjx0,tx);
337 fjy0 = _mm256_add_ps(fjy0,ty);
338 fjz0 = _mm256_add_ps(fjz0,tz);
342 /**************************
343 * CALCULATE INTERACTIONS *
344 **************************/
346 if (gmx_mm256_any_lt(rsq01,rcutoff2))
349 /* REACTION-FIELD ELECTROSTATICS */
350 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
351 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
353 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velec = _mm256_and_ps(velec,cutoff_mask);
357 velecsum = _mm256_add_ps(velecsum,velec);
361 fscal = _mm256_and_ps(fscal,cutoff_mask);
363 /* Calculate temporary vectorial force */
364 tx = _mm256_mul_ps(fscal,dx01);
365 ty = _mm256_mul_ps(fscal,dy01);
366 tz = _mm256_mul_ps(fscal,dz01);
368 /* Update vectorial force */
369 fix0 = _mm256_add_ps(fix0,tx);
370 fiy0 = _mm256_add_ps(fiy0,ty);
371 fiz0 = _mm256_add_ps(fiz0,tz);
373 fjx1 = _mm256_add_ps(fjx1,tx);
374 fjy1 = _mm256_add_ps(fjy1,ty);
375 fjz1 = _mm256_add_ps(fjz1,tz);
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
383 if (gmx_mm256_any_lt(rsq02,rcutoff2))
386 /* REACTION-FIELD ELECTROSTATICS */
387 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
388 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
390 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
392 /* Update potential sum for this i atom from the interaction with this j atom. */
393 velec = _mm256_and_ps(velec,cutoff_mask);
394 velecsum = _mm256_add_ps(velecsum,velec);
398 fscal = _mm256_and_ps(fscal,cutoff_mask);
400 /* Calculate temporary vectorial force */
401 tx = _mm256_mul_ps(fscal,dx02);
402 ty = _mm256_mul_ps(fscal,dy02);
403 tz = _mm256_mul_ps(fscal,dz02);
405 /* Update vectorial force */
406 fix0 = _mm256_add_ps(fix0,tx);
407 fiy0 = _mm256_add_ps(fiy0,ty);
408 fiz0 = _mm256_add_ps(fiz0,tz);
410 fjx2 = _mm256_add_ps(fjx2,tx);
411 fjy2 = _mm256_add_ps(fjy2,ty);
412 fjz2 = _mm256_add_ps(fjz2,tz);
416 /**************************
417 * CALCULATE INTERACTIONS *
418 **************************/
420 if (gmx_mm256_any_lt(rsq10,rcutoff2))
423 /* REACTION-FIELD ELECTROSTATICS */
424 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
425 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
427 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
429 /* Update potential sum for this i atom from the interaction with this j atom. */
430 velec = _mm256_and_ps(velec,cutoff_mask);
431 velecsum = _mm256_add_ps(velecsum,velec);
435 fscal = _mm256_and_ps(fscal,cutoff_mask);
437 /* Calculate temporary vectorial force */
438 tx = _mm256_mul_ps(fscal,dx10);
439 ty = _mm256_mul_ps(fscal,dy10);
440 tz = _mm256_mul_ps(fscal,dz10);
442 /* Update vectorial force */
443 fix1 = _mm256_add_ps(fix1,tx);
444 fiy1 = _mm256_add_ps(fiy1,ty);
445 fiz1 = _mm256_add_ps(fiz1,tz);
447 fjx0 = _mm256_add_ps(fjx0,tx);
448 fjy0 = _mm256_add_ps(fjy0,ty);
449 fjz0 = _mm256_add_ps(fjz0,tz);
453 /**************************
454 * CALCULATE INTERACTIONS *
455 **************************/
457 if (gmx_mm256_any_lt(rsq11,rcutoff2))
460 /* REACTION-FIELD ELECTROSTATICS */
461 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
462 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
464 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
466 /* Update potential sum for this i atom from the interaction with this j atom. */
467 velec = _mm256_and_ps(velec,cutoff_mask);
468 velecsum = _mm256_add_ps(velecsum,velec);
472 fscal = _mm256_and_ps(fscal,cutoff_mask);
474 /* Calculate temporary vectorial force */
475 tx = _mm256_mul_ps(fscal,dx11);
476 ty = _mm256_mul_ps(fscal,dy11);
477 tz = _mm256_mul_ps(fscal,dz11);
479 /* Update vectorial force */
480 fix1 = _mm256_add_ps(fix1,tx);
481 fiy1 = _mm256_add_ps(fiy1,ty);
482 fiz1 = _mm256_add_ps(fiz1,tz);
484 fjx1 = _mm256_add_ps(fjx1,tx);
485 fjy1 = _mm256_add_ps(fjy1,ty);
486 fjz1 = _mm256_add_ps(fjz1,tz);
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
494 if (gmx_mm256_any_lt(rsq12,rcutoff2))
497 /* REACTION-FIELD ELECTROSTATICS */
498 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
499 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
501 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
503 /* Update potential sum for this i atom from the interaction with this j atom. */
504 velec = _mm256_and_ps(velec,cutoff_mask);
505 velecsum = _mm256_add_ps(velecsum,velec);
509 fscal = _mm256_and_ps(fscal,cutoff_mask);
511 /* Calculate temporary vectorial force */
512 tx = _mm256_mul_ps(fscal,dx12);
513 ty = _mm256_mul_ps(fscal,dy12);
514 tz = _mm256_mul_ps(fscal,dz12);
516 /* Update vectorial force */
517 fix1 = _mm256_add_ps(fix1,tx);
518 fiy1 = _mm256_add_ps(fiy1,ty);
519 fiz1 = _mm256_add_ps(fiz1,tz);
521 fjx2 = _mm256_add_ps(fjx2,tx);
522 fjy2 = _mm256_add_ps(fjy2,ty);
523 fjz2 = _mm256_add_ps(fjz2,tz);
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
531 if (gmx_mm256_any_lt(rsq20,rcutoff2))
534 /* REACTION-FIELD ELECTROSTATICS */
535 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
536 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
538 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
540 /* Update potential sum for this i atom from the interaction with this j atom. */
541 velec = _mm256_and_ps(velec,cutoff_mask);
542 velecsum = _mm256_add_ps(velecsum,velec);
546 fscal = _mm256_and_ps(fscal,cutoff_mask);
548 /* Calculate temporary vectorial force */
549 tx = _mm256_mul_ps(fscal,dx20);
550 ty = _mm256_mul_ps(fscal,dy20);
551 tz = _mm256_mul_ps(fscal,dz20);
553 /* Update vectorial force */
554 fix2 = _mm256_add_ps(fix2,tx);
555 fiy2 = _mm256_add_ps(fiy2,ty);
556 fiz2 = _mm256_add_ps(fiz2,tz);
558 fjx0 = _mm256_add_ps(fjx0,tx);
559 fjy0 = _mm256_add_ps(fjy0,ty);
560 fjz0 = _mm256_add_ps(fjz0,tz);
564 /**************************
565 * CALCULATE INTERACTIONS *
566 **************************/
568 if (gmx_mm256_any_lt(rsq21,rcutoff2))
571 /* REACTION-FIELD ELECTROSTATICS */
572 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
573 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
575 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
577 /* Update potential sum for this i atom from the interaction with this j atom. */
578 velec = _mm256_and_ps(velec,cutoff_mask);
579 velecsum = _mm256_add_ps(velecsum,velec);
583 fscal = _mm256_and_ps(fscal,cutoff_mask);
585 /* Calculate temporary vectorial force */
586 tx = _mm256_mul_ps(fscal,dx21);
587 ty = _mm256_mul_ps(fscal,dy21);
588 tz = _mm256_mul_ps(fscal,dz21);
590 /* Update vectorial force */
591 fix2 = _mm256_add_ps(fix2,tx);
592 fiy2 = _mm256_add_ps(fiy2,ty);
593 fiz2 = _mm256_add_ps(fiz2,tz);
595 fjx1 = _mm256_add_ps(fjx1,tx);
596 fjy1 = _mm256_add_ps(fjy1,ty);
597 fjz1 = _mm256_add_ps(fjz1,tz);
601 /**************************
602 * CALCULATE INTERACTIONS *
603 **************************/
605 if (gmx_mm256_any_lt(rsq22,rcutoff2))
608 /* REACTION-FIELD ELECTROSTATICS */
609 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
610 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
612 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
614 /* Update potential sum for this i atom from the interaction with this j atom. */
615 velec = _mm256_and_ps(velec,cutoff_mask);
616 velecsum = _mm256_add_ps(velecsum,velec);
620 fscal = _mm256_and_ps(fscal,cutoff_mask);
622 /* Calculate temporary vectorial force */
623 tx = _mm256_mul_ps(fscal,dx22);
624 ty = _mm256_mul_ps(fscal,dy22);
625 tz = _mm256_mul_ps(fscal,dz22);
627 /* Update vectorial force */
628 fix2 = _mm256_add_ps(fix2,tx);
629 fiy2 = _mm256_add_ps(fiy2,ty);
630 fiz2 = _mm256_add_ps(fiz2,tz);
632 fjx2 = _mm256_add_ps(fjx2,tx);
633 fjy2 = _mm256_add_ps(fjy2,ty);
634 fjz2 = _mm256_add_ps(fjz2,tz);
638 fjptrA = f+j_coord_offsetA;
639 fjptrB = f+j_coord_offsetB;
640 fjptrC = f+j_coord_offsetC;
641 fjptrD = f+j_coord_offsetD;
642 fjptrE = f+j_coord_offsetE;
643 fjptrF = f+j_coord_offsetF;
644 fjptrG = f+j_coord_offsetG;
645 fjptrH = f+j_coord_offsetH;
647 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
648 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
650 /* Inner loop uses 324 flops */
656 /* Get j neighbor index, and coordinate index */
657 jnrlistA = jjnr[jidx];
658 jnrlistB = jjnr[jidx+1];
659 jnrlistC = jjnr[jidx+2];
660 jnrlistD = jjnr[jidx+3];
661 jnrlistE = jjnr[jidx+4];
662 jnrlistF = jjnr[jidx+5];
663 jnrlistG = jjnr[jidx+6];
664 jnrlistH = jjnr[jidx+7];
665 /* Sign of each element will be negative for non-real atoms.
666 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
667 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
669 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
670 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
672 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
673 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
674 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
675 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
676 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
677 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
678 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
679 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
680 j_coord_offsetA = DIM*jnrA;
681 j_coord_offsetB = DIM*jnrB;
682 j_coord_offsetC = DIM*jnrC;
683 j_coord_offsetD = DIM*jnrD;
684 j_coord_offsetE = DIM*jnrE;
685 j_coord_offsetF = DIM*jnrF;
686 j_coord_offsetG = DIM*jnrG;
687 j_coord_offsetH = DIM*jnrH;
689 /* load j atom coordinates */
690 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
691 x+j_coord_offsetC,x+j_coord_offsetD,
692 x+j_coord_offsetE,x+j_coord_offsetF,
693 x+j_coord_offsetG,x+j_coord_offsetH,
694 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
696 /* Calculate displacement vector */
697 dx00 = _mm256_sub_ps(ix0,jx0);
698 dy00 = _mm256_sub_ps(iy0,jy0);
699 dz00 = _mm256_sub_ps(iz0,jz0);
700 dx01 = _mm256_sub_ps(ix0,jx1);
701 dy01 = _mm256_sub_ps(iy0,jy1);
702 dz01 = _mm256_sub_ps(iz0,jz1);
703 dx02 = _mm256_sub_ps(ix0,jx2);
704 dy02 = _mm256_sub_ps(iy0,jy2);
705 dz02 = _mm256_sub_ps(iz0,jz2);
706 dx10 = _mm256_sub_ps(ix1,jx0);
707 dy10 = _mm256_sub_ps(iy1,jy0);
708 dz10 = _mm256_sub_ps(iz1,jz0);
709 dx11 = _mm256_sub_ps(ix1,jx1);
710 dy11 = _mm256_sub_ps(iy1,jy1);
711 dz11 = _mm256_sub_ps(iz1,jz1);
712 dx12 = _mm256_sub_ps(ix1,jx2);
713 dy12 = _mm256_sub_ps(iy1,jy2);
714 dz12 = _mm256_sub_ps(iz1,jz2);
715 dx20 = _mm256_sub_ps(ix2,jx0);
716 dy20 = _mm256_sub_ps(iy2,jy0);
717 dz20 = _mm256_sub_ps(iz2,jz0);
718 dx21 = _mm256_sub_ps(ix2,jx1);
719 dy21 = _mm256_sub_ps(iy2,jy1);
720 dz21 = _mm256_sub_ps(iz2,jz1);
721 dx22 = _mm256_sub_ps(ix2,jx2);
722 dy22 = _mm256_sub_ps(iy2,jy2);
723 dz22 = _mm256_sub_ps(iz2,jz2);
725 /* Calculate squared distance and things based on it */
726 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
727 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
728 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
729 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
730 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
731 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
732 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
733 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
734 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
736 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
737 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
738 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
739 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
740 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
741 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
742 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
743 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
744 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
746 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
747 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
748 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
749 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
750 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
751 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
752 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
753 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
754 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
756 fjx0 = _mm256_setzero_ps();
757 fjy0 = _mm256_setzero_ps();
758 fjz0 = _mm256_setzero_ps();
759 fjx1 = _mm256_setzero_ps();
760 fjy1 = _mm256_setzero_ps();
761 fjz1 = _mm256_setzero_ps();
762 fjx2 = _mm256_setzero_ps();
763 fjy2 = _mm256_setzero_ps();
764 fjz2 = _mm256_setzero_ps();
766 /**************************
767 * CALCULATE INTERACTIONS *
768 **************************/
770 if (gmx_mm256_any_lt(rsq00,rcutoff2))
773 /* REACTION-FIELD ELECTROSTATICS */
774 velec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_add_ps(rinv00,_mm256_mul_ps(krf,rsq00)),crf));
775 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
777 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
779 /* Update potential sum for this i atom from the interaction with this j atom. */
780 velec = _mm256_and_ps(velec,cutoff_mask);
781 velec = _mm256_andnot_ps(dummy_mask,velec);
782 velecsum = _mm256_add_ps(velecsum,velec);
786 fscal = _mm256_and_ps(fscal,cutoff_mask);
788 fscal = _mm256_andnot_ps(dummy_mask,fscal);
790 /* Calculate temporary vectorial force */
791 tx = _mm256_mul_ps(fscal,dx00);
792 ty = _mm256_mul_ps(fscal,dy00);
793 tz = _mm256_mul_ps(fscal,dz00);
795 /* Update vectorial force */
796 fix0 = _mm256_add_ps(fix0,tx);
797 fiy0 = _mm256_add_ps(fiy0,ty);
798 fiz0 = _mm256_add_ps(fiz0,tz);
800 fjx0 = _mm256_add_ps(fjx0,tx);
801 fjy0 = _mm256_add_ps(fjy0,ty);
802 fjz0 = _mm256_add_ps(fjz0,tz);
806 /**************************
807 * CALCULATE INTERACTIONS *
808 **************************/
810 if (gmx_mm256_any_lt(rsq01,rcutoff2))
813 /* REACTION-FIELD ELECTROSTATICS */
814 velec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_add_ps(rinv01,_mm256_mul_ps(krf,rsq01)),crf));
815 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
817 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
819 /* Update potential sum for this i atom from the interaction with this j atom. */
820 velec = _mm256_and_ps(velec,cutoff_mask);
821 velec = _mm256_andnot_ps(dummy_mask,velec);
822 velecsum = _mm256_add_ps(velecsum,velec);
826 fscal = _mm256_and_ps(fscal,cutoff_mask);
828 fscal = _mm256_andnot_ps(dummy_mask,fscal);
830 /* Calculate temporary vectorial force */
831 tx = _mm256_mul_ps(fscal,dx01);
832 ty = _mm256_mul_ps(fscal,dy01);
833 tz = _mm256_mul_ps(fscal,dz01);
835 /* Update vectorial force */
836 fix0 = _mm256_add_ps(fix0,tx);
837 fiy0 = _mm256_add_ps(fiy0,ty);
838 fiz0 = _mm256_add_ps(fiz0,tz);
840 fjx1 = _mm256_add_ps(fjx1,tx);
841 fjy1 = _mm256_add_ps(fjy1,ty);
842 fjz1 = _mm256_add_ps(fjz1,tz);
846 /**************************
847 * CALCULATE INTERACTIONS *
848 **************************/
850 if (gmx_mm256_any_lt(rsq02,rcutoff2))
853 /* REACTION-FIELD ELECTROSTATICS */
854 velec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_add_ps(rinv02,_mm256_mul_ps(krf,rsq02)),crf));
855 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
857 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
859 /* Update potential sum for this i atom from the interaction with this j atom. */
860 velec = _mm256_and_ps(velec,cutoff_mask);
861 velec = _mm256_andnot_ps(dummy_mask,velec);
862 velecsum = _mm256_add_ps(velecsum,velec);
866 fscal = _mm256_and_ps(fscal,cutoff_mask);
868 fscal = _mm256_andnot_ps(dummy_mask,fscal);
870 /* Calculate temporary vectorial force */
871 tx = _mm256_mul_ps(fscal,dx02);
872 ty = _mm256_mul_ps(fscal,dy02);
873 tz = _mm256_mul_ps(fscal,dz02);
875 /* Update vectorial force */
876 fix0 = _mm256_add_ps(fix0,tx);
877 fiy0 = _mm256_add_ps(fiy0,ty);
878 fiz0 = _mm256_add_ps(fiz0,tz);
880 fjx2 = _mm256_add_ps(fjx2,tx);
881 fjy2 = _mm256_add_ps(fjy2,ty);
882 fjz2 = _mm256_add_ps(fjz2,tz);
886 /**************************
887 * CALCULATE INTERACTIONS *
888 **************************/
890 if (gmx_mm256_any_lt(rsq10,rcutoff2))
893 /* REACTION-FIELD ELECTROSTATICS */
894 velec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_add_ps(rinv10,_mm256_mul_ps(krf,rsq10)),crf));
895 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
897 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
899 /* Update potential sum for this i atom from the interaction with this j atom. */
900 velec = _mm256_and_ps(velec,cutoff_mask);
901 velec = _mm256_andnot_ps(dummy_mask,velec);
902 velecsum = _mm256_add_ps(velecsum,velec);
906 fscal = _mm256_and_ps(fscal,cutoff_mask);
908 fscal = _mm256_andnot_ps(dummy_mask,fscal);
910 /* Calculate temporary vectorial force */
911 tx = _mm256_mul_ps(fscal,dx10);
912 ty = _mm256_mul_ps(fscal,dy10);
913 tz = _mm256_mul_ps(fscal,dz10);
915 /* Update vectorial force */
916 fix1 = _mm256_add_ps(fix1,tx);
917 fiy1 = _mm256_add_ps(fiy1,ty);
918 fiz1 = _mm256_add_ps(fiz1,tz);
920 fjx0 = _mm256_add_ps(fjx0,tx);
921 fjy0 = _mm256_add_ps(fjy0,ty);
922 fjz0 = _mm256_add_ps(fjz0,tz);
926 /**************************
927 * CALCULATE INTERACTIONS *
928 **************************/
930 if (gmx_mm256_any_lt(rsq11,rcutoff2))
933 /* REACTION-FIELD ELECTROSTATICS */
934 velec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
935 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
937 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
939 /* Update potential sum for this i atom from the interaction with this j atom. */
940 velec = _mm256_and_ps(velec,cutoff_mask);
941 velec = _mm256_andnot_ps(dummy_mask,velec);
942 velecsum = _mm256_add_ps(velecsum,velec);
946 fscal = _mm256_and_ps(fscal,cutoff_mask);
948 fscal = _mm256_andnot_ps(dummy_mask,fscal);
950 /* Calculate temporary vectorial force */
951 tx = _mm256_mul_ps(fscal,dx11);
952 ty = _mm256_mul_ps(fscal,dy11);
953 tz = _mm256_mul_ps(fscal,dz11);
955 /* Update vectorial force */
956 fix1 = _mm256_add_ps(fix1,tx);
957 fiy1 = _mm256_add_ps(fiy1,ty);
958 fiz1 = _mm256_add_ps(fiz1,tz);
960 fjx1 = _mm256_add_ps(fjx1,tx);
961 fjy1 = _mm256_add_ps(fjy1,ty);
962 fjz1 = _mm256_add_ps(fjz1,tz);
966 /**************************
967 * CALCULATE INTERACTIONS *
968 **************************/
970 if (gmx_mm256_any_lt(rsq12,rcutoff2))
973 /* REACTION-FIELD ELECTROSTATICS */
974 velec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
975 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
977 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
979 /* Update potential sum for this i atom from the interaction with this j atom. */
980 velec = _mm256_and_ps(velec,cutoff_mask);
981 velec = _mm256_andnot_ps(dummy_mask,velec);
982 velecsum = _mm256_add_ps(velecsum,velec);
986 fscal = _mm256_and_ps(fscal,cutoff_mask);
988 fscal = _mm256_andnot_ps(dummy_mask,fscal);
990 /* Calculate temporary vectorial force */
991 tx = _mm256_mul_ps(fscal,dx12);
992 ty = _mm256_mul_ps(fscal,dy12);
993 tz = _mm256_mul_ps(fscal,dz12);
995 /* Update vectorial force */
996 fix1 = _mm256_add_ps(fix1,tx);
997 fiy1 = _mm256_add_ps(fiy1,ty);
998 fiz1 = _mm256_add_ps(fiz1,tz);
1000 fjx2 = _mm256_add_ps(fjx2,tx);
1001 fjy2 = _mm256_add_ps(fjy2,ty);
1002 fjz2 = _mm256_add_ps(fjz2,tz);
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1010 if (gmx_mm256_any_lt(rsq20,rcutoff2))
1013 /* REACTION-FIELD ELECTROSTATICS */
1014 velec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_add_ps(rinv20,_mm256_mul_ps(krf,rsq20)),crf));
1015 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1017 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
1019 /* Update potential sum for this i atom from the interaction with this j atom. */
1020 velec = _mm256_and_ps(velec,cutoff_mask);
1021 velec = _mm256_andnot_ps(dummy_mask,velec);
1022 velecsum = _mm256_add_ps(velecsum,velec);
1026 fscal = _mm256_and_ps(fscal,cutoff_mask);
1028 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1030 /* Calculate temporary vectorial force */
1031 tx = _mm256_mul_ps(fscal,dx20);
1032 ty = _mm256_mul_ps(fscal,dy20);
1033 tz = _mm256_mul_ps(fscal,dz20);
1035 /* Update vectorial force */
1036 fix2 = _mm256_add_ps(fix2,tx);
1037 fiy2 = _mm256_add_ps(fiy2,ty);
1038 fiz2 = _mm256_add_ps(fiz2,tz);
1040 fjx0 = _mm256_add_ps(fjx0,tx);
1041 fjy0 = _mm256_add_ps(fjy0,ty);
1042 fjz0 = _mm256_add_ps(fjz0,tz);
1046 /**************************
1047 * CALCULATE INTERACTIONS *
1048 **************************/
1050 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1053 /* REACTION-FIELD ELECTROSTATICS */
1054 velec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1055 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1057 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1059 /* Update potential sum for this i atom from the interaction with this j atom. */
1060 velec = _mm256_and_ps(velec,cutoff_mask);
1061 velec = _mm256_andnot_ps(dummy_mask,velec);
1062 velecsum = _mm256_add_ps(velecsum,velec);
1066 fscal = _mm256_and_ps(fscal,cutoff_mask);
1068 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1070 /* Calculate temporary vectorial force */
1071 tx = _mm256_mul_ps(fscal,dx21);
1072 ty = _mm256_mul_ps(fscal,dy21);
1073 tz = _mm256_mul_ps(fscal,dz21);
1075 /* Update vectorial force */
1076 fix2 = _mm256_add_ps(fix2,tx);
1077 fiy2 = _mm256_add_ps(fiy2,ty);
1078 fiz2 = _mm256_add_ps(fiz2,tz);
1080 fjx1 = _mm256_add_ps(fjx1,tx);
1081 fjy1 = _mm256_add_ps(fjy1,ty);
1082 fjz1 = _mm256_add_ps(fjz1,tz);
1086 /**************************
1087 * CALCULATE INTERACTIONS *
1088 **************************/
1090 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1093 /* REACTION-FIELD ELECTROSTATICS */
1094 velec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1095 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1097 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1099 /* Update potential sum for this i atom from the interaction with this j atom. */
1100 velec = _mm256_and_ps(velec,cutoff_mask);
1101 velec = _mm256_andnot_ps(dummy_mask,velec);
1102 velecsum = _mm256_add_ps(velecsum,velec);
1106 fscal = _mm256_and_ps(fscal,cutoff_mask);
1108 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1110 /* Calculate temporary vectorial force */
1111 tx = _mm256_mul_ps(fscal,dx22);
1112 ty = _mm256_mul_ps(fscal,dy22);
1113 tz = _mm256_mul_ps(fscal,dz22);
1115 /* Update vectorial force */
1116 fix2 = _mm256_add_ps(fix2,tx);
1117 fiy2 = _mm256_add_ps(fiy2,ty);
1118 fiz2 = _mm256_add_ps(fiz2,tz);
1120 fjx2 = _mm256_add_ps(fjx2,tx);
1121 fjy2 = _mm256_add_ps(fjy2,ty);
1122 fjz2 = _mm256_add_ps(fjz2,tz);
1126 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1127 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1128 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1129 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1130 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1131 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1132 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1133 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1135 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1136 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1138 /* Inner loop uses 324 flops */
1141 /* End of innermost loop */
1143 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1144 f+i_coord_offset,fshift+i_shift_offset);
1147 /* Update potential energies */
1148 gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1150 /* Increment number of inner iterations */
1151 inneriter += j_index_end - j_index_start;
1153 /* Outer loop uses 19 flops */
1156 /* Increment number of outer iterations */
1159 /* Update outer/inner flops */
1161 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*324);
1164 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3W3_F_avx_256_single
1165 * Electrostatics interaction: ReactionField
1166 * VdW interaction: None
1167 * Geometry: Water3-Water3
1168 * Calculate force/pot: Force
1171 nb_kernel_ElecRFCut_VdwNone_GeomW3W3_F_avx_256_single
1172 (t_nblist * gmx_restrict nlist,
1173 rvec * gmx_restrict xx,
1174 rvec * gmx_restrict ff,
1175 t_forcerec * gmx_restrict fr,
1176 t_mdatoms * gmx_restrict mdatoms,
1177 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1178 t_nrnb * gmx_restrict nrnb)
1180 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1181 * just 0 for non-waters.
1182 * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1183 * jnr indices corresponding to data put in the four positions in the SIMD register.
1185 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1186 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1187 int jnrA,jnrB,jnrC,jnrD;
1188 int jnrE,jnrF,jnrG,jnrH;
1189 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1190 int jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1191 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1192 int j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1193 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1194 real rcutoff_scalar;
1195 real *shiftvec,*fshift,*x,*f;
1196 real *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1197 real scratch[4*DIM];
1198 __m256 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1199 real * vdwioffsetptr0;
1200 __m256 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1201 real * vdwioffsetptr1;
1202 __m256 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1203 real * vdwioffsetptr2;
1204 __m256 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1205 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1206 __m256 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1207 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1208 __m256 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1209 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1210 __m256 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1211 __m256 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1212 __m256 dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1213 __m256 dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1214 __m256 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1215 __m256 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1216 __m256 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1217 __m256 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1218 __m256 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1219 __m256 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1220 __m256 velec,felec,velecsum,facel,crf,krf,krf2;
1222 __m256 dummy_mask,cutoff_mask;
1223 __m256 signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1224 __m256 one = _mm256_set1_ps(1.0);
1225 __m256 two = _mm256_set1_ps(2.0);
1231 jindex = nlist->jindex;
1233 shiftidx = nlist->shift;
1235 shiftvec = fr->shift_vec[0];
1236 fshift = fr->fshift[0];
1237 facel = _mm256_set1_ps(fr->epsfac);
1238 charge = mdatoms->chargeA;
1239 krf = _mm256_set1_ps(fr->ic->k_rf);
1240 krf2 = _mm256_set1_ps(fr->ic->k_rf*2.0);
1241 crf = _mm256_set1_ps(fr->ic->c_rf);
1243 /* Setup water-specific parameters */
1244 inr = nlist->iinr[0];
1245 iq0 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+0]));
1246 iq1 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1247 iq2 = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1249 jq0 = _mm256_set1_ps(charge[inr+0]);
1250 jq1 = _mm256_set1_ps(charge[inr+1]);
1251 jq2 = _mm256_set1_ps(charge[inr+2]);
1252 qq00 = _mm256_mul_ps(iq0,jq0);
1253 qq01 = _mm256_mul_ps(iq0,jq1);
1254 qq02 = _mm256_mul_ps(iq0,jq2);
1255 qq10 = _mm256_mul_ps(iq1,jq0);
1256 qq11 = _mm256_mul_ps(iq1,jq1);
1257 qq12 = _mm256_mul_ps(iq1,jq2);
1258 qq20 = _mm256_mul_ps(iq2,jq0);
1259 qq21 = _mm256_mul_ps(iq2,jq1);
1260 qq22 = _mm256_mul_ps(iq2,jq2);
1262 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1263 rcutoff_scalar = fr->rcoulomb;
1264 rcutoff = _mm256_set1_ps(rcutoff_scalar);
1265 rcutoff2 = _mm256_mul_ps(rcutoff,rcutoff);
1267 /* Avoid stupid compiler warnings */
1268 jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1269 j_coord_offsetA = 0;
1270 j_coord_offsetB = 0;
1271 j_coord_offsetC = 0;
1272 j_coord_offsetD = 0;
1273 j_coord_offsetE = 0;
1274 j_coord_offsetF = 0;
1275 j_coord_offsetG = 0;
1276 j_coord_offsetH = 0;
1281 for(iidx=0;iidx<4*DIM;iidx++)
1283 scratch[iidx] = 0.0;
1286 /* Start outer loop over neighborlists */
1287 for(iidx=0; iidx<nri; iidx++)
1289 /* Load shift vector for this list */
1290 i_shift_offset = DIM*shiftidx[iidx];
1292 /* Load limits for loop over neighbors */
1293 j_index_start = jindex[iidx];
1294 j_index_end = jindex[iidx+1];
1296 /* Get outer coordinate index */
1298 i_coord_offset = DIM*inr;
1300 /* Load i particle coords and add shift vector */
1301 gmx_mm256_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1302 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1304 fix0 = _mm256_setzero_ps();
1305 fiy0 = _mm256_setzero_ps();
1306 fiz0 = _mm256_setzero_ps();
1307 fix1 = _mm256_setzero_ps();
1308 fiy1 = _mm256_setzero_ps();
1309 fiz1 = _mm256_setzero_ps();
1310 fix2 = _mm256_setzero_ps();
1311 fiy2 = _mm256_setzero_ps();
1312 fiz2 = _mm256_setzero_ps();
1314 /* Start inner kernel loop */
1315 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1318 /* Get j neighbor index, and coordinate index */
1320 jnrB = jjnr[jidx+1];
1321 jnrC = jjnr[jidx+2];
1322 jnrD = jjnr[jidx+3];
1323 jnrE = jjnr[jidx+4];
1324 jnrF = jjnr[jidx+5];
1325 jnrG = jjnr[jidx+6];
1326 jnrH = jjnr[jidx+7];
1327 j_coord_offsetA = DIM*jnrA;
1328 j_coord_offsetB = DIM*jnrB;
1329 j_coord_offsetC = DIM*jnrC;
1330 j_coord_offsetD = DIM*jnrD;
1331 j_coord_offsetE = DIM*jnrE;
1332 j_coord_offsetF = DIM*jnrF;
1333 j_coord_offsetG = DIM*jnrG;
1334 j_coord_offsetH = DIM*jnrH;
1336 /* load j atom coordinates */
1337 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1338 x+j_coord_offsetC,x+j_coord_offsetD,
1339 x+j_coord_offsetE,x+j_coord_offsetF,
1340 x+j_coord_offsetG,x+j_coord_offsetH,
1341 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1343 /* Calculate displacement vector */
1344 dx00 = _mm256_sub_ps(ix0,jx0);
1345 dy00 = _mm256_sub_ps(iy0,jy0);
1346 dz00 = _mm256_sub_ps(iz0,jz0);
1347 dx01 = _mm256_sub_ps(ix0,jx1);
1348 dy01 = _mm256_sub_ps(iy0,jy1);
1349 dz01 = _mm256_sub_ps(iz0,jz1);
1350 dx02 = _mm256_sub_ps(ix0,jx2);
1351 dy02 = _mm256_sub_ps(iy0,jy2);
1352 dz02 = _mm256_sub_ps(iz0,jz2);
1353 dx10 = _mm256_sub_ps(ix1,jx0);
1354 dy10 = _mm256_sub_ps(iy1,jy0);
1355 dz10 = _mm256_sub_ps(iz1,jz0);
1356 dx11 = _mm256_sub_ps(ix1,jx1);
1357 dy11 = _mm256_sub_ps(iy1,jy1);
1358 dz11 = _mm256_sub_ps(iz1,jz1);
1359 dx12 = _mm256_sub_ps(ix1,jx2);
1360 dy12 = _mm256_sub_ps(iy1,jy2);
1361 dz12 = _mm256_sub_ps(iz1,jz2);
1362 dx20 = _mm256_sub_ps(ix2,jx0);
1363 dy20 = _mm256_sub_ps(iy2,jy0);
1364 dz20 = _mm256_sub_ps(iz2,jz0);
1365 dx21 = _mm256_sub_ps(ix2,jx1);
1366 dy21 = _mm256_sub_ps(iy2,jy1);
1367 dz21 = _mm256_sub_ps(iz2,jz1);
1368 dx22 = _mm256_sub_ps(ix2,jx2);
1369 dy22 = _mm256_sub_ps(iy2,jy2);
1370 dz22 = _mm256_sub_ps(iz2,jz2);
1372 /* Calculate squared distance and things based on it */
1373 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1374 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1375 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1376 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1377 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1378 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1379 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1380 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1381 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1383 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1384 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1385 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1386 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1387 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1388 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1389 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1390 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1391 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1393 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1394 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1395 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1396 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1397 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1398 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1399 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1400 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1401 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1403 fjx0 = _mm256_setzero_ps();
1404 fjy0 = _mm256_setzero_ps();
1405 fjz0 = _mm256_setzero_ps();
1406 fjx1 = _mm256_setzero_ps();
1407 fjy1 = _mm256_setzero_ps();
1408 fjz1 = _mm256_setzero_ps();
1409 fjx2 = _mm256_setzero_ps();
1410 fjy2 = _mm256_setzero_ps();
1411 fjz2 = _mm256_setzero_ps();
1413 /**************************
1414 * CALCULATE INTERACTIONS *
1415 **************************/
1417 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1420 /* REACTION-FIELD ELECTROSTATICS */
1421 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1423 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1427 fscal = _mm256_and_ps(fscal,cutoff_mask);
1429 /* Calculate temporary vectorial force */
1430 tx = _mm256_mul_ps(fscal,dx00);
1431 ty = _mm256_mul_ps(fscal,dy00);
1432 tz = _mm256_mul_ps(fscal,dz00);
1434 /* Update vectorial force */
1435 fix0 = _mm256_add_ps(fix0,tx);
1436 fiy0 = _mm256_add_ps(fiy0,ty);
1437 fiz0 = _mm256_add_ps(fiz0,tz);
1439 fjx0 = _mm256_add_ps(fjx0,tx);
1440 fjy0 = _mm256_add_ps(fjy0,ty);
1441 fjz0 = _mm256_add_ps(fjz0,tz);
1445 /**************************
1446 * CALCULATE INTERACTIONS *
1447 **************************/
1449 if (gmx_mm256_any_lt(rsq01,rcutoff2))
1452 /* REACTION-FIELD ELECTROSTATICS */
1453 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1455 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
1459 fscal = _mm256_and_ps(fscal,cutoff_mask);
1461 /* Calculate temporary vectorial force */
1462 tx = _mm256_mul_ps(fscal,dx01);
1463 ty = _mm256_mul_ps(fscal,dy01);
1464 tz = _mm256_mul_ps(fscal,dz01);
1466 /* Update vectorial force */
1467 fix0 = _mm256_add_ps(fix0,tx);
1468 fiy0 = _mm256_add_ps(fiy0,ty);
1469 fiz0 = _mm256_add_ps(fiz0,tz);
1471 fjx1 = _mm256_add_ps(fjx1,tx);
1472 fjy1 = _mm256_add_ps(fjy1,ty);
1473 fjz1 = _mm256_add_ps(fjz1,tz);
1477 /**************************
1478 * CALCULATE INTERACTIONS *
1479 **************************/
1481 if (gmx_mm256_any_lt(rsq02,rcutoff2))
1484 /* REACTION-FIELD ELECTROSTATICS */
1485 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1487 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
1491 fscal = _mm256_and_ps(fscal,cutoff_mask);
1493 /* Calculate temporary vectorial force */
1494 tx = _mm256_mul_ps(fscal,dx02);
1495 ty = _mm256_mul_ps(fscal,dy02);
1496 tz = _mm256_mul_ps(fscal,dz02);
1498 /* Update vectorial force */
1499 fix0 = _mm256_add_ps(fix0,tx);
1500 fiy0 = _mm256_add_ps(fiy0,ty);
1501 fiz0 = _mm256_add_ps(fiz0,tz);
1503 fjx2 = _mm256_add_ps(fjx2,tx);
1504 fjy2 = _mm256_add_ps(fjy2,ty);
1505 fjz2 = _mm256_add_ps(fjz2,tz);
1509 /**************************
1510 * CALCULATE INTERACTIONS *
1511 **************************/
1513 if (gmx_mm256_any_lt(rsq10,rcutoff2))
1516 /* REACTION-FIELD ELECTROSTATICS */
1517 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1519 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
1523 fscal = _mm256_and_ps(fscal,cutoff_mask);
1525 /* Calculate temporary vectorial force */
1526 tx = _mm256_mul_ps(fscal,dx10);
1527 ty = _mm256_mul_ps(fscal,dy10);
1528 tz = _mm256_mul_ps(fscal,dz10);
1530 /* Update vectorial force */
1531 fix1 = _mm256_add_ps(fix1,tx);
1532 fiy1 = _mm256_add_ps(fiy1,ty);
1533 fiz1 = _mm256_add_ps(fiz1,tz);
1535 fjx0 = _mm256_add_ps(fjx0,tx);
1536 fjy0 = _mm256_add_ps(fjy0,ty);
1537 fjz0 = _mm256_add_ps(fjz0,tz);
1541 /**************************
1542 * CALCULATE INTERACTIONS *
1543 **************************/
1545 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1548 /* REACTION-FIELD ELECTROSTATICS */
1549 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1551 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1555 fscal = _mm256_and_ps(fscal,cutoff_mask);
1557 /* Calculate temporary vectorial force */
1558 tx = _mm256_mul_ps(fscal,dx11);
1559 ty = _mm256_mul_ps(fscal,dy11);
1560 tz = _mm256_mul_ps(fscal,dz11);
1562 /* Update vectorial force */
1563 fix1 = _mm256_add_ps(fix1,tx);
1564 fiy1 = _mm256_add_ps(fiy1,ty);
1565 fiz1 = _mm256_add_ps(fiz1,tz);
1567 fjx1 = _mm256_add_ps(fjx1,tx);
1568 fjy1 = _mm256_add_ps(fjy1,ty);
1569 fjz1 = _mm256_add_ps(fjz1,tz);
1573 /**************************
1574 * CALCULATE INTERACTIONS *
1575 **************************/
1577 if (gmx_mm256_any_lt(rsq12,rcutoff2))
1580 /* REACTION-FIELD ELECTROSTATICS */
1581 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1583 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1587 fscal = _mm256_and_ps(fscal,cutoff_mask);
1589 /* Calculate temporary vectorial force */
1590 tx = _mm256_mul_ps(fscal,dx12);
1591 ty = _mm256_mul_ps(fscal,dy12);
1592 tz = _mm256_mul_ps(fscal,dz12);
1594 /* Update vectorial force */
1595 fix1 = _mm256_add_ps(fix1,tx);
1596 fiy1 = _mm256_add_ps(fiy1,ty);
1597 fiz1 = _mm256_add_ps(fiz1,tz);
1599 fjx2 = _mm256_add_ps(fjx2,tx);
1600 fjy2 = _mm256_add_ps(fjy2,ty);
1601 fjz2 = _mm256_add_ps(fjz2,tz);
1605 /**************************
1606 * CALCULATE INTERACTIONS *
1607 **************************/
1609 if (gmx_mm256_any_lt(rsq20,rcutoff2))
1612 /* REACTION-FIELD ELECTROSTATICS */
1613 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
1615 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
1619 fscal = _mm256_and_ps(fscal,cutoff_mask);
1621 /* Calculate temporary vectorial force */
1622 tx = _mm256_mul_ps(fscal,dx20);
1623 ty = _mm256_mul_ps(fscal,dy20);
1624 tz = _mm256_mul_ps(fscal,dz20);
1626 /* Update vectorial force */
1627 fix2 = _mm256_add_ps(fix2,tx);
1628 fiy2 = _mm256_add_ps(fiy2,ty);
1629 fiz2 = _mm256_add_ps(fiz2,tz);
1631 fjx0 = _mm256_add_ps(fjx0,tx);
1632 fjy0 = _mm256_add_ps(fjy0,ty);
1633 fjz0 = _mm256_add_ps(fjz0,tz);
1637 /**************************
1638 * CALCULATE INTERACTIONS *
1639 **************************/
1641 if (gmx_mm256_any_lt(rsq21,rcutoff2))
1644 /* REACTION-FIELD ELECTROSTATICS */
1645 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1647 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1651 fscal = _mm256_and_ps(fscal,cutoff_mask);
1653 /* Calculate temporary vectorial force */
1654 tx = _mm256_mul_ps(fscal,dx21);
1655 ty = _mm256_mul_ps(fscal,dy21);
1656 tz = _mm256_mul_ps(fscal,dz21);
1658 /* Update vectorial force */
1659 fix2 = _mm256_add_ps(fix2,tx);
1660 fiy2 = _mm256_add_ps(fiy2,ty);
1661 fiz2 = _mm256_add_ps(fiz2,tz);
1663 fjx1 = _mm256_add_ps(fjx1,tx);
1664 fjy1 = _mm256_add_ps(fjy1,ty);
1665 fjz1 = _mm256_add_ps(fjz1,tz);
1669 /**************************
1670 * CALCULATE INTERACTIONS *
1671 **************************/
1673 if (gmx_mm256_any_lt(rsq22,rcutoff2))
1676 /* REACTION-FIELD ELECTROSTATICS */
1677 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1679 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1683 fscal = _mm256_and_ps(fscal,cutoff_mask);
1685 /* Calculate temporary vectorial force */
1686 tx = _mm256_mul_ps(fscal,dx22);
1687 ty = _mm256_mul_ps(fscal,dy22);
1688 tz = _mm256_mul_ps(fscal,dz22);
1690 /* Update vectorial force */
1691 fix2 = _mm256_add_ps(fix2,tx);
1692 fiy2 = _mm256_add_ps(fiy2,ty);
1693 fiz2 = _mm256_add_ps(fiz2,tz);
1695 fjx2 = _mm256_add_ps(fjx2,tx);
1696 fjy2 = _mm256_add_ps(fjy2,ty);
1697 fjz2 = _mm256_add_ps(fjz2,tz);
1701 fjptrA = f+j_coord_offsetA;
1702 fjptrB = f+j_coord_offsetB;
1703 fjptrC = f+j_coord_offsetC;
1704 fjptrD = f+j_coord_offsetD;
1705 fjptrE = f+j_coord_offsetE;
1706 fjptrF = f+j_coord_offsetF;
1707 fjptrG = f+j_coord_offsetG;
1708 fjptrH = f+j_coord_offsetH;
1710 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1711 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1713 /* Inner loop uses 270 flops */
1716 if(jidx<j_index_end)
1719 /* Get j neighbor index, and coordinate index */
1720 jnrlistA = jjnr[jidx];
1721 jnrlistB = jjnr[jidx+1];
1722 jnrlistC = jjnr[jidx+2];
1723 jnrlistD = jjnr[jidx+3];
1724 jnrlistE = jjnr[jidx+4];
1725 jnrlistF = jjnr[jidx+5];
1726 jnrlistG = jjnr[jidx+6];
1727 jnrlistH = jjnr[jidx+7];
1728 /* Sign of each element will be negative for non-real atoms.
1729 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1730 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1732 dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1733 gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1735 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1736 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1737 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1738 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1739 jnrE = (jnrlistE>=0) ? jnrlistE : 0;
1740 jnrF = (jnrlistF>=0) ? jnrlistF : 0;
1741 jnrG = (jnrlistG>=0) ? jnrlistG : 0;
1742 jnrH = (jnrlistH>=0) ? jnrlistH : 0;
1743 j_coord_offsetA = DIM*jnrA;
1744 j_coord_offsetB = DIM*jnrB;
1745 j_coord_offsetC = DIM*jnrC;
1746 j_coord_offsetD = DIM*jnrD;
1747 j_coord_offsetE = DIM*jnrE;
1748 j_coord_offsetF = DIM*jnrF;
1749 j_coord_offsetG = DIM*jnrG;
1750 j_coord_offsetH = DIM*jnrH;
1752 /* load j atom coordinates */
1753 gmx_mm256_load_3rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1754 x+j_coord_offsetC,x+j_coord_offsetD,
1755 x+j_coord_offsetE,x+j_coord_offsetF,
1756 x+j_coord_offsetG,x+j_coord_offsetH,
1757 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1759 /* Calculate displacement vector */
1760 dx00 = _mm256_sub_ps(ix0,jx0);
1761 dy00 = _mm256_sub_ps(iy0,jy0);
1762 dz00 = _mm256_sub_ps(iz0,jz0);
1763 dx01 = _mm256_sub_ps(ix0,jx1);
1764 dy01 = _mm256_sub_ps(iy0,jy1);
1765 dz01 = _mm256_sub_ps(iz0,jz1);
1766 dx02 = _mm256_sub_ps(ix0,jx2);
1767 dy02 = _mm256_sub_ps(iy0,jy2);
1768 dz02 = _mm256_sub_ps(iz0,jz2);
1769 dx10 = _mm256_sub_ps(ix1,jx0);
1770 dy10 = _mm256_sub_ps(iy1,jy0);
1771 dz10 = _mm256_sub_ps(iz1,jz0);
1772 dx11 = _mm256_sub_ps(ix1,jx1);
1773 dy11 = _mm256_sub_ps(iy1,jy1);
1774 dz11 = _mm256_sub_ps(iz1,jz1);
1775 dx12 = _mm256_sub_ps(ix1,jx2);
1776 dy12 = _mm256_sub_ps(iy1,jy2);
1777 dz12 = _mm256_sub_ps(iz1,jz2);
1778 dx20 = _mm256_sub_ps(ix2,jx0);
1779 dy20 = _mm256_sub_ps(iy2,jy0);
1780 dz20 = _mm256_sub_ps(iz2,jz0);
1781 dx21 = _mm256_sub_ps(ix2,jx1);
1782 dy21 = _mm256_sub_ps(iy2,jy1);
1783 dz21 = _mm256_sub_ps(iz2,jz1);
1784 dx22 = _mm256_sub_ps(ix2,jx2);
1785 dy22 = _mm256_sub_ps(iy2,jy2);
1786 dz22 = _mm256_sub_ps(iz2,jz2);
1788 /* Calculate squared distance and things based on it */
1789 rsq00 = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1790 rsq01 = gmx_mm256_calc_rsq_ps(dx01,dy01,dz01);
1791 rsq02 = gmx_mm256_calc_rsq_ps(dx02,dy02,dz02);
1792 rsq10 = gmx_mm256_calc_rsq_ps(dx10,dy10,dz10);
1793 rsq11 = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1794 rsq12 = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1795 rsq20 = gmx_mm256_calc_rsq_ps(dx20,dy20,dz20);
1796 rsq21 = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1797 rsq22 = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1799 rinv00 = gmx_mm256_invsqrt_ps(rsq00);
1800 rinv01 = gmx_mm256_invsqrt_ps(rsq01);
1801 rinv02 = gmx_mm256_invsqrt_ps(rsq02);
1802 rinv10 = gmx_mm256_invsqrt_ps(rsq10);
1803 rinv11 = gmx_mm256_invsqrt_ps(rsq11);
1804 rinv12 = gmx_mm256_invsqrt_ps(rsq12);
1805 rinv20 = gmx_mm256_invsqrt_ps(rsq20);
1806 rinv21 = gmx_mm256_invsqrt_ps(rsq21);
1807 rinv22 = gmx_mm256_invsqrt_ps(rsq22);
1809 rinvsq00 = _mm256_mul_ps(rinv00,rinv00);
1810 rinvsq01 = _mm256_mul_ps(rinv01,rinv01);
1811 rinvsq02 = _mm256_mul_ps(rinv02,rinv02);
1812 rinvsq10 = _mm256_mul_ps(rinv10,rinv10);
1813 rinvsq11 = _mm256_mul_ps(rinv11,rinv11);
1814 rinvsq12 = _mm256_mul_ps(rinv12,rinv12);
1815 rinvsq20 = _mm256_mul_ps(rinv20,rinv20);
1816 rinvsq21 = _mm256_mul_ps(rinv21,rinv21);
1817 rinvsq22 = _mm256_mul_ps(rinv22,rinv22);
1819 fjx0 = _mm256_setzero_ps();
1820 fjy0 = _mm256_setzero_ps();
1821 fjz0 = _mm256_setzero_ps();
1822 fjx1 = _mm256_setzero_ps();
1823 fjy1 = _mm256_setzero_ps();
1824 fjz1 = _mm256_setzero_ps();
1825 fjx2 = _mm256_setzero_ps();
1826 fjy2 = _mm256_setzero_ps();
1827 fjz2 = _mm256_setzero_ps();
1829 /**************************
1830 * CALCULATE INTERACTIONS *
1831 **************************/
1833 if (gmx_mm256_any_lt(rsq00,rcutoff2))
1836 /* REACTION-FIELD ELECTROSTATICS */
1837 felec = _mm256_mul_ps(qq00,_mm256_sub_ps(_mm256_mul_ps(rinv00,rinvsq00),krf2));
1839 cutoff_mask = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1843 fscal = _mm256_and_ps(fscal,cutoff_mask);
1845 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1847 /* Calculate temporary vectorial force */
1848 tx = _mm256_mul_ps(fscal,dx00);
1849 ty = _mm256_mul_ps(fscal,dy00);
1850 tz = _mm256_mul_ps(fscal,dz00);
1852 /* Update vectorial force */
1853 fix0 = _mm256_add_ps(fix0,tx);
1854 fiy0 = _mm256_add_ps(fiy0,ty);
1855 fiz0 = _mm256_add_ps(fiz0,tz);
1857 fjx0 = _mm256_add_ps(fjx0,tx);
1858 fjy0 = _mm256_add_ps(fjy0,ty);
1859 fjz0 = _mm256_add_ps(fjz0,tz);
1863 /**************************
1864 * CALCULATE INTERACTIONS *
1865 **************************/
1867 if (gmx_mm256_any_lt(rsq01,rcutoff2))
1870 /* REACTION-FIELD ELECTROSTATICS */
1871 felec = _mm256_mul_ps(qq01,_mm256_sub_ps(_mm256_mul_ps(rinv01,rinvsq01),krf2));
1873 cutoff_mask = _mm256_cmp_ps(rsq01,rcutoff2,_CMP_LT_OQ);
1877 fscal = _mm256_and_ps(fscal,cutoff_mask);
1879 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1881 /* Calculate temporary vectorial force */
1882 tx = _mm256_mul_ps(fscal,dx01);
1883 ty = _mm256_mul_ps(fscal,dy01);
1884 tz = _mm256_mul_ps(fscal,dz01);
1886 /* Update vectorial force */
1887 fix0 = _mm256_add_ps(fix0,tx);
1888 fiy0 = _mm256_add_ps(fiy0,ty);
1889 fiz0 = _mm256_add_ps(fiz0,tz);
1891 fjx1 = _mm256_add_ps(fjx1,tx);
1892 fjy1 = _mm256_add_ps(fjy1,ty);
1893 fjz1 = _mm256_add_ps(fjz1,tz);
1897 /**************************
1898 * CALCULATE INTERACTIONS *
1899 **************************/
1901 if (gmx_mm256_any_lt(rsq02,rcutoff2))
1904 /* REACTION-FIELD ELECTROSTATICS */
1905 felec = _mm256_mul_ps(qq02,_mm256_sub_ps(_mm256_mul_ps(rinv02,rinvsq02),krf2));
1907 cutoff_mask = _mm256_cmp_ps(rsq02,rcutoff2,_CMP_LT_OQ);
1911 fscal = _mm256_and_ps(fscal,cutoff_mask);
1913 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1915 /* Calculate temporary vectorial force */
1916 tx = _mm256_mul_ps(fscal,dx02);
1917 ty = _mm256_mul_ps(fscal,dy02);
1918 tz = _mm256_mul_ps(fscal,dz02);
1920 /* Update vectorial force */
1921 fix0 = _mm256_add_ps(fix0,tx);
1922 fiy0 = _mm256_add_ps(fiy0,ty);
1923 fiz0 = _mm256_add_ps(fiz0,tz);
1925 fjx2 = _mm256_add_ps(fjx2,tx);
1926 fjy2 = _mm256_add_ps(fjy2,ty);
1927 fjz2 = _mm256_add_ps(fjz2,tz);
1931 /**************************
1932 * CALCULATE INTERACTIONS *
1933 **************************/
1935 if (gmx_mm256_any_lt(rsq10,rcutoff2))
1938 /* REACTION-FIELD ELECTROSTATICS */
1939 felec = _mm256_mul_ps(qq10,_mm256_sub_ps(_mm256_mul_ps(rinv10,rinvsq10),krf2));
1941 cutoff_mask = _mm256_cmp_ps(rsq10,rcutoff2,_CMP_LT_OQ);
1945 fscal = _mm256_and_ps(fscal,cutoff_mask);
1947 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1949 /* Calculate temporary vectorial force */
1950 tx = _mm256_mul_ps(fscal,dx10);
1951 ty = _mm256_mul_ps(fscal,dy10);
1952 tz = _mm256_mul_ps(fscal,dz10);
1954 /* Update vectorial force */
1955 fix1 = _mm256_add_ps(fix1,tx);
1956 fiy1 = _mm256_add_ps(fiy1,ty);
1957 fiz1 = _mm256_add_ps(fiz1,tz);
1959 fjx0 = _mm256_add_ps(fjx0,tx);
1960 fjy0 = _mm256_add_ps(fjy0,ty);
1961 fjz0 = _mm256_add_ps(fjz0,tz);
1965 /**************************
1966 * CALCULATE INTERACTIONS *
1967 **************************/
1969 if (gmx_mm256_any_lt(rsq11,rcutoff2))
1972 /* REACTION-FIELD ELECTROSTATICS */
1973 felec = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1975 cutoff_mask = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1979 fscal = _mm256_and_ps(fscal,cutoff_mask);
1981 fscal = _mm256_andnot_ps(dummy_mask,fscal);
1983 /* Calculate temporary vectorial force */
1984 tx = _mm256_mul_ps(fscal,dx11);
1985 ty = _mm256_mul_ps(fscal,dy11);
1986 tz = _mm256_mul_ps(fscal,dz11);
1988 /* Update vectorial force */
1989 fix1 = _mm256_add_ps(fix1,tx);
1990 fiy1 = _mm256_add_ps(fiy1,ty);
1991 fiz1 = _mm256_add_ps(fiz1,tz);
1993 fjx1 = _mm256_add_ps(fjx1,tx);
1994 fjy1 = _mm256_add_ps(fjy1,ty);
1995 fjz1 = _mm256_add_ps(fjz1,tz);
1999 /**************************
2000 * CALCULATE INTERACTIONS *
2001 **************************/
2003 if (gmx_mm256_any_lt(rsq12,rcutoff2))
2006 /* REACTION-FIELD ELECTROSTATICS */
2007 felec = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
2009 cutoff_mask = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
2013 fscal = _mm256_and_ps(fscal,cutoff_mask);
2015 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2017 /* Calculate temporary vectorial force */
2018 tx = _mm256_mul_ps(fscal,dx12);
2019 ty = _mm256_mul_ps(fscal,dy12);
2020 tz = _mm256_mul_ps(fscal,dz12);
2022 /* Update vectorial force */
2023 fix1 = _mm256_add_ps(fix1,tx);
2024 fiy1 = _mm256_add_ps(fiy1,ty);
2025 fiz1 = _mm256_add_ps(fiz1,tz);
2027 fjx2 = _mm256_add_ps(fjx2,tx);
2028 fjy2 = _mm256_add_ps(fjy2,ty);
2029 fjz2 = _mm256_add_ps(fjz2,tz);
2033 /**************************
2034 * CALCULATE INTERACTIONS *
2035 **************************/
2037 if (gmx_mm256_any_lt(rsq20,rcutoff2))
2040 /* REACTION-FIELD ELECTROSTATICS */
2041 felec = _mm256_mul_ps(qq20,_mm256_sub_ps(_mm256_mul_ps(rinv20,rinvsq20),krf2));
2043 cutoff_mask = _mm256_cmp_ps(rsq20,rcutoff2,_CMP_LT_OQ);
2047 fscal = _mm256_and_ps(fscal,cutoff_mask);
2049 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2051 /* Calculate temporary vectorial force */
2052 tx = _mm256_mul_ps(fscal,dx20);
2053 ty = _mm256_mul_ps(fscal,dy20);
2054 tz = _mm256_mul_ps(fscal,dz20);
2056 /* Update vectorial force */
2057 fix2 = _mm256_add_ps(fix2,tx);
2058 fiy2 = _mm256_add_ps(fiy2,ty);
2059 fiz2 = _mm256_add_ps(fiz2,tz);
2061 fjx0 = _mm256_add_ps(fjx0,tx);
2062 fjy0 = _mm256_add_ps(fjy0,ty);
2063 fjz0 = _mm256_add_ps(fjz0,tz);
2067 /**************************
2068 * CALCULATE INTERACTIONS *
2069 **************************/
2071 if (gmx_mm256_any_lt(rsq21,rcutoff2))
2074 /* REACTION-FIELD ELECTROSTATICS */
2075 felec = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
2077 cutoff_mask = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
2081 fscal = _mm256_and_ps(fscal,cutoff_mask);
2083 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2085 /* Calculate temporary vectorial force */
2086 tx = _mm256_mul_ps(fscal,dx21);
2087 ty = _mm256_mul_ps(fscal,dy21);
2088 tz = _mm256_mul_ps(fscal,dz21);
2090 /* Update vectorial force */
2091 fix2 = _mm256_add_ps(fix2,tx);
2092 fiy2 = _mm256_add_ps(fiy2,ty);
2093 fiz2 = _mm256_add_ps(fiz2,tz);
2095 fjx1 = _mm256_add_ps(fjx1,tx);
2096 fjy1 = _mm256_add_ps(fjy1,ty);
2097 fjz1 = _mm256_add_ps(fjz1,tz);
2101 /**************************
2102 * CALCULATE INTERACTIONS *
2103 **************************/
2105 if (gmx_mm256_any_lt(rsq22,rcutoff2))
2108 /* REACTION-FIELD ELECTROSTATICS */
2109 felec = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2111 cutoff_mask = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
2115 fscal = _mm256_and_ps(fscal,cutoff_mask);
2117 fscal = _mm256_andnot_ps(dummy_mask,fscal);
2119 /* Calculate temporary vectorial force */
2120 tx = _mm256_mul_ps(fscal,dx22);
2121 ty = _mm256_mul_ps(fscal,dy22);
2122 tz = _mm256_mul_ps(fscal,dz22);
2124 /* Update vectorial force */
2125 fix2 = _mm256_add_ps(fix2,tx);
2126 fiy2 = _mm256_add_ps(fiy2,ty);
2127 fiz2 = _mm256_add_ps(fiz2,tz);
2129 fjx2 = _mm256_add_ps(fjx2,tx);
2130 fjy2 = _mm256_add_ps(fjy2,ty);
2131 fjz2 = _mm256_add_ps(fjz2,tz);
2135 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2136 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2137 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2138 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2139 fjptrE = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2140 fjptrF = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2141 fjptrG = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2142 fjptrH = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2144 gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2145 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2147 /* Inner loop uses 270 flops */
2150 /* End of innermost loop */
2152 gmx_mm256_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2153 f+i_coord_offset,fshift+i_shift_offset);
2155 /* Increment number of inner iterations */
2156 inneriter += j_index_end - j_index_start;
2158 /* Outer loop uses 18 flops */
2161 /* Increment number of outer iterations */
2164 /* Update outer/inner flops */
2166 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*270);