Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_double / nb_kernel_ElecEw_VdwNone_GeomP1P1_sse2_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015,2017, 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 sse2_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_sse2_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecEw_VdwNone_GeomP1P1_VF_sse2_double
51  * Electrostatics interaction: Ewald
52  * VdW interaction:            None
53  * Geometry:                   Particle-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecEw_VdwNone_GeomP1P1_VF_sse2_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     __m128i          ewitab;
87     __m128d          ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
88     real             *ewtab;
89     __m128d          dummy_mask,cutoff_mask;
90     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
91     __m128d          one     = _mm_set1_pd(1.0);
92     __m128d          two     = _mm_set1_pd(2.0);
93     x                = xx[0];
94     f                = ff[0];
95
96     nri              = nlist->nri;
97     iinr             = nlist->iinr;
98     jindex           = nlist->jindex;
99     jjnr             = nlist->jjnr;
100     shiftidx         = nlist->shift;
101     gid              = nlist->gid;
102     shiftvec         = fr->shift_vec[0];
103     fshift           = fr->fshift[0];
104     facel            = _mm_set1_pd(fr->ic->epsfac);
105     charge           = mdatoms->chargeA;
106
107     sh_ewald         = _mm_set1_pd(fr->ic->sh_ewald);
108     ewtab            = fr->ic->tabq_coul_FDV0;
109     ewtabscale       = _mm_set1_pd(fr->ic->tabq_scale);
110     ewtabhalfspace   = _mm_set1_pd(0.5/fr->ic->tabq_scale);
111
112     /* Avoid stupid compiler warnings */
113     jnrA = jnrB = 0;
114     j_coord_offsetA = 0;
115     j_coord_offsetB = 0;
116
117     outeriter        = 0;
118     inneriter        = 0;
119
120     /* Start outer loop over neighborlists */
121     for(iidx=0; iidx<nri; iidx++)
122     {
123         /* Load shift vector for this list */
124         i_shift_offset   = DIM*shiftidx[iidx];
125
126         /* Load limits for loop over neighbors */
127         j_index_start    = jindex[iidx];
128         j_index_end      = jindex[iidx+1];
129
130         /* Get outer coordinate index */
131         inr              = iinr[iidx];
132         i_coord_offset   = DIM*inr;
133
134         /* Load i particle coords and add shift vector */
135         gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
136
137         fix0             = _mm_setzero_pd();
138         fiy0             = _mm_setzero_pd();
139         fiz0             = _mm_setzero_pd();
140
141         /* Load parameters for i particles */
142         iq0              = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
143
144         /* Reset potential sums */
145         velecsum         = _mm_setzero_pd();
146
147         /* Start inner kernel loop */
148         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
149         {
150
151             /* Get j neighbor index, and coordinate index */
152             jnrA             = jjnr[jidx];
153             jnrB             = jjnr[jidx+1];
154             j_coord_offsetA  = DIM*jnrA;
155             j_coord_offsetB  = DIM*jnrB;
156
157             /* load j atom coordinates */
158             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
159                                               &jx0,&jy0,&jz0);
160
161             /* Calculate displacement vector */
162             dx00             = _mm_sub_pd(ix0,jx0);
163             dy00             = _mm_sub_pd(iy0,jy0);
164             dz00             = _mm_sub_pd(iz0,jz0);
165
166             /* Calculate squared distance and things based on it */
167             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
168
169             rinv00           = sse2_invsqrt_d(rsq00);
170
171             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
172
173             /* Load parameters for j particles */
174             jq0              = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
175
176             /**************************
177              * CALCULATE INTERACTIONS *
178              **************************/
179
180             r00              = _mm_mul_pd(rsq00,rinv00);
181
182             /* Compute parameters for interactions between i and j atoms */
183             qq00             = _mm_mul_pd(iq0,jq0);
184
185             /* EWALD ELECTROSTATICS */
186
187             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
188             ewrt             = _mm_mul_pd(r00,ewtabscale);
189             ewitab           = _mm_cvttpd_epi32(ewrt);
190             eweps            = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
191             ewitab           = _mm_slli_epi32(ewitab,2);
192             ewtabF           = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
193             ewtabD           = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
194             GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
195             ewtabV           = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
196             ewtabFn          = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
197             GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
198             felec            = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
199             velec            = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
200             velec            = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
201             felec            = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
202
203             /* Update potential sum for this i atom from the interaction with this j atom. */
204             velecsum         = _mm_add_pd(velecsum,velec);
205
206             fscal            = felec;
207
208             /* Calculate temporary vectorial force */
209             tx               = _mm_mul_pd(fscal,dx00);
210             ty               = _mm_mul_pd(fscal,dy00);
211             tz               = _mm_mul_pd(fscal,dz00);
212
213             /* Update vectorial force */
214             fix0             = _mm_add_pd(fix0,tx);
215             fiy0             = _mm_add_pd(fiy0,ty);
216             fiz0             = _mm_add_pd(fiz0,tz);
217
218             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
219
220             /* Inner loop uses 41 flops */
221         }
222
223         if(jidx<j_index_end)
224         {
225
226             jnrA             = jjnr[jidx];
227             j_coord_offsetA  = DIM*jnrA;
228
229             /* load j atom coordinates */
230             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
231                                               &jx0,&jy0,&jz0);
232
233             /* Calculate displacement vector */
234             dx00             = _mm_sub_pd(ix0,jx0);
235             dy00             = _mm_sub_pd(iy0,jy0);
236             dz00             = _mm_sub_pd(iz0,jz0);
237
238             /* Calculate squared distance and things based on it */
239             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
240
241             rinv00           = sse2_invsqrt_d(rsq00);
242
243             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
244
245             /* Load parameters for j particles */
246             jq0              = _mm_load_sd(charge+jnrA+0);
247
248             /**************************
249              * CALCULATE INTERACTIONS *
250              **************************/
251
252             r00              = _mm_mul_pd(rsq00,rinv00);
253
254             /* Compute parameters for interactions between i and j atoms */
255             qq00             = _mm_mul_pd(iq0,jq0);
256
257             /* EWALD ELECTROSTATICS */
258
259             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
260             ewrt             = _mm_mul_pd(r00,ewtabscale);
261             ewitab           = _mm_cvttpd_epi32(ewrt);
262             eweps            = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
263             ewitab           = _mm_slli_epi32(ewitab,2);
264             ewtabF           = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
265             ewtabD           = _mm_setzero_pd();
266             GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
267             ewtabV           = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
268             ewtabFn          = _mm_setzero_pd();
269             GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
270             felec            = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
271             velec            = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
272             velec            = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
273             felec            = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
274
275             /* Update potential sum for this i atom from the interaction with this j atom. */
276             velec            = _mm_unpacklo_pd(velec,_mm_setzero_pd());
277             velecsum         = _mm_add_pd(velecsum,velec);
278
279             fscal            = felec;
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 41 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
307         /* Increment number of inner iterations */
308         inneriter                  += j_index_end - j_index_start;
309
310         /* Outer loop uses 8 flops */
311     }
312
313     /* Increment number of outer iterations */
314     outeriter        += nri;
315
316     /* Update outer/inner flops */
317
318     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*41);
319 }
320 /*
321  * Gromacs nonbonded kernel:   nb_kernel_ElecEw_VdwNone_GeomP1P1_F_sse2_double
322  * Electrostatics interaction: Ewald
323  * VdW interaction:            None
324  * Geometry:                   Particle-Particle
325  * Calculate force/pot:        Force
326  */
327 void
328 nb_kernel_ElecEw_VdwNone_GeomP1P1_F_sse2_double
329                     (t_nblist                    * gmx_restrict       nlist,
330                      rvec                        * gmx_restrict          xx,
331                      rvec                        * gmx_restrict          ff,
332                      struct t_forcerec           * gmx_restrict          fr,
333                      t_mdatoms                   * gmx_restrict     mdatoms,
334                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
335                      t_nrnb                      * gmx_restrict        nrnb)
336 {
337     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
338      * just 0 for non-waters.
339      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
340      * jnr indices corresponding to data put in the four positions in the SIMD register.
341      */
342     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
343     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
344     int              jnrA,jnrB;
345     int              j_coord_offsetA,j_coord_offsetB;
346     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
347     real             rcutoff_scalar;
348     real             *shiftvec,*fshift,*x,*f;
349     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
350     int              vdwioffset0;
351     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
352     int              vdwjidx0A,vdwjidx0B;
353     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
354     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
355     __m128d          velec,felec,velecsum,facel,crf,krf,krf2;
356     real             *charge;
357     __m128i          ewitab;
358     __m128d          ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
359     real             *ewtab;
360     __m128d          dummy_mask,cutoff_mask;
361     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
362     __m128d          one     = _mm_set1_pd(1.0);
363     __m128d          two     = _mm_set1_pd(2.0);
364     x                = xx[0];
365     f                = ff[0];
366
367     nri              = nlist->nri;
368     iinr             = nlist->iinr;
369     jindex           = nlist->jindex;
370     jjnr             = nlist->jjnr;
371     shiftidx         = nlist->shift;
372     gid              = nlist->gid;
373     shiftvec         = fr->shift_vec[0];
374     fshift           = fr->fshift[0];
375     facel            = _mm_set1_pd(fr->ic->epsfac);
376     charge           = mdatoms->chargeA;
377
378     sh_ewald         = _mm_set1_pd(fr->ic->sh_ewald);
379     ewtab            = fr->ic->tabq_coul_F;
380     ewtabscale       = _mm_set1_pd(fr->ic->tabq_scale);
381     ewtabhalfspace   = _mm_set1_pd(0.5/fr->ic->tabq_scale);
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
415         /* Start inner kernel loop */
416         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
417         {
418
419             /* Get j neighbor index, and coordinate index */
420             jnrA             = jjnr[jidx];
421             jnrB             = jjnr[jidx+1];
422             j_coord_offsetA  = DIM*jnrA;
423             j_coord_offsetB  = DIM*jnrB;
424
425             /* load j atom coordinates */
426             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
427                                               &jx0,&jy0,&jz0);
428
429             /* Calculate displacement vector */
430             dx00             = _mm_sub_pd(ix0,jx0);
431             dy00             = _mm_sub_pd(iy0,jy0);
432             dz00             = _mm_sub_pd(iz0,jz0);
433
434             /* Calculate squared distance and things based on it */
435             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
436
437             rinv00           = sse2_invsqrt_d(rsq00);
438
439             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
440
441             /* Load parameters for j particles */
442             jq0              = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
443
444             /**************************
445              * CALCULATE INTERACTIONS *
446              **************************/
447
448             r00              = _mm_mul_pd(rsq00,rinv00);
449
450             /* Compute parameters for interactions between i and j atoms */
451             qq00             = _mm_mul_pd(iq0,jq0);
452
453             /* EWALD ELECTROSTATICS */
454
455             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
456             ewrt             = _mm_mul_pd(r00,ewtabscale);
457             ewitab           = _mm_cvttpd_epi32(ewrt);
458             eweps            = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
459             gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
460                                          &ewtabF,&ewtabFn);
461             felec            = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
462             felec            = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
463
464             fscal            = felec;
465
466             /* Calculate temporary vectorial force */
467             tx               = _mm_mul_pd(fscal,dx00);
468             ty               = _mm_mul_pd(fscal,dy00);
469             tz               = _mm_mul_pd(fscal,dz00);
470
471             /* Update vectorial force */
472             fix0             = _mm_add_pd(fix0,tx);
473             fiy0             = _mm_add_pd(fiy0,ty);
474             fiz0             = _mm_add_pd(fiz0,tz);
475
476             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
477
478             /* Inner loop uses 36 flops */
479         }
480
481         if(jidx<j_index_end)
482         {
483
484             jnrA             = jjnr[jidx];
485             j_coord_offsetA  = DIM*jnrA;
486
487             /* load j atom coordinates */
488             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
489                                               &jx0,&jy0,&jz0);
490
491             /* Calculate displacement vector */
492             dx00             = _mm_sub_pd(ix0,jx0);
493             dy00             = _mm_sub_pd(iy0,jy0);
494             dz00             = _mm_sub_pd(iz0,jz0);
495
496             /* Calculate squared distance and things based on it */
497             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
498
499             rinv00           = sse2_invsqrt_d(rsq00);
500
501             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
502
503             /* Load parameters for j particles */
504             jq0              = _mm_load_sd(charge+jnrA+0);
505
506             /**************************
507              * CALCULATE INTERACTIONS *
508              **************************/
509
510             r00              = _mm_mul_pd(rsq00,rinv00);
511
512             /* Compute parameters for interactions between i and j atoms */
513             qq00             = _mm_mul_pd(iq0,jq0);
514
515             /* EWALD ELECTROSTATICS */
516
517             /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
518             ewrt             = _mm_mul_pd(r00,ewtabscale);
519             ewitab           = _mm_cvttpd_epi32(ewrt);
520             eweps            = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
521             gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
522             felec            = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
523             felec            = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
524
525             fscal            = felec;
526
527             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
528
529             /* Calculate temporary vectorial force */
530             tx               = _mm_mul_pd(fscal,dx00);
531             ty               = _mm_mul_pd(fscal,dy00);
532             tz               = _mm_mul_pd(fscal,dz00);
533
534             /* Update vectorial force */
535             fix0             = _mm_add_pd(fix0,tx);
536             fiy0             = _mm_add_pd(fiy0,ty);
537             fiz0             = _mm_add_pd(fiz0,tz);
538
539             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
540
541             /* Inner loop uses 36 flops */
542         }
543
544         /* End of innermost loop */
545
546         gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
547                                               f+i_coord_offset,fshift+i_shift_offset);
548
549         /* Increment number of inner iterations */
550         inneriter                  += j_index_end - j_index_start;
551
552         /* Outer loop uses 7 flops */
553     }
554
555     /* Increment number of outer iterations */
556     outeriter        += nri;
557
558     /* Update outer/inner flops */
559
560     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*36);
561 }