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