Beispiel #1
0
/*
 * Print all available counters for a given CUDA device to stdout.
 *
 * @param cuDev the CUDA device
 */
static void vt_cupti_showAllCounters(CUdevice cuDev)
{
  CUptiResult cuptiErr = CUPTI_SUCCESS;
  CUpti_EventDomainID *domainId = NULL;
  uint32_t maxDomains = 0;
  uint32_t i;
  size_t size = 0;

  cuptiErr = cuptiDeviceGetNumEventDomains(cuDev, &maxDomains);
  CHECK_CUPTI_ERROR(cuptiErr, "cuptiDeviceGetNumEventDomains");

  if(maxDomains == 0){
    vt_cntl_msg(1, "[CUPTI] No domain is exposed by dev = %d\n", cuDev);
    return;
  }

  size = sizeof(CUpti_EventDomainID) * maxDomains;
  domainId = (CUpti_EventDomainID*)malloc(size);
  if(domainId == NULL){
    vt_cntl_msg(1, "[CUPTI] Failed to allocate memory to domain ID");
    return;
  }
  memset(domainId, 0, size);

  cuptiErr = cuptiDeviceEnumEventDomains(cuDev, &size, domainId);
  CHECK_CUPTI_ERROR(cuptiErr, "cuptiDeviceEnumEventDomains");

  /* enum domains */
  for(i = 0; i < maxDomains; i++) enumEvents(cuDev, domainId[i]);

  free(domainId);
}
/*
 * Print all available counters to stdout.
 *
 * @param capList list of CUDA devices with different capabilities
 */
static void vt_cupti_showAllCounters(vt_cupti_device_t *capList)
{
  CUptiResult cuptiErr = CUPTI_SUCCESS;
  CUpti_EventDomainID *domainId = NULL;
  uint32_t maxDomains = 0;
  uint32_t i;
  size_t size = 0;
  
  while(capList != NULL){
    CUdevice cuDev = capList->cuDev;
    vt_cntl_msg(1, "[CUPTI Events] Available events for device %d (SM %d.%d):", 
                   cuDev, capList->dev_major, capList->dev_minor);
    vt_cntl_msg(1, "Id:Name");
    vt_cntl_msg(1, "Description\n"
         "-------------------------------------------------------------------");
    
    cuptiErr = cuptiDeviceGetNumEventDomains(cuDev, &maxDomains);
    VT_CUPTI_CALL(cuptiErr, "cuptiDeviceGetNumEventDomains");

    if(maxDomains == 0){
      vt_warning("[CUPTI Events] No domain is exposed by dev = %d\n", cuDev);
      return;
    }

    size = sizeof(CUpti_EventDomainID) * maxDomains;
    domainId = (CUpti_EventDomainID*)malloc(size);
    if(domainId == NULL){
      vt_warning("[CUPTI Events] Failed to allocate memory to domain ID");
      return;
    }
    memset(domainId, 0, size);

    cuptiErr = cuptiDeviceEnumEventDomains(cuDev, &size, domainId);
    VT_CUPTI_CALL(cuptiErr, "cuptiDeviceEnumEventDomains");

    /* enum domains */
    for(i = 0; i < maxDomains; i++) vt_cuptievt_enumEvents(cuDev, domainId[i]);

    vt_cntl_msg(1, "------------------------------------------------------");
    
    free(domainId);
    
    capList = capList->next;
  }
  
  /* as this function is in the call-path of the initialize functions
   * -> vt_cupti_setupMetrics 
   * -> vt_cupti_fillMetricList 
   * -> vt_cupti_showAllCounters
   */
  vt_cuptievt_initialized = 1;
  VT_CUPTI_UNLOCK();
  exit(0);
}