Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecCoul_VdwNone_GeomW4P1_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_GeomW4P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: Coulomb
52  * VdW interaction:            None
53  * Geometry:                   Water4-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCoul_VdwNone_GeomW4P1_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              vdwioffset1;
80     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
81     int              vdwioffset2;
82     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
83     int              vdwioffset3;
84     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
85     int              vdwjidx0A,vdwjidx0B;
86     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
88     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
89     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
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     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
115     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
116     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
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+DIM,
142                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
143
144         fix1             = _fjsp_setzero_v2r8();
145         fiy1             = _fjsp_setzero_v2r8();
146         fiz1             = _fjsp_setzero_v2r8();
147         fix2             = _fjsp_setzero_v2r8();
148         fiy2             = _fjsp_setzero_v2r8();
149         fiz2             = _fjsp_setzero_v2r8();
150         fix3             = _fjsp_setzero_v2r8();
151         fiy3             = _fjsp_setzero_v2r8();
152         fiz3             = _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             dx10             = _fjsp_sub_v2r8(ix1,jx0);
173             dy10             = _fjsp_sub_v2r8(iy1,jy0);
174             dz10             = _fjsp_sub_v2r8(iz1,jz0);
175             dx20             = _fjsp_sub_v2r8(ix2,jx0);
176             dy20             = _fjsp_sub_v2r8(iy2,jy0);
177             dz20             = _fjsp_sub_v2r8(iz2,jz0);
178             dx30             = _fjsp_sub_v2r8(ix3,jx0);
179             dy30             = _fjsp_sub_v2r8(iy3,jy0);
180             dz30             = _fjsp_sub_v2r8(iz3,jz0);
181
182             /* Calculate squared distance and things based on it */
183             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
184             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
185             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
186
187             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
188             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
189             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
190
191             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
192             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
193             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
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             qq10             = _fjsp_mul_v2r8(iq1,jq0);
208
209             /* COULOMB ELECTROSTATICS */
210             velec            = _fjsp_mul_v2r8(qq10,rinv10);
211             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
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             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
220             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
221             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
222             
223             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
224             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
225             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
226
227             /**************************
228              * CALCULATE INTERACTIONS *
229              **************************/
230
231             /* Compute parameters for interactions between i and j atoms */
232             qq20             = _fjsp_mul_v2r8(iq2,jq0);
233
234             /* COULOMB ELECTROSTATICS */
235             velec            = _fjsp_mul_v2r8(qq20,rinv20);
236             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
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             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
245             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
246             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
247             
248             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
249             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
250             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
251
252             /**************************
253              * CALCULATE INTERACTIONS *
254              **************************/
255
256             /* Compute parameters for interactions between i and j atoms */
257             qq30             = _fjsp_mul_v2r8(iq3,jq0);
258
259             /* COULOMB ELECTROSTATICS */
260             velec            = _fjsp_mul_v2r8(qq30,rinv30);
261             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
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             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
270             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
271             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
272             
273             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
274             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
275             fjz0             = _fjsp_madd_v2r8(dz30,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             dx10             = _fjsp_sub_v2r8(ix1,jx0);
294             dy10             = _fjsp_sub_v2r8(iy1,jy0);
295             dz10             = _fjsp_sub_v2r8(iz1,jz0);
296             dx20             = _fjsp_sub_v2r8(ix2,jx0);
297             dy20             = _fjsp_sub_v2r8(iy2,jy0);
298             dz20             = _fjsp_sub_v2r8(iz2,jz0);
299             dx30             = _fjsp_sub_v2r8(ix3,jx0);
300             dy30             = _fjsp_sub_v2r8(iy3,jy0);
301             dz30             = _fjsp_sub_v2r8(iz3,jz0);
302
303             /* Calculate squared distance and things based on it */
304             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
305             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
306             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
307
308             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
309             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
310             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
311
312             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
313             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
314             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
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             qq10             = _fjsp_mul_v2r8(iq1,jq0);
329
330             /* COULOMB ELECTROSTATICS */
331             velec            = _fjsp_mul_v2r8(qq10,rinv10);
332             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
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             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
344             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
345             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
346             
347             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
348             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
349             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
350
351             /**************************
352              * CALCULATE INTERACTIONS *
353              **************************/
354
355             /* Compute parameters for interactions between i and j atoms */
356             qq20             = _fjsp_mul_v2r8(iq2,jq0);
357
358             /* COULOMB ELECTROSTATICS */
359             velec            = _fjsp_mul_v2r8(qq20,rinv20);
360             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
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             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
372             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
373             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
374             
375             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
376             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
377             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
378
379             /**************************
380              * CALCULATE INTERACTIONS *
381              **************************/
382
383             /* Compute parameters for interactions between i and j atoms */
384             qq30             = _fjsp_mul_v2r8(iq3,jq0);
385
386             /* COULOMB ELECTROSTATICS */
387             velec            = _fjsp_mul_v2r8(qq30,rinv30);
388             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
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             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
400             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
401             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
402             
403             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
404             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
405             fjz0             = _fjsp_madd_v2r8(dz30,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(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
415                                               f+i_coord_offset+DIM,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_W4_VF,outeriter*19 + inneriter*96);
433 }
434 /*
435  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_sparc64_hpc_ace_double
436  * Electrostatics interaction: Coulomb
437  * VdW interaction:            None
438  * Geometry:                   Water4-Particle
439  * Calculate force/pot:        Force
440  */
441 void
442 nb_kernel_ElecCoul_VdwNone_GeomW4P1_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              vdwioffset1;
465     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
466     int              vdwioffset2;
467     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
468     int              vdwioffset3;
469     _fjsp_v2r8       ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
470     int              vdwjidx0A,vdwjidx0B;
471     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
472     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
473     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
474     _fjsp_v2r8       dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
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     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
500     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
501     iq3              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
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+DIM,
527                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
528
529         fix1             = _fjsp_setzero_v2r8();
530         fiy1             = _fjsp_setzero_v2r8();
531         fiz1             = _fjsp_setzero_v2r8();
532         fix2             = _fjsp_setzero_v2r8();
533         fiy2             = _fjsp_setzero_v2r8();
534         fiz2             = _fjsp_setzero_v2r8();
535         fix3             = _fjsp_setzero_v2r8();
536         fiy3             = _fjsp_setzero_v2r8();
537         fiz3             = _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             dx10             = _fjsp_sub_v2r8(ix1,jx0);
555             dy10             = _fjsp_sub_v2r8(iy1,jy0);
556             dz10             = _fjsp_sub_v2r8(iz1,jz0);
557             dx20             = _fjsp_sub_v2r8(ix2,jx0);
558             dy20             = _fjsp_sub_v2r8(iy2,jy0);
559             dz20             = _fjsp_sub_v2r8(iz2,jz0);
560             dx30             = _fjsp_sub_v2r8(ix3,jx0);
561             dy30             = _fjsp_sub_v2r8(iy3,jy0);
562             dz30             = _fjsp_sub_v2r8(iz3,jz0);
563
564             /* Calculate squared distance and things based on it */
565             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
566             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
567             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
568
569             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
570             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
571             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
572
573             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
574             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
575             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
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             qq10             = _fjsp_mul_v2r8(iq1,jq0);
590
591             /* COULOMB ELECTROSTATICS */
592             velec            = _fjsp_mul_v2r8(qq10,rinv10);
593             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
594
595             fscal            = felec;
596
597             /* Update vectorial force */
598             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
599             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
600             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
601             
602             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
603             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
604             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
605
606             /**************************
607              * CALCULATE INTERACTIONS *
608              **************************/
609
610             /* Compute parameters for interactions between i and j atoms */
611             qq20             = _fjsp_mul_v2r8(iq2,jq0);
612
613             /* COULOMB ELECTROSTATICS */
614             velec            = _fjsp_mul_v2r8(qq20,rinv20);
615             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
616
617             fscal            = felec;
618
619             /* Update vectorial force */
620             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
621             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
622             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
623             
624             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
625             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
626             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
627
628             /**************************
629              * CALCULATE INTERACTIONS *
630              **************************/
631
632             /* Compute parameters for interactions between i and j atoms */
633             qq30             = _fjsp_mul_v2r8(iq3,jq0);
634
635             /* COULOMB ELECTROSTATICS */
636             velec            = _fjsp_mul_v2r8(qq30,rinv30);
637             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
638
639             fscal            = felec;
640
641             /* Update vectorial force */
642             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
643             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
644             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
645             
646             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
647             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
648             fjz0             = _fjsp_madd_v2r8(dz30,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             dx10             = _fjsp_sub_v2r8(ix1,jx0);
667             dy10             = _fjsp_sub_v2r8(iy1,jy0);
668             dz10             = _fjsp_sub_v2r8(iz1,jz0);
669             dx20             = _fjsp_sub_v2r8(ix2,jx0);
670             dy20             = _fjsp_sub_v2r8(iy2,jy0);
671             dz20             = _fjsp_sub_v2r8(iz2,jz0);
672             dx30             = _fjsp_sub_v2r8(ix3,jx0);
673             dy30             = _fjsp_sub_v2r8(iy3,jy0);
674             dz30             = _fjsp_sub_v2r8(iz3,jz0);
675
676             /* Calculate squared distance and things based on it */
677             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
678             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
679             rsq30            = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
680
681             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
682             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
683             rinv30           = gmx_fjsp_invsqrt_v2r8(rsq30);
684
685             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
686             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
687             rinvsq30         = _fjsp_mul_v2r8(rinv30,rinv30);
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             qq10             = _fjsp_mul_v2r8(iq1,jq0);
702
703             /* COULOMB ELECTROSTATICS */
704             velec            = _fjsp_mul_v2r8(qq10,rinv10);
705             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
706
707             fscal            = felec;
708
709             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
710
711             /* Update vectorial force */
712             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
713             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
714             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
715             
716             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
717             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
718             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
719
720             /**************************
721              * CALCULATE INTERACTIONS *
722              **************************/
723
724             /* Compute parameters for interactions between i and j atoms */
725             qq20             = _fjsp_mul_v2r8(iq2,jq0);
726
727             /* COULOMB ELECTROSTATICS */
728             velec            = _fjsp_mul_v2r8(qq20,rinv20);
729             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
730
731             fscal            = felec;
732
733             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
734
735             /* Update vectorial force */
736             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
737             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
738             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
739             
740             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
741             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
742             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
743
744             /**************************
745              * CALCULATE INTERACTIONS *
746              **************************/
747
748             /* Compute parameters for interactions between i and j atoms */
749             qq30             = _fjsp_mul_v2r8(iq3,jq0);
750
751             /* COULOMB ELECTROSTATICS */
752             velec            = _fjsp_mul_v2r8(qq30,rinv30);
753             felec            = _fjsp_mul_v2r8(velec,rinvsq30);
754
755             fscal            = felec;
756
757             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
758
759             /* Update vectorial force */
760             fix3             = _fjsp_madd_v2r8(dx30,fscal,fix3);
761             fiy3             = _fjsp_madd_v2r8(dy30,fscal,fiy3);
762             fiz3             = _fjsp_madd_v2r8(dz30,fscal,fiz3);
763             
764             fjx0             = _fjsp_madd_v2r8(dx30,fscal,fjx0);
765             fjy0             = _fjsp_madd_v2r8(dy30,fscal,fjy0);
766             fjz0             = _fjsp_madd_v2r8(dz30,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(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
776                                               f+i_coord_offset+DIM,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_W4_F,outeriter*18 + inneriter*93);
790 }