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