Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_single / nb_kernel_ElecRFCut_VdwNone_GeomW3P1_sse2_single.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_single 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_single.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwNone_GeomW3P1_VF_sse2_single
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            None
53  * Geometry:                   Water3-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_VF_sse2_single
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,C,D refer to j loop unrolling done with SSE, e.g. for the four 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,jnrC,jnrD;
74     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
77     real             rcutoff_scalar;
78     real             *shiftvec,*fshift,*x,*f;
79     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
80     real             scratch[4*DIM];
81     __m128           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
82     int              vdwioffset0;
83     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84     int              vdwioffset1;
85     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
86     int              vdwioffset2;
87     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
89     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     __m128           dummy_mask,cutoff_mask;
96     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
97     __m128           one     = _mm_set1_ps(1.0);
98     __m128           two     = _mm_set1_ps(2.0);
99     x                = xx[0];
100     f                = ff[0];
101
102     nri              = nlist->nri;
103     iinr             = nlist->iinr;
104     jindex           = nlist->jindex;
105     jjnr             = nlist->jjnr;
106     shiftidx         = nlist->shift;
107     gid              = nlist->gid;
108     shiftvec         = fr->shift_vec[0];
109     fshift           = fr->fshift[0];
110     facel            = _mm_set1_ps(fr->ic->epsfac);
111     charge           = mdatoms->chargeA;
112     krf              = _mm_set1_ps(fr->ic->k_rf);
113     krf2             = _mm_set1_ps(fr->ic->k_rf*2.0);
114     crf              = _mm_set1_ps(fr->ic->c_rf);
115
116     /* Setup water-specific parameters */
117     inr              = nlist->iinr[0];
118     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
119     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
120     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
121
122     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
123     rcutoff_scalar   = fr->ic->rcoulomb;
124     rcutoff          = _mm_set1_ps(rcutoff_scalar);
125     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
126
127     /* Avoid stupid compiler warnings */
128     jnrA = jnrB = jnrC = jnrD = 0;
129     j_coord_offsetA = 0;
130     j_coord_offsetB = 0;
131     j_coord_offsetC = 0;
132     j_coord_offsetD = 0;
133
134     outeriter        = 0;
135     inneriter        = 0;
136
137     for(iidx=0;iidx<4*DIM;iidx++)
138     {
139         scratch[iidx] = 0.0;
140     }  
141
142     /* Start outer loop over neighborlists */
143     for(iidx=0; iidx<nri; iidx++)
144     {
145         /* Load shift vector for this list */
146         i_shift_offset   = DIM*shiftidx[iidx];
147
148         /* Load limits for loop over neighbors */
149         j_index_start    = jindex[iidx];
150         j_index_end      = jindex[iidx+1];
151
152         /* Get outer coordinate index */
153         inr              = iinr[iidx];
154         i_coord_offset   = DIM*inr;
155
156         /* Load i particle coords and add shift vector */
157         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
158                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
159         
160         fix0             = _mm_setzero_ps();
161         fiy0             = _mm_setzero_ps();
162         fiz0             = _mm_setzero_ps();
163         fix1             = _mm_setzero_ps();
164         fiy1             = _mm_setzero_ps();
165         fiz1             = _mm_setzero_ps();
166         fix2             = _mm_setzero_ps();
167         fiy2             = _mm_setzero_ps();
168         fiz2             = _mm_setzero_ps();
169
170         /* Reset potential sums */
171         velecsum         = _mm_setzero_ps();
172
173         /* Start inner kernel loop */
174         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
175         {
176
177             /* Get j neighbor index, and coordinate index */
178             jnrA             = jjnr[jidx];
179             jnrB             = jjnr[jidx+1];
180             jnrC             = jjnr[jidx+2];
181             jnrD             = jjnr[jidx+3];
182             j_coord_offsetA  = DIM*jnrA;
183             j_coord_offsetB  = DIM*jnrB;
184             j_coord_offsetC  = DIM*jnrC;
185             j_coord_offsetD  = DIM*jnrD;
186
187             /* load j atom coordinates */
188             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
189                                               x+j_coord_offsetC,x+j_coord_offsetD,
190                                               &jx0,&jy0,&jz0);
191
192             /* Calculate displacement vector */
193             dx00             = _mm_sub_ps(ix0,jx0);
194             dy00             = _mm_sub_ps(iy0,jy0);
195             dz00             = _mm_sub_ps(iz0,jz0);
196             dx10             = _mm_sub_ps(ix1,jx0);
197             dy10             = _mm_sub_ps(iy1,jy0);
198             dz10             = _mm_sub_ps(iz1,jz0);
199             dx20             = _mm_sub_ps(ix2,jx0);
200             dy20             = _mm_sub_ps(iy2,jy0);
201             dz20             = _mm_sub_ps(iz2,jz0);
202
203             /* Calculate squared distance and things based on it */
204             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
205             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
206             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
207
208             rinv00           = sse2_invsqrt_f(rsq00);
209             rinv10           = sse2_invsqrt_f(rsq10);
210             rinv20           = sse2_invsqrt_f(rsq20);
211
212             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
213             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
214             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
215
216             /* Load parameters for j particles */
217             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
218                                                               charge+jnrC+0,charge+jnrD+0);
219
220             fjx0             = _mm_setzero_ps();
221             fjy0             = _mm_setzero_ps();
222             fjz0             = _mm_setzero_ps();
223
224             /**************************
225              * CALCULATE INTERACTIONS *
226              **************************/
227
228             if (gmx_mm_any_lt(rsq00,rcutoff2))
229             {
230
231             /* Compute parameters for interactions between i and j atoms */
232             qq00             = _mm_mul_ps(iq0,jq0);
233
234             /* REACTION-FIELD ELECTROSTATICS */
235             velec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_add_ps(rinv00,_mm_mul_ps(krf,rsq00)),crf));
236             felec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
237
238             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
239
240             /* Update potential sum for this i atom from the interaction with this j atom. */
241             velec            = _mm_and_ps(velec,cutoff_mask);
242             velecsum         = _mm_add_ps(velecsum,velec);
243
244             fscal            = felec;
245
246             fscal            = _mm_and_ps(fscal,cutoff_mask);
247
248             /* Calculate temporary vectorial force */
249             tx               = _mm_mul_ps(fscal,dx00);
250             ty               = _mm_mul_ps(fscal,dy00);
251             tz               = _mm_mul_ps(fscal,dz00);
252
253             /* Update vectorial force */
254             fix0             = _mm_add_ps(fix0,tx);
255             fiy0             = _mm_add_ps(fiy0,ty);
256             fiz0             = _mm_add_ps(fiz0,tz);
257
258             fjx0             = _mm_add_ps(fjx0,tx);
259             fjy0             = _mm_add_ps(fjy0,ty);
260             fjz0             = _mm_add_ps(fjz0,tz);
261             
262             }
263
264             /**************************
265              * CALCULATE INTERACTIONS *
266              **************************/
267
268             if (gmx_mm_any_lt(rsq10,rcutoff2))
269             {
270
271             /* Compute parameters for interactions between i and j atoms */
272             qq10             = _mm_mul_ps(iq1,jq0);
273
274             /* REACTION-FIELD ELECTROSTATICS */
275             velec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_add_ps(rinv10,_mm_mul_ps(krf,rsq10)),crf));
276             felec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
277
278             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
279
280             /* Update potential sum for this i atom from the interaction with this j atom. */
281             velec            = _mm_and_ps(velec,cutoff_mask);
282             velecsum         = _mm_add_ps(velecsum,velec);
283
284             fscal            = felec;
285
286             fscal            = _mm_and_ps(fscal,cutoff_mask);
287
288             /* Calculate temporary vectorial force */
289             tx               = _mm_mul_ps(fscal,dx10);
290             ty               = _mm_mul_ps(fscal,dy10);
291             tz               = _mm_mul_ps(fscal,dz10);
292
293             /* Update vectorial force */
294             fix1             = _mm_add_ps(fix1,tx);
295             fiy1             = _mm_add_ps(fiy1,ty);
296             fiz1             = _mm_add_ps(fiz1,tz);
297
298             fjx0             = _mm_add_ps(fjx0,tx);
299             fjy0             = _mm_add_ps(fjy0,ty);
300             fjz0             = _mm_add_ps(fjz0,tz);
301             
302             }
303
304             /**************************
305              * CALCULATE INTERACTIONS *
306              **************************/
307
308             if (gmx_mm_any_lt(rsq20,rcutoff2))
309             {
310
311             /* Compute parameters for interactions between i and j atoms */
312             qq20             = _mm_mul_ps(iq2,jq0);
313
314             /* REACTION-FIELD ELECTROSTATICS */
315             velec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_add_ps(rinv20,_mm_mul_ps(krf,rsq20)),crf));
316             felec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
317
318             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
319
320             /* Update potential sum for this i atom from the interaction with this j atom. */
321             velec            = _mm_and_ps(velec,cutoff_mask);
322             velecsum         = _mm_add_ps(velecsum,velec);
323
324             fscal            = felec;
325
326             fscal            = _mm_and_ps(fscal,cutoff_mask);
327
328             /* Calculate temporary vectorial force */
329             tx               = _mm_mul_ps(fscal,dx20);
330             ty               = _mm_mul_ps(fscal,dy20);
331             tz               = _mm_mul_ps(fscal,dz20);
332
333             /* Update vectorial force */
334             fix2             = _mm_add_ps(fix2,tx);
335             fiy2             = _mm_add_ps(fiy2,ty);
336             fiz2             = _mm_add_ps(fiz2,tz);
337
338             fjx0             = _mm_add_ps(fjx0,tx);
339             fjy0             = _mm_add_ps(fjy0,ty);
340             fjz0             = _mm_add_ps(fjz0,tz);
341             
342             }
343
344             fjptrA             = f+j_coord_offsetA;
345             fjptrB             = f+j_coord_offsetB;
346             fjptrC             = f+j_coord_offsetC;
347             fjptrD             = f+j_coord_offsetD;
348
349             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
350
351             /* Inner loop uses 108 flops */
352         }
353
354         if(jidx<j_index_end)
355         {
356
357             /* Get j neighbor index, and coordinate index */
358             jnrlistA         = jjnr[jidx];
359             jnrlistB         = jjnr[jidx+1];
360             jnrlistC         = jjnr[jidx+2];
361             jnrlistD         = jjnr[jidx+3];
362             /* Sign of each element will be negative for non-real atoms.
363              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
364              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
365              */
366             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
367             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
368             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
369             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
370             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
371             j_coord_offsetA  = DIM*jnrA;
372             j_coord_offsetB  = DIM*jnrB;
373             j_coord_offsetC  = DIM*jnrC;
374             j_coord_offsetD  = DIM*jnrD;
375
376             /* load j atom coordinates */
377             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
378                                               x+j_coord_offsetC,x+j_coord_offsetD,
379                                               &jx0,&jy0,&jz0);
380
381             /* Calculate displacement vector */
382             dx00             = _mm_sub_ps(ix0,jx0);
383             dy00             = _mm_sub_ps(iy0,jy0);
384             dz00             = _mm_sub_ps(iz0,jz0);
385             dx10             = _mm_sub_ps(ix1,jx0);
386             dy10             = _mm_sub_ps(iy1,jy0);
387             dz10             = _mm_sub_ps(iz1,jz0);
388             dx20             = _mm_sub_ps(ix2,jx0);
389             dy20             = _mm_sub_ps(iy2,jy0);
390             dz20             = _mm_sub_ps(iz2,jz0);
391
392             /* Calculate squared distance and things based on it */
393             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
394             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
395             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
396
397             rinv00           = sse2_invsqrt_f(rsq00);
398             rinv10           = sse2_invsqrt_f(rsq10);
399             rinv20           = sse2_invsqrt_f(rsq20);
400
401             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
402             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
403             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
404
405             /* Load parameters for j particles */
406             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
407                                                               charge+jnrC+0,charge+jnrD+0);
408
409             fjx0             = _mm_setzero_ps();
410             fjy0             = _mm_setzero_ps();
411             fjz0             = _mm_setzero_ps();
412
413             /**************************
414              * CALCULATE INTERACTIONS *
415              **************************/
416
417             if (gmx_mm_any_lt(rsq00,rcutoff2))
418             {
419
420             /* Compute parameters for interactions between i and j atoms */
421             qq00             = _mm_mul_ps(iq0,jq0);
422
423             /* REACTION-FIELD ELECTROSTATICS */
424             velec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_add_ps(rinv00,_mm_mul_ps(krf,rsq00)),crf));
425             felec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
426
427             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
428
429             /* Update potential sum for this i atom from the interaction with this j atom. */
430             velec            = _mm_and_ps(velec,cutoff_mask);
431             velec            = _mm_andnot_ps(dummy_mask,velec);
432             velecsum         = _mm_add_ps(velecsum,velec);
433
434             fscal            = felec;
435
436             fscal            = _mm_and_ps(fscal,cutoff_mask);
437
438             fscal            = _mm_andnot_ps(dummy_mask,fscal);
439
440             /* Calculate temporary vectorial force */
441             tx               = _mm_mul_ps(fscal,dx00);
442             ty               = _mm_mul_ps(fscal,dy00);
443             tz               = _mm_mul_ps(fscal,dz00);
444
445             /* Update vectorial force */
446             fix0             = _mm_add_ps(fix0,tx);
447             fiy0             = _mm_add_ps(fiy0,ty);
448             fiz0             = _mm_add_ps(fiz0,tz);
449
450             fjx0             = _mm_add_ps(fjx0,tx);
451             fjy0             = _mm_add_ps(fjy0,ty);
452             fjz0             = _mm_add_ps(fjz0,tz);
453             
454             }
455
456             /**************************
457              * CALCULATE INTERACTIONS *
458              **************************/
459
460             if (gmx_mm_any_lt(rsq10,rcutoff2))
461             {
462
463             /* Compute parameters for interactions between i and j atoms */
464             qq10             = _mm_mul_ps(iq1,jq0);
465
466             /* REACTION-FIELD ELECTROSTATICS */
467             velec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_add_ps(rinv10,_mm_mul_ps(krf,rsq10)),crf));
468             felec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
469
470             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
471
472             /* Update potential sum for this i atom from the interaction with this j atom. */
473             velec            = _mm_and_ps(velec,cutoff_mask);
474             velec            = _mm_andnot_ps(dummy_mask,velec);
475             velecsum         = _mm_add_ps(velecsum,velec);
476
477             fscal            = felec;
478
479             fscal            = _mm_and_ps(fscal,cutoff_mask);
480
481             fscal            = _mm_andnot_ps(dummy_mask,fscal);
482
483             /* Calculate temporary vectorial force */
484             tx               = _mm_mul_ps(fscal,dx10);
485             ty               = _mm_mul_ps(fscal,dy10);
486             tz               = _mm_mul_ps(fscal,dz10);
487
488             /* Update vectorial force */
489             fix1             = _mm_add_ps(fix1,tx);
490             fiy1             = _mm_add_ps(fiy1,ty);
491             fiz1             = _mm_add_ps(fiz1,tz);
492
493             fjx0             = _mm_add_ps(fjx0,tx);
494             fjy0             = _mm_add_ps(fjy0,ty);
495             fjz0             = _mm_add_ps(fjz0,tz);
496             
497             }
498
499             /**************************
500              * CALCULATE INTERACTIONS *
501              **************************/
502
503             if (gmx_mm_any_lt(rsq20,rcutoff2))
504             {
505
506             /* Compute parameters for interactions between i and j atoms */
507             qq20             = _mm_mul_ps(iq2,jq0);
508
509             /* REACTION-FIELD ELECTROSTATICS */
510             velec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_add_ps(rinv20,_mm_mul_ps(krf,rsq20)),crf));
511             felec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
512
513             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
514
515             /* Update potential sum for this i atom from the interaction with this j atom. */
516             velec            = _mm_and_ps(velec,cutoff_mask);
517             velec            = _mm_andnot_ps(dummy_mask,velec);
518             velecsum         = _mm_add_ps(velecsum,velec);
519
520             fscal            = felec;
521
522             fscal            = _mm_and_ps(fscal,cutoff_mask);
523
524             fscal            = _mm_andnot_ps(dummy_mask,fscal);
525
526             /* Calculate temporary vectorial force */
527             tx               = _mm_mul_ps(fscal,dx20);
528             ty               = _mm_mul_ps(fscal,dy20);
529             tz               = _mm_mul_ps(fscal,dz20);
530
531             /* Update vectorial force */
532             fix2             = _mm_add_ps(fix2,tx);
533             fiy2             = _mm_add_ps(fiy2,ty);
534             fiz2             = _mm_add_ps(fiz2,tz);
535
536             fjx0             = _mm_add_ps(fjx0,tx);
537             fjy0             = _mm_add_ps(fjy0,ty);
538             fjz0             = _mm_add_ps(fjz0,tz);
539             
540             }
541
542             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
543             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
544             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
545             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
546
547             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
548
549             /* Inner loop uses 108 flops */
550         }
551
552         /* End of innermost loop */
553
554         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
555                                               f+i_coord_offset,fshift+i_shift_offset);
556
557         ggid                        = gid[iidx];
558         /* Update potential energies */
559         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
560
561         /* Increment number of inner iterations */
562         inneriter                  += j_index_end - j_index_start;
563
564         /* Outer loop uses 19 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_W3_VF,outeriter*19 + inneriter*108);
573 }
574 /*
575  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_sse2_single
576  * Electrostatics interaction: ReactionField
577  * VdW interaction:            None
578  * Geometry:                   Water3-Particle
579  * Calculate force/pot:        Force
580  */
581 void
582 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_sse2_single
583                     (t_nblist                    * gmx_restrict       nlist,
584                      rvec                        * gmx_restrict          xx,
585                      rvec                        * gmx_restrict          ff,
586                      struct t_forcerec           * gmx_restrict          fr,
587                      t_mdatoms                   * gmx_restrict     mdatoms,
588                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
589                      t_nrnb                      * gmx_restrict        nrnb)
590 {
591     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or 
592      * just 0 for non-waters.
593      * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
594      * jnr indices corresponding to data put in the four positions in the SIMD register.
595      */
596     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
597     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
598     int              jnrA,jnrB,jnrC,jnrD;
599     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
600     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
601     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
602     real             rcutoff_scalar;
603     real             *shiftvec,*fshift,*x,*f;
604     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
605     real             scratch[4*DIM];
606     __m128           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
607     int              vdwioffset0;
608     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
609     int              vdwioffset1;
610     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
611     int              vdwioffset2;
612     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
613     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
614     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
615     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
616     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
617     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
618     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
619     real             *charge;
620     __m128           dummy_mask,cutoff_mask;
621     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
622     __m128           one     = _mm_set1_ps(1.0);
623     __m128           two     = _mm_set1_ps(2.0);
624     x                = xx[0];
625     f                = ff[0];
626
627     nri              = nlist->nri;
628     iinr             = nlist->iinr;
629     jindex           = nlist->jindex;
630     jjnr             = nlist->jjnr;
631     shiftidx         = nlist->shift;
632     gid              = nlist->gid;
633     shiftvec         = fr->shift_vec[0];
634     fshift           = fr->fshift[0];
635     facel            = _mm_set1_ps(fr->ic->epsfac);
636     charge           = mdatoms->chargeA;
637     krf              = _mm_set1_ps(fr->ic->k_rf);
638     krf2             = _mm_set1_ps(fr->ic->k_rf*2.0);
639     crf              = _mm_set1_ps(fr->ic->c_rf);
640
641     /* Setup water-specific parameters */
642     inr              = nlist->iinr[0];
643     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
644     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
645     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
646
647     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
648     rcutoff_scalar   = fr->ic->rcoulomb;
649     rcutoff          = _mm_set1_ps(rcutoff_scalar);
650     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
651
652     /* Avoid stupid compiler warnings */
653     jnrA = jnrB = jnrC = jnrD = 0;
654     j_coord_offsetA = 0;
655     j_coord_offsetB = 0;
656     j_coord_offsetC = 0;
657     j_coord_offsetD = 0;
658
659     outeriter        = 0;
660     inneriter        = 0;
661
662     for(iidx=0;iidx<4*DIM;iidx++)
663     {
664         scratch[iidx] = 0.0;
665     }  
666
667     /* Start outer loop over neighborlists */
668     for(iidx=0; iidx<nri; iidx++)
669     {
670         /* Load shift vector for this list */
671         i_shift_offset   = DIM*shiftidx[iidx];
672
673         /* Load limits for loop over neighbors */
674         j_index_start    = jindex[iidx];
675         j_index_end      = jindex[iidx+1];
676
677         /* Get outer coordinate index */
678         inr              = iinr[iidx];
679         i_coord_offset   = DIM*inr;
680
681         /* Load i particle coords and add shift vector */
682         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
683                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
684         
685         fix0             = _mm_setzero_ps();
686         fiy0             = _mm_setzero_ps();
687         fiz0             = _mm_setzero_ps();
688         fix1             = _mm_setzero_ps();
689         fiy1             = _mm_setzero_ps();
690         fiz1             = _mm_setzero_ps();
691         fix2             = _mm_setzero_ps();
692         fiy2             = _mm_setzero_ps();
693         fiz2             = _mm_setzero_ps();
694
695         /* Start inner kernel loop */
696         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
697         {
698
699             /* Get j neighbor index, and coordinate index */
700             jnrA             = jjnr[jidx];
701             jnrB             = jjnr[jidx+1];
702             jnrC             = jjnr[jidx+2];
703             jnrD             = jjnr[jidx+3];
704             j_coord_offsetA  = DIM*jnrA;
705             j_coord_offsetB  = DIM*jnrB;
706             j_coord_offsetC  = DIM*jnrC;
707             j_coord_offsetD  = DIM*jnrD;
708
709             /* load j atom coordinates */
710             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
711                                               x+j_coord_offsetC,x+j_coord_offsetD,
712                                               &jx0,&jy0,&jz0);
713
714             /* Calculate displacement vector */
715             dx00             = _mm_sub_ps(ix0,jx0);
716             dy00             = _mm_sub_ps(iy0,jy0);
717             dz00             = _mm_sub_ps(iz0,jz0);
718             dx10             = _mm_sub_ps(ix1,jx0);
719             dy10             = _mm_sub_ps(iy1,jy0);
720             dz10             = _mm_sub_ps(iz1,jz0);
721             dx20             = _mm_sub_ps(ix2,jx0);
722             dy20             = _mm_sub_ps(iy2,jy0);
723             dz20             = _mm_sub_ps(iz2,jz0);
724
725             /* Calculate squared distance and things based on it */
726             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
727             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
728             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
729
730             rinv00           = sse2_invsqrt_f(rsq00);
731             rinv10           = sse2_invsqrt_f(rsq10);
732             rinv20           = sse2_invsqrt_f(rsq20);
733
734             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
735             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
736             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
737
738             /* Load parameters for j particles */
739             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
740                                                               charge+jnrC+0,charge+jnrD+0);
741
742             fjx0             = _mm_setzero_ps();
743             fjy0             = _mm_setzero_ps();
744             fjz0             = _mm_setzero_ps();
745
746             /**************************
747              * CALCULATE INTERACTIONS *
748              **************************/
749
750             if (gmx_mm_any_lt(rsq00,rcutoff2))
751             {
752
753             /* Compute parameters for interactions between i and j atoms */
754             qq00             = _mm_mul_ps(iq0,jq0);
755
756             /* REACTION-FIELD ELECTROSTATICS */
757             felec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
758
759             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
760
761             fscal            = felec;
762
763             fscal            = _mm_and_ps(fscal,cutoff_mask);
764
765             /* Calculate temporary vectorial force */
766             tx               = _mm_mul_ps(fscal,dx00);
767             ty               = _mm_mul_ps(fscal,dy00);
768             tz               = _mm_mul_ps(fscal,dz00);
769
770             /* Update vectorial force */
771             fix0             = _mm_add_ps(fix0,tx);
772             fiy0             = _mm_add_ps(fiy0,ty);
773             fiz0             = _mm_add_ps(fiz0,tz);
774
775             fjx0             = _mm_add_ps(fjx0,tx);
776             fjy0             = _mm_add_ps(fjy0,ty);
777             fjz0             = _mm_add_ps(fjz0,tz);
778             
779             }
780
781             /**************************
782              * CALCULATE INTERACTIONS *
783              **************************/
784
785             if (gmx_mm_any_lt(rsq10,rcutoff2))
786             {
787
788             /* Compute parameters for interactions between i and j atoms */
789             qq10             = _mm_mul_ps(iq1,jq0);
790
791             /* REACTION-FIELD ELECTROSTATICS */
792             felec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
793
794             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
795
796             fscal            = felec;
797
798             fscal            = _mm_and_ps(fscal,cutoff_mask);
799
800             /* Calculate temporary vectorial force */
801             tx               = _mm_mul_ps(fscal,dx10);
802             ty               = _mm_mul_ps(fscal,dy10);
803             tz               = _mm_mul_ps(fscal,dz10);
804
805             /* Update vectorial force */
806             fix1             = _mm_add_ps(fix1,tx);
807             fiy1             = _mm_add_ps(fiy1,ty);
808             fiz1             = _mm_add_ps(fiz1,tz);
809
810             fjx0             = _mm_add_ps(fjx0,tx);
811             fjy0             = _mm_add_ps(fjy0,ty);
812             fjz0             = _mm_add_ps(fjz0,tz);
813             
814             }
815
816             /**************************
817              * CALCULATE INTERACTIONS *
818              **************************/
819
820             if (gmx_mm_any_lt(rsq20,rcutoff2))
821             {
822
823             /* Compute parameters for interactions between i and j atoms */
824             qq20             = _mm_mul_ps(iq2,jq0);
825
826             /* REACTION-FIELD ELECTROSTATICS */
827             felec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
828
829             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
830
831             fscal            = felec;
832
833             fscal            = _mm_and_ps(fscal,cutoff_mask);
834
835             /* Calculate temporary vectorial force */
836             tx               = _mm_mul_ps(fscal,dx20);
837             ty               = _mm_mul_ps(fscal,dy20);
838             tz               = _mm_mul_ps(fscal,dz20);
839
840             /* Update vectorial force */
841             fix2             = _mm_add_ps(fix2,tx);
842             fiy2             = _mm_add_ps(fiy2,ty);
843             fiz2             = _mm_add_ps(fiz2,tz);
844
845             fjx0             = _mm_add_ps(fjx0,tx);
846             fjy0             = _mm_add_ps(fjy0,ty);
847             fjz0             = _mm_add_ps(fjz0,tz);
848             
849             }
850
851             fjptrA             = f+j_coord_offsetA;
852             fjptrB             = f+j_coord_offsetB;
853             fjptrC             = f+j_coord_offsetC;
854             fjptrD             = f+j_coord_offsetD;
855
856             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
857
858             /* Inner loop uses 90 flops */
859         }
860
861         if(jidx<j_index_end)
862         {
863
864             /* Get j neighbor index, and coordinate index */
865             jnrlistA         = jjnr[jidx];
866             jnrlistB         = jjnr[jidx+1];
867             jnrlistC         = jjnr[jidx+2];
868             jnrlistD         = jjnr[jidx+3];
869             /* Sign of each element will be negative for non-real atoms.
870              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
871              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
872              */
873             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
874             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
875             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
876             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
877             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
878             j_coord_offsetA  = DIM*jnrA;
879             j_coord_offsetB  = DIM*jnrB;
880             j_coord_offsetC  = DIM*jnrC;
881             j_coord_offsetD  = DIM*jnrD;
882
883             /* load j atom coordinates */
884             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
885                                               x+j_coord_offsetC,x+j_coord_offsetD,
886                                               &jx0,&jy0,&jz0);
887
888             /* Calculate displacement vector */
889             dx00             = _mm_sub_ps(ix0,jx0);
890             dy00             = _mm_sub_ps(iy0,jy0);
891             dz00             = _mm_sub_ps(iz0,jz0);
892             dx10             = _mm_sub_ps(ix1,jx0);
893             dy10             = _mm_sub_ps(iy1,jy0);
894             dz10             = _mm_sub_ps(iz1,jz0);
895             dx20             = _mm_sub_ps(ix2,jx0);
896             dy20             = _mm_sub_ps(iy2,jy0);
897             dz20             = _mm_sub_ps(iz2,jz0);
898
899             /* Calculate squared distance and things based on it */
900             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
901             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
902             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
903
904             rinv00           = sse2_invsqrt_f(rsq00);
905             rinv10           = sse2_invsqrt_f(rsq10);
906             rinv20           = sse2_invsqrt_f(rsq20);
907
908             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
909             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
910             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
911
912             /* Load parameters for j particles */
913             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
914                                                               charge+jnrC+0,charge+jnrD+0);
915
916             fjx0             = _mm_setzero_ps();
917             fjy0             = _mm_setzero_ps();
918             fjz0             = _mm_setzero_ps();
919
920             /**************************
921              * CALCULATE INTERACTIONS *
922              **************************/
923
924             if (gmx_mm_any_lt(rsq00,rcutoff2))
925             {
926
927             /* Compute parameters for interactions between i and j atoms */
928             qq00             = _mm_mul_ps(iq0,jq0);
929
930             /* REACTION-FIELD ELECTROSTATICS */
931             felec            = _mm_mul_ps(qq00,_mm_sub_ps(_mm_mul_ps(rinv00,rinvsq00),krf2));
932
933             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
934
935             fscal            = felec;
936
937             fscal            = _mm_and_ps(fscal,cutoff_mask);
938
939             fscal            = _mm_andnot_ps(dummy_mask,fscal);
940
941             /* Calculate temporary vectorial force */
942             tx               = _mm_mul_ps(fscal,dx00);
943             ty               = _mm_mul_ps(fscal,dy00);
944             tz               = _mm_mul_ps(fscal,dz00);
945
946             /* Update vectorial force */
947             fix0             = _mm_add_ps(fix0,tx);
948             fiy0             = _mm_add_ps(fiy0,ty);
949             fiz0             = _mm_add_ps(fiz0,tz);
950
951             fjx0             = _mm_add_ps(fjx0,tx);
952             fjy0             = _mm_add_ps(fjy0,ty);
953             fjz0             = _mm_add_ps(fjz0,tz);
954             
955             }
956
957             /**************************
958              * CALCULATE INTERACTIONS *
959              **************************/
960
961             if (gmx_mm_any_lt(rsq10,rcutoff2))
962             {
963
964             /* Compute parameters for interactions between i and j atoms */
965             qq10             = _mm_mul_ps(iq1,jq0);
966
967             /* REACTION-FIELD ELECTROSTATICS */
968             felec            = _mm_mul_ps(qq10,_mm_sub_ps(_mm_mul_ps(rinv10,rinvsq10),krf2));
969
970             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
971
972             fscal            = felec;
973
974             fscal            = _mm_and_ps(fscal,cutoff_mask);
975
976             fscal            = _mm_andnot_ps(dummy_mask,fscal);
977
978             /* Calculate temporary vectorial force */
979             tx               = _mm_mul_ps(fscal,dx10);
980             ty               = _mm_mul_ps(fscal,dy10);
981             tz               = _mm_mul_ps(fscal,dz10);
982
983             /* Update vectorial force */
984             fix1             = _mm_add_ps(fix1,tx);
985             fiy1             = _mm_add_ps(fiy1,ty);
986             fiz1             = _mm_add_ps(fiz1,tz);
987
988             fjx0             = _mm_add_ps(fjx0,tx);
989             fjy0             = _mm_add_ps(fjy0,ty);
990             fjz0             = _mm_add_ps(fjz0,tz);
991             
992             }
993
994             /**************************
995              * CALCULATE INTERACTIONS *
996              **************************/
997
998             if (gmx_mm_any_lt(rsq20,rcutoff2))
999             {
1000
1001             /* Compute parameters for interactions between i and j atoms */
1002             qq20             = _mm_mul_ps(iq2,jq0);
1003
1004             /* REACTION-FIELD ELECTROSTATICS */
1005             felec            = _mm_mul_ps(qq20,_mm_sub_ps(_mm_mul_ps(rinv20,rinvsq20),krf2));
1006
1007             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
1008
1009             fscal            = felec;
1010
1011             fscal            = _mm_and_ps(fscal,cutoff_mask);
1012
1013             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1014
1015             /* Calculate temporary vectorial force */
1016             tx               = _mm_mul_ps(fscal,dx20);
1017             ty               = _mm_mul_ps(fscal,dy20);
1018             tz               = _mm_mul_ps(fscal,dz20);
1019
1020             /* Update vectorial force */
1021             fix2             = _mm_add_ps(fix2,tx);
1022             fiy2             = _mm_add_ps(fiy2,ty);
1023             fiz2             = _mm_add_ps(fiz2,tz);
1024
1025             fjx0             = _mm_add_ps(fjx0,tx);
1026             fjy0             = _mm_add_ps(fjy0,ty);
1027             fjz0             = _mm_add_ps(fjz0,tz);
1028             
1029             }
1030
1031             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1032             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1033             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1034             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1035
1036             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1037
1038             /* Inner loop uses 90 flops */
1039         }
1040
1041         /* End of innermost loop */
1042
1043         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1044                                               f+i_coord_offset,fshift+i_shift_offset);
1045
1046         /* Increment number of inner iterations */
1047         inneriter                  += j_index_end - j_index_start;
1048
1049         /* Outer loop uses 18 flops */
1050     }
1051
1052     /* Increment number of outer iterations */
1053     outeriter        += nri;
1054
1055     /* Update outer/inner flops */
1056
1057     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*90);
1058 }