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