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