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