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