fd7dbd32845a0386af227f6663e15ae047987c39
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, 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 "vec.h"
47 #include "nrnb.h"
48
49 #include "kernelutil_sparc64_hpc_ace_double.h"
50
51 /*
52  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: Coulomb
54  * VdW interaction:            CubicSplineTable
55  * Geometry:                   Water3-Water3
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_VF_sparc64_hpc_ace_double
60                     (t_nblist                    * gmx_restrict       nlist,
61                      rvec                        * gmx_restrict          xx,
62                      rvec                        * gmx_restrict          ff,
63                      t_forcerec                  * gmx_restrict          fr,
64                      t_mdatoms                   * gmx_restrict     mdatoms,
65                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset0;
82     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83     int              vdwioffset1;
84     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85     int              vdwioffset2;
86     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     int              vdwjidx1A,vdwjidx1B;
90     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
91     int              vdwjidx2A,vdwjidx2B;
92     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
93     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94     _fjsp_v2r8       dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
95     _fjsp_v2r8       dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
96     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
97     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
98     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
99     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
100     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
101     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
102     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
103     real             *charge;
104     int              nvdwtype;
105     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
106     int              *vdwtype;
107     real             *vdwparam;
108     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
109     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
110     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
111     real             *vftab;
112     _fjsp_v2r8       itab_tmp;
113     _fjsp_v2r8       dummy_mask,cutoff_mask;
114     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
115     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
116     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
117
118     x                = xx[0];
119     f                = ff[0];
120
121     nri              = nlist->nri;
122     iinr             = nlist->iinr;
123     jindex           = nlist->jindex;
124     jjnr             = nlist->jjnr;
125     shiftidx         = nlist->shift;
126     gid              = nlist->gid;
127     shiftvec         = fr->shift_vec[0];
128     fshift           = fr->fshift[0];
129     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
130     charge           = mdatoms->chargeA;
131     nvdwtype         = fr->ntype;
132     vdwparam         = fr->nbfp;
133     vdwtype          = mdatoms->typeA;
134
135     vftab            = kernel_data->table_vdw->data;
136     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
137
138     /* Setup water-specific parameters */
139     inr              = nlist->iinr[0];
140     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
141     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
142     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
143     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
144
145     jq0              = gmx_fjsp_set1_v2r8(charge[inr+0]);
146     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
147     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
148     vdwjidx0A        = 2*vdwtype[inr+0];
149     qq00             = _fjsp_mul_v2r8(iq0,jq0);
150     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
151     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
152     qq01             = _fjsp_mul_v2r8(iq0,jq1);
153     qq02             = _fjsp_mul_v2r8(iq0,jq2);
154     qq10             = _fjsp_mul_v2r8(iq1,jq0);
155     qq11             = _fjsp_mul_v2r8(iq1,jq1);
156     qq12             = _fjsp_mul_v2r8(iq1,jq2);
157     qq20             = _fjsp_mul_v2r8(iq2,jq0);
158     qq21             = _fjsp_mul_v2r8(iq2,jq1);
159     qq22             = _fjsp_mul_v2r8(iq2,jq2);
160
161     /* Avoid stupid compiler warnings */
162     jnrA = jnrB = 0;
163     j_coord_offsetA = 0;
164     j_coord_offsetB = 0;
165
166     outeriter        = 0;
167     inneriter        = 0;
168
169     /* Start outer loop over neighborlists */
170     for(iidx=0; iidx<nri; iidx++)
171     {
172         /* Load shift vector for this list */
173         i_shift_offset   = DIM*shiftidx[iidx];
174
175         /* Load limits for loop over neighbors */
176         j_index_start    = jindex[iidx];
177         j_index_end      = jindex[iidx+1];
178
179         /* Get outer coordinate index */
180         inr              = iinr[iidx];
181         i_coord_offset   = DIM*inr;
182
183         /* Load i particle coords and add shift vector */
184         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
185                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
186
187         fix0             = _fjsp_setzero_v2r8();
188         fiy0             = _fjsp_setzero_v2r8();
189         fiz0             = _fjsp_setzero_v2r8();
190         fix1             = _fjsp_setzero_v2r8();
191         fiy1             = _fjsp_setzero_v2r8();
192         fiz1             = _fjsp_setzero_v2r8();
193         fix2             = _fjsp_setzero_v2r8();
194         fiy2             = _fjsp_setzero_v2r8();
195         fiz2             = _fjsp_setzero_v2r8();
196
197         /* Reset potential sums */
198         velecsum         = _fjsp_setzero_v2r8();
199         vvdwsum          = _fjsp_setzero_v2r8();
200
201         /* Start inner kernel loop */
202         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
203         {
204
205             /* Get j neighbor index, and coordinate index */
206             jnrA             = jjnr[jidx];
207             jnrB             = jjnr[jidx+1];
208             j_coord_offsetA  = DIM*jnrA;
209             j_coord_offsetB  = DIM*jnrB;
210
211             /* load j atom coordinates */
212             gmx_fjsp_load_3rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
213                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
214
215             /* Calculate displacement vector */
216             dx00             = _fjsp_sub_v2r8(ix0,jx0);
217             dy00             = _fjsp_sub_v2r8(iy0,jy0);
218             dz00             = _fjsp_sub_v2r8(iz0,jz0);
219             dx01             = _fjsp_sub_v2r8(ix0,jx1);
220             dy01             = _fjsp_sub_v2r8(iy0,jy1);
221             dz01             = _fjsp_sub_v2r8(iz0,jz1);
222             dx02             = _fjsp_sub_v2r8(ix0,jx2);
223             dy02             = _fjsp_sub_v2r8(iy0,jy2);
224             dz02             = _fjsp_sub_v2r8(iz0,jz2);
225             dx10             = _fjsp_sub_v2r8(ix1,jx0);
226             dy10             = _fjsp_sub_v2r8(iy1,jy0);
227             dz10             = _fjsp_sub_v2r8(iz1,jz0);
228             dx11             = _fjsp_sub_v2r8(ix1,jx1);
229             dy11             = _fjsp_sub_v2r8(iy1,jy1);
230             dz11             = _fjsp_sub_v2r8(iz1,jz1);
231             dx12             = _fjsp_sub_v2r8(ix1,jx2);
232             dy12             = _fjsp_sub_v2r8(iy1,jy2);
233             dz12             = _fjsp_sub_v2r8(iz1,jz2);
234             dx20             = _fjsp_sub_v2r8(ix2,jx0);
235             dy20             = _fjsp_sub_v2r8(iy2,jy0);
236             dz20             = _fjsp_sub_v2r8(iz2,jz0);
237             dx21             = _fjsp_sub_v2r8(ix2,jx1);
238             dy21             = _fjsp_sub_v2r8(iy2,jy1);
239             dz21             = _fjsp_sub_v2r8(iz2,jz1);
240             dx22             = _fjsp_sub_v2r8(ix2,jx2);
241             dy22             = _fjsp_sub_v2r8(iy2,jy2);
242             dz22             = _fjsp_sub_v2r8(iz2,jz2);
243
244             /* Calculate squared distance and things based on it */
245             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
246             rsq01            = gmx_fjsp_calc_rsq_v2r8(dx01,dy01,dz01);
247             rsq02            = gmx_fjsp_calc_rsq_v2r8(dx02,dy02,dz02);
248             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
249             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
250             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
251             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
252             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
253             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
254
255             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
256             rinv01           = gmx_fjsp_invsqrt_v2r8(rsq01);
257             rinv02           = gmx_fjsp_invsqrt_v2r8(rsq02);
258             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
259             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
260             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
261             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
262             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
263             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
264
265             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
266             rinvsq01         = _fjsp_mul_v2r8(rinv01,rinv01);
267             rinvsq02         = _fjsp_mul_v2r8(rinv02,rinv02);
268             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
269             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
270             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
271             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
272             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
273             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
274
275             fjx0             = _fjsp_setzero_v2r8();
276             fjy0             = _fjsp_setzero_v2r8();
277             fjz0             = _fjsp_setzero_v2r8();
278             fjx1             = _fjsp_setzero_v2r8();
279             fjy1             = _fjsp_setzero_v2r8();
280             fjz1             = _fjsp_setzero_v2r8();
281             fjx2             = _fjsp_setzero_v2r8();
282             fjy2             = _fjsp_setzero_v2r8();
283             fjz2             = _fjsp_setzero_v2r8();
284
285             /**************************
286              * CALCULATE INTERACTIONS *
287              **************************/
288
289             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
290
291             /* Calculate table index by multiplying r with table scale and truncate to integer */
292             rt               = _fjsp_mul_v2r8(r00,vftabscale);
293             itab_tmp         = _fjsp_dtox_v2r8(rt);
294             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
295             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
296             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
297
298             vfconv.i[0]     *= 8;
299             vfconv.i[1]     *= 8;
300
301             /* COULOMB ELECTROSTATICS */
302             velec            = _fjsp_mul_v2r8(qq00,rinv00);
303             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
304
305             /* CUBIC SPLINE TABLE DISPERSION */
306             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
307             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
308             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
309             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
310             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
311             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
312             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
313             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
314             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
315             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
316             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
317
318             /* CUBIC SPLINE TABLE REPULSION */
319             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
320             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
321             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
322             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
323             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
324             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
325             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
326             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
327             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
328             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
329             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
330             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
331             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
332
333             /* Update potential sum for this i atom from the interaction with this j atom. */
334             velecsum         = _fjsp_add_v2r8(velecsum,velec);
335             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
336
337             fscal            = _fjsp_add_v2r8(felec,fvdw);
338
339             /* Update vectorial force */
340             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
341             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
342             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
343             
344             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
345             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
346             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
347
348             /**************************
349              * CALCULATE INTERACTIONS *
350              **************************/
351
352             /* COULOMB ELECTROSTATICS */
353             velec            = _fjsp_mul_v2r8(qq01,rinv01);
354             felec            = _fjsp_mul_v2r8(velec,rinvsq01);
355
356             /* Update potential sum for this i atom from the interaction with this j atom. */
357             velecsum         = _fjsp_add_v2r8(velecsum,velec);
358
359             fscal            = felec;
360
361             /* Update vectorial force */
362             fix0             = _fjsp_madd_v2r8(dx01,fscal,fix0);
363             fiy0             = _fjsp_madd_v2r8(dy01,fscal,fiy0);
364             fiz0             = _fjsp_madd_v2r8(dz01,fscal,fiz0);
365             
366             fjx1             = _fjsp_madd_v2r8(dx01,fscal,fjx1);
367             fjy1             = _fjsp_madd_v2r8(dy01,fscal,fjy1);
368             fjz1             = _fjsp_madd_v2r8(dz01,fscal,fjz1);
369
370             /**************************
371              * CALCULATE INTERACTIONS *
372              **************************/
373
374             /* COULOMB ELECTROSTATICS */
375             velec            = _fjsp_mul_v2r8(qq02,rinv02);
376             felec            = _fjsp_mul_v2r8(velec,rinvsq02);
377
378             /* Update potential sum for this i atom from the interaction with this j atom. */
379             velecsum         = _fjsp_add_v2r8(velecsum,velec);
380
381             fscal            = felec;
382
383             /* Update vectorial force */
384             fix0             = _fjsp_madd_v2r8(dx02,fscal,fix0);
385             fiy0             = _fjsp_madd_v2r8(dy02,fscal,fiy0);
386             fiz0             = _fjsp_madd_v2r8(dz02,fscal,fiz0);
387             
388             fjx2             = _fjsp_madd_v2r8(dx02,fscal,fjx2);
389             fjy2             = _fjsp_madd_v2r8(dy02,fscal,fjy2);
390             fjz2             = _fjsp_madd_v2r8(dz02,fscal,fjz2);
391
392             /**************************
393              * CALCULATE INTERACTIONS *
394              **************************/
395
396             /* COULOMB ELECTROSTATICS */
397             velec            = _fjsp_mul_v2r8(qq10,rinv10);
398             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
399
400             /* Update potential sum for this i atom from the interaction with this j atom. */
401             velecsum         = _fjsp_add_v2r8(velecsum,velec);
402
403             fscal            = felec;
404
405             /* Update vectorial force */
406             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
407             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
408             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
409             
410             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
411             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
412             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
413
414             /**************************
415              * CALCULATE INTERACTIONS *
416              **************************/
417
418             /* COULOMB ELECTROSTATICS */
419             velec            = _fjsp_mul_v2r8(qq11,rinv11);
420             felec            = _fjsp_mul_v2r8(velec,rinvsq11);
421
422             /* Update potential sum for this i atom from the interaction with this j atom. */
423             velecsum         = _fjsp_add_v2r8(velecsum,velec);
424
425             fscal            = felec;
426
427             /* Update vectorial force */
428             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
429             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
430             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
431             
432             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
433             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
434             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
435
436             /**************************
437              * CALCULATE INTERACTIONS *
438              **************************/
439
440             /* COULOMB ELECTROSTATICS */
441             velec            = _fjsp_mul_v2r8(qq12,rinv12);
442             felec            = _fjsp_mul_v2r8(velec,rinvsq12);
443
444             /* Update potential sum for this i atom from the interaction with this j atom. */
445             velecsum         = _fjsp_add_v2r8(velecsum,velec);
446
447             fscal            = felec;
448
449             /* Update vectorial force */
450             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
451             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
452             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
453             
454             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
455             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
456             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
457
458             /**************************
459              * CALCULATE INTERACTIONS *
460              **************************/
461
462             /* COULOMB ELECTROSTATICS */
463             velec            = _fjsp_mul_v2r8(qq20,rinv20);
464             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
465
466             /* Update potential sum for this i atom from the interaction with this j atom. */
467             velecsum         = _fjsp_add_v2r8(velecsum,velec);
468
469             fscal            = felec;
470
471             /* Update vectorial force */
472             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
473             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
474             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
475             
476             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
477             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
478             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
479
480             /**************************
481              * CALCULATE INTERACTIONS *
482              **************************/
483
484             /* COULOMB ELECTROSTATICS */
485             velec            = _fjsp_mul_v2r8(qq21,rinv21);
486             felec            = _fjsp_mul_v2r8(velec,rinvsq21);
487
488             /* Update potential sum for this i atom from the interaction with this j atom. */
489             velecsum         = _fjsp_add_v2r8(velecsum,velec);
490
491             fscal            = felec;
492
493             /* Update vectorial force */
494             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
495             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
496             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
497             
498             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
499             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
500             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
501
502             /**************************
503              * CALCULATE INTERACTIONS *
504              **************************/
505
506             /* COULOMB ELECTROSTATICS */
507             velec            = _fjsp_mul_v2r8(qq22,rinv22);
508             felec            = _fjsp_mul_v2r8(velec,rinvsq22);
509
510             /* Update potential sum for this i atom from the interaction with this j atom. */
511             velecsum         = _fjsp_add_v2r8(velecsum,velec);
512
513             fscal            = felec;
514
515             /* Update vectorial force */
516             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
517             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
518             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
519             
520             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
521             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
522             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
523
524             gmx_fjsp_decrement_3rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
525
526             /* Inner loop uses 314 flops */
527         }
528
529         if(jidx<j_index_end)
530         {
531
532             jnrA             = jjnr[jidx];
533             j_coord_offsetA  = DIM*jnrA;
534
535             /* load j atom coordinates */
536             gmx_fjsp_load_3rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
537                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
538
539             /* Calculate displacement vector */
540             dx00             = _fjsp_sub_v2r8(ix0,jx0);
541             dy00             = _fjsp_sub_v2r8(iy0,jy0);
542             dz00             = _fjsp_sub_v2r8(iz0,jz0);
543             dx01             = _fjsp_sub_v2r8(ix0,jx1);
544             dy01             = _fjsp_sub_v2r8(iy0,jy1);
545             dz01             = _fjsp_sub_v2r8(iz0,jz1);
546             dx02             = _fjsp_sub_v2r8(ix0,jx2);
547             dy02             = _fjsp_sub_v2r8(iy0,jy2);
548             dz02             = _fjsp_sub_v2r8(iz0,jz2);
549             dx10             = _fjsp_sub_v2r8(ix1,jx0);
550             dy10             = _fjsp_sub_v2r8(iy1,jy0);
551             dz10             = _fjsp_sub_v2r8(iz1,jz0);
552             dx11             = _fjsp_sub_v2r8(ix1,jx1);
553             dy11             = _fjsp_sub_v2r8(iy1,jy1);
554             dz11             = _fjsp_sub_v2r8(iz1,jz1);
555             dx12             = _fjsp_sub_v2r8(ix1,jx2);
556             dy12             = _fjsp_sub_v2r8(iy1,jy2);
557             dz12             = _fjsp_sub_v2r8(iz1,jz2);
558             dx20             = _fjsp_sub_v2r8(ix2,jx0);
559             dy20             = _fjsp_sub_v2r8(iy2,jy0);
560             dz20             = _fjsp_sub_v2r8(iz2,jz0);
561             dx21             = _fjsp_sub_v2r8(ix2,jx1);
562             dy21             = _fjsp_sub_v2r8(iy2,jy1);
563             dz21             = _fjsp_sub_v2r8(iz2,jz1);
564             dx22             = _fjsp_sub_v2r8(ix2,jx2);
565             dy22             = _fjsp_sub_v2r8(iy2,jy2);
566             dz22             = _fjsp_sub_v2r8(iz2,jz2);
567
568             /* Calculate squared distance and things based on it */
569             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
570             rsq01            = gmx_fjsp_calc_rsq_v2r8(dx01,dy01,dz01);
571             rsq02            = gmx_fjsp_calc_rsq_v2r8(dx02,dy02,dz02);
572             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
573             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
574             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
575             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
576             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
577             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
578
579             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
580             rinv01           = gmx_fjsp_invsqrt_v2r8(rsq01);
581             rinv02           = gmx_fjsp_invsqrt_v2r8(rsq02);
582             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
583             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
584             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
585             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
586             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
587             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
588
589             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
590             rinvsq01         = _fjsp_mul_v2r8(rinv01,rinv01);
591             rinvsq02         = _fjsp_mul_v2r8(rinv02,rinv02);
592             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
593             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
594             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
595             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
596             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
597             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
598
599             fjx0             = _fjsp_setzero_v2r8();
600             fjy0             = _fjsp_setzero_v2r8();
601             fjz0             = _fjsp_setzero_v2r8();
602             fjx1             = _fjsp_setzero_v2r8();
603             fjy1             = _fjsp_setzero_v2r8();
604             fjz1             = _fjsp_setzero_v2r8();
605             fjx2             = _fjsp_setzero_v2r8();
606             fjy2             = _fjsp_setzero_v2r8();
607             fjz2             = _fjsp_setzero_v2r8();
608
609             /**************************
610              * CALCULATE INTERACTIONS *
611              **************************/
612
613             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
614
615             /* Calculate table index by multiplying r with table scale and truncate to integer */
616             rt               = _fjsp_mul_v2r8(r00,vftabscale);
617             itab_tmp         = _fjsp_dtox_v2r8(rt);
618             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
619             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
620             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
621
622             vfconv.i[0]     *= 8;
623             vfconv.i[1]     *= 8;
624
625             /* COULOMB ELECTROSTATICS */
626             velec            = _fjsp_mul_v2r8(qq00,rinv00);
627             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
628
629             /* CUBIC SPLINE TABLE DISPERSION */
630             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
631             F                = _fjsp_setzero_v2r8();
632             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
633             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
634             H                = _fjsp_setzero_v2r8();
635             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
636             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
637             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
638             vvdw6            = _fjsp_mul_v2r8(c6_00,VV);
639             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
640             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
641
642             /* CUBIC SPLINE TABLE REPULSION */
643             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
644             F                = _fjsp_setzero_v2r8();
645             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
646             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
647             H                = _fjsp_setzero_v2r8();
648             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
649             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
650             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
651             vvdw12           = _fjsp_mul_v2r8(c12_00,VV);
652             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
653             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
654             vvdw             = _fjsp_add_v2r8(vvdw12,vvdw6);
655             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
656
657             /* Update potential sum for this i atom from the interaction with this j atom. */
658             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
659             velecsum         = _fjsp_add_v2r8(velecsum,velec);
660             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
661             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
662
663             fscal            = _fjsp_add_v2r8(felec,fvdw);
664
665             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
666
667             /* Update vectorial force */
668             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
669             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
670             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
671             
672             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
673             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
674             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
675
676             /**************************
677              * CALCULATE INTERACTIONS *
678              **************************/
679
680             /* COULOMB ELECTROSTATICS */
681             velec            = _fjsp_mul_v2r8(qq01,rinv01);
682             felec            = _fjsp_mul_v2r8(velec,rinvsq01);
683
684             /* Update potential sum for this i atom from the interaction with this j atom. */
685             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
686             velecsum         = _fjsp_add_v2r8(velecsum,velec);
687
688             fscal            = felec;
689
690             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
691
692             /* Update vectorial force */
693             fix0             = _fjsp_madd_v2r8(dx01,fscal,fix0);
694             fiy0             = _fjsp_madd_v2r8(dy01,fscal,fiy0);
695             fiz0             = _fjsp_madd_v2r8(dz01,fscal,fiz0);
696             
697             fjx1             = _fjsp_madd_v2r8(dx01,fscal,fjx1);
698             fjy1             = _fjsp_madd_v2r8(dy01,fscal,fjy1);
699             fjz1             = _fjsp_madd_v2r8(dz01,fscal,fjz1);
700
701             /**************************
702              * CALCULATE INTERACTIONS *
703              **************************/
704
705             /* COULOMB ELECTROSTATICS */
706             velec            = _fjsp_mul_v2r8(qq02,rinv02);
707             felec            = _fjsp_mul_v2r8(velec,rinvsq02);
708
709             /* Update potential sum for this i atom from the interaction with this j atom. */
710             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
711             velecsum         = _fjsp_add_v2r8(velecsum,velec);
712
713             fscal            = felec;
714
715             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
716
717             /* Update vectorial force */
718             fix0             = _fjsp_madd_v2r8(dx02,fscal,fix0);
719             fiy0             = _fjsp_madd_v2r8(dy02,fscal,fiy0);
720             fiz0             = _fjsp_madd_v2r8(dz02,fscal,fiz0);
721             
722             fjx2             = _fjsp_madd_v2r8(dx02,fscal,fjx2);
723             fjy2             = _fjsp_madd_v2r8(dy02,fscal,fjy2);
724             fjz2             = _fjsp_madd_v2r8(dz02,fscal,fjz2);
725
726             /**************************
727              * CALCULATE INTERACTIONS *
728              **************************/
729
730             /* COULOMB ELECTROSTATICS */
731             velec            = _fjsp_mul_v2r8(qq10,rinv10);
732             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
733
734             /* Update potential sum for this i atom from the interaction with this j atom. */
735             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
736             velecsum         = _fjsp_add_v2r8(velecsum,velec);
737
738             fscal            = felec;
739
740             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
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             /* COULOMB ELECTROSTATICS */
756             velec            = _fjsp_mul_v2r8(qq11,rinv11);
757             felec            = _fjsp_mul_v2r8(velec,rinvsq11);
758
759             /* Update potential sum for this i atom from the interaction with this j atom. */
760             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
761             velecsum         = _fjsp_add_v2r8(velecsum,velec);
762
763             fscal            = felec;
764
765             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
766
767             /* Update vectorial force */
768             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
769             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
770             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
771             
772             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
773             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
774             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
775
776             /**************************
777              * CALCULATE INTERACTIONS *
778              **************************/
779
780             /* COULOMB ELECTROSTATICS */
781             velec            = _fjsp_mul_v2r8(qq12,rinv12);
782             felec            = _fjsp_mul_v2r8(velec,rinvsq12);
783
784             /* Update potential sum for this i atom from the interaction with this j atom. */
785             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
786             velecsum         = _fjsp_add_v2r8(velecsum,velec);
787
788             fscal            = felec;
789
790             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
791
792             /* Update vectorial force */
793             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
794             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
795             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
796             
797             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
798             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
799             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
800
801             /**************************
802              * CALCULATE INTERACTIONS *
803              **************************/
804
805             /* COULOMB ELECTROSTATICS */
806             velec            = _fjsp_mul_v2r8(qq20,rinv20);
807             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
808
809             /* Update potential sum for this i atom from the interaction with this j atom. */
810             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
811             velecsum         = _fjsp_add_v2r8(velecsum,velec);
812
813             fscal            = felec;
814
815             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
816
817             /* Update vectorial force */
818             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
819             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
820             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
821             
822             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
823             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
824             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
825
826             /**************************
827              * CALCULATE INTERACTIONS *
828              **************************/
829
830             /* COULOMB ELECTROSTATICS */
831             velec            = _fjsp_mul_v2r8(qq21,rinv21);
832             felec            = _fjsp_mul_v2r8(velec,rinvsq21);
833
834             /* Update potential sum for this i atom from the interaction with this j atom. */
835             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
836             velecsum         = _fjsp_add_v2r8(velecsum,velec);
837
838             fscal            = felec;
839
840             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
841
842             /* Update vectorial force */
843             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
844             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
845             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
846             
847             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
848             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
849             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
850
851             /**************************
852              * CALCULATE INTERACTIONS *
853              **************************/
854
855             /* COULOMB ELECTROSTATICS */
856             velec            = _fjsp_mul_v2r8(qq22,rinv22);
857             felec            = _fjsp_mul_v2r8(velec,rinvsq22);
858
859             /* Update potential sum for this i atom from the interaction with this j atom. */
860             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
861             velecsum         = _fjsp_add_v2r8(velecsum,velec);
862
863             fscal            = felec;
864
865             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
866
867             /* Update vectorial force */
868             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
869             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
870             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
871             
872             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
873             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
874             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
875
876             gmx_fjsp_decrement_3rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
877
878             /* Inner loop uses 314 flops */
879         }
880
881         /* End of innermost loop */
882
883         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
884                                               f+i_coord_offset,fshift+i_shift_offset);
885
886         ggid                        = gid[iidx];
887         /* Update potential energies */
888         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
889         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
890
891         /* Increment number of inner iterations */
892         inneriter                  += j_index_end - j_index_start;
893
894         /* Outer loop uses 20 flops */
895     }
896
897     /* Increment number of outer iterations */
898     outeriter        += nri;
899
900     /* Update outer/inner flops */
901
902     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*20 + inneriter*314);
903 }
904 /*
905  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_F_sparc64_hpc_ace_double
906  * Electrostatics interaction: Coulomb
907  * VdW interaction:            CubicSplineTable
908  * Geometry:                   Water3-Water3
909  * Calculate force/pot:        Force
910  */
911 void
912 nb_kernel_ElecCoul_VdwCSTab_GeomW3W3_F_sparc64_hpc_ace_double
913                     (t_nblist                    * gmx_restrict       nlist,
914                      rvec                        * gmx_restrict          xx,
915                      rvec                        * gmx_restrict          ff,
916                      t_forcerec                  * gmx_restrict          fr,
917                      t_mdatoms                   * gmx_restrict     mdatoms,
918                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
919                      t_nrnb                      * gmx_restrict        nrnb)
920 {
921     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
922      * just 0 for non-waters.
923      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
924      * jnr indices corresponding to data put in the four positions in the SIMD register.
925      */
926     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
927     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
928     int              jnrA,jnrB;
929     int              j_coord_offsetA,j_coord_offsetB;
930     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
931     real             rcutoff_scalar;
932     real             *shiftvec,*fshift,*x,*f;
933     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
934     int              vdwioffset0;
935     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
936     int              vdwioffset1;
937     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
938     int              vdwioffset2;
939     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
940     int              vdwjidx0A,vdwjidx0B;
941     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
942     int              vdwjidx1A,vdwjidx1B;
943     _fjsp_v2r8       jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
944     int              vdwjidx2A,vdwjidx2B;
945     _fjsp_v2r8       jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
946     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
947     _fjsp_v2r8       dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
948     _fjsp_v2r8       dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
949     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
950     _fjsp_v2r8       dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
951     _fjsp_v2r8       dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
952     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
953     _fjsp_v2r8       dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
954     _fjsp_v2r8       dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
955     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
956     real             *charge;
957     int              nvdwtype;
958     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
959     int              *vdwtype;
960     real             *vdwparam;
961     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
962     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
963     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
964     real             *vftab;
965     _fjsp_v2r8       itab_tmp;
966     _fjsp_v2r8       dummy_mask,cutoff_mask;
967     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
968     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
969     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
970
971     x                = xx[0];
972     f                = ff[0];
973
974     nri              = nlist->nri;
975     iinr             = nlist->iinr;
976     jindex           = nlist->jindex;
977     jjnr             = nlist->jjnr;
978     shiftidx         = nlist->shift;
979     gid              = nlist->gid;
980     shiftvec         = fr->shift_vec[0];
981     fshift           = fr->fshift[0];
982     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
983     charge           = mdatoms->chargeA;
984     nvdwtype         = fr->ntype;
985     vdwparam         = fr->nbfp;
986     vdwtype          = mdatoms->typeA;
987
988     vftab            = kernel_data->table_vdw->data;
989     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
990
991     /* Setup water-specific parameters */
992     inr              = nlist->iinr[0];
993     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
994     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
995     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
996     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
997
998     jq0              = gmx_fjsp_set1_v2r8(charge[inr+0]);
999     jq1              = gmx_fjsp_set1_v2r8(charge[inr+1]);
1000     jq2              = gmx_fjsp_set1_v2r8(charge[inr+2]);
1001     vdwjidx0A        = 2*vdwtype[inr+0];
1002     qq00             = _fjsp_mul_v2r8(iq0,jq0);
1003     c6_00            = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A]);
1004     c12_00           = gmx_fjsp_set1_v2r8(vdwparam[vdwioffset0+vdwjidx0A+1]);
1005     qq01             = _fjsp_mul_v2r8(iq0,jq1);
1006     qq02             = _fjsp_mul_v2r8(iq0,jq2);
1007     qq10             = _fjsp_mul_v2r8(iq1,jq0);
1008     qq11             = _fjsp_mul_v2r8(iq1,jq1);
1009     qq12             = _fjsp_mul_v2r8(iq1,jq2);
1010     qq20             = _fjsp_mul_v2r8(iq2,jq0);
1011     qq21             = _fjsp_mul_v2r8(iq2,jq1);
1012     qq22             = _fjsp_mul_v2r8(iq2,jq2);
1013
1014     /* Avoid stupid compiler warnings */
1015     jnrA = jnrB = 0;
1016     j_coord_offsetA = 0;
1017     j_coord_offsetB = 0;
1018
1019     outeriter        = 0;
1020     inneriter        = 0;
1021
1022     /* Start outer loop over neighborlists */
1023     for(iidx=0; iidx<nri; iidx++)
1024     {
1025         /* Load shift vector for this list */
1026         i_shift_offset   = DIM*shiftidx[iidx];
1027
1028         /* Load limits for loop over neighbors */
1029         j_index_start    = jindex[iidx];
1030         j_index_end      = jindex[iidx+1];
1031
1032         /* Get outer coordinate index */
1033         inr              = iinr[iidx];
1034         i_coord_offset   = DIM*inr;
1035
1036         /* Load i particle coords and add shift vector */
1037         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
1038                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1039
1040         fix0             = _fjsp_setzero_v2r8();
1041         fiy0             = _fjsp_setzero_v2r8();
1042         fiz0             = _fjsp_setzero_v2r8();
1043         fix1             = _fjsp_setzero_v2r8();
1044         fiy1             = _fjsp_setzero_v2r8();
1045         fiz1             = _fjsp_setzero_v2r8();
1046         fix2             = _fjsp_setzero_v2r8();
1047         fiy2             = _fjsp_setzero_v2r8();
1048         fiz2             = _fjsp_setzero_v2r8();
1049
1050         /* Start inner kernel loop */
1051         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
1052         {
1053
1054             /* Get j neighbor index, and coordinate index */
1055             jnrA             = jjnr[jidx];
1056             jnrB             = jjnr[jidx+1];
1057             j_coord_offsetA  = DIM*jnrA;
1058             j_coord_offsetB  = DIM*jnrB;
1059
1060             /* load j atom coordinates */
1061             gmx_fjsp_load_3rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
1062                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1063
1064             /* Calculate displacement vector */
1065             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1066             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1067             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1068             dx01             = _fjsp_sub_v2r8(ix0,jx1);
1069             dy01             = _fjsp_sub_v2r8(iy0,jy1);
1070             dz01             = _fjsp_sub_v2r8(iz0,jz1);
1071             dx02             = _fjsp_sub_v2r8(ix0,jx2);
1072             dy02             = _fjsp_sub_v2r8(iy0,jy2);
1073             dz02             = _fjsp_sub_v2r8(iz0,jz2);
1074             dx10             = _fjsp_sub_v2r8(ix1,jx0);
1075             dy10             = _fjsp_sub_v2r8(iy1,jy0);
1076             dz10             = _fjsp_sub_v2r8(iz1,jz0);
1077             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1078             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1079             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1080             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1081             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1082             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1083             dx20             = _fjsp_sub_v2r8(ix2,jx0);
1084             dy20             = _fjsp_sub_v2r8(iy2,jy0);
1085             dz20             = _fjsp_sub_v2r8(iz2,jz0);
1086             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1087             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1088             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1089             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1090             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1091             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1092
1093             /* Calculate squared distance and things based on it */
1094             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1095             rsq01            = gmx_fjsp_calc_rsq_v2r8(dx01,dy01,dz01);
1096             rsq02            = gmx_fjsp_calc_rsq_v2r8(dx02,dy02,dz02);
1097             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1098             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1099             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1100             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1101             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1102             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1103
1104             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1105             rinv01           = gmx_fjsp_invsqrt_v2r8(rsq01);
1106             rinv02           = gmx_fjsp_invsqrt_v2r8(rsq02);
1107             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
1108             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1109             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1110             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
1111             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1112             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1113
1114             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
1115             rinvsq01         = _fjsp_mul_v2r8(rinv01,rinv01);
1116             rinvsq02         = _fjsp_mul_v2r8(rinv02,rinv02);
1117             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
1118             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1119             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1120             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
1121             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1122             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1123
1124             fjx0             = _fjsp_setzero_v2r8();
1125             fjy0             = _fjsp_setzero_v2r8();
1126             fjz0             = _fjsp_setzero_v2r8();
1127             fjx1             = _fjsp_setzero_v2r8();
1128             fjy1             = _fjsp_setzero_v2r8();
1129             fjz1             = _fjsp_setzero_v2r8();
1130             fjx2             = _fjsp_setzero_v2r8();
1131             fjy2             = _fjsp_setzero_v2r8();
1132             fjz2             = _fjsp_setzero_v2r8();
1133
1134             /**************************
1135              * CALCULATE INTERACTIONS *
1136              **************************/
1137
1138             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1139
1140             /* Calculate table index by multiplying r with table scale and truncate to integer */
1141             rt               = _fjsp_mul_v2r8(r00,vftabscale);
1142             itab_tmp         = _fjsp_dtox_v2r8(rt);
1143             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
1144             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
1145             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
1146
1147             vfconv.i[0]     *= 8;
1148             vfconv.i[1]     *= 8;
1149
1150             /* COULOMB ELECTROSTATICS */
1151             velec            = _fjsp_mul_v2r8(qq00,rinv00);
1152             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
1153
1154             /* CUBIC SPLINE TABLE DISPERSION */
1155             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
1156             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
1157             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1158             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
1159             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
1160             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1161             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1162             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1163             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
1164
1165             /* CUBIC SPLINE TABLE REPULSION */
1166             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
1167             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
1168             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1169             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
1170             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
1171             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1172             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1173             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1174             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
1175             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
1176
1177             fscal            = _fjsp_add_v2r8(felec,fvdw);
1178
1179             /* Update vectorial force */
1180             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1181             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1182             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1183             
1184             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1185             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1186             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1187
1188             /**************************
1189              * CALCULATE INTERACTIONS *
1190              **************************/
1191
1192             /* COULOMB ELECTROSTATICS */
1193             velec            = _fjsp_mul_v2r8(qq01,rinv01);
1194             felec            = _fjsp_mul_v2r8(velec,rinvsq01);
1195
1196             fscal            = felec;
1197
1198             /* Update vectorial force */
1199             fix0             = _fjsp_madd_v2r8(dx01,fscal,fix0);
1200             fiy0             = _fjsp_madd_v2r8(dy01,fscal,fiy0);
1201             fiz0             = _fjsp_madd_v2r8(dz01,fscal,fiz0);
1202             
1203             fjx1             = _fjsp_madd_v2r8(dx01,fscal,fjx1);
1204             fjy1             = _fjsp_madd_v2r8(dy01,fscal,fjy1);
1205             fjz1             = _fjsp_madd_v2r8(dz01,fscal,fjz1);
1206
1207             /**************************
1208              * CALCULATE INTERACTIONS *
1209              **************************/
1210
1211             /* COULOMB ELECTROSTATICS */
1212             velec            = _fjsp_mul_v2r8(qq02,rinv02);
1213             felec            = _fjsp_mul_v2r8(velec,rinvsq02);
1214
1215             fscal            = felec;
1216
1217             /* Update vectorial force */
1218             fix0             = _fjsp_madd_v2r8(dx02,fscal,fix0);
1219             fiy0             = _fjsp_madd_v2r8(dy02,fscal,fiy0);
1220             fiz0             = _fjsp_madd_v2r8(dz02,fscal,fiz0);
1221             
1222             fjx2             = _fjsp_madd_v2r8(dx02,fscal,fjx2);
1223             fjy2             = _fjsp_madd_v2r8(dy02,fscal,fjy2);
1224             fjz2             = _fjsp_madd_v2r8(dz02,fscal,fjz2);
1225
1226             /**************************
1227              * CALCULATE INTERACTIONS *
1228              **************************/
1229
1230             /* COULOMB ELECTROSTATICS */
1231             velec            = _fjsp_mul_v2r8(qq10,rinv10);
1232             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
1233
1234             fscal            = felec;
1235
1236             /* Update vectorial force */
1237             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1238             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1239             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1240             
1241             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1242             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1243             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1244
1245             /**************************
1246              * CALCULATE INTERACTIONS *
1247              **************************/
1248
1249             /* COULOMB ELECTROSTATICS */
1250             velec            = _fjsp_mul_v2r8(qq11,rinv11);
1251             felec            = _fjsp_mul_v2r8(velec,rinvsq11);
1252
1253             fscal            = felec;
1254
1255             /* Update vectorial force */
1256             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1257             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1258             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1259             
1260             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1261             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1262             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1263
1264             /**************************
1265              * CALCULATE INTERACTIONS *
1266              **************************/
1267
1268             /* COULOMB ELECTROSTATICS */
1269             velec            = _fjsp_mul_v2r8(qq12,rinv12);
1270             felec            = _fjsp_mul_v2r8(velec,rinvsq12);
1271
1272             fscal            = felec;
1273
1274             /* Update vectorial force */
1275             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1276             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1277             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1278             
1279             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1280             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1281             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1282
1283             /**************************
1284              * CALCULATE INTERACTIONS *
1285              **************************/
1286
1287             /* COULOMB ELECTROSTATICS */
1288             velec            = _fjsp_mul_v2r8(qq20,rinv20);
1289             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
1290
1291             fscal            = felec;
1292
1293             /* Update vectorial force */
1294             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1295             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1296             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1297             
1298             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1299             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1300             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1301
1302             /**************************
1303              * CALCULATE INTERACTIONS *
1304              **************************/
1305
1306             /* COULOMB ELECTROSTATICS */
1307             velec            = _fjsp_mul_v2r8(qq21,rinv21);
1308             felec            = _fjsp_mul_v2r8(velec,rinvsq21);
1309
1310             fscal            = felec;
1311
1312             /* Update vectorial force */
1313             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1314             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1315             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1316             
1317             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1318             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1319             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1320
1321             /**************************
1322              * CALCULATE INTERACTIONS *
1323              **************************/
1324
1325             /* COULOMB ELECTROSTATICS */
1326             velec            = _fjsp_mul_v2r8(qq22,rinv22);
1327             felec            = _fjsp_mul_v2r8(velec,rinvsq22);
1328
1329             fscal            = felec;
1330
1331             /* Update vectorial force */
1332             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1333             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1334             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1335             
1336             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1337             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1338             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1339
1340             gmx_fjsp_decrement_3rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1341
1342             /* Inner loop uses 297 flops */
1343         }
1344
1345         if(jidx<j_index_end)
1346         {
1347
1348             jnrA             = jjnr[jidx];
1349             j_coord_offsetA  = DIM*jnrA;
1350
1351             /* load j atom coordinates */
1352             gmx_fjsp_load_3rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1353                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1354
1355             /* Calculate displacement vector */
1356             dx00             = _fjsp_sub_v2r8(ix0,jx0);
1357             dy00             = _fjsp_sub_v2r8(iy0,jy0);
1358             dz00             = _fjsp_sub_v2r8(iz0,jz0);
1359             dx01             = _fjsp_sub_v2r8(ix0,jx1);
1360             dy01             = _fjsp_sub_v2r8(iy0,jy1);
1361             dz01             = _fjsp_sub_v2r8(iz0,jz1);
1362             dx02             = _fjsp_sub_v2r8(ix0,jx2);
1363             dy02             = _fjsp_sub_v2r8(iy0,jy2);
1364             dz02             = _fjsp_sub_v2r8(iz0,jz2);
1365             dx10             = _fjsp_sub_v2r8(ix1,jx0);
1366             dy10             = _fjsp_sub_v2r8(iy1,jy0);
1367             dz10             = _fjsp_sub_v2r8(iz1,jz0);
1368             dx11             = _fjsp_sub_v2r8(ix1,jx1);
1369             dy11             = _fjsp_sub_v2r8(iy1,jy1);
1370             dz11             = _fjsp_sub_v2r8(iz1,jz1);
1371             dx12             = _fjsp_sub_v2r8(ix1,jx2);
1372             dy12             = _fjsp_sub_v2r8(iy1,jy2);
1373             dz12             = _fjsp_sub_v2r8(iz1,jz2);
1374             dx20             = _fjsp_sub_v2r8(ix2,jx0);
1375             dy20             = _fjsp_sub_v2r8(iy2,jy0);
1376             dz20             = _fjsp_sub_v2r8(iz2,jz0);
1377             dx21             = _fjsp_sub_v2r8(ix2,jx1);
1378             dy21             = _fjsp_sub_v2r8(iy2,jy1);
1379             dz21             = _fjsp_sub_v2r8(iz2,jz1);
1380             dx22             = _fjsp_sub_v2r8(ix2,jx2);
1381             dy22             = _fjsp_sub_v2r8(iy2,jy2);
1382             dz22             = _fjsp_sub_v2r8(iz2,jz2);
1383
1384             /* Calculate squared distance and things based on it */
1385             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1386             rsq01            = gmx_fjsp_calc_rsq_v2r8(dx01,dy01,dz01);
1387             rsq02            = gmx_fjsp_calc_rsq_v2r8(dx02,dy02,dz02);
1388             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1389             rsq11            = gmx_fjsp_calc_rsq_v2r8(dx11,dy11,dz11);
1390             rsq12            = gmx_fjsp_calc_rsq_v2r8(dx12,dy12,dz12);
1391             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1392             rsq21            = gmx_fjsp_calc_rsq_v2r8(dx21,dy21,dz21);
1393             rsq22            = gmx_fjsp_calc_rsq_v2r8(dx22,dy22,dz22);
1394
1395             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
1396             rinv01           = gmx_fjsp_invsqrt_v2r8(rsq01);
1397             rinv02           = gmx_fjsp_invsqrt_v2r8(rsq02);
1398             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
1399             rinv11           = gmx_fjsp_invsqrt_v2r8(rsq11);
1400             rinv12           = gmx_fjsp_invsqrt_v2r8(rsq12);
1401             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
1402             rinv21           = gmx_fjsp_invsqrt_v2r8(rsq21);
1403             rinv22           = gmx_fjsp_invsqrt_v2r8(rsq22);
1404
1405             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
1406             rinvsq01         = _fjsp_mul_v2r8(rinv01,rinv01);
1407             rinvsq02         = _fjsp_mul_v2r8(rinv02,rinv02);
1408             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
1409             rinvsq11         = _fjsp_mul_v2r8(rinv11,rinv11);
1410             rinvsq12         = _fjsp_mul_v2r8(rinv12,rinv12);
1411             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
1412             rinvsq21         = _fjsp_mul_v2r8(rinv21,rinv21);
1413             rinvsq22         = _fjsp_mul_v2r8(rinv22,rinv22);
1414
1415             fjx0             = _fjsp_setzero_v2r8();
1416             fjy0             = _fjsp_setzero_v2r8();
1417             fjz0             = _fjsp_setzero_v2r8();
1418             fjx1             = _fjsp_setzero_v2r8();
1419             fjy1             = _fjsp_setzero_v2r8();
1420             fjz1             = _fjsp_setzero_v2r8();
1421             fjx2             = _fjsp_setzero_v2r8();
1422             fjy2             = _fjsp_setzero_v2r8();
1423             fjz2             = _fjsp_setzero_v2r8();
1424
1425             /**************************
1426              * CALCULATE INTERACTIONS *
1427              **************************/
1428
1429             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
1430
1431             /* Calculate table index by multiplying r with table scale and truncate to integer */
1432             rt               = _fjsp_mul_v2r8(r00,vftabscale);
1433             itab_tmp         = _fjsp_dtox_v2r8(rt);
1434             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
1435             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
1436             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
1437
1438             vfconv.i[0]     *= 8;
1439             vfconv.i[1]     *= 8;
1440
1441             /* COULOMB ELECTROSTATICS */
1442             velec            = _fjsp_mul_v2r8(qq00,rinv00);
1443             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
1444
1445             /* CUBIC SPLINE TABLE DISPERSION */
1446             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
1447             F                = _fjsp_setzero_v2r8();
1448             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1449             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
1450             H                = _fjsp_setzero_v2r8();
1451             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1452             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1453             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1454             fvdw6            = _fjsp_mul_v2r8(c6_00,FF);
1455
1456             /* CUBIC SPLINE TABLE REPULSION */
1457             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
1458             F                = _fjsp_setzero_v2r8();
1459             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
1460             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
1461             H                = _fjsp_setzero_v2r8();
1462             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
1463             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
1464             FF               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
1465             fvdw12           = _fjsp_mul_v2r8(c12_00,FF);
1466             fvdw             = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
1467
1468             fscal            = _fjsp_add_v2r8(felec,fvdw);
1469
1470             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1471
1472             /* Update vectorial force */
1473             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
1474             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1475             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1476             
1477             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1478             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1479             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1480
1481             /**************************
1482              * CALCULATE INTERACTIONS *
1483              **************************/
1484
1485             /* COULOMB ELECTROSTATICS */
1486             velec            = _fjsp_mul_v2r8(qq01,rinv01);
1487             felec            = _fjsp_mul_v2r8(velec,rinvsq01);
1488
1489             fscal            = felec;
1490
1491             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1492
1493             /* Update vectorial force */
1494             fix0             = _fjsp_madd_v2r8(dx01,fscal,fix0);
1495             fiy0             = _fjsp_madd_v2r8(dy01,fscal,fiy0);
1496             fiz0             = _fjsp_madd_v2r8(dz01,fscal,fiz0);
1497             
1498             fjx1             = _fjsp_madd_v2r8(dx01,fscal,fjx1);
1499             fjy1             = _fjsp_madd_v2r8(dy01,fscal,fjy1);
1500             fjz1             = _fjsp_madd_v2r8(dz01,fscal,fjz1);
1501
1502             /**************************
1503              * CALCULATE INTERACTIONS *
1504              **************************/
1505
1506             /* COULOMB ELECTROSTATICS */
1507             velec            = _fjsp_mul_v2r8(qq02,rinv02);
1508             felec            = _fjsp_mul_v2r8(velec,rinvsq02);
1509
1510             fscal            = felec;
1511
1512             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1513
1514             /* Update vectorial force */
1515             fix0             = _fjsp_madd_v2r8(dx02,fscal,fix0);
1516             fiy0             = _fjsp_madd_v2r8(dy02,fscal,fiy0);
1517             fiz0             = _fjsp_madd_v2r8(dz02,fscal,fiz0);
1518             
1519             fjx2             = _fjsp_madd_v2r8(dx02,fscal,fjx2);
1520             fjy2             = _fjsp_madd_v2r8(dy02,fscal,fjy2);
1521             fjz2             = _fjsp_madd_v2r8(dz02,fscal,fjz2);
1522
1523             /**************************
1524              * CALCULATE INTERACTIONS *
1525              **************************/
1526
1527             /* COULOMB ELECTROSTATICS */
1528             velec            = _fjsp_mul_v2r8(qq10,rinv10);
1529             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
1530
1531             fscal            = felec;
1532
1533             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1534
1535             /* Update vectorial force */
1536             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
1537             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1538             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1539             
1540             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1541             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1542             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1543
1544             /**************************
1545              * CALCULATE INTERACTIONS *
1546              **************************/
1547
1548             /* COULOMB ELECTROSTATICS */
1549             velec            = _fjsp_mul_v2r8(qq11,rinv11);
1550             felec            = _fjsp_mul_v2r8(velec,rinvsq11);
1551
1552             fscal            = felec;
1553
1554             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1555
1556             /* Update vectorial force */
1557             fix1             = _fjsp_madd_v2r8(dx11,fscal,fix1);
1558             fiy1             = _fjsp_madd_v2r8(dy11,fscal,fiy1);
1559             fiz1             = _fjsp_madd_v2r8(dz11,fscal,fiz1);
1560             
1561             fjx1             = _fjsp_madd_v2r8(dx11,fscal,fjx1);
1562             fjy1             = _fjsp_madd_v2r8(dy11,fscal,fjy1);
1563             fjz1             = _fjsp_madd_v2r8(dz11,fscal,fjz1);
1564
1565             /**************************
1566              * CALCULATE INTERACTIONS *
1567              **************************/
1568
1569             /* COULOMB ELECTROSTATICS */
1570             velec            = _fjsp_mul_v2r8(qq12,rinv12);
1571             felec            = _fjsp_mul_v2r8(velec,rinvsq12);
1572
1573             fscal            = felec;
1574
1575             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1576
1577             /* Update vectorial force */
1578             fix1             = _fjsp_madd_v2r8(dx12,fscal,fix1);
1579             fiy1             = _fjsp_madd_v2r8(dy12,fscal,fiy1);
1580             fiz1             = _fjsp_madd_v2r8(dz12,fscal,fiz1);
1581             
1582             fjx2             = _fjsp_madd_v2r8(dx12,fscal,fjx2);
1583             fjy2             = _fjsp_madd_v2r8(dy12,fscal,fjy2);
1584             fjz2             = _fjsp_madd_v2r8(dz12,fscal,fjz2);
1585
1586             /**************************
1587              * CALCULATE INTERACTIONS *
1588              **************************/
1589
1590             /* COULOMB ELECTROSTATICS */
1591             velec            = _fjsp_mul_v2r8(qq20,rinv20);
1592             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
1593
1594             fscal            = felec;
1595
1596             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1597
1598             /* Update vectorial force */
1599             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
1600             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1601             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1602             
1603             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1604             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1605             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1606
1607             /**************************
1608              * CALCULATE INTERACTIONS *
1609              **************************/
1610
1611             /* COULOMB ELECTROSTATICS */
1612             velec            = _fjsp_mul_v2r8(qq21,rinv21);
1613             felec            = _fjsp_mul_v2r8(velec,rinvsq21);
1614
1615             fscal            = felec;
1616
1617             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1618
1619             /* Update vectorial force */
1620             fix2             = _fjsp_madd_v2r8(dx21,fscal,fix2);
1621             fiy2             = _fjsp_madd_v2r8(dy21,fscal,fiy2);
1622             fiz2             = _fjsp_madd_v2r8(dz21,fscal,fiz2);
1623             
1624             fjx1             = _fjsp_madd_v2r8(dx21,fscal,fjx1);
1625             fjy1             = _fjsp_madd_v2r8(dy21,fscal,fjy1);
1626             fjz1             = _fjsp_madd_v2r8(dz21,fscal,fjz1);
1627
1628             /**************************
1629              * CALCULATE INTERACTIONS *
1630              **************************/
1631
1632             /* COULOMB ELECTROSTATICS */
1633             velec            = _fjsp_mul_v2r8(qq22,rinv22);
1634             felec            = _fjsp_mul_v2r8(velec,rinvsq22);
1635
1636             fscal            = felec;
1637
1638             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1639
1640             /* Update vectorial force */
1641             fix2             = _fjsp_madd_v2r8(dx22,fscal,fix2);
1642             fiy2             = _fjsp_madd_v2r8(dy22,fscal,fiy2);
1643             fiz2             = _fjsp_madd_v2r8(dz22,fscal,fiz2);
1644             
1645             fjx2             = _fjsp_madd_v2r8(dx22,fscal,fjx2);
1646             fjy2             = _fjsp_madd_v2r8(dy22,fscal,fjy2);
1647             fjz2             = _fjsp_madd_v2r8(dz22,fscal,fjz2);
1648
1649             gmx_fjsp_decrement_3rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1650
1651             /* Inner loop uses 297 flops */
1652         }
1653
1654         /* End of innermost loop */
1655
1656         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1657                                               f+i_coord_offset,fshift+i_shift_offset);
1658
1659         /* Increment number of inner iterations */
1660         inneriter                  += j_index_end - j_index_start;
1661
1662         /* Outer loop uses 18 flops */
1663     }
1664
1665     /* Increment number of outer iterations */
1666     outeriter        += nri;
1667
1668     /* Update outer/inner flops */
1669
1670     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*18 + inneriter*297);
1671 }