Version bumps after new release
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecCSTab_VdwNone_GeomW4P1_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/legacyheaders/vec.h"
47 #include "nrnb.h"
48
49 #include "kernelutil_sparc64_hpc_ace_double.h"
50
51 /*
52  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW4P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: CubicSplineTable
54  * VdW interaction:            None
55  * Geometry:                   Water4-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecCSTab_VdwNone_GeomW4P1_VF_sparc64_hpc_ace_double
60                     (t_nblist                    * gmx_restrict       nlist,
61                      rvec                        * gmx_restrict          xx,
62                      rvec                        * gmx_restrict          ff,
63                      t_forcerec                  * gmx_restrict          fr,
64                      t_mdatoms                   * gmx_restrict     mdatoms,
65                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwioffset3;
86     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
90     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
91     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
92     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
93     real             *charge;
94     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
95     real             *vftab;
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     vftab            = kernel_data->table_elec->data;
117     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_elec->scale);
118
119     /* Setup water-specific parameters */
120     inr              = nlist->iinr[0];
121     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
122     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
123     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
124
125     /* Avoid stupid compiler warnings */
126     jnrA = jnrB = 0;
127     j_coord_offsetA = 0;
128     j_coord_offsetB = 0;
129
130     outeriter        = 0;
131     inneriter        = 0;
132
133     /* Start outer loop over neighborlists */
134     for(iidx=0; iidx<nri; iidx++)
135     {
136         /* Load shift vector for this list */
137         i_shift_offset   = DIM*shiftidx[iidx];
138
139         /* Load limits for loop over neighbors */
140         j_index_start    = jindex[iidx];
141         j_index_end      = jindex[iidx+1];
142
143         /* Get outer coordinate index */
144         inr              = iinr[iidx];
145         i_coord_offset   = DIM*inr;
146
147         /* Load i particle coords and add shift vector */
148         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
149                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
150
151         fix1             = _fjsp_setzero_v2r8();
152         fiy1             = _fjsp_setzero_v2r8();
153         fiz1             = _fjsp_setzero_v2r8();
154         fix2             = _fjsp_setzero_v2r8();
155         fiy2             = _fjsp_setzero_v2r8();
156         fiz2             = _fjsp_setzero_v2r8();
157         fix3             = _fjsp_setzero_v2r8();
158         fiy3             = _fjsp_setzero_v2r8();
159         fiz3             = _fjsp_setzero_v2r8();
160
161         /* Reset potential sums */
162         velecsum         = _fjsp_setzero_v2r8();
163
164         /* Start inner kernel loop */
165         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
166         {
167
168             /* Get j neighbor index, and coordinate index */
169             jnrA             = jjnr[jidx];
170             jnrB             = jjnr[jidx+1];
171             j_coord_offsetA  = DIM*jnrA;
172             j_coord_offsetB  = DIM*jnrB;
173
174             /* load j atom coordinates */
175             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
176                                               &jx0,&jy0,&jz0);
177
178             /* Calculate displacement vector */
179             dx10             = _fjsp_sub_v2r8(ix1,jx0);
180             dy10             = _fjsp_sub_v2r8(iy1,jy0);
181             dz10             = _fjsp_sub_v2r8(iz1,jz0);
182             dx20             = _fjsp_sub_v2r8(ix2,jx0);
183             dy20             = _fjsp_sub_v2r8(iy2,jy0);
184             dz20             = _fjsp_sub_v2r8(iz2,jz0);
185             dx30             = _fjsp_sub_v2r8(ix3,jx0);
186             dy30             = _fjsp_sub_v2r8(iy3,jy0);
187             dz30             = _fjsp_sub_v2r8(iz3,jz0);
188
189             /* Calculate squared distance and things based on it */
190             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
191             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
192             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
193
194             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
195             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
196             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
197
198             /* Load parameters for j particles */
199             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
200
201             fjx0             = _fjsp_setzero_v2r8();
202             fjy0             = _fjsp_setzero_v2r8();
203             fjz0             = _fjsp_setzero_v2r8();
204
205             /**************************
206              * CALCULATE INTERACTIONS *
207              **************************/
208
209             r10              = _fjsp_mul_v2r8(rsq10,rinv10);
210
211             /* Compute parameters for interactions between i and j atoms */
212             qq10             = _fjsp_mul_v2r8(iq1,jq0);
213
214             /* Calculate table index by multiplying r with table scale and truncate to integer */
215             rt               = _fjsp_mul_v2r8(r10,vftabscale);
216             itab_tmp         = _fjsp_dtox_v2r8(rt);
217             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
218             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
219             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
220
221             vfconv.i[0]     *= 4;
222             vfconv.i[1]     *= 4;
223
224             /* CUBIC SPLINE TABLE ELECTROSTATICS */
225             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
226             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
227             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
228             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
229             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
230             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
231             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
232             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
233             velec            = _fjsp_mul_v2r8(qq10,VV);
234             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
235             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,FF),_fjsp_mul_v2r8(vftabscale,rinv10)));
236
237             /* Update potential sum for this i atom from the interaction with this j atom. */
238             velecsum         = _fjsp_add_v2r8(velecsum,velec);
239
240             fscal            = felec;
241
242             /* Update vectorial force */
243             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
244             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
245             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
246             
247             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
248             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
249             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
250
251             /**************************
252              * CALCULATE INTERACTIONS *
253              **************************/
254
255             r20              = _fjsp_mul_v2r8(rsq20,rinv20);
256
257             /* Compute parameters for interactions between i and j atoms */
258             qq20             = _fjsp_mul_v2r8(iq2,jq0);
259
260             /* Calculate table index by multiplying r with table scale and truncate to integer */
261             rt               = _fjsp_mul_v2r8(r20,vftabscale);
262             itab_tmp         = _fjsp_dtox_v2r8(rt);
263             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
264             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
265             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
266
267             vfconv.i[0]     *= 4;
268             vfconv.i[1]     *= 4;
269
270             /* CUBIC SPLINE TABLE ELECTROSTATICS */
271             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
272             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
273             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
274             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
275             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
276             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
277             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
278             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
279             velec            = _fjsp_mul_v2r8(qq20,VV);
280             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
281             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,FF),_fjsp_mul_v2r8(vftabscale,rinv20)));
282
283             /* Update potential sum for this i atom from the interaction with this j atom. */
284             velecsum         = _fjsp_add_v2r8(velecsum,velec);
285
286             fscal            = felec;
287
288             /* Update vectorial force */
289             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
290             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
291             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
292             
293             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
294             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
295             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
296
297             /**************************
298              * CALCULATE INTERACTIONS *
299              **************************/
300
301             r30              = _fjsp_mul_v2r8(rsq30,rinv30);
302
303             /* Compute parameters for interactions between i and j atoms */
304             qq30             = _fjsp_mul_v2r8(iq3,jq0);
305
306             /* Calculate table index by multiplying r with table scale and truncate to integer */
307             rt               = _fjsp_mul_v2r8(r30,vftabscale);
308             itab_tmp         = _fjsp_dtox_v2r8(rt);
309             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
310             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
311             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
312
313             vfconv.i[0]     *= 4;
314             vfconv.i[1]     *= 4;
315
316             /* CUBIC SPLINE TABLE ELECTROSTATICS */
317             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
318             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
319             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
320             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
321             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
322             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
323             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
324             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
325             velec            = _fjsp_mul_v2r8(qq30,VV);
326             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
327             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,FF),_fjsp_mul_v2r8(vftabscale,rinv30)));
328
329             /* Update potential sum for this i atom from the interaction with this j atom. */
330             velecsum         = _fjsp_add_v2r8(velecsum,velec);
331
332             fscal            = felec;
333
334             /* Update vectorial force */
335             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
336             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
337             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
338             
339             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
340             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
341             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
342
343             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
344
345             /* Inner loop uses 141 flops */
346         }
347
348         if(jidx<j_index_end)
349         {
350
351             jnrA             = jjnr[jidx];
352             j_coord_offsetA  = DIM*jnrA;
353
354             /* load j atom coordinates */
355             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
356                                               &jx0,&jy0,&jz0);
357
358             /* Calculate displacement vector */
359             dx10             = _fjsp_sub_v2r8(ix1,jx0);
360             dy10             = _fjsp_sub_v2r8(iy1,jy0);
361             dz10             = _fjsp_sub_v2r8(iz1,jz0);
362             dx20             = _fjsp_sub_v2r8(ix2,jx0);
363             dy20             = _fjsp_sub_v2r8(iy2,jy0);
364             dz20             = _fjsp_sub_v2r8(iz2,jz0);
365             dx30             = _fjsp_sub_v2r8(ix3,jx0);
366             dy30             = _fjsp_sub_v2r8(iy3,jy0);
367             dz30             = _fjsp_sub_v2r8(iz3,jz0);
368
369             /* Calculate squared distance and things based on it */
370             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
371             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
372             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
373
374             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
375             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
376             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
377
378             /* Load parameters for j particles */
379             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
380
381             fjx0             = _fjsp_setzero_v2r8();
382             fjy0             = _fjsp_setzero_v2r8();
383             fjz0             = _fjsp_setzero_v2r8();
384
385             /**************************
386              * CALCULATE INTERACTIONS *
387              **************************/
388
389             r10              = _fjsp_mul_v2r8(rsq10,rinv10);
390
391             /* Compute parameters for interactions between i and j atoms */
392             qq10             = _fjsp_mul_v2r8(iq1,jq0);
393
394             /* Calculate table index by multiplying r with table scale and truncate to integer */
395             rt               = _fjsp_mul_v2r8(r10,vftabscale);
396             itab_tmp         = _fjsp_dtox_v2r8(rt);
397             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
398             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
399             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
400
401             vfconv.i[0]     *= 4;
402             vfconv.i[1]     *= 4;
403
404             /* CUBIC SPLINE TABLE ELECTROSTATICS */
405             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
406             F                = _fjsp_setzero_v2r8();
407             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
408             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
409             H                = _fjsp_setzero_v2r8();
410             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
411             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
412             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
413             velec            = _fjsp_mul_v2r8(qq10,VV);
414             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
415             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,FF),_fjsp_mul_v2r8(vftabscale,rinv10)));
416
417             /* Update potential sum for this i atom from the interaction with this j atom. */
418             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
419             velecsum         = _fjsp_add_v2r8(velecsum,velec);
420
421             fscal            = felec;
422
423             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
424
425             /* Update vectorial force */
426             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
427             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
428             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
429             
430             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
431             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
432             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
433
434             /**************************
435              * CALCULATE INTERACTIONS *
436              **************************/
437
438             r20              = _fjsp_mul_v2r8(rsq20,rinv20);
439
440             /* Compute parameters for interactions between i and j atoms */
441             qq20             = _fjsp_mul_v2r8(iq2,jq0);
442
443             /* Calculate table index by multiplying r with table scale and truncate to integer */
444             rt               = _fjsp_mul_v2r8(r20,vftabscale);
445             itab_tmp         = _fjsp_dtox_v2r8(rt);
446             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
447             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
448             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
449
450             vfconv.i[0]     *= 4;
451             vfconv.i[1]     *= 4;
452
453             /* CUBIC SPLINE TABLE ELECTROSTATICS */
454             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
455             F                = _fjsp_setzero_v2r8();
456             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
457             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
458             H                = _fjsp_setzero_v2r8();
459             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
460             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
461             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
462             velec            = _fjsp_mul_v2r8(qq20,VV);
463             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
464             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,FF),_fjsp_mul_v2r8(vftabscale,rinv20)));
465
466             /* Update potential sum for this i atom from the interaction with this j atom. */
467             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
468             velecsum         = _fjsp_add_v2r8(velecsum,velec);
469
470             fscal            = felec;
471
472             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
473
474             /* Update vectorial force */
475             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
476             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
477             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
478             
479             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
480             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
481             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
482
483             /**************************
484              * CALCULATE INTERACTIONS *
485              **************************/
486
487             r30              = _fjsp_mul_v2r8(rsq30,rinv30);
488
489             /* Compute parameters for interactions between i and j atoms */
490             qq30             = _fjsp_mul_v2r8(iq3,jq0);
491
492             /* Calculate table index by multiplying r with table scale and truncate to integer */
493             rt               = _fjsp_mul_v2r8(r30,vftabscale);
494             itab_tmp         = _fjsp_dtox_v2r8(rt);
495             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
496             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
497             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
498
499             vfconv.i[0]     *= 4;
500             vfconv.i[1]     *= 4;
501
502             /* CUBIC SPLINE TABLE ELECTROSTATICS */
503             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
504             F                = _fjsp_setzero_v2r8();
505             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
506             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
507             H                = _fjsp_setzero_v2r8();
508             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
509             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
510             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
511             velec            = _fjsp_mul_v2r8(qq30,VV);
512             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
513             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,FF),_fjsp_mul_v2r8(vftabscale,rinv30)));
514
515             /* Update potential sum for this i atom from the interaction with this j atom. */
516             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
517             velecsum         = _fjsp_add_v2r8(velecsum,velec);
518
519             fscal            = felec;
520
521             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
522
523             /* Update vectorial force */
524             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
525             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
526             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
527             
528             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
529             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
530             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
531
532             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
533
534             /* Inner loop uses 141 flops */
535         }
536
537         /* End of innermost loop */
538
539         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
540                                               f+i_coord_offset+DIM,fshift+i_shift_offset);
541
542         ggid                        = gid[iidx];
543         /* Update potential energies */
544         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
545
546         /* Increment number of inner iterations */
547         inneriter                  += j_index_end - j_index_start;
548
549         /* Outer loop uses 19 flops */
550     }
551
552     /* Increment number of outer iterations */
553     outeriter        += nri;
554
555     /* Update outer/inner flops */
556
557     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*19 + inneriter*141);
558 }
559 /*
560  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_sparc64_hpc_ace_double
561  * Electrostatics interaction: CubicSplineTable
562  * VdW interaction:            None
563  * Geometry:                   Water4-Particle
564  * Calculate force/pot:        Force
565  */
566 void
567 nb_kernel_ElecCSTab_VdwNone_GeomW4P1_F_sparc64_hpc_ace_double
568                     (t_nblist                    * gmx_restrict       nlist,
569                      rvec                        * gmx_restrict          xx,
570                      rvec                        * gmx_restrict          ff,
571                      t_forcerec                  * gmx_restrict          fr,
572                      t_mdatoms                   * gmx_restrict     mdatoms,
573                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
574                      t_nrnb                      * gmx_restrict        nrnb)
575 {
576     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
577      * just 0 for non-waters.
578      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
579      * jnr indices corresponding to data put in the four positions in the SIMD register.
580      */
581     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
582     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
583     int              jnrA,jnrB;
584     int              j_coord_offsetA,j_coord_offsetB;
585     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
586     real             rcutoff_scalar;
587     real             *shiftvec,*fshift,*x,*f;
588     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
589     int              vdwioffset1;
590     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
591     int              vdwioffset2;
592     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
593     int              vdwioffset3;
594     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
595     int              vdwjidx0A,vdwjidx0B;
596     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
597     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
598     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
599     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
600     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
601     real             *charge;
602     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
603     real             *vftab;
604     _fjsp_v2r8       itab_tmp;
605     _fjsp_v2r8       dummy_mask,cutoff_mask;
606     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
607     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
608     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
609
610     x                = xx[0];
611     f                = ff[0];
612
613     nri              = nlist->nri;
614     iinr             = nlist->iinr;
615     jindex           = nlist->jindex;
616     jjnr             = nlist->jjnr;
617     shiftidx         = nlist->shift;
618     gid              = nlist->gid;
619     shiftvec         = fr->shift_vec[0];
620     fshift           = fr->fshift[0];
621     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
622     charge           = mdatoms->chargeA;
623
624     vftab            = kernel_data->table_elec->data;
625     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_elec->scale);
626
627     /* Setup water-specific parameters */
628     inr              = nlist->iinr[0];
629     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
630     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
631     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
632
633     /* Avoid stupid compiler warnings */
634     jnrA = jnrB = 0;
635     j_coord_offsetA = 0;
636     j_coord_offsetB = 0;
637
638     outeriter        = 0;
639     inneriter        = 0;
640
641     /* Start outer loop over neighborlists */
642     for(iidx=0; iidx<nri; iidx++)
643     {
644         /* Load shift vector for this list */
645         i_shift_offset   = DIM*shiftidx[iidx];
646
647         /* Load limits for loop over neighbors */
648         j_index_start    = jindex[iidx];
649         j_index_end      = jindex[iidx+1];
650
651         /* Get outer coordinate index */
652         inr              = iinr[iidx];
653         i_coord_offset   = DIM*inr;
654
655         /* Load i particle coords and add shift vector */
656         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
657                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
658
659         fix1             = _fjsp_setzero_v2r8();
660         fiy1             = _fjsp_setzero_v2r8();
661         fiz1             = _fjsp_setzero_v2r8();
662         fix2             = _fjsp_setzero_v2r8();
663         fiy2             = _fjsp_setzero_v2r8();
664         fiz2             = _fjsp_setzero_v2r8();
665         fix3             = _fjsp_setzero_v2r8();
666         fiy3             = _fjsp_setzero_v2r8();
667         fiz3             = _fjsp_setzero_v2r8();
668
669         /* Start inner kernel loop */
670         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
671         {
672
673             /* Get j neighbor index, and coordinate index */
674             jnrA             = jjnr[jidx];
675             jnrB             = jjnr[jidx+1];
676             j_coord_offsetA  = DIM*jnrA;
677             j_coord_offsetB  = DIM*jnrB;
678
679             /* load j atom coordinates */
680             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
681                                               &jx0,&jy0,&jz0);
682
683             /* Calculate displacement vector */
684             dx10             = _fjsp_sub_v2r8(ix1,jx0);
685             dy10             = _fjsp_sub_v2r8(iy1,jy0);
686             dz10             = _fjsp_sub_v2r8(iz1,jz0);
687             dx20             = _fjsp_sub_v2r8(ix2,jx0);
688             dy20             = _fjsp_sub_v2r8(iy2,jy0);
689             dz20             = _fjsp_sub_v2r8(iz2,jz0);
690             dx30             = _fjsp_sub_v2r8(ix3,jx0);
691             dy30             = _fjsp_sub_v2r8(iy3,jy0);
692             dz30             = _fjsp_sub_v2r8(iz3,jz0);
693
694             /* Calculate squared distance and things based on it */
695             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
696             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
697             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
698
699             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
700             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
701             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
702
703             /* Load parameters for j particles */
704             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
705
706             fjx0             = _fjsp_setzero_v2r8();
707             fjy0             = _fjsp_setzero_v2r8();
708             fjz0             = _fjsp_setzero_v2r8();
709
710             /**************************
711              * CALCULATE INTERACTIONS *
712              **************************/
713
714             r10              = _fjsp_mul_v2r8(rsq10,rinv10);
715
716             /* Compute parameters for interactions between i and j atoms */
717             qq10             = _fjsp_mul_v2r8(iq1,jq0);
718
719             /* Calculate table index by multiplying r with table scale and truncate to integer */
720             rt               = _fjsp_mul_v2r8(r10,vftabscale);
721             itab_tmp         = _fjsp_dtox_v2r8(rt);
722             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
723             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
724             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
725
726             vfconv.i[0]     *= 4;
727             vfconv.i[1]     *= 4;
728
729             /* CUBIC SPLINE TABLE ELECTROSTATICS */
730             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
731             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
732             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
733             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
734             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
735             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
736             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
737             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
738             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,FF),_fjsp_mul_v2r8(vftabscale,rinv10)));
739
740             fscal            = felec;
741
742             /* Update vectorial force */
743             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
744             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
745             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
746             
747             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
748             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
749             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
750
751             /**************************
752              * CALCULATE INTERACTIONS *
753              **************************/
754
755             r20              = _fjsp_mul_v2r8(rsq20,rinv20);
756
757             /* Compute parameters for interactions between i and j atoms */
758             qq20             = _fjsp_mul_v2r8(iq2,jq0);
759
760             /* Calculate table index by multiplying r with table scale and truncate to integer */
761             rt               = _fjsp_mul_v2r8(r20,vftabscale);
762             itab_tmp         = _fjsp_dtox_v2r8(rt);
763             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
764             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
765             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
766
767             vfconv.i[0]     *= 4;
768             vfconv.i[1]     *= 4;
769
770             /* CUBIC SPLINE TABLE ELECTROSTATICS */
771             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
772             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
773             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
774             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
775             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
776             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
777             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
778             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
779             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,FF),_fjsp_mul_v2r8(vftabscale,rinv20)));
780
781             fscal            = felec;
782
783             /* Update vectorial force */
784             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
785             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
786             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
787             
788             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
789             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
790             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
791
792             /**************************
793              * CALCULATE INTERACTIONS *
794              **************************/
795
796             r30              = _fjsp_mul_v2r8(rsq30,rinv30);
797
798             /* Compute parameters for interactions between i and j atoms */
799             qq30             = _fjsp_mul_v2r8(iq3,jq0);
800
801             /* Calculate table index by multiplying r with table scale and truncate to integer */
802             rt               = _fjsp_mul_v2r8(r30,vftabscale);
803             itab_tmp         = _fjsp_dtox_v2r8(rt);
804             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
805             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
806             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
807
808             vfconv.i[0]     *= 4;
809             vfconv.i[1]     *= 4;
810
811             /* CUBIC SPLINE TABLE ELECTROSTATICS */
812             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
813             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
814             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
815             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
816             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
817             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
818             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
819             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
820             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,FF),_fjsp_mul_v2r8(vftabscale,rinv30)));
821
822             fscal            = felec;
823
824             /* Update vectorial force */
825             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
826             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
827             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
828             
829             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
830             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
831             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
832
833             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
834
835             /* Inner loop uses 129 flops */
836         }
837
838         if(jidx<j_index_end)
839         {
840
841             jnrA             = jjnr[jidx];
842             j_coord_offsetA  = DIM*jnrA;
843
844             /* load j atom coordinates */
845             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
846                                               &jx0,&jy0,&jz0);
847
848             /* Calculate displacement vector */
849             dx10             = _fjsp_sub_v2r8(ix1,jx0);
850             dy10             = _fjsp_sub_v2r8(iy1,jy0);
851             dz10             = _fjsp_sub_v2r8(iz1,jz0);
852             dx20             = _fjsp_sub_v2r8(ix2,jx0);
853             dy20             = _fjsp_sub_v2r8(iy2,jy0);
854             dz20             = _fjsp_sub_v2r8(iz2,jz0);
855             dx30             = _fjsp_sub_v2r8(ix3,jx0);
856             dy30             = _fjsp_sub_v2r8(iy3,jy0);
857             dz30             = _fjsp_sub_v2r8(iz3,jz0);
858
859             /* Calculate squared distance and things based on it */
860             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
861             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
862             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
863
864             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
865             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
866             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
867
868             /* Load parameters for j particles */
869             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
870
871             fjx0             = _fjsp_setzero_v2r8();
872             fjy0             = _fjsp_setzero_v2r8();
873             fjz0             = _fjsp_setzero_v2r8();
874
875             /**************************
876              * CALCULATE INTERACTIONS *
877              **************************/
878
879             r10              = _fjsp_mul_v2r8(rsq10,rinv10);
880
881             /* Compute parameters for interactions between i and j atoms */
882             qq10             = _fjsp_mul_v2r8(iq1,jq0);
883
884             /* Calculate table index by multiplying r with table scale and truncate to integer */
885             rt               = _fjsp_mul_v2r8(r10,vftabscale);
886             itab_tmp         = _fjsp_dtox_v2r8(rt);
887             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
888             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
889             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
890
891             vfconv.i[0]     *= 4;
892             vfconv.i[1]     *= 4;
893
894             /* CUBIC SPLINE TABLE ELECTROSTATICS */
895             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
896             F                = _fjsp_setzero_v2r8();
897             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
898             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
899             H                = _fjsp_setzero_v2r8();
900             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
901             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
902             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
903             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,FF),_fjsp_mul_v2r8(vftabscale,rinv10)));
904
905             fscal            = felec;
906
907             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
908
909             /* Update vectorial force */
910             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
911             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
912             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
913             
914             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
915             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
916             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
917
918             /**************************
919              * CALCULATE INTERACTIONS *
920              **************************/
921
922             r20              = _fjsp_mul_v2r8(rsq20,rinv20);
923
924             /* Compute parameters for interactions between i and j atoms */
925             qq20             = _fjsp_mul_v2r8(iq2,jq0);
926
927             /* Calculate table index by multiplying r with table scale and truncate to integer */
928             rt               = _fjsp_mul_v2r8(r20,vftabscale);
929             itab_tmp         = _fjsp_dtox_v2r8(rt);
930             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
931             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
932             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
933
934             vfconv.i[0]     *= 4;
935             vfconv.i[1]     *= 4;
936
937             /* CUBIC SPLINE TABLE ELECTROSTATICS */
938             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
939             F                = _fjsp_setzero_v2r8();
940             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
941             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
942             H                = _fjsp_setzero_v2r8();
943             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
944             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
945             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
946             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,FF),_fjsp_mul_v2r8(vftabscale,rinv20)));
947
948             fscal            = felec;
949
950             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
951
952             /* Update vectorial force */
953             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
954             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
955             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
956             
957             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
958             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
959             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
960
961             /**************************
962              * CALCULATE INTERACTIONS *
963              **************************/
964
965             r30              = _fjsp_mul_v2r8(rsq30,rinv30);
966
967             /* Compute parameters for interactions between i and j atoms */
968             qq30             = _fjsp_mul_v2r8(iq3,jq0);
969
970             /* Calculate table index by multiplying r with table scale and truncate to integer */
971             rt               = _fjsp_mul_v2r8(r30,vftabscale);
972             itab_tmp         = _fjsp_dtox_v2r8(rt);
973             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
974             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
975             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
976
977             vfconv.i[0]     *= 4;
978             vfconv.i[1]     *= 4;
979
980             /* CUBIC SPLINE TABLE ELECTROSTATICS */
981             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
982             F                = _fjsp_setzero_v2r8();
983             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
984             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
985             H                = _fjsp_setzero_v2r8();
986             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
987             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
988             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
989             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,FF),_fjsp_mul_v2r8(vftabscale,rinv30)));
990
991             fscal            = felec;
992
993             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
994
995             /* Update vectorial force */
996             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
997             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
998             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
999             
1000             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1001             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1002             fjz0             = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1003
1004             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1005
1006             /* Inner loop uses 129 flops */
1007         }
1008
1009         /* End of innermost loop */
1010
1011         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1012                                               f+i_coord_offset+DIM,fshift+i_shift_offset);
1013
1014         /* Increment number of inner iterations */
1015         inneriter                  += j_index_end - j_index_start;
1016
1017         /* Outer loop uses 18 flops */
1018     }
1019
1020     /* Increment number of outer iterations */
1021     outeriter        += nri;
1022
1023     /* Update outer/inner flops */
1024
1025     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*18 + inneriter*129);
1026 }