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