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