HPCToolkit
monitor.c File Reference
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <signal.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <dlfcn.h>
#include <pthread.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <include/hpctoolkit-config.h>
#include <include/uint.h>
#include <include/min-max.h>
#include "monitor.h"
#include "hpcrun.h"
#include "hpcpapi.h"
#include "rtmap.h"
#include <lib/prof-lean/hpcio.h>
Include dependency graph for monitor.c:

Go to the source code of this file.

Macros

#define OPEN_OUTPUTFILE_AT_BEG   1
 

Typedefs

typedef uint32_t hpc_hist_bucket
 

Functions

static void hpcrun_sighandler (int sig)
 
static void init_option_debug ()
 
static void init_options ()
 
void init_library ()
 
void fini_library ()
 
static void count_events (uint *sysEvents, uint *papiEvents)
 
static void init_profdesc (hpcrun_profiles_desc_t **profdesc, uint numSysEv, uint numPapiEv, rtloadmap_t *rtmap, hpcrun_profiles_desc_t *sharedprofdesc)
 
static void init_sysprofdesc_buffer (hpcsys_profile_desc_vec_t *profdesc, uint numEv, rtloadmap_t *rtmap, hpcsys_profile_desc_vec_t *sharedprofdesc)
 
static void append_sysprofdesc_buffer (hpcsys_profile_desc_vec_t *profdesc, uint numEv, rtloadmap_t *rtmap, hpcsys_profile_desc_vec_t *sharedprofdesc)
 
static void init_papiprofdesc_buffer (hpcpapi_profile_desc_vec_t *profdesc, uint numEv, rtloadmap_t *rtmap, hpcpapi_profile_desc_vec_t *sharedprofdesc)
 
static void append_papiprofdesc_buffer (hpcpapi_profile_desc_vec_t *profdesc, uint numEv, rtloadmap_t *rtmap, hpcpapi_profile_desc_vec_t *sharedprofdesc)
 
static void init_profdesc_ofile (hpcrun_profiles_desc_t *profdesc, int sharedprofdesc)
 
static void notify_ofile (hpcrun_profiles_desc_t *profdesc, hpcrun_profiles_desc_t *sharedprofdesc)
 
static void add_sysevent (hpcsys_profile_desc_vec_t *profdescs, rtloadmap_t *rtmap, int profidx, char *eventnm, uint64_t period)
 
static void start_sysprof (hpcsys_profile_desc_vec_t *profdescs)
 
static void init_papi_for_process ()
 
static void add_papievent (hpcpapi_profile_desc_vec_t *profdescs, rtloadmap_t *rtmap, int profidx, char *eventnm, uint64_t period)
 
static void start_papi_for_thread (hpcpapi_profile_desc_vec_t *profdescs)
 
static void init_sighandlers ()
 
static void stop_sysprof (hpcsys_profile_desc_vec_t *profdescs)
 
static void stop_papi_for_thread (hpcpapi_profile_desc_vec_t *profdescs)
 
void init_process ()
 
void handle_dlopen ()
 
hpcrun_profiles_desc_tinit_thread (int is_thread)
 
static int get_next_gen (const char *path)
 
static void init_sighandler (int sig)
 
static void write_all_profiles (hpcrun_profiles_desc_t *profdesc, rtloadmap_t *rtmap)
 
static void fini_papi_for_thread (hpcpapi_profile_desc_vec_t *profdescs)
 
static void fini_papi_for_process ()
 
static void fini_profdesc (hpcrun_profiles_desc_t **profdesc, int sharedprofdesc)
 
void fini_process ()
 
void fini_thread (hpcrun_profiles_desc_t **profdesc, int is_thread)
 
static void write_module_profile (FILE *fp, rtloadmod_desc_t *mod, hpcrun_profiles_desc_t *profdesc, int sprofidx)
 
static void write_event_hdr (FILE *fs, char *name, char *desc, uint64_t period)
 
static void write_sysevent_data (FILE *fs, hpcsys_profile_desc_t *prof, int sprofidx)
 
static void write_papievent_data (FILE *fp, hpcpapi_profile_desc_t *prof, int sprofidx)
 
static void write_event_data (FILE *fs, char *ename, hpc_hist_bucket *histo, uint64_t ncounters, uint bytesPerCodeBlk)
 
static void write_string (FILE *fp, char *str)
 
long hpcrun_gettid ()
 
void hpcrun_parse_execl (const char ***argv, const char *const **envp, const char *arg, va_list arglist)
 

Variables

static const uint64_t default_period = 999999
 
int opt_debug = 0
 
int opt_recursive = 0
 
hpc_threadprof_t opt_thread = HPCRUN_THREADPROF_EACH
 
char * opt_eventlist = NULL
 
