Esempio n. 1
0
void VTThrd_finalize()
{
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
  /* delete mutexes for locking */
  VTThrd_deleteMutex(&VTThrdMutexEnv);
  VTThrd_deleteMutex(&VTThrdMutexIds);
#endif /* VT_MT || VT_HYB || VT_JAVA */

  if ( VTThrdv != NULL )
    free(VTThrdv);
}
/*
 * Finalize the CUPTI common interface.
 * - free the VampirTrace CUPTI context list
 */
void vt_cupti_finalize()
{
  if(!vt_cupti_finalized && vt_cupti_initialized){
    VT_CUPTI_LOCK();
    if(!vt_cupti_finalized && vt_cupti_initialized){
      vt_cntl_msg(2, "[CUPTI] Finalizing ... ");
      
      /* free VampirTrace CUPTI context structures */
      while(vt_cupti_ctxList != NULL){
        vt_cupti_ctx_t *tmp =  vt_cupti_ctxList;

        vt_cupti_ctxList = vt_cupti_ctxList->next;

        vt_cupti_finalizeCtx(tmp);
        tmp = NULL;
      }
      
      vt_cupti_finalized = 1;
      VT_CUPTI_UNLOCK();

#if (defined(VT_MT) || defined (VT_HYB))
      VTTHRD_LOCK_ENV();
      VTThrd_deleteMutex(&VTThrdMutexCupti);
      VTTHRD_UNLOCK_ENV();
#endif /* VT_MT || VT_HYB */
    }
  }
}
void vt_cupti_activity_finalize()
{
  if(!vt_cuptiact_finalized && vt_cuptiact_initialized){
    VT_CUPTI_ACT_LOCK();
    if(!vt_cuptiact_finalized && vt_cuptiact_initialized){      
      vt_cntl_msg(2, "[CUPTI Activity] Finalizing ... ");
      
      vt_cuptiact_finalized = 1;
      VT_CUPTI_ACT_UNLOCK();
 
      while(vt_cuptiact_ctxList != NULL){
        vt_cuptiact_ctx_t *vtCtx = vt_cuptiact_ctxList;
        
        /* write buffered activities, which have not been dumped yet */
        vt_cuptiact_flushCtxActivities(vtCtx->cuCtx);
        
        /* set pointer to next context before freeing current one */
        vt_cuptiact_ctxList = vt_cuptiact_ctxList->next;

        /* free the context */
        vt_cuptiact_destroyContext(vtCtx);
      }

#if (defined(VT_MT) || defined (VT_HYB))
      VTTHRD_LOCK_ENV();
      VTThrd_deleteMutex(&VTThrdMutexCuptiAct);
      VTTHRD_UNLOCK_ENV();
#endif /* VT_MT || VT_HYB */
    }
  }
}
Esempio n. 4
0
/*
 * Finalizes the VampirTrace CUPTI implementation.
 */
void vt_cupti_finalize()
{
  if(!vt_cupti_finalized){

    CUPTI_LOCK();
    if(!vt_cupti_finalized){

      vt_cntl_msg(2, "[CUPTI] Finalizing ...");

      /* free VampirTrace CUPTI context structures (should already be freed) */
      while(vtcuptiCtxlist != NULL){
        vt_cupti_ctx_t *tmp =  vtcuptiCtxlist;

        vt_cupti_finish(vtcuptiCtxlist);

        vtcuptiCtxlist = vtcuptiCtxlist->next;

        free(tmp);
        tmp = NULL;
      }

      /* free capability metric list */
      while(vt_cupti_capList != NULL){
        vt_cupti_dev_t *tmp = vt_cupti_capList;
        vt_cupti_capList = vt_cupti_capList->next;
        
        /* free VampirTrace CUPTI events */
        while(tmp->vtcuptiEvtList != NULL){
          vt_cupti_evt_t *tmpEvt = tmp->vtcuptiEvtList;
          tmp->vtcuptiEvtList = tmp->vtcuptiEvtList->next;
          free(tmpEvt);
          tmpEvt = NULL;
        }

        free(tmp);
        tmp = NULL;
      }

      vt_cupti_finalized = 1;
      CUPTI_UNLOCK();

#if (defined(VT_MT) || defined (VT_HYB))
      VTTHRD_LOCK_ENV();
      VTThrd_deleteMutex(&VTThrdMutexCupti);
      VTTHRD_UNLOCK_ENV();
#endif /* VT_MT || VT_HYB */
    }
  }
}
void vt_plugin_cntr_thread_exit(VTThrd * thrd) {
  uint32_t i, j;

  struct vt_plugin_cntr_defines * defines =
      (struct vt_plugin_cntr_defines *) thrd->plugin_cntr_defines;

  vt_cntl_msg(3, "Process %i Thread %s-%s exits plugin counters ...",
      vt_my_ptrace, thrd->name, thrd->name_suffix);

  /* make sure that we can process */
  if (defines == NULL)
    return;

  vt_plugin_cntr_thread_disable_counters(thrd);
  /* free per thread resources */
  if (defines->counters != NULL) {
    for (i = 0; i < VT_PLUGIN_CNTR_SYNCH_TYPE_MAX; i++) {
      if (defines->counters[i] != NULL) {
        if (defines->size_of_counters != NULL) {
          for (j = 0; j < defines->size_of_counters[i]; j++) {
#if (defined(VT_MT) || defined (VT_HYB) || defined(VT_JAVA))
            if (defines->counters[i][j].callback_mutex!=NULL)
              VTThrd_lock((VTThrdMutex **) &defines->counters[i][j].callback_mutex);
            if (defines->counters[i][j].callback_values != NULL) {
              free(defines->counters[i][j].callback_values);
              defines->counters[i][j].callback_values = NULL;
              vt_trace_off(thrd->tid, 0, 1);
            }
            if (defines->counters[i][j].callback_mutex != NULL) {
              VTThrd_unlock((VTThrdMutex **) &defines->counters[i][j].callback_mutex);
              VTThrd_deleteMutex((VTThrdMutex **) &(defines->counters[i][j].callback_mutex));
            }
#endif /* VT_MT || VT_HYB || VT_JAVA */
          }
        }
        free(defines->counters[i]);
      }
    }
    free(defines->counters);
  }
  if (defines->size_of_counters != NULL)
    free(defines->size_of_counters);
  free(defines);

  vt_cntl_msg(3, "Process %i Thread %s-%s exits plugin counters ... done",
      vt_my_ptrace, thrd->name, thrd->name_suffix);
}