Fix profiling calculation for CPU profiling path.

-There was a precision problem with timestamp calculation, all math was using
integers which are not very precise in overflow scenarios
-Change the logic to use doubles and cast back to uint64_t at the end.

Change-Id: Ia08d504a90a43df7330f398af966535ed944650d
This commit is contained in:
Mrozek, Michal
2018-02-19 15:04:03 +01:00
committed by sys_ocldev
parent 063e9623ba
commit ca33e029b7
4 changed files with 30 additions and 5 deletions

View File

@@ -85,11 +85,9 @@ bool OSTimeWin::getCpuGpuTime(TimeStampData *pGpuCpuTime) {
bool OSTimeWin::getCpuTime(uint64_t *timeStamp) {
uint64_t time;
uint64_t frequency;
QueryPerformanceCounter((LARGE_INTEGER *)&time);
QueryPerformanceFrequency((LARGE_INTEGER *)&frequency);
this->QueryPerfomanceCounterFnc((LARGE_INTEGER *)&time);
*timeStamp = time * NSEC_PER_SEC / frequency;
*timeStamp = static_cast<uint64_t>((static_cast<double>(time) * NSEC_PER_SEC / frequency.QuadPart));
return true;
};
@@ -126,7 +124,7 @@ double OSTimeWin::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) co
uint64_t OSTimeWin::getCpuRawTimestamp() {
LARGE_INTEGER cpuRawTimestamp = {};
QueryPerformanceCounter(&cpuRawTimestamp);
this->QueryPerfomanceCounterFnc(&cpuRawTimestamp);
return cpuRawTimestamp.QuadPart;
}
} // namespace OCLRT

View File

@@ -42,6 +42,7 @@ class OSTimeWin : public OSTime {
Wddm *wddm;
LARGE_INTEGER frequency;
OSTimeWin() {}
decltype(&QueryPerformanceCounter) QueryPerfomanceCounterFnc = QueryPerformanceCounter;
};
typedef enum GTDI_ESCAPE_FUNCTION_ENUM {