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