static void hash_put_region(const char* name, const char* file, int lno, uint32_t rid) { uint32_t idx; HN_RegionT* add; /* -- get hash index -- */ idx = vt_hash(name, strlen(name), 0); if ( file ) { idx = vt_hash(file, strlen(file), idx); idx = vt_hashtriple(lno, 0, 0, idx); } idx &= (REGION_HASH_MAX - 1); /* -- allocate/initialize new hash entry -- */ add = (HN_RegionT*)calloc(1, sizeof(HN_RegionT)); if ( add == NULL ) vt_error(); add->name = strdup(name); if ( file ) { add->file = strdup(file); add->lno = lno; } add->rid = rid; /* -- insert new hash entry at calculated hash index -- */ add->next = htab_region[idx]; htab_region[idx] = add; }
static uint32_t hash_get_region(const char* name, const char* file, int lno) { uint32_t idx; HN_RegionT* curr; /* -- get hash index -- */ idx = vt_hash(name, strlen(name), 0); if ( file ) { idx = vt_hash(file, strlen(file), idx); idx = vt_hashtriple(lno, 0, 0, idx); } idx &= (REGION_HASH_MAX - 1); /* -- search for matching entry at calculated hash index -- */ curr = htab_region[idx]; while ( curr ) { if ( strcmp( curr->name, name ) == 0 ) { if ( ( !curr->file && !file ) || ( curr->file && file && strcmp( curr->file, file ) == 0 && curr->lno == lno ) ) { return curr->rid; } } curr = curr->next; } return VT_NO_ID; }
static void hash_put( const char* n, uint32_t i ) { uint32_t id = (uint32_t)vt_hash((uint8_t*)n, strlen(n), 0) % HASH_MAX; HashNode_file* add = (HashNode_file*)malloc(sizeof(HashNode_file)); add->fname = vt_strdup(n); add->fid = i; add->next = htab_mpifile[id]; htab_mpifile[id] = add; }
static HashNode_file* hash_get( const char* n ) { uint32_t id = (uint32_t)vt_hash((uint8_t*)n, strlen(n), 0) % HASH_MAX; HashNode_file* curr = htab_mpifile[id]; while ( curr ) { if ( strcmp( curr->fname, n ) == 0 ) { return curr; } curr = curr->next; } return NULL; }
static void cpath_regions_hash_put( RFG_FilterCallPathRegionHN** htab, const char* name, uint32_t id ) { uint32_t idx = vt_hash( name, strlen( name ), 0 ) & ( CPATH_REGIONS_HASH_MAX - 1 ); RFG_FilterCallPathRegionHN* add = (RFG_FilterCallPathRegionHN*)malloc( sizeof( RFG_FilterCallPathRegionHN ) ); add->name = strdup( name ); add->id = id; add->next = htab[idx]; htab[idx] = add; }
static RFG_FilterCallPathRegionHN* cpath_regions_hash_get( RFG_FilterCallPathRegionHN** htab, const char* name ) { uint32_t idx = vt_hash( name, strlen( name ), 0 ) & ( CPATH_REGIONS_HASH_MAX - 1 ); RFG_FilterCallPathRegionHN* curr = htab[idx]; while( curr ) { if( strcmp( curr->name , name ) == 0 ) return curr; curr = curr->next; } return NULL; }
/* platform specific initialization */ void vt_pform_init() { int pid = getpid(); char exec_proc[VT_PATH_MAX]; char exec[VT_PATH_MAX]; int exec_len; int hostid_retries; #if TIMER == TIMER_PAPI_REAL_USEC vt_time_base = vt_metric_real_usec(); #endif /* get full path of executable */ snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/path/a.out", pid); exec_len = readlink(exec_proc, exec, sizeof (exec)-1); if(exec_len != -1) { exec[exec_len] = '\0'; vt_exec = strdup(exec); } /* get unique numeric SMP-node identifier */ hostid_retries = 0; while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) { vt_node_id = gethostid(); } if (!vt_node_id) { vt_error_msg("Maximum retries (%i) for gethostid exceeded!", VT_MAX_GETHOSTID_RETRIES); } else { char* nodename = vt_pform_node_name(); vt_node_id = (long)vt_hash((uint8_t*)nodename, strlen(nodename), (uint32_t)vt_node_id); } }