56c0f4f12df9725aa002e6d65de309f117507b43
[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 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_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                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwioffset1;
82     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83     int              vdwioffset2;
84     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85     int              vdwjidx0A,vdwjidx0B;
86     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
89     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
90     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
91     real             *charge;
92     int              nvdwtype;
93     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
94     int              *vdwtype;
95     real             *vdwparam;
96     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
97     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
98     _fjsp_v2r8       itab_tmp;
99     _fjsp_v2r8       dummy_mask,cutoff_mask;
100     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
101     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
102     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
103
104     x                = xx[0];
105     f                = ff[0];
106
107     nri              = nlist->nri;
108     iinr             = nlist->iinr;
109     jindex           = nlist->jindex;
110     jjnr             = nlist->jjnr;
111     shiftidx         = nlist->shift;
112     gid              = nlist->gid;
113     shiftvec         = fr->shift_vec[0];
114     fshift           = fr->fshift[0];
115     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
116     charge           = mdatoms->chargeA;
117     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_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
358
359             /* REACTION-FIELD ELECTROSTATICS */
360             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
361             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
362
363             /* LENNARD-JONES DISPERSION/REPULSION */
364
365             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
366             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
367             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
368             vvdw             = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
369             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
370
371             /* Update potential sum for this i atom from the interaction with this j atom. */
372             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
373             velecsum         = _fjsp_add_v2r8(velecsum,velec);
374             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
375             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
376
377             fscal            = _fjsp_add_v2r8(felec,fvdw);
378
379             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
380
381             /* Update vectorial force */
382             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
383             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
384             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
385             
386             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
387             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
388             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
389
390             /**************************
391              * CALCULATE INTERACTIONS *
392              **************************/
393
394             /* Compute parameters for interactions between i and j atoms */
395             qq10             = _fjsp_mul_v2r8(iq1,jq0);
396
397             /* REACTION-FIELD ELECTROSTATICS */
398             velec            = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
399             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
400
401             /* Update potential sum for this i atom from the interaction with this j atom. */
402             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
403             velecsum         = _fjsp_add_v2r8(velecsum,velec);
404
405             fscal            = felec;
406
407             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
408
409             /* Update vectorial force */
410             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
411             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
412             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
413             
414             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
415             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
416             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
417
418             /**************************
419              * CALCULATE INTERACTIONS *
420              **************************/
421
422             /* Compute parameters for interactions between i and j atoms */
423             qq20             = _fjsp_mul_v2r8(iq2,jq0);
424
425             /* REACTION-FIELD ELECTROSTATICS */
426             velec            = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
427             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
428
429             /* Update potential sum for this i atom from the interaction with this j atom. */
430             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
431             velecsum         = _fjsp_add_v2r8(velecsum,velec);
432
433             fscal            = felec;
434
435             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
436
437             /* Update vectorial force */
438             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
439             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
440             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
441             
442             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
443             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
444             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
445
446             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
447
448             /* Inner loop uses 120 flops */
449         }
450
451         /* End of innermost loop */
452
453         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
454                                               f+i_coord_offset,fshift+i_shift_offset);
455
456         ggid                        = gid[iidx];
457         /* Update potential energies */
458         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
459         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
460
461         /* Increment number of inner iterations */
462         inneriter                  += j_index_end - j_index_start;
463
464         /* Outer loop uses 20 flops */
465     }
466
467     /* Increment number of outer iterations */
468     outeriter        += nri;
469
470     /* Update outer/inner flops */
471
472     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
473 }
474 /*
475  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
476  * Electrostatics interaction: ReactionField
477  * VdW interaction:            LennardJones
478  * Geometry:                   Water3-Particle
479  * Calculate force/pot:        Force
480  */
481 void
482 nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
483                     (t_nblist                    * gmx_restrict       nlist,
484                      rvec                        * gmx_restrict          xx,
485                      rvec                        * gmx_restrict          ff,
486                      t_forcerec                  * gmx_restrict          fr,
487                      t_mdatoms                   * gmx_restrict     mdatoms,
488                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
489                      t_nrnb                      * gmx_restrict        nrnb)
490 {
491     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
492      * just 0 for non-waters.
493      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
494      * jnr indices corresponding to data put in the four positions in the SIMD register.
495      */
496     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
497     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
498     int              jnrA,jnrB;
499     int              j_coord_offsetA,j_coord_offsetB;
500     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
501     real             rcutoff_scalar;
502     real             *shiftvec,*fshift,*x,*f;
503     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
504     int              vdwioffset0;
505     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
506     int              vdwioffset1;
507     _fjsp_v2r8       ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
508     int              vdwioffset2;
509     _fjsp_v2r8       ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
510     int              vdwjidx0A,vdwjidx0B;
511     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
512     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
513     _fjsp_v2r8       dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
514     _fjsp_v2r8       dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
515     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
516     real             *charge;
517     int              nvdwtype;
518     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
519     int              *vdwtype;
520     real             *vdwparam;
521     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
522     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
523     _fjsp_v2r8       itab_tmp;
524     _fjsp_v2r8       dummy_mask,cutoff_mask;
525     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
526     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
527     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
528
529     x                = xx[0];
530     f                = ff[0];
531
532     nri              = nlist->nri;
533     iinr             = nlist->iinr;
534     jindex           = nlist->jindex;
535     jjnr             = nlist->jjnr;
536     shiftidx         = nlist->shift;
537     gid              = nlist->gid;
538     shiftvec         = fr->shift_vec[0];
539     fshift           = fr->fshift[0];
540     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
541     charge           = mdatoms->chargeA;
542     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
543     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
544     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
545     nvdwtype         = fr->ntype;
546     vdwparam         = fr->nbfp;
547     vdwtype          = mdatoms->typeA;
548
549     /* Setup water-specific parameters */
550     inr              = nlist->iinr[0];
551     iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
552     iq1              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
553     iq2              = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
554     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
555
556     /* Avoid stupid compiler warnings */
557     jnrA = jnrB = 0;
558     j_coord_offsetA = 0;
559     j_coord_offsetB = 0;
560
561     outeriter        = 0;
562     inneriter        = 0;
563
564     /* Start outer loop over neighborlists */
565     for(iidx=0; iidx<nri; iidx++)
566     {
567         /* Load shift vector for this list */
568         i_shift_offset   = DIM*shiftidx[iidx];
569
570         /* Load limits for loop over neighbors */
571         j_index_start    = jindex[iidx];
572         j_index_end      = jindex[iidx+1];
573
574         /* Get outer coordinate index */
575         inr              = iinr[iidx];
576         i_coord_offset   = DIM*inr;
577
578         /* Load i particle coords and add shift vector */
579         gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
580                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
581
582         fix0             = _fjsp_setzero_v2r8();
583         fiy0             = _fjsp_setzero_v2r8();
584         fiz0             = _fjsp_setzero_v2r8();
585         fix1             = _fjsp_setzero_v2r8();
586         fiy1             = _fjsp_setzero_v2r8();
587         fiz1             = _fjsp_setzero_v2r8();
588         fix2             = _fjsp_setzero_v2r8();
589         fiy2             = _fjsp_setzero_v2r8();
590         fiz2             = _fjsp_setzero_v2r8();
591
592         /* Start inner kernel loop */
593         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
594         {
595
596             /* Get j neighbor index, and coordinate index */
597             jnrA             = jjnr[jidx];
598             jnrB             = jjnr[jidx+1];
599             j_coord_offsetA  = DIM*jnrA;
600             j_coord_offsetB  = DIM*jnrB;
601
602             /* load j atom coordinates */
603             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
604                                               &jx0,&jy0,&jz0);
605
606             /* Calculate displacement vector */
607             dx00             = _fjsp_sub_v2r8(ix0,jx0);
608             dy00             = _fjsp_sub_v2r8(iy0,jy0);
609             dz00             = _fjsp_sub_v2r8(iz0,jz0);
610             dx10             = _fjsp_sub_v2r8(ix1,jx0);
611             dy10             = _fjsp_sub_v2r8(iy1,jy0);
612             dz10             = _fjsp_sub_v2r8(iz1,jz0);
613             dx20             = _fjsp_sub_v2r8(ix2,jx0);
614             dy20             = _fjsp_sub_v2r8(iy2,jy0);
615             dz20             = _fjsp_sub_v2r8(iz2,jz0);
616
617             /* Calculate squared distance and things based on it */
618             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
619             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
620             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
621
622             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
623             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
624             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
625
626             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
627             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
628             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
629
630             /* Load parameters for j particles */
631             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
632             vdwjidx0A        = 2*vdwtype[jnrA+0];
633             vdwjidx0B        = 2*vdwtype[jnrB+0];
634
635             fjx0             = _fjsp_setzero_v2r8();
636             fjy0             = _fjsp_setzero_v2r8();
637             fjz0             = _fjsp_setzero_v2r8();
638
639             /**************************
640              * CALCULATE INTERACTIONS *
641              **************************/
642
643             /* Compute parameters for interactions between i and j atoms */
644             qq00             = _fjsp_mul_v2r8(iq0,jq0);
645             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
646                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
647
648             /* REACTION-FIELD ELECTROSTATICS */
649             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
650
651             /* LENNARD-JONES DISPERSION/REPULSION */
652
653             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
654             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
655
656             fscal            = _fjsp_add_v2r8(felec,fvdw);
657
658             /* Update vectorial force */
659             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
660             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
661             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
662             
663             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
664             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
665             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
666
667             /**************************
668              * CALCULATE INTERACTIONS *
669              **************************/
670
671             /* Compute parameters for interactions between i and j atoms */
672             qq10             = _fjsp_mul_v2r8(iq1,jq0);
673
674             /* REACTION-FIELD ELECTROSTATICS */
675             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
676
677             fscal            = felec;
678
679             /* Update vectorial force */
680             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
681             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
682             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
683             
684             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
685             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
686             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
687
688             /**************************
689              * CALCULATE INTERACTIONS *
690              **************************/
691
692             /* Compute parameters for interactions between i and j atoms */
693             qq20             = _fjsp_mul_v2r8(iq2,jq0);
694
695             /* REACTION-FIELD ELECTROSTATICS */
696             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
697
698             fscal            = felec;
699
700             /* Update vectorial force */
701             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
702             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
703             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
704             
705             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
706             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
707             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
708
709             gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
710
711             /* Inner loop uses 100 flops */
712         }
713
714         if(jidx<j_index_end)
715         {
716
717             jnrA             = jjnr[jidx];
718             j_coord_offsetA  = DIM*jnrA;
719
720             /* load j atom coordinates */
721             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
722                                               &jx0,&jy0,&jz0);
723
724             /* Calculate displacement vector */
725             dx00             = _fjsp_sub_v2r8(ix0,jx0);
726             dy00             = _fjsp_sub_v2r8(iy0,jy0);
727             dz00             = _fjsp_sub_v2r8(iz0,jz0);
728             dx10             = _fjsp_sub_v2r8(ix1,jx0);
729             dy10             = _fjsp_sub_v2r8(iy1,jy0);
730             dz10             = _fjsp_sub_v2r8(iz1,jz0);
731             dx20             = _fjsp_sub_v2r8(ix2,jx0);
732             dy20             = _fjsp_sub_v2r8(iy2,jy0);
733             dz20             = _fjsp_sub_v2r8(iz2,jz0);
734
735             /* Calculate squared distance and things based on it */
736             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
737             rsq10            = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
738             rsq20            = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
739
740             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
741             rinv10           = gmx_fjsp_invsqrt_v2r8(rsq10);
742             rinv20           = gmx_fjsp_invsqrt_v2r8(rsq20);
743
744             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
745             rinvsq10         = _fjsp_mul_v2r8(rinv10,rinv10);
746             rinvsq20         = _fjsp_mul_v2r8(rinv20,rinv20);
747
748             /* Load parameters for j particles */
749             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
750             vdwjidx0A        = 2*vdwtype[jnrA+0];
751
752             fjx0             = _fjsp_setzero_v2r8();
753             fjy0             = _fjsp_setzero_v2r8();
754             fjz0             = _fjsp_setzero_v2r8();
755
756             /**************************
757              * CALCULATE INTERACTIONS *
758              **************************/
759
760             /* Compute parameters for interactions between i and j atoms */
761             qq00             = _fjsp_mul_v2r8(iq0,jq0);
762             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
763
764             /* REACTION-FIELD ELECTROSTATICS */
765             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
766
767             /* LENNARD-JONES DISPERSION/REPULSION */
768
769             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
770             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
771
772             fscal            = _fjsp_add_v2r8(felec,fvdw);
773
774             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
775
776             /* Update vectorial force */
777             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
778             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
779             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
780             
781             fjx0             = _fjsp_madd_v2r8(dx00,fscal,fjx0);
782             fjy0             = _fjsp_madd_v2r8(dy00,fscal,fjy0);
783             fjz0             = _fjsp_madd_v2r8(dz00,fscal,fjz0);
784
785             /**************************
786              * CALCULATE INTERACTIONS *
787              **************************/
788
789             /* Compute parameters for interactions between i and j atoms */
790             qq10             = _fjsp_mul_v2r8(iq1,jq0);
791
792             /* REACTION-FIELD ELECTROSTATICS */
793             felec            = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
794
795             fscal            = felec;
796
797             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
798
799             /* Update vectorial force */
800             fix1             = _fjsp_madd_v2r8(dx10,fscal,fix1);
801             fiy1             = _fjsp_madd_v2r8(dy10,fscal,fiy1);
802             fiz1             = _fjsp_madd_v2r8(dz10,fscal,fiz1);
803             
804             fjx0             = _fjsp_madd_v2r8(dx10,fscal,fjx0);
805             fjy0             = _fjsp_madd_v2r8(dy10,fscal,fjy0);
806             fjz0             = _fjsp_madd_v2r8(dz10,fscal,fjz0);
807
808             /**************************
809              * CALCULATE INTERACTIONS *
810              **************************/
811
812             /* Compute parameters for interactions between i and j atoms */
813             qq20             = _fjsp_mul_v2r8(iq2,jq0);
814
815             /* REACTION-FIELD ELECTROSTATICS */
816             felec            = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
817
818             fscal            = felec;
819
820             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
821
822             /* Update vectorial force */
823             fix2             = _fjsp_madd_v2r8(dx20,fscal,fix2);
824             fiy2             = _fjsp_madd_v2r8(dy20,fscal,fiy2);
825             fiz2             = _fjsp_madd_v2r8(dz20,fscal,fiz2);
826             
827             fjx0             = _fjsp_madd_v2r8(dx20,fscal,fjx0);
828             fjy0             = _fjsp_madd_v2r8(dy20,fscal,fjy0);
829             fjz0             = _fjsp_madd_v2r8(dz20,fscal,fjz0);
830
831             gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
832
833             /* Inner loop uses 100 flops */
834         }
835
836         /* End of innermost loop */
837
838         gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
839                                               f+i_coord_offset,fshift+i_shift_offset);
840
841         /* Increment number of inner iterations */
842         inneriter                  += j_index_end - j_index_start;
843
844         /* Outer loop uses 18 flops */
845     }
846
847     /* Increment number of outer iterations */
848     outeriter        += nri;
849
850     /* Update outer/inner flops */
851
852     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);
853 }