Created SIMD module
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_256_single / nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_avx_256_single.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 /*
36  * Note: this file was generated by the GROMACS avx_256_single kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 #include "gromacs/simd/math_x86_avx_256_single.h"
50 #include "kernelutil_x86_avx_256_single.h"
51
52 /*
53  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_VF_avx_256_single
54  * Electrostatics interaction: ReactionField
55  * VdW interaction:            LennardJones
56  * Geometry:                   Water4-Water4
57  * Calculate force/pot:        PotentialAndForce
58  */
59 void
60 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_VF_avx_256_single
61                     (t_nblist                    * gmx_restrict       nlist,
62                      rvec                        * gmx_restrict          xx,
63                      rvec                        * gmx_restrict          ff,
64                      t_forcerec                  * gmx_restrict          fr,
65                      t_mdatoms                   * gmx_restrict     mdatoms,
66                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67                      t_nrnb                      * gmx_restrict        nrnb)
68 {
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.
73      */
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;
83     real             rcutoff_scalar;
84     real             *shiftvec,*fshift,*x,*f;
85     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
86     real             scratch[4*DIM];
87     __m256           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
88     real *           vdwioffsetptr0;
89     __m256           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
90     real *           vdwioffsetptr1;
91     __m256           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
92     real *           vdwioffsetptr2;
93     __m256           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
94     real *           vdwioffsetptr3;
95     __m256           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
96     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
97     __m256           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
98     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
99     __m256           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
100     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
101     __m256           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
102     int              vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
103     __m256           jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
104     __m256           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
105     __m256           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
106     __m256           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
107     __m256           dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
108     __m256           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
109     __m256           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
110     __m256           dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
111     __m256           dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
112     __m256           dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
113     __m256           dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
114     __m256           velec,felec,velecsum,facel,crf,krf,krf2;
115     real             *charge;
116     int              nvdwtype;
117     __m256           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
118     int              *vdwtype;
119     real             *vdwparam;
120     __m256           one_sixth   = _mm256_set1_ps(1.0/6.0);
121     __m256           one_twelfth = _mm256_set1_ps(1.0/12.0);
122     __m256           dummy_mask,cutoff_mask;
123     __m256           signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
124     __m256           one     = _mm256_set1_ps(1.0);
125     __m256           two     = _mm256_set1_ps(2.0);
126     x                = xx[0];
127     f                = ff[0];
128
129     nri              = nlist->nri;
130     iinr             = nlist->iinr;
131     jindex           = nlist->jindex;
132     jjnr             = nlist->jjnr;
133     shiftidx         = nlist->shift;
134     gid              = nlist->gid;
135     shiftvec         = fr->shift_vec[0];
136     fshift           = fr->fshift[0];
137     facel            = _mm256_set1_ps(fr->epsfac);
138     charge           = mdatoms->chargeA;
139     krf              = _mm256_set1_ps(fr->ic->k_rf);
140     krf2             = _mm256_set1_ps(fr->ic->k_rf*2.0);
141     crf              = _mm256_set1_ps(fr->ic->c_rf);
142     nvdwtype         = fr->ntype;
143     vdwparam         = fr->nbfp;
144     vdwtype          = mdatoms->typeA;
145
146     /* Setup water-specific parameters */
147     inr              = nlist->iinr[0];
148     iq1              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
149     iq2              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
150     iq3              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
151     vdwioffsetptr0   = vdwparam+2*nvdwtype*vdwtype[inr+0];
152
153     jq1              = _mm256_set1_ps(charge[inr+1]);
154     jq2              = _mm256_set1_ps(charge[inr+2]);
155     jq3              = _mm256_set1_ps(charge[inr+3]);
156     vdwjidx0A        = 2*vdwtype[inr+0];
157     c6_00            = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
158     c12_00           = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
159     qq11             = _mm256_mul_ps(iq1,jq1);
160     qq12             = _mm256_mul_ps(iq1,jq2);
161     qq13             = _mm256_mul_ps(iq1,jq3);
162     qq21             = _mm256_mul_ps(iq2,jq1);
163     qq22             = _mm256_mul_ps(iq2,jq2);
164     qq23             = _mm256_mul_ps(iq2,jq3);
165     qq31             = _mm256_mul_ps(iq3,jq1);
166     qq32             = _mm256_mul_ps(iq3,jq2);
167     qq33             = _mm256_mul_ps(iq3,jq3);
168
169     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
170     rcutoff_scalar   = fr->rcoulomb;
171     rcutoff          = _mm256_set1_ps(rcutoff_scalar);
172     rcutoff2         = _mm256_mul_ps(rcutoff,rcutoff);
173
174     sh_vdw_invrcut6  = _mm256_set1_ps(fr->ic->sh_invrc6);
175     rvdw             = _mm256_set1_ps(fr->rvdw);
176
177     /* Avoid stupid compiler warnings */
178     jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
179     j_coord_offsetA = 0;
180     j_coord_offsetB = 0;
181     j_coord_offsetC = 0;
182     j_coord_offsetD = 0;
183     j_coord_offsetE = 0;
184     j_coord_offsetF = 0;
185     j_coord_offsetG = 0;
186     j_coord_offsetH = 0;
187
188     outeriter        = 0;
189     inneriter        = 0;
190
191     for(iidx=0;iidx<4*DIM;iidx++)
192     {
193         scratch[iidx] = 0.0;
194     }
195
196     /* Start outer loop over neighborlists */
197     for(iidx=0; iidx<nri; iidx++)
198     {
199         /* Load shift vector for this list */
200         i_shift_offset   = DIM*shiftidx[iidx];
201
202         /* Load limits for loop over neighbors */
203         j_index_start    = jindex[iidx];
204         j_index_end      = jindex[iidx+1];
205
206         /* Get outer coordinate index */
207         inr              = iinr[iidx];
208         i_coord_offset   = DIM*inr;
209
210         /* Load i particle coords and add shift vector */
211         gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
212                                                     &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
213
214         fix0             = _mm256_setzero_ps();
215         fiy0             = _mm256_setzero_ps();
216         fiz0             = _mm256_setzero_ps();
217         fix1             = _mm256_setzero_ps();
218         fiy1             = _mm256_setzero_ps();
219         fiz1             = _mm256_setzero_ps();
220         fix2             = _mm256_setzero_ps();
221         fiy2             = _mm256_setzero_ps();
222         fiz2             = _mm256_setzero_ps();
223         fix3             = _mm256_setzero_ps();
224         fiy3             = _mm256_setzero_ps();
225         fiz3             = _mm256_setzero_ps();
226
227         /* Reset potential sums */
228         velecsum         = _mm256_setzero_ps();
229         vvdwsum          = _mm256_setzero_ps();
230
231         /* Start inner kernel loop */
232         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
233         {
234
235             /* Get j neighbor index, and coordinate index */
236             jnrA             = jjnr[jidx];
237             jnrB             = jjnr[jidx+1];
238             jnrC             = jjnr[jidx+2];
239             jnrD             = jjnr[jidx+3];
240             jnrE             = jjnr[jidx+4];
241             jnrF             = jjnr[jidx+5];
242             jnrG             = jjnr[jidx+6];
243             jnrH             = jjnr[jidx+7];
244             j_coord_offsetA  = DIM*jnrA;
245             j_coord_offsetB  = DIM*jnrB;
246             j_coord_offsetC  = DIM*jnrC;
247             j_coord_offsetD  = DIM*jnrD;
248             j_coord_offsetE  = DIM*jnrE;
249             j_coord_offsetF  = DIM*jnrF;
250             j_coord_offsetG  = DIM*jnrG;
251             j_coord_offsetH  = DIM*jnrH;
252
253             /* load j atom coordinates */
254             gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
255                                                  x+j_coord_offsetC,x+j_coord_offsetD,
256                                                  x+j_coord_offsetE,x+j_coord_offsetF,
257                                                  x+j_coord_offsetG,x+j_coord_offsetH,
258                                                  &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
259                                                  &jy2,&jz2,&jx3,&jy3,&jz3);
260
261             /* Calculate displacement vector */
262             dx00             = _mm256_sub_ps(ix0,jx0);
263             dy00             = _mm256_sub_ps(iy0,jy0);
264             dz00             = _mm256_sub_ps(iz0,jz0);
265             dx11             = _mm256_sub_ps(ix1,jx1);
266             dy11             = _mm256_sub_ps(iy1,jy1);
267             dz11             = _mm256_sub_ps(iz1,jz1);
268             dx12             = _mm256_sub_ps(ix1,jx2);
269             dy12             = _mm256_sub_ps(iy1,jy2);
270             dz12             = _mm256_sub_ps(iz1,jz2);
271             dx13             = _mm256_sub_ps(ix1,jx3);
272             dy13             = _mm256_sub_ps(iy1,jy3);
273             dz13             = _mm256_sub_ps(iz1,jz3);
274             dx21             = _mm256_sub_ps(ix2,jx1);
275             dy21             = _mm256_sub_ps(iy2,jy1);
276             dz21             = _mm256_sub_ps(iz2,jz1);
277             dx22             = _mm256_sub_ps(ix2,jx2);
278             dy22             = _mm256_sub_ps(iy2,jy2);
279             dz22             = _mm256_sub_ps(iz2,jz2);
280             dx23             = _mm256_sub_ps(ix2,jx3);
281             dy23             = _mm256_sub_ps(iy2,jy3);
282             dz23             = _mm256_sub_ps(iz2,jz3);
283             dx31             = _mm256_sub_ps(ix3,jx1);
284             dy31             = _mm256_sub_ps(iy3,jy1);
285             dz31             = _mm256_sub_ps(iz3,jz1);
286             dx32             = _mm256_sub_ps(ix3,jx2);
287             dy32             = _mm256_sub_ps(iy3,jy2);
288             dz32             = _mm256_sub_ps(iz3,jz2);
289             dx33             = _mm256_sub_ps(ix3,jx3);
290             dy33             = _mm256_sub_ps(iy3,jy3);
291             dz33             = _mm256_sub_ps(iz3,jz3);
292
293             /* Calculate squared distance and things based on it */
294             rsq00            = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
295             rsq11            = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
296             rsq12            = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
297             rsq13            = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
298             rsq21            = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
299             rsq22            = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
300             rsq23            = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
301             rsq31            = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
302             rsq32            = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
303             rsq33            = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
304
305             rinv11           = gmx_mm256_invsqrt_ps(rsq11);
306             rinv12           = gmx_mm256_invsqrt_ps(rsq12);
307             rinv13           = gmx_mm256_invsqrt_ps(rsq13);
308             rinv21           = gmx_mm256_invsqrt_ps(rsq21);
309             rinv22           = gmx_mm256_invsqrt_ps(rsq22);
310             rinv23           = gmx_mm256_invsqrt_ps(rsq23);
311             rinv31           = gmx_mm256_invsqrt_ps(rsq31);
312             rinv32           = gmx_mm256_invsqrt_ps(rsq32);
313             rinv33           = gmx_mm256_invsqrt_ps(rsq33);
314
315             rinvsq00         = gmx_mm256_inv_ps(rsq00);
316             rinvsq11         = _mm256_mul_ps(rinv11,rinv11);
317             rinvsq12         = _mm256_mul_ps(rinv12,rinv12);
318             rinvsq13         = _mm256_mul_ps(rinv13,rinv13);
319             rinvsq21         = _mm256_mul_ps(rinv21,rinv21);
320             rinvsq22         = _mm256_mul_ps(rinv22,rinv22);
321             rinvsq23         = _mm256_mul_ps(rinv23,rinv23);
322             rinvsq31         = _mm256_mul_ps(rinv31,rinv31);
323             rinvsq32         = _mm256_mul_ps(rinv32,rinv32);
324             rinvsq33         = _mm256_mul_ps(rinv33,rinv33);
325
326             fjx0             = _mm256_setzero_ps();
327             fjy0             = _mm256_setzero_ps();
328             fjz0             = _mm256_setzero_ps();
329             fjx1             = _mm256_setzero_ps();
330             fjy1             = _mm256_setzero_ps();
331             fjz1             = _mm256_setzero_ps();
332             fjx2             = _mm256_setzero_ps();
333             fjy2             = _mm256_setzero_ps();
334             fjz2             = _mm256_setzero_ps();
335             fjx3             = _mm256_setzero_ps();
336             fjy3             = _mm256_setzero_ps();
337             fjz3             = _mm256_setzero_ps();
338
339             /**************************
340              * CALCULATE INTERACTIONS *
341              **************************/
342
343             if (gmx_mm256_any_lt(rsq00,rcutoff2))
344             {
345
346             /* LENNARD-JONES DISPERSION/REPULSION */
347
348             rinvsix          = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
349             vvdw6            = _mm256_mul_ps(c6_00,rinvsix);
350             vvdw12           = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
351             vvdw             = _mm256_sub_ps(_mm256_mul_ps( _mm256_sub_ps(vvdw12 , _mm256_mul_ps(c12_00,_mm256_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
352                                           _mm256_mul_ps( _mm256_sub_ps(vvdw6,_mm256_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
353             fvdw             = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
354
355             cutoff_mask      = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
356
357             /* Update potential sum for this i atom from the interaction with this j atom. */
358             vvdw             = _mm256_and_ps(vvdw,cutoff_mask);
359             vvdwsum          = _mm256_add_ps(vvdwsum,vvdw);
360
361             fscal            = fvdw;
362
363             fscal            = _mm256_and_ps(fscal,cutoff_mask);
364
365             /* Calculate temporary vectorial force */
366             tx               = _mm256_mul_ps(fscal,dx00);
367             ty               = _mm256_mul_ps(fscal,dy00);
368             tz               = _mm256_mul_ps(fscal,dz00);
369
370             /* Update vectorial force */
371             fix0             = _mm256_add_ps(fix0,tx);
372             fiy0             = _mm256_add_ps(fiy0,ty);
373             fiz0             = _mm256_add_ps(fiz0,tz);
374
375             fjx0             = _mm256_add_ps(fjx0,tx);
376             fjy0             = _mm256_add_ps(fjy0,ty);
377             fjz0             = _mm256_add_ps(fjz0,tz);
378
379             }
380
381             /**************************
382              * CALCULATE INTERACTIONS *
383              **************************/
384
385             if (gmx_mm256_any_lt(rsq11,rcutoff2))
386             {
387
388             /* REACTION-FIELD ELECTROSTATICS */
389             velec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
390             felec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
391
392             cutoff_mask      = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
393
394             /* Update potential sum for this i atom from the interaction with this j atom. */
395             velec            = _mm256_and_ps(velec,cutoff_mask);
396             velecsum         = _mm256_add_ps(velecsum,velec);
397
398             fscal            = felec;
399
400             fscal            = _mm256_and_ps(fscal,cutoff_mask);
401
402             /* Calculate temporary vectorial force */
403             tx               = _mm256_mul_ps(fscal,dx11);
404             ty               = _mm256_mul_ps(fscal,dy11);
405             tz               = _mm256_mul_ps(fscal,dz11);
406
407             /* Update vectorial force */
408             fix1             = _mm256_add_ps(fix1,tx);
409             fiy1             = _mm256_add_ps(fiy1,ty);
410             fiz1             = _mm256_add_ps(fiz1,tz);
411
412             fjx1             = _mm256_add_ps(fjx1,tx);
413             fjy1             = _mm256_add_ps(fjy1,ty);
414             fjz1             = _mm256_add_ps(fjz1,tz);
415
416             }
417
418             /**************************
419              * CALCULATE INTERACTIONS *
420              **************************/
421
422             if (gmx_mm256_any_lt(rsq12,rcutoff2))
423             {
424
425             /* REACTION-FIELD ELECTROSTATICS */
426             velec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
427             felec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
428
429             cutoff_mask      = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
430
431             /* Update potential sum for this i atom from the interaction with this j atom. */
432             velec            = _mm256_and_ps(velec,cutoff_mask);
433             velecsum         = _mm256_add_ps(velecsum,velec);
434
435             fscal            = felec;
436
437             fscal            = _mm256_and_ps(fscal,cutoff_mask);
438
439             /* Calculate temporary vectorial force */
440             tx               = _mm256_mul_ps(fscal,dx12);
441             ty               = _mm256_mul_ps(fscal,dy12);
442             tz               = _mm256_mul_ps(fscal,dz12);
443
444             /* Update vectorial force */
445             fix1             = _mm256_add_ps(fix1,tx);
446             fiy1             = _mm256_add_ps(fiy1,ty);
447             fiz1             = _mm256_add_ps(fiz1,tz);
448
449             fjx2             = _mm256_add_ps(fjx2,tx);
450             fjy2             = _mm256_add_ps(fjy2,ty);
451             fjz2             = _mm256_add_ps(fjz2,tz);
452
453             }
454
455             /**************************
456              * CALCULATE INTERACTIONS *
457              **************************/
458
459             if (gmx_mm256_any_lt(rsq13,rcutoff2))
460             {
461
462             /* REACTION-FIELD ELECTROSTATICS */
463             velec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
464             felec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
465
466             cutoff_mask      = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
467
468             /* Update potential sum for this i atom from the interaction with this j atom. */
469             velec            = _mm256_and_ps(velec,cutoff_mask);
470             velecsum         = _mm256_add_ps(velecsum,velec);
471
472             fscal            = felec;
473
474             fscal            = _mm256_and_ps(fscal,cutoff_mask);
475
476             /* Calculate temporary vectorial force */
477             tx               = _mm256_mul_ps(fscal,dx13);
478             ty               = _mm256_mul_ps(fscal,dy13);
479             tz               = _mm256_mul_ps(fscal,dz13);
480
481             /* Update vectorial force */
482             fix1             = _mm256_add_ps(fix1,tx);
483             fiy1             = _mm256_add_ps(fiy1,ty);
484             fiz1             = _mm256_add_ps(fiz1,tz);
485
486             fjx3             = _mm256_add_ps(fjx3,tx);
487             fjy3             = _mm256_add_ps(fjy3,ty);
488             fjz3             = _mm256_add_ps(fjz3,tz);
489
490             }
491
492             /**************************
493              * CALCULATE INTERACTIONS *
494              **************************/
495
496             if (gmx_mm256_any_lt(rsq21,rcutoff2))
497             {
498
499             /* REACTION-FIELD ELECTROSTATICS */
500             velec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
501             felec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
502
503             cutoff_mask      = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
504
505             /* Update potential sum for this i atom from the interaction with this j atom. */
506             velec            = _mm256_and_ps(velec,cutoff_mask);
507             velecsum         = _mm256_add_ps(velecsum,velec);
508
509             fscal            = felec;
510
511             fscal            = _mm256_and_ps(fscal,cutoff_mask);
512
513             /* Calculate temporary vectorial force */
514             tx               = _mm256_mul_ps(fscal,dx21);
515             ty               = _mm256_mul_ps(fscal,dy21);
516             tz               = _mm256_mul_ps(fscal,dz21);
517
518             /* Update vectorial force */
519             fix2             = _mm256_add_ps(fix2,tx);
520             fiy2             = _mm256_add_ps(fiy2,ty);
521             fiz2             = _mm256_add_ps(fiz2,tz);
522
523             fjx1             = _mm256_add_ps(fjx1,tx);
524             fjy1             = _mm256_add_ps(fjy1,ty);
525             fjz1             = _mm256_add_ps(fjz1,tz);
526
527             }
528
529             /**************************
530              * CALCULATE INTERACTIONS *
531              **************************/
532
533             if (gmx_mm256_any_lt(rsq22,rcutoff2))
534             {
535
536             /* REACTION-FIELD ELECTROSTATICS */
537             velec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
538             felec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
539
540             cutoff_mask      = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
541
542             /* Update potential sum for this i atom from the interaction with this j atom. */
543             velec            = _mm256_and_ps(velec,cutoff_mask);
544             velecsum         = _mm256_add_ps(velecsum,velec);
545
546             fscal            = felec;
547
548             fscal            = _mm256_and_ps(fscal,cutoff_mask);
549
550             /* Calculate temporary vectorial force */
551             tx               = _mm256_mul_ps(fscal,dx22);
552             ty               = _mm256_mul_ps(fscal,dy22);
553             tz               = _mm256_mul_ps(fscal,dz22);
554
555             /* Update vectorial force */
556             fix2             = _mm256_add_ps(fix2,tx);
557             fiy2             = _mm256_add_ps(fiy2,ty);
558             fiz2             = _mm256_add_ps(fiz2,tz);
559
560             fjx2             = _mm256_add_ps(fjx2,tx);
561             fjy2             = _mm256_add_ps(fjy2,ty);
562             fjz2             = _mm256_add_ps(fjz2,tz);
563
564             }
565
566             /**************************
567              * CALCULATE INTERACTIONS *
568              **************************/
569
570             if (gmx_mm256_any_lt(rsq23,rcutoff2))
571             {
572
573             /* REACTION-FIELD ELECTROSTATICS */
574             velec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
575             felec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
576
577             cutoff_mask      = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
578
579             /* Update potential sum for this i atom from the interaction with this j atom. */
580             velec            = _mm256_and_ps(velec,cutoff_mask);
581             velecsum         = _mm256_add_ps(velecsum,velec);
582
583             fscal            = felec;
584
585             fscal            = _mm256_and_ps(fscal,cutoff_mask);
586
587             /* Calculate temporary vectorial force */
588             tx               = _mm256_mul_ps(fscal,dx23);
589             ty               = _mm256_mul_ps(fscal,dy23);
590             tz               = _mm256_mul_ps(fscal,dz23);
591
592             /* Update vectorial force */
593             fix2             = _mm256_add_ps(fix2,tx);
594             fiy2             = _mm256_add_ps(fiy2,ty);
595             fiz2             = _mm256_add_ps(fiz2,tz);
596
597             fjx3             = _mm256_add_ps(fjx3,tx);
598             fjy3             = _mm256_add_ps(fjy3,ty);
599             fjz3             = _mm256_add_ps(fjz3,tz);
600
601             }
602
603             /**************************
604              * CALCULATE INTERACTIONS *
605              **************************/
606
607             if (gmx_mm256_any_lt(rsq31,rcutoff2))
608             {
609
610             /* REACTION-FIELD ELECTROSTATICS */
611             velec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
612             felec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
613
614             cutoff_mask      = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
615
616             /* Update potential sum for this i atom from the interaction with this j atom. */
617             velec            = _mm256_and_ps(velec,cutoff_mask);
618             velecsum         = _mm256_add_ps(velecsum,velec);
619
620             fscal            = felec;
621
622             fscal            = _mm256_and_ps(fscal,cutoff_mask);
623
624             /* Calculate temporary vectorial force */
625             tx               = _mm256_mul_ps(fscal,dx31);
626             ty               = _mm256_mul_ps(fscal,dy31);
627             tz               = _mm256_mul_ps(fscal,dz31);
628
629             /* Update vectorial force */
630             fix3             = _mm256_add_ps(fix3,tx);
631             fiy3             = _mm256_add_ps(fiy3,ty);
632             fiz3             = _mm256_add_ps(fiz3,tz);
633
634             fjx1             = _mm256_add_ps(fjx1,tx);
635             fjy1             = _mm256_add_ps(fjy1,ty);
636             fjz1             = _mm256_add_ps(fjz1,tz);
637
638             }
639
640             /**************************
641              * CALCULATE INTERACTIONS *
642              **************************/
643
644             if (gmx_mm256_any_lt(rsq32,rcutoff2))
645             {
646
647             /* REACTION-FIELD ELECTROSTATICS */
648             velec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
649             felec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
650
651             cutoff_mask      = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
652
653             /* Update potential sum for this i atom from the interaction with this j atom. */
654             velec            = _mm256_and_ps(velec,cutoff_mask);
655             velecsum         = _mm256_add_ps(velecsum,velec);
656
657             fscal            = felec;
658
659             fscal            = _mm256_and_ps(fscal,cutoff_mask);
660
661             /* Calculate temporary vectorial force */
662             tx               = _mm256_mul_ps(fscal,dx32);
663             ty               = _mm256_mul_ps(fscal,dy32);
664             tz               = _mm256_mul_ps(fscal,dz32);
665
666             /* Update vectorial force */
667             fix3             = _mm256_add_ps(fix3,tx);
668             fiy3             = _mm256_add_ps(fiy3,ty);
669             fiz3             = _mm256_add_ps(fiz3,tz);
670
671             fjx2             = _mm256_add_ps(fjx2,tx);
672             fjy2             = _mm256_add_ps(fjy2,ty);
673             fjz2             = _mm256_add_ps(fjz2,tz);
674
675             }
676
677             /**************************
678              * CALCULATE INTERACTIONS *
679              **************************/
680
681             if (gmx_mm256_any_lt(rsq33,rcutoff2))
682             {
683
684             /* REACTION-FIELD ELECTROSTATICS */
685             velec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
686             felec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
687
688             cutoff_mask      = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
689
690             /* Update potential sum for this i atom from the interaction with this j atom. */
691             velec            = _mm256_and_ps(velec,cutoff_mask);
692             velecsum         = _mm256_add_ps(velecsum,velec);
693
694             fscal            = felec;
695
696             fscal            = _mm256_and_ps(fscal,cutoff_mask);
697
698             /* Calculate temporary vectorial force */
699             tx               = _mm256_mul_ps(fscal,dx33);
700             ty               = _mm256_mul_ps(fscal,dy33);
701             tz               = _mm256_mul_ps(fscal,dz33);
702
703             /* Update vectorial force */
704             fix3             = _mm256_add_ps(fix3,tx);
705             fiy3             = _mm256_add_ps(fiy3,ty);
706             fiz3             = _mm256_add_ps(fiz3,tz);
707
708             fjx3             = _mm256_add_ps(fjx3,tx);
709             fjy3             = _mm256_add_ps(fjy3,ty);
710             fjz3             = _mm256_add_ps(fjz3,tz);
711
712             }
713
714             fjptrA             = f+j_coord_offsetA;
715             fjptrB             = f+j_coord_offsetB;
716             fjptrC             = f+j_coord_offsetC;
717             fjptrD             = f+j_coord_offsetD;
718             fjptrE             = f+j_coord_offsetE;
719             fjptrF             = f+j_coord_offsetF;
720             fjptrG             = f+j_coord_offsetG;
721             fjptrH             = f+j_coord_offsetH;
722
723             gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
724                                                       fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
725                                                       fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
726
727             /* Inner loop uses 368 flops */
728         }
729
730         if(jidx<j_index_end)
731         {
732
733             /* Get j neighbor index, and coordinate index */
734             jnrlistA         = jjnr[jidx];
735             jnrlistB         = jjnr[jidx+1];
736             jnrlistC         = jjnr[jidx+2];
737             jnrlistD         = jjnr[jidx+3];
738             jnrlistE         = jjnr[jidx+4];
739             jnrlistF         = jjnr[jidx+5];
740             jnrlistG         = jjnr[jidx+6];
741             jnrlistH         = jjnr[jidx+7];
742             /* Sign of each element will be negative for non-real atoms.
743              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
744              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
745              */
746             dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
747                                             gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
748                                             
749             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
750             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
751             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
752             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
753             jnrE       = (jnrlistE>=0) ? jnrlistE : 0;
754             jnrF       = (jnrlistF>=0) ? jnrlistF : 0;
755             jnrG       = (jnrlistG>=0) ? jnrlistG : 0;
756             jnrH       = (jnrlistH>=0) ? jnrlistH : 0;
757             j_coord_offsetA  = DIM*jnrA;
758             j_coord_offsetB  = DIM*jnrB;
759             j_coord_offsetC  = DIM*jnrC;
760             j_coord_offsetD  = DIM*jnrD;
761             j_coord_offsetE  = DIM*jnrE;
762             j_coord_offsetF  = DIM*jnrF;
763             j_coord_offsetG  = DIM*jnrG;
764             j_coord_offsetH  = DIM*jnrH;
765
766             /* load j atom coordinates */
767             gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
768                                                  x+j_coord_offsetC,x+j_coord_offsetD,
769                                                  x+j_coord_offsetE,x+j_coord_offsetF,
770                                                  x+j_coord_offsetG,x+j_coord_offsetH,
771                                                  &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
772                                                  &jy2,&jz2,&jx3,&jy3,&jz3);
773
774             /* Calculate displacement vector */
775             dx00             = _mm256_sub_ps(ix0,jx0);
776             dy00             = _mm256_sub_ps(iy0,jy0);
777             dz00             = _mm256_sub_ps(iz0,jz0);
778             dx11             = _mm256_sub_ps(ix1,jx1);
779             dy11             = _mm256_sub_ps(iy1,jy1);
780             dz11             = _mm256_sub_ps(iz1,jz1);
781             dx12             = _mm256_sub_ps(ix1,jx2);
782             dy12             = _mm256_sub_ps(iy1,jy2);
783             dz12             = _mm256_sub_ps(iz1,jz2);
784             dx13             = _mm256_sub_ps(ix1,jx3);
785             dy13             = _mm256_sub_ps(iy1,jy3);
786             dz13             = _mm256_sub_ps(iz1,jz3);
787             dx21             = _mm256_sub_ps(ix2,jx1);
788             dy21             = _mm256_sub_ps(iy2,jy1);
789             dz21             = _mm256_sub_ps(iz2,jz1);
790             dx22             = _mm256_sub_ps(ix2,jx2);
791             dy22             = _mm256_sub_ps(iy2,jy2);
792             dz22             = _mm256_sub_ps(iz2,jz2);
793             dx23             = _mm256_sub_ps(ix2,jx3);
794             dy23             = _mm256_sub_ps(iy2,jy3);
795             dz23             = _mm256_sub_ps(iz2,jz3);
796             dx31             = _mm256_sub_ps(ix3,jx1);
797             dy31             = _mm256_sub_ps(iy3,jy1);
798             dz31             = _mm256_sub_ps(iz3,jz1);
799             dx32             = _mm256_sub_ps(ix3,jx2);
800             dy32             = _mm256_sub_ps(iy3,jy2);
801             dz32             = _mm256_sub_ps(iz3,jz2);
802             dx33             = _mm256_sub_ps(ix3,jx3);
803             dy33             = _mm256_sub_ps(iy3,jy3);
804             dz33             = _mm256_sub_ps(iz3,jz3);
805
806             /* Calculate squared distance and things based on it */
807             rsq00            = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
808             rsq11            = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
809             rsq12            = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
810             rsq13            = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
811             rsq21            = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
812             rsq22            = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
813             rsq23            = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
814             rsq31            = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
815             rsq32            = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
816             rsq33            = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
817
818             rinv11           = gmx_mm256_invsqrt_ps(rsq11);
819             rinv12           = gmx_mm256_invsqrt_ps(rsq12);
820             rinv13           = gmx_mm256_invsqrt_ps(rsq13);
821             rinv21           = gmx_mm256_invsqrt_ps(rsq21);
822             rinv22           = gmx_mm256_invsqrt_ps(rsq22);
823             rinv23           = gmx_mm256_invsqrt_ps(rsq23);
824             rinv31           = gmx_mm256_invsqrt_ps(rsq31);
825             rinv32           = gmx_mm256_invsqrt_ps(rsq32);
826             rinv33           = gmx_mm256_invsqrt_ps(rsq33);
827
828             rinvsq00         = gmx_mm256_inv_ps(rsq00);
829             rinvsq11         = _mm256_mul_ps(rinv11,rinv11);
830             rinvsq12         = _mm256_mul_ps(rinv12,rinv12);
831             rinvsq13         = _mm256_mul_ps(rinv13,rinv13);
832             rinvsq21         = _mm256_mul_ps(rinv21,rinv21);
833             rinvsq22         = _mm256_mul_ps(rinv22,rinv22);
834             rinvsq23         = _mm256_mul_ps(rinv23,rinv23);
835             rinvsq31         = _mm256_mul_ps(rinv31,rinv31);
836             rinvsq32         = _mm256_mul_ps(rinv32,rinv32);
837             rinvsq33         = _mm256_mul_ps(rinv33,rinv33);
838
839             fjx0             = _mm256_setzero_ps();
840             fjy0             = _mm256_setzero_ps();
841             fjz0             = _mm256_setzero_ps();
842             fjx1             = _mm256_setzero_ps();
843             fjy1             = _mm256_setzero_ps();
844             fjz1             = _mm256_setzero_ps();
845             fjx2             = _mm256_setzero_ps();
846             fjy2             = _mm256_setzero_ps();
847             fjz2             = _mm256_setzero_ps();
848             fjx3             = _mm256_setzero_ps();
849             fjy3             = _mm256_setzero_ps();
850             fjz3             = _mm256_setzero_ps();
851
852             /**************************
853              * CALCULATE INTERACTIONS *
854              **************************/
855
856             if (gmx_mm256_any_lt(rsq00,rcutoff2))
857             {
858
859             /* LENNARD-JONES DISPERSION/REPULSION */
860
861             rinvsix          = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
862             vvdw6            = _mm256_mul_ps(c6_00,rinvsix);
863             vvdw12           = _mm256_mul_ps(c12_00,_mm256_mul_ps(rinvsix,rinvsix));
864             vvdw             = _mm256_sub_ps(_mm256_mul_ps( _mm256_sub_ps(vvdw12 , _mm256_mul_ps(c12_00,_mm256_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
865                                           _mm256_mul_ps( _mm256_sub_ps(vvdw6,_mm256_mul_ps(c6_00,sh_vdw_invrcut6)),one_sixth));
866             fvdw             = _mm256_mul_ps(_mm256_sub_ps(vvdw12,vvdw6),rinvsq00);
867
868             cutoff_mask      = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
869
870             /* Update potential sum for this i atom from the interaction with this j atom. */
871             vvdw             = _mm256_and_ps(vvdw,cutoff_mask);
872             vvdw             = _mm256_andnot_ps(dummy_mask,vvdw);
873             vvdwsum          = _mm256_add_ps(vvdwsum,vvdw);
874
875             fscal            = fvdw;
876
877             fscal            = _mm256_and_ps(fscal,cutoff_mask);
878
879             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
880
881             /* Calculate temporary vectorial force */
882             tx               = _mm256_mul_ps(fscal,dx00);
883             ty               = _mm256_mul_ps(fscal,dy00);
884             tz               = _mm256_mul_ps(fscal,dz00);
885
886             /* Update vectorial force */
887             fix0             = _mm256_add_ps(fix0,tx);
888             fiy0             = _mm256_add_ps(fiy0,ty);
889             fiz0             = _mm256_add_ps(fiz0,tz);
890
891             fjx0             = _mm256_add_ps(fjx0,tx);
892             fjy0             = _mm256_add_ps(fjy0,ty);
893             fjz0             = _mm256_add_ps(fjz0,tz);
894
895             }
896
897             /**************************
898              * CALCULATE INTERACTIONS *
899              **************************/
900
901             if (gmx_mm256_any_lt(rsq11,rcutoff2))
902             {
903
904             /* REACTION-FIELD ELECTROSTATICS */
905             velec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_add_ps(rinv11,_mm256_mul_ps(krf,rsq11)),crf));
906             felec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
907
908             cutoff_mask      = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
909
910             /* Update potential sum for this i atom from the interaction with this j atom. */
911             velec            = _mm256_and_ps(velec,cutoff_mask);
912             velec            = _mm256_andnot_ps(dummy_mask,velec);
913             velecsum         = _mm256_add_ps(velecsum,velec);
914
915             fscal            = felec;
916
917             fscal            = _mm256_and_ps(fscal,cutoff_mask);
918
919             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
920
921             /* Calculate temporary vectorial force */
922             tx               = _mm256_mul_ps(fscal,dx11);
923             ty               = _mm256_mul_ps(fscal,dy11);
924             tz               = _mm256_mul_ps(fscal,dz11);
925
926             /* Update vectorial force */
927             fix1             = _mm256_add_ps(fix1,tx);
928             fiy1             = _mm256_add_ps(fiy1,ty);
929             fiz1             = _mm256_add_ps(fiz1,tz);
930
931             fjx1             = _mm256_add_ps(fjx1,tx);
932             fjy1             = _mm256_add_ps(fjy1,ty);
933             fjz1             = _mm256_add_ps(fjz1,tz);
934
935             }
936
937             /**************************
938              * CALCULATE INTERACTIONS *
939              **************************/
940
941             if (gmx_mm256_any_lt(rsq12,rcutoff2))
942             {
943
944             /* REACTION-FIELD ELECTROSTATICS */
945             velec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_add_ps(rinv12,_mm256_mul_ps(krf,rsq12)),crf));
946             felec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
947
948             cutoff_mask      = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
949
950             /* Update potential sum for this i atom from the interaction with this j atom. */
951             velec            = _mm256_and_ps(velec,cutoff_mask);
952             velec            = _mm256_andnot_ps(dummy_mask,velec);
953             velecsum         = _mm256_add_ps(velecsum,velec);
954
955             fscal            = felec;
956
957             fscal            = _mm256_and_ps(fscal,cutoff_mask);
958
959             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
960
961             /* Calculate temporary vectorial force */
962             tx               = _mm256_mul_ps(fscal,dx12);
963             ty               = _mm256_mul_ps(fscal,dy12);
964             tz               = _mm256_mul_ps(fscal,dz12);
965
966             /* Update vectorial force */
967             fix1             = _mm256_add_ps(fix1,tx);
968             fiy1             = _mm256_add_ps(fiy1,ty);
969             fiz1             = _mm256_add_ps(fiz1,tz);
970
971             fjx2             = _mm256_add_ps(fjx2,tx);
972             fjy2             = _mm256_add_ps(fjy2,ty);
973             fjz2             = _mm256_add_ps(fjz2,tz);
974
975             }
976
977             /**************************
978              * CALCULATE INTERACTIONS *
979              **************************/
980
981             if (gmx_mm256_any_lt(rsq13,rcutoff2))
982             {
983
984             /* REACTION-FIELD ELECTROSTATICS */
985             velec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_add_ps(rinv13,_mm256_mul_ps(krf,rsq13)),crf));
986             felec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
987
988             cutoff_mask      = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
989
990             /* Update potential sum for this i atom from the interaction with this j atom. */
991             velec            = _mm256_and_ps(velec,cutoff_mask);
992             velec            = _mm256_andnot_ps(dummy_mask,velec);
993             velecsum         = _mm256_add_ps(velecsum,velec);
994
995             fscal            = felec;
996
997             fscal            = _mm256_and_ps(fscal,cutoff_mask);
998
999             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1000
1001             /* Calculate temporary vectorial force */
1002             tx               = _mm256_mul_ps(fscal,dx13);
1003             ty               = _mm256_mul_ps(fscal,dy13);
1004             tz               = _mm256_mul_ps(fscal,dz13);
1005
1006             /* Update vectorial force */
1007             fix1             = _mm256_add_ps(fix1,tx);
1008             fiy1             = _mm256_add_ps(fiy1,ty);
1009             fiz1             = _mm256_add_ps(fiz1,tz);
1010
1011             fjx3             = _mm256_add_ps(fjx3,tx);
1012             fjy3             = _mm256_add_ps(fjy3,ty);
1013             fjz3             = _mm256_add_ps(fjz3,tz);
1014
1015             }
1016
1017             /**************************
1018              * CALCULATE INTERACTIONS *
1019              **************************/
1020
1021             if (gmx_mm256_any_lt(rsq21,rcutoff2))
1022             {
1023
1024             /* REACTION-FIELD ELECTROSTATICS */
1025             velec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_add_ps(rinv21,_mm256_mul_ps(krf,rsq21)),crf));
1026             felec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1027
1028             cutoff_mask      = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1029
1030             /* Update potential sum for this i atom from the interaction with this j atom. */
1031             velec            = _mm256_and_ps(velec,cutoff_mask);
1032             velec            = _mm256_andnot_ps(dummy_mask,velec);
1033             velecsum         = _mm256_add_ps(velecsum,velec);
1034
1035             fscal            = felec;
1036
1037             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1038
1039             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1040
1041             /* Calculate temporary vectorial force */
1042             tx               = _mm256_mul_ps(fscal,dx21);
1043             ty               = _mm256_mul_ps(fscal,dy21);
1044             tz               = _mm256_mul_ps(fscal,dz21);
1045
1046             /* Update vectorial force */
1047             fix2             = _mm256_add_ps(fix2,tx);
1048             fiy2             = _mm256_add_ps(fiy2,ty);
1049             fiz2             = _mm256_add_ps(fiz2,tz);
1050
1051             fjx1             = _mm256_add_ps(fjx1,tx);
1052             fjy1             = _mm256_add_ps(fjy1,ty);
1053             fjz1             = _mm256_add_ps(fjz1,tz);
1054
1055             }
1056
1057             /**************************
1058              * CALCULATE INTERACTIONS *
1059              **************************/
1060
1061             if (gmx_mm256_any_lt(rsq22,rcutoff2))
1062             {
1063
1064             /* REACTION-FIELD ELECTROSTATICS */
1065             velec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_add_ps(rinv22,_mm256_mul_ps(krf,rsq22)),crf));
1066             felec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1067
1068             cutoff_mask      = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1069
1070             /* Update potential sum for this i atom from the interaction with this j atom. */
1071             velec            = _mm256_and_ps(velec,cutoff_mask);
1072             velec            = _mm256_andnot_ps(dummy_mask,velec);
1073             velecsum         = _mm256_add_ps(velecsum,velec);
1074
1075             fscal            = felec;
1076
1077             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1078
1079             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1080
1081             /* Calculate temporary vectorial force */
1082             tx               = _mm256_mul_ps(fscal,dx22);
1083             ty               = _mm256_mul_ps(fscal,dy22);
1084             tz               = _mm256_mul_ps(fscal,dz22);
1085
1086             /* Update vectorial force */
1087             fix2             = _mm256_add_ps(fix2,tx);
1088             fiy2             = _mm256_add_ps(fiy2,ty);
1089             fiz2             = _mm256_add_ps(fiz2,tz);
1090
1091             fjx2             = _mm256_add_ps(fjx2,tx);
1092             fjy2             = _mm256_add_ps(fjy2,ty);
1093             fjz2             = _mm256_add_ps(fjz2,tz);
1094
1095             }
1096
1097             /**************************
1098              * CALCULATE INTERACTIONS *
1099              **************************/
1100
1101             if (gmx_mm256_any_lt(rsq23,rcutoff2))
1102             {
1103
1104             /* REACTION-FIELD ELECTROSTATICS */
1105             velec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_add_ps(rinv23,_mm256_mul_ps(krf,rsq23)),crf));
1106             felec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1107
1108             cutoff_mask      = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1109
1110             /* Update potential sum for this i atom from the interaction with this j atom. */
1111             velec            = _mm256_and_ps(velec,cutoff_mask);
1112             velec            = _mm256_andnot_ps(dummy_mask,velec);
1113             velecsum         = _mm256_add_ps(velecsum,velec);
1114
1115             fscal            = felec;
1116
1117             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1118
1119             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1120
1121             /* Calculate temporary vectorial force */
1122             tx               = _mm256_mul_ps(fscal,dx23);
1123             ty               = _mm256_mul_ps(fscal,dy23);
1124             tz               = _mm256_mul_ps(fscal,dz23);
1125
1126             /* Update vectorial force */
1127             fix2             = _mm256_add_ps(fix2,tx);
1128             fiy2             = _mm256_add_ps(fiy2,ty);
1129             fiz2             = _mm256_add_ps(fiz2,tz);
1130
1131             fjx3             = _mm256_add_ps(fjx3,tx);
1132             fjy3             = _mm256_add_ps(fjy3,ty);
1133             fjz3             = _mm256_add_ps(fjz3,tz);
1134
1135             }
1136
1137             /**************************
1138              * CALCULATE INTERACTIONS *
1139              **************************/
1140
1141             if (gmx_mm256_any_lt(rsq31,rcutoff2))
1142             {
1143
1144             /* REACTION-FIELD ELECTROSTATICS */
1145             velec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_add_ps(rinv31,_mm256_mul_ps(krf,rsq31)),crf));
1146             felec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1147
1148             cutoff_mask      = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1149
1150             /* Update potential sum for this i atom from the interaction with this j atom. */
1151             velec            = _mm256_and_ps(velec,cutoff_mask);
1152             velec            = _mm256_andnot_ps(dummy_mask,velec);
1153             velecsum         = _mm256_add_ps(velecsum,velec);
1154
1155             fscal            = felec;
1156
1157             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1158
1159             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1160
1161             /* Calculate temporary vectorial force */
1162             tx               = _mm256_mul_ps(fscal,dx31);
1163             ty               = _mm256_mul_ps(fscal,dy31);
1164             tz               = _mm256_mul_ps(fscal,dz31);
1165
1166             /* Update vectorial force */
1167             fix3             = _mm256_add_ps(fix3,tx);
1168             fiy3             = _mm256_add_ps(fiy3,ty);
1169             fiz3             = _mm256_add_ps(fiz3,tz);
1170
1171             fjx1             = _mm256_add_ps(fjx1,tx);
1172             fjy1             = _mm256_add_ps(fjy1,ty);
1173             fjz1             = _mm256_add_ps(fjz1,tz);
1174
1175             }
1176
1177             /**************************
1178              * CALCULATE INTERACTIONS *
1179              **************************/
1180
1181             if (gmx_mm256_any_lt(rsq32,rcutoff2))
1182             {
1183
1184             /* REACTION-FIELD ELECTROSTATICS */
1185             velec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_add_ps(rinv32,_mm256_mul_ps(krf,rsq32)),crf));
1186             felec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1187
1188             cutoff_mask      = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1189
1190             /* Update potential sum for this i atom from the interaction with this j atom. */
1191             velec            = _mm256_and_ps(velec,cutoff_mask);
1192             velec            = _mm256_andnot_ps(dummy_mask,velec);
1193             velecsum         = _mm256_add_ps(velecsum,velec);
1194
1195             fscal            = felec;
1196
1197             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1198
1199             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1200
1201             /* Calculate temporary vectorial force */
1202             tx               = _mm256_mul_ps(fscal,dx32);
1203             ty               = _mm256_mul_ps(fscal,dy32);
1204             tz               = _mm256_mul_ps(fscal,dz32);
1205
1206             /* Update vectorial force */
1207             fix3             = _mm256_add_ps(fix3,tx);
1208             fiy3             = _mm256_add_ps(fiy3,ty);
1209             fiz3             = _mm256_add_ps(fiz3,tz);
1210
1211             fjx2             = _mm256_add_ps(fjx2,tx);
1212             fjy2             = _mm256_add_ps(fjy2,ty);
1213             fjz2             = _mm256_add_ps(fjz2,tz);
1214
1215             }
1216
1217             /**************************
1218              * CALCULATE INTERACTIONS *
1219              **************************/
1220
1221             if (gmx_mm256_any_lt(rsq33,rcutoff2))
1222             {
1223
1224             /* REACTION-FIELD ELECTROSTATICS */
1225             velec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_add_ps(rinv33,_mm256_mul_ps(krf,rsq33)),crf));
1226             felec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1227
1228             cutoff_mask      = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1229
1230             /* Update potential sum for this i atom from the interaction with this j atom. */
1231             velec            = _mm256_and_ps(velec,cutoff_mask);
1232             velec            = _mm256_andnot_ps(dummy_mask,velec);
1233             velecsum         = _mm256_add_ps(velecsum,velec);
1234
1235             fscal            = felec;
1236
1237             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1238
1239             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
1240
1241             /* Calculate temporary vectorial force */
1242             tx               = _mm256_mul_ps(fscal,dx33);
1243             ty               = _mm256_mul_ps(fscal,dy33);
1244             tz               = _mm256_mul_ps(fscal,dz33);
1245
1246             /* Update vectorial force */
1247             fix3             = _mm256_add_ps(fix3,tx);
1248             fiy3             = _mm256_add_ps(fiy3,ty);
1249             fiz3             = _mm256_add_ps(fiz3,tz);
1250
1251             fjx3             = _mm256_add_ps(fjx3,tx);
1252             fjy3             = _mm256_add_ps(fjy3,ty);
1253             fjz3             = _mm256_add_ps(fjz3,tz);
1254
1255             }
1256
1257             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1258             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1259             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1260             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1261             fjptrE             = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
1262             fjptrF             = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
1263             fjptrG             = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
1264             fjptrH             = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
1265
1266             gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1267                                                       fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1268                                                       fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1269
1270             /* Inner loop uses 368 flops */
1271         }
1272
1273         /* End of innermost loop */
1274
1275         gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1276                                                  f+i_coord_offset,fshift+i_shift_offset);
1277
1278         ggid                        = gid[iidx];
1279         /* Update potential energies */
1280         gmx_mm256_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1281         gmx_mm256_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1282
1283         /* Increment number of inner iterations */
1284         inneriter                  += j_index_end - j_index_start;
1285
1286         /* Outer loop uses 26 flops */
1287     }
1288
1289     /* Increment number of outer iterations */
1290     outeriter        += nri;
1291
1292     /* Update outer/inner flops */
1293
1294     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*368);
1295 }
1296 /*
1297  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_avx_256_single
1298  * Electrostatics interaction: ReactionField
1299  * VdW interaction:            LennardJones
1300  * Geometry:                   Water4-Water4
1301  * Calculate force/pot:        Force
1302  */
1303 void
1304 nb_kernel_ElecRFCut_VdwLJSh_GeomW4W4_F_avx_256_single
1305                     (t_nblist                    * gmx_restrict       nlist,
1306                      rvec                        * gmx_restrict          xx,
1307                      rvec                        * gmx_restrict          ff,
1308                      t_forcerec                  * gmx_restrict          fr,
1309                      t_mdatoms                   * gmx_restrict     mdatoms,
1310                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1311                      t_nrnb                      * gmx_restrict        nrnb)
1312 {
1313     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or 
1314      * just 0 for non-waters.
1315      * Suffixes A,B,C,D,E,F,G,H refer to j loop unrolling done with AVX, e.g. for the eight different
1316      * jnr indices corresponding to data put in the four positions in the SIMD register.
1317      */
1318     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1319     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1320     int              jnrA,jnrB,jnrC,jnrD;
1321     int              jnrE,jnrF,jnrG,jnrH;
1322     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1323     int              jnrlistE,jnrlistF,jnrlistG,jnrlistH;
1324     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1325     int              j_coord_offsetE,j_coord_offsetF,j_coord_offsetG,j_coord_offsetH;
1326     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1327     real             rcutoff_scalar;
1328     real             *shiftvec,*fshift,*x,*f;
1329     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD,*fjptrE,*fjptrF,*fjptrG,*fjptrH;
1330     real             scratch[4*DIM];
1331     __m256           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1332     real *           vdwioffsetptr0;
1333     __m256           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1334     real *           vdwioffsetptr1;
1335     __m256           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1336     real *           vdwioffsetptr2;
1337     __m256           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1338     real *           vdwioffsetptr3;
1339     __m256           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1340     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D,vdwjidx0E,vdwjidx0F,vdwjidx0G,vdwjidx0H;
1341     __m256           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1342     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D,vdwjidx1E,vdwjidx1F,vdwjidx1G,vdwjidx1H;
1343     __m256           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1344     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D,vdwjidx2E,vdwjidx2F,vdwjidx2G,vdwjidx2H;
1345     __m256           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1346     int              vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D,vdwjidx3E,vdwjidx3F,vdwjidx3G,vdwjidx3H;
1347     __m256           jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1348     __m256           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1349     __m256           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1350     __m256           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1351     __m256           dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1352     __m256           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1353     __m256           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1354     __m256           dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1355     __m256           dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1356     __m256           dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1357     __m256           dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1358     __m256           velec,felec,velecsum,facel,crf,krf,krf2;
1359     real             *charge;
1360     int              nvdwtype;
1361     __m256           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1362     int              *vdwtype;
1363     real             *vdwparam;
1364     __m256           one_sixth   = _mm256_set1_ps(1.0/6.0);
1365     __m256           one_twelfth = _mm256_set1_ps(1.0/12.0);
1366     __m256           dummy_mask,cutoff_mask;
1367     __m256           signbit = _mm256_castsi256_ps( _mm256_set1_epi32(0x80000000) );
1368     __m256           one     = _mm256_set1_ps(1.0);
1369     __m256           two     = _mm256_set1_ps(2.0);
1370     x                = xx[0];
1371     f                = ff[0];
1372
1373     nri              = nlist->nri;
1374     iinr             = nlist->iinr;
1375     jindex           = nlist->jindex;
1376     jjnr             = nlist->jjnr;
1377     shiftidx         = nlist->shift;
1378     gid              = nlist->gid;
1379     shiftvec         = fr->shift_vec[0];
1380     fshift           = fr->fshift[0];
1381     facel            = _mm256_set1_ps(fr->epsfac);
1382     charge           = mdatoms->chargeA;
1383     krf              = _mm256_set1_ps(fr->ic->k_rf);
1384     krf2             = _mm256_set1_ps(fr->ic->k_rf*2.0);
1385     crf              = _mm256_set1_ps(fr->ic->c_rf);
1386     nvdwtype         = fr->ntype;
1387     vdwparam         = fr->nbfp;
1388     vdwtype          = mdatoms->typeA;
1389
1390     /* Setup water-specific parameters */
1391     inr              = nlist->iinr[0];
1392     iq1              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+1]));
1393     iq2              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+2]));
1394     iq3              = _mm256_mul_ps(facel,_mm256_set1_ps(charge[inr+3]));
1395     vdwioffsetptr0   = vdwparam+2*nvdwtype*vdwtype[inr+0];
1396
1397     jq1              = _mm256_set1_ps(charge[inr+1]);
1398     jq2              = _mm256_set1_ps(charge[inr+2]);
1399     jq3              = _mm256_set1_ps(charge[inr+3]);
1400     vdwjidx0A        = 2*vdwtype[inr+0];
1401     c6_00            = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A]);
1402     c12_00           = _mm256_set1_ps(vdwioffsetptr0[vdwjidx0A+1]);
1403     qq11             = _mm256_mul_ps(iq1,jq1);
1404     qq12             = _mm256_mul_ps(iq1,jq2);
1405     qq13             = _mm256_mul_ps(iq1,jq3);
1406     qq21             = _mm256_mul_ps(iq2,jq1);
1407     qq22             = _mm256_mul_ps(iq2,jq2);
1408     qq23             = _mm256_mul_ps(iq2,jq3);
1409     qq31             = _mm256_mul_ps(iq3,jq1);
1410     qq32             = _mm256_mul_ps(iq3,jq2);
1411     qq33             = _mm256_mul_ps(iq3,jq3);
1412
1413     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1414     rcutoff_scalar   = fr->rcoulomb;
1415     rcutoff          = _mm256_set1_ps(rcutoff_scalar);
1416     rcutoff2         = _mm256_mul_ps(rcutoff,rcutoff);
1417
1418     sh_vdw_invrcut6  = _mm256_set1_ps(fr->ic->sh_invrc6);
1419     rvdw             = _mm256_set1_ps(fr->rvdw);
1420
1421     /* Avoid stupid compiler warnings */
1422     jnrA = jnrB = jnrC = jnrD = jnrE = jnrF = jnrG = jnrH = 0;
1423     j_coord_offsetA = 0;
1424     j_coord_offsetB = 0;
1425     j_coord_offsetC = 0;
1426     j_coord_offsetD = 0;
1427     j_coord_offsetE = 0;
1428     j_coord_offsetF = 0;
1429     j_coord_offsetG = 0;
1430     j_coord_offsetH = 0;
1431
1432     outeriter        = 0;
1433     inneriter        = 0;
1434
1435     for(iidx=0;iidx<4*DIM;iidx++)
1436     {
1437         scratch[iidx] = 0.0;
1438     }
1439
1440     /* Start outer loop over neighborlists */
1441     for(iidx=0; iidx<nri; iidx++)
1442     {
1443         /* Load shift vector for this list */
1444         i_shift_offset   = DIM*shiftidx[iidx];
1445
1446         /* Load limits for loop over neighbors */
1447         j_index_start    = jindex[iidx];
1448         j_index_end      = jindex[iidx+1];
1449
1450         /* Get outer coordinate index */
1451         inr              = iinr[iidx];
1452         i_coord_offset   = DIM*inr;
1453
1454         /* Load i particle coords and add shift vector */
1455         gmx_mm256_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1456                                                     &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1457
1458         fix0             = _mm256_setzero_ps();
1459         fiy0             = _mm256_setzero_ps();
1460         fiz0             = _mm256_setzero_ps();
1461         fix1             = _mm256_setzero_ps();
1462         fiy1             = _mm256_setzero_ps();
1463         fiz1             = _mm256_setzero_ps();
1464         fix2             = _mm256_setzero_ps();
1465         fiy2             = _mm256_setzero_ps();
1466         fiz2             = _mm256_setzero_ps();
1467         fix3             = _mm256_setzero_ps();
1468         fiy3             = _mm256_setzero_ps();
1469         fiz3             = _mm256_setzero_ps();
1470
1471         /* Start inner kernel loop */
1472         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+7]>=0; jidx+=8)
1473         {
1474
1475             /* Get j neighbor index, and coordinate index */
1476             jnrA             = jjnr[jidx];
1477             jnrB             = jjnr[jidx+1];
1478             jnrC             = jjnr[jidx+2];
1479             jnrD             = jjnr[jidx+3];
1480             jnrE             = jjnr[jidx+4];
1481             jnrF             = jjnr[jidx+5];
1482             jnrG             = jjnr[jidx+6];
1483             jnrH             = jjnr[jidx+7];
1484             j_coord_offsetA  = DIM*jnrA;
1485             j_coord_offsetB  = DIM*jnrB;
1486             j_coord_offsetC  = DIM*jnrC;
1487             j_coord_offsetD  = DIM*jnrD;
1488             j_coord_offsetE  = DIM*jnrE;
1489             j_coord_offsetF  = DIM*jnrF;
1490             j_coord_offsetG  = DIM*jnrG;
1491             j_coord_offsetH  = DIM*jnrH;
1492
1493             /* load j atom coordinates */
1494             gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1495                                                  x+j_coord_offsetC,x+j_coord_offsetD,
1496                                                  x+j_coord_offsetE,x+j_coord_offsetF,
1497                                                  x+j_coord_offsetG,x+j_coord_offsetH,
1498                                                  &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1499                                                  &jy2,&jz2,&jx3,&jy3,&jz3);
1500
1501             /* Calculate displacement vector */
1502             dx00             = _mm256_sub_ps(ix0,jx0);
1503             dy00             = _mm256_sub_ps(iy0,jy0);
1504             dz00             = _mm256_sub_ps(iz0,jz0);
1505             dx11             = _mm256_sub_ps(ix1,jx1);
1506             dy11             = _mm256_sub_ps(iy1,jy1);
1507             dz11             = _mm256_sub_ps(iz1,jz1);
1508             dx12             = _mm256_sub_ps(ix1,jx2);
1509             dy12             = _mm256_sub_ps(iy1,jy2);
1510             dz12             = _mm256_sub_ps(iz1,jz2);
1511             dx13             = _mm256_sub_ps(ix1,jx3);
1512             dy13             = _mm256_sub_ps(iy1,jy3);
1513             dz13             = _mm256_sub_ps(iz1,jz3);
1514             dx21             = _mm256_sub_ps(ix2,jx1);
1515             dy21             = _mm256_sub_ps(iy2,jy1);
1516             dz21             = _mm256_sub_ps(iz2,jz1);
1517             dx22             = _mm256_sub_ps(ix2,jx2);
1518             dy22             = _mm256_sub_ps(iy2,jy2);
1519             dz22             = _mm256_sub_ps(iz2,jz2);
1520             dx23             = _mm256_sub_ps(ix2,jx3);
1521             dy23             = _mm256_sub_ps(iy2,jy3);
1522             dz23             = _mm256_sub_ps(iz2,jz3);
1523             dx31             = _mm256_sub_ps(ix3,jx1);
1524             dy31             = _mm256_sub_ps(iy3,jy1);
1525             dz31             = _mm256_sub_ps(iz3,jz1);
1526             dx32             = _mm256_sub_ps(ix3,jx2);
1527             dy32             = _mm256_sub_ps(iy3,jy2);
1528             dz32             = _mm256_sub_ps(iz3,jz2);
1529             dx33             = _mm256_sub_ps(ix3,jx3);
1530             dy33             = _mm256_sub_ps(iy3,jy3);
1531             dz33             = _mm256_sub_ps(iz3,jz3);
1532
1533             /* Calculate squared distance and things based on it */
1534             rsq00            = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1535             rsq11            = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1536             rsq12            = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1537             rsq13            = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1538             rsq21            = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1539             rsq22            = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
1540             rsq23            = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
1541             rsq31            = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
1542             rsq32            = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
1543             rsq33            = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
1544
1545             rinv11           = gmx_mm256_invsqrt_ps(rsq11);
1546             rinv12           = gmx_mm256_invsqrt_ps(rsq12);
1547             rinv13           = gmx_mm256_invsqrt_ps(rsq13);
1548             rinv21           = gmx_mm256_invsqrt_ps(rsq21);
1549             rinv22           = gmx_mm256_invsqrt_ps(rsq22);
1550             rinv23           = gmx_mm256_invsqrt_ps(rsq23);
1551             rinv31           = gmx_mm256_invsqrt_ps(rsq31);
1552             rinv32           = gmx_mm256_invsqrt_ps(rsq32);
1553             rinv33           = gmx_mm256_invsqrt_ps(rsq33);
1554
1555             rinvsq00         = gmx_mm256_inv_ps(rsq00);
1556             rinvsq11         = _mm256_mul_ps(rinv11,rinv11);
1557             rinvsq12         = _mm256_mul_ps(rinv12,rinv12);
1558             rinvsq13         = _mm256_mul_ps(rinv13,rinv13);
1559             rinvsq21         = _mm256_mul_ps(rinv21,rinv21);
1560             rinvsq22         = _mm256_mul_ps(rinv22,rinv22);
1561             rinvsq23         = _mm256_mul_ps(rinv23,rinv23);
1562             rinvsq31         = _mm256_mul_ps(rinv31,rinv31);
1563             rinvsq32         = _mm256_mul_ps(rinv32,rinv32);
1564             rinvsq33         = _mm256_mul_ps(rinv33,rinv33);
1565
1566             fjx0             = _mm256_setzero_ps();
1567             fjy0             = _mm256_setzero_ps();
1568             fjz0             = _mm256_setzero_ps();
1569             fjx1             = _mm256_setzero_ps();
1570             fjy1             = _mm256_setzero_ps();
1571             fjz1             = _mm256_setzero_ps();
1572             fjx2             = _mm256_setzero_ps();
1573             fjy2             = _mm256_setzero_ps();
1574             fjz2             = _mm256_setzero_ps();
1575             fjx3             = _mm256_setzero_ps();
1576             fjy3             = _mm256_setzero_ps();
1577             fjz3             = _mm256_setzero_ps();
1578
1579             /**************************
1580              * CALCULATE INTERACTIONS *
1581              **************************/
1582
1583             if (gmx_mm256_any_lt(rsq00,rcutoff2))
1584             {
1585
1586             /* LENNARD-JONES DISPERSION/REPULSION */
1587
1588             rinvsix          = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1589             fvdw             = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
1590
1591             cutoff_mask      = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
1592
1593             fscal            = fvdw;
1594
1595             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1596
1597             /* Calculate temporary vectorial force */
1598             tx               = _mm256_mul_ps(fscal,dx00);
1599             ty               = _mm256_mul_ps(fscal,dy00);
1600             tz               = _mm256_mul_ps(fscal,dz00);
1601
1602             /* Update vectorial force */
1603             fix0             = _mm256_add_ps(fix0,tx);
1604             fiy0             = _mm256_add_ps(fiy0,ty);
1605             fiz0             = _mm256_add_ps(fiz0,tz);
1606
1607             fjx0             = _mm256_add_ps(fjx0,tx);
1608             fjy0             = _mm256_add_ps(fjy0,ty);
1609             fjz0             = _mm256_add_ps(fjz0,tz);
1610
1611             }
1612
1613             /**************************
1614              * CALCULATE INTERACTIONS *
1615              **************************/
1616
1617             if (gmx_mm256_any_lt(rsq11,rcutoff2))
1618             {
1619
1620             /* REACTION-FIELD ELECTROSTATICS */
1621             felec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
1622
1623             cutoff_mask      = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
1624
1625             fscal            = felec;
1626
1627             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1628
1629             /* Calculate temporary vectorial force */
1630             tx               = _mm256_mul_ps(fscal,dx11);
1631             ty               = _mm256_mul_ps(fscal,dy11);
1632             tz               = _mm256_mul_ps(fscal,dz11);
1633
1634             /* Update vectorial force */
1635             fix1             = _mm256_add_ps(fix1,tx);
1636             fiy1             = _mm256_add_ps(fiy1,ty);
1637             fiz1             = _mm256_add_ps(fiz1,tz);
1638
1639             fjx1             = _mm256_add_ps(fjx1,tx);
1640             fjy1             = _mm256_add_ps(fjy1,ty);
1641             fjz1             = _mm256_add_ps(fjz1,tz);
1642
1643             }
1644
1645             /**************************
1646              * CALCULATE INTERACTIONS *
1647              **************************/
1648
1649             if (gmx_mm256_any_lt(rsq12,rcutoff2))
1650             {
1651
1652             /* REACTION-FIELD ELECTROSTATICS */
1653             felec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
1654
1655             cutoff_mask      = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
1656
1657             fscal            = felec;
1658
1659             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1660
1661             /* Calculate temporary vectorial force */
1662             tx               = _mm256_mul_ps(fscal,dx12);
1663             ty               = _mm256_mul_ps(fscal,dy12);
1664             tz               = _mm256_mul_ps(fscal,dz12);
1665
1666             /* Update vectorial force */
1667             fix1             = _mm256_add_ps(fix1,tx);
1668             fiy1             = _mm256_add_ps(fiy1,ty);
1669             fiz1             = _mm256_add_ps(fiz1,tz);
1670
1671             fjx2             = _mm256_add_ps(fjx2,tx);
1672             fjy2             = _mm256_add_ps(fjy2,ty);
1673             fjz2             = _mm256_add_ps(fjz2,tz);
1674
1675             }
1676
1677             /**************************
1678              * CALCULATE INTERACTIONS *
1679              **************************/
1680
1681             if (gmx_mm256_any_lt(rsq13,rcutoff2))
1682             {
1683
1684             /* REACTION-FIELD ELECTROSTATICS */
1685             felec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
1686
1687             cutoff_mask      = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
1688
1689             fscal            = felec;
1690
1691             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1692
1693             /* Calculate temporary vectorial force */
1694             tx               = _mm256_mul_ps(fscal,dx13);
1695             ty               = _mm256_mul_ps(fscal,dy13);
1696             tz               = _mm256_mul_ps(fscal,dz13);
1697
1698             /* Update vectorial force */
1699             fix1             = _mm256_add_ps(fix1,tx);
1700             fiy1             = _mm256_add_ps(fiy1,ty);
1701             fiz1             = _mm256_add_ps(fiz1,tz);
1702
1703             fjx3             = _mm256_add_ps(fjx3,tx);
1704             fjy3             = _mm256_add_ps(fjy3,ty);
1705             fjz3             = _mm256_add_ps(fjz3,tz);
1706
1707             }
1708
1709             /**************************
1710              * CALCULATE INTERACTIONS *
1711              **************************/
1712
1713             if (gmx_mm256_any_lt(rsq21,rcutoff2))
1714             {
1715
1716             /* REACTION-FIELD ELECTROSTATICS */
1717             felec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
1718
1719             cutoff_mask      = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
1720
1721             fscal            = felec;
1722
1723             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1724
1725             /* Calculate temporary vectorial force */
1726             tx               = _mm256_mul_ps(fscal,dx21);
1727             ty               = _mm256_mul_ps(fscal,dy21);
1728             tz               = _mm256_mul_ps(fscal,dz21);
1729
1730             /* Update vectorial force */
1731             fix2             = _mm256_add_ps(fix2,tx);
1732             fiy2             = _mm256_add_ps(fiy2,ty);
1733             fiz2             = _mm256_add_ps(fiz2,tz);
1734
1735             fjx1             = _mm256_add_ps(fjx1,tx);
1736             fjy1             = _mm256_add_ps(fjy1,ty);
1737             fjz1             = _mm256_add_ps(fjz1,tz);
1738
1739             }
1740
1741             /**************************
1742              * CALCULATE INTERACTIONS *
1743              **************************/
1744
1745             if (gmx_mm256_any_lt(rsq22,rcutoff2))
1746             {
1747
1748             /* REACTION-FIELD ELECTROSTATICS */
1749             felec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
1750
1751             cutoff_mask      = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
1752
1753             fscal            = felec;
1754
1755             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1756
1757             /* Calculate temporary vectorial force */
1758             tx               = _mm256_mul_ps(fscal,dx22);
1759             ty               = _mm256_mul_ps(fscal,dy22);
1760             tz               = _mm256_mul_ps(fscal,dz22);
1761
1762             /* Update vectorial force */
1763             fix2             = _mm256_add_ps(fix2,tx);
1764             fiy2             = _mm256_add_ps(fiy2,ty);
1765             fiz2             = _mm256_add_ps(fiz2,tz);
1766
1767             fjx2             = _mm256_add_ps(fjx2,tx);
1768             fjy2             = _mm256_add_ps(fjy2,ty);
1769             fjz2             = _mm256_add_ps(fjz2,tz);
1770
1771             }
1772
1773             /**************************
1774              * CALCULATE INTERACTIONS *
1775              **************************/
1776
1777             if (gmx_mm256_any_lt(rsq23,rcutoff2))
1778             {
1779
1780             /* REACTION-FIELD ELECTROSTATICS */
1781             felec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
1782
1783             cutoff_mask      = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
1784
1785             fscal            = felec;
1786
1787             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1788
1789             /* Calculate temporary vectorial force */
1790             tx               = _mm256_mul_ps(fscal,dx23);
1791             ty               = _mm256_mul_ps(fscal,dy23);
1792             tz               = _mm256_mul_ps(fscal,dz23);
1793
1794             /* Update vectorial force */
1795             fix2             = _mm256_add_ps(fix2,tx);
1796             fiy2             = _mm256_add_ps(fiy2,ty);
1797             fiz2             = _mm256_add_ps(fiz2,tz);
1798
1799             fjx3             = _mm256_add_ps(fjx3,tx);
1800             fjy3             = _mm256_add_ps(fjy3,ty);
1801             fjz3             = _mm256_add_ps(fjz3,tz);
1802
1803             }
1804
1805             /**************************
1806              * CALCULATE INTERACTIONS *
1807              **************************/
1808
1809             if (gmx_mm256_any_lt(rsq31,rcutoff2))
1810             {
1811
1812             /* REACTION-FIELD ELECTROSTATICS */
1813             felec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
1814
1815             cutoff_mask      = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
1816
1817             fscal            = felec;
1818
1819             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1820
1821             /* Calculate temporary vectorial force */
1822             tx               = _mm256_mul_ps(fscal,dx31);
1823             ty               = _mm256_mul_ps(fscal,dy31);
1824             tz               = _mm256_mul_ps(fscal,dz31);
1825
1826             /* Update vectorial force */
1827             fix3             = _mm256_add_ps(fix3,tx);
1828             fiy3             = _mm256_add_ps(fiy3,ty);
1829             fiz3             = _mm256_add_ps(fiz3,tz);
1830
1831             fjx1             = _mm256_add_ps(fjx1,tx);
1832             fjy1             = _mm256_add_ps(fjy1,ty);
1833             fjz1             = _mm256_add_ps(fjz1,tz);
1834
1835             }
1836
1837             /**************************
1838              * CALCULATE INTERACTIONS *
1839              **************************/
1840
1841             if (gmx_mm256_any_lt(rsq32,rcutoff2))
1842             {
1843
1844             /* REACTION-FIELD ELECTROSTATICS */
1845             felec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
1846
1847             cutoff_mask      = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
1848
1849             fscal            = felec;
1850
1851             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1852
1853             /* Calculate temporary vectorial force */
1854             tx               = _mm256_mul_ps(fscal,dx32);
1855             ty               = _mm256_mul_ps(fscal,dy32);
1856             tz               = _mm256_mul_ps(fscal,dz32);
1857
1858             /* Update vectorial force */
1859             fix3             = _mm256_add_ps(fix3,tx);
1860             fiy3             = _mm256_add_ps(fiy3,ty);
1861             fiz3             = _mm256_add_ps(fiz3,tz);
1862
1863             fjx2             = _mm256_add_ps(fjx2,tx);
1864             fjy2             = _mm256_add_ps(fjy2,ty);
1865             fjz2             = _mm256_add_ps(fjz2,tz);
1866
1867             }
1868
1869             /**************************
1870              * CALCULATE INTERACTIONS *
1871              **************************/
1872
1873             if (gmx_mm256_any_lt(rsq33,rcutoff2))
1874             {
1875
1876             /* REACTION-FIELD ELECTROSTATICS */
1877             felec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
1878
1879             cutoff_mask      = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
1880
1881             fscal            = felec;
1882
1883             fscal            = _mm256_and_ps(fscal,cutoff_mask);
1884
1885             /* Calculate temporary vectorial force */
1886             tx               = _mm256_mul_ps(fscal,dx33);
1887             ty               = _mm256_mul_ps(fscal,dy33);
1888             tz               = _mm256_mul_ps(fscal,dz33);
1889
1890             /* Update vectorial force */
1891             fix3             = _mm256_add_ps(fix3,tx);
1892             fiy3             = _mm256_add_ps(fiy3,ty);
1893             fiz3             = _mm256_add_ps(fiz3,tz);
1894
1895             fjx3             = _mm256_add_ps(fjx3,tx);
1896             fjy3             = _mm256_add_ps(fjy3,ty);
1897             fjz3             = _mm256_add_ps(fjz3,tz);
1898
1899             }
1900
1901             fjptrA             = f+j_coord_offsetA;
1902             fjptrB             = f+j_coord_offsetB;
1903             fjptrC             = f+j_coord_offsetC;
1904             fjptrD             = f+j_coord_offsetD;
1905             fjptrE             = f+j_coord_offsetE;
1906             fjptrF             = f+j_coord_offsetF;
1907             fjptrG             = f+j_coord_offsetG;
1908             fjptrH             = f+j_coord_offsetH;
1909
1910             gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
1911                                                       fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1912                                                       fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1913
1914             /* Inner loop uses 303 flops */
1915         }
1916
1917         if(jidx<j_index_end)
1918         {
1919
1920             /* Get j neighbor index, and coordinate index */
1921             jnrlistA         = jjnr[jidx];
1922             jnrlistB         = jjnr[jidx+1];
1923             jnrlistC         = jjnr[jidx+2];
1924             jnrlistD         = jjnr[jidx+3];
1925             jnrlistE         = jjnr[jidx+4];
1926             jnrlistF         = jjnr[jidx+5];
1927             jnrlistG         = jjnr[jidx+6];
1928             jnrlistH         = jjnr[jidx+7];
1929             /* Sign of each element will be negative for non-real atoms.
1930              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1931              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1932              */
1933             dummy_mask = gmx_mm256_set_m128(gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx+4)),_mm_setzero_si128())),
1934                                             gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())));
1935                                             
1936             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
1937             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
1938             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
1939             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
1940             jnrE       = (jnrlistE>=0) ? jnrlistE : 0;
1941             jnrF       = (jnrlistF>=0) ? jnrlistF : 0;
1942             jnrG       = (jnrlistG>=0) ? jnrlistG : 0;
1943             jnrH       = (jnrlistH>=0) ? jnrlistH : 0;
1944             j_coord_offsetA  = DIM*jnrA;
1945             j_coord_offsetB  = DIM*jnrB;
1946             j_coord_offsetC  = DIM*jnrC;
1947             j_coord_offsetD  = DIM*jnrD;
1948             j_coord_offsetE  = DIM*jnrE;
1949             j_coord_offsetF  = DIM*jnrF;
1950             j_coord_offsetG  = DIM*jnrG;
1951             j_coord_offsetH  = DIM*jnrH;
1952
1953             /* load j atom coordinates */
1954             gmx_mm256_load_4rvec_8ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1955                                                  x+j_coord_offsetC,x+j_coord_offsetD,
1956                                                  x+j_coord_offsetE,x+j_coord_offsetF,
1957                                                  x+j_coord_offsetG,x+j_coord_offsetH,
1958                                                  &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1959                                                  &jy2,&jz2,&jx3,&jy3,&jz3);
1960
1961             /* Calculate displacement vector */
1962             dx00             = _mm256_sub_ps(ix0,jx0);
1963             dy00             = _mm256_sub_ps(iy0,jy0);
1964             dz00             = _mm256_sub_ps(iz0,jz0);
1965             dx11             = _mm256_sub_ps(ix1,jx1);
1966             dy11             = _mm256_sub_ps(iy1,jy1);
1967             dz11             = _mm256_sub_ps(iz1,jz1);
1968             dx12             = _mm256_sub_ps(ix1,jx2);
1969             dy12             = _mm256_sub_ps(iy1,jy2);
1970             dz12             = _mm256_sub_ps(iz1,jz2);
1971             dx13             = _mm256_sub_ps(ix1,jx3);
1972             dy13             = _mm256_sub_ps(iy1,jy3);
1973             dz13             = _mm256_sub_ps(iz1,jz3);
1974             dx21             = _mm256_sub_ps(ix2,jx1);
1975             dy21             = _mm256_sub_ps(iy2,jy1);
1976             dz21             = _mm256_sub_ps(iz2,jz1);
1977             dx22             = _mm256_sub_ps(ix2,jx2);
1978             dy22             = _mm256_sub_ps(iy2,jy2);
1979             dz22             = _mm256_sub_ps(iz2,jz2);
1980             dx23             = _mm256_sub_ps(ix2,jx3);
1981             dy23             = _mm256_sub_ps(iy2,jy3);
1982             dz23             = _mm256_sub_ps(iz2,jz3);
1983             dx31             = _mm256_sub_ps(ix3,jx1);
1984             dy31             = _mm256_sub_ps(iy3,jy1);
1985             dz31             = _mm256_sub_ps(iz3,jz1);
1986             dx32             = _mm256_sub_ps(ix3,jx2);
1987             dy32             = _mm256_sub_ps(iy3,jy2);
1988             dz32             = _mm256_sub_ps(iz3,jz2);
1989             dx33             = _mm256_sub_ps(ix3,jx3);
1990             dy33             = _mm256_sub_ps(iy3,jy3);
1991             dz33             = _mm256_sub_ps(iz3,jz3);
1992
1993             /* Calculate squared distance and things based on it */
1994             rsq00            = gmx_mm256_calc_rsq_ps(dx00,dy00,dz00);
1995             rsq11            = gmx_mm256_calc_rsq_ps(dx11,dy11,dz11);
1996             rsq12            = gmx_mm256_calc_rsq_ps(dx12,dy12,dz12);
1997             rsq13            = gmx_mm256_calc_rsq_ps(dx13,dy13,dz13);
1998             rsq21            = gmx_mm256_calc_rsq_ps(dx21,dy21,dz21);
1999             rsq22            = gmx_mm256_calc_rsq_ps(dx22,dy22,dz22);
2000             rsq23            = gmx_mm256_calc_rsq_ps(dx23,dy23,dz23);
2001             rsq31            = gmx_mm256_calc_rsq_ps(dx31,dy31,dz31);
2002             rsq32            = gmx_mm256_calc_rsq_ps(dx32,dy32,dz32);
2003             rsq33            = gmx_mm256_calc_rsq_ps(dx33,dy33,dz33);
2004
2005             rinv11           = gmx_mm256_invsqrt_ps(rsq11);
2006             rinv12           = gmx_mm256_invsqrt_ps(rsq12);
2007             rinv13           = gmx_mm256_invsqrt_ps(rsq13);
2008             rinv21           = gmx_mm256_invsqrt_ps(rsq21);
2009             rinv22           = gmx_mm256_invsqrt_ps(rsq22);
2010             rinv23           = gmx_mm256_invsqrt_ps(rsq23);
2011             rinv31           = gmx_mm256_invsqrt_ps(rsq31);
2012             rinv32           = gmx_mm256_invsqrt_ps(rsq32);
2013             rinv33           = gmx_mm256_invsqrt_ps(rsq33);
2014
2015             rinvsq00         = gmx_mm256_inv_ps(rsq00);
2016             rinvsq11         = _mm256_mul_ps(rinv11,rinv11);
2017             rinvsq12         = _mm256_mul_ps(rinv12,rinv12);
2018             rinvsq13         = _mm256_mul_ps(rinv13,rinv13);
2019             rinvsq21         = _mm256_mul_ps(rinv21,rinv21);
2020             rinvsq22         = _mm256_mul_ps(rinv22,rinv22);
2021             rinvsq23         = _mm256_mul_ps(rinv23,rinv23);
2022             rinvsq31         = _mm256_mul_ps(rinv31,rinv31);
2023             rinvsq32         = _mm256_mul_ps(rinv32,rinv32);
2024             rinvsq33         = _mm256_mul_ps(rinv33,rinv33);
2025
2026             fjx0             = _mm256_setzero_ps();
2027             fjy0             = _mm256_setzero_ps();
2028             fjz0             = _mm256_setzero_ps();
2029             fjx1             = _mm256_setzero_ps();
2030             fjy1             = _mm256_setzero_ps();
2031             fjz1             = _mm256_setzero_ps();
2032             fjx2             = _mm256_setzero_ps();
2033             fjy2             = _mm256_setzero_ps();
2034             fjz2             = _mm256_setzero_ps();
2035             fjx3             = _mm256_setzero_ps();
2036             fjy3             = _mm256_setzero_ps();
2037             fjz3             = _mm256_setzero_ps();
2038
2039             /**************************
2040              * CALCULATE INTERACTIONS *
2041              **************************/
2042
2043             if (gmx_mm256_any_lt(rsq00,rcutoff2))
2044             {
2045
2046             /* LENNARD-JONES DISPERSION/REPULSION */
2047
2048             rinvsix          = _mm256_mul_ps(_mm256_mul_ps(rinvsq00,rinvsq00),rinvsq00);
2049             fvdw             = _mm256_mul_ps(_mm256_sub_ps(_mm256_mul_ps(c12_00,rinvsix),c6_00),_mm256_mul_ps(rinvsix,rinvsq00));
2050
2051             cutoff_mask      = _mm256_cmp_ps(rsq00,rcutoff2,_CMP_LT_OQ);
2052
2053             fscal            = fvdw;
2054
2055             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2056
2057             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2058
2059             /* Calculate temporary vectorial force */
2060             tx               = _mm256_mul_ps(fscal,dx00);
2061             ty               = _mm256_mul_ps(fscal,dy00);
2062             tz               = _mm256_mul_ps(fscal,dz00);
2063
2064             /* Update vectorial force */
2065             fix0             = _mm256_add_ps(fix0,tx);
2066             fiy0             = _mm256_add_ps(fiy0,ty);
2067             fiz0             = _mm256_add_ps(fiz0,tz);
2068
2069             fjx0             = _mm256_add_ps(fjx0,tx);
2070             fjy0             = _mm256_add_ps(fjy0,ty);
2071             fjz0             = _mm256_add_ps(fjz0,tz);
2072
2073             }
2074
2075             /**************************
2076              * CALCULATE INTERACTIONS *
2077              **************************/
2078
2079             if (gmx_mm256_any_lt(rsq11,rcutoff2))
2080             {
2081
2082             /* REACTION-FIELD ELECTROSTATICS */
2083             felec            = _mm256_mul_ps(qq11,_mm256_sub_ps(_mm256_mul_ps(rinv11,rinvsq11),krf2));
2084
2085             cutoff_mask      = _mm256_cmp_ps(rsq11,rcutoff2,_CMP_LT_OQ);
2086
2087             fscal            = felec;
2088
2089             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2090
2091             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2092
2093             /* Calculate temporary vectorial force */
2094             tx               = _mm256_mul_ps(fscal,dx11);
2095             ty               = _mm256_mul_ps(fscal,dy11);
2096             tz               = _mm256_mul_ps(fscal,dz11);
2097
2098             /* Update vectorial force */
2099             fix1             = _mm256_add_ps(fix1,tx);
2100             fiy1             = _mm256_add_ps(fiy1,ty);
2101             fiz1             = _mm256_add_ps(fiz1,tz);
2102
2103             fjx1             = _mm256_add_ps(fjx1,tx);
2104             fjy1             = _mm256_add_ps(fjy1,ty);
2105             fjz1             = _mm256_add_ps(fjz1,tz);
2106
2107             }
2108
2109             /**************************
2110              * CALCULATE INTERACTIONS *
2111              **************************/
2112
2113             if (gmx_mm256_any_lt(rsq12,rcutoff2))
2114             {
2115
2116             /* REACTION-FIELD ELECTROSTATICS */
2117             felec            = _mm256_mul_ps(qq12,_mm256_sub_ps(_mm256_mul_ps(rinv12,rinvsq12),krf2));
2118
2119             cutoff_mask      = _mm256_cmp_ps(rsq12,rcutoff2,_CMP_LT_OQ);
2120
2121             fscal            = felec;
2122
2123             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2124
2125             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2126
2127             /* Calculate temporary vectorial force */
2128             tx               = _mm256_mul_ps(fscal,dx12);
2129             ty               = _mm256_mul_ps(fscal,dy12);
2130             tz               = _mm256_mul_ps(fscal,dz12);
2131
2132             /* Update vectorial force */
2133             fix1             = _mm256_add_ps(fix1,tx);
2134             fiy1             = _mm256_add_ps(fiy1,ty);
2135             fiz1             = _mm256_add_ps(fiz1,tz);
2136
2137             fjx2             = _mm256_add_ps(fjx2,tx);
2138             fjy2             = _mm256_add_ps(fjy2,ty);
2139             fjz2             = _mm256_add_ps(fjz2,tz);
2140
2141             }
2142
2143             /**************************
2144              * CALCULATE INTERACTIONS *
2145              **************************/
2146
2147             if (gmx_mm256_any_lt(rsq13,rcutoff2))
2148             {
2149
2150             /* REACTION-FIELD ELECTROSTATICS */
2151             felec            = _mm256_mul_ps(qq13,_mm256_sub_ps(_mm256_mul_ps(rinv13,rinvsq13),krf2));
2152
2153             cutoff_mask      = _mm256_cmp_ps(rsq13,rcutoff2,_CMP_LT_OQ);
2154
2155             fscal            = felec;
2156
2157             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2158
2159             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2160
2161             /* Calculate temporary vectorial force */
2162             tx               = _mm256_mul_ps(fscal,dx13);
2163             ty               = _mm256_mul_ps(fscal,dy13);
2164             tz               = _mm256_mul_ps(fscal,dz13);
2165
2166             /* Update vectorial force */
2167             fix1             = _mm256_add_ps(fix1,tx);
2168             fiy1             = _mm256_add_ps(fiy1,ty);
2169             fiz1             = _mm256_add_ps(fiz1,tz);
2170
2171             fjx3             = _mm256_add_ps(fjx3,tx);
2172             fjy3             = _mm256_add_ps(fjy3,ty);
2173             fjz3             = _mm256_add_ps(fjz3,tz);
2174
2175             }
2176
2177             /**************************
2178              * CALCULATE INTERACTIONS *
2179              **************************/
2180
2181             if (gmx_mm256_any_lt(rsq21,rcutoff2))
2182             {
2183
2184             /* REACTION-FIELD ELECTROSTATICS */
2185             felec            = _mm256_mul_ps(qq21,_mm256_sub_ps(_mm256_mul_ps(rinv21,rinvsq21),krf2));
2186
2187             cutoff_mask      = _mm256_cmp_ps(rsq21,rcutoff2,_CMP_LT_OQ);
2188
2189             fscal            = felec;
2190
2191             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2192
2193             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2194
2195             /* Calculate temporary vectorial force */
2196             tx               = _mm256_mul_ps(fscal,dx21);
2197             ty               = _mm256_mul_ps(fscal,dy21);
2198             tz               = _mm256_mul_ps(fscal,dz21);
2199
2200             /* Update vectorial force */
2201             fix2             = _mm256_add_ps(fix2,tx);
2202             fiy2             = _mm256_add_ps(fiy2,ty);
2203             fiz2             = _mm256_add_ps(fiz2,tz);
2204
2205             fjx1             = _mm256_add_ps(fjx1,tx);
2206             fjy1             = _mm256_add_ps(fjy1,ty);
2207             fjz1             = _mm256_add_ps(fjz1,tz);
2208
2209             }
2210
2211             /**************************
2212              * CALCULATE INTERACTIONS *
2213              **************************/
2214
2215             if (gmx_mm256_any_lt(rsq22,rcutoff2))
2216             {
2217
2218             /* REACTION-FIELD ELECTROSTATICS */
2219             felec            = _mm256_mul_ps(qq22,_mm256_sub_ps(_mm256_mul_ps(rinv22,rinvsq22),krf2));
2220
2221             cutoff_mask      = _mm256_cmp_ps(rsq22,rcutoff2,_CMP_LT_OQ);
2222
2223             fscal            = felec;
2224
2225             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2226
2227             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2228
2229             /* Calculate temporary vectorial force */
2230             tx               = _mm256_mul_ps(fscal,dx22);
2231             ty               = _mm256_mul_ps(fscal,dy22);
2232             tz               = _mm256_mul_ps(fscal,dz22);
2233
2234             /* Update vectorial force */
2235             fix2             = _mm256_add_ps(fix2,tx);
2236             fiy2             = _mm256_add_ps(fiy2,ty);
2237             fiz2             = _mm256_add_ps(fiz2,tz);
2238
2239             fjx2             = _mm256_add_ps(fjx2,tx);
2240             fjy2             = _mm256_add_ps(fjy2,ty);
2241             fjz2             = _mm256_add_ps(fjz2,tz);
2242
2243             }
2244
2245             /**************************
2246              * CALCULATE INTERACTIONS *
2247              **************************/
2248
2249             if (gmx_mm256_any_lt(rsq23,rcutoff2))
2250             {
2251
2252             /* REACTION-FIELD ELECTROSTATICS */
2253             felec            = _mm256_mul_ps(qq23,_mm256_sub_ps(_mm256_mul_ps(rinv23,rinvsq23),krf2));
2254
2255             cutoff_mask      = _mm256_cmp_ps(rsq23,rcutoff2,_CMP_LT_OQ);
2256
2257             fscal            = felec;
2258
2259             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2260
2261             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2262
2263             /* Calculate temporary vectorial force */
2264             tx               = _mm256_mul_ps(fscal,dx23);
2265             ty               = _mm256_mul_ps(fscal,dy23);
2266             tz               = _mm256_mul_ps(fscal,dz23);
2267
2268             /* Update vectorial force */
2269             fix2             = _mm256_add_ps(fix2,tx);
2270             fiy2             = _mm256_add_ps(fiy2,ty);
2271             fiz2             = _mm256_add_ps(fiz2,tz);
2272
2273             fjx3             = _mm256_add_ps(fjx3,tx);
2274             fjy3             = _mm256_add_ps(fjy3,ty);
2275             fjz3             = _mm256_add_ps(fjz3,tz);
2276
2277             }
2278
2279             /**************************
2280              * CALCULATE INTERACTIONS *
2281              **************************/
2282
2283             if (gmx_mm256_any_lt(rsq31,rcutoff2))
2284             {
2285
2286             /* REACTION-FIELD ELECTROSTATICS */
2287             felec            = _mm256_mul_ps(qq31,_mm256_sub_ps(_mm256_mul_ps(rinv31,rinvsq31),krf2));
2288
2289             cutoff_mask      = _mm256_cmp_ps(rsq31,rcutoff2,_CMP_LT_OQ);
2290
2291             fscal            = felec;
2292
2293             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2294
2295             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2296
2297             /* Calculate temporary vectorial force */
2298             tx               = _mm256_mul_ps(fscal,dx31);
2299             ty               = _mm256_mul_ps(fscal,dy31);
2300             tz               = _mm256_mul_ps(fscal,dz31);
2301
2302             /* Update vectorial force */
2303             fix3             = _mm256_add_ps(fix3,tx);
2304             fiy3             = _mm256_add_ps(fiy3,ty);
2305             fiz3             = _mm256_add_ps(fiz3,tz);
2306
2307             fjx1             = _mm256_add_ps(fjx1,tx);
2308             fjy1             = _mm256_add_ps(fjy1,ty);
2309             fjz1             = _mm256_add_ps(fjz1,tz);
2310
2311             }
2312
2313             /**************************
2314              * CALCULATE INTERACTIONS *
2315              **************************/
2316
2317             if (gmx_mm256_any_lt(rsq32,rcutoff2))
2318             {
2319
2320             /* REACTION-FIELD ELECTROSTATICS */
2321             felec            = _mm256_mul_ps(qq32,_mm256_sub_ps(_mm256_mul_ps(rinv32,rinvsq32),krf2));
2322
2323             cutoff_mask      = _mm256_cmp_ps(rsq32,rcutoff2,_CMP_LT_OQ);
2324
2325             fscal            = felec;
2326
2327             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2328
2329             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2330
2331             /* Calculate temporary vectorial force */
2332             tx               = _mm256_mul_ps(fscal,dx32);
2333             ty               = _mm256_mul_ps(fscal,dy32);
2334             tz               = _mm256_mul_ps(fscal,dz32);
2335
2336             /* Update vectorial force */
2337             fix3             = _mm256_add_ps(fix3,tx);
2338             fiy3             = _mm256_add_ps(fiy3,ty);
2339             fiz3             = _mm256_add_ps(fiz3,tz);
2340
2341             fjx2             = _mm256_add_ps(fjx2,tx);
2342             fjy2             = _mm256_add_ps(fjy2,ty);
2343             fjz2             = _mm256_add_ps(fjz2,tz);
2344
2345             }
2346
2347             /**************************
2348              * CALCULATE INTERACTIONS *
2349              **************************/
2350
2351             if (gmx_mm256_any_lt(rsq33,rcutoff2))
2352             {
2353
2354             /* REACTION-FIELD ELECTROSTATICS */
2355             felec            = _mm256_mul_ps(qq33,_mm256_sub_ps(_mm256_mul_ps(rinv33,rinvsq33),krf2));
2356
2357             cutoff_mask      = _mm256_cmp_ps(rsq33,rcutoff2,_CMP_LT_OQ);
2358
2359             fscal            = felec;
2360
2361             fscal            = _mm256_and_ps(fscal,cutoff_mask);
2362
2363             fscal            = _mm256_andnot_ps(dummy_mask,fscal);
2364
2365             /* Calculate temporary vectorial force */
2366             tx               = _mm256_mul_ps(fscal,dx33);
2367             ty               = _mm256_mul_ps(fscal,dy33);
2368             tz               = _mm256_mul_ps(fscal,dz33);
2369
2370             /* Update vectorial force */
2371             fix3             = _mm256_add_ps(fix3,tx);
2372             fiy3             = _mm256_add_ps(fiy3,ty);
2373             fiz3             = _mm256_add_ps(fiz3,tz);
2374
2375             fjx3             = _mm256_add_ps(fjx3,tx);
2376             fjy3             = _mm256_add_ps(fjy3,ty);
2377             fjz3             = _mm256_add_ps(fjz3,tz);
2378
2379             }
2380
2381             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2382             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2383             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2384             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2385             fjptrE             = (jnrlistE>=0) ? f+j_coord_offsetE : scratch;
2386             fjptrF             = (jnrlistF>=0) ? f+j_coord_offsetF : scratch;
2387             fjptrG             = (jnrlistG>=0) ? f+j_coord_offsetG : scratch;
2388             fjptrH             = (jnrlistH>=0) ? f+j_coord_offsetH : scratch;
2389
2390             gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjptrE,fjptrF,fjptrG,fjptrH,
2391                                                       fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2392                                                       fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2393
2394             /* Inner loop uses 303 flops */
2395         }
2396
2397         /* End of innermost loop */
2398
2399         gmx_mm256_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2400                                                  f+i_coord_offset,fshift+i_shift_offset);
2401
2402         /* Increment number of inner iterations */
2403         inneriter                  += j_index_end - j_index_start;
2404
2405         /* Outer loop uses 24 flops */
2406     }
2407
2408     /* Increment number of outer iterations */
2409     outeriter        += nri;
2410
2411     /* Update outer/inner flops */
2412
2413     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*303);
2414 }