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