1ba53ce4761562a6d80a6ba29ccbe5b5461938e8
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecCoul_VdwNone_GeomP1P1_avx_128_fma_single.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 avx_128_fma_single 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_avx_128_fma_single.h"
48 #include "kernelutil_x86_avx_128_fma_single.h"
49
50 /*
51  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomP1P1_VF_avx_128_fma_single
52  * Electrostatics interaction: Coulomb
53  * VdW interaction:            None
54  * Geometry:                   Particle-Particle
55  * Calculate force/pot:        PotentialAndForce
56  */
57 void
58 nb_kernel_ElecCoul_VdwNone_GeomP1P1_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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,jnrC,jnrD;
75     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
76     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81     real             scratch[4*DIM];
82     __m128           fscal,rcutoff,rcutoff2,jidxall;
83     int              vdwioffset0;
84     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
86     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
89     real             *charge;
90     __m128           dummy_mask,cutoff_mask;
91     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
92     __m128           one     = _mm_set1_ps(1.0);
93     __m128           two     = _mm_set1_ps(2.0);
94     x                = xx[0];
95     f                = ff[0];
96
97     nri              = nlist->nri;
98     iinr             = nlist->iinr;
99     jindex           = nlist->jindex;
100     jjnr             = nlist->jjnr;
101     shiftidx         = nlist->shift;
102     gid              = nlist->gid;
103     shiftvec         = fr->shift_vec[0];
104     fshift           = fr->fshift[0];
105     facel            = _mm_set1_ps(fr->epsfac);
106     charge           = mdatoms->chargeA;
107
108     /* Avoid stupid compiler warnings */
109     jnrA = jnrB = jnrC = jnrD = 0;
110     j_coord_offsetA = 0;
111     j_coord_offsetB = 0;
112     j_coord_offsetC = 0;
113     j_coord_offsetD = 0;
114
115     outeriter        = 0;
116     inneriter        = 0;
117
118     for(iidx=0;iidx<4*DIM;iidx++)
119     {
120         scratch[iidx] = 0.0;
121     }
122
123     /* Start outer loop over neighborlists */
124     for(iidx=0; iidx<nri; iidx++)
125     {
126         /* Load shift vector for this list */
127         i_shift_offset   = DIM*shiftidx[iidx];
128
129         /* Load limits for loop over neighbors */
130         j_index_start    = jindex[iidx];
131         j_index_end      = jindex[iidx+1];
132
133         /* Get outer coordinate index */
134         inr              = iinr[iidx];
135         i_coord_offset   = DIM*inr;
136
137         /* Load i particle coords and add shift vector */
138         gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
139
140         fix0             = _mm_setzero_ps();
141         fiy0             = _mm_setzero_ps();
142         fiz0             = _mm_setzero_ps();
143
144         /* Load parameters for i particles */
145         iq0              = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
146
147         /* Reset potential sums */
148         velecsum         = _mm_setzero_ps();
149
150         /* Start inner kernel loop */
151         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
152         {
153
154             /* Get j neighbor index, and coordinate index */
155             jnrA             = jjnr[jidx];
156             jnrB             = jjnr[jidx+1];
157             jnrC             = jjnr[jidx+2];
158             jnrD             = jjnr[jidx+3];
159             j_coord_offsetA  = DIM*jnrA;
160             j_coord_offsetB  = DIM*jnrB;
161             j_coord_offsetC  = DIM*jnrC;
162             j_coord_offsetD  = DIM*jnrD;
163
164             /* load j atom coordinates */
165             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
166                                               x+j_coord_offsetC,x+j_coord_offsetD,
167                                               &jx0,&jy0,&jz0);
168
169             /* Calculate displacement vector */
170             dx00             = _mm_sub_ps(ix0,jx0);
171             dy00             = _mm_sub_ps(iy0,jy0);
172             dz00             = _mm_sub_ps(iz0,jz0);
173
174             /* Calculate squared distance and things based on it */
175             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
176
177             rinv00           = gmx_mm_invsqrt_ps(rsq00);
178
179             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
180
181             /* Load parameters for j particles */
182             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
183                                                               charge+jnrC+0,charge+jnrD+0);
184
185             /**************************
186              * CALCULATE INTERACTIONS *
187              **************************/
188
189             /* Compute parameters for interactions between i and j atoms */
190             qq00             = _mm_mul_ps(iq0,jq0);
191
192             /* COULOMB ELECTROSTATICS */
193             velec            = _mm_mul_ps(qq00,rinv00);
194             felec            = _mm_mul_ps(velec,rinvsq00);
195
196             /* Update potential sum for this i atom from the interaction with this j atom. */
197             velecsum         = _mm_add_ps(velecsum,velec);
198
199             fscal            = felec;
200
201              /* Update vectorial force */
202             fix0             = _mm_macc_ps(dx00,fscal,fix0);
203             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
204             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
205
206             fjptrA             = f+j_coord_offsetA;
207             fjptrB             = f+j_coord_offsetB;
208             fjptrC             = f+j_coord_offsetC;
209             fjptrD             = f+j_coord_offsetD;
210             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
211                                                    _mm_mul_ps(dx00,fscal),
212                                                    _mm_mul_ps(dy00,fscal),
213                                                    _mm_mul_ps(dz00,fscal));
214
215             /* Inner loop uses 31 flops */
216         }
217
218         if(jidx<j_index_end)
219         {
220
221             /* Get j neighbor index, and coordinate index */
222             jnrlistA         = jjnr[jidx];
223             jnrlistB         = jjnr[jidx+1];
224             jnrlistC         = jjnr[jidx+2];
225             jnrlistD         = jjnr[jidx+3];
226             /* Sign of each element will be negative for non-real atoms.
227              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
228              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
229              */
230             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
231             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
232             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
233             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
234             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
235             j_coord_offsetA  = DIM*jnrA;
236             j_coord_offsetB  = DIM*jnrB;
237             j_coord_offsetC  = DIM*jnrC;
238             j_coord_offsetD  = DIM*jnrD;
239
240             /* load j atom coordinates */
241             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
242                                               x+j_coord_offsetC,x+j_coord_offsetD,
243                                               &jx0,&jy0,&jz0);
244
245             /* Calculate displacement vector */
246             dx00             = _mm_sub_ps(ix0,jx0);
247             dy00             = _mm_sub_ps(iy0,jy0);
248             dz00             = _mm_sub_ps(iz0,jz0);
249
250             /* Calculate squared distance and things based on it */
251             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
252
253             rinv00           = gmx_mm_invsqrt_ps(rsq00);
254
255             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
256
257             /* Load parameters for j particles */
258             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
259                                                               charge+jnrC+0,charge+jnrD+0);
260
261             /**************************
262              * CALCULATE INTERACTIONS *
263              **************************/
264
265             /* Compute parameters for interactions between i and j atoms */
266             qq00             = _mm_mul_ps(iq0,jq0);
267
268             /* COULOMB ELECTROSTATICS */
269             velec            = _mm_mul_ps(qq00,rinv00);
270             felec            = _mm_mul_ps(velec,rinvsq00);
271
272             /* Update potential sum for this i atom from the interaction with this j atom. */
273             velec            = _mm_andnot_ps(dummy_mask,velec);
274             velecsum         = _mm_add_ps(velecsum,velec);
275
276             fscal            = felec;
277
278             fscal            = _mm_andnot_ps(dummy_mask,fscal);
279
280              /* Update vectorial force */
281             fix0             = _mm_macc_ps(dx00,fscal,fix0);
282             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
283             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
284
285             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
286             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
287             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
288             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
289             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
290                                                    _mm_mul_ps(dx00,fscal),
291                                                    _mm_mul_ps(dy00,fscal),
292                                                    _mm_mul_ps(dz00,fscal));
293
294             /* Inner loop uses 31 flops */
295         }
296
297         /* End of innermost loop */
298
299         gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
300                                               f+i_coord_offset,fshift+i_shift_offset);
301
302         ggid                        = gid[iidx];
303         /* Update potential energies */
304         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
305
306         /* Increment number of inner iterations */
307         inneriter                  += j_index_end - j_index_start;
308
309         /* Outer loop uses 8 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_VF,outeriter*8 + inneriter*31);
318 }
319 /*
320  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_avx_128_fma_single
321  * Electrostatics interaction: Coulomb
322  * VdW interaction:            None
323  * Geometry:                   Particle-Particle
324  * Calculate force/pot:        Force
325  */
326 void
327 nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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,jnrC,jnrD;
344     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
345     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
346     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
347     real             rcutoff_scalar;
348     real             *shiftvec,*fshift,*x,*f;
349     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
350     real             scratch[4*DIM];
351     __m128           fscal,rcutoff,rcutoff2,jidxall;
352     int              vdwioffset0;
353     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
354     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
355     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
356     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
357     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
358     real             *charge;
359     __m128           dummy_mask,cutoff_mask;
360     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
361     __m128           one     = _mm_set1_ps(1.0);
362     __m128           two     = _mm_set1_ps(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_ps(fr->epsfac);
375     charge           = mdatoms->chargeA;
376
377     /* Avoid stupid compiler warnings */
378     jnrA = jnrB = jnrC = jnrD = 0;
379     j_coord_offsetA = 0;
380     j_coord_offsetB = 0;
381     j_coord_offsetC = 0;
382     j_coord_offsetD = 0;
383
384     outeriter        = 0;
385     inneriter        = 0;
386
387     for(iidx=0;iidx<4*DIM;iidx++)
388     {
389         scratch[iidx] = 0.0;
390     }
391
392     /* Start outer loop over neighborlists */
393     for(iidx=0; iidx<nri; iidx++)
394     {
395         /* Load shift vector for this list */
396         i_shift_offset   = DIM*shiftidx[iidx];
397
398         /* Load limits for loop over neighbors */
399         j_index_start    = jindex[iidx];
400         j_index_end      = jindex[iidx+1];
401
402         /* Get outer coordinate index */
403         inr              = iinr[iidx];
404         i_coord_offset   = DIM*inr;
405
406         /* Load i particle coords and add shift vector */
407         gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
408
409         fix0             = _mm_setzero_ps();
410         fiy0             = _mm_setzero_ps();
411         fiz0             = _mm_setzero_ps();
412
413         /* Load parameters for i particles */
414         iq0              = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
415
416         /* Start inner kernel loop */
417         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
418         {
419
420             /* Get j neighbor index, and coordinate index */
421             jnrA             = jjnr[jidx];
422             jnrB             = jjnr[jidx+1];
423             jnrC             = jjnr[jidx+2];
424             jnrD             = jjnr[jidx+3];
425             j_coord_offsetA  = DIM*jnrA;
426             j_coord_offsetB  = DIM*jnrB;
427             j_coord_offsetC  = DIM*jnrC;
428             j_coord_offsetD  = DIM*jnrD;
429
430             /* load j atom coordinates */
431             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
432                                               x+j_coord_offsetC,x+j_coord_offsetD,
433                                               &jx0,&jy0,&jz0);
434
435             /* Calculate displacement vector */
436             dx00             = _mm_sub_ps(ix0,jx0);
437             dy00             = _mm_sub_ps(iy0,jy0);
438             dz00             = _mm_sub_ps(iz0,jz0);
439
440             /* Calculate squared distance and things based on it */
441             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
442
443             rinv00           = gmx_mm_invsqrt_ps(rsq00);
444
445             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
446
447             /* Load parameters for j particles */
448             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
449                                                               charge+jnrC+0,charge+jnrD+0);
450
451             /**************************
452              * CALCULATE INTERACTIONS *
453              **************************/
454
455             /* Compute parameters for interactions between i and j atoms */
456             qq00             = _mm_mul_ps(iq0,jq0);
457
458             /* COULOMB ELECTROSTATICS */
459             velec            = _mm_mul_ps(qq00,rinv00);
460             felec            = _mm_mul_ps(velec,rinvsq00);
461
462             fscal            = felec;
463
464              /* Update vectorial force */
465             fix0             = _mm_macc_ps(dx00,fscal,fix0);
466             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
467             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
468
469             fjptrA             = f+j_coord_offsetA;
470             fjptrB             = f+j_coord_offsetB;
471             fjptrC             = f+j_coord_offsetC;
472             fjptrD             = f+j_coord_offsetD;
473             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
474                                                    _mm_mul_ps(dx00,fscal),
475                                                    _mm_mul_ps(dy00,fscal),
476                                                    _mm_mul_ps(dz00,fscal));
477
478             /* Inner loop uses 30 flops */
479         }
480
481         if(jidx<j_index_end)
482         {
483
484             /* Get j neighbor index, and coordinate index */
485             jnrlistA         = jjnr[jidx];
486             jnrlistB         = jjnr[jidx+1];
487             jnrlistC         = jjnr[jidx+2];
488             jnrlistD         = jjnr[jidx+3];
489             /* Sign of each element will be negative for non-real atoms.
490              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
491              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
492              */
493             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
494             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
495             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
496             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
497             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
498             j_coord_offsetA  = DIM*jnrA;
499             j_coord_offsetB  = DIM*jnrB;
500             j_coord_offsetC  = DIM*jnrC;
501             j_coord_offsetD  = DIM*jnrD;
502
503             /* load j atom coordinates */
504             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
505                                               x+j_coord_offsetC,x+j_coord_offsetD,
506                                               &jx0,&jy0,&jz0);
507
508             /* Calculate displacement vector */
509             dx00             = _mm_sub_ps(ix0,jx0);
510             dy00             = _mm_sub_ps(iy0,jy0);
511             dz00             = _mm_sub_ps(iz0,jz0);
512
513             /* Calculate squared distance and things based on it */
514             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
515
516             rinv00           = gmx_mm_invsqrt_ps(rsq00);
517
518             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
519
520             /* Load parameters for j particles */
521             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
522                                                               charge+jnrC+0,charge+jnrD+0);
523
524             /**************************
525              * CALCULATE INTERACTIONS *
526              **************************/
527
528             /* Compute parameters for interactions between i and j atoms */
529             qq00             = _mm_mul_ps(iq0,jq0);
530
531             /* COULOMB ELECTROSTATICS */
532             velec            = _mm_mul_ps(qq00,rinv00);
533             felec            = _mm_mul_ps(velec,rinvsq00);
534
535             fscal            = felec;
536
537             fscal            = _mm_andnot_ps(dummy_mask,fscal);
538
539              /* Update vectorial force */
540             fix0             = _mm_macc_ps(dx00,fscal,fix0);
541             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
542             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
543
544             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
545             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
546             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
547             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
548             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
549                                                    _mm_mul_ps(dx00,fscal),
550                                                    _mm_mul_ps(dy00,fscal),
551                                                    _mm_mul_ps(dz00,fscal));
552
553             /* Inner loop uses 30 flops */
554         }
555
556         /* End of innermost loop */
557
558         gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
559                                               f+i_coord_offset,fshift+i_shift_offset);
560
561         /* Increment number of inner iterations */
562         inneriter                  += j_index_end - j_index_start;
563
564         /* Outer loop uses 7 flops */
565     }
566
567     /* Increment number of outer iterations */
568     outeriter        += nri;
569
570     /* Update outer/inner flops */
571
572     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*30);
573 }