2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/windows/os_time_win.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-20 19:49:44 +02:00
|
|
|
#include "shared/source/os_interface/windows/device_time_wddm.h"
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#undef WIN32_NO_STATUS
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
bool OSTimeWin::getCpuTime(uint64_t *timeStamp) {
|
|
|
|
uint64_t time;
|
2018-02-19 15:04:03 +01:00
|
|
|
this->QueryPerfomanceCounterFnc((LARGE_INTEGER *)&time);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-19 15:04:03 +01:00
|
|
|
*timeStamp = static_cast<uint64_t>((static_cast<double>(time) * NSEC_PER_SEC / frequency.QuadPart));
|
2017-12-21 00:45:38 +01:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2021-05-27 19:44:47 +02:00
|
|
|
std::unique_ptr<OSTime> OSTimeWin::create(OSInterface *osInterface) {
|
2017-12-21 00:45:38 +01:00
|
|
|
return std::unique_ptr<OSTime>(new OSTimeWin(osInterface));
|
|
|
|
}
|
|
|
|
|
2018-06-28 07:49:06 +02:00
|
|
|
OSTimeWin::OSTimeWin(OSInterface *osInterface) {
|
2017-12-21 00:45:38 +01:00
|
|
|
this->osInterface = osInterface;
|
2021-05-21 01:17:57 +02:00
|
|
|
Wddm *wddm = osInterface ? osInterface->getDriverModel()->as<Wddm>() : nullptr;
|
2021-05-20 19:49:44 +02:00
|
|
|
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
|
2017-12-21 00:45:38 +01:00
|
|
|
QueryPerformanceFrequency(&frequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
double OSTimeWin::getHostTimerResolution() const {
|
|
|
|
double retValue = 0;
|
|
|
|
if (frequency.QuadPart) {
|
|
|
|
retValue = 1e9 / frequency.QuadPart;
|
|
|
|
}
|
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t OSTimeWin::getCpuRawTimestamp() {
|
|
|
|
LARGE_INTEGER cpuRawTimestamp = {};
|
2018-02-19 15:04:03 +01:00
|
|
|
this->QueryPerfomanceCounterFnc(&cpuRawTimestamp);
|
2017-12-21 00:45:38 +01:00
|
|
|
return cpuRawTimestamp.QuadPart;
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|