Fujitsu Sparc64 acceleration and general fixes for non-x86 builds
[alexxy/gromacs.git] / src / 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, by the GROMACS development team, led by
5  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6  * others, as listed in the AUTHORS file in the top-level source
7  * 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 "vec.h"
47 #include "nrnb.h"
48
49 #include "kernelutil_sparc64_hpc_ace_double.h"
50
51 /*
52  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_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_VdwLJSh_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_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       itab_tmp;
104     _fjsp_v2r8       dummy_mask,cutoff_mask;
105     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
106     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
107     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
108
109     x                = xx[0];
110     f                = ff[0];
111
112     nri              = nlist->nri;
113     iinr             = nlist->iinr;
114     jindex           = nlist->jindex;
115     jjnr             = nlist->jjnr;
116     shiftidx         = nlist->shift;
117     gid              = nlist->gid;
118     shiftvec         = fr->shift_vec[0];
119     fshift           = fr->fshift[0];
120     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
121     charge           = mdatoms->chargeA;
122     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
123     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
124     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
125     nvdwtype         = fr->ntype;
126     vdwparam         = fr->nbfp;
127     vdwtype          = mdatoms->typeA;
128
129     /* Setup water-specific parameters */
130     inr              = nlist->iinr[0];
131     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
132     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
133     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
134     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
135
136     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
137     rcutoff_scalar   = fr->rcoulomb;
138     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
139     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
140
141     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
142     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
143
144     /* Avoid stupid compiler warnings */
145     jnrA = jnrB = 0;
146     j_coord_offsetA = 0;
147     j_coord_offsetB = 0;
148
149     outeriter        = 0;
150     inneriter        = 0;
151
152     /* Start outer loop over neighborlists */
153     for(iidx=0; iidx<nri; iidx++)
154     {
155         /* Load shift vector for this list */
156         i_shift_offset   = DIM*shiftidx[iidx];
157
158         /* Load limits for loop over neighbors */
159         j_index_start    = jindex[iidx];
160         j_index_end      = jindex[iidx+1];
161
162         /* Get outer coordinate index */
163         inr              = iinr[iidx];
164         i_coord_offset   = DIM*inr;
165
166         /* Load i particle coords and add shift vector */
167         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
168                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
169
170         fix0             = _fjsp_setzero_v2r8();
171         fiy0             = _fjsp_setzero_v2r8();
172         fiz0             = _fjsp_setzero_v2r8();
173         fix1             = _fjsp_setzero_v2r8();
174         fiy1             = _fjsp_setzero_v2r8();
175         fiz1             = _fjsp_setzero_v2r8();
176         fix2             = _fjsp_setzero_v2r8();
177         fiy2             = _fjsp_setzero_v2r8();
178         fiz2             = _fjsp_setzero_v2r8();
179         fix3             = _fjsp_setzero_v2r8();
180         fiy3             = _fjsp_setzero_v2r8();
181         fiz3             = _fjsp_setzero_v2r8();
182
183         /* Reset potential sums */
184         velecsum         = _fjsp_setzero_v2r8();
185         vvdwsum          = _fjsp_setzero_v2r8();
186
187         /* Start inner kernel loop */
188         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
189         {
190
191             /* Get j neighbor index, and coordinate index */
192             jnrA             = jjnr[jidx];
193             jnrB             = jjnr[jidx+1];
194             j_coord_offsetA  = DIM*jnrA;
195             j_coord_offsetB  = DIM*jnrB;
196
197             /* load j atom coordinates */
198             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
199                                               &jx0,&jy0,&jz0);
200
201             /* Calculate displacement vector */
202             dx00             = _fjsp_sub_v2r8(ix0,jx0);
203             dy00             = _fjsp_sub_v2r8(iy0,jy0);
204             dz00             = _fjsp_sub_v2r8(iz0,jz0);
205             dx10             = _fjsp_sub_v2r8(ix1,jx0);
206             dy10             = _fjsp_sub_v2r8(iy1,jy0);
207             dz10             = _fjsp_sub_v2r8(iz1,jz0);
208             dx20             = _fjsp_sub_v2r8(ix2,jx0);
209             dy20             = _fjsp_sub_v2r8(iy2,jy0);
210             dz20             = _fjsp_sub_v2r8(iz2,jz0);
211             dx30             = _fjsp_sub_v2r8(ix3,jx0);
212             dy30             = _fjsp_sub_v2r8(iy3,jy0);
213             dz30             = _fjsp_sub_v2r8(iz3,jz0);
214
215             /* Calculate squared distance and things based on it */
216             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
217             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
218             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
219             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
220
221             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
222             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
223             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
224
225             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
226             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
227             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
228             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
229
230             /* Load parameters for j particles */
231             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
232             vdwjidx0A        = 2*vdwtype[jnrA+0];
233             vdwjidx0B        = 2*vdwtype[jnrB+0];
234
235             fjx0             = _fjsp_setzero_v2r8();
236             fjy0             = _fjsp_setzero_v2r8();
237             fjz0             = _fjsp_setzero_v2r8();
238
239             /**************************
240              * CALCULATE INTERACTIONS *
241              **************************/
242
243             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
244             {
245
246             /* Compute parameters for interactions between i and j atoms */
247             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
248                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
249
250             /* LENNARD-JONES DISPERSION/REPULSION */
251
252             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
253             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
254             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
255             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
256                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
257             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
258
259             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
260
261             /* Update potential sum for this i atom from the interaction with this j atom. */
262             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
263             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
264
265             fscal            = fvdw;
266
267             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
268
269             /* Update vectorial force */
270             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
271             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
272             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
273             
274             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
275             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
276             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
277
278             }
279
280             /**************************
281              * CALCULATE INTERACTIONS *
282              **************************/
283
284             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
285             {
286
287             /* Compute parameters for interactions between i and j atoms */
288             qq10             = _fjsp_mul_v2r8(iq1,jq0);
289
290             /* REACTION-FIELD ELECTROSTATICS */
291             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
292             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
293
294             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
295
296             /* Update potential sum for this i atom from the interaction with this j atom. */
297             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
298             velecsum         = _fjsp_add_v2r8(velecsum,velec);
299
300             fscal            = felec;
301
302             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
303
304             /* Update vectorial force */
305             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
306             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
307             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
308             
309             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
310             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
311             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
312
313             }
314
315             /**************************
316              * CALCULATE INTERACTIONS *
317              **************************/
318
319             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
320             {
321
322             /* Compute parameters for interactions between i and j atoms */
323             qq20             = _fjsp_mul_v2r8(iq2,jq0);
324
325             /* REACTION-FIELD ELECTROSTATICS */
326             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
327             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
328
329             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
330
331             /* Update potential sum for this i atom from the interaction with this j atom. */
332             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
333             velecsum         = _fjsp_add_v2r8(velecsum,velec);
334
335             fscal            = felec;
336
337             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
338
339             /* Update vectorial force */
340             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
341             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
342             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
343             
344             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
345             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
346             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
347
348             }
349
350             /**************************
351              * CALCULATE INTERACTIONS *
352              **************************/
353
354             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
355             {
356
357             /* Compute parameters for interactions between i and j atoms */
358             qq30             = _fjsp_mul_v2r8(iq3,jq0);
359
360             /* REACTION-FIELD ELECTROSTATICS */
361             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
362             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
363
364             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
365
366             /* Update potential sum for this i atom from the interaction with this j atom. */
367             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
368             velecsum         = _fjsp_add_v2r8(velecsum,velec);
369
370             fscal            = felec;
371
372             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
373
374             /* Update vectorial force */
375             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
376             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
377             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
378             
379             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
380             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
381             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
382
383             }
384
385             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
386
387             /* Inner loop uses 164 flops */
388         }
389
390         if(jidx<j_index_end)
391         {
392
393             jnrA             = jjnr[jidx];
394             j_coord_offsetA  = DIM*jnrA;
395
396             /* load j atom coordinates */
397             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
398                                               &jx0,&jy0,&jz0);
399
400             /* Calculate displacement vector */
401             dx00             = _fjsp_sub_v2r8(ix0,jx0);
402             dy00             = _fjsp_sub_v2r8(iy0,jy0);
403             dz00             = _fjsp_sub_v2r8(iz0,jz0);
404             dx10             = _fjsp_sub_v2r8(ix1,jx0);
405             dy10             = _fjsp_sub_v2r8(iy1,jy0);
406             dz10             = _fjsp_sub_v2r8(iz1,jz0);
407             dx20             = _fjsp_sub_v2r8(ix2,jx0);
408             dy20             = _fjsp_sub_v2r8(iy2,jy0);
409             dz20             = _fjsp_sub_v2r8(iz2,jz0);
410             dx30             = _fjsp_sub_v2r8(ix3,jx0);
411             dy30             = _fjsp_sub_v2r8(iy3,jy0);
412             dz30             = _fjsp_sub_v2r8(iz3,jz0);
413
414             /* Calculate squared distance and things based on it */
415             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
416             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
417             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
418             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
419
420             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
421             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
422             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
423
424             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
425             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
426             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
427             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
428
429             /* Load parameters for j particles */
430             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
431             vdwjidx0A        = 2*vdwtype[jnrA+0];
432
433             fjx0             = _fjsp_setzero_v2r8();
434             fjy0             = _fjsp_setzero_v2r8();
435             fjz0             = _fjsp_setzero_v2r8();
436
437             /**************************
438              * CALCULATE INTERACTIONS *
439              **************************/
440
441             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
442             {
443
444             /* Compute parameters for interactions between i and j atoms */
445             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
446
447             /* LENNARD-JONES DISPERSION/REPULSION */
448
449             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
450             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
451             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
452             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
453                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
454             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
455
456             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
457
458             /* Update potential sum for this i atom from the interaction with this j atom. */
459             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
460             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
461             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
462
463             fscal            = fvdw;
464
465             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
466
467             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
468
469             /* Update vectorial force */
470             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
471             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
472             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
473             
474             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
475             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
476             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
477
478             }
479
480             /**************************
481              * CALCULATE INTERACTIONS *
482              **************************/
483
484             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
485             {
486
487             /* Compute parameters for interactions between i and j atoms */
488             qq10             = _fjsp_mul_v2r8(iq1,jq0);
489
490             /* REACTION-FIELD ELECTROSTATICS */
491             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
492             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
493
494             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
495
496             /* Update potential sum for this i atom from the interaction with this j atom. */
497             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
498             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
499             velecsum         = _fjsp_add_v2r8(velecsum,velec);
500
501             fscal            = felec;
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             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
509             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
510             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
511             
512             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
513             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
514             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
515
516             }
517
518             /**************************
519              * CALCULATE INTERACTIONS *
520              **************************/
521
522             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
523             {
524
525             /* Compute parameters for interactions between i and j atoms */
526             qq20             = _fjsp_mul_v2r8(iq2,jq0);
527
528             /* REACTION-FIELD ELECTROSTATICS */
529             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
530             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
531
532             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,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             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
547             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
548             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
549             
550             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
551             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
552             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
553
554             }
555
556             /**************************
557              * CALCULATE INTERACTIONS *
558              **************************/
559
560             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
561             {
562
563             /* Compute parameters for interactions between i and j atoms */
564             qq30             = _fjsp_mul_v2r8(iq3,jq0);
565
566             /* REACTION-FIELD ELECTROSTATICS */
567             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
568             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
569
570             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,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             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
585             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
586             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
587             
588             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
589             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
590             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
591
592             }
593
594             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
595
596             /* Inner loop uses 164 flops */
597         }
598
599         /* End of innermost loop */
600
601         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
602                                               f+i_coord_offset,fshift+i_shift_offset);
603
604         ggid                        = gid[iidx];
605         /* Update potential energies */
606         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
607         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
608
609         /* Increment number of inner iterations */
610         inneriter                  += j_index_end - j_index_start;
611
612         /* Outer loop uses 26 flops */
613     }
614
615     /* Increment number of outer iterations */
616     outeriter        += nri;
617
618     /* Update outer/inner flops */
619
620     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*164);
621 }
622 /*
623  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
624  * Electrostatics interaction: ReactionField
625  * VdW interaction:            LennardJones
626  * Geometry:                   Water4-Particle
627  * Calculate force/pot:        Force
628  */
629 void
630 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
631                     (t_nblist * gmx_restrict                nlist,
632                      rvec * gmx_restrict                    xx,
633                      rvec * gmx_restrict                    ff,
634                      t_forcerec * gmx_restrict              fr,
635                      t_mdatoms * gmx_restrict               mdatoms,
636                      nb_kernel_data_t * gmx_restrict        kernel_data,
637                      t_nrnb * gmx_restrict                  nrnb)
638 {
639     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
640      * just 0 for non-waters.
641      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
642      * jnr indices corresponding to data put in the four positions in the SIMD register.
643      */
644     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
645     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
646     int              jnrA,jnrB;
647     int              j_coord_offsetA,j_coord_offsetB;
648     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
649     real             rcutoff_scalar;
650     real             *shiftvec,*fshift,*x,*f;
651     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
652     int              vdwioffset0;
653     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
654     int              vdwioffset1;
655     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
656     int              vdwioffset2;
657     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
658     int              vdwioffset3;
659     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
660     int              vdwjidx0A,vdwjidx0B;
661     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
662     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
663     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
664     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
665     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
666     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
667     real             *charge;
668     int              nvdwtype;
669     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
670     int              *vdwtype;
671     real             *vdwparam;
672     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
673     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
674     _fjsp_v2r8       itab_tmp;
675     _fjsp_v2r8       dummy_mask,cutoff_mask;
676     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
677     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
678     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
679
680     x                = xx[0];
681     f                = ff[0];
682
683     nri              = nlist->nri;
684     iinr             = nlist->iinr;
685     jindex           = nlist->jindex;
686     jjnr             = nlist->jjnr;
687     shiftidx         = nlist->shift;
688     gid              = nlist->gid;
689     shiftvec         = fr->shift_vec[0];
690     fshift           = fr->fshift[0];
691     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
692     charge           = mdatoms->chargeA;
693     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
694     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
695     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
696     nvdwtype         = fr->ntype;
697     vdwparam         = fr->nbfp;
698     vdwtype          = mdatoms->typeA;
699
700     /* Setup water-specific parameters */
701     inr              = nlist->iinr[0];
702     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
703     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
704     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
705     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
706
707     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
708     rcutoff_scalar   = fr->rcoulomb;
709     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
710     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
711
712     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
713     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
714
715     /* Avoid stupid compiler warnings */
716     jnrA = jnrB = 0;
717     j_coord_offsetA = 0;
718     j_coord_offsetB = 0;
719
720     outeriter        = 0;
721     inneriter        = 0;
722
723     /* Start outer loop over neighborlists */
724     for(iidx=0; iidx<nri; iidx++)
725     {
726         /* Load shift vector for this list */
727         i_shift_offset   = DIM*shiftidx[iidx];
728
729         /* Load limits for loop over neighbors */
730         j_index_start    = jindex[iidx];
731         j_index_end      = jindex[iidx+1];
732
733         /* Get outer coordinate index */
734         inr              = iinr[iidx];
735         i_coord_offset   = DIM*inr;
736
737         /* Load i particle coords and add shift vector */
738         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
739                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
740
741         fix0             = _fjsp_setzero_v2r8();
742         fiy0             = _fjsp_setzero_v2r8();
743         fiz0             = _fjsp_setzero_v2r8();
744         fix1             = _fjsp_setzero_v2r8();
745         fiy1             = _fjsp_setzero_v2r8();
746         fiz1             = _fjsp_setzero_v2r8();
747         fix2             = _fjsp_setzero_v2r8();
748         fiy2             = _fjsp_setzero_v2r8();
749         fiz2             = _fjsp_setzero_v2r8();
750         fix3             = _fjsp_setzero_v2r8();
751         fiy3             = _fjsp_setzero_v2r8();
752         fiz3             = _fjsp_setzero_v2r8();
753
754         /* Start inner kernel loop */
755         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
756         {
757
758             /* Get j neighbor index, and coordinate index */
759             jnrA             = jjnr[jidx];
760             jnrB             = jjnr[jidx+1];
761             j_coord_offsetA  = DIM*jnrA;
762             j_coord_offsetB  = DIM*jnrB;
763
764             /* load j atom coordinates */
765             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
766                                               &jx0,&jy0,&jz0);
767
768             /* Calculate displacement vector */
769             dx00             = _fjsp_sub_v2r8(ix0,jx0);
770             dy00             = _fjsp_sub_v2r8(iy0,jy0);
771             dz00             = _fjsp_sub_v2r8(iz0,jz0);
772             dx10             = _fjsp_sub_v2r8(ix1,jx0);
773             dy10             = _fjsp_sub_v2r8(iy1,jy0);
774             dz10             = _fjsp_sub_v2r8(iz1,jz0);
775             dx20             = _fjsp_sub_v2r8(ix2,jx0);
776             dy20             = _fjsp_sub_v2r8(iy2,jy0);
777             dz20             = _fjsp_sub_v2r8(iz2,jz0);
778             dx30             = _fjsp_sub_v2r8(ix3,jx0);
779             dy30             = _fjsp_sub_v2r8(iy3,jy0);
780             dz30             = _fjsp_sub_v2r8(iz3,jz0);
781
782             /* Calculate squared distance and things based on it */
783             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
784             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
785             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
786             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
787
788             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
789             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
790             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
791
792             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
793             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
794             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
795             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
796
797             /* Load parameters for j particles */
798             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
799             vdwjidx0A        = 2*vdwtype[jnrA+0];
800             vdwjidx0B        = 2*vdwtype[jnrB+0];
801
802             fjx0             = _fjsp_setzero_v2r8();
803             fjy0             = _fjsp_setzero_v2r8();
804             fjz0             = _fjsp_setzero_v2r8();
805
806             /**************************
807              * CALCULATE INTERACTIONS *
808              **************************/
809
810             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
811             {
812
813             /* Compute parameters for interactions between i and j atoms */
814             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
815                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
816
817             /* LENNARD-JONES DISPERSION/REPULSION */
818
819             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
820             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
821
822             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
823
824             fscal            = fvdw;
825
826             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
827
828             /* Update vectorial force */
829             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
830             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
831             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
832             
833             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
834             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
835             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
836
837             }
838
839             /**************************
840              * CALCULATE INTERACTIONS *
841              **************************/
842
843             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
844             {
845
846             /* Compute parameters for interactions between i and j atoms */
847             qq10             = _fjsp_mul_v2r8(iq1,jq0);
848
849             /* REACTION-FIELD ELECTROSTATICS */
850             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
851
852             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
853
854             fscal            = felec;
855
856             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
857
858             /* Update vectorial force */
859             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
860             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
861             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
862             
863             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
864             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
865             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
866
867             }
868
869             /**************************
870              * CALCULATE INTERACTIONS *
871              **************************/
872
873             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
874             {
875
876             /* Compute parameters for interactions between i and j atoms */
877             qq20             = _fjsp_mul_v2r8(iq2,jq0);
878
879             /* REACTION-FIELD ELECTROSTATICS */
880             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
881
882             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
883
884             fscal            = felec;
885
886             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
887
888             /* Update vectorial force */
889             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
890             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
891             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
892             
893             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
894             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
895             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
896
897             }
898
899             /**************************
900              * CALCULATE INTERACTIONS *
901              **************************/
902
903             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
904             {
905
906             /* Compute parameters for interactions between i and j atoms */
907             qq30             = _fjsp_mul_v2r8(iq3,jq0);
908
909             /* REACTION-FIELD ELECTROSTATICS */
910             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
911
912             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
913
914             fscal            = felec;
915
916             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
917
918             /* Update vectorial force */
919             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
920             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
921             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
922             
923             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
924             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
925             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
926
927             }
928
929             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
930
931             /* Inner loop uses 135 flops */
932         }
933
934         if(jidx<j_index_end)
935         {
936
937             jnrA             = jjnr[jidx];
938             j_coord_offsetA  = DIM*jnrA;
939
940             /* load j atom coordinates */
941             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
942                                               &jx0,&jy0,&jz0);
943
944             /* Calculate displacement vector */
945             dx00             = _fjsp_sub_v2r8(ix0,jx0);
946             dy00             = _fjsp_sub_v2r8(iy0,jy0);
947             dz00             = _fjsp_sub_v2r8(iz0,jz0);
948             dx10             = _fjsp_sub_v2r8(ix1,jx0);
949             dy10             = _fjsp_sub_v2r8(iy1,jy0);
950             dz10             = _fjsp_sub_v2r8(iz1,jz0);
951             dx20             = _fjsp_sub_v2r8(ix2,jx0);
952             dy20             = _fjsp_sub_v2r8(iy2,jy0);
953             dz20             = _fjsp_sub_v2r8(iz2,jz0);
954             dx30             = _fjsp_sub_v2r8(ix3,jx0);
955             dy30             = _fjsp_sub_v2r8(iy3,jy0);
956             dz30             = _fjsp_sub_v2r8(iz3,jz0);
957
958             /* Calculate squared distance and things based on it */
959             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
960             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
961             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
962             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
963
964             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
965             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
966             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
967
968             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
969             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
970             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
971             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
972
973             /* Load parameters for j particles */
974             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
975             vdwjidx0A        = 2*vdwtype[jnrA+0];
976
977             fjx0             = _fjsp_setzero_v2r8();
978             fjy0             = _fjsp_setzero_v2r8();
979             fjz0             = _fjsp_setzero_v2r8();
980
981             /**************************
982              * CALCULATE INTERACTIONS *
983              **************************/
984
985             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
986             {
987
988             /* Compute parameters for interactions between i and j atoms */
989             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&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 }