src/pbe/pbedefs.h

Go to the documentation of this file.
00001 #ifndef _PBEDEFS_H
00002 #define _PBEDEFS_H
00003 
00004 /*        LAM                 MPICH                IBM         */
00005 #if defined(_MPI_H) || defined(_MPI_INCLUDE) || defined(_H_MPI)
00006 #  define _PBE_USE_MPI
00007 #endif /* defined(_MPI_H) || defined(_MPI_INCLUDE) */
00008 
00009 #if defined(POOMA_MPI)
00010 #  define _PBE_USE_MPI
00011 #  include <mpi.h>
00012 #endif
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 #include <assert.h>
00019 #include <sys/times.h>
00020 #include <stdlib.h>
00021 #include <time.h>
00022 #include <stdio.h>
00023 
00024 #ifndef CLK_TCK
00025 #  define CLK_TCK 100
00026 #endif
00027 
00028 /* Prototypes for functions inlined in pbe.h */
00029 int pbe_init(const char *name, int numofslots, int argparametercount, struct pbeparameter *argparameters);
00030 void pbe_dump();
00031 int pbe_finalize(int numofiterations);
00032 
00033 extern struct benchmark *pbe_data;
00034 
00035 typedef struct pbeparameter
00036 {
00037     char       name[80];
00038     char       shortname[3];
00039     int        value;
00040 }
00041 pbeparameter;
00042 
00043 typedef struct timer
00044 {
00045     char       name[80];
00046     int        counter;
00047     struct tms times[2];
00048     clock_t    realtimes[2];
00049 }
00050 timer;
00051 
00052 typedef struct benchmark
00053 {
00054     char                 name[80];
00055     int                  slots;
00056     struct timer        *timers;
00057     int                  have_mpi;
00058     int                  mpisize;
00059     int                  mpirank;
00060     struct pbeparameter *parameters;
00061     int                  parametercount;
00062 }
00063 benchmark;
00064 
00065 extern struct tms _tms_aid;
00066 extern struct benchmark *pbe_data;
00067 
00068 /*
00069   struct tms _tms_aid;
00070   struct benchmark *pbe_data; 
00071 */
00072 
00073 #define pbe_start_noname(handle) writestart_noname( (handle) )
00074 
00075 #define pbe_start(handle,parname) if (( (handle) >0) && ( (handle) <= pbe_data->slots)) writestart( (handle) , (parname) )
00076 
00077 #define pbe_stop(handle)          if (( (handle) >0) && ( (handle) <= pbe_data->slots)) writestop( (handle) )
00078 
00079 #define pbe_resetcounter(handle)  if (( (handle) >0) && ( (handle) <= pbe_data->slots))\
00080     { pbe_data->timers[(handle)].realtimes[1] = 0;         \
00081       pbe_data->timers[(handle)].times[1].tms_utime = 0;   \
00082       pbe_data->timers[(handle)].times[1].tms_stime = 0;   \
00083       pbe_data->timers[(handle)].times[1].tms_cutime = 0;  \
00084       pbe_data->timers[(handle)].times[1].tms_cstime = 0;  \
00085       pbe_data->timers[(handle)].counter = 0;              \
00086     }
00087 
00088 #define pbe_getrealtime(handle) (pbe_data->timers[(handle)].realtimes[1] / ((float) CLK_TCK))
00089 
00090 #define pbe_getsystime(handle)  ((pbe_data->timers[(handle)].times[1].tms_stime + \
00091                                       pbe_data->timers[(handle)].times[1].tms_cstime) \
00092                                       / ((float) CLK_TCK))
00093 #define pbe_getusrtime(handle)  ((pbe_data->timers[(handle)].times[1].tms_utime + \
00094                                       pbe_data->timers[(handle)].times[1].tms_cutime) \
00095                                       / ((float) CLK_TCK))
00096 #define pbe_getsysusrtime(handle) (pbe_getsystime(handle) + pbe_getusrtime(handle))
00097 
00098 #define pbe_getcounter(handle) (pbe_data->timers[handle].counter)
00099 
00100 #define writestart(handle,parname) { \
00101     if(parname!=NULL) {sprintf(pbe_data->timers[(handle)].name,"%s",(parname));}  \
00102     pbe_data->timers[(handle)].realtimes[0]=times(&(pbe_data->timers[(handle)].times[0])); }
00103 
00104 #define writestart_noname(handle) pbe_data->timers[(handle)].realtimes[0]=times(&(pbe_data->timers[(handle)].times[0]))
00105 
00106 #define writestop(handle) { \
00107     pbe_data->timers[(handle)].counter += 1; \
00108     pbe_data->timers[(handle)].realtimes[1]+=times(&_tms_aid) - pbe_data->timers[(handle)].realtimes[0]; \
00109     pbe_data->timers[(handle)].times[1].tms_utime += _tms_aid.tms_utime - pbe_data->timers[(handle)].times[0].tms_utime; \
00110     pbe_data->timers[(handle)].times[1].tms_stime += _tms_aid.tms_stime - pbe_data->timers[(handle)].times[0].tms_stime; \
00111     pbe_data->timers[(handle)].times[1].tms_cutime += _tms_aid.tms_cutime - pbe_data->timers[(handle)].times[0].tms_cutime; \
00112     pbe_data->timers[(handle)].times[1].tms_cstime += _tms_aid.tms_cstime - pbe_data->timers[(handle)].times[0].tms_cstime; }
00113 
00114 int pbe_init(const char *name, int numofslots, int argparametercount, struct pbeparameter *argparameters);
00115 int pbe_finalize(int numofiterations);
00116 
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 
00121 #endif /* not _PBEDEFS_H_ */

Generated on Fri Oct 26 13:35:12 2007 for FEMAXX (Finite Element Maxwell Eigensolver) by  doxygen 1.4.7