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