Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / 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,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 "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/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_unused * 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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
357                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
358
359             /* COULOMB ELECTROSTATICS */
360             velec            = _fjsp_mul_v2r8(qq00,rinv00);
361             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
362
363             /* LENNARD-JONES DISPERSION/REPULSION */
364
365             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
366             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
367             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
368             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
369             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
370
371             /* Update potential sum for this i atom from the interaction with this j atom. */
372             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
373             velecsum         = _fjsp_add_v2r8(velecsum,velec);
374             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
375             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
376
377             fscal            = _fjsp_add_v2r8(felec,fvdw);
378
379             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
380
381             /* Update vectorial force */
382             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
383             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
384             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
385             
386             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
387             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
388             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
389
390             /**************************
391              * CALCULATE INTERACTIONS *
392              **************************/
393
394             /* Compute parameters for interactions between i and j atoms */
395             qq10             = _fjsp_mul_v2r8(iq1,jq0);
396
397             /* COULOMB ELECTROSTATICS */
398             velec            = _fjsp_mul_v2r8(qq10,rinv10);
399             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
400
401             /* Update potential sum for this i atom from the interaction with this j atom. */
402             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
403             velecsum         = _fjsp_add_v2r8(velecsum,velec);
404
405             fscal            = felec;
406
407             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
408
409             /* Update vectorial force */
410             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
411             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
412             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
413             
414             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
415             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
416             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
417
418             /**************************
419              * CALCULATE INTERACTIONS *
420              **************************/
421
422             /* Compute parameters for interactions between i and j atoms */
423             qq20             = _fjsp_mul_v2r8(iq2,jq0);
424
425             /* COULOMB ELECTROSTATICS */
426             velec            = _fjsp_mul_v2r8(qq20,rinv20);
427             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
428
429             /* Update potential sum for this i atom from the interaction with this j atom. */
430             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
431             velecsum         = _fjsp_add_v2r8(velecsum,velec);
432
433             fscal            = felec;
434
435             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
436
437             /* Update vectorial force */
438             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
439             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
440             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
441             
442             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
443             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
444             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
445
446             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
447
448             /* Inner loop uses 108 flops */
449         }
450
451         /* End of innermost loop */
452
453         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
454                                               f+i_coord_offset,fshift+i_shift_offset);
455
456         ggid                        = gid[iidx];
457         /* Update potential energies */
458         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
459         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
460
461         /* Increment number of inner iterations */
462         inneriter                  += j_index_end - j_index_start;
463
464         /* Outer loop uses 20 flops */
465     }
466
467     /* Increment number of outer iterations */
468     outeriter        += nri;
469
470     /* Update outer/inner flops */
471
472     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*108);
473 }
474 /*
475  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
476  * Electrostatics interaction: Coulomb
477  * VdW interaction:            LennardJones
478  * Geometry:                   Water3-Particle
479  * Calculate force/pot:        Force
480  */
481 void
482 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
483                     (t_nblist                    * gmx_restrict       nlist,
484                      rvec                        * gmx_restrict          xx,
485                      rvec                        * gmx_restrict          ff,
486                      t_forcerec                  * gmx_restrict          fr,
487                      t_mdatoms                   * gmx_restrict     mdatoms,
488                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
489                      t_nrnb                      * gmx_restrict        nrnb)
490 {
491     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
492      * just 0 for non-waters.
493      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
494      * jnr indices corresponding to data put in the four positions in the SIMD register.
495      */
496     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
497     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
498     int              jnrA,jnrB;
499     int              j_coord_offsetA,j_coord_offsetB;
500     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
501     real             rcutoff_scalar;
502     real             *shiftvec,*fshift,*x,*f;
503     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
504     int              vdwioffset0;
505     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
506     int              vdwioffset1;
507     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
508     int              vdwioffset2;
509     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
510     int              vdwjidx0A,vdwjidx0B;
511     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
512     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
513     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
514     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
515     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
516     real             *charge;
517     int              nvdwtype;
518     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
519     int              *vdwtype;
520     real             *vdwparam;
521     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
522     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
523     _fjsp_v2r8       itab_tmp;
524     _fjsp_v2r8       dummy_mask,cutoff_mask;
525     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
526     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
527     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
528
529     x                = xx[0];
530     f                = ff[0];
531
532     nri              = nlist->nri;
533     iinr             = nlist->iinr;
534     jindex           = nlist->jindex;
535     jjnr             = nlist->jjnr;
536     shiftidx         = nlist->shift;
537     gid              = nlist->gid;
538     shiftvec         = fr->shift_vec[0];
539     fshift           = fr->fshift[0];
540     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
541     charge           = mdatoms->chargeA;
542     nvdwtype         = fr->ntype;
543     vdwparam         = fr->nbfp;
544     vdwtype          = mdatoms->typeA;
545
546     /* Setup water-specific parameters */
547     inr              = nlist->iinr[0];
548     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
549     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
550     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
551     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
552
553     /* Avoid stupid compiler warnings */
554     jnrA = jnrB = 0;
555     j_coord_offsetA = 0;
556     j_coord_offsetB = 0;
557
558     outeriter        = 0;
559     inneriter        = 0;
560
561     /* Start outer loop over neighborlists */
562     for(iidx=0; iidx<nri; iidx++)
563     {
564         /* Load shift vector for this list */
565         i_shift_offset   = DIM*shiftidx[iidx];
566
567         /* Load limits for loop over neighbors */
568         j_index_start    = jindex[iidx];
569         j_index_end      = jindex[iidx+1];
570
571         /* Get outer coordinate index */
572         inr              = iinr[iidx];
573         i_coord_offset   = DIM*inr;
574
575         /* Load i particle coords and add shift vector */
576         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
577                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
578
579         fix0             = _fjsp_setzero_v2r8();
580         fiy0             = _fjsp_setzero_v2r8();
581         fiz0             = _fjsp_setzero_v2r8();
582         fix1             = _fjsp_setzero_v2r8();
583         fiy1             = _fjsp_setzero_v2r8();
584         fiz1             = _fjsp_setzero_v2r8();
585         fix2             = _fjsp_setzero_v2r8();
586         fiy2             = _fjsp_setzero_v2r8();
587         fiz2             = _fjsp_setzero_v2r8();
588
589         /* Start inner kernel loop */
590         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
591         {
592
593             /* Get j neighbor index, and coordinate index */
594             jnrA             = jjnr[jidx];
595             jnrB             = jjnr[jidx+1];
596             j_coord_offsetA  = DIM*jnrA;
597             j_coord_offsetB  = DIM*jnrB;
598
599             /* load j atom coordinates */
600             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
601                                               &jx0,&jy0,&jz0);
602
603             /* Calculate displacement vector */
604             dx00             = _fjsp_sub_v2r8(ix0,jx0);
605             dy00             = _fjsp_sub_v2r8(iy0,jy0);
606             dz00             = _fjsp_sub_v2r8(iz0,jz0);
607             dx10             = _fjsp_sub_v2r8(ix1,jx0);
608             dy10             = _fjsp_sub_v2r8(iy1,jy0);
609             dz10             = _fjsp_sub_v2r8(iz1,jz0);
610             dx20             = _fjsp_sub_v2r8(ix2,jx0);
611             dy20             = _fjsp_sub_v2r8(iy2,jy0);
612             dz20             = _fjsp_sub_v2r8(iz2,jz0);
613
614             /* Calculate squared distance and things based on it */
615             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
616             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
617             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
618
619             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
620             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
621             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
622
623             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
624             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
625             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
626
627             /* Load parameters for j particles */
628             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
629             vdwjidx0A        = 2*vdwtype[jnrA+0];
630             vdwjidx0B        = 2*vdwtype[jnrB+0];
631
632             fjx0             = _fjsp_setzero_v2r8();
633             fjy0             = _fjsp_setzero_v2r8();
634             fjz0             = _fjsp_setzero_v2r8();
635
636             /**************************
637              * CALCULATE INTERACTIONS *
638              **************************/
639
640             /* Compute parameters for interactions between i and j atoms */
641             qq00             = _fjsp_mul_v2r8(iq0,jq0);
642             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
643                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
644
645             /* COULOMB ELECTROSTATICS */
646             velec            = _fjsp_mul_v2r8(qq00,rinv00);
647             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
648
649             /* LENNARD-JONES DISPERSION/REPULSION */
650
651             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
652             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
653
654             fscal            = _fjsp_add_v2r8(felec,fvdw);
655
656             /* Update vectorial force */
657             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
658             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
659             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
660             
661             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
662             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
663             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
664
665             /**************************
666              * CALCULATE INTERACTIONS *
667              **************************/
668
669             /* Compute parameters for interactions between i and j atoms */
670             qq10             = _fjsp_mul_v2r8(iq1,jq0);
671
672             /* COULOMB ELECTROSTATICS */
673             velec            = _fjsp_mul_v2r8(qq10,rinv10);
674             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
675
676             fscal            = felec;
677
678             /* Update vectorial force */
679             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
680             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
681             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
682             
683             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
684             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
685             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
686
687             /**************************
688              * CALCULATE INTERACTIONS *
689              **************************/
690
691             /* Compute parameters for interactions between i and j atoms */
692             qq20             = _fjsp_mul_v2r8(iq2,jq0);
693
694             /* COULOMB ELECTROSTATICS */
695             velec            = _fjsp_mul_v2r8(qq20,rinv20);
696             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
697
698             fscal            = felec;
699
700             /* Update vectorial force */
701             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
702             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
703             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
704             
705             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
706             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
707             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
708
709             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
710
711             /* Inner loop uses 100 flops */
712         }
713
714         if(jidx<j_index_end)
715         {
716
717             jnrA             = jjnr[jidx];
718             j_coord_offsetA  = DIM*jnrA;
719
720             /* load j atom coordinates */
721             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
722                                               &jx0,&jy0,&jz0);
723
724             /* Calculate displacement vector */
725             dx00             = _fjsp_sub_v2r8(ix0,jx0);
726             dy00             = _fjsp_sub_v2r8(iy0,jy0);
727             dz00             = _fjsp_sub_v2r8(iz0,jz0);
728             dx10             = _fjsp_sub_v2r8(ix1,jx0);
729             dy10             = _fjsp_sub_v2r8(iy1,jy0);
730             dz10             = _fjsp_sub_v2r8(iz1,jz0);
731             dx20             = _fjsp_sub_v2r8(ix2,jx0);
732             dy20             = _fjsp_sub_v2r8(iy2,jy0);
733             dz20             = _fjsp_sub_v2r8(iz2,jz0);
734
735             /* Calculate squared distance and things based on it */
736             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
737             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
738             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
739
740             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
741             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
742             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
743
744             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
745             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
746             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
747
748             /* Load parameters for j particles */
749             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
750             vdwjidx0A        = 2*vdwtype[jnrA+0];
751
752             fjx0             = _fjsp_setzero_v2r8();
753             fjy0             = _fjsp_setzero_v2r8();
754             fjz0             = _fjsp_setzero_v2r8();
755
756             /**************************
757              * CALCULATE INTERACTIONS *
758              **************************/
759
760             /* Compute parameters for interactions between i and j atoms */
761             qq00             = _fjsp_mul_v2r8(iq0,jq0);
762             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
763                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
764
765             /* COULOMB ELECTROSTATICS */
766             velec            = _fjsp_mul_v2r8(qq00,rinv00);
767             felec            = _fjsp_mul_v2r8(velec,rinvsq00);
768
769             /* LENNARD-JONES DISPERSION/REPULSION */
770
771             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
772             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
773
774             fscal            = _fjsp_add_v2r8(felec,fvdw);
775
776             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
777
778             /* Update vectorial force */
779             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
780             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
781             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
782             
783             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
784             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
785             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
786
787             /**************************
788              * CALCULATE INTERACTIONS *
789              **************************/
790
791             /* Compute parameters for interactions between i and j atoms */
792             qq10             = _fjsp_mul_v2r8(iq1,jq0);
793
794             /* COULOMB ELECTROSTATICS */
795             velec            = _fjsp_mul_v2r8(qq10,rinv10);
796             felec            = _fjsp_mul_v2r8(velec,rinvsq10);
797
798             fscal            = felec;
799
800             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
801
802             /* Update vectorial force */
803             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
804             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
805             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
806             
807             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
808             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
809             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
810
811             /**************************
812              * CALCULATE INTERACTIONS *
813              **************************/
814
815             /* Compute parameters for interactions between i and j atoms */
816             qq20             = _fjsp_mul_v2r8(iq2,jq0);
817
818             /* COULOMB ELECTROSTATICS */
819             velec            = _fjsp_mul_v2r8(qq20,rinv20);
820             felec            = _fjsp_mul_v2r8(velec,rinvsq20);
821
822             fscal            = felec;
823
824             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
825
826             /* Update vectorial force */
827             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
828             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
829             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
830             
831             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
832             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
833             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
834
835             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
836
837             /* Inner loop uses 100 flops */
838         }
839
840         /* End of innermost loop */
841
842         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
843                                               f+i_coord_offset,fshift+i_shift_offset);
844
845         /* Increment number of inner iterations */
846         inneriter                  += j_index_end - j_index_start;
847
848         /* Outer loop uses 18 flops */
849     }
850
851     /* Increment number of outer iterations */
852     outeriter        += nri;
853
854     /* Update outer/inner flops */
855
856     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);
857 }