mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Move mock_ostime to shared
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
52c75e92da
commit
852b2f6e6e
@@ -58,6 +58,7 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_migration_sync_data.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_multi_graphics_allocation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_ostime.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_physical_address_allocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sip.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sip.h
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test//common/mocks/mock_ostime.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/unit_test/tests_configuration.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_ostime.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
bool MockDevice::createSingleDevice = true;
|
||||
|
||||
90
shared/test/common/mocks/mock_ostime.h
Normal file
90
shared/test/common/mocks/mock_ostime.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
|
||||
namespace NEO {
|
||||
static int PerfTicks = 0;
|
||||
class MockDeviceTime : public DeviceTime {
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
pGpuCpuTime->GPUTimeStamp = ++PerfTicks;
|
||||
pGpuCpuTime->CPUTimeinNS = PerfTicks;
|
||||
return true;
|
||||
}
|
||||
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return OSTime::getDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
};
|
||||
|
||||
class MockOSTime : public OSTime {
|
||||
public:
|
||||
MockOSTime() {
|
||||
this->deviceTime = std::make_unique<MockDeviceTime>();
|
||||
}
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
*timeStamp = ++PerfTicks;
|
||||
return true;
|
||||
};
|
||||
double getHostTimerResolution() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
static std::unique_ptr<OSTime> create() {
|
||||
return std::unique_ptr<OSTime>(new MockOSTime());
|
||||
}
|
||||
};
|
||||
|
||||
class MockDeviceTimeWithConstTimestamp : public DeviceTime {
|
||||
public:
|
||||
static constexpr uint64_t CPU_TIME_IN_NS = 1u;
|
||||
static constexpr uint64_t GPU_TIMESTAMP = 2u;
|
||||
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
pGpuCpuTime->GPUTimeStamp = GPU_TIMESTAMP;
|
||||
pGpuCpuTime->CPUTimeinNS = CPU_TIME_IN_NS;
|
||||
return true;
|
||||
}
|
||||
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
};
|
||||
|
||||
class MockOSTimeWithConstTimestamp : public OSTime {
|
||||
public:
|
||||
MockOSTimeWithConstTimestamp() {
|
||||
this->deviceTime = std::make_unique<MockDeviceTimeWithConstTimestamp>();
|
||||
}
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
*timeStamp = MockDeviceTimeWithConstTimestamp::CPU_TIME_IN_NS;
|
||||
return true;
|
||||
}
|
||||
|
||||
double getHostTimerResolution() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user