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