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