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