K-computer specific modifications
[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 #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_ElecEw_VdwLJ_GeomP1P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: Ewald
54  * VdW interaction:            LennardJones
55  * Geometry:                   Particle-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecEw_VdwLJ_GeomP1P1_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              vdwjidx0A,vdwjidx0B;
84     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
85     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
87     real             *charge;
88     int              nvdwtype;
89     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
90     int              *vdwtype;
91     real             *vdwparam;
92     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
93     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
94     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
95     real             *ewtab;
96     _fjsp_v2r8       itab_tmp;
97     _fjsp_v2r8       dummy_mask,cutoff_mask;
98     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
99     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
100     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
101
102     x                = xx[0];
103     f                = ff[0];
104
105     nri              = nlist->nri;
106     iinr             = nlist->iinr;
107     jindex           = nlist->jindex;
108     jjnr             = nlist->jjnr;
109     shiftidx         = nlist->shift;
110     gid              = nlist->gid;
111     shiftvec         = fr->shift_vec[0];
112     fshift           = fr->fshift[0];
113     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
114     charge           = mdatoms->chargeA;
115     nvdwtype         = fr->ntype;
116     vdwparam         = fr->nbfp;
117     vdwtype          = mdatoms->typeA;
118
119     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
120     ewtab            = fr->ic->tabq_coul_FDV0;
121     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
122     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
123
124     /* Avoid stupid compiler warnings */
125     jnrA = jnrB = 0;
126     j_coord_offsetA = 0;
127     j_coord_offsetB = 0;
128
129     outeriter        = 0;
130     inneriter        = 0;
131
132     /* Start outer loop over neighborlists */
133     for(iidx=0; iidx<nri; iidx++)
134     {
135         /* Load shift vector for this list */
136         i_shift_offset   = DIM*shiftidx[iidx];
137
138         /* Load limits for loop over neighbors */
139         j_index_start    = jindex[iidx];
140         j_index_end      = jindex[iidx+1];
141
142         /* Get outer coordinate index */
143         inr              = iinr[iidx];
144         i_coord_offset   = DIM*inr;
145
146         /* Load i particle coords and add shift vector */
147         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
148
149         fix0             = _fjsp_setzero_v2r8();
150         fiy0             = _fjsp_setzero_v2r8();
151         fiz0             = _fjsp_setzero_v2r8();
152
153         /* Load parameters for i particles */
154         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
155         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
156
157         /* Reset potential sums */
158         velecsum         = _fjsp_setzero_v2r8();
159         vvdwsum          = _fjsp_setzero_v2r8();
160
161         /* Start inner kernel loop */
162         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
163         {
164
165             /* Get j neighbor index, and coordinate index */
166             jnrA             = jjnr[jidx];
167             jnrB             = jjnr[jidx+1];
168             j_coord_offsetA  = DIM*jnrA;
169             j_coord_offsetB  = DIM*jnrB;
170
171             /* load j atom coordinates */
172             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
173                                               &jx0,&jy0,&jz0);
174
175             /* Calculate displacement vector */
176             dx00             = _fjsp_sub_v2r8(ix0,jx0);
177             dy00             = _fjsp_sub_v2r8(iy0,jy0);
178             dz00             = _fjsp_sub_v2r8(iz0,jz0);
179
180             /* Calculate squared distance and things based on it */
181             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
182
183             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
184
185             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
186
187             /* Load parameters for j particles */
188             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
189             vdwjidx0A        = 2*vdwtype[jnrA+0];
190             vdwjidx0B        = 2*vdwtype[jnrB+0];
191
192             /**************************
193              * CALCULATE INTERACTIONS *
194              **************************/
195
196             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
197
198             /* Compute parameters for interactions between i and j atoms */
199             qq00             = _fjsp_mul_v2r8(iq0,jq0);
200             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
201                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
202
203             /* EWALD ELECTROSTATICS */
204
205             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
206             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
207             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
208             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
209             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
210
211             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
212             ewtabD           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
213             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
214             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
215             ewtabFn          = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
216             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
217             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
218             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
219             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
220             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
221
222             /* LENNARD-JONES DISPERSION/REPULSION */
223
224             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
225             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
226             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
227             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
228             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
229
230             /* Update potential sum for this i atom from the interaction with this j atom. */
231             velecsum         = _fjsp_add_v2r8(velecsum,velec);
232             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
233
234             fscal            = _fjsp_add_v2r8(felec,fvdw);
235
236             /* Update vectorial force */
237             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
238             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
239             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
240             
241             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
242
243             /* Inner loop uses 56 flops */
244         }
245
246         if(jidx<j_index_end)
247         {
248
249             jnrA             = jjnr[jidx];
250             j_coord_offsetA  = DIM*jnrA;
251
252             /* load j atom coordinates */
253             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
254                                               &jx0,&jy0,&jz0);
255
256             /* Calculate displacement vector */
257             dx00             = _fjsp_sub_v2r8(ix0,jx0);
258             dy00             = _fjsp_sub_v2r8(iy0,jy0);
259             dz00             = _fjsp_sub_v2r8(iz0,jz0);
260
261             /* Calculate squared distance and things based on it */
262             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
263
264             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
265
266             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
267
268             /* Load parameters for j particles */
269             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
270             vdwjidx0A        = 2*vdwtype[jnrA+0];
271
272             /**************************
273              * CALCULATE INTERACTIONS *
274              **************************/
275
276             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
277
278             /* Compute parameters for interactions between i and j atoms */
279             qq00             = _fjsp_mul_v2r8(iq0,jq0);
280             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
281                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
282
283             /* EWALD ELECTROSTATICS */
284
285             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
286             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
287             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
288             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
289             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
290
291             ewtabF           = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
292             ewtabD           = _fjsp_setzero_v2r8();
293             GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
294             ewtabV           = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
295             ewtabFn          = _fjsp_setzero_v2r8();
296             GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
297             felec            = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
298             velec            = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
299             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
300             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
301
302             /* LENNARD-JONES DISPERSION/REPULSION */
303
304             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
305             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
306             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
307             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
308             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
309
310             /* Update potential sum for this i atom from the interaction with this j atom. */
311             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
312             velecsum         = _fjsp_add_v2r8(velecsum,velec);
313             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
314             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
315
316             fscal            = _fjsp_add_v2r8(felec,fvdw);
317
318             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
319
320             /* Update vectorial force */
321             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
322             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
323             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
324             
325             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
326
327             /* Inner loop uses 56 flops */
328         }
329
330         /* End of innermost loop */
331
332         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
333                                               f+i_coord_offset,fshift+i_shift_offset);
334
335         ggid                        = gid[iidx];
336         /* Update potential energies */
337         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
338         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
339
340         /* Increment number of inner iterations */
341         inneriter                  += j_index_end - j_index_start;
342
343         /* Outer loop uses 9 flops */
344     }
345
346     /* Increment number of outer iterations */
347     outeriter        += nri;
348
349     /* Update outer/inner flops */
350
351     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*56);
352 }
353 /*
354  * Gromacs nonbonded kernel:   nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_sparc64_hpc_ace_double
355  * Electrostatics interaction: Ewald
356  * VdW interaction:            LennardJones
357  * Geometry:                   Particle-Particle
358  * Calculate force/pot:        Force
359  */
360 void
361 nb_kernel_ElecEw_VdwLJ_GeomP1P1_F_sparc64_hpc_ace_double
362                     (t_nblist                    * gmx_restrict       nlist,
363                      rvec                        * gmx_restrict          xx,
364                      rvec                        * gmx_restrict          ff,
365                      t_forcerec                  * gmx_restrict          fr,
366                      t_mdatoms                   * gmx_restrict     mdatoms,
367                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
368                      t_nrnb                      * gmx_restrict        nrnb)
369 {
370     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
371      * just 0 for non-waters.
372      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
373      * jnr indices corresponding to data put in the four positions in the SIMD register.
374      */
375     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
376     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
377     int              jnrA,jnrB;
378     int              j_coord_offsetA,j_coord_offsetB;
379     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
380     real             rcutoff_scalar;
381     real             *shiftvec,*fshift,*x,*f;
382     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
383     int              vdwioffset0;
384     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
385     int              vdwjidx0A,vdwjidx0B;
386     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
387     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
388     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
389     real             *charge;
390     int              nvdwtype;
391     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
392     int              *vdwtype;
393     real             *vdwparam;
394     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
395     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
396     _fjsp_v2r8       ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
397     real             *ewtab;
398     _fjsp_v2r8       itab_tmp;
399     _fjsp_v2r8       dummy_mask,cutoff_mask;
400     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
401     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
402     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
403
404     x                = xx[0];
405     f                = ff[0];
406
407     nri              = nlist->nri;
408     iinr             = nlist->iinr;
409     jindex           = nlist->jindex;
410     jjnr             = nlist->jjnr;
411     shiftidx         = nlist->shift;
412     gid              = nlist->gid;
413     shiftvec         = fr->shift_vec[0];
414     fshift           = fr->fshift[0];
415     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
416     charge           = mdatoms->chargeA;
417     nvdwtype         = fr->ntype;
418     vdwparam         = fr->nbfp;
419     vdwtype          = mdatoms->typeA;
420
421     sh_ewald         = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
422     ewtab            = fr->ic->tabq_coul_F;
423     ewtabscale       = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
424     ewtabhalfspace   = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
425
426     /* Avoid stupid compiler warnings */
427     jnrA = jnrB = 0;
428     j_coord_offsetA = 0;
429     j_coord_offsetB = 0;
430
431     outeriter        = 0;
432     inneriter        = 0;
433
434     /* Start outer loop over neighborlists */
435     for(iidx=0; iidx<nri; iidx++)
436     {
437         /* Load shift vector for this list */
438         i_shift_offset   = DIM*shiftidx[iidx];
439
440         /* Load limits for loop over neighbors */
441         j_index_start    = jindex[iidx];
442         j_index_end      = jindex[iidx+1];
443
444         /* Get outer coordinate index */
445         inr              = iinr[iidx];
446         i_coord_offset   = DIM*inr;
447
448         /* Load i particle coords and add shift vector */
449         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
450
451         fix0             = _fjsp_setzero_v2r8();
452         fiy0             = _fjsp_setzero_v2r8();
453         fiz0             = _fjsp_setzero_v2r8();
454
455         /* Load parameters for i particles */
456         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
457         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
458
459         /* Start inner kernel loop */
460         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
461         {
462
463             /* Get j neighbor index, and coordinate index */
464             jnrA             = jjnr[jidx];
465             jnrB             = jjnr[jidx+1];
466             j_coord_offsetA  = DIM*jnrA;
467             j_coord_offsetB  = DIM*jnrB;
468
469             /* load j atom coordinates */
470             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
471                                               &jx0,&jy0,&jz0);
472
473             /* Calculate displacement vector */
474             dx00             = _fjsp_sub_v2r8(ix0,jx0);
475             dy00             = _fjsp_sub_v2r8(iy0,jy0);
476             dz00             = _fjsp_sub_v2r8(iz0,jz0);
477
478             /* Calculate squared distance and things based on it */
479             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
480
481             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
482
483             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
484
485             /* Load parameters for j particles */
486             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
487             vdwjidx0A        = 2*vdwtype[jnrA+0];
488             vdwjidx0B        = 2*vdwtype[jnrB+0];
489
490             /**************************
491              * CALCULATE INTERACTIONS *
492              **************************/
493
494             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
495
496             /* Compute parameters for interactions between i and j atoms */
497             qq00             = _fjsp_mul_v2r8(iq0,jq0);
498             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
499                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
500
501             /* EWALD ELECTROSTATICS */
502
503             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
504             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
505             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
506             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
507             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
508
509             gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
510                                          &ewtabF,&ewtabFn);
511             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
512             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
513
514             /* LENNARD-JONES DISPERSION/REPULSION */
515
516             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
517             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
518
519             fscal            = _fjsp_add_v2r8(felec,fvdw);
520
521             /* Update vectorial force */
522             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
523             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
524             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
525             
526             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
527
528             /* Inner loop uses 46 flops */
529         }
530
531         if(jidx<j_index_end)
532         {
533
534             jnrA             = jjnr[jidx];
535             j_coord_offsetA  = DIM*jnrA;
536
537             /* load j atom coordinates */
538             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
539                                               &jx0,&jy0,&jz0);
540
541             /* Calculate displacement vector */
542             dx00             = _fjsp_sub_v2r8(ix0,jx0);
543             dy00             = _fjsp_sub_v2r8(iy0,jy0);
544             dz00             = _fjsp_sub_v2r8(iz0,jz0);
545
546             /* Calculate squared distance and things based on it */
547             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
548
549             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
550
551             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
552
553             /* Load parameters for j particles */
554             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
555             vdwjidx0A        = 2*vdwtype[jnrA+0];
556
557             /**************************
558              * CALCULATE INTERACTIONS *
559              **************************/
560
561             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
562
563             /* Compute parameters for interactions between i and j atoms */
564             qq00             = _fjsp_mul_v2r8(iq0,jq0);
565             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
566                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
567
568             /* EWALD ELECTROSTATICS */
569
570             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
571             ewrt             = _fjsp_mul_v2r8(r00,ewtabscale);
572             itab_tmp         = _fjsp_dtox_v2r8(ewrt);
573             eweps            = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
574             _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
575
576             gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
577             felec            = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
578             felec            = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
579
580             /* LENNARD-JONES DISPERSION/REPULSION */
581
582             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
583             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
584
585             fscal            = _fjsp_add_v2r8(felec,fvdw);
586
587             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
588
589             /* Update vectorial force */
590             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
591             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
592             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
593             
594             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
595
596             /* Inner loop uses 46 flops */
597         }
598
599         /* End of innermost loop */
600
601         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
602                                               f+i_coord_offset,fshift+i_shift_offset);
603
604         /* Increment number of inner iterations */
605         inneriter                  += j_index_end - j_index_start;
606
607         /* Outer loop uses 7 flops */
608     }
609
610     /* Increment number of outer iterations */
611     outeriter        += nri;
612
613     /* Update outer/inner flops */
614
615     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*46);
616 }