Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecEw_VdwLJ_GeomP1P1_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecEw_VdwLJ_GeomP1P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: Ewald
52  * VdW interaction:            LennardJones
53  * Geometry:                   Particle-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecEw_VdwLJ_GeomP1P1_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwjidx0A,vdwjidx0B;
82     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
85     real             *charge;
86     int              nvdwtype;
87     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
88     int              *vdwtype;
89     real             *vdwparam;
90     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
91     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
92     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
93     real             *ewtab;
94     _fjsp_v2r8       itab_tmp;
95     _fjsp_v2r8       dummy_mask,cutoff_mask;
96     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
97     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
98     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
99
100     x                = xx[0];
101     f                = ff[0];
102
103     nri              = nlist->nri;
104     iinr             = nlist->iinr;
105     jindex           = nlist->jindex;
106     jjnr             = nlist->jjnr;
107     shiftidx         = nlist->shift;
108     gid              = nlist->gid;
109     shiftvec         = fr->shift_vec[0];
110     fshift           = fr->fshift[0];
111     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
112     charge           = mdatoms->chargeA;
113     nvdwtype         = fr->ntype;
114     vdwparam         = fr->nbfp;
115     vdwtype          = mdatoms->typeA;
116
117     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
118     ewtab            = fr->ic->tabq_coul_FDV0;
119     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
120     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
121
122     /* Avoid stupid compiler warnings */
123     jnrA = jnrB = 0;
124     j_coord_offsetA = 0;
125     j_coord_offsetB = 0;
126
127     outeriter        = 0;
128     inneriter        = 0;
129
130     /* Start outer loop over neighborlists */
131     for(iidx=0; iidx<nri; iidx++)
132     {
133         /* Load shift vector for this list */
134         i_shift_offset   = DIM*shiftidx[iidx];
135
136         /* Load limits for loop over neighbors */
137         j_index_start    = jindex[iidx];
138         j_index_end      = jindex[iidx+1];
139
140         /* Get outer coordinate index */
141         inr              = iinr[iidx];
142         i_coord_offset   = DIM*inr;
143
144         /* Load i particle coords and add shift vector */
145         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
146
147         fix0             = _fjsp_setzero_v2r8();
148         fiy0             = _fjsp_setzero_v2r8();
149         fiz0             = _fjsp_setzero_v2r8();
150
151         /* Load parameters for i particles */
152         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
153         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
154
155         /* Reset potential sums */
156         velecsum         = _fjsp_setzero_v2r8();
157         vvdwsum          = _fjsp_setzero_v2r8();
158
159         /* Start inner kernel loop */
160         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
161         {
162
163             /* Get j neighbor index, and coordinate index */
164             jnrA             = jjnr[jidx];
165             jnrB             = jjnr[jidx+1];
166             j_coord_offsetA  = DIM*jnrA;
167             j_coord_offsetB  = DIM*jnrB;
168
169             /* load j atom coordinates */
170             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
171                                               &jx0,&jy0,&jz0);
172
173             /* Calculate displacement vector */
174             dx00             = _fjsp_sub_v2r8(ix0,jx0);
175             dy00             = _fjsp_sub_v2r8(iy0,jy0);
176             dz00             = _fjsp_sub_v2r8(iz0,jz0);
177
178             /* Calculate squared distance and things based on it */
179             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
180
181             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
182
183             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
184
185             /* Load parameters for j particles */
186             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
187             vdwjidx0A        = 2*vdwtype[jnrA+0];
188             vdwjidx0B        = 2*vdwtype[jnrB+0];
189
190             /**************************
191              * CALCULATE INTERACTIONS *
192              **************************/
193
194             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
195
196             /* Compute parameters for interactions between i and j atoms */
197             qq00             = _fjsp_mul_v2r8(iq0,jq0);
198             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
199                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
200
201             /* EWALD ELECTROSTATICS */
202
203             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
204             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
205             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
206             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
207             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
208
209             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
210             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
211             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
212             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
213             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
214             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
215             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
216             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
217             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
218             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
219
220             /* LENNARD-JONES DISPERSION/REPULSION */
221
222             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
223             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
224             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
225             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
226             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
227
228             /* Update potential sum for this i atom from the interaction with this j atom. */
229             velecsum         = _fjsp_add_v2r8(velecsum,velec);
230             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
231
232             fscal            = _fjsp_add_v2r8(felec,fvdw);
233
234             /* Update vectorial force */
235             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
236             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
237             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
238             
239             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
240
241             /* Inner loop uses 56 flops */
242         }
243
244         if(jidx<j_index_end)
245         {
246
247             jnrA             = jjnr[jidx];
248             j_coord_offsetA  = DIM*jnrA;
249
250             /* load j atom coordinates */
251             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
252                                               &jx0,&jy0,&jz0);
253
254             /* Calculate displacement vector */
255             dx00             = _fjsp_sub_v2r8(ix0,jx0);
256             dy00             = _fjsp_sub_v2r8(iy0,jy0);
257             dz00             = _fjsp_sub_v2r8(iz0,jz0);
258
259             /* Calculate squared distance and things based on it */
260             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
261
262             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
263
264             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
265
266             /* Load parameters for j particles */
267             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
268             vdwjidx0A        = 2*vdwtype[jnrA+0];
269
270             /**************************
271              * CALCULATE INTERACTIONS *
272              **************************/
273
274             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
275
276             /* Compute parameters for interactions between i and j atoms */
277             qq00             = _fjsp_mul_v2r8(iq0,jq0);
278             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
279
280             /* EWALD ELECTROSTATICS */
281
282             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
283             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
284             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
285             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
286             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
287
288             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
289             ewtabD           = _fjsp_setzero_v2r8();
290             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
291             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
292             ewtabFn          = _fjsp_setzero_v2r8();
293             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
294             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
295             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
296             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
297             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
298
299             /* LENNARD-JONES DISPERSION/REPULSION */
300
301             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
302             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
303             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
304             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
305             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
306
307             /* Update potential sum for this i atom from the interaction with this j atom. */
308             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
309             velecsum         = _fjsp_add_v2r8(velecsum,velec);
310             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
311             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
312
313             fscal            = _fjsp_add_v2r8(felec,fvdw);
314
315             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
316
317             /* Update vectorial force */
318             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
319             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
320             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
321             
322             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
323
324             /* Inner loop uses 56 flops */
325         }
326
327         /* End of innermost loop */
328
329         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
330                                               f+i_coord_offset,fshift+i_shift_offset);
331
332         ggid                        = gid[iidx];
333         /* Update potential energies */
334         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
335         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
336
337         /* Increment number of inner iterations */
338         inneriter                  += j_index_end - j_index_start;
339
340         /* Outer loop uses 9 flops */
341     }
342
343     /* Increment number of outer iterations */
344     outeriter        += nri;
345
346     /* Update outer/inner flops */
347
348     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*56);
349 }
350 /*
351  * Gromacs nonbonded kernel:   nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_sparc64_hpc_ace_double
352  * Electrostatics interaction: Ewald
353  * VdW interaction:            LennardJones
354  * Geometry:                   Particle-Particle
355  * Calculate force/pot:        Force
356  */
357 void
358 nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_sparc64_hpc_ace_double
359                     (t_nblist                    * gmx_restrict       nlist,
360                      rvec                        * gmx_restrict          xx,
361                      rvec                        * gmx_restrict          ff,
362                      t_forcerec                  * gmx_restrict          fr,
363                      t_mdatoms                   * gmx_restrict     mdatoms,
364                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
365                      t_nrnb                      * gmx_restrict        nrnb)
366 {
367     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
368      * just 0 for non-waters.
369      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
370      * jnr indices corresponding to data put in the four positions in the SIMD register.
371      */
372     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
373     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
374     int              jnrA,jnrB;
375     int              j_coord_offsetA,j_coord_offsetB;
376     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
377     real             rcutoff_scalar;
378     real             *shiftvec,*fshift,*x,*f;
379     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
380     int              vdwioffset0;
381     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
382     int              vdwjidx0A,vdwjidx0B;
383     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
384     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
385     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
386     real             *charge;
387     int              nvdwtype;
388     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
389     int              *vdwtype;
390     real             *vdwparam;
391     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
392     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
393     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
394     real             *ewtab;
395     _fjsp_v2r8       itab_tmp;
396     _fjsp_v2r8       dummy_mask,cutoff_mask;
397     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
398     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
399     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
400
401     x                = xx[0];
402     f                = ff[0];
403
404     nri              = nlist->nri;
405     iinr             = nlist->iinr;
406     jindex           = nlist->jindex;
407     jjnr             = nlist->jjnr;
408     shiftidx         = nlist->shift;
409     gid              = nlist->gid;
410     shiftvec         = fr->shift_vec[0];
411     fshift           = fr->fshift[0];
412     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
413     charge           = mdatoms->chargeA;
414     nvdwtype         = fr->ntype;
415     vdwparam         = fr->nbfp;
416     vdwtype          = mdatoms->typeA;
417
418     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
419     ewtab            = fr->ic->tabq_coul_F;
420     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
421     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
422
423     /* Avoid stupid compiler warnings */
424     jnrA = jnrB = 0;
425     j_coord_offsetA = 0;
426     j_coord_offsetB = 0;
427
428     outeriter        = 0;
429     inneriter        = 0;
430
431     /* Start outer loop over neighborlists */
432     for(iidx=0; iidx<nri; iidx++)
433     {
434         /* Load shift vector for this list */
435         i_shift_offset   = DIM*shiftidx[iidx];
436
437         /* Load limits for loop over neighbors */
438         j_index_start    = jindex[iidx];
439         j_index_end      = jindex[iidx+1];
440
441         /* Get outer coordinate index */
442         inr              = iinr[iidx];
443         i_coord_offset   = DIM*inr;
444
445         /* Load i particle coords and add shift vector */
446         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
447
448         fix0             = _fjsp_setzero_v2r8();
449         fiy0             = _fjsp_setzero_v2r8();
450         fiz0             = _fjsp_setzero_v2r8();
451
452         /* Load parameters for i particles */
453         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
454         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
455
456         /* Start inner kernel loop */
457         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
458         {
459
460             /* Get j neighbor index, and coordinate index */
461             jnrA             = jjnr[jidx];
462             jnrB             = jjnr[jidx+1];
463             j_coord_offsetA  = DIM*jnrA;
464             j_coord_offsetB  = DIM*jnrB;
465
466             /* load j atom coordinates */
467             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
468                                               &jx0,&jy0,&jz0);
469
470             /* Calculate displacement vector */
471             dx00             = _fjsp_sub_v2r8(ix0,jx0);
472             dy00             = _fjsp_sub_v2r8(iy0,jy0);
473             dz00             = _fjsp_sub_v2r8(iz0,jz0);
474
475             /* Calculate squared distance and things based on it */
476             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
477
478             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
479
480             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
481
482             /* Load parameters for j particles */
483             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
484             vdwjidx0A        = 2*vdwtype[jnrA+0];
485             vdwjidx0B        = 2*vdwtype[jnrB+0];
486
487             /**************************
488              * CALCULATE INTERACTIONS *
489              **************************/
490
491             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
492
493             /* Compute parameters for interactions between i and j atoms */
494             qq00             = _fjsp_mul_v2r8(iq0,jq0);
495             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
496                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
497
498             /* EWALD ELECTROSTATICS */
499
500             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
501             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
502             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
503             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
504             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
505
506             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
507                                          &ewtabF,&ewtabFn);
508             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
509             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
510
511             /* LENNARD-JONES DISPERSION/REPULSION */
512
513             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
514             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
515
516             fscal            = _fjsp_add_v2r8(felec,fvdw);
517
518             /* Update vectorial force */
519             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
520             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
521             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
522             
523             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
524
525             /* Inner loop uses 46 flops */
526         }
527
528         if(jidx<j_index_end)
529         {
530
531             jnrA             = jjnr[jidx];
532             j_coord_offsetA  = DIM*jnrA;
533
534             /* load j atom coordinates */
535             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
536                                               &jx0,&jy0,&jz0);
537
538             /* Calculate displacement vector */
539             dx00             = _fjsp_sub_v2r8(ix0,jx0);
540             dy00             = _fjsp_sub_v2r8(iy0,jy0);
541             dz00             = _fjsp_sub_v2r8(iz0,jz0);
542
543             /* Calculate squared distance and things based on it */
544             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
545
546             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
547
548             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
549
550             /* Load parameters for j particles */
551             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
552             vdwjidx0A        = 2*vdwtype[jnrA+0];
553
554             /**************************
555              * CALCULATE INTERACTIONS *
556              **************************/
557
558             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
559
560             /* Compute parameters for interactions between i and j atoms */
561             qq00             = _fjsp_mul_v2r8(iq0,jq0);
562             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
563
564             /* EWALD ELECTROSTATICS */
565
566             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
567             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
568             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
569             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
570             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
571
572             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
573             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
574             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
575
576             /* LENNARD-JONES DISPERSION/REPULSION */
577
578             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
579             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
580
581             fscal            = _fjsp_add_v2r8(felec,fvdw);
582
583             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
584
585             /* Update vectorial force */
586             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
587             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
588             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
589             
590             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
591
592             /* Inner loop uses 46 flops */
593         }
594
595         /* End of innermost loop */
596
597         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
598                                               f+i_coord_offset,fshift+i_shift_offset);
599
600         /* Increment number of inner iterations */
601         inneriter                  += j_index_end - j_index_start;
602
603         /* Outer loop uses 7 flops */
604     }
605
606     /* Increment number of outer iterations */
607     outeriter        += nri;
608
609     /* Update outer/inner flops */
610
611     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*46);
612 }