Use full path for legacyheaders
[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 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomP1P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            None
53  * Geometry:                   Particle-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRF_VdwNone_GeomP1P1_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              vdwjidx0A,vdwjidx0B;
82     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
85     real             *charge;
86     _fjsp_v2r8       itab_tmp;
87     _fjsp_v2r8       dummy_mask,cutoff_mask;
88     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
89     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
90     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
91
92     x                = xx[0];
93     f                = ff[0];
94
95     nri              = nlist->nri;
96     iinr             = nlist->iinr;
97     jindex           = nlist->jindex;
98     jjnr             = nlist->jjnr;
99     shiftidx         = nlist->shift;
100     gid              = nlist->gid;
101     shiftvec         = fr->shift_vec[0];
102     fshift           = fr->fshift[0];
103     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
104     charge           = mdatoms->chargeA;
105     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
106     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
107     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
108
109     /* Avoid stupid compiler warnings */
110     jnrA = jnrB = 0;
111     j_coord_offsetA = 0;
112     j_coord_offsetB = 0;
113
114     outeriter        = 0;
115     inneriter        = 0;
116
117     /* Start outer loop over neighborlists */
118     for(iidx=0; iidx<nri; iidx++)
119     {
120         /* Load shift vector for this list */
121         i_shift_offset   = DIM*shiftidx[iidx];
122
123         /* Load limits for loop over neighbors */
124         j_index_start    = jindex[iidx];
125         j_index_end      = jindex[iidx+1];
126
127         /* Get outer coordinate index */
128         inr              = iinr[iidx];
129         i_coord_offset   = DIM*inr;
130
131         /* Load i particle coords and add shift vector */
132         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
133
134         fix0             = _fjsp_setzero_v2r8();
135         fiy0             = _fjsp_setzero_v2r8();
136         fiz0             = _fjsp_setzero_v2r8();
137
138         /* Load parameters for i particles */
139         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
140
141         /* Reset potential sums */
142         velecsum         = _fjsp_setzero_v2r8();
143
144         /* Start inner kernel loop */
145         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
146         {
147
148             /* Get j neighbor index, and coordinate index */
149             jnrA             = jjnr[jidx];
150             jnrB             = jjnr[jidx+1];
151             j_coord_offsetA  = DIM*jnrA;
152             j_coord_offsetB  = DIM*jnrB;
153
154             /* load j atom coordinates */
155             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
156                                               &jx0,&jy0,&jz0);
157
158             /* Calculate displacement vector */
159             dx00             = _fjsp_sub_v2r8(ix0,jx0);
160             dy00             = _fjsp_sub_v2r8(iy0,jy0);
161             dz00             = _fjsp_sub_v2r8(iz0,jz0);
162
163             /* Calculate squared distance and things based on it */
164             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
165
166             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
167
168             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
169
170             /* Load parameters for j particles */
171             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
172
173             /**************************
174              * CALCULATE INTERACTIONS *
175              **************************/
176
177             /* Compute parameters for interactions between i and j atoms */
178             qq00             = _fjsp_mul_v2r8(iq0,jq0);
179
180             /* REACTION-FIELD ELECTROSTATICS */
181             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
182             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
183
184             /* Update potential sum for this i atom from the interaction with this j atom. */
185             velecsum         = _fjsp_add_v2r8(velecsum,velec);
186
187             fscal            = felec;
188
189             /* Update vectorial force */
190             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
191             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
192             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
193             
194             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
195
196             /* Inner loop uses 35 flops */
197         }
198
199         if(jidx<j_index_end)
200         {
201
202             jnrA             = jjnr[jidx];
203             j_coord_offsetA  = DIM*jnrA;
204
205             /* load j atom coordinates */
206             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
207                                               &jx0,&jy0,&jz0);
208
209             /* Calculate displacement vector */
210             dx00             = _fjsp_sub_v2r8(ix0,jx0);
211             dy00             = _fjsp_sub_v2r8(iy0,jy0);
212             dz00             = _fjsp_sub_v2r8(iz0,jz0);
213
214             /* Calculate squared distance and things based on it */
215             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
216
217             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
218
219             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
220
221             /* Load parameters for j particles */
222             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
223
224             /**************************
225              * CALCULATE INTERACTIONS *
226              **************************/
227
228             /* Compute parameters for interactions between i and j atoms */
229             qq00             = _fjsp_mul_v2r8(iq0,jq0);
230
231             /* REACTION-FIELD ELECTROSTATICS */
232             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
233             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
234
235             /* Update potential sum for this i atom from the interaction with this j atom. */
236             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
237             velecsum         = _fjsp_add_v2r8(velecsum,velec);
238
239             fscal            = felec;
240
241             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
242
243             /* Update vectorial force */
244             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
245             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
246             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
247             
248             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
249
250             /* Inner loop uses 35 flops */
251         }
252
253         /* End of innermost loop */
254
255         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
256                                               f+i_coord_offset,fshift+i_shift_offset);
257
258         ggid                        = gid[iidx];
259         /* Update potential energies */
260         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
261
262         /* Increment number of inner iterations */
263         inneriter                  += j_index_end - j_index_start;
264
265         /* Outer loop uses 8 flops */
266     }
267
268     /* Increment number of outer iterations */
269     outeriter        += nri;
270
271     /* Update outer/inner flops */
272
273     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*35);
274 }
275 /*
276  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
277  * Electrostatics interaction: ReactionField
278  * VdW interaction:            None
279  * Geometry:                   Particle-Particle
280  * Calculate force/pot:        Force
281  */
282 void
283 nb_kernel_ElecRF_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
284                     (t_nblist                    * gmx_restrict       nlist,
285                      rvec                        * gmx_restrict          xx,
286                      rvec                        * gmx_restrict          ff,
287                      t_forcerec                  * gmx_restrict          fr,
288                      t_mdatoms                   * gmx_restrict     mdatoms,
289                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
290                      t_nrnb                      * gmx_restrict        nrnb)
291 {
292     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
293      * just 0 for non-waters.
294      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
295      * jnr indices corresponding to data put in the four positions in the SIMD register.
296      */
297     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
298     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
299     int              jnrA,jnrB;
300     int              j_coord_offsetA,j_coord_offsetB;
301     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
302     real             rcutoff_scalar;
303     real             *shiftvec,*fshift,*x,*f;
304     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
305     int              vdwioffset0;
306     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
307     int              vdwjidx0A,vdwjidx0B;
308     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
309     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
310     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
311     real             *charge;
312     _fjsp_v2r8       itab_tmp;
313     _fjsp_v2r8       dummy_mask,cutoff_mask;
314     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
315     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
316     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
317
318     x                = xx[0];
319     f                = ff[0];
320
321     nri              = nlist->nri;
322     iinr             = nlist->iinr;
323     jindex           = nlist->jindex;
324     jjnr             = nlist->jjnr;
325     shiftidx         = nlist->shift;
326     gid              = nlist->gid;
327     shiftvec         = fr->shift_vec[0];
328     fshift           = fr->fshift[0];
329     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
330     charge           = mdatoms->chargeA;
331     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
332     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
333     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
334
335     /* Avoid stupid compiler warnings */
336     jnrA = jnrB = 0;
337     j_coord_offsetA = 0;
338     j_coord_offsetB = 0;
339
340     outeriter        = 0;
341     inneriter        = 0;
342
343     /* Start outer loop over neighborlists */
344     for(iidx=0; iidx<nri; iidx++)
345     {
346         /* Load shift vector for this list */
347         i_shift_offset   = DIM*shiftidx[iidx];
348
349         /* Load limits for loop over neighbors */
350         j_index_start    = jindex[iidx];
351         j_index_end      = jindex[iidx+1];
352
353         /* Get outer coordinate index */
354         inr              = iinr[iidx];
355         i_coord_offset   = DIM*inr;
356
357         /* Load i particle coords and add shift vector */
358         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
359
360         fix0             = _fjsp_setzero_v2r8();
361         fiy0             = _fjsp_setzero_v2r8();
362         fiz0             = _fjsp_setzero_v2r8();
363
364         /* Load parameters for i particles */
365         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
366
367         /* Start inner kernel loop */
368         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
369         {
370
371             /* Get j neighbor index, and coordinate index */
372             jnrA             = jjnr[jidx];
373             jnrB             = jjnr[jidx+1];
374             j_coord_offsetA  = DIM*jnrA;
375             j_coord_offsetB  = DIM*jnrB;
376
377             /* load j atom coordinates */
378             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
379                                               &jx0,&jy0,&jz0);
380
381             /* Calculate displacement vector */
382             dx00             = _fjsp_sub_v2r8(ix0,jx0);
383             dy00             = _fjsp_sub_v2r8(iy0,jy0);
384             dz00             = _fjsp_sub_v2r8(iz0,jz0);
385
386             /* Calculate squared distance and things based on it */
387             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
388
389             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
390
391             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
392
393             /* Load parameters for j particles */
394             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
395
396             /**************************
397              * CALCULATE INTERACTIONS *
398              **************************/
399
400             /* Compute parameters for interactions between i and j atoms */
401             qq00             = _fjsp_mul_v2r8(iq0,jq0);
402
403             /* REACTION-FIELD ELECTROSTATICS */
404             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
405
406             fscal            = felec;
407
408             /* Update vectorial force */
409             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
410             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
411             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
412             
413             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
414
415             /* Inner loop uses 30 flops */
416         }
417
418         if(jidx<j_index_end)
419         {
420
421             jnrA             = jjnr[jidx];
422             j_coord_offsetA  = DIM*jnrA;
423
424             /* load j atom coordinates */
425             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
426                                               &jx0,&jy0,&jz0);
427
428             /* Calculate displacement vector */
429             dx00             = _fjsp_sub_v2r8(ix0,jx0);
430             dy00             = _fjsp_sub_v2r8(iy0,jy0);
431             dz00             = _fjsp_sub_v2r8(iz0,jz0);
432
433             /* Calculate squared distance and things based on it */
434             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
435
436             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
437
438             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
439
440             /* Load parameters for j particles */
441             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
442
443             /**************************
444              * CALCULATE INTERACTIONS *
445              **************************/
446
447             /* Compute parameters for interactions between i and j atoms */
448             qq00             = _fjsp_mul_v2r8(iq0,jq0);
449
450             /* REACTION-FIELD ELECTROSTATICS */
451             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
452
453             fscal            = felec;
454
455             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
456
457             /* Update vectorial force */
458             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
459             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
460             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
461             
462             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
463
464             /* Inner loop uses 30 flops */
465         }
466
467         /* End of innermost loop */
468
469         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
470                                               f+i_coord_offset,fshift+i_shift_offset);
471
472         /* Increment number of inner iterations */
473         inneriter                  += j_index_end - j_index_start;
474
475         /* Outer loop uses 7 flops */
476     }
477
478     /* Increment number of outer iterations */
479     outeriter        += nri;
480
481     /* Update outer/inner flops */
482
483     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*30);
484 }