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