mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Implement support for zeDeviceGetGlobalTimestamps
Related-To: LOCI-1933 Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
3c6d026d7b
commit
7764ac44ae
@ -219,6 +219,7 @@ zeGetDeviceProcAddrTable(
|
|||||||
pDdiTable->pfnCanAccessPeer = zeDeviceCanAccessPeer;
|
pDdiTable->pfnCanAccessPeer = zeDeviceCanAccessPeer;
|
||||||
pDdiTable->pfnGetStatus = zeDeviceGetStatus;
|
pDdiTable->pfnGetStatus = zeDeviceGetStatus;
|
||||||
pDdiTable->pfnGetExternalMemoryProperties = zeDeviceGetExternalMemoryProperties;
|
pDdiTable->pfnGetExternalMemoryProperties = zeDeviceGetExternalMemoryProperties;
|
||||||
|
pDdiTable->pfnGetGlobalTimestamps = zeDeviceGetGlobalTimestamps;
|
||||||
driver_ddiTable.core_ddiTable.Device = *pDdiTable;
|
driver_ddiTable.core_ddiTable.Device = *pDdiTable;
|
||||||
if (driver_ddiTable.enableTracing) {
|
if (driver_ddiTable.enableTracing) {
|
||||||
pDdiTable->pfnGet = zeDeviceGet_Tracing;
|
pDdiTable->pfnGet = zeDeviceGet_Tracing;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2019-2020 Intel Corporation
|
* Copyright (C) 2019-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@ -114,3 +114,11 @@ zeDeviceGetStatus(
|
|||||||
ze_device_handle_t hDevice) {
|
ze_device_handle_t hDevice) {
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||||
|
zeDeviceGetGlobalTimestamps(
|
||||||
|
ze_device_handle_t hDevice,
|
||||||
|
uint64_t *hostTimestamp,
|
||||||
|
uint64_t *deviceTimestamp) {
|
||||||
|
return L0::Device::fromHandle(hDevice)->getGlobalTimestamps(hostTimestamp, deviceTimestamp);
|
||||||
|
}
|
@ -70,6 +70,7 @@ struct Device : _ze_device_handle_t {
|
|||||||
virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0;
|
virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0;
|
||||||
virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0;
|
virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0;
|
||||||
virtual ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) = 0;
|
virtual ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) = 0;
|
||||||
|
virtual ze_result_t getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) = 0;
|
||||||
|
|
||||||
virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
||||||
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0;
|
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0;
|
||||||
|
@ -431,6 +431,21 @@ ze_result_t DeviceImp::getExternalMemoryProperties(ze_device_external_memory_pro
|
|||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ze_result_t DeviceImp::getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) {
|
||||||
|
NEO::TimeStampData queueTimeStamp;
|
||||||
|
bool retVal = this->neoDevice->getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
||||||
|
if (!retVal)
|
||||||
|
return ZE_RESULT_ERROR_DEVICE_LOST;
|
||||||
|
|
||||||
|
*deviceTimestamp = queueTimeStamp.GPUTimeStamp;
|
||||||
|
|
||||||
|
retVal = this->neoDevice->getOSTime()->getCpuTime(hostTimestamp);
|
||||||
|
if (!retVal)
|
||||||
|
return ZE_RESULT_ERROR_DEVICE_LOST;
|
||||||
|
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) {
|
ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) {
|
||||||
if (*pCount == 0) {
|
if (*pCount == 0) {
|
||||||
*pCount = this->numSubDevices;
|
*pCount = this->numSubDevices;
|
||||||
|
@ -46,6 +46,7 @@ struct DeviceImp : public Device {
|
|||||||
ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
||||||
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) override;
|
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) override;
|
||||||
ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) override;
|
ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) override;
|
||||||
|
ze_result_t getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) override;
|
||||||
ze_result_t getDebugProperties(zet_device_debug_properties_t *pDebugProperties) override;
|
ze_result_t getDebugProperties(zet_device_debug_properties_t *pDebugProperties) override;
|
||||||
|
|
||||||
ze_result_t systemBarrier() override;
|
ze_result_t systemBarrier() override;
|
||||||
|
@ -131,6 +131,11 @@ struct Mock<Device> : public Device {
|
|||||||
getExternalMemoryProperties,
|
getExternalMemoryProperties,
|
||||||
(ze_device_external_memory_properties_t * pExternalMemoryProperties),
|
(ze_device_external_memory_properties_t * pExternalMemoryProperties),
|
||||||
(override));
|
(override));
|
||||||
|
MOCK_METHOD(ze_result_t,
|
||||||
|
getGlobalTimestamps,
|
||||||
|
(uint64_t * hostTimestamp,
|
||||||
|
uint64_t *deviceTimestamp),
|
||||||
|
(override));
|
||||||
MOCK_METHOD(ze_result_t,
|
MOCK_METHOD(ze_result_t,
|
||||||
systemBarrier,
|
systemBarrier,
|
||||||
(),
|
(),
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "shared/source/device/root_device.h"
|
#include "shared/source/device/root_device.h"
|
||||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||||
#include "shared/source/os_interface/hw_info_config.h"
|
#include "shared/source/os_interface/hw_info_config.h"
|
||||||
|
#include "shared/source/os_interface/os_time.h"
|
||||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/common/mocks/mock_device.h"
|
#include "shared/test/common/mocks/mock_device.h"
|
||||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||||
@ -326,6 +327,105 @@ TEST_F(DeviceTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIsReturnedA
|
|||||||
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DeviceTest, whenGetGlobalTimestampIsCalledThenSuccessIsReturnedAndValuesSetCorrectly) {
|
||||||
|
uint64_t hostTs = 0u;
|
||||||
|
uint64_t deviceTs = 0u;
|
||||||
|
|
||||||
|
ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs);
|
||||||
|
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||||
|
|
||||||
|
EXPECT_NE(0u, hostTs);
|
||||||
|
EXPECT_NE(0u, deviceTs);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FalseCpuGpuTime : public NEO::OSTime {
|
||||||
|
public:
|
||||||
|
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool getCpuTime(uint64_t *timeStamp) override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
double getHostTimerResolution() const override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||||
|
return NEO::OSTime::getDeviceTimerResolution(hwInfo);
|
||||||
|
}
|
||||||
|
uint64_t getCpuRawTimestamp() override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static std::unique_ptr<OSTime> create() {
|
||||||
|
return std::unique_ptr<OSTime>(new FalseCpuGpuTime());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GlobalTimestampTest : public ::testing::Test {
|
||||||
|
void SetUp() override {
|
||||||
|
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||||
|
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), rootDeviceIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||||
|
NEO::MockDevice *neoDevice = nullptr;
|
||||||
|
L0::Device *device = nullptr;
|
||||||
|
const uint32_t rootDeviceIndex = 1u;
|
||||||
|
const uint32_t numRootDevices = 2u;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetCpuGpuTimeIsFalseReturnError) {
|
||||||
|
uint64_t hostTs = 0u;
|
||||||
|
uint64_t deviceTs = 0u;
|
||||||
|
|
||||||
|
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||||
|
NEO::DeviceVector devices;
|
||||||
|
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||||
|
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||||
|
driverHandle->initialize(std::move(devices));
|
||||||
|
device = driverHandle->devices[0];
|
||||||
|
|
||||||
|
ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs);
|
||||||
|
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
class FalseCpuTime : public NEO::OSTime {
|
||||||
|
public:
|
||||||
|
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool getCpuTime(uint64_t *timeStamp) override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
double getHostTimerResolution() const override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||||
|
return NEO::OSTime::getDeviceTimerResolution(hwInfo);
|
||||||
|
}
|
||||||
|
uint64_t getCpuRawTimestamp() override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static std::unique_ptr<OSTime> create() {
|
||||||
|
return std::unique_ptr<OSTime>(new FalseCpuTime());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetCpuTimeIsFalseReturnError) {
|
||||||
|
uint64_t hostTs = 0u;
|
||||||
|
uint64_t deviceTs = 0u;
|
||||||
|
|
||||||
|
neoDevice->setOSTime(new FalseCpuTime());
|
||||||
|
NEO::DeviceVector devices;
|
||||||
|
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||||
|
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||||
|
driverHandle->initialize(std::move(devices));
|
||||||
|
device = driverHandle->devices[0];
|
||||||
|
|
||||||
|
ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs);
|
||||||
|
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||||
|
}
|
||||||
|
|
||||||
using DeviceGetMemoryTests = DeviceTest;
|
using DeviceGetMemoryTests = DeviceTest;
|
||||||
|
|
||||||
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithCountZeroThenOneIsReturned) {
|
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithCountZeroThenOneIsReturned) {
|
||||||
|
Reference in New Issue
Block a user