mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Add new functionality to load SIP from file
Related-To: NEO-5718 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f83b51e628
commit
902cce597a
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "shared/source/built_ins/sip.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -59,7 +59,7 @@ GEN11TEST_F(Gen11PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSip
|
||||
|
||||
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
|
||||
ASSERT_NE(nullptr, stateSipCmd);
|
||||
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, *device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
EXPECT_EQ(SipKernel::getSipKernel(*device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, WhenGettingPreemptionWaCsSizeThenZeroIsReturned) {
|
||||
|
||||
@@ -65,7 +65,7 @@ GEN9TEST_F(Gen9PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSipIs
|
||||
|
||||
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
|
||||
ASSERT_NE(nullptr, stateSipCmd);
|
||||
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, *device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
EXPECT_EQ(SipKernel::getSipKernel(*device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenMidBatchPreemptionWhenProgrammingWaCmdsBeginThenExpectNoCmds) {
|
||||
@@ -154,6 +154,5 @@ GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionModeWhenStateSipIsProgra
|
||||
auto cmd = hwParserOnlyPreemption.getCommand<STATE_SIP>();
|
||||
EXPECT_NE(nullptr, cmd);
|
||||
|
||||
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
|
||||
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer());
|
||||
EXPECT_EQ(SipKernel::getSipKernel(*mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer());
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ set(NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager_state_restore.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
|
||||
@@ -23,6 +22,7 @@ set(NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_leak_listener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_management.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sip_init.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits.h
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/built_ins_helper.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace MockSipData {
|
||||
std::unique_ptr<MockSipKernel> mockSipKernel;
|
||||
SipKernelType calledType = SipKernelType::COUNT;
|
||||
bool called = false;
|
||||
} // namespace MockSipData
|
||||
|
||||
void initSipKernel(SipKernelType type, Device &device) {
|
||||
MockSipData::calledType = type;
|
||||
MockSipData::called = true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
50
shared/test/common/helpers/sip_init.cpp
Normal file
50
shared/test/common/helpers/sip_init.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace MockSipData {
|
||||
std::unique_ptr<MockSipKernel> mockSipKernel;
|
||||
SipKernelType calledType = SipKernelType::COUNT;
|
||||
bool called = false;
|
||||
bool returned = true;
|
||||
bool useMockSip = false;
|
||||
|
||||
void clearUseFlags() {
|
||||
calledType = SipKernelType::COUNT;
|
||||
called = false;
|
||||
}
|
||||
} // namespace MockSipData
|
||||
|
||||
bool SipKernel::initSipKernel(SipKernelType type, Device &device) {
|
||||
if (MockSipData::useMockSip) {
|
||||
SipKernel::classType = SipClassType::Builtins;
|
||||
MockSipData::calledType = type;
|
||||
MockSipData::called = true;
|
||||
|
||||
MockSipData::mockSipKernel->mockSipMemoryAllocation->clearUsageInfo();
|
||||
return MockSipData::returned;
|
||||
} else {
|
||||
return SipKernel::initSipKernelImpl(type, device);
|
||||
}
|
||||
}
|
||||
|
||||
const SipKernel &SipKernel::getSipKernel(Device &device) {
|
||||
if (MockSipData::useMockSip) {
|
||||
return *MockSipData::mockSipKernel.get();
|
||||
} else {
|
||||
return SipKernel::getSipKernelImpl(device);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -49,6 +49,7 @@ class MockDevice : public RootDevice {
|
||||
using Device::executionEnvironment;
|
||||
using Device::getGlobalMemorySize;
|
||||
using Device::initializeCaps;
|
||||
using Device::isDebuggerActive;
|
||||
using RootDevice::createEngines;
|
||||
using RootDevice::defaultEngineIndex;
|
||||
using RootDevice::getDeviceBitfield;
|
||||
@@ -127,7 +128,17 @@ class MockDevice : public RootDevice {
|
||||
return std::unique_ptr<CommandStreamReceiver>(createCommandStreamReceiverFunc(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
||||
}
|
||||
|
||||
bool isDebuggerActive() const override {
|
||||
if (isDebuggerActiveParentCall) {
|
||||
return Device::isDebuggerActive();
|
||||
}
|
||||
return isDebuggerActiveReturn;
|
||||
}
|
||||
|
||||
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
||||
|
||||
bool isDebuggerActiveParentCall = true;
|
||||
bool isDebuggerActiveReturn = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -7,38 +7,19 @@
|
||||
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
|
||||
#include "cif/macros/enable.h"
|
||||
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
namespace NEO {
|
||||
MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : SipKernel(type, sipAlloc, {'s', 's', 'a', 'h'}) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
createMockSipAllocation();
|
||||
}
|
||||
|
||||
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr, {'s', 's', 'a', 'h'}) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
createMockSipAllocation();
|
||||
}
|
||||
|
||||
MockSipKernel::~MockSipKernel() = default;
|
||||
@@ -56,4 +37,16 @@ GraphicsAllocation *MockSipKernel::getSipAllocation() const {
|
||||
const std::vector<char> &MockSipKernel::getStateSaveAreaHeader() const {
|
||||
return mockStateSaveAreaHeader;
|
||||
}
|
||||
|
||||
void MockSipKernel::createMockSipAllocation() {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -31,6 +31,8 @@ class MockSipKernel : public SipKernel {
|
||||
GraphicsAllocation *getSipAllocation() const override;
|
||||
const std::vector<char> &getStateSaveAreaHeader() const override;
|
||||
|
||||
void createMockSipAllocation();
|
||||
|
||||
std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation;
|
||||
const std::vector<char> mockStateSaveAreaHeader = {'s', 's', 'a', 'h'};
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
@@ -40,5 +42,9 @@ namespace MockSipData {
|
||||
extern std::unique_ptr<MockSipKernel> mockSipKernel;
|
||||
extern SipKernelType calledType;
|
||||
extern bool called;
|
||||
extern bool returned;
|
||||
extern bool useMockSip;
|
||||
|
||||
void clearUseFlags();
|
||||
} // namespace MockSipData
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user