char opt_outpath [PATH_MAX] = ""
 
char opt_prefix [PATH_MAX] = ""
 
char opt_file [PATH_MAX] = ""
 
int opt_flagscode = 0
 
const char * hpcrun_cmd = NULL
 
static rtloadmap_trtloadmap = NULL
 
static uint numSysEvents = 0
 
static uint numPAPIEvents = 0
 
static hpcrun_profiles_desc_thpc_profdesc = NULL
 
static int domain = 0
 
volatile int DEBUGGER_WAIT = 1
 

Macro Definition Documentation

◆ OPEN_OUTPUTFILE_AT_BEG

#define OPEN_OUTPUTFILE_AT_BEG   1

Definition at line 151 of file monitor.c.

Typedef Documentation

◆ hpc_hist_bucket

typedef uint32_t hpc_hist_bucket

Definition at line 111 of file monitor.c.

Function Documentation

◆ add_papievent()

static void add_papievent ( hpcpapi_profile_desc_vec_t profdescs,
rtloadmap_t rtmap,
int  profidx,
char *  eventnm,
uint64_t  period 
)
static

Definition at line 1271 of file monitor.c.

Here is the caller graph for this function:

◆ add_sysevent()

static void add_sysevent ( hpcsys_profile_desc_vec_t profdescs,
rtloadmap_t rtmap,
int  profidx,
char *  eventnm,
uint64_t  period 
)
static

Definition at line 1151 of file monitor.c.

Here is the caller graph for this function:

◆ append_papiprofdesc_buffer()

static void append_papiprofdesc_buffer ( hpcpapi_profile_desc_vec_t profdesc,
uint  numEv,
rtloadmap_t rtmap,
hpcpapi_profile_desc_vec_t sharedprofdesc 
)
static

Definition at line 953 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_sysprofdesc_buffer()

static void append_sysprofdesc_buffer ( hpcsys_profile_desc_vec_t profdesc,
uint  numEv,
rtloadmap_t rtmap,
hpcsys_profile_desc_vec_t sharedprofdesc 
)
static

Definition at line 825 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count_events()

static void count_events ( uint sysEvents,
uint papiEvents 
)
static

Definition at line 548 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fini_library()

void fini_library ( )

Definition at line 183 of file monitor.c.

Here is the caller graph for this function:

◆ fini_papi_for_process()

static void fini_papi_for_process ( )
static

Definition at line 1595 of file monitor.c.

Here is the caller graph for this function:

◆ fini_papi_for_thread()

static void fini_papi_for_thread ( hpcpapi_profile_desc_vec_t profdescs)
static

Definition at line 1570 of file monitor.c.

Here is the caller graph for this function:

◆ fini_process()

void fini_process ( )

Definition at line 1466 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fini_profdesc()

static void fini_profdesc ( hpcrun_profiles_desc_t **  profdesc,
int  sharedprofdesc 
)
static

Definition at line 1602 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fini_thread()

void fini_thread ( hpcrun_profiles_desc_t **  profdesc,
int  is_thread 
)

Definition at line 1491 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_next_gen()

static int get_next_gen ( const char *  path)
static

Definition at line 1021 of file monitor.c.

Here is the caller graph for this function:

◆ handle_dlopen()

void handle_dlopen ( )

Definition at line 455 of file monitor.c.

Here is the call graph for this function:

◆ hpcrun_gettid()

long hpcrun_gettid ( )

Definition at line 1864 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_parse_execl()

void hpcrun_parse_execl ( const char ***  argv,
const char *const **  envp,
const char *  arg,
va_list  arglist 
)

Definition at line 1874 of file monitor.c.

Here is the call graph for this function:

◆ hpcrun_sighandler()

static void hpcrun_sighandler ( int  sig)
static

Definition at line 327 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_library()

void init_library ( )

Definition at line 164 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_option_debug()

static void init_option_debug ( )
static

Definition at line 197 of file monitor.c.

Here is the caller graph for this function:

◆ init_options()

static void init_options ( )
static

Definition at line 206 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_papi_for_process()

static void init_papi_for_process ( )
static

Definition at line 1232 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_papiprofdesc_buffer()

static void init_papiprofdesc_buffer ( hpcpapi_profile_desc_vec_t profdesc,
uint  numEv,
rtloadmap_t rtmap,
hpcpapi_profile_desc_vec_t sharedprofdesc 
)
static

Definition at line 886 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_process()

void init_process ( )

Definition at line 430 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_profdesc()

static void init_profdesc ( hpcrun_profiles_desc_t **  profdesc,
uint  numSysEv,
uint  numPapiEv,
rtloadmap_t rtmap,
hpcrun_profiles_desc_t sharedprofdesc 
)
static

