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