Version bumps after new release
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_double / nb_kernel_ElecCoul_VdwNone_GeomW3P1_avx_128_fma_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, 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_double kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
51
52 /*
53  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_double
54  * Electrostatics interaction: Coulomb
55  * VdW interaction:            None
56  * Geometry:                   Water3-Particle
57  * Calculate force/pot:        PotentialAndForce
58  */
59 void
60 nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_double
61                     (t_nblist                    * gmx_restrict       nlist,
62                      rvec                        * gmx_restrict          xx,
63                      rvec                        * gmx_restrict          ff,
64                      t_forcerec                  * gmx_restrict          fr,
65                      t_mdatoms                   * gmx_restrict     mdatoms,
66                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67                      t_nrnb                      * gmx_restrict        nrnb)
68 {
69     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70      * just 0 for non-waters.
71      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72      * jnr indices corresponding to data put in the four positions in the SIMD register.
73      */
74     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
75     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76     int              jnrA,jnrB;
77     int              j_coord_offsetA,j_coord_offsetB;
78     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
79     real             rcutoff_scalar;
80     real             *shiftvec,*fshift,*x,*f;
81     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
82     int              vdwioffset0;
83     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84     int              vdwioffset1;
85     __m128d          ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
86     int              vdwioffset2;
87     __m128d          ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88     int              vdwjidx0A,vdwjidx0B;
89     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91     __m128d          dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92     __m128d          dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93     __m128d          velec,felec,velecsum,facel,crf,krf,krf2;
94     real             *charge;
95     __m128d          dummy_mask,cutoff_mask;
96     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
97     __m128d          one     = _mm_set1_pd(1.0);
98     __m128d          two     = _mm_set1_pd(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_pd(fr->epsfac);
111     charge           = mdatoms->chargeA;
112
113     /* Setup water-specific parameters */
114     inr              = nlist->iinr[0];
115     iq0              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
116     iq1              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
117     iq2              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
118
119     /* Avoid stupid compiler warnings */
120     jnrA = jnrB = 0;
121     j_coord_offsetA = 0;
122     j_coord_offsetB = 0;
123
124     outeriter        = 0;
125     inneriter        = 0;
126
127     /* Start outer loop over neighborlists */
128     for(iidx=0; iidx<nri; iidx++)
129     {
130         /* Load shift vector for this list */
131         i_shift_offset   = DIM*shiftidx[iidx];
132
133         /* Load limits for loop over neighbors */
134         j_index_start    = jindex[iidx];
135         j_index_end      = jindex[iidx+1];
136
137         /* Get outer coordinate index */
138         inr              = iinr[iidx];
139         i_coord_offset   = DIM*inr;
140
141         /* Load i particle coords and add shift vector */
142         gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
143                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
144
145         fix0             = _mm_setzero_pd();
146         fiy0             = _mm_setzero_pd();
147         fiz0             = _mm_setzero_pd();
148         fix1             = _mm_setzero_pd();
149         fiy1             = _mm_setzero_pd();
150         fiz1             = _mm_setzero_pd();
151         fix2             = _mm_setzero_pd();
152         fiy2             = _mm_setzero_pd();
153         fiz2             = _mm_setzero_pd();
154
155         /* Reset potential sums */
156         velecsum         = _mm_setzero_pd();
157
158         /* Start inner kernel loop */
159         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
160         {
161
162             /* Get j neighbor index, and coordinate index */
163             jnrA             = jjnr[jidx];
164             jnrB             = jjnr[jidx+1];
165             j_coord_offsetA  = DIM*jnrA;
166             j_coord_offsetB  = DIM*jnrB;
167
168             /* load j atom coordinates */
169             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
170                                               &jx0,&jy0,&jz0);
171
172             /* Calculate displacement vector */
173             dx00             = _mm_sub_pd(ix0,jx0);
174             dy00             = _mm_sub_pd(iy0,jy0);
175             dz00             = _mm_sub_pd(iz0,jz0);
176             dx10             = _mm_sub_pd(ix1,jx0);
177             dy10             = _mm_sub_pd(iy1,jy0);
178             dz10             = _mm_sub_pd(iz1,jz0);
179             dx20             = _mm_sub_pd(ix2,jx0);
180             dy20             = _mm_sub_pd(iy2,jy0);
181             dz20             = _mm_sub_pd(iz2,jz0);
182
183             /* Calculate squared distance and things based on it */
184             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
185             rsq10            = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
186             rsq20            = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
187
188             rinv00           = gmx_mm_invsqrt_pd(rsq00);
189             rinv10           = gmx_mm_invsqrt_pd(rsq10);
190             rinv20           = gmx_mm_invsqrt_pd(rsq20);
191
192             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
193             rinvsq10         = _mm_mul_pd(rinv10,rinv10);
194             rinvsq20         = _mm_mul_pd(rinv20,rinv20);
195
196             /* Load parameters for j particles */
197             jq0              = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
198
199             fjx0             = _mm_setzero_pd();
200             fjy0             = _mm_setzero_pd();
201             fjz0             = _mm_setzero_pd();
202
203             /**************************
204              * CALCULATE INTERACTIONS *
205              **************************/
206
207             /* Compute parameters for interactions between i and j atoms */
208             qq00             = _mm_mul_pd(iq0,jq0);
209
210             /* COULOMB ELECTROSTATICS */
211             velec            = _mm_mul_pd(qq00,rinv00);
212             felec            = _mm_mul_pd(velec,rinvsq00);
213
214             /* Update potential sum for this i atom from the interaction with this j atom. */
215             velecsum         = _mm_add_pd(velecsum,velec);
216
217             fscal            = felec;
218
219             /* Update vectorial force */
220             fix0             = _mm_macc_pd(dx00,fscal,fix0);
221             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
222             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
223             
224             fjx0             = _mm_macc_pd(dx00,fscal,fjx0);
225             fjy0             = _mm_macc_pd(dy00,fscal,fjy0);
226             fjz0             = _mm_macc_pd(dz00,fscal,fjz0);
227
228             /**************************
229              * CALCULATE INTERACTIONS *
230              **************************/
231
232             /* Compute parameters for interactions between i and j atoms */
233             qq10             = _mm_mul_pd(iq1,jq0);
234
235             /* COULOMB ELECTROSTATICS */
236             velec            = _mm_mul_pd(qq10,rinv10);
237             felec            = _mm_mul_pd(velec,rinvsq10);
238
239             /* Update potential sum for this i atom from the interaction with this j atom. */
240             velecsum         = _mm_add_pd(velecsum,velec);
241
242             fscal            = felec;
243
244             /* Update vectorial force */
245             fix1             = _mm_macc_pd(dx10,fscal,fix1);
246             fiy1             = _mm_macc_pd(dy10,fscal,fiy1);
247             fiz1             = _mm_macc_pd(dz10,fscal,fiz1);
248             
249             fjx0             = _mm_macc_pd(dx10,fscal,fjx0);
250             fjy0             = _mm_macc_pd(dy10,fscal,fjy0);
251             fjz0             = _mm_macc_pd(dz10,fscal,fjz0);
252
253             /**************************
254              * CALCULATE INTERACTIONS *
255              **************************/
256
257             /* Compute parameters for interactions between i and j atoms */
258             qq20             = _mm_mul_pd(iq2,jq0);
259
260             /* COULOMB ELECTROSTATICS */
261             velec            = _mm_mul_pd(qq20,rinv20);
262             felec            = _mm_mul_pd(velec,rinvsq20);
263
264             /* Update potential sum for this i atom from the interaction with this j atom. */
265             velecsum         = _mm_add_pd(velecsum,velec);
266
267             fscal            = felec;
268
269             /* Update vectorial force */
270             fix2             = _mm_macc_pd(dx20,fscal,fix2);
271             fiy2             = _mm_macc_pd(dy20,fscal,fiy2);
272             fiz2             = _mm_macc_pd(dz20,fscal,fiz2);
273             
274             fjx0             = _mm_macc_pd(dx20,fscal,fjx0);
275             fjy0             = _mm_macc_pd(dy20,fscal,fjy0);
276             fjz0             = _mm_macc_pd(dz20,fscal,fjz0);
277
278             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
279
280             /* Inner loop uses 96 flops */
281         }
282
283         if(jidx<j_index_end)
284         {
285
286             jnrA             = jjnr[jidx];
287             j_coord_offsetA  = DIM*jnrA;
288
289             /* load j atom coordinates */
290             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
291                                               &jx0,&jy0,&jz0);
292
293             /* Calculate displacement vector */
294             dx00             = _mm_sub_pd(ix0,jx0);
295             dy00             = _mm_sub_pd(iy0,jy0);
296             dz00             = _mm_sub_pd(iz0,jz0);
297             dx10             = _mm_sub_pd(ix1,jx0);
298             dy10             = _mm_sub_pd(iy1,jy0);
299             dz10             = _mm_sub_pd(iz1,jz0);
300             dx20             = _mm_sub_pd(ix2,jx0);
301             dy20             = _mm_sub_pd(iy2,jy0);
302             dz20             = _mm_sub_pd(iz2,jz0);
303
304             /* Calculate squared distance and things based on it */
305             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
306             rsq10            = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
307             rsq20            = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
308
309             rinv00           = gmx_mm_invsqrt_pd(rsq00);
310             rinv10           = gmx_mm_invsqrt_pd(rsq10);
311             rinv20           = gmx_mm_invsqrt_pd(rsq20);
312
313             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
314             rinvsq10         = _mm_mul_pd(rinv10,rinv10);
315             rinvsq20         = _mm_mul_pd(rinv20,rinv20);
316
317             /* Load parameters for j particles */
318             jq0              = _mm_load_sd(charge+jnrA+0);
319
320             fjx0             = _mm_setzero_pd();
321             fjy0             = _mm_setzero_pd();
322             fjz0             = _mm_setzero_pd();
323
324             /**************************
325              * CALCULATE INTERACTIONS *
326              **************************/
327
328             /* Compute parameters for interactions between i and j atoms */
329             qq00             = _mm_mul_pd(iq0,jq0);
330
331             /* COULOMB ELECTROSTATICS */
332             velec            = _mm_mul_pd(qq00,rinv00);
333             felec            = _mm_mul_pd(velec,rinvsq00);
334
335             /* Update potential sum for this i atom from the interaction with this j atom. */
336             velec            = _mm_unpacklo_pd(velec,_mm_setzero_pd());
337             velecsum         = _mm_add_pd(velecsum,velec);
338
339             fscal            = felec;
340
341             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
342
343             /* Update vectorial force */
344             fix0             = _mm_macc_pd(dx00,fscal,fix0);
345             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
346             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
347             
348             fjx0             = _mm_macc_pd(dx00,fscal,fjx0);
349             fjy0             = _mm_macc_pd(dy00,fscal,fjy0);
350             fjz0             = _mm_macc_pd(dz00,fscal,fjz0);
351
352             /**************************
353              * CALCULATE INTERACTIONS *
354              **************************/
355
356             /* Compute parameters for interactions between i and j atoms */
357             qq10             = _mm_mul_pd(iq1,jq0);
358
359             /* COULOMB ELECTROSTATICS */
360             velec            = _mm_mul_pd(qq10,rinv10);
361             felec            = _mm_mul_pd(velec,rinvsq10);
362
363             /* Update potential sum for this i atom from the interaction with this j atom. */
364             velec            = _mm_unpacklo_pd(velec,_mm_setzero_pd());
365             velecsum         = _mm_add_pd(velecsum,velec);
366
367             fscal            = felec;
368
369             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
370
371             /* Update vectorial force */
372             fix1             = _mm_macc_pd(dx10,fscal,fix1);
373             fiy1             = _mm_macc_pd(dy10,fscal,fiy1);
374             fiz1             = _mm_macc_pd(dz10,fscal,fiz1);
375             
376             fjx0             = _mm_macc_pd(dx10,fscal,fjx0);
377             fjy0             = _mm_macc_pd(dy10,fscal,fjy0);
378             fjz0             = _mm_macc_pd(dz10,fscal,fjz0);
379
380             /**************************
381              * CALCULATE INTERACTIONS *
382              **************************/
383
384             /* Compute parameters for interactions between i and j atoms */
385             qq20             = _mm_mul_pd(iq2,jq0);
386
387             /* COULOMB ELECTROSTATICS */
388             velec            = _mm_mul_pd(qq20,rinv20);
389             felec            = _mm_mul_pd(velec,rinvsq20);
390
391             /* Update potential sum for this i atom from the interaction with this j atom. */
392             velec            = _mm_unpacklo_pd(velec,_mm_setzero_pd());
393             velecsum         = _mm_add_pd(velecsum,velec);
394
395             fscal            = felec;
396
397             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
398
399             /* Update vectorial force */
400             fix2             = _mm_macc_pd(dx20,fscal,fix2);
401             fiy2             = _mm_macc_pd(dy20,fscal,fiy2);
402             fiz2             = _mm_macc_pd(dz20,fscal,fiz2);
403             
404             fjx0             = _mm_macc_pd(dx20,fscal,fjx0);
405             fjy0             = _mm_macc_pd(dy20,fscal,fjy0);
406             fjz0             = _mm_macc_pd(dz20,fscal,fjz0);
407
408             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
409
410             /* Inner loop uses 96 flops */
411         }
412
413         /* End of innermost loop */
414
415         gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
416                                               f+i_coord_offset,fshift+i_shift_offset);
417
418         ggid                        = gid[iidx];
419         /* Update potential energies */
420         gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
421
422         /* Increment number of inner iterations */
423         inneriter                  += j_index_end - j_index_start;
424
425         /* Outer loop uses 19 flops */
426     }
427
428     /* Increment number of outer iterations */
429     outeriter        += nri;
430
431     /* Update outer/inner flops */
432
433     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*96);
434 }
435 /*
436  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
437  * Electrostatics interaction: Coulomb
438  * VdW interaction:            None
439  * Geometry:                   Water3-Particle
440  * Calculate force/pot:        Force
441  */
442 void
443 nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_double
444                     (t_nblist                    * gmx_restrict       nlist,
445                      rvec                        * gmx_restrict          xx,
446                      rvec                        * gmx_restrict          ff,
447                      t_forcerec                  * gmx_restrict          fr,
448                      t_mdatoms                   * gmx_restrict     mdatoms,
449                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
450                      t_nrnb                      * gmx_restrict        nrnb)
451 {
452     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
453      * just 0 for non-waters.
454      * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
455      * jnr indices corresponding to data put in the four positions in the SIMD register.
456      */
457     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
458     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
459     int              jnrA,jnrB;
460     int              j_coord_offsetA,j_coord_offsetB;
461     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
462     real             rcutoff_scalar;
463     real             *shiftvec,*fshift,*x,*f;
464     __m128d          tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
465     int              vdwioffset0;
466     __m128d          ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
467     int              vdwioffset1;
468     __m128d          ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
469     int              vdwioffset2;
470     __m128d          ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
471     int              vdwjidx0A,vdwjidx0B;
472     __m128d          jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
473     __m128d          dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
474     __m128d          dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
475     __m128d          dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
476     __m128d          velec,felec,velecsum,facel,crf,krf,krf2;
477     real             *charge;
478     __m128d          dummy_mask,cutoff_mask;
479     __m128d          signbit   = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
480     __m128d          one     = _mm_set1_pd(1.0);
481     __m128d          two     = _mm_set1_pd(2.0);
482     x                = xx[0];
483     f                = ff[0];
484
485     nri              = nlist->nri;
486     iinr             = nlist->iinr;
487     jindex           = nlist->jindex;
488     jjnr             = nlist->jjnr;
489     shiftidx         = nlist->shift;
490     gid              = nlist->gid;
491     shiftvec         = fr->shift_vec[0];
492     fshift           = fr->fshift[0];
493     facel            = _mm_set1_pd(fr->epsfac);
494     charge           = mdatoms->chargeA;
495
496     /* Setup water-specific parameters */
497     inr              = nlist->iinr[0];
498     iq0              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
499     iq1              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
500     iq2              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
501
502     /* Avoid stupid compiler warnings */
503     jnrA = jnrB = 0;
504     j_coord_offsetA = 0;
505     j_coord_offsetB = 0;
506
507     outeriter        = 0;
508     inneriter        = 0;
509
510     /* Start outer loop over neighborlists */
511     for(iidx=0; iidx<nri; iidx++)
512     {
513         /* Load shift vector for this list */
514         i_shift_offset   = DIM*shiftidx[iidx];
515
516         /* Load limits for loop over neighbors */
517         j_index_start    = jindex[iidx];
518         j_index_end      = jindex[iidx+1];
519
520         /* Get outer coordinate index */
521         inr              = iinr[iidx];
522         i_coord_offset   = DIM*inr;
523
524         /* Load i particle coords and add shift vector */
525         gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
526                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
527
528         fix0             = _mm_setzero_pd();
529         fiy0             = _mm_setzero_pd();
530         fiz0             = _mm_setzero_pd();
531         fix1             = _mm_setzero_pd();
532         fiy1             = _mm_setzero_pd();
533         fiz1             = _mm_setzero_pd();
534         fix2             = _mm_setzero_pd();
535         fiy2             = _mm_setzero_pd();
536         fiz2             = _mm_setzero_pd();
537
538         /* Start inner kernel loop */
539         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
540         {
541
542             /* Get j neighbor index, and coordinate index */
543             jnrA             = jjnr[jidx];
544             jnrB             = jjnr[jidx+1];
545             j_coord_offsetA  = DIM*jnrA;
546             j_coord_offsetB  = DIM*jnrB;
547
548             /* load j atom coordinates */
549             gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
550                                               &jx0,&jy0,&jz0);
551
552             /* Calculate displacement vector */
553             dx00             = _mm_sub_pd(ix0,jx0);
554             dy00             = _mm_sub_pd(iy0,jy0);
555             dz00             = _mm_sub_pd(iz0,jz0);
556             dx10             = _mm_sub_pd(ix1,jx0);
557             dy10             = _mm_sub_pd(iy1,jy0);
558             dz10             = _mm_sub_pd(iz1,jz0);
559             dx20             = _mm_sub_pd(ix2,jx0);
560             dy20             = _mm_sub_pd(iy2,jy0);
561             dz20             = _mm_sub_pd(iz2,jz0);
562
563             /* Calculate squared distance and things based on it */
564             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
565             rsq10            = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
566             rsq20            = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
567
568             rinv00           = gmx_mm_invsqrt_pd(rsq00);
569             rinv10           = gmx_mm_invsqrt_pd(rsq10);
570             rinv20           = gmx_mm_invsqrt_pd(rsq20);
571
572             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
573             rinvsq10         = _mm_mul_pd(rinv10,rinv10);
574             rinvsq20         = _mm_mul_pd(rinv20,rinv20);
575
576             /* Load parameters for j particles */
577             jq0              = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
578
579             fjx0             = _mm_setzero_pd();
580             fjy0             = _mm_setzero_pd();
581             fjz0             = _mm_setzero_pd();
582
583             /**************************
584              * CALCULATE INTERACTIONS *
585              **************************/
586
587             /* Compute parameters for interactions between i and j atoms */
588             qq00             = _mm_mul_pd(iq0,jq0);
589
590             /* COULOMB ELECTROSTATICS */
591             velec            = _mm_mul_pd(qq00,rinv00);
592             felec            = _mm_mul_pd(velec,rinvsq00);
593
594             fscal            = felec;
595
596             /* Update vectorial force */
597             fix0             = _mm_macc_pd(dx00,fscal,fix0);
598             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
599             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
600             
601             fjx0             = _mm_macc_pd(dx00,fscal,fjx0);
602             fjy0             = _mm_macc_pd(dy00,fscal,fjy0);
603             fjz0             = _mm_macc_pd(dz00,fscal,fjz0);
604
605             /**************************
606              * CALCULATE INTERACTIONS *
607              **************************/
608
609             /* Compute parameters for interactions between i and j atoms */
610             qq10             = _mm_mul_pd(iq1,jq0);
611
612             /* COULOMB ELECTROSTATICS */
613             velec            = _mm_mul_pd(qq10,rinv10);
614             felec            = _mm_mul_pd(velec,rinvsq10);
615
616             fscal            = felec;
617
618             /* Update vectorial force */
619             fix1             = _mm_macc_pd(dx10,fscal,fix1);
620             fiy1             = _mm_macc_pd(dy10,fscal,fiy1);
621             fiz1             = _mm_macc_pd(dz10,fscal,fiz1);
622             
623             fjx0             = _mm_macc_pd(dx10,fscal,fjx0);
624             fjy0             = _mm_macc_pd(dy10,fscal,fjy0);
625             fjz0             = _mm_macc_pd(dz10,fscal,fjz0);
626
627             /**************************
628              * CALCULATE INTERACTIONS *
629              **************************/
630
631             /* Compute parameters for interactions between i and j atoms */
632             qq20             = _mm_mul_pd(iq2,jq0);
633
634             /* COULOMB ELECTROSTATICS */
635             velec            = _mm_mul_pd(qq20,rinv20);
636             felec            = _mm_mul_pd(velec,rinvsq20);
637
638             fscal            = felec;
639
640             /* Update vectorial force */
641             fix2             = _mm_macc_pd(dx20,fscal,fix2);
642             fiy2             = _mm_macc_pd(dy20,fscal,fiy2);
643             fiz2             = _mm_macc_pd(dz20,fscal,fiz2);
644             
645             fjx0             = _mm_macc_pd(dx20,fscal,fjx0);
646             fjy0             = _mm_macc_pd(dy20,fscal,fjy0);
647             fjz0             = _mm_macc_pd(dz20,fscal,fjz0);
648
649             gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
650
651             /* Inner loop uses 93 flops */
652         }
653
654         if(jidx<j_index_end)
655         {
656
657             jnrA             = jjnr[jidx];
658             j_coord_offsetA  = DIM*jnrA;
659
660             /* load j atom coordinates */
661             gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
662                                               &jx0,&jy0,&jz0);
663
664             /* Calculate displacement vector */
665             dx00             = _mm_sub_pd(ix0,jx0);
666             dy00             = _mm_sub_pd(iy0,jy0);
667             dz00             = _mm_sub_pd(iz0,jz0);
668             dx10             = _mm_sub_pd(ix1,jx0);
669             dy10             = _mm_sub_pd(iy1,jy0);
670             dz10             = _mm_sub_pd(iz1,jz0);
671             dx20             = _mm_sub_pd(ix2,jx0);
672             dy20             = _mm_sub_pd(iy2,jy0);
673             dz20             = _mm_sub_pd(iz2,jz0);
674
675             /* Calculate squared distance and things based on it */
676             rsq00            = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
677             rsq10            = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
678             rsq20            = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
679
680             rinv00           = gmx_mm_invsqrt_pd(rsq00);
681             rinv10           = gmx_mm_invsqrt_pd(rsq10);
682             rinv20           = gmx_mm_invsqrt_pd(rsq20);
683
684             rinvsq00         = _mm_mul_pd(rinv00,rinv00);
685             rinvsq10         = _mm_mul_pd(rinv10,rinv10);
686             rinvsq20         = _mm_mul_pd(rinv20,rinv20);
687
688             /* Load parameters for j particles */
689             jq0              = _mm_load_sd(charge+jnrA+0);
690
691             fjx0             = _mm_setzero_pd();
692             fjy0             = _mm_setzero_pd();
693             fjz0             = _mm_setzero_pd();
694
695             /**************************
696              * CALCULATE INTERACTIONS *
697              **************************/
698
699             /* Compute parameters for interactions between i and j atoms */
700             qq00             = _mm_mul_pd(iq0,jq0);
701
702             /* COULOMB ELECTROSTATICS */
703             velec            = _mm_mul_pd(qq00,rinv00);
704             felec            = _mm_mul_pd(velec,rinvsq00);
705
706             fscal            = felec;
707
708             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
709
710             /* Update vectorial force */
711             fix0             = _mm_macc_pd(dx00,fscal,fix0);
712             fiy0             = _mm_macc_pd(dy00,fscal,fiy0);
713             fiz0             = _mm_macc_pd(dz00,fscal,fiz0);
714             
715             fjx0             = _mm_macc_pd(dx00,fscal,fjx0);
716             fjy0             = _mm_macc_pd(dy00,fscal,fjy0);
717             fjz0             = _mm_macc_pd(dz00,fscal,fjz0);
718
719             /**************************
720              * CALCULATE INTERACTIONS *
721              **************************/
722
723             /* Compute parameters for interactions between i and j atoms */
724             qq10             = _mm_mul_pd(iq1,jq0);
725
726             /* COULOMB ELECTROSTATICS */
727             velec            = _mm_mul_pd(qq10,rinv10);
728             felec            = _mm_mul_pd(velec,rinvsq10);
729
730             fscal            = felec;
731
732             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
733
734             /* Update vectorial force */
735             fix1             = _mm_macc_pd(dx10,fscal,fix1);
736             fiy1             = _mm_macc_pd(dy10,fscal,fiy1);
737             fiz1             = _mm_macc_pd(dz10,fscal,fiz1);
738             
739             fjx0             = _mm_macc_pd(dx10,fscal,fjx0);
740             fjy0             = _mm_macc_pd(dy10,fscal,fjy0);
741             fjz0             = _mm_macc_pd(dz10,fscal,fjz0);
742
743             /**************************
744              * CALCULATE INTERACTIONS *
745              **************************/
746
747             /* Compute parameters for interactions between i and j atoms */
748             qq20             = _mm_mul_pd(iq2,jq0);
749
750             /* COULOMB ELECTROSTATICS */
751             velec            = _mm_mul_pd(qq20,rinv20);
752             felec            = _mm_mul_pd(velec,rinvsq20);
753
754             fscal            = felec;
755
756             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
757
758             /* Update vectorial force */
759             fix2             = _mm_macc_pd(dx20,fscal,fix2);
760             fiy2             = _mm_macc_pd(dy20,fscal,fiy2);
761             fiz2             = _mm_macc_pd(dz20,fscal,fiz2);
762             
763             fjx0             = _mm_macc_pd(dx20,fscal,fjx0);
764             fjy0             = _mm_macc_pd(dy20,fscal,fjy0);
765             fjz0             = _mm_macc_pd(dz20,fscal,fjz0);
766
767             gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
768
769             /* Inner loop uses 93 flops */
770         }
771
772         /* End of innermost loop */
773
774         gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
775                                               f+i_coord_offset,fshift+i_shift_offset);
776
777         /* Increment number of inner iterations */
778         inneriter                  += j_index_end - j_index_start;
779
780         /* Outer loop uses 18 flops */
781     }
782
783     /* Increment number of outer iterations */
784     outeriter        += nri;
785
786     /* Update outer/inner flops */
787
788     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*93);
789 }