Merge release-5-0 into master
[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, 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/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/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_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset0;
82     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83     int              vdwioffset1;
84     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85     int              vdwioffset2;
86     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87     int              vdwioffset3;
88     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
89     int              vdwjidx0A,vdwjidx0B;
90     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
91     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
93     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
94     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
95     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
96     real             *charge;
97     int              nvdwtype;
98     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
99     int              *vdwtype;
100     real             *vdwparam;
101     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
102     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
103     _fjsp_v2r8       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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
446                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
447
448             /* LENNARD-JONES DISPERSION/REPULSION */
449
450             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
451             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
452             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
453             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
454                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
455             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
456
457             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
458
459             /* Update potential sum for this i atom from the interaction with this j atom. */
460             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
461             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
462             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
463
464             fscal            = fvdw;
465
466             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
467
468             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
469
470             /* Update vectorial force */
471             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
472             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
473             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
474             
475             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
476             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
477             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
478
479             }
480
481             /**************************
482              * CALCULATE INTERACTIONS *
483              **************************/
484
485             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
486             {
487
488             /* Compute parameters for interactions between i and j atoms */
489             qq10             = _fjsp_mul_v2r8(iq1,jq0);
490
491             /* REACTION-FIELD ELECTROSTATICS */
492             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
493             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
494
495             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
496
497             /* Update potential sum for this i atom from the interaction with this j atom. */
498             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
499             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
500             velecsum         = _fjsp_add_v2r8(velecsum,velec);
501
502             fscal            = felec;
503
504             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
505
506             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
507
508             /* Update vectorial force */
509             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
510             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
511             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
512             
513             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
514             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
515             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
516
517             }
518
519             /**************************
520              * CALCULATE INTERACTIONS *
521              **************************/
522
523             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
524             {
525
526             /* Compute parameters for interactions between i and j atoms */
527             qq20             = _fjsp_mul_v2r8(iq2,jq0);
528
529             /* REACTION-FIELD ELECTROSTATICS */
530             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
531             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
532
533             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
534
535             /* Update potential sum for this i atom from the interaction with this j atom. */
536             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
537             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
538             velecsum         = _fjsp_add_v2r8(velecsum,velec);
539
540             fscal            = felec;
541
542             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
543
544             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
545
546             /* Update vectorial force */
547             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
548             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
549             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
550             
551             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
552             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
553             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
554
555             }
556
557             /**************************
558              * CALCULATE INTERACTIONS *
559              **************************/
560
561             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
562             {
563
564             /* Compute parameters for interactions between i and j atoms */
565             qq30             = _fjsp_mul_v2r8(iq3,jq0);
566
567             /* REACTION-FIELD ELECTROSTATICS */
568             velec            = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
569             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
570
571             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
572
573             /* Update potential sum for this i atom from the interaction with this j atom. */
574             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
575             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
576             velecsum         = _fjsp_add_v2r8(velecsum,velec);
577
578             fscal            = felec;
579
580             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
581
582             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
583
584             /* Update vectorial force */
585             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
586             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
587             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
588             
589             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
590             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
591             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
592
593             }
594
595             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
596
597             /* Inner loop uses 164 flops */
598         }
599
600         /* End of innermost loop */
601
602         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
603                                               f+i_coord_offset,fshift+i_shift_offset);
604
605         ggid                        = gid[iidx];
606         /* Update potential energies */
607         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
608         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
609
610         /* Increment number of inner iterations */
611         inneriter                  += j_index_end - j_index_start;
612
613         /* Outer loop uses 26 flops */
614     }
615
616     /* Increment number of outer iterations */
617     outeriter        += nri;
618
619     /* Update outer/inner flops */
620
621     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*164);
622 }
623 /*
624  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
625  * Electrostatics interaction: ReactionField
626  * VdW interaction:            LennardJones
627  * Geometry:                   Water4-Particle
628  * Calculate force/pot:        Force
629  */
630 void
631 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
632                     (t_nblist                    * gmx_restrict       nlist,
633                      rvec                        * gmx_restrict          xx,
634                      rvec                        * gmx_restrict          ff,
635                      t_forcerec                  * gmx_restrict          fr,
636                      t_mdatoms                   * gmx_restrict     mdatoms,
637                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
638                      t_nrnb                      * gmx_restrict        nrnb)
639 {
640     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
641      * just 0 for non-waters.
642      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
643      * jnr indices corresponding to data put in the four positions in the SIMD register.
644      */
645     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
646     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
647     int              jnrA,jnrB;
648     int              j_coord_offsetA,j_coord_offsetB;
649     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
650     real             rcutoff_scalar;
651     real             *shiftvec,*fshift,*x,*f;
652     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
653     int              vdwioffset0;
654     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
655     int              vdwioffset1;
656     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
657     int              vdwioffset2;
658     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
659     int              vdwioffset3;
660     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
661     int              vdwjidx0A,vdwjidx0B;
662     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
663     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
664     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
665     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
666     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
667     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
668     real             *charge;
669     int              nvdwtype;
670     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
671     int              *vdwtype;
672     real             *vdwparam;
673     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
674     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
675     _fjsp_v2r8       itab_tmp;
676     _fjsp_v2r8       dummy_mask,cutoff_mask;
677     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
678     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
679     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
680
681     x                = xx[0];
682     f                = ff[0];
683
684     nri              = nlist->nri;
685     iinr             = nlist->iinr;
686     jindex           = nlist->jindex;
687     jjnr             = nlist->jjnr;
688     shiftidx         = nlist->shift;
689     gid              = nlist->gid;
690     shiftvec         = fr->shift_vec[0];
691     fshift           = fr->fshift[0];
692     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
693     charge           = mdatoms->chargeA;
694     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
695     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
696     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
697     nvdwtype         = fr->ntype;
698     vdwparam         = fr->nbfp;
699     vdwtype          = mdatoms->typeA;
700
701     /* Setup water-specific parameters */
702     inr              = nlist->iinr[0];
703     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
704     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
705     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
706     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
707
708     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
709     rcutoff_scalar   = fr->rcoulomb;
710     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
711     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
712
713     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
714     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
715
716     /* Avoid stupid compiler warnings */
717     jnrA = jnrB = 0;
718     j_coord_offsetA = 0;
719     j_coord_offsetB = 0;
720
721     outeriter        = 0;
722     inneriter        = 0;
723
724     /* Start outer loop over neighborlists */
725     for(iidx=0; iidx<nri; iidx++)
726     {
727         /* Load shift vector for this list */
728         i_shift_offset   = DIM*shiftidx[iidx];
729
730         /* Load limits for loop over neighbors */
731         j_index_start    = jindex[iidx];
732         j_index_end      = jindex[iidx+1];
733
734         /* Get outer coordinate index */
735         inr              = iinr[iidx];
736         i_coord_offset   = DIM*inr;
737
738         /* Load i particle coords and add shift vector */
739         gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
740                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
741
742         fix0             = _fjsp_setzero_v2r8();
743         fiy0             = _fjsp_setzero_v2r8();
744         fiz0             = _fjsp_setzero_v2r8();
745         fix1             = _fjsp_setzero_v2r8();
746         fiy1             = _fjsp_setzero_v2r8();
747         fiz1             = _fjsp_setzero_v2r8();
748         fix2             = _fjsp_setzero_v2r8();
749         fiy2             = _fjsp_setzero_v2r8();
750         fiz2             = _fjsp_setzero_v2r8();
751         fix3             = _fjsp_setzero_v2r8();
752         fiy3             = _fjsp_setzero_v2r8();
753         fiz3             = _fjsp_setzero_v2r8();
754
755         /* Start inner kernel loop */
756         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
757         {
758
759             /* Get j neighbor index, and coordinate index */
760             jnrA             = jjnr[jidx];
761             jnrB             = jjnr[jidx+1];
762             j_coord_offsetA  = DIM*jnrA;
763             j_coord_offsetB  = DIM*jnrB;
764
765             /* load j atom coordinates */
766             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
767                                               &jx0,&jy0,&jz0);
768
769             /* Calculate displacement vector */
770             dx00             = _fjsp_sub_v2r8(ix0,jx0);
771             dy00             = _fjsp_sub_v2r8(iy0,jy0);
772             dz00             = _fjsp_sub_v2r8(iz0,jz0);
773             dx10             = _fjsp_sub_v2r8(ix1,jx0);
774             dy10             = _fjsp_sub_v2r8(iy1,jy0);
775             dz10             = _fjsp_sub_v2r8(iz1,jz0);
776             dx20             = _fjsp_sub_v2r8(ix2,jx0);
777             dy20             = _fjsp_sub_v2r8(iy2,jy0);
778             dz20             = _fjsp_sub_v2r8(iz2,jz0);
779             dx30             = _fjsp_sub_v2r8(ix3,jx0);
780             dy30             = _fjsp_sub_v2r8(iy3,jy0);
781             dz30             = _fjsp_sub_v2r8(iz3,jz0);
782
783             /* Calculate squared distance and things based on it */
784             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
785             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
786             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
787             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
788
789             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
790             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
791             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
792
793             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
794             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
795             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
796             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
797
798             /* Load parameters for j particles */
799             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
800             vdwjidx0A        = 2*vdwtype[jnrA+0];
801             vdwjidx0B        = 2*vdwtype[jnrB+0];
802
803             fjx0             = _fjsp_setzero_v2r8();
804             fjy0             = _fjsp_setzero_v2r8();
805             fjz0             = _fjsp_setzero_v2r8();
806
807             /**************************
808              * CALCULATE INTERACTIONS *
809              **************************/
810
811             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
812             {
813
814             /* Compute parameters for interactions between i and j atoms */
815             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
816                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
817
818             /* LENNARD-JONES DISPERSION/REPULSION */
819
820             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
821             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
822
823             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
824
825             fscal            = fvdw;
826
827             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
828
829             /* Update vectorial force */
830             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
831             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
832             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
833             
834             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
835             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
836             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
837
838             }
839
840             /**************************
841              * CALCULATE INTERACTIONS *
842              **************************/
843
844             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
845             {
846
847             /* Compute parameters for interactions between i and j atoms */
848             qq10             = _fjsp_mul_v2r8(iq1,jq0);
849
850             /* REACTION-FIELD ELECTROSTATICS */
851             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
852
853             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
854
855             fscal            = felec;
856
857             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
858
859             /* Update vectorial force */
860             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
861             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
862             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
863             
864             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
865             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
866             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
867
868             }
869
870             /**************************
871              * CALCULATE INTERACTIONS *
872              **************************/
873
874             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
875             {
876
877             /* Compute parameters for interactions between i and j atoms */
878             qq20             = _fjsp_mul_v2r8(iq2,jq0);
879
880             /* REACTION-FIELD ELECTROSTATICS */
881             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
882
883             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
884
885             fscal            = felec;
886
887             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
888
889             /* Update vectorial force */
890             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
891             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
892             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
893             
894             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
895             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
896             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
897
898             }
899
900             /**************************
901              * CALCULATE INTERACTIONS *
902              **************************/
903
904             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
905             {
906
907             /* Compute parameters for interactions between i and j atoms */
908             qq30             = _fjsp_mul_v2r8(iq3,jq0);
909
910             /* REACTION-FIELD ELECTROSTATICS */
911             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
912
913             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
914
915             fscal            = felec;
916
917             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
918
919             /* Update vectorial force */
920             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
921             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
922             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
923             
924             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
925             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
926             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
927
928             }
929
930             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
931
932             /* Inner loop uses 135 flops */
933         }
934
935         if(jidx<j_index_end)
936         {
937
938             jnrA             = jjnr[jidx];
939             j_coord_offsetA  = DIM*jnrA;
940
941             /* load j atom coordinates */
942             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
943                                               &jx0,&jy0,&jz0);
944
945             /* Calculate displacement vector */
946             dx00             = _fjsp_sub_v2r8(ix0,jx0);
947             dy00             = _fjsp_sub_v2r8(iy0,jy0);
948             dz00             = _fjsp_sub_v2r8(iz0,jz0);
949             dx10             = _fjsp_sub_v2r8(ix1,jx0);
950             dy10             = _fjsp_sub_v2r8(iy1,jy0);
951             dz10             = _fjsp_sub_v2r8(iz1,jz0);
952             dx20             = _fjsp_sub_v2r8(ix2,jx0);
953             dy20             = _fjsp_sub_v2r8(iy2,jy0);
954             dz20             = _fjsp_sub_v2r8(iz2,jz0);
955             dx30             = _fjsp_sub_v2r8(ix3,jx0);
956             dy30             = _fjsp_sub_v2r8(iy3,jy0);
957             dz30             = _fjsp_sub_v2r8(iz3,jz0);
958
959             /* Calculate squared distance and things based on it */
960             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
961             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
962             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
963             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
964
965             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
966             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
967             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
968
969             rinvsq00         = gmx_fjsp_inv_v2r8(rsq00);
970             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
971             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
972             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
973
974             /* Load parameters for j particles */
975             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
976             vdwjidx0A        = 2*vdwtype[jnrA+0];
977
978             fjx0             = _fjsp_setzero_v2r8();
979             fjy0             = _fjsp_setzero_v2r8();
980             fjz0             = _fjsp_setzero_v2r8();
981
982             /**************************
983              * CALCULATE INTERACTIONS *
984              **************************/
985
986             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
987             {
988
989             /* Compute parameters for interactions between i and j atoms */
990             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
991                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
992
993             /* LENNARD-JONES DISPERSION/REPULSION */
994
995             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
996             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
997
998             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
999
1000             fscal            = fvdw;
1001
1002             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1003
1004             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1005
1006             /* Update vectorial force */
1007             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1008             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1009             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1010             
1011             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1012             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1013             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1014
1015             }
1016
1017             /**************************
1018              * CALCULATE INTERACTIONS *
1019              **************************/
1020
1021             if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1022             {
1023
1024             /* Compute parameters for interactions between i and j atoms */
1025             qq10             = _fjsp_mul_v2r8(iq1,jq0);
1026
1027             /* REACTION-FIELD ELECTROSTATICS */
1028             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
1029
1030             cutoff_mask      = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1031
1032             fscal            = felec;
1033
1034             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1035
1036             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1037
1038             /* Update vectorial force */
1039             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1040             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1041             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1042             
1043             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1044             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1045             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1046
1047             }
1048
1049             /**************************
1050              * CALCULATE INTERACTIONS *
1051              **************************/
1052
1053             if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1054             {
1055
1056             /* Compute parameters for interactions between i and j atoms */
1057             qq20             = _fjsp_mul_v2r8(iq2,jq0);
1058
1059             /* REACTION-FIELD ELECTROSTATICS */
1060             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
1061
1062             cutoff_mask      = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1063
1064             fscal            = felec;
1065
1066             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1067
1068             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1069
1070             /* Update vectorial force */
1071             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1072             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1073             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1074             
1075             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1076             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1077             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1078
1079             }
1080
1081             /**************************
1082              * CALCULATE INTERACTIONS *
1083              **************************/
1084
1085             if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1086             {
1087
1088             /* Compute parameters for interactions between i and j atoms */
1089             qq30             = _fjsp_mul_v2r8(iq3,jq0);
1090
1091             /* REACTION-FIELD ELECTROSTATICS */
1092             felec            = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
1093
1094             cutoff_mask      = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1095
1096             fscal            = felec;
1097
1098             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
1099
1100             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1101
1102             /* Update vectorial force */
1103             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
1104             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1105             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1106             
1107             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1108             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1109             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1110
1111             }
1112
1113             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1114
1115             /* Inner loop uses 135 flops */
1116         }
1117
1118         /* End of innermost loop */
1119
1120         gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1121                                               f+i_coord_offset,fshift+i_shift_offset);
1122
1123         /* Increment number of inner iterations */
1124         inneriter                  += j_index_end - j_index_start;
1125
1126         /* Outer loop uses 24 flops */
1127     }
1128
1129     /* Increment number of outer iterations */
1130     outeriter        += nri;
1131
1132     /* Update outer/inner flops */
1133
1134     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*135);
1135 }