Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_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_VdwLJSw_GeomW4P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: ReactionField
54  * VdW interaction:            LennardJones
55  * Geometry:                   Water4-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_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     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
93     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
94     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
95     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
96     real             *charge;
97     int              nvdwtype;
98     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
99     int              *vdwtype;
100     real             *vdwparam;
101     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
102     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
103     _fjsp_v2r8       rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
104     real             rswitch_scalar,d_scalar;
105     _fjsp_v2r8       itab_tmp;
106     _fjsp_v2r8       dummy_mask,cutoff_mask;
107     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
108     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
109     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
110
111     x                = xx[0];
112     f                = ff[0];
113
114     nri              = nlist->nri;
115     iinr             = nlist->iinr;
116     jindex           = nlist->jindex;
117     jjnr             = nlist->jjnr;
118     shiftidx         = nlist->shift;
119     gid              = nlist->gid;
120     shiftvec         = fr->shift_vec[0];
121     fshift           = fr->fshift[0];
122     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
123     charge           = mdatoms->chargeA;
124     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
125     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
126     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
127     nvdwtype         = fr->ntype;
128     vdwparam         = fr->nbfp;
129     vdwtype          = mdatoms->typeA;
130
131     /* Setup water-specific parameters */
132     inr              = nlist->iinr[0];
133     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
134     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
135     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
136     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
137
138     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
139     rcutoff_scalar   = fr->rcoulomb;
140     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
141     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
142
143     rswitch_scalar   = fr->rvdw_switch;
144     rswitch          = gmx_fjsp_set1_v2r8(rswitch_scalar);
145     /* Setup switch parameters */
146     d_scalar         = rcutoff_scalar-rswitch_scalar;
147     d                = gmx_fjsp_set1_v2r8(d_scalar);
148     swV3             = gmx_fjsp_set1_v2r8(-10.0/(d_scalar*d_scalar*d_scalar));
149     swV4             = gmx_fjsp_set1_v2r8( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
150     swV5             = gmx_fjsp_set1_v2r8( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
151     swF2             = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar));
152     swF3             = gmx_fjsp_set1_v2r8( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
153     swF4             = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
154
155     /* Avoid stupid compiler warnings */
156     jnrA = jnrB = 0;
157     j_coord_offsetA = 0;
158     j_coord_offsetB = 0;
159
160     outeriter        = 0;
161     inneriter        = 0;
162
163     /* Start outer loop over neighborlists */
164     for(iidx=0; iidx<nri; iidx++)
165     {
166         /* Load shift vector for this list */
167         i_shift_offset   = DIM*shiftidx[iidx];
168
169         /* Load limits for loop over neighbors */
170         j_index_start    = jindex[iidx];
171         j_index_end      = jindex[iidx+1];
172
173         /* Get outer coordinate index */
174         inr              = iinr[iidx];
175         i_coord_offset   = DIM*inr;
176
177         /* Load i particle coords and add shift vector */
178         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
179                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
180
181         fix0             = _fjsp_setzero_v2r8();
182         fiy0             = _fjsp_setzero_v2r8();
183         fiz0             = _fjsp_setzero_v2r8();
184         fix1             = _fjsp_setzero_v2r8();
185         fiy1             = _fjsp_setzero_v2r8();
186         fiz1             = _fjsp_setzero_v2r8();
187         fix2             = _fjsp_setzero_v2r8();
188         fiy2             = _fjsp_setzero_v2r8();
189         fiz2             = _fjsp_setzero_v2r8();
190         fix3             = _fjsp_setzero_v2r8();
191         fiy3             = _fjsp_setzero_v2r8();
192         fiz3             = _fjsp_setzero_v2r8();
193
194         /* Reset potential sums */
195         velecsum         = _fjsp_setzero_v2r8();
196         vvdwsum          = _fjsp_setzero_v2r8();
197
198         /* Start inner kernel loop */
199         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
200         {
201
202             /* Get j neighbor index, and coordinate index */
203             jnrA             = jjnr[jidx];
204             jnrB             = jjnr[jidx+1];
205             j_coord_offsetA  = DIM*jnrA;
206             j_coord_offsetB  = DIM*jnrB;
207
208             /* load j atom coordinates */
209             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
210                                               &jx0,&jy0,&jz0);
211
212             /* Calculate displacement vector */
213             dx00             = _fjsp_sub_v2r8(ix0,jx0);
214             dy00             = _fjsp_sub_v2r8(iy0,jy0);
215             dz00             = _fjsp_sub_v2r8(iz0,jz0);
216             dx10             = _fjsp_sub_v2r8(ix1,jx0);
217             dy10             = _fjsp_sub_v2r8(iy1,jy0);
218             dz10             = _fjsp_sub_v2r8(iz1,jz0);
219             dx20             = _fjsp_sub_v2r8(ix2,jx0);
220             dy20             = _fjsp_sub_v2r8(iy2,jy0);
221             dz20             = _fjsp_sub_v2r8(iz2,jz0);
222             dx30             = _fjsp_sub_v2r8(ix3,jx0);
223             dy30             = _fjsp_sub_v2r8(iy3,jy0);
224             dz30             = _fjsp_sub_v2r8(iz3,jz0);
225
226             /* Calculate squared distance and things based on it */
227             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
228             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
229             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
230             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
231
232             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
233             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
234             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
235             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
236
237             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
238             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
239             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
240             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
241
242             /* Load parameters for j particles */
243             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
244             vdwjidx0A        = 2*vdwtype[jnrA+0];
245             vdwjidx0B        = 2*vdwtype[jnrB+0];
246
247             fjx0             = _fjsp_setzero_v2r8();
248             fjy0             = _fjsp_setzero_v2r8();
249             fjz0             = _fjsp_setzero_v2r8();
250
251             /**************************
252              * CALCULATE INTERACTIONS *
253              **************************/
254
255             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
256             {
257
258             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
259
260             /* Compute parameters for interactions between i and j atoms */
261             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
262                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
263
264             /* LENNARD-JONES DISPERSION/REPULSION */
265
266             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
267             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
268             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
269             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
270             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
271
272             d                = _fjsp_sub_v2r8(r00,rswitch);
273             d                = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
274             d2               = _fjsp_mul_v2r8(d,d);
275             sw               = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
276
277             dsw              = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
278
279             /* Evaluate switch function */
280             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
281             fvdw             = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
282             vvdw             = _fjsp_mul_v2r8(vvdw,sw);
283             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
284
285             /* Update potential sum for this i atom from the interaction with this j atom. */
286             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
287             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
288
289             fscal            = fvdw;
290
291             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
292
293             /* Update vectorial force */
294             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
295             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
296             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
297             
298             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
299             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
300             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
301
302             }
303
304             /**************************
305              * CALCULATE INTERACTIONS *
306              **************************/
307
308             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
309             {
310
311             /* Compute parameters for interactions between i and j atoms */
312             qq10             = _fjsp_mul_v2r8(iq1,jq0);
313
314             /* REACTION-FIELD ELECTROSTATICS */
315             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
316             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
317
318             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
319
320             /* Update potential sum for this i atom from the interaction with this j atom. */
321             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
322             velecsum         = _fjsp_add_v2r8(velecsum,velec);
323
324             fscal            = felec;
325
326             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
327
328             /* Update vectorial force */
329             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
330             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
331             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
332             
333             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
334             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
335             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
336
337             }
338
339             /**************************
340              * CALCULATE INTERACTIONS *
341              **************************/
342
343             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
344             {
345
346             /* Compute parameters for interactions between i and j atoms */
347             qq20             = _fjsp_mul_v2r8(iq2,jq0);
348
349             /* REACTION-FIELD ELECTROSTATICS */
350             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
351             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
352
353             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
354
355             /* Update potential sum for this i atom from the interaction with this j atom. */
356             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
357             velecsum         = _fjsp_add_v2r8(velecsum,velec);
358
359             fscal            = felec;
360
361             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
362
363             /* Update vectorial force */
364             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
365             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
366             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
367             
368             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
369             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
370             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
371
372             }
373
374             /**************************
375              * CALCULATE INTERACTIONS *
376              **************************/
377
378             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
379             {
380
381             /* Compute parameters for interactions between i and j atoms */
382             qq30             = _fjsp_mul_v2r8(iq3,jq0);
383
384             /* REACTION-FIELD ELECTROSTATICS */
385             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
386             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
387
388             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,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             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
400             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
401             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
402             
403             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
404             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
405             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
406
407             }
408
409             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
410
411             /* Inner loop uses 182 flops */
412         }
413
414         if(jidx<j_index_end)
415         {
416
417             jnrA             = jjnr[jidx];
418             j_coord_offsetA  = DIM*jnrA;
419
420             /* load j atom coordinates */
421             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
422                                               &jx0,&jy0,&jz0);
423
424             /* Calculate displacement vector */
425             dx00             = _fjsp_sub_v2r8(ix0,jx0);
426             dy00             = _fjsp_sub_v2r8(iy0,jy0);
427             dz00             = _fjsp_sub_v2r8(iz0,jz0);
428             dx10             = _fjsp_sub_v2r8(ix1,jx0);
429             dy10             = _fjsp_sub_v2r8(iy1,jy0);
430             dz10             = _fjsp_sub_v2r8(iz1,jz0);
431             dx20             = _fjsp_sub_v2r8(ix2,jx0);
432             dy20             = _fjsp_sub_v2r8(iy2,jy0);
433             dz20             = _fjsp_sub_v2r8(iz2,jz0);
434             dx30             = _fjsp_sub_v2r8(ix3,jx0);
435             dy30             = _fjsp_sub_v2r8(iy3,jy0);
436             dz30             = _fjsp_sub_v2r8(iz3,jz0);
437
438             /* Calculate squared distance and things based on it */
439             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
440             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
441             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
442             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
443
444             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
445             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
446             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
447             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
448
449             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
450             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
451             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
452             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
453
454             /* Load parameters for j particles */
455             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
456             vdwjidx0A        = 2*vdwtype[jnrA+0];
457
458             fjx0             = _fjsp_setzero_v2r8();
459             fjy0             = _fjsp_setzero_v2r8();
460             fjz0             = _fjsp_setzero_v2r8();
461
462             /**************************
463              * CALCULATE INTERACTIONS *
464              **************************/
465
466             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
467             {
468
469             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
470
471             /* Compute parameters for interactions between i and j atoms */
472             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
473                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
474
475             /* LENNARD-JONES DISPERSION/REPULSION */
476
477             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
478             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
479             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
480             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
481             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
482
483             d                = _fjsp_sub_v2r8(r00,rswitch);
484             d                = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
485             d2               = _fjsp_mul_v2r8(d,d);
486             sw               = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
487
488             dsw              = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
489
490             /* Evaluate switch function */
491             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
492             fvdw             = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
493             vvdw             = _fjsp_mul_v2r8(vvdw,sw);
494             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
495
496             /* Update potential sum for this i atom from the interaction with this j atom. */
497             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
498             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
499             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
500
501             fscal            = fvdw;
502
503             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
504
505             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
506
507             /* Update vectorial force */
508             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
509             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
510             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
511             
512             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
513             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
514             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
515
516             }
517
518             /**************************
519              * CALCULATE INTERACTIONS *
520              **************************/
521
522             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
523             {
524
525             /* Compute parameters for interactions between i and j atoms */
526             qq10             = _fjsp_mul_v2r8(iq1,jq0);
527
528             /* REACTION-FIELD ELECTROSTATICS */
529             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
530             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
531
532             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
533
534             /* Update potential sum for this i atom from the interaction with this j atom. */
535             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
536             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
537             velecsum         = _fjsp_add_v2r8(velecsum,velec);
538
539             fscal            = felec;
540
541             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
542
543             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
544
545             /* Update vectorial force */
546             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
547             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
548             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
549             
550             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
551             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
552             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
553
554             }
555
556             /**************************
557              * CALCULATE INTERACTIONS *
558              **************************/
559
560             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
561             {
562
563             /* Compute parameters for interactions between i and j atoms */
564             qq20             = _fjsp_mul_v2r8(iq2,jq0);
565
566             /* REACTION-FIELD ELECTROSTATICS */
567             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
568             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
569
570             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
571
572             /* Update potential sum for this i atom from the interaction with this j atom. */
573             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
574             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
575             velecsum         = _fjsp_add_v2r8(velecsum,velec);
576
577             fscal            = felec;
578
579             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
580
581             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
582
583             /* Update vectorial force */
584             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
585             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
586             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
587             
588             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
589             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
590             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
591
592             }
593
594             /**************************
595              * CALCULATE INTERACTIONS *
596              **************************/
597
598             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
599             {
600
601             /* Compute parameters for interactions between i and j atoms */
602             qq30             = _fjsp_mul_v2r8(iq3,jq0);
603
604             /* REACTION-FIELD ELECTROSTATICS */
605             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
606             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
607
608             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
609
610             /* Update potential sum for this i atom from the interaction with this j atom. */
611             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
612             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
613             velecsum         = _fjsp_add_v2r8(velecsum,velec);
614
615             fscal            = felec;
616
617             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
618
619             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
620
621             /* Update vectorial force */
622             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
623             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
624             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
625             
626             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
627             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
628             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
629
630             }
631
632             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
633
634             /* Inner loop uses 182 flops */
635         }
636
637         /* End of innermost loop */
638
639         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
640                                               f+i_coord_offset,fshift+i_shift_offset);
641
642         ggid                        = gid[iidx];
643         /* Update potential energies */
644         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
645         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
646
647         /* Increment number of inner iterations */
648         inneriter                  += j_index_end - j_index_start;
649
650         /* Outer loop uses 26 flops */
651     }
652
653     /* Increment number of outer iterations */
654     outeriter        += nri;
655
656     /* Update outer/inner flops */
657
658     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*182);
659 }
660 /*
661  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_sparc64_hpc_ace_double
662  * Electrostatics interaction: ReactionField
663  * VdW interaction:            LennardJones
664  * Geometry:                   Water4-Particle
665  * Calculate force/pot:        Force
666  */
667 void
668 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_sparc64_hpc_ace_double
669                     (t_nblist                    * gmx_restrict       nlist,
670                      rvec                        * gmx_restrict          xx,
671                      rvec                        * gmx_restrict          ff,
672                      t_forcerec                  * gmx_restrict          fr,
673                      t_mdatoms                   * gmx_restrict     mdatoms,
674                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
675                      t_nrnb                      * gmx_restrict        nrnb)
676 {
677     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
678      * just 0 for non-waters.
679      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
680      * jnr indices corresponding to data put in the four positions in the SIMD register.
681      */
682     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
683     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
684     int              jnrA,jnrB;
685     int              j_coord_offsetA,j_coord_offsetB;
686     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
687     real             rcutoff_scalar;
688     real             *shiftvec,*fshift,*x,*f;
689     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
690     int              vdwioffset0;
691     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
692     int              vdwioffset1;
693     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
694     int              vdwioffset2;
695     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
696     int              vdwioffset3;
697     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
698     int              vdwjidx0A,vdwjidx0B;
699     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
700     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
701     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
702     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
703     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
704     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
705     real             *charge;
706     int              nvdwtype;
707     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
708     int              *vdwtype;
709     real             *vdwparam;
710     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
711     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
712     _fjsp_v2r8       rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
713     real             rswitch_scalar,d_scalar;
714     _fjsp_v2r8       itab_tmp;
715     _fjsp_v2r8       dummy_mask,cutoff_mask;
716     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
717     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
718     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
719
720     x                = xx[0];
721     f                = ff[0];
722
723     nri              = nlist->nri;
724     iinr             = nlist->iinr;
725     jindex           = nlist->jindex;
726     jjnr             = nlist->jjnr;
727     shiftidx         = nlist->shift;
728     gid              = nlist->gid;
729     shiftvec         = fr->shift_vec[0];
730     fshift           = fr->fshift[0];
731     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
732     charge           = mdatoms->chargeA;
733     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
734     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
735     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
736     nvdwtype         = fr->ntype;
737     vdwparam         = fr->nbfp;
738     vdwtype          = mdatoms->typeA;
739
740     /* Setup water-specific parameters */
741     inr              = nlist->iinr[0];
742     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
743     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
744     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
745     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
746
747     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
748     rcutoff_scalar   = fr->rcoulomb;
749     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
750     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
751
752     rswitch_scalar   = fr->rvdw_switch;
753     rswitch          = gmx_fjsp_set1_v2r8(rswitch_scalar);
754     /* Setup switch parameters */
755     d_scalar         = rcutoff_scalar-rswitch_scalar;
756     d                = gmx_fjsp_set1_v2r8(d_scalar);
757     swV3             = gmx_fjsp_set1_v2r8(-10.0/(d_scalar*d_scalar*d_scalar));
758     swV4             = gmx_fjsp_set1_v2r8( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
759     swV5             = gmx_fjsp_set1_v2r8( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
760     swF2             = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar));
761     swF3             = gmx_fjsp_set1_v2r8( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
762     swF4             = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
763
764     /* Avoid stupid compiler warnings */
765     jnrA = jnrB = 0;
766     j_coord_offsetA = 0;
767     j_coord_offsetB = 0;
768
769     outeriter        = 0;
770     inneriter        = 0;
771
772     /* Start outer loop over neighborlists */
773     for(iidx=0; iidx<nri; iidx++)
774     {
775         /* Load shift vector for this list */
776         i_shift_offset   = DIM*shiftidx[iidx];
777
778         /* Load limits for loop over neighbors */
779         j_index_start    = jindex[iidx];
780         j_index_end      = jindex[iidx+1];
781
782         /* Get outer coordinate index */
783         inr              = iinr[iidx];
784         i_coord_offset   = DIM*inr;
785
786         /* Load i particle coords and add shift vector */
787         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
788                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
789
790         fix0             = _fjsp_setzero_v2r8();
791         fiy0             = _fjsp_setzero_v2r8();
792         fiz0             = _fjsp_setzero_v2r8();
793         fix1             = _fjsp_setzero_v2r8();
794         fiy1             = _fjsp_setzero_v2r8();
795         fiz1             = _fjsp_setzero_v2r8();
796         fix2             = _fjsp_setzero_v2r8();
797         fiy2             = _fjsp_setzero_v2r8();
798         fiz2             = _fjsp_setzero_v2r8();
799         fix3             = _fjsp_setzero_v2r8();
800         fiy3             = _fjsp_setzero_v2r8();
801         fiz3             = _fjsp_setzero_v2r8();
802
803         /* Start inner kernel loop */
804         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
805         {
806
807             /* Get j neighbor index, and coordinate index */
808             jnrA             = jjnr[jidx];
809             jnrB             = jjnr[jidx+1];
810             j_coord_offsetA  = DIM*jnrA;
811             j_coord_offsetB  = DIM*jnrB;
812
813             /* load j atom coordinates */
814             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
815                                               &jx0,&jy0,&jz0);
816
817             /* Calculate displacement vector */
818             dx00             = _fjsp_sub_v2r8(ix0,jx0);
819             dy00             = _fjsp_sub_v2r8(iy0,jy0);
820             dz00             = _fjsp_sub_v2r8(iz0,jz0);
821             dx10             = _fjsp_sub_v2r8(ix1,jx0);
822             dy10             = _fjsp_sub_v2r8(iy1,jy0);
823             dz10             = _fjsp_sub_v2r8(iz1,jz0);
824             dx20             = _fjsp_sub_v2r8(ix2,jx0);
825             dy20             = _fjsp_sub_v2r8(iy2,jy0);
826             dz20             = _fjsp_sub_v2r8(iz2,jz0);
827             dx30             = _fjsp_sub_v2r8(ix3,jx0);
828             dy30             = _fjsp_sub_v2r8(iy3,jy0);
829             dz30             = _fjsp_sub_v2r8(iz3,jz0);
830
831             /* Calculate squared distance and things based on it */
832             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
833             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
834             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
835             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
836
837             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
838             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
839             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
840             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
841
842             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
843             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
844             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
845             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
846
847             /* Load parameters for j particles */
848             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
849             vdwjidx0A        = 2*vdwtype[jnrA+0];
850             vdwjidx0B        = 2*vdwtype[jnrB+0];
851
852             fjx0             = _fjsp_setzero_v2r8();
853             fjy0             = _fjsp_setzero_v2r8();
854             fjz0             = _fjsp_setzero_v2r8();
855
856             /**************************
857              * CALCULATE INTERACTIONS *
858              **************************/
859
860             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
861             {
862
863             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
864
865             /* Compute parameters for interactions between i and j atoms */
866             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
867                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
868
869             /* LENNARD-JONES DISPERSION/REPULSION */
870
871             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
872             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
873             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
874             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
875             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
876
877             d                = _fjsp_sub_v2r8(r00,rswitch);
878             d                = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
879             d2               = _fjsp_mul_v2r8(d,d);
880             sw               = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
881
882             dsw              = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
883
884             /* Evaluate switch function */
885             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
886             fvdw             = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
887             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
888
889             fscal            = fvdw;
890
891             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
892
893             /* Update vectorial force */
894             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
895             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
896             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
897             
898             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
899             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
900             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
901
902             }
903
904             /**************************
905              * CALCULATE INTERACTIONS *
906              **************************/
907
908             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
909             {
910
911             /* Compute parameters for interactions between i and j atoms */
912             qq10             = _fjsp_mul_v2r8(iq1,jq0);
913
914             /* REACTION-FIELD ELECTROSTATICS */
915             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
916
917             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
918
919             fscal            = felec;
920
921             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
922
923             /* Update vectorial force */
924             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
925             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
926             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
927             
928             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
929             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
930             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
931
932             }
933
934             /**************************
935              * CALCULATE INTERACTIONS *
936              **************************/
937
938             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
939             {
940
941             /* Compute parameters for interactions between i and j atoms */
942             qq20             = _fjsp_mul_v2r8(iq2,jq0);
943
944             /* REACTION-FIELD ELECTROSTATICS */
945             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
946
947             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
948
949             fscal            = felec;
950
951             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
952
953             /* Update vectorial force */
954             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
955             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
956             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
957             
958             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
959             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
960             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
961
962             }
963
964             /**************************
965              * CALCULATE INTERACTIONS *
966              **************************/
967
968             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
969             {
970
971             /* Compute parameters for interactions between i and j atoms */
972             qq30             = _fjsp_mul_v2r8(iq3,jq0);
973
974             /* REACTION-FIELD ELECTROSTATICS */
975             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
976
977             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
978
979             fscal            = felec;
980
981             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
982
983             /* Update vectorial force */
984             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
985             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
986             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
987             
988             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
989             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
990             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
991
992             }
993
994             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
995
996             /* Inner loop uses 161 flops */
997         }
998
999         if(jidx<j_index_end)
1000         {
1001
1002             jnrA             = jjnr[jidx];
1003             j_coord_offsetA  = DIM*jnrA;
1004
1005             /* load j atom coordinates */
1006             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1007                                               &jx0,&jy0,&jz0);
1008
1009             /* Calculate displacement vector */
1010             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1011             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1012             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1013             dx10             = _fjsp_sub_v2r8(ix1,jx0);
1014             dy10             = _fjsp_sub_v2r8(iy1,jy0);
1015             dz10             = _fjsp_sub_v2r8(iz1,jz0);
1016             dx20             = _fjsp_sub_v2r8(ix2,jx0);
1017             dy20             = _fjsp_sub_v2r8(iy2,jy0);
1018             dz20             = _fjsp_sub_v2r8(iz2,jz0);
1019             dx30             = _fjsp_sub_v2r8(ix3,jx0);
1020             dy30             = _fjsp_sub_v2r8(iy3,jy0);
1021             dz30             = _fjsp_sub_v2r8(iz3,jz0);
1022
1023             /* Calculate squared distance and things based on it */
1024             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1025             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1026             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1027             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1028
1029             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1030             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
1031             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
1032             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
1033
1034             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
1035             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
1036             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
1037             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
1038
1039             /* Load parameters for j particles */
1040             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1041             vdwjidx0A        = 2*vdwtype[jnrA+0];
1042
1043             fjx0             = _fjsp_setzero_v2r8();
1044             fjy0             = _fjsp_setzero_v2r8();
1045             fjz0             = _fjsp_setzero_v2r8();
1046
1047             /**************************
1048              * CALCULATE INTERACTIONS *
1049              **************************/
1050
1051             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
1052             {
1053
1054             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1055
1056             /* Compute parameters for interactions between i and j atoms */
1057             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
1058                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
1059
1060             /* LENNARD-JONES DISPERSION/REPULSION */
1061
1062             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1063             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
1064             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
1065             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
1066             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
1067
1068             d                = _fjsp_sub_v2r8(r00,rswitch);
1069             d                = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
1070             d2               = _fjsp_mul_v2r8(d,d);
1071             sw               = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
1072
1073             dsw              = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
1074
1075             /* Evaluate switch function */
1076             /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1077             fvdw             = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
1078             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
1079
1080             fscal            = fvdw;
1081
1082             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1083
1084             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1085
1086             /* Update vectorial force */
1087             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1088             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1089             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1090             
1091             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1092             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1093             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1094
1095             }
1096
1097             /**************************
1098              * CALCULATE INTERACTIONS *
1099              **************************/
1100
1101             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1102             {
1103
1104             /* Compute parameters for interactions between i and j atoms */
1105             qq10             = _fjsp_mul_v2r8(iq1,jq0);
1106
1107             /* REACTION-FIELD ELECTROSTATICS */
1108             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
1109
1110             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1111
1112             fscal            = felec;
1113
1114             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1115
1116             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1117
1118             /* Update vectorial force */
1119             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1120             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1121             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1122             
1123             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1124             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1125             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1126
1127             }
1128
1129             /**************************
1130              * CALCULATE INTERACTIONS *
1131              **************************/
1132
1133             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1134             {
1135
1136             /* Compute parameters for interactions between i and j atoms */
1137             qq20             = _fjsp_mul_v2r8(iq2,jq0);
1138
1139             /* REACTION-FIELD ELECTROSTATICS */
1140             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
1141
1142             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1143
1144             fscal            = felec;
1145
1146             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1147
1148             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1149
1150             /* Update vectorial force */
1151             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1152             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1153             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1154             
1155             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1156             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1157             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1158
1159             }
1160
1161             /**************************
1162              * CALCULATE INTERACTIONS *
1163              **************************/
1164
1165             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1166             {
1167
1168             /* Compute parameters for interactions between i and j atoms */
1169             qq30             = _fjsp_mul_v2r8(iq3,jq0);
1170
1171             /* REACTION-FIELD ELECTROSTATICS */
1172             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
1173
1174             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1175
1176             fscal            = felec;
1177
1178             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1179
1180             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1181
1182             /* Update vectorial force */
1183             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
1184             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1185             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1186             
1187             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1188             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1189             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1190
1191             }
1192
1193             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1194
1195             /* Inner loop uses 161 flops */
1196         }
1197
1198         /* End of innermost loop */
1199
1200         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1201                                               f+i_coord_offset,fshift+i_shift_offset);
1202
1203         /* Increment number of inner iterations */
1204         inneriter                  += j_index_end - j_index_start;
1205
1206         /* Outer loop uses 24 flops */
1207     }
1208
1209     /* Increment number of outer iterations */
1210     outeriter        += nri;
1211
1212     /* Update outer/inner flops */
1213
1214     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*161);
1215 }