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