Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_VdwLJSh_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,2015,2017, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            LennardJones
53  * Geometry:                   Water4-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      struct t_forcerec           * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
93     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     int              nvdwtype;
96     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
97     int              *vdwtype;
98     real             *vdwparam;
99     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
100     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
101     _fjsp_v2r8       itab_tmp;
102     _fjsp_v2r8       dummy_mask,cutoff_mask;
103     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
104     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
105     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
106
107     x                = xx[0];
108     f                = ff[0];
109
110     nri              = nlist->nri;
111     iinr             = nlist->iinr;
112     jindex           = nlist->jindex;
113     jjnr             = nlist->jjnr;
114     shiftidx         = nlist->shift;
115     gid              = nlist->gid;
116     shiftvec         = fr->shift_vec[0];
117     fshift           = fr->fshift[0];
118     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
119     charge           = mdatoms->chargeA;
120     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
121     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
122     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
123     nvdwtype         = fr->ntype;
124     vdwparam         = fr->nbfp;
125     vdwtype          = mdatoms->typeA;
126
127     /* Setup water-specific parameters */
128     inr              = nlist->iinr[0];
129     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
130     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
131     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
132     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
133
134     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
135     rcutoff_scalar   = fr->ic->rcoulomb;
136     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
137     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
138
139     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
140     rvdw             = gmx_fjsp_set1_v2r8(fr->ic->rvdw);
141
142     /* Avoid stupid compiler warnings */
143     jnrA = jnrB = 0;
144     j_coord_offsetA = 0;
145     j_coord_offsetB = 0;
146
147     outeriter        = 0;
148     inneriter        = 0;
149
150     /* Start outer loop over neighborlists */
151     for(iidx=0; iidx<nri; iidx++)
152     {
153         /* Load shift vector for this list */
154         i_shift_offset   = DIM*shiftidx[iidx];
155
156         /* Load limits for loop over neighbors */
157         j_index_start    = jindex[iidx];
158         j_index_end      = jindex[iidx+1];
159
160         /* Get outer coordinate index */
161         inr              = iinr[iidx];
162         i_coord_offset   = DIM*inr;
163
164         /* Load i particle coords and add shift vector */
165         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
166                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
167
168         fix0             = _fjsp_setzero_v2r8();
169         fiy0             = _fjsp_setzero_v2r8();
170         fiz0             = _fjsp_setzero_v2r8();
171         fix1             = _fjsp_setzero_v2r8();
172         fiy1             = _fjsp_setzero_v2r8();
173         fiz1             = _fjsp_setzero_v2r8();
174         fix2             = _fjsp_setzero_v2r8();
175         fiy2             = _fjsp_setzero_v2r8();
176         fiz2             = _fjsp_setzero_v2r8();
177         fix3             = _fjsp_setzero_v2r8();
178         fiy3             = _fjsp_setzero_v2r8();
179         fiz3             = _fjsp_setzero_v2r8();
180
181         /* Reset potential sums */
182         velecsum         = _fjsp_setzero_v2r8();
183         vvdwsum          = _fjsp_setzero_v2r8();
184
185         /* Start inner kernel loop */
186         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
187         {
188
189             /* Get j neighbor index, and coordinate index */
190             jnrA             = jjnr[jidx];
191             jnrB             = jjnr[jidx+1];
192             j_coord_offsetA  = DIM*jnrA;
193             j_coord_offsetB  = DIM*jnrB;
194
195             /* load j atom coordinates */
196             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
197                                               &jx0,&jy0,&jz0);
198
199             /* Calculate displacement vector */
200             dx00             = _fjsp_sub_v2r8(ix0,jx0);
201             dy00             = _fjsp_sub_v2r8(iy0,jy0);
202             dz00             = _fjsp_sub_v2r8(iz0,jz0);
203             dx10             = _fjsp_sub_v2r8(ix1,jx0);
204             dy10             = _fjsp_sub_v2r8(iy1,jy0);
205             dz10             = _fjsp_sub_v2r8(iz1,jz0);
206             dx20             = _fjsp_sub_v2r8(ix2,jx0);
207             dy20             = _fjsp_sub_v2r8(iy2,jy0);
208             dz20             = _fjsp_sub_v2r8(iz2,jz0);
209             dx30             = _fjsp_sub_v2r8(ix3,jx0);
210             dy30             = _fjsp_sub_v2r8(iy3,jy0);
211             dz30             = _fjsp_sub_v2r8(iz3,jz0);
212
213             /* Calculate squared distance and things based on it */
214             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
215             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
216             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
217             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
218
219             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
220             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
221             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
222
223             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
224             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
225             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
226             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
227
228             /* Load parameters for j particles */
229             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
230             vdwjidx0A        = 2*vdwtype[jnrA+0];
231             vdwjidx0B        = 2*vdwtype[jnrB+0];
232
233             fjx0             = _fjsp_setzero_v2r8();
234             fjy0             = _fjsp_setzero_v2r8();
235             fjz0             = _fjsp_setzero_v2r8();
236
237             /**************************
238              * CALCULATE INTERACTIONS *
239              **************************/
240
241             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
242             {
243
244             /* Compute parameters for interactions between i and j atoms */
245             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
246                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
247
248             /* LENNARD-JONES DISPERSION/REPULSION */
249
250             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
251             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
252             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
253             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
254                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
255             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
256
257             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
258
259             /* Update potential sum for this i atom from the interaction with this j atom. */
260             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
261             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
262
263             fscal            = fvdw;
264
265             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
266
267             /* Update vectorial force */
268             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
269             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
270             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
271             
272             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
273             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
274             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
275
276             }
277
278             /**************************
279              * CALCULATE INTERACTIONS *
280              **************************/
281
282             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
283             {
284
285             /* Compute parameters for interactions between i and j atoms */
286             qq10             = _fjsp_mul_v2r8(iq1,jq0);
287
288             /* REACTION-FIELD ELECTROSTATICS */
289             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
290             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
291
292             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
293
294             /* Update potential sum for this i atom from the interaction with this j atom. */
295             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
296             velecsum         = _fjsp_add_v2r8(velecsum,velec);
297
298             fscal            = felec;
299
300             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
301
302             /* Update vectorial force */
303             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
304             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
305             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
306             
307             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
308             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
309             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
310
311             }
312
313             /**************************
314              * CALCULATE INTERACTIONS *
315              **************************/
316
317             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
318             {
319
320             /* Compute parameters for interactions between i and j atoms */
321             qq20             = _fjsp_mul_v2r8(iq2,jq0);
322
323             /* REACTION-FIELD ELECTROSTATICS */
324             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
325             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
326
327             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
328
329             /* Update potential sum for this i atom from the interaction with this j atom. */
330             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
331             velecsum         = _fjsp_add_v2r8(velecsum,velec);
332
333             fscal            = felec;
334
335             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
336
337             /* Update vectorial force */
338             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
339             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
340             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
341             
342             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
343             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
344             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
345
346             }
347
348             /**************************
349              * CALCULATE INTERACTIONS *
350              **************************/
351
352             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
353             {
354
355             /* Compute parameters for interactions between i and j atoms */
356             qq30             = _fjsp_mul_v2r8(iq3,jq0);
357
358             /* REACTION-FIELD ELECTROSTATICS */
359             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
360             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
361
362             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
363
364             /* Update potential sum for this i atom from the interaction with this j atom. */
365             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
366             velecsum         = _fjsp_add_v2r8(velecsum,velec);
367
368             fscal            = felec;
369
370             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
371
372             /* Update vectorial force */
373             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
374             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
375             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
376             
377             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
378             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
379             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
380
381             }
382
383             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
384
385             /* Inner loop uses 164 flops */
386         }
387
388         if(jidx<j_index_end)
389         {
390
391             jnrA             = jjnr[jidx];
392             j_coord_offsetA  = DIM*jnrA;
393
394             /* load j atom coordinates */
395             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
396                                               &jx0,&jy0,&jz0);
397
398             /* Calculate displacement vector */
399             dx00             = _fjsp_sub_v2r8(ix0,jx0);
400             dy00             = _fjsp_sub_v2r8(iy0,jy0);
401             dz00             = _fjsp_sub_v2r8(iz0,jz0);
402             dx10             = _fjsp_sub_v2r8(ix1,jx0);
403             dy10             = _fjsp_sub_v2r8(iy1,jy0);
404             dz10             = _fjsp_sub_v2r8(iz1,jz0);
405             dx20             = _fjsp_sub_v2r8(ix2,jx0);
406             dy20             = _fjsp_sub_v2r8(iy2,jy0);
407             dz20             = _fjsp_sub_v2r8(iz2,jz0);
408             dx30             = _fjsp_sub_v2r8(ix3,jx0);
409             dy30             = _fjsp_sub_v2r8(iy3,jy0);
410             dz30             = _fjsp_sub_v2r8(iz3,jz0);
411
412             /* Calculate squared distance and things based on it */
413             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
414             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
415             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
416             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
417
418             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
419             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
420             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
421
422             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
423             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
424             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
425             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
426
427             /* Load parameters for j particles */
428             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
429             vdwjidx0A        = 2*vdwtype[jnrA+0];
430
431             fjx0             = _fjsp_setzero_v2r8();
432             fjy0             = _fjsp_setzero_v2r8();
433             fjz0             = _fjsp_setzero_v2r8();
434
435             /**************************
436              * CALCULATE INTERACTIONS *
437              **************************/
438
439             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
440             {
441
442             /* Compute parameters for interactions between i and j atoms */
443             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
444                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
445
446             /* LENNARD-JONES DISPERSION/REPULSION */
447
448             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
449             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
450             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
451             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
452                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
453             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
454
455             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
456
457             /* Update potential sum for this i atom from the interaction with this j atom. */
458             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
459             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
460             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
461
462             fscal            = fvdw;
463
464             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
465
466             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
467
468             /* Update vectorial force */
469             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
470             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
471             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
472             
473             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
474             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
475             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
476
477             }
478
479             /**************************
480              * CALCULATE INTERACTIONS *
481              **************************/
482
483             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
484             {
485
486             /* Compute parameters for interactions between i and j atoms */
487             qq10             = _fjsp_mul_v2r8(iq1,jq0);
488
489             /* REACTION-FIELD ELECTROSTATICS */
490             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
491             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
492
493             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
494
495             /* Update potential sum for this i atom from the interaction with this j atom. */
496             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
497             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
498             velecsum         = _fjsp_add_v2r8(velecsum,velec);
499
500             fscal            = felec;
501
502             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
503
504             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
505
506             /* Update vectorial force */
507             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
508             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
509             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
510             
511             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
512             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
513             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
514
515             }
516
517             /**************************
518              * CALCULATE INTERACTIONS *
519              **************************/
520
521             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
522             {
523
524             /* Compute parameters for interactions between i and j atoms */
525             qq20             = _fjsp_mul_v2r8(iq2,jq0);
526
527             /* REACTION-FIELD ELECTROSTATICS */
528             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
529             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
530
531             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
532
533             /* Update potential sum for this i atom from the interaction with this j atom. */
534             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
535             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
536             velecsum         = _fjsp_add_v2r8(velecsum,velec);
537
538             fscal            = felec;
539
540             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
541
542             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
543
544             /* Update vectorial force */
545             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
546             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
547             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
548             
549             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
550             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
551             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
552
553             }
554
555             /**************************
556              * CALCULATE INTERACTIONS *
557              **************************/
558
559             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
560             {
561
562             /* Compute parameters for interactions between i and j atoms */
563             qq30             = _fjsp_mul_v2r8(iq3,jq0);
564
565             /* REACTION-FIELD ELECTROSTATICS */
566             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
567             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
568
569             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
570
571             /* Update potential sum for this i atom from the interaction with this j atom. */
572             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
573             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
574             velecsum         = _fjsp_add_v2r8(velecsum,velec);
575
576             fscal            = felec;
577
578             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
579
580             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
581
582             /* Update vectorial force */
583             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
584             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
585             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
586             
587             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
588             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
589             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
590
591             }
592
593             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
594
595             /* Inner loop uses 164 flops */
596         }
597
598         /* End of innermost loop */
599
600         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
601                                               f+i_coord_offset,fshift+i_shift_offset);
602
603         ggid                        = gid[iidx];
604         /* Update potential energies */
605         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
606         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
607
608         /* Increment number of inner iterations */
609         inneriter                  += j_index_end - j_index_start;
610
611         /* Outer loop uses 26 flops */
612     }
613
614     /* Increment number of outer iterations */
615     outeriter        += nri;
616
617     /* Update outer/inner flops */
618
619     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*164);
620 }
621 /*
622  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
623  * Electrostatics interaction: ReactionField
624  * VdW interaction:            LennardJones
625  * Geometry:                   Water4-Particle
626  * Calculate force/pot:        Force
627  */
628 void
629 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
630                     (t_nblist                    * gmx_restrict       nlist,
631                      rvec                        * gmx_restrict          xx,
632                      rvec                        * gmx_restrict          ff,
633                      struct t_forcerec           * gmx_restrict          fr,
634                      t_mdatoms                   * gmx_restrict     mdatoms,
635                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
636                      t_nrnb                      * gmx_restrict        nrnb)
637 {
638     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
639      * just 0 for non-waters.
640      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
641      * jnr indices corresponding to data put in the four positions in the SIMD register.
642      */
643     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
644     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
645     int              jnrA,jnrB;
646     int              j_coord_offsetA,j_coord_offsetB;
647     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
648     real             rcutoff_scalar;
649     real             *shiftvec,*fshift,*x,*f;
650     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
651     int              vdwioffset0;
652     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
653     int              vdwioffset1;
654     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
655     int              vdwioffset2;
656     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
657     int              vdwioffset3;
658     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
659     int              vdwjidx0A,vdwjidx0B;
660     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
661     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
662     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
663     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
664     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
665     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
666     real             *charge;
667     int              nvdwtype;
668     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
669     int              *vdwtype;
670     real             *vdwparam;
671     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
672     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
673     _fjsp_v2r8       itab_tmp;
674     _fjsp_v2r8       dummy_mask,cutoff_mask;
675     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
676     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
677     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
678
679     x                = xx[0];
680     f                = ff[0];
681
682     nri              = nlist->nri;
683     iinr             = nlist->iinr;
684     jindex           = nlist->jindex;
685     jjnr             = nlist->jjnr;
686     shiftidx         = nlist->shift;
687     gid              = nlist->gid;
688     shiftvec         = fr->shift_vec[0];
689     fshift           = fr->fshift[0];
690     facel            = gmx_fjsp_set1_v2r8(fr->ic->epsfac);
691     charge           = mdatoms->chargeA;
692     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
693     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
694     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
695     nvdwtype         = fr->ntype;
696     vdwparam         = fr->nbfp;
697     vdwtype          = mdatoms->typeA;
698
699     /* Setup water-specific parameters */
700     inr              = nlist->iinr[0];
701     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
702     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
703     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
704     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
705
706     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
707     rcutoff_scalar   = fr->ic->rcoulomb;
708     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
709     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
710
711     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
712     rvdw             = gmx_fjsp_set1_v2r8(fr->ic->rvdw);
713
714     /* Avoid stupid compiler warnings */
715     jnrA = jnrB = 0;
716     j_coord_offsetA = 0;
717     j_coord_offsetB = 0;
718
719     outeriter        = 0;
720     inneriter        = 0;
721
722     /* Start outer loop over neighborlists */
723     for(iidx=0; iidx<nri; iidx++)
724     {
725         /* Load shift vector for this list */
726         i_shift_offset   = DIM*shiftidx[iidx];
727
728         /* Load limits for loop over neighbors */
729         j_index_start    = jindex[iidx];
730         j_index_end      = jindex[iidx+1];
731
732         /* Get outer coordinate index */
733         inr              = iinr[iidx];
734         i_coord_offset   = DIM*inr;
735
736         /* Load i particle coords and add shift vector */
737         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
738                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
739
740         fix0             = _fjsp_setzero_v2r8();
741         fiy0             = _fjsp_setzero_v2r8();
742         fiz0             = _fjsp_setzero_v2r8();
743         fix1             = _fjsp_setzero_v2r8();
744         fiy1             = _fjsp_setzero_v2r8();
745         fiz1             = _fjsp_setzero_v2r8();
746         fix2             = _fjsp_setzero_v2r8();
747         fiy2             = _fjsp_setzero_v2r8();
748         fiz2             = _fjsp_setzero_v2r8();
749         fix3             = _fjsp_setzero_v2r8();
750         fiy3             = _fjsp_setzero_v2r8();
751         fiz3             = _fjsp_setzero_v2r8();
752
753         /* Start inner kernel loop */
754         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
755         {
756
757             /* Get j neighbor index, and coordinate index */
758             jnrA             = jjnr[jidx];
759             jnrB             = jjnr[jidx+1];
760             j_coord_offsetA  = DIM*jnrA;
761             j_coord_offsetB  = DIM*jnrB;
762
763             /* load j atom coordinates */
764             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
765                                               &jx0,&jy0,&jz0);
766
767             /* Calculate displacement vector */
768             dx00             = _fjsp_sub_v2r8(ix0,jx0);
769             dy00             = _fjsp_sub_v2r8(iy0,jy0);
770             dz00             = _fjsp_sub_v2r8(iz0,jz0);
771             dx10             = _fjsp_sub_v2r8(ix1,jx0);
772             dy10             = _fjsp_sub_v2r8(iy1,jy0);
773             dz10             = _fjsp_sub_v2r8(iz1,jz0);
774             dx20             = _fjsp_sub_v2r8(ix2,jx0);
775             dy20             = _fjsp_sub_v2r8(iy2,jy0);
776             dz20             = _fjsp_sub_v2r8(iz2,jz0);
777             dx30             = _fjsp_sub_v2r8(ix3,jx0);
778             dy30             = _fjsp_sub_v2r8(iy3,jy0);
779             dz30             = _fjsp_sub_v2r8(iz3,jz0);
780
781             /* Calculate squared distance and things based on it */
782             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
783             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
784             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
785             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
786
787             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
788             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
789             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
790
791             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
792             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
793             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
794             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
795
796             /* Load parameters for j particles */
797             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
798             vdwjidx0A        = 2*vdwtype[jnrA+0];
799             vdwjidx0B        = 2*vdwtype[jnrB+0];
800
801             fjx0             = _fjsp_setzero_v2r8();
802             fjy0             = _fjsp_setzero_v2r8();
803             fjz0             = _fjsp_setzero_v2r8();
804
805             /**************************
806              * CALCULATE INTERACTIONS *
807              **************************/
808
809             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
810             {
811
812             /* Compute parameters for interactions between i and j atoms */
813             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
814                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
815
816             /* LENNARD-JONES DISPERSION/REPULSION */
817
818             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
819             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
820
821             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
822
823             fscal            = fvdw;
824
825             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
826
827             /* Update vectorial force */
828             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
829             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
830             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
831             
832             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
833             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
834             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
835
836             }
837
838             /**************************
839              * CALCULATE INTERACTIONS *
840              **************************/
841
842             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
843             {
844
845             /* Compute parameters for interactions between i and j atoms */
846             qq10             = _fjsp_mul_v2r8(iq1,jq0);
847
848             /* REACTION-FIELD ELECTROSTATICS */
849             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
850
851             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
852
853             fscal            = felec;
854
855             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
856
857             /* Update vectorial force */
858             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
859             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
860             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
861             
862             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
863             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
864             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
865
866             }
867
868             /**************************
869              * CALCULATE INTERACTIONS *
870              **************************/
871
872             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
873             {
874
875             /* Compute parameters for interactions between i and j atoms */
876             qq20             = _fjsp_mul_v2r8(iq2,jq0);
877
878             /* REACTION-FIELD ELECTROSTATICS */
879             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
880
881             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
882
883             fscal            = felec;
884
885             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
886
887             /* Update vectorial force */
888             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
889             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
890             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
891             
892             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
893             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
894             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
895
896             }
897
898             /**************************
899              * CALCULATE INTERACTIONS *
900              **************************/
901
902             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
903             {
904
905             /* Compute parameters for interactions between i and j atoms */
906             qq30             = _fjsp_mul_v2r8(iq3,jq0);
907
908             /* REACTION-FIELD ELECTROSTATICS */
909             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
910
911             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
912
913             fscal            = felec;
914
915             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
916
917             /* Update vectorial force */
918             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
919             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
920             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
921             
922             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
923             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
924             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
925
926             }
927
928             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
929
930             /* Inner loop uses 135 flops */
931         }
932
933         if(jidx<j_index_end)
934         {
935
936             jnrA             = jjnr[jidx];
937             j_coord_offsetA  = DIM*jnrA;
938
939             /* load j atom coordinates */
940             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
941                                               &jx0,&jy0,&jz0);
942
943             /* Calculate displacement vector */
944             dx00             = _fjsp_sub_v2r8(ix0,jx0);
945             dy00             = _fjsp_sub_v2r8(iy0,jy0);
946             dz00             = _fjsp_sub_v2r8(iz0,jz0);
947             dx10             = _fjsp_sub_v2r8(ix1,jx0);
948             dy10             = _fjsp_sub_v2r8(iy1,jy0);
949             dz10             = _fjsp_sub_v2r8(iz1,jz0);
950             dx20             = _fjsp_sub_v2r8(ix2,jx0);
951             dy20             = _fjsp_sub_v2r8(iy2,jy0);
952             dz20             = _fjsp_sub_v2r8(iz2,jz0);
953             dx30             = _fjsp_sub_v2r8(ix3,jx0);
954             dy30             = _fjsp_sub_v2r8(iy3,jy0);
955             dz30             = _fjsp_sub_v2r8(iz3,jz0);
956
957             /* Calculate squared distance and things based on it */
958             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
959             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
960             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
961             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
962
963             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
964             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
965             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
966
967             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
968             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
969             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
970             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
971
972             /* Load parameters for j particles */
973             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
974             vdwjidx0A        = 2*vdwtype[jnrA+0];
975
976             fjx0             = _fjsp_setzero_v2r8();
977             fjy0             = _fjsp_setzero_v2r8();
978             fjz0             = _fjsp_setzero_v2r8();
979
980             /**************************
981              * CALCULATE INTERACTIONS *
982              **************************/
983
984             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
985             {
986
987             /* Compute parameters for interactions between i and j atoms */
988             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
989                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
990
991             /* LENNARD-JONES DISPERSION/REPULSION */
992
993             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
994             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
995
996             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
997
998             fscal            = fvdw;
999
1000             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1001
1002             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1003
1004             /* Update vectorial force */
1005             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1006             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1007             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1008             
1009             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1010             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1011             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1012
1013             }
1014
1015             /**************************
1016              * CALCULATE INTERACTIONS *
1017              **************************/
1018
1019             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1020             {
1021
1022             /* Compute parameters for interactions between i and j atoms */
1023             qq10             = _fjsp_mul_v2r8(iq1,jq0);
1024
1025             /* REACTION-FIELD ELECTROSTATICS */
1026             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
1027
1028             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
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             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1038             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1039             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1040             
1041             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1042             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1043             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1044
1045             }
1046
1047             /**************************
1048              * CALCULATE INTERACTIONS *
1049              **************************/
1050
1051             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1052             {
1053
1054             /* Compute parameters for interactions between i and j atoms */
1055             qq20             = _fjsp_mul_v2r8(iq2,jq0);
1056
1057             /* REACTION-FIELD ELECTROSTATICS */
1058             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
1059
1060             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1061
1062             fscal            = felec;
1063
1064             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1065
1066             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1067
1068             /* Update vectorial force */
1069             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1070             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1071             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1072             
1073             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1074             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1075             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1076
1077             }
1078
1079             /**************************
1080              * CALCULATE INTERACTIONS *
1081              **************************/
1082
1083             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1084             {
1085
1086             /* Compute parameters for interactions between i and j atoms */
1087             qq30             = _fjsp_mul_v2r8(iq3,jq0);
1088
1089             /* REACTION-FIELD ELECTROSTATICS */
1090             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
1091
1092             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1093
1094             fscal            = felec;
1095
1096             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1097
1098             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1099
1100             /* Update vectorial force */
1101             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
1102             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1103             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1104             
1105             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1106             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1107             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1108
1109             }
1110
1111             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1112
1113             /* Inner loop uses 135 flops */
1114         }
1115
1116         /* End of innermost loop */
1117
1118         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1119                                               f+i_coord_offset,fshift+i_shift_offset);
1120
1121         /* Increment number of inner iterations */
1122         inneriter                  += j_index_end - j_index_start;
1123
1124         /* Outer loop uses 24 flops */
1125     }
1126
1127     /* Increment number of outer iterations */
1128     outeriter        += nri;
1129
1130     /* Update outer/inner flops */
1131
1132     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*135);
1133 }