void phat_enter(char *str, int *id) { uint64_t time; /* -- if not yet initialized, initialize VampirTrace -- */ if ( phat_init ) { uint32_t main_id; VT_MEMHOOKS_OFF(); phat_init = 0; vt_open(); main_id = register_region("main"); time = vt_pform_wtime(); vt_enter(&time, main_id); 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_OMPI) || defined (VT_OMP) if (omp_in_parallel()) { # pragma omp critical (vt_comp_phat_1) { if ( (*id = hash_get((long) str)) == VT_NO_ID ) { *id = register_region(str); } } } else { *id = register_region(str); } # else *id = register_region(str); # endif } /* -- write enter record -- */ vt_enter(&time, *id); VT_MEMHOOKS_ON(); }
/* * Retrieve the VampirTrace CUPTI context from the CUDA context. * * @param cuCtx the CUDA context * @param ptid the active VampirTrace thread id * * @return VampirTrace CUPTI context */ static vt_cupti_ctx_t* vt_cuptievt_getOrCreateCtx(CUcontext cuCtx, uint32_t ptid) { vt_cupti_ctx_t *vtcuptiCtx = NULL; uint64_t time; /* check, if the current VampirTrace thread is enabled for GPU counters */ if((vt_gpu_prop[ptid] & VTGPU_NO_PC) == VTGPU_NO_PC) return NULL; time = vt_pform_wtime(); vt_enter(ptid, &time, vt_cuptievt_rid_init); /* retrieve a global VampirTrace CUPTI context */ vtcuptiCtx = vt_cupti_getCreateCtx(cuCtx); /* if the event context is not available yet, then create it */ if(NULL == vtcuptiCtx->events){ vt_cupti_events_initContext(vtcuptiCtx); } time = vt_pform_wtime(); vt_exit(ptid, &time); return vtcuptiCtx; }
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(); }
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(); }
pid_t wait(WAIT_STATUS_TYPE status) { pid_t rc; uint64_t time; VT_MEMHOOKS_OFF(); if ( DO_TRACE(wait) ) { /* mark enter function */ time = vt_pform_wtime(); vt_enter(&time, libc_funcs[FUNCIDX(wait)].rid); } /* call (real) function */ CALL_FUNC(wait, rc, (status)); if ( DO_TRACE(wait) ) { /* mark leave function */ time = vt_pform_wtime(); vt_exit(&time); } VT_MEMHOOKS_ON(); return rc; }
pid_t waitpid(pid_t pid, int* status, int options) { pid_t rc; uint64_t time; VT_MEMHOOKS_OFF(); if ( DO_TRACE(waitpid) ) { /* mark enter function */ time = vt_pform_wtime(); vt_enter(&time, libc_funcs[FUNCIDX(waitpid)].rid); } /* call (real) function */ CALL_FUNC(waitpid, rc, (pid, status, options)); if ( DO_TRACE(waitpid) ) { /* mark leave function */ time = vt_pform_wtime(); vt_exit(&time); } VT_MEMHOOKS_ON(); return rc; }
int system(const char* string) { int rc; uint64_t time; VT_MEMHOOKS_OFF(); if ( DO_TRACE(system) ) { /* mark enter function */ time = vt_pform_wtime(); vt_enter(&time, libc_funcs[FUNCIDX(system)].rid); } /* call (real) function */ CALL_FUNC(system, rc, (string)); if ( DO_TRACE(system) ) { /* mark leave function */ time = vt_pform_wtime(); vt_exit(&time); } VT_MEMHOOKS_ON(); return rc; }
pid_t fork(void) { pid_t rc; uint64_t time; VT_MEMHOOKS_OFF(); if ( DO_TRACE(fork) ) { /* mark enter function */ time = vt_pform_wtime(); vt_enter(&time, libc_funcs[FUNCIDX(fork)].rid); } /* call (real) function */ CALL_FUNC(fork, rc, ()); if ( DO_TRACE(fork) ) { /* handle fork, if succeeded */ if ( rc != -1 ) vt_fork(rc); if ( rc != 0 ) { /* mark leave function */ time = vt_pform_wtime(); vt_exit(&time); } } VT_MEMHOOKS_ON(); return rc; }
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(int VT_pthread_create__(pthread_t* thread, const pthread_attr_t* attr, void *(*start_routine)(void*), void* arg)) { int rc; uint64_t time; struct vt_pthread_pack_struct* pack; if (vt_init) { vt_init = 0; vt_open(); } time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_pthread_regid[VT__PTHREAD_CREATE]); pack = (struct vt_pthread_pack_struct*)malloc( sizeof(struct vt_pthread_pack_struct)); if (pack == NULL) vt_error(); pack->start_routine = start_routine; pack->arg = arg; pack->ptid = VTThrd_getThreadId(); rc = pthread_create(thread, attr, vt_pthread_function, (void*)pack); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); return rc; }
void POMP_Parallel_begin(struct ompregdescr* r) { if ( IS_POMP_TRACE_ON ) { struct VTRegDescr* data = (struct VTRegDescr*)(r->data); uint64_t time = vt_pform_wtime(); vt_omp_parallel_begin(); vt_enter(&time, data->rid); } }
void POMP_Critical_begin(struct ompregdescr* r) { if ( IS_POMP_TRACE_ON ) { struct VTRegDescr* data = (struct VTRegDescr*)(r->data); uint64_t time = vt_pform_wtime(); vt_omp_alock(&time, data->brid); vt_enter(&time, data->sbrid); } }
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 POMP_Begin(struct ompregdescr* r) { struct VTRegDescr* data = (struct VTRegDescr*)(r->data); if ( main_rid == VT_NO_ID ) main_rid = data->rid; if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, data->rid); } }
void POMP_Parallel_fork2(struct ompregdescr* r, int* p) { if ( !pomp_initialized ) POMP_Init(); vt_omp_fork2(VT_CURRENT_THREAD, (uint32_t*)p); if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_trc_regid[VT__TRC_OMPPREG]); } }
VT_DECLDEF(void POMP_Unset_nest_lock_f(omp_nest_lock_t *s)) { if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_UNSET_NEST_LOCK]); omp_unset_nest_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); } else { omp_unset_nest_lock(s); } } VT_GENERATE_F77_BINDINGS(pomp_unset_nest_lock, POMP_UNSET_NEST_LOCK,
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 POMP_Unset_nest_lock(omp_nest_lock_t *s) { if ( IS_POMP_TRACE_ON ) { uint64_t time = vt_pform_wtime(); vt_enter(&time, vt_omp_regid[VT__OMP_UNSET_NEST_LOCK]); omp_unset_nest_lock(s); time = vt_pform_wtime(); vt_omp_rlock(&time, vt_lock_id(s)); vt_exit(&time); } else { omp_unset_nest_lock(s); } }
void POMP_Destroy_lock(omp_lock_t *s) { if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_DESTROY_LOCK]); omp_destroy_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); } else { omp_destroy_lock(s); } }
VT_DECLDEF(void VT_User_start2___f(unsigned int* rid)) { uint64_t time; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); /* -- write enter record -- */ time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, *rid); VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); } VT_GENERATE_F77_BINDINGS(vt_user_start2__, VT_USER_START2__,
void VT_User_start2__(unsigned int rid) { uint64_t time; VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); /* -- write enter record -- */ time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, rid); VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); }
DEF_FPOMP_FUNC(void POMP_Unset_nest_lock_f(omp_nest_lock_t *s)) { if ( IS_POMP_TRACE_ON ) { uint64_t time = vt_pform_wtime(); vt_enter(&time, vt_omp_regid[VT__OMP_UNSET_NEST_LOCK]); omp_unset_nest_lock(s); time = vt_pform_wtime(); vt_omp_rlock(&time, vt_lock_id(s)); vt_exit(&time); } else { omp_unset_nest_lock(s); } } VT_GENERATE_F77_BINDINGS(pomp_unset_nest_lock, POMP_UNSET_NEST_LOCK,
void POMP_Set_nest_lock(omp_nest_lock_t *s) { if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_SET_NEST_LOCK]); omp_set_nest_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); } else { omp_set_nest_lock(s); } }
DEF_FPOMP_FUNC(void POMP_Destroy_lock_f(omp_lock_t *s)) { if ( IS_POMP_TRACE_ON ) { uint64_t time = vt_pform_wtime(); vt_enter(&time, vt_omp_regid[VT__OMP_DESTROY_LOCK]); omp_destroy_lock(s); vt_lock_destroy(s); time = vt_pform_wtime(); vt_exit(&time); } else { omp_destroy_lock(s); vt_lock_destroy(s); } } VT_GENERATE_F77_BINDINGS(pomp_destroy_lock, POMP_DESTROY_LOCK,
void POMP_Destroy_nest_lock(omp_nest_lock_t *s) { if ( IS_POMP_TRACE_ON ) { uint64_t time = vt_pform_wtime(); vt_enter(&time, vt_omp_regid[VT__OMP_DESTROY_NEST_LOCK]); omp_destroy_nest_lock(s); vt_lock_destroy(s); time = vt_pform_wtime(); vt_exit(&time); } else { omp_destroy_nest_lock(s); vt_lock_destroy(s); } }
void POMP_Init_nest_lock(omp_nest_lock_t *s) { if ( IS_POMP_TRACE_ON ) { uint64_t time = vt_pform_wtime(); vt_enter(&time, vt_omp_regid[VT__OMP_INIT_NEST_LOCK]); omp_init_nest_lock(s); vt_lock_init(s); time = vt_pform_wtime(); vt_exit(&time); } else { omp_init_nest_lock(s); vt_lock_init(s); } }
/* * Create a VampirTrace CUPTI Activity stream. * * @param devID ID of the CUDA device * @param strmID ID of the CUDA stream * * @return pointer to created VampirTrace CUPTI Activity stream */ static vt_cuptiact_strm_t* vt_cuptiact_createStream(vt_cupti_ctx_t *vtCtx, uint32_t strmID) { vt_cuptiact_strm_t *vtStrm = NULL; vtStrm = (vt_cuptiact_strm_t *)malloc(sizeof(vt_cuptiact_strm_t)); if(vtStrm == NULL) vt_error_msg("[CUPTI Activity] Could not allocate memory for stream!"); vtStrm->strmID = strmID; vtStrm->vtLastTime = vt_gpu_init_time; vtStrm->destroyed = 0; vtStrm->next = NULL; /* create VT-User-Thread with name and parent id and get its id */ { char thread_name[16] = "CUDA"; if(vt_gpu_stream_reuse){ if(vtCtx->devID != VT_NO_ID){ if(-1 == snprintf(thread_name+4, 12, "[%d]", vtCtx->devID)) vt_cntl_msg(1, "Could not create thread name for CUDA thread!"); } }else{ if(vtCtx->devID == VT_NO_ID){ if(-1 == snprintf(thread_name+4, 12, "[?:%d]", strmID)) vt_cntl_msg(1, "Could not create thread name for CUDA thread!"); }else{ if(-1 == snprintf(thread_name+4, 12, "[%d:%d]", vtCtx->devID, strmID)) vt_cntl_msg(1, "Could not create thread name for CUDA thread!"); } } VT_CHECK_THREAD; vt_gpu_registerThread(thread_name, VT_MY_THREAD, &(vtStrm->vtThrdID)); } /* if first stream created for this device, make it the default stream */ if(vtCtx->activity->strmList == NULL){ /* write enter event for GPU_IDLE on first stream */ if(vt_gpu_trace_idle == 1){ if(vt_gpu_init_time < vt_start_time) vt_gpu_init_time = vt_start_time; vt_enter(vtStrm->vtThrdID, &vt_gpu_init_time, vt_gpu_rid_idle); /*vt_warning("IDLEente: %llu (%d)", vt_gpu_init_time, vtStrm->vtThrdID);*/ vtCtx->activity->gpuIdleOn = 1; } } return vtStrm; }
int POMP_Test_nest_lock(omp_nest_lock_t *s) { if ( IS_POMP_TRACE_ON ) { int result; uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]); result = omp_test_nest_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); return result; } else { return omp_test_nest_lock(s); } }
VT_DECLDEF(void POMP_Init_lock_f(omp_lock_t *s)) { if ( !pomp_initialized ) POMP_Init(); if ( IS_POMP_TRACE_ON ) { uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_INIT_LOCK]); omp_init_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); } else { omp_init_lock(s); } } VT_GENERATE_F77_BINDINGS(pomp_init_lock, POMP_INIT_LOCK,
VT_DECLDEF(int POMP_Test_nest_lock_f(omp_nest_lock_t *s)) { if ( IS_POMP_TRACE_ON ) { int result; uint64_t time; time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]); result = omp_test_nest_lock(s); time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); return result; } else { return omp_test_nest_lock(s); } } VT_GENERATE_F77_BINDINGS(pomp_test_nest_lock, POMP_TEST_NEST_LOCK,