Valgrind suppression for OS X 10.9
[alexxy/gromacs.git] / src / gromacs / 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,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #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 "gromacs/legacyheaders/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_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset0;
82     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83     int              vdwioffset1;
84     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85     int              vdwioffset2;
86     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87     int              vdwjidx0A,vdwjidx0B;
88     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
93     real             *charge;
94     int              nvdwtype;
95     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
96     int              *vdwtype;
97     real             *vdwparam;
98     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
99     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
100     _fjsp_v2r8       itab_tmp;
101     _fjsp_v2r8       dummy_mask,cutoff_mask;
102     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
103     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
104     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
105
106     x                = xx[0];
107     f                = ff[0];
108
109     nri              = nlist->nri;
110     iinr             = nlist->iinr;
111     jindex           = nlist->jindex;
112     jjnr             = nlist->jjnr;
113     shiftidx         = nlist->shift;
114     gid              = nlist->gid;
115     shiftvec         = fr->shift_vec[0];
116     fshift           = fr->fshift[0];
117     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
118     charge           = mdatoms->chargeA;
119     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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
360                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
361
362             /* REACTION-FIELD ELECTROSTATICS */
363             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
364             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
365
366             /* LENNARD-JONES DISPERSION/REPULSION */
367
368             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
369             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
370             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
371             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
372             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
373
374             /* Update potential sum for this i atom from the interaction with this j atom. */
375             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
376             velecsum         = _fjsp_add_v2r8(velecsum,velec);
377             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
378             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
379
380             fscal            = _fjsp_add_v2r8(felec,fvdw);
381
382             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
383
384             /* Update vectorial force */
385             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
386             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
387             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
388             
389             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
390             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
391             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
392
393             /**************************
394              * CALCULATE INTERACTIONS *
395              **************************/
396
397             /* Compute parameters for interactions between i and j atoms */
398             qq10             = _fjsp_mul_v2r8(iq1,jq0);
399
400             /* REACTION-FIELD ELECTROSTATICS */
401             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
402             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
403
404             /* Update potential sum for this i atom from the interaction with this j atom. */
405             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
406             velecsum         = _fjsp_add_v2r8(velecsum,velec);
407
408             fscal            = felec;
409
410             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
411
412             /* Update vectorial force */
413             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
414             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
415             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
416             
417             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
418             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
419             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
420
421             /**************************
422              * CALCULATE INTERACTIONS *
423              **************************/
424
425             /* Compute parameters for interactions between i and j atoms */
426             qq20             = _fjsp_mul_v2r8(iq2,jq0);
427
428             /* REACTION-FIELD ELECTROSTATICS */
429             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
430             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
431
432             /* Update potential sum for this i atom from the interaction with this j atom. */
433             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
434             velecsum         = _fjsp_add_v2r8(velecsum,velec);
435
436             fscal            = felec;
437
438             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
439
440             /* Update vectorial force */
441             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
442             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
443             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
444             
445             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
446             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
447             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
448
449             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
450
451             /* Inner loop uses 120 flops */
452         }
453
454         /* End of innermost loop */
455
456         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
457                                               f+i_coord_offset,fshift+i_shift_offset);
458
459         ggid                        = gid[iidx];
460         /* Update potential energies */
461         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
462         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
463
464         /* Increment number of inner iterations */
465         inneriter                  += j_index_end - j_index_start;
466
467         /* Outer loop uses 20 flops */
468     }
469
470     /* Increment number of outer iterations */
471     outeriter        += nri;
472
473     /* Update outer/inner flops */
474
475     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
476 }
477 /*
478  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
479  * Electrostatics interaction: ReactionField
480  * VdW interaction:            LennardJones
481  * Geometry:                   Water3-Particle
482  * Calculate force/pot:        Force
483  */
484 void
485 nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
486                     (t_nblist                    * gmx_restrict       nlist,
487                      rvec                        * gmx_restrict          xx,
488                      rvec                        * gmx_restrict          ff,
489                      t_forcerec                  * gmx_restrict          fr,
490                      t_mdatoms                   * gmx_restrict     mdatoms,
491                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
492                      t_nrnb                      * gmx_restrict        nrnb)
493 {
494     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
495      * just 0 for non-waters.
496      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
497      * jnr indices corresponding to data put in the four positions in the SIMD register.
498      */
499     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
500     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
501     int              jnrA,jnrB;
502     int              j_coord_offsetA,j_coord_offsetB;
503     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
504     real             rcutoff_scalar;
505     real             *shiftvec,*fshift,*x,*f;
506     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
507     int              vdwioffset0;
508     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
509     int              vdwioffset1;
510     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
511     int              vdwioffset2;
512     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
513     int              vdwjidx0A,vdwjidx0B;
514     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
515     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
516     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
517     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
518     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
519     real             *charge;
520     int              nvdwtype;
521     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
522     int              *vdwtype;
523     real             *vdwparam;
524     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
525     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
526     _fjsp_v2r8       itab_tmp;
527     _fjsp_v2r8       dummy_mask,cutoff_mask;
528     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
529     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
530     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
531
532     x                = xx[0];
533     f                = ff[0];
534
535     nri              = nlist->nri;
536     iinr             = nlist->iinr;
537     jindex           = nlist->jindex;
538     jjnr             = nlist->jjnr;
539     shiftidx         = nlist->shift;
540     gid              = nlist->gid;
541     shiftvec         = fr->shift_vec[0];
542     fshift           = fr->fshift[0];
543     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
544     charge           = mdatoms->chargeA;
545     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
546     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
547     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
548     nvdwtype         = fr->ntype;
549     vdwparam         = fr->nbfp;
550     vdwtype          = mdatoms->typeA;
551
552     /* Setup water-specific parameters */
553     inr              = nlist->iinr[0];
554     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
555     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
556     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
557     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
558
559     /* Avoid stupid compiler warnings */
560     jnrA = jnrB = 0;
561     j_coord_offsetA = 0;
562     j_coord_offsetB = 0;
563
564     outeriter        = 0;
565     inneriter        = 0;
566
567     /* Start outer loop over neighborlists */
568     for(iidx=0; iidx<nri; iidx++)
569     {
570         /* Load shift vector for this list */
571         i_shift_offset   = DIM*shiftidx[iidx];
572
573         /* Load limits for loop over neighbors */
574         j_index_start    = jindex[iidx];
575         j_index_end      = jindex[iidx+1];
576
577         /* Get outer coordinate index */
578         inr              = iinr[iidx];
579         i_coord_offset   = DIM*inr;
580
581         /* Load i particle coords and add shift vector */
582         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
583                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
584
585         fix0             = _fjsp_setzero_v2r8();
586         fiy0             = _fjsp_setzero_v2r8();
587         fiz0             = _fjsp_setzero_v2r8();
588         fix1             = _fjsp_setzero_v2r8();
589         fiy1             = _fjsp_setzero_v2r8();
590         fiz1             = _fjsp_setzero_v2r8();
591         fix2             = _fjsp_setzero_v2r8();
592         fiy2             = _fjsp_setzero_v2r8();
593         fiz2             = _fjsp_setzero_v2r8();
594
595         /* Start inner kernel loop */
596         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
597         {
598
599             /* Get j neighbor index, and coordinate index */
600             jnrA             = jjnr[jidx];
601             jnrB             = jjnr[jidx+1];
602             j_coord_offsetA  = DIM*jnrA;
603             j_coord_offsetB  = DIM*jnrB;
604
605             /* load j atom coordinates */
606             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
607                                               &jx0,&jy0,&jz0);
608
609             /* Calculate displacement vector */
610             dx00             = _fjsp_sub_v2r8(ix0,jx0);
611             dy00             = _fjsp_sub_v2r8(iy0,jy0);
612             dz00             = _fjsp_sub_v2r8(iz0,jz0);
613             dx10             = _fjsp_sub_v2r8(ix1,jx0);
614             dy10             = _fjsp_sub_v2r8(iy1,jy0);
615             dz10             = _fjsp_sub_v2r8(iz1,jz0);
616             dx20             = _fjsp_sub_v2r8(ix2,jx0);
617             dy20             = _fjsp_sub_v2r8(iy2,jy0);
618             dz20             = _fjsp_sub_v2r8(iz2,jz0);
619
620             /* Calculate squared distance and things based on it */
621             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
622             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
623             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
624
625             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
626             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
627             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
628
629             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
630             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
631             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
632
633             /* Load parameters for j particles */
634             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
635             vdwjidx0A        = 2*vdwtype[jnrA+0];
636             vdwjidx0B        = 2*vdwtype[jnrB+0];
637
638             fjx0             = _fjsp_setzero_v2r8();
639             fjy0             = _fjsp_setzero_v2r8();
640             fjz0             = _fjsp_setzero_v2r8();
641
642             /**************************
643              * CALCULATE INTERACTIONS *
644              **************************/
645
646             /* Compute parameters for interactions between i and j atoms */
647             qq00             = _fjsp_mul_v2r8(iq0,jq0);
648             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
649                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
650
651             /* REACTION-FIELD ELECTROSTATICS */
652             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
653
654             /* LENNARD-JONES DISPERSION/REPULSION */
655
656             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
657             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
658
659             fscal            = _fjsp_add_v2r8(felec,fvdw);
660
661             /* Update vectorial force */
662             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
663             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
664             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
665             
666             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
667             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
668             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
669
670             /**************************
671              * CALCULATE INTERACTIONS *
672              **************************/
673
674             /* Compute parameters for interactions between i and j atoms */
675             qq10             = _fjsp_mul_v2r8(iq1,jq0);
676
677             /* REACTION-FIELD ELECTROSTATICS */
678             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
679
680             fscal            = felec;
681
682             /* Update vectorial force */
683             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
684             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
685             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
686             
687             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
688             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
689             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
690
691             /**************************
692              * CALCULATE INTERACTIONS *
693              **************************/
694
695             /* Compute parameters for interactions between i and j atoms */
696             qq20             = _fjsp_mul_v2r8(iq2,jq0);
697
698             /* REACTION-FIELD ELECTROSTATICS */
699             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
700
701             fscal            = felec;
702
703             /* Update vectorial force */
704             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
705             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
706             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
707             
708             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
709             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
710             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
711
712             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
713
714             /* Inner loop uses 100 flops */
715         }
716
717         if(jidx<j_index_end)
718         {
719
720             jnrA             = jjnr[jidx];
721             j_coord_offsetA  = DIM*jnrA;
722
723             /* load j atom coordinates */
724             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
725                                               &jx0,&jy0,&jz0);
726
727             /* Calculate displacement vector */
728             dx00             = _fjsp_sub_v2r8(ix0,jx0);
729             dy00             = _fjsp_sub_v2r8(iy0,jy0);
730             dz00             = _fjsp_sub_v2r8(iz0,jz0);
731             dx10             = _fjsp_sub_v2r8(ix1,jx0);
732             dy10             = _fjsp_sub_v2r8(iy1,jy0);
733             dz10             = _fjsp_sub_v2r8(iz1,jz0);
734             dx20             = _fjsp_sub_v2r8(ix2,jx0);
735             dy20             = _fjsp_sub_v2r8(iy2,jy0);
736             dz20             = _fjsp_sub_v2r8(iz2,jz0);
737
738             /* Calculate squared distance and things based on it */
739             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
740             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
741             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
742
743             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
744             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
745             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
746
747             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
748             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
749             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
750
751             /* Load parameters for j particles */
752             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
753             vdwjidx0A        = 2*vdwtype[jnrA+0];
754
755             fjx0             = _fjsp_setzero_v2r8();
756             fjy0             = _fjsp_setzero_v2r8();
757             fjz0             = _fjsp_setzero_v2r8();
758
759             /**************************
760              * CALCULATE INTERACTIONS *
761              **************************/
762
763             /* Compute parameters for interactions between i and j atoms */
764             qq00             = _fjsp_mul_v2r8(iq0,jq0);
765             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
766                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
767
768             /* REACTION-FIELD ELECTROSTATICS */
769             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
770
771             /* LENNARD-JONES DISPERSION/REPULSION */
772
773             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
774             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
775
776             fscal            = _fjsp_add_v2r8(felec,fvdw);
777
778             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
779
780             /* Update vectorial force */
781             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
782             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
783             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
784             
785             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
786             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
787             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
788
789             /**************************
790              * CALCULATE INTERACTIONS *
791              **************************/
792
793             /* Compute parameters for interactions between i and j atoms */
794             qq10             = _fjsp_mul_v2r8(iq1,jq0);
795
796             /* REACTION-FIELD ELECTROSTATICS */
797             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
798
799             fscal            = felec;
800
801             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
802
803             /* Update vectorial force */
804             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
805             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
806             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
807             
808             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
809             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
810             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
811
812             /**************************
813              * CALCULATE INTERACTIONS *
814              **************************/
815
816             /* Compute parameters for interactions between i and j atoms */
817             qq20             = _fjsp_mul_v2r8(iq2,jq0);
818
819             /* REACTION-FIELD ELECTROSTATICS */
820             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
821
822             fscal            = felec;
823
824             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
825
826             /* Update vectorial force */
827             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
828             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
829             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
830             
831             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
832             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
833             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
834
835             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
836
837             /* Inner loop uses 100 flops */
838         }
839
840         /* End of innermost loop */
841
842         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
843                                               f+i_coord_offset,fshift+i_shift_offset);
844
845         /* Increment number of inner iterations */
846         inneriter                  += j_index_end - j_index_start;
847
848         /* Outer loop uses 18 flops */
849     }
850
851     /* Increment number of outer iterations */
852     outeriter        += nri;
853
854     /* Update outer/inner flops */
855
856     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);
857 }