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