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