/* * Initialize Mutex, VampirTrace ids and registers the finalize function. * This may be done implicitly by vt_cupti_count(). */ void vt_cupti_init() { if(!vt_cupti_initialized){ #if (defined(VT_MT) || defined(VT_HYB)) VTThrd_createMutex(&VTThrdMutexCupti); #endif CUPTI_LOCK(); if(!vt_cupti_initialized){ vt_cntl_msg(2, "[CUPTI] Initializing ... "); /* create VampirTrace counter group ID only once */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif rid_cupti_init = vt_def_region(VT_MASTER_THREAD, "vtcuptiHostThreadInit", VT_NO_ID, VT_NO_LNO, VT_NO_LNO, "VT_CUPTI", VT_FUNCTION); cgid_cupti = vt_def_counter_group(VT_MASTER_THREAD, "CUPTI"); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif vt_cupti_capList = vt_cupti_setupMetricList(); /* register the finalize function of the CUDA wrapper to be called before * the program exits and CUDA has done its implicit clean-up */ atexit(vt_cupti_finalize); vt_cupti_initialized = 1; CUPTI_UNLOCK(); } } }
unsigned int VT_User_def__(const char* name, const char* file, int lno) { uint32_t rid; VT_INIT; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); /* -- get region identifier by name, file, and line number -- */ if ( (rid = hash_get_region(name, file, lno)) == VT_NO_ID ) { /* -- register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get_region(name, file, lno)) == VT_NO_ID ) rid = register_region(0, name, file, lno); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ rid = register_region(0, name, file, lno); #endif /* VT_MT || VT_HYB */ } VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); return rid; }
void VT_User_start__(const char* name, const char *file, int lno) { uint32_t rid; uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if ( vt_init ) { VT_MEMHOOKS_OFF(); vt_init = 0; vt_open(); VT_MEMHOOKS_ON(); } VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( (rid = hash_get((unsigned long) name)) == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get((unsigned long) name)) == VT_NO_ID ) rid = register_region(name, 0, file, lno); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ rid = register_region(name, 0, file, lno); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(&time, rid); VT_MEMHOOKS_ON(); }
void VT_User_start__(const char* name, const char* file, int lno) { uint32_t rid; uint64_t time; VT_INIT; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); time = vt_pform_wtime(); /* -- get region identifier by address -- */ if ( (rid = hash_get_addr((unsigned long)name)) == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get_addr((unsigned long)name)) == VT_NO_ID ) rid = register_region((unsigned long)name, name, file, lno); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ rid = register_region((unsigned long)name, name, file, lno); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, rid); VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); }
VT_DECLDEF(void __profile_loop(struct profile_gen_struct* d)) { uint64_t time; /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( d->data == NULL ) { /* -- loop entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( d->data == NULL ) register_region(d, VT_LOOP); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ register_region(d, VT_LOOP); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(&time, *((uint32_t*)(d->data))); VT_MEMHOOKS_ON(); }
void ___rouent2(struct s1 *p) { uint32_t tid; uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if (rou_init) { rou_init = 0; vt_open(); } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; /* -- get calling thread id -- */ GET_THREAD_ID(tid); VT_SUSPEND_MALLOC_TRACING(tid); time = vt_pform_wtime(); if (!p->isseen) { char* rname = p->rout; char* modpos; /* fix opari output file names */ if ( (modpos = strstr(p->file, ".mod.")) != NULL ) { strcpy(modpos, modpos+4); } #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if (!p->isseen) { p->fid = vt_def_scl_file(tid, p->file); p->rid = vt_def_region(tid, rname, p->fid, p->lineno, VT_NO_LNO, NULL, VT_FUNCTION); p->isseen = 1; } VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ p->fid = vt_def_scl_file(tid, p->file); p->rid = vt_def_region(tid, rname, p->fid, p->lineno, VT_NO_LNO, NULL, VT_FUNCTION); p->isseen = 1; #endif /* VT_MT || VT_HYB */ } /* write enter trace record */ vt_enter(tid, &time, p->rid); VT_RESUME_MALLOC_TRACING(tid); }
void VT_Dyn_start(uint32_t index, const char* name, const char* fname, uint32_t lno, uint32_t loop) { uint64_t time; uint32_t* rid; vt_libassert(index < VT_MAX_DYNINST_REGIONS); /* Ignore events if VT is initializing */ if( !dyn_init && !vt_is_alive ) return; /* If not yet initialized, initialize VampirTrace */ if ( dyn_init ) { VT_MEMHOOKS_OFF(); dyn_init = 0; rtab = (uint32_t*)calloc(VT_MAX_DYNINST_REGIONS, sizeof(uint32_t)); if ( rtab == NULL ) vt_error(); vt_open(); vt_comp_finalize = VT_Dyn_finalize; VT_MEMHOOKS_ON(); } /* If VampirTrace already finalized, return */ if ( !vt_is_alive ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* Get region identifier */ rid = &(rtab[index]); if ( *rid == 0 ) { /* If region entered the first time, register region */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( *rid == 0 ) *rid = register_region(name, fname, lno, loop); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ *rid = register_region(name, fname, lno, loop); #endif /* VT_MT || VT_HYB */ } /* Write enter record */ vt_enter(VT_CURRENT_THREAD, &time, *rid); VT_MEMHOOKS_ON(); }
void vt_win_create( MPI_Win win, MPI_Comm comm ) { MPI_Group group; /* check if window already exists */ if (win_search( win ) == (uint32_t)-1) { uint32_t wid; #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif /* VT_MT || VT_HYB */ wid = vt_get_curid(); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif /* VT_MT || VT_HYB */ /* ask for group of win and register them */ PMPI_Win_get_group(win, &group); vt_libassert(group != MPI_GROUP_NULL); vt_group_create(group); /* enter win in wins[] array */ if( free_win != (uint32_t)-1 ) { wins[free_win].win = win; wins[free_win].comm = comm; wins[free_win].gid = vt_group_id(group); wins[free_win].wid = wid; } else { /* raise maximum number of windows, if necessary */ if (last_win == max_wins) RAISE_MAX(wins, max_wins, struct VTWin); wins[last_win].win = win; wins[last_win].comm = comm; wins[last_win].gid = vt_group_id(group); wins[last_win].wid = wid; last_win++; } } }
unsigned int VT_User_marker_def__(const char* mname, int mtype) { uint32_t mid; uint32_t mtype_otf = OTF_MARKER_TYPE_UNKNOWN; VT_INIT; VT_MEMHOOKS_OFF(); switch(mtype) { case VT_MARKER_TYPE_ERROR: { mtype_otf = OTF_MARKER_TYPE_ERROR; break; } case VT_MARKER_TYPE_WARNING: { mtype_otf = OTF_MARKER_TYPE_WARNING; break; } case VT_MARKER_TYPE_HINT: { mtype_otf = OTF_MARKER_TYPE_HINT; break; } default: { vt_error_msg("Unknown marker type %i", mtype); break; } } #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif mid = (uint32_t)vt_def_marker(mname, mtype_otf); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif VT_MEMHOOKS_ON(); return mid; }
unsigned int VT_User_marker_def__(const char* mname, int mtype) { uint32_t mid; uint32_t _mtype = VT_MARKER_UNKNOWN; VT_INIT; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); switch(mtype) { case VT_MARKER_TYPE_ERROR: { _mtype = VT_MARKER_ERROR; break; } case VT_MARKER_TYPE_WARNING: { _mtype = VT_MARKER_WARNING; break; } case VT_MARKER_TYPE_HINT: { _mtype = VT_MARKER_HINT; break; } default: { vt_error_msg("Unknown marker type %i", mtype); break; } } #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif mid = vt_def_marker(VT_CURRENT_THREAD, mname, _mtype); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); return mid; }
VT_DECLDEF(void VT_User_start___f(const char* name, const char* file, int* lno, int nl, int fl)) { uint32_t rid; uint64_t time; int namlen; int fillen; char fnambuf[128]; char ffilbuf[1024]; VT_INIT; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); time = vt_pform_wtime(); /* -- convert Fortran to C strings -- */ namlen = ( nl < 128 ) ? nl : 127; strncpy(fnambuf, name, namlen); fnambuf[namlen] = '\0'; fillen = ( fl < 1024 ) ? fl : 1023; strncpy(ffilbuf, file, fillen); ffilbuf[fillen] = '\0'; /* -- get region identifier by address -- */ if ( (rid = hash_get_addr((unsigned long)name)) == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get_addr((unsigned long)name)) == VT_NO_ID ) rid = register_region((unsigned long)name, fnambuf, NULL, ffilbuf, *lno); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ rid = register_region((unsigned long)name, fnambuf, NULL, ffilbuf, *lno); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, rid); VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); } VT_GENERATE_F77_BINDINGS(vt_user_start__, VT_USER_START__,
void __cyg_profile_func_enter(void* func, void* callsite) { void* funcptr; uint64_t time; HashNode* hn; funcptr = DEREF_IA64_FUNC_PTR(func); /* -- if not yet initialized, initialize VampirTrace -- */ if ( gnu_init ) { VT_MEMHOOKS_OFF(); gnu_init = 0; vt_open(); vt_comp_finalize = gnu_finalize; get_symtab(); VT_MEMHOOKS_ON(); } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( (hn = hash_get((long)funcptr))) { if ( hn->vtid == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if( hn->vtid == VT_NO_ID ) register_region(hn); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ register_region(hn); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, hn->vtid); } VT_MEMHOOKS_ON(); }
void VT_User_start___f(const char* name, const char *file, int *lno, int nl, int fl) { uint32_t rid; uint64_t time; int namlen; int fillen; /* -- convert Fortran to C strings -- */ namlen = ( nl < 128 ) ? nl : 127; fillen = ( fl < 1024 ) ? fl : 1023; strncpy(fnambuf, name, namlen); fnambuf[namlen] = '\0'; strncpy(ffilbuf, file, fillen); ffilbuf[fillen] = '\0'; /* -- if not yet initialized, initialize VampirTrace -- */ if ( vt_init ) { VT_MEMHOOKS_OFF(); vt_init = 0; vt_open(); VT_MEMHOOKS_ON(); } VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( (rid = hash_get((unsigned long) name)) == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get((unsigned long) name)) == VT_NO_ID ) rid = register_region(fnambuf, (unsigned long) name, ffilbuf, *lno); VTTHRD_UNLOCK_IDS(); #else rid = register_region(fnambuf, (unsigned long) name, ffilbuf, *lno); #endif } /* -- write enter record -- */ vt_enter(&time, rid); VT_MEMHOOKS_ON(); } VT_GENERATE_F77_BINDINGS(vt_user_start__, VT_USER_START__,
void _ftrace_enter2_() { char *func = (char *)vftr_getname(); int len = vftr_getname_len(); uint32_t rid; uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if ( necsx_init ) { VT_MEMHOOKS_OFF(); necsx_init = 0; vt_open(); vt_comp_finalize = &ftrace_finalize; VT_MEMHOOKS_ON(); } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; /* -- ignore NEC OMP runtime functions -- */ if ( strchr(func, '$') != NULL ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( (rid = hash_get((long) func)) == VT_NO_ID ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (rid = hash_get((long) func)) == VT_NO_ID ) rid = register_region(func, len); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ rid = register_region(func, len); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, rid); VT_MEMHOOKS_ON(); }
unsigned int VT_User_msg_comm_def__(const char* cname) { uint32_t cid; VT_INIT; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif cid = vt_def_user_comm(VT_CURRENT_THREAD, cname); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); return cid; }
unsigned int VT_User_count_group_def__(const char* gname) { uint32_t gid; VT_INIT; VT_MEMHOOKS_OFF(); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif gid = vt_def_counter_group(VT_CURRENT_THREAD, gname); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif VT_MEMHOOKS_ON(); return gid; }
void __func_trace_enter(char* name, char* fname, int lno) { HashNode *hn; uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if ( xl_init ) { VT_MEMHOOKS_OFF(); xl_init = 0; vt_open(); vt_comp_finalize = &xl_finalize; VT_MEMHOOKS_ON(); } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; /* -- ignore IBM OMP runtime functions -- */ if ( strchr(name, '@') != NULL ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( (hn = hash_get((long) name)) == 0 ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (hn = hash_get((long) name)) == 0 ) hn = register_region(name, fname, lno); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ hn = register_region(name, fname, lno); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, hn->vtid); VT_MEMHOOKS_ON(); }
void phat_enter(char *str, int *id) { uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if ( phat_init ) { VT_MEMHOOKS_OFF(); phat_init = 0; vt_open(); vt_comp_finalize = &phat_finalize; VT_MEMHOOKS_ON(); } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; /* -- ignore SUN OMP runtime functions -- */ if ( strchr(str, '$') != NULL ) return; VT_MEMHOOKS_OFF(); time = vt_pform_wtime(); /* -- get region identifier -- */ if ( *id == -1 ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (*id = hash_get((long) str)) == VT_NO_ID ) *id = register_region(str); VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ *id = register_region(str); #endif /* VT_MT || VT_HYB */ } /* -- write enter record -- */ vt_enter(VT_CURRENT_THREAD, &time, *id); VT_MEMHOOKS_ON(); }
void vt_group_create(MPI_Group group) { uint32_t i; /* check if group already exists */ if ((i = group_search( group )) == (uint32_t)-1) { uint32_t gid; /* raise maximum number of groups, if necessary */ if (last_group == max_groups) RAISE_MAX(groups, max_groups, struct VTGroup); /* create group entry in grpv */ group_to_bitvector( group ); /* register mpi group definition (as communicator) */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif /* VT_MT || VT_HYB */ gid = vt_def_mpi_comm(VT_CURRENT_THREAD, VT_MPI_GROUP, world.size_grpv, grpv); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif /* VT_MT || VT_HYB */ /* enter group in groups[] array */ groups[last_group].group = group; groups[last_group].gid = gid; groups[last_group].refcnt = 1; last_group++; } else { /* count additional reference on group */ groups[i].refcnt++; } }
/* * Initialize VampirTrace IDs and registers the finalize function. * This may be done implicitly by vt_cupti_count(). */ void vt_cupti_events_init() { if(!vt_cuptievt_initialized){ /* fast check without lock */ vt_cupti_init(); VT_CUPTI_LOCK(); if(!vt_cuptievt_initialized){ vt_cntl_msg(2, "[CUPTI Events] Initializing ... "); /* create VampirTrace counter group ID only once */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif vt_cuptievt_rid_init = vt_def_region(VT_MASTER_THREAD, "vtcuptiHostThreadInit", VT_NO_ID, VT_NO_LNO, VT_NO_LNO, "VT_CUPTI", VT_FUNCTION); vt_cuptievt_cgid = vt_def_counter_group(VT_MASTER_THREAD, "CUPTI"); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif vt_cupti_events_sampling = (uint8_t)vt_env_cupti_sampling(); vtcuptievtCapList = vt_cuptievt_setupMetricList(); if(NULL == vtcuptievtCapList){ vt_cupti_events_enabled = 0; }else{ /* register the finalize function of VampirTrace CUPTI to be called before * the program exits */ atexit(vt_cupti_events_finalize); } vt_cuptievt_initialized = 1; VT_CUPTI_UNLOCK(); } } }
/* no need to lock, because it is only called by vt_cupti_callback_init() */ void vt_cupti_activity_init() { /*if(!vt_cuptiact_initialized){ vt_cupti_init(); VT_CUPTI_LOCK();*/ if(!vt_cuptiact_initialized){ vt_cntl_msg(2, "[CUPTI Activity] Initializing ... "); { vt_cuptiact_bufSize = vt_env_cudatrace_bsize(); /* no buffer size < 1024 bytes allowed (see CUPTI documentation) */ if(vt_cuptiact_bufSize < 1024){ if(vt_cuptiact_bufSize > 0){ vt_warning("[CUPTI Activity] Buffer size has to be at least 1024 " "bytes! It has been set to %d.", vt_cuptiact_bufSize); } vt_cuptiact_bufSize = VT_CUPTI_ACT_DEFAULT_BSIZE; } /* queue a global buffer to initialize CUPTI before CUDA init vt_cuptiact_buffer = (uint8_t *)malloc(vt_cuptiact_bufSize); VT_CUPTI_CALL(cuptiActivityEnqueueBuffer(NULL, 0, vt_cuptiact_buffer, vt_cuptiact_bufSize), "cuptiActivityEnqueueBuffer");*/ } #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif if(vt_gpu_trace_kernels > 1){ /* define kernel counters */ vt_cuptiact_cid_knStaticSharedMem = vt_def_counter(VT_MASTER_THREAD, "staticSharedMemory", "Bytes", VT_CNTR_ABS | VT_CNTR_NEXT | VT_CNTR_UNSIGNED, vt_cupti_cgid_cuda_kernel, 0); vt_cuptiact_cid_knDynamicSharedMem = vt_def_counter(VT_MASTER_THREAD, "dynamicSharedMemory", "Bytes", VT_CNTR_ABS | VT_CNTR_NEXT | VT_CNTR_UNSIGNED, vt_cupti_cgid_cuda_kernel, 0); vt_cuptiact_cid_knLocalMemTotal = vt_def_counter(VT_MASTER_THREAD, "localMemoryPerKernel", "Bytes", VT_CNTR_ABS | VT_CNTR_NEXT | VT_CNTR_UNSIGNED, vt_cupti_cgid_cuda_kernel, 0); vt_cuptiact_cid_knRegistersPerThread = vt_def_counter(VT_MASTER_THREAD, "registersPerThread", "#", VT_CNTR_ABS | VT_CNTR_NEXT | VT_CNTR_UNSIGNED, vt_cupti_cgid_cuda_kernel, 0); } /* define region for GPU activity flush */ vt_cuptiact_rid_flush = vt_def_region(VT_MASTER_THREAD, "flushActivities", VT_NO_ID, VT_NO_LNO, VT_NO_LNO, "VT_CUDA", VT_FUNCTION); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif /*** enable the activities ***/ /* enable kernel tracing */ if(vt_gpu_trace_kernels > 0){ #if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 3)) if((vt_gpu_config & VT_GPU_TRACE_CONCURRENT_KERNEL) == VT_GPU_TRACE_CONCURRENT_KERNEL){ /*VT_CUPTI_CALL(cuptiActivityEnable(CUPTI_ACTIVITY_KIND_KERNEL), "cuptiActivityEnable");*/ VT_CUPTI_CALL(cuptiActivityEnable(CUPTI_ACTIVITY_KIND_CONCURRENT_KERNEL), "cuptiActivityEnable"); }else #endif VT_CUPTI_CALL(cuptiActivityEnable(CUPTI_ACTIVITY_KIND_KERNEL), "cuptiActivityEnable"); } /* enable memory copy tracing */ if(vt_gpu_trace_mcpy){ VT_CUPTI_CALL(cuptiActivityEnable(CUPTI_ACTIVITY_KIND_MEMCPY), "cuptiActivityEnable"); } /* register the finalize function of VampirTrace CUPTI to be called before * the program exits atexit(vt_cupti_activity_finalize);*/ vt_cuptiact_initialized = 1; /*VT_CUPTI_UNLOCK(); }*/ } }
/* * Parse the environment variable for CUPTI metrics (including CUDA device * capabilities) and fill the capability metric list. * * @param capList points to the first element of the capability metric list */ static void vt_cupti_fillMetricList(vt_cupti_device_t *capList) { char *metricString = vt_env_cupti_events(); char *metric_sep = vt_env_metrics_sep(); char *metric, *metric_cap; metric = strtok(metricString, metric_sep); while (metric != NULL){ CUptiResult cuptiErr = CUPTI_SUCCESS; vt_cupti_device_t *cuptiDev = NULL; vt_cupti_evtctr_t *vtcuptiEvt = NULL; int metr_major = 0; int metr_minor = 0; /* try to get CUDA device capability parsed from metric */ metr_major = atoi(metric); metric_cap = strchr(metric+1, '.'); if(metric_cap){ metr_minor = atoi(metric_cap+1); metric_cap = strchr(metric_cap+1, '_'); } /* check whether device capability is given or not */ if(metric_cap){ metric = metric_cap + 1; vt_cntl_msg(2, "Metric '%s', %d.%d", metric, metr_major, metr_minor); cuptiDev = vt_cupti_checkMetricList(capList, metr_major, metr_minor); if(cuptiDev == NULL){ metric = strtok(NULL, metric_sep); continue; } vtcuptiEvt = (vt_cupti_evtctr_t*)malloc(sizeof(vt_cupti_evtctr_t)); cuptiErr = cuptiEventGetIdFromName(cuptiDev->cuDev, metric, &vtcuptiEvt->cuptiEvtID); if(cuptiErr != CUPTI_SUCCESS){ if(!strncmp(metric, "help", 4)) vt_cupti_showAllCounters(capList); vt_warning("[CUPTI Events] Skipping invalid event '%s' for device %d", metric, cuptiDev->cuDev); metric = strtok(NULL, metric_sep); continue; } /* create VampirTrace counter ID */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif vtcuptiEvt->vtCID = vt_def_counter(VT_MASTER_THREAD, metric, "#", VT_CNTR_ABS | VT_CNTR_LAST | VT_CNTR_UNSIGNED, vt_cuptievt_cgid, 0); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif cuptiDev->evtNum++; vtcuptiEvt->next = cuptiDev->vtcuptiEvtList; cuptiDev->vtcuptiEvtList = vtcuptiEvt; }else{ /* device capability is not given. Try to add metric to all devices */ uint32_t cid_metric = VT_NO_ID; cuptiDev = capList; while(cuptiDev != NULL){ vtcuptiEvt = (vt_cupti_evtctr_t*)malloc(sizeof(vt_cupti_evtctr_t)); cuptiErr = cuptiEventGetIdFromName(cuptiDev->cuDev, metric, &vtcuptiEvt->cuptiEvtID); if(cuptiErr != CUPTI_SUCCESS){ if(!strncmp(metric, "help", 4)) vt_cupti_showAllCounters(capList); vt_warning("[CUPTI Events] Skipping invalid event '%s' for device %d", metric, cuptiDev->cuDev); }else{ /* create VampirTrace counter ID, if not yet done for other device */ if(cid_metric == VT_NO_ID){ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif cid_metric = vt_def_counter(VT_MASTER_THREAD, metric, "#", VT_CNTR_ABS | VT_CNTR_LAST | VT_CNTR_UNSIGNED, vt_cuptievt_cgid, 0); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif } cuptiDev->evtNum++; vtcuptiEvt->vtCID = cid_metric; vtcuptiEvt->next = cuptiDev->vtcuptiEvtList; cuptiDev->vtcuptiEvtList = vtcuptiEvt; } cuptiDev = cuptiDev->next; } } metric = strtok(NULL, metric_sep); } }
void vt_comm_create(MPI_Comm comm) { MPI_Group group, lgroup, rgroup; VT_MPI_INT inter; VT_MPI_INT size_grpv = 0; uint32_t cid; /* raise maximum number of communicators, if necessary */ if (last_comm == max_comms) RAISE_MAX(comms, max_comms, struct VTComm); /* ask for group of comm */ PMPI_Comm_test_inter(comm, &inter); if (inter) { PMPI_Comm_remote_group(comm, &rgroup); PMPI_Comm_group(comm, &lgroup); PMPI_Group_union(lgroup, rgroup, &group); PMPI_Group_free(&lgroup); PMPI_Group_free(&rgroup); } else { PMPI_Comm_group(comm, &group); } /* create group entry in grpv except for MPI_COMM_SELF and MPI_COMM_WORLD (if the current rank isn't the first available one) */ if ((comm != MPI_COMM_SELF && comm != MPI_COMM_WORLD) || (comm == MPI_COMM_WORLD && vt_my_trace_is_first_avail)) { group_to_bitvector( group ); size_grpv = world.size_grpv; } /* register mpi communicator definition */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif /* VT_MT || VT_HYB */ cid = vt_def_mpi_comm(VT_CURRENT_THREAD, comm == MPI_COMM_WORLD ? VT_MPI_COMM_WORLD : comm == MPI_COMM_SELF ? VT_MPI_COMM_SELF : VT_MPI_COMM_OTHER, size_grpv, grpv); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif /* VT_MT || VT_HYB */ /* save communicator id for fast access in VT_COMM_ID */ if (comm == MPI_COMM_WORLD) vt_mpi_comm_world_cid = cid; else if (comm == MPI_COMM_SELF) vt_mpi_comm_self_cid = cid; /* enter comm in comms[] array */ comms[last_comm].comm = comm; comms[last_comm].cid = cid; last_comm++; /* clean up */ PMPI_Group_free(&group); }
/* * This function is called at the entry of each function * The call is generated by the IBM xl compilers * * XL C/C++ 11.x / XLF 13.x or later pass the address of a static pointer * variable, initialized with NULL, as additional parameter. */ #if __IBMC__ > 1100 void __func_trace_enter(char* name, char* fname, int lno, HashNode** ihn) #else /* __IBMC__ */ void __func_trace_enter(char* name, char* fname, int lno) #endif /* __IBMC__ */ { HashNode *hn; uint32_t tid; uint64_t time; /* -- ignore IBM OMP runtime functions -- */ # if __IBMC__ > 1100 if ( *ihn == &ignored_func ) return; # endif /* __IBMC__ */ if ( ( strchr(name, '@') != NULL ) || (strchr(name, '$') != NULL) ) { # if __IBMC__ > 1100 *ihn = &ignored_func; # endif /* __IBMC__ */ return; } /* -- if not yet initialized, initialize VampirTrace -- */ if ( xl_init ) { xl_init = 0; vt_open(); vt_comp_finalize = &xl_finalize; } /* -- if VampirTrace already finalized, return -- */ if ( !vt_is_alive ) return; /* -- get calling thread id -- */ GET_THREAD_ID(tid); VT_SUSPEND_MALLOC_TRACING(tid); time = vt_pform_wtime(); # if __IBMC__ > 1100 /* -- region not yet registered -- */ if ( *ihn == NULL ) { # endif /* __IBMC__ */ /* -- get region identifier -- */ if ( (hn = hash_get((long) name)) == 0 ) { /* -- region entered the first time, register region -- */ #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); if ( (hn = hash_get((long) name)) == 0 ) { hn = register_region(tid, name, fname, lno); # if __IBMC__ > 1100 *ihn = hn; # endif /* __IBMC__ */ } VTTHRD_UNLOCK_IDS(); #else /* VT_MT || VT_HYB */ hn = register_region(tid, name, fname, lno); # if __IBMC__ > 1100 *ihn = hn; # endif /* __IBMC__ */ #endif /* VT_MT || VT_HYB */ } #if __IBMC__ > 1100 } else { /* -- region already registered -- */ hn = *ihn; } #endif /* __IBMC__ */ /* -- write enter record -- */ vt_enter(tid, &time, hn->vtid); VT_RESUME_MALLOC_TRACING(tid); }
unsigned int VT_User_count_def__(const char* cname, const char* cunit, int ctype, unsigned int gid) { uint32_t cid; uint32_t cprop = VT_CNTR_ABS | VT_CNTR_NEXT; VT_INIT; VT_MEMHOOKS_OFF(); if (gid == (uint32_t)VT_COUNT_DEFGROUP) { if (def_gid == 0) def_gid = VT_User_count_group_def__("User"); gid = def_gid; } switch(ctype) { case VT_COUNT_TYPE_SIGNED: case VT_COUNT_TYPE_INTEGER: case VT_COUNT_TYPE_INTEGER8: { cprop |= VT_CNTR_SIGNED; break; } case VT_COUNT_TYPE_UNSIGNED: { cprop |= VT_CNTR_UNSIGNED; break; } case VT_COUNT_TYPE_FLOAT: case VT_COUNT_TYPE_REAL: { cprop |= VT_CNTR_FLOAT; break; } case VT_COUNT_TYPE_DOUBLE: { cprop |= VT_CNTR_DOUBLE; break; } default: { vt_error_msg("Unknown counter type %i", ctype); break; } } #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_LOCK_IDS(); #endif cid = vt_def_counter(VT_CURRENT_THREAD, cname, cprop, gid, cunit); #if (defined(VT_MT) || defined(VT_HYB)) VTTHRD_UNLOCK_IDS(); #endif VT_MEMHOOKS_ON(); return cid; }