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