Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRF_VdwNone_GeomP1P1_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/legacyheaders/vec.h"
47 #include "nrnb.h"
48
49 #include "kernelutil_sparc64_hpc_ace_double.h"
50
51 /*
52  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomP1P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: ReactionField
54  * VdW interaction:            None
55  * Geometry:                   Particle-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecRF_VdwNone_GeomP1P1_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              vdwjidx0A,vdwjidx0B;
84     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
85     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
87     real             *charge;
88     _fjsp_v2r8       itab_tmp;
89     _fjsp_v2r8       dummy_mask,cutoff_mask;
90     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
91     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
92     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
93
94     x                = xx[0];
95     f                = ff[0];
96
97     nri              = nlist->nri;
98     iinr             = nlist->iinr;
99     jindex           = nlist->jindex;
100     jjnr             = nlist->jjnr;
101     shiftidx         = nlist->shift;
102     gid              = nlist->gid;
103     shiftvec         = fr->shift_vec[0];
104     fshift           = fr->fshift[0];
105     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
106     charge           = mdatoms->chargeA;
107     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
108     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
109     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
110
111     /* Avoid stupid compiler warnings */
112     jnrA = jnrB = 0;
113     j_coord_offsetA = 0;
114     j_coord_offsetB = 0;
115
116     outeriter        = 0;
117     inneriter        = 0;
118
119     /* Start outer loop over neighborlists */
120     for(iidx=0; iidx<nri; iidx++)
121     {
122         /* Load shift vector for this list */
123         i_shift_offset   = DIM*shiftidx[iidx];
124
125         /* Load limits for loop over neighbors */
126         j_index_start    = jindex[iidx];
127         j_index_end      = jindex[iidx+1];
128
129         /* Get outer coordinate index */
130         inr              = iinr[iidx];
131         i_coord_offset   = DIM*inr;
132
133         /* Load i particle coords and add shift vector */
134         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
135
136         fix0             = _fjsp_setzero_v2r8();
137         fiy0             = _fjsp_setzero_v2r8();
138         fiz0             = _fjsp_setzero_v2r8();
139
140         /* Load parameters for i particles */
141         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
142
143         /* Reset potential sums */
144         velecsum         = _fjsp_setzero_v2r8();
145
146         /* Start inner kernel loop */
147         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
148         {
149
150             /* Get j neighbor index, and coordinate index */
151             jnrA             = jjnr[jidx];
152             jnrB             = jjnr[jidx+1];
153             j_coord_offsetA  = DIM*jnrA;
154             j_coord_offsetB  = DIM*jnrB;
155
156             /* load j atom coordinates */
157             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
158                                               &jx0,&jy0,&jz0);
159
160             /* Calculate displacement vector */
161             dx00             = _fjsp_sub_v2r8(ix0,jx0);
162             dy00             = _fjsp_sub_v2r8(iy0,jy0);
163             dz00             = _fjsp_sub_v2r8(iz0,jz0);
164
165             /* Calculate squared distance and things based on it */
166             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
167
168             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
169
170             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
171
172             /* Load parameters for j particles */
173             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
174
175             /**************************
176              * CALCULATE INTERACTIONS *
177              **************************/
178
179             /* Compute parameters for interactions between i and j atoms */
180             qq00             = _fjsp_mul_v2r8(iq0,jq0);
181
182             /* REACTION-FIELD ELECTROSTATICS */
183             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
184             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
185
186             /* Update potential sum for this i atom from the interaction with this j atom. */
187             velecsum         = _fjsp_add_v2r8(velecsum,velec);
188
189             fscal            = felec;
190
191             /* Update vectorial force */
192             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
193             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
194             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
195             
196             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
197
198             /* Inner loop uses 35 flops */
199         }
200
201         if(jidx<j_index_end)
202         {
203
204             jnrA             = jjnr[jidx];
205             j_coord_offsetA  = DIM*jnrA;
206
207             /* load j atom coordinates */
208             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
209                                               &jx0,&jy0,&jz0);
210
211             /* Calculate displacement vector */
212             dx00             = _fjsp_sub_v2r8(ix0,jx0);
213             dy00             = _fjsp_sub_v2r8(iy0,jy0);
214             dz00             = _fjsp_sub_v2r8(iz0,jz0);
215
216             /* Calculate squared distance and things based on it */
217             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
218
219             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
220
221             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
222
223             /* Load parameters for j particles */
224             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
225
226             /**************************
227              * CALCULATE INTERACTIONS *
228              **************************/
229
230             /* Compute parameters for interactions between i and j atoms */
231             qq00             = _fjsp_mul_v2r8(iq0,jq0);
232
233             /* REACTION-FIELD ELECTROSTATICS */
234             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
235             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
236
237             /* Update potential sum for this i atom from the interaction with this j atom. */
238             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
239             velecsum         = _fjsp_add_v2r8(velecsum,velec);
240
241             fscal            = felec;
242
243             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
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             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
251
252             /* Inner loop uses 35 flops */
253         }
254
255         /* End of innermost loop */
256
257         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
258                                               f+i_coord_offset,fshift+i_shift_offset);
259
260         ggid                        = gid[iidx];
261         /* Update potential energies */
262         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
263
264         /* Increment number of inner iterations */
265         inneriter                  += j_index_end - j_index_start;
266
267         /* Outer loop uses 8 flops */
268     }
269
270     /* Increment number of outer iterations */
271     outeriter        += nri;
272
273     /* Update outer/inner flops */
274
275     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*35);
276 }
277 /*
278  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
279  * Electrostatics interaction: ReactionField
280  * VdW interaction:            None
281  * Geometry:                   Particle-Particle
282  * Calculate force/pot:        Force
283  */
284 void
285 nb_kernel_ElecRF_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
286                     (t_nblist                    * gmx_restrict       nlist,
287                      rvec                        * gmx_restrict          xx,
288                      rvec                        * gmx_restrict          ff,
289                      t_forcerec                  * gmx_restrict          fr,
290                      t_mdatoms                   * gmx_restrict     mdatoms,
291                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
292                      t_nrnb                      * gmx_restrict        nrnb)
293 {
294     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
295      * just 0 for non-waters.
296      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
297      * jnr indices corresponding to data put in the four positions in the SIMD register.
298      */
299     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
300     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
301     int              jnrA,jnrB;
302     int              j_coord_offsetA,j_coord_offsetB;
303     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
304     real             rcutoff_scalar;
305     real             *shiftvec,*fshift,*x,*f;
306     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
307     int              vdwioffset0;
308     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
309     int              vdwjidx0A,vdwjidx0B;
310     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
311     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
312     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
313     real             *charge;
314     _fjsp_v2r8       itab_tmp;
315     _fjsp_v2r8       dummy_mask,cutoff_mask;
316     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
317     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
318     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
319
320     x                = xx[0];
321     f                = ff[0];
322
323     nri              = nlist->nri;
324     iinr             = nlist->iinr;
325     jindex           = nlist->jindex;
326     jjnr             = nlist->jjnr;
327     shiftidx         = nlist->shift;
328     gid              = nlist->gid;
329     shiftvec         = fr->shift_vec[0];
330     fshift           = fr->fshift[0];
331     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
332     charge           = mdatoms->chargeA;
333     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
334     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
335     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
336
337     /* Avoid stupid compiler warnings */
338     jnrA = jnrB = 0;
339     j_coord_offsetA = 0;
340     j_coord_offsetB = 0;
341
342     outeriter        = 0;
343     inneriter        = 0;
344
345     /* Start outer loop over neighborlists */
346     for(iidx=0; iidx<nri; iidx++)
347     {
348         /* Load shift vector for this list */
349         i_shift_offset   = DIM*shiftidx[iidx];
350
351         /* Load limits for loop over neighbors */
352         j_index_start    = jindex[iidx];
353         j_index_end      = jindex[iidx+1];
354
355         /* Get outer coordinate index */
356         inr              = iinr[iidx];
357         i_coord_offset   = DIM*inr;
358
359         /* Load i particle coords and add shift vector */
360         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
361
362         fix0             = _fjsp_setzero_v2r8();
363         fiy0             = _fjsp_setzero_v2r8();
364         fiz0             = _fjsp_setzero_v2r8();
365
366         /* Load parameters for i particles */
367         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
368
369         /* Start inner kernel loop */
370         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
371         {
372
373             /* Get j neighbor index, and coordinate index */
374             jnrA             = jjnr[jidx];
375             jnrB             = jjnr[jidx+1];
376             j_coord_offsetA  = DIM*jnrA;
377             j_coord_offsetB  = DIM*jnrB;
378
379             /* load j atom coordinates */
380             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
381                                               &jx0,&jy0,&jz0);
382
383             /* Calculate displacement vector */
384             dx00             = _fjsp_sub_v2r8(ix0,jx0);
385             dy00             = _fjsp_sub_v2r8(iy0,jy0);
386             dz00             = _fjsp_sub_v2r8(iz0,jz0);
387
388             /* Calculate squared distance and things based on it */
389             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
390
391             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
392
393             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
394
395             /* Load parameters for j particles */
396             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
397
398             /**************************
399              * CALCULATE INTERACTIONS *
400              **************************/
401
402             /* Compute parameters for interactions between i and j atoms */
403             qq00             = _fjsp_mul_v2r8(iq0,jq0);
404
405             /* REACTION-FIELD ELECTROSTATICS */
406             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
407
408             fscal            = felec;
409
410             /* Update vectorial force */
411             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
412             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
413             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
414             
415             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
416
417             /* Inner loop uses 30 flops */
418         }
419
420         if(jidx<j_index_end)
421         {
422
423             jnrA             = jjnr[jidx];
424             j_coord_offsetA  = DIM*jnrA;
425
426             /* load j atom coordinates */
427             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
428                                               &jx0,&jy0,&jz0);
429
430             /* Calculate displacement vector */
431             dx00             = _fjsp_sub_v2r8(ix0,jx0);
432             dy00             = _fjsp_sub_v2r8(iy0,jy0);
433             dz00             = _fjsp_sub_v2r8(iz0,jz0);
434
435             /* Calculate squared distance and things based on it */
436             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
437
438             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
439
440             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
441
442             /* Load parameters for j particles */
443             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
444
445             /**************************
446              * CALCULATE INTERACTIONS *
447              **************************/
448
449             /* Compute parameters for interactions between i and j atoms */
450             qq00             = _fjsp_mul_v2r8(iq0,jq0);
451
452             /* REACTION-FIELD ELECTROSTATICS */
453             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
454
455             fscal            = felec;
456
457             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
458
459             /* Update vectorial force */
460             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
461             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
462             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
463             
464             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
465
466             /* Inner loop uses 30 flops */
467         }
468
469         /* End of innermost loop */
470
471         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
472                                               f+i_coord_offset,fshift+i_shift_offset);
473
474         /* Increment number of inner iterations */
475         inneriter                  += j_index_end - j_index_start;
476
477         /* Outer loop uses 7 flops */
478     }
479
480     /* Increment number of outer iterations */
481     outeriter        += nri;
482
483     /* Update outer/inner flops */
484
485     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*30);
486 }