void init(void) { gProcessorSpeed = getClockSpeed(); gProcessorRecip = 1.0f / (NxF32) gProcessorSpeed; gCurrentTime = 0; QueryPerformanceCounter((LARGE_INTEGER *) &gLastTimeRTDSC); //gLastTimeRTDSC = Cycle::getRTDSC(); }
/* hardware or reads values from the operatings system. */ static int nvml_hardware_read( long long *value, int which_one) //, nvml_context_t *ctx) { nvml_native_event_entry_t *entry; nvmlDevice_t handle; int cudaIdx = -1; entry = &nvml_native_table[which_one]; *value = (long long) -1; /* replace entry->resources with the current cuda_device->nvml device */ cudaGetDevice( &cudaIdx ); if ( cudaIdx < 0 || cudaIdx > device_count ) return PAPI_EINVAL; /* Make sure the device we are running on has the requested event */ if ( !HAS_FEATURE( features[cudaIdx] , entry->type) ) return PAPI_EINVAL; handle = devices[cudaIdx]; switch (entry->type) { case FEATURE_CLOCK_INFO: *value = getClockSpeed( handle, (nvmlClockType_t)entry->options.clock ); break; case FEATURE_ECC_LOCAL_ERRORS: *value = getEccLocalErrors( handle, (nvmlEccBitType_t)entry->options.ecc_opts.bits, (int)entry->options.ecc_opts.which_one); break; case FEATURE_FAN_SPEED: *value = getFanSpeed( handle ); break; case FEATURE_MAX_CLOCK: *value = getMaxClockSpeed( handle, (nvmlClockType_t)entry->options.clock ); break; case FEATURE_MEMORY_INFO: *value = getMemoryInfo( handle, (int)entry->options.which_one ); break; case FEATURE_PERF_STATES: *value = getPState( handle ); break; case FEATURE_POWER: *value = getPowerUsage( handle ); break; case FEATURE_TEMP: *value = getTemperature( handle ); break; case FEATURE_ECC_TOTAL_ERRORS: *value = getTotalEccErrors( handle, (nvmlEccBitType_t)entry->options.ecc_opts.bits ); break; case FEATURE_UTILIZATION: *value = getUtilization( handle, (int)entry->options.which_one ); break; default: return PAPI_EINVAL; } return PAPI_OK; }