/*
 * 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;
}
Example #2
0
void POMP_Parallel_end(struct ompregdescr* r) {
  if ( IS_POMP_TRACE_ON ) {
    uint64_t time = vt_pform_wtime();
    vt_exit(&time);
    vt_omp_parallel_end();
  }
}
Example #3
0
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;
}
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;
}
Example #5
0
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;
}
Example #6
0
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;
}
Example #7
0
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;
}
Example #8
0
void POMP_Critical_end(struct ompregdescr* r) {
  if ( IS_POMP_TRACE_ON ) {
    struct VTRegDescr* data = (struct VTRegDescr*)(r->data);
    uint64_t time = vt_pform_wtime();
    vt_exit(&time);
    vt_omp_rlock(&time, data->brid);
  }
}
/*
 * Finalize the VampirTrace CUPTI context and free all memory allocated with it.
 * 
 * @param vtCtx pointer to the VampirTrace CUPTI context
 */
void vt_cupti_finalizeCtx(vt_cupti_ctx_t *vtCtx)
{
  if(vtCtx == NULL)
    return;
  
  /* write exit event for GPU idle time */
  if(vt_gpu_trace_idle > 0 && vtCtx->strmList != NULL 
#if defined(VT_CUPTI_ACTIVITY)
     && vtCtx->activity != NULL && vtCtx->activity->gpuIdleOn == 1
#endif
    ){
    uint64_t idle_end = vt_pform_wtime();
    
    /*vt_warning("IDLEexit: %llu (%d)", idle_end, vtCtx->strmList->vtThrdID);*/
    vt_exit(vtCtx->strmList->vtThrdID, &idle_end);
  }
  
  /* cleanup stream list */
  while(vtCtx->strmList != NULL){
    vt_cupti_strm_t *vtStrm = vtCtx->strmList;
    
    vtCtx->strmList = vtCtx->strmList->next;
    
    free(vtStrm);
    vtStrm = NULL;
  }
  
  /* free CUDA malloc entries, if user application has memory leaks */
  while(vtCtx->gpuMemList != NULL){
    vt_cupti_gpumem_t *vtMem =  vtCtx->gpuMemList;
    
    if(vt_gpu_trace_memusage > 1)
      vt_cntl_msg(1, "[CUPTI] Free of %d bytes GPU memory missing!", 
                     vtMem->size);
    
    vtCtx->gpuMemList = vtMem->next;
    free(vtMem);
    vtMem = NULL;
  }
  
#if defined(VT_CUPTI_ACTIVITY)
  if(vtCtx->activity != NULL)
    free(vtCtx->activity);
#endif

#if (defined(VT_CUPTI_CALLBACKS) && !defined(VT_CUPTI_ACTIVITY))
  if(vtCtx->callbacks != NULL)
    free(vtCtx->callbacks);
#endif
  
#if defined(VT_CUPTI_EVENTS)
  if(vtCtx->events != NULL)
    free(vtCtx->events);
#endif
  
  free(vtCtx);
  vtCtx = NULL;
}
Example #10
0
void POMP_Parallel_join(struct ompregdescr* r) {
  vt_omp_join(VT_CURRENT_THREAD);

  if ( IS_POMP_TRACE_ON ) {
    uint64_t time;
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
  }
}
Example #11
0
void POMP_End(struct ompregdescr* r) {
  struct VTRegDescr* data = (struct VTRegDescr*)(r->data);

  if ( IS_POMP_TRACE_ON )
  {
    uint64_t time;
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
  }
  if ( data->rid == main_rid ) POMP_Finalize();
}
void VT_User_end___f(const char *name, int nl) {
  uint64_t time;

  VT_MEMHOOKS_OFF();

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(&time);

  VT_MEMHOOKS_ON();
} VT_GENERATE_F77_BINDINGS(vt_user_end__, VT_USER_END__,
void VT_User_end__(const char *name) {
  uint64_t time;

  VT_MEMHOOKS_OFF();

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(&time);

  VT_MEMHOOKS_ON();
}
Example #14
0
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);
  }
}
Example #15
0
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);
  }
}
Example #16
0
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,
VT_DECLDEF(void VT_User_end___f(const char* name, int nl))
{
  uint64_t time;

  VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(VT_CURRENT_THREAD, &time);

  VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
} VT_GENERATE_F77_BINDINGS(vt_user_end__, VT_USER_END__,
Example #18
0
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);
  }
}
Example #19
0
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,
Example #20
0
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,
Example #21
0
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);
  }
}
Example #22
0
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);
  }
}
Example #23
0
void ___rouret2(void) {
  uint64_t time;

  /* -- if VampirTrace already finalized, return -- */
  if ( !vt_is_alive ) return;

  VT_MEMHOOKS_OFF();

  time = vt_pform_wtime();
  vt_exit(VT_CURRENT_THREAD, &time);

  VT_MEMHOOKS_ON();
}
void VT_User_end__(const char* name)
{
  uint64_t time;

  (void)name;

  VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(VT_CURRENT_THREAD, &time);

  VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
}
void VT_User_end2__(unsigned int rid)
{
  uint64_t time;

  (void)rid;

  VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(VT_CURRENT_THREAD, &time);

  VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
}
VT_DECLDEF(void VT_User_end2___f(unsigned int* rid))
{
  uint64_t time;

  (void)rid;

  VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);

  /* -- write exit record -- */
  time = vt_pform_wtime();
  vt_exit(VT_CURRENT_THREAD, &time);

  VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
} VT_GENERATE_F77_BINDINGS(vt_user_end2__, VT_USER_END2__,
Example #27
0
void POMP_Init_lock(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);
  }
}
Example #28
0
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,
Example #29
0
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,
Example #30
0
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);
  }
}