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