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