








































#define PROFILE_COMM_BUFFER_SIZE    4000
#define PROFILE_SSTEP_BUFFER_SIZE    100







#ifdef MPASS_EXPRESS
#define PROF_FILETYPE FILE*
#define PROF_DATETYPE int
#define prof_fopen(filename)   fopen(filename,"wA")
#define prof_freopen(filename) fopen(filename,"aA")
#define prof_fflush(fptr)      fflush(fptr)
#define prof_fclose(fptr)      fclose(fptr)
#define prof_datestring(clock) "date unknown\n"
#else

#define PROF_FILETYPE FILE*
#define PROF_DATETYPE          time_t
#define prof_fopen(filename)   fopen(filename,"w")
#define prof_freopen(filename) fopen(filename,"a")
#define prof_fflush(fptr)      fflush(fptr)
#define prof_fclose(fptr)      fclose(fptr)
#define prof_datestring(clock) (time(&clock), ctime(&clock))
#endif






typedef struct {
   int    super_steps;
   int    packet_puts_src;
   int    packet_puts_srcnbytes;
   int    packet_puts_dst;
   int    packet_puts_dstnbytes;
   int    buffer_high_water_mark;
   int    write_waits;
   int    read_waits;
   int    combput_fails;
   int    combput_hits;
 } _BSPstat_info;

extern _BSPstat_info _bspstat;







#ifdef CALLGRAPH_PROFILE
typedef struct {
   double     proc_comp;
   double     proc_comm;
   double     proc_idle;
   long int   proc_hin;
   long int   proc_hout;
} _BSPprof_callgraph_proc;
#endif

typedef struct __BSPprof_sstep_info {
   bsp_int32                    sstep_id;
   bsp_int32                    lineno;
   char                        *filename;
#ifdef CALLGRAPH_PROFILE
   char     **call_stack;
   bsp_int32  accum_syncs;
   double     accum_comp_max, accum_comp_avg, accum_comp_min;
   double     accum_comm_max, accum_comm_avg, accum_comm_min;
   double     accum_idle_max, accum_idle_avg, accum_idle_min;
   long int   accum_h_max,    accum_h_avg,    accum_h_min;
   _BSPprof_callgraph_proc *proc; /* Entry per process */
#endif
   struct __BSPprof_sstep_info *next;
} _BSPprof_sstep_info;

typedef int _BSPprof_sstep_id;





typedef struct {
  _BSPprof_sstep_id    sstep_id;
  double               time_delta_start;
  double               time_fix;
  double               time_delta_comm;
  double               time_delta_end;
  bsp_int32            in_bytes;
  bsp_int32            out_bytes;
  bsp_int32            no_in;
  bsp_int32            no_out;
} _BSPprof_comm_info;



extern void bspstat_init();
extern void bspstat_create();
extern void bspstat_truncate();
extern void bspstat_recreate();
extern void bspstat_close();
extern void bspstat_incoming(int,int);
extern void bspstat_updateremote();
extern void bspstat_finalise();
extern void bspprof_init();
extern void bspprof_create();
extern void bspprof_recreate();
extern void bspprof_truncate();
extern void bspprof_close();
extern void bspprof_sstep_start();
extern void bspprof_sstep_fix();
extern void bspprof_sstep_end();