Definition at line 576 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_profdesc_ofile()

static void init_profdesc_ofile ( hpcrun_profiles_desc_t profdesc,
int  sharedprofdesc 
)
static

Definition at line 1039 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_sighandler()

static void init_sighandler ( int  sig)
static

Definition at line 1436 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_sighandlers()

static void init_sighandlers ( )
static

Definition at line 1428 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_sysprofdesc_buffer()

static void init_sysprofdesc_buffer ( hpcsys_profile_desc_vec_t profdesc,
uint  numEv,
rtloadmap_t rtmap,
hpcsys_profile_desc_vec_t sharedprofdesc 
)
static

Definition at line 761 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_thread()

hpcrun_profiles_desc_t* init_thread ( int  is_thread)

Definition at line 510 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_ofile()

static void notify_ofile ( hpcrun_profiles_desc_t profdesc,
hpcrun_profiles_desc_t sharedprofdesc 
)
static

Definition at line 1135 of file monitor.c.

Here is the caller graph for this function:

◆ start_papi_for_thread()

static void start_papi_for_thread ( hpcpapi_profile_desc_vec_t profdescs)
static

Definition at line 1389 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_sysprof()

static void start_sysprof ( hpcsys_profile_desc_vec_t profdescs)
static

Definition at line 1215 of file monitor.c.

Here is the caller graph for this function:

◆ stop_papi_for_thread()

static void stop_papi_for_thread ( hpcpapi_profile_desc_vec_t profdescs)
static

Definition at line 1546 of file monitor.c.

Here is the caller graph for this function:

◆ stop_sysprof()

static void stop_sysprof ( hpcsys_profile_desc_vec_t profdescs)
static

Definition at line 1531 of file monitor.c.

Here is the caller graph for this function:

◆ write_all_profiles()

static void write_all_profiles ( hpcrun_profiles_desc_t profdesc,
rtloadmap_t rtmap 
)
static

Definition at line 1684 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_event_data()

static void write_event_data ( FILE *  fs,
char *  ename,
hpc_hist_bucket histo,
uint64_t  ncounters,
uint  bytesPerCodeBlk 
)
static

Definition at line 1814 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_event_hdr()

static void write_event_hdr ( FILE *  fs,
char *  name,
char *  desc,
uint64_t  period 
)
static

Definition at line 1775 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_module_profile()

static void write_module_profile ( FILE *  fp,
rtloadmod_desc_t mod,
hpcrun_profiles_desc_t profdesc,
int  sprofidx 
)
static

Definition at line 1730 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_papievent_data()

static void write_papievent_data ( FILE *  fp,
hpcpapi_profile_desc_t prof,
int  sprofidx 
)
static

Definition at line 1797 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_string()

static void write_string ( FILE *  fp,
char *  str 
)
static

Definition at line 1850 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_sysevent_data()

static void write_sysevent_data ( FILE *  fs,
hpcsys_profile_desc_t prof,
int  sprofidx 
)
static

Definition at line 1785 of file monitor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ DEBUGGER_WAIT

volatile int DEBUGGER_WAIT = 1

Definition at line 424 of file monitor.c.

◆ default_period

const uint64_t default_period = 999999
static

Definition at line 113 of file monitor.c.

◆ domain

int domain = 0
static

Definition at line 149 of file monitor.c.

◆ hpc_profdesc

hpcrun_profiles_desc_t* hpc_profdesc = NULL
static

Definition at line 146 of file monitor.c.

◆ hpcrun_cmd

const char* hpcrun_cmd = NULL

Definition at line 136 of file monitor.c.

◆ numPAPIEvents

uint numPAPIEvents = 0
static

Definition at line 141 of file monitor.c.

◆ numSysEvents

uint numSysEvents = 0
static

Definition at line 140 of file monitor.c.

◆ opt_debug

int opt_debug = 0

Definition at line 126 of file monitor.c.

◆ opt_eventlist

char* opt_eventlist = NULL

Definition at line 129 of file monitor.c.

◆ opt_file

char opt_file[PATH_MAX] = ""

Definition at line 132 of file monitor.c.

◆ opt_flagscode

int opt_flagscode = 0

Definition at line 133 of file monitor.c.

◆ opt_outpath

char opt_outpath[PATH_MAX] = ""

Definition at line 130 of file monitor.c.

◆ opt_prefix

char opt_prefix[PATH_MAX] = ""

Definition at line 131 of file monitor.c.

◆ opt_recursive

int opt_recursive = 0

Definition at line 127 of file monitor.c.

◆ opt_thread

Definition at line 128 of file monitor.c.

◆ rtloadmap

rtloadmap_t* rtloadmap = NULL
static

Definition at line 139 of file monitor.c.