mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
Move mocks: cif, gmm context, compilers
Related-To: NEO-5161 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
00fc92129d
commit
d0cb27226f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,10 +8,9 @@
|
||||
#include "helper.h"
|
||||
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "opencl/source/os_interface/os_inc_base.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
#include "iga_wrapper.h"
|
||||
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "opencl/source/os_interface/os_inc_base.h"
|
||||
|
||||
#include "helper.h"
|
||||
#include "igfxfmid.h"
|
||||
#include "translate_platform_base.h"
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "opencl/source/os_interface/os_inc_base.h"
|
||||
#include "opencl/source/platform/extensions.h"
|
||||
|
||||
#include "cif/common/cif_main.h"
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "opencl/source/os_interface/os_inc_base.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
|
||||
#include "cif/common/cif_main.h"
|
||||
#include "cif/helpers/error.h"
|
||||
|
||||
@@ -28,6 +28,7 @@ set(NEO_CORE_OS_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/print.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc_base.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE ${NEO_CORE_OS_INTERFACE})
|
||||
|
||||
22
shared/source/os_interface/os_inc_base.h
Normal file
22
shared/source/os_interface/os_inc_base.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
namespace Os {
|
||||
// Compiler library names
|
||||
extern const char *frontEndDllName;
|
||||
extern const char *igcDllName;
|
||||
extern const char *testDllName;
|
||||
|
||||
// OS specific directory separator
|
||||
extern const char *fileSeparator;
|
||||
|
||||
// Os specific Metrics Library name
|
||||
extern const char *metricsLibraryDllName;
|
||||
}; // namespace Os
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_aub_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
aub_stream::AubManager *createAubManager(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, uint32_t stepping, bool localMemorySupported, uint32_t streamMode, uint64_t gpuAddressSpace) {
|
||||
return new MockAubManager(productFamily, devicesCount, memoryBankSize, stepping, localMemorySupported, streamMode, gpuAddressSpace);
|
||||
}
|
||||
} // namespace NEO
|
||||
19
shared/test/common/libult/create_tbx_sockets.cpp
Normal file
19
shared/test/common/libult/create_tbx_sockets.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/tbx/tbx_sockets_imp.h"
|
||||
#include "shared/test/common/mocks/mock_tbx_sockets.h"
|
||||
#include "shared/test/unit_test/tests_configuration.h"
|
||||
|
||||
namespace NEO {
|
||||
TbxSockets *TbxSockets::create() {
|
||||
if (testMode == TestMode::AubTestsWithTbx) {
|
||||
return new TbxSocketsImp;
|
||||
}
|
||||
return new MockTbxSockets;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
16
shared/test/common/libult/os_interface.cpp
Normal file
16
shared/test/common/libult/os_interface.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
#include "shared/source/helpers/constants.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool OSInterface::osEnableLocalMemory = true;
|
||||
|
||||
} // namespace NEO
|
||||
109
shared/test/common/libult/source_level_debugger_library.cpp
Normal file
109
shared/test/common/libult/source_level_debugger_library.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "source_level_debugger_library.h"
|
||||
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
bool DebuggerLibrary::debuggerActive = false;
|
||||
bool DebuggerLibrary::isLibraryAvailable = false;
|
||||
DebuggerLibraryInterceptor *DebuggerLibrary::interceptor = nullptr;
|
||||
|
||||
void *DebuggerLibrary::getProcAddress(const std::string &procName) {
|
||||
if (procName == "notifyNewDevice") {
|
||||
return reinterpret_cast<void *>(notifyNewDevice);
|
||||
} else if (procName == "notifySourceCode") {
|
||||
return reinterpret_cast<void *>(notifySourceCode);
|
||||
} else if (procName == "getDebuggerOption") {
|
||||
return reinterpret_cast<void *>(getDebuggerOption);
|
||||
} else if (procName == "notifyKernelDebugData") {
|
||||
return reinterpret_cast<void *>(notifyKernelDebugData);
|
||||
} else if (procName == "init") {
|
||||
return reinterpret_cast<void *>(init);
|
||||
} else if (procName == "isDebuggerActive") {
|
||||
return reinterpret_cast<void *>(isDebuggerActive);
|
||||
} else if (procName == "notifyDeviceDestruction") {
|
||||
return reinterpret_cast<void *>(notifyDeviceDestruction);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OsLibrary *DebuggerLibrary::load(const std::string &name) {
|
||||
if (isLibraryAvailable) {
|
||||
return new DebuggerLibrary();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::notifyNewDevice(GfxDbgNewDeviceData *newDevice) {
|
||||
if (interceptor) {
|
||||
interceptor->newDeviceArgIn = *newDevice;
|
||||
interceptor->newDeviceCalled = true;
|
||||
return interceptor->newDeviceRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::notifySourceCode(GfxDbgSourceCode *sourceCode) {
|
||||
if (interceptor) {
|
||||
interceptor->sourceCodeArgIn = *sourceCode;
|
||||
interceptor->sourceCodeCalled = true;
|
||||
if (interceptor->sourceCodeArgOut && sourceCode->sourceNameMaxLen > 0) {
|
||||
memcpy_s(sourceCode->sourceName, sourceCode->sourceNameMaxLen, interceptor->sourceCodeArgOut->sourceName, interceptor->sourceCodeArgOut->sourceNameMaxLen);
|
||||
}
|
||||
return interceptor->sourceCodeRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::getDebuggerOption(GfxDbgOption *option) {
|
||||
if (interceptor) {
|
||||
interceptor->optionArgIn = *option;
|
||||
interceptor->optionCalled = true;
|
||||
|
||||
if (interceptor->optionArgOut && option->valueLen >= interceptor->optionArgOut->valueLen) {
|
||||
memcpy_s(option->value, option->valueLen, interceptor->optionArgOut->value, interceptor->optionArgOut->valueLen);
|
||||
} else {
|
||||
memset(option->value, 0, option->valueLen);
|
||||
}
|
||||
return interceptor->optionRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::notifyKernelDebugData(GfxDbgKernelDebugData *kernelDebugData) {
|
||||
if (interceptor) {
|
||||
interceptor->kernelDebugDataArgIn = *kernelDebugData;
|
||||
interceptor->kernelDebugDataCalled = true;
|
||||
return interceptor->kernelDebugDataRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::init(GfxDbgTargetCaps *targetCaps) {
|
||||
if (interceptor) {
|
||||
interceptor->targetCapsArgIn = *targetCaps;
|
||||
interceptor->initCalled = true;
|
||||
return interceptor->initRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::isDebuggerActive(void) {
|
||||
return debuggerActive ? 1 : 0;
|
||||
}
|
||||
|
||||
int DebuggerLibrary::notifyDeviceDestruction(GfxDbgDeviceDestructionData *deviceDestruction) {
|
||||
if (interceptor) {
|
||||
interceptor->deviceDestructionArgIn = *deviceDestruction;
|
||||
interceptor->deviceDestructionCalled = true;
|
||||
return interceptor->deviceDestructionRetVal;
|
||||
}
|
||||
return IgfxdbgRetVal::IGFXDBG_SUCCESS;
|
||||
}
|
||||
94
shared/test/common/libult/source_level_debugger_library.h
Normal file
94
shared/test/common/libult/source_level_debugger_library.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "igfx_debug_interchange_types.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#define IGFXDBG_CURRENT_VERSION 4
|
||||
|
||||
struct DebuggerLibraryInterceptor {
|
||||
GfxDbgNewDeviceData newDeviceArgIn;
|
||||
GfxDbgSourceCode sourceCodeArgIn;
|
||||
GfxDbgOption optionArgIn;
|
||||
GfxDbgKernelDebugData kernelDebugDataArgIn;
|
||||
GfxDbgTargetCaps targetCapsArgIn;
|
||||
GfxDbgDeviceDestructionData deviceDestructionArgIn;
|
||||
|
||||
GfxDbgNewDeviceData *newDeviceArgOut = nullptr;
|
||||
GfxDbgSourceCode *sourceCodeArgOut = nullptr;
|
||||
GfxDbgOption *optionArgOut = nullptr;
|
||||
GfxDbgKernelDebugData *kernelDebugDataArgOut = nullptr;
|
||||
GfxDbgTargetCaps *targetCapsArgOut = nullptr;
|
||||
GfxDbgDeviceDestructionData *deviceDestructionArgOut = nullptr;
|
||||
|
||||
bool newDeviceCalled = false;
|
||||
bool sourceCodeCalled = false;
|
||||
bool optionCalled = false;
|
||||
bool kernelDebugDataCalled = false;
|
||||
bool initCalled = false;
|
||||
bool deviceDestructionCalled = false;
|
||||
|
||||
int newDeviceRetVal = 0;
|
||||
int sourceCodeRetVal = 0;
|
||||
int optionRetVal = 0;
|
||||
int kernelDebugDataRetVal = 0;
|
||||
int initRetVal = 0;
|
||||
int deviceDestructionRetVal = 0;
|
||||
};
|
||||
|
||||
class DebuggerLibrary : public NEO::OsLibrary {
|
||||
public:
|
||||
DebuggerLibrary() = default;
|
||||
void *getProcAddress(const std::string &procName) override;
|
||||
|
||||
static OsLibrary *load(const std::string &name);
|
||||
|
||||
bool isLoaded() override {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void setDebuggerActive(bool active) {
|
||||
debuggerActive = active;
|
||||
}
|
||||
|
||||
static bool getDebuggerActive() {
|
||||
return debuggerActive;
|
||||
}
|
||||
|
||||
static void setLibraryAvailable(bool available) {
|
||||
isLibraryAvailable = available;
|
||||
}
|
||||
|
||||
static bool getLibraryAvailable() {
|
||||
return isLibraryAvailable;
|
||||
}
|
||||
|
||||
static void injectDebuggerLibraryInterceptor(DebuggerLibraryInterceptor *interceptorArg) {
|
||||
interceptor = interceptorArg;
|
||||
}
|
||||
|
||||
static void clearDebuggerLibraryInterceptor() {
|
||||
interceptor = nullptr;
|
||||
}
|
||||
|
||||
static DebuggerLibraryInterceptor *interceptor;
|
||||
|
||||
protected:
|
||||
static int notifyNewDevice(GfxDbgNewDeviceData *);
|
||||
static int notifySourceCode(GfxDbgSourceCode *);
|
||||
static int getDebuggerOption(GfxDbgOption *);
|
||||
static int notifyKernelDebugData(GfxDbgKernelDebugData *);
|
||||
static int init(GfxDbgTargetCaps *);
|
||||
static int isDebuggerActive(void);
|
||||
static int notifyDeviceDestruction(GfxDbgDeviceDestructionData *);
|
||||
|
||||
static bool isLibraryAvailable;
|
||||
static bool debuggerActive;
|
||||
};
|
||||
16
shared/test/common/libult/source_level_debugger_ult.cpp
Normal file
16
shared/test/common/libult/source_level_debugger_ult.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/source_level_debugger/source_level_debugger.h"
|
||||
#include "shared/test/common/libult/source_level_debugger_library.h"
|
||||
|
||||
namespace NEO {
|
||||
OsLibrary *SourceLevelDebugger::loadDebugger() {
|
||||
return DebuggerLibrary::load(SourceLevelDebugger::dllName);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -4,17 +4,36 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_tests_compiler_mocks
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_cif.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_cif.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_tests_compiler_mocks ${NEO_CORE_tests_compiler_mocks})
|
||||
|
||||
set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_bindless_heaps_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_cif.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_cif.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compilers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compilers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_diagnostic_collector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_experimental_command_buffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context_base.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_client_context_base.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gmm_client_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_gmm_client_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_debugger.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_device.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_device.h
|
||||
@@ -31,6 +50,8 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_deferred_deleter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_deferred_deleter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_physical_address_allocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_tbx_csr.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_tbx_stream.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.h
|
||||
)
|
||||
|
||||
171
shared/test/common/mocks/mock_aub_manager.h
Normal file
171
shared/test/common/mocks/mock_aub_manager.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include "third_party/aub_stream/headers/allocation_params.h"
|
||||
#include "third_party/aub_stream/headers/aub_manager.h"
|
||||
#include "third_party/aub_stream/headers/aubstream.h"
|
||||
#include "third_party/aub_stream/headers/hardware_context.h"
|
||||
|
||||
struct MockHardwareContext : public aub_stream::HardwareContext {
|
||||
using SurfaceInfo = aub_stream::SurfaceInfo;
|
||||
|
||||
MockHardwareContext(uint32_t deviceIndex) : deviceIndex(deviceIndex) {}
|
||||
~MockHardwareContext() override {}
|
||||
|
||||
void initialize() override { initializeCalled = true; }
|
||||
void pollForCompletion() override { pollForCompletionCalled = true; }
|
||||
void writeAndSubmitBatchBuffer(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank, size_t pageSize) override { writeAndSubmitCalled = true; }
|
||||
void submitBatchBuffer(uint64_t gfxAddress, bool overrideRingHead) override { submitCalled = true; }
|
||||
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) override {
|
||||
UNRECOVERABLE_IF(true); // shouldnt be used
|
||||
}
|
||||
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
|
||||
writeMemory2Called = true;
|
||||
writeMemoryPageSizePassed = allocationParams.pageSize;
|
||||
memoryBanksPassed = allocationParams.memoryBanks;
|
||||
|
||||
if (storeAllocationParams) {
|
||||
storedAllocationParams.push_back(allocationParams);
|
||||
}
|
||||
}
|
||||
void writeMMIO(uint32_t offset, uint32_t value) override { writeMMIOCalled = true; }
|
||||
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
|
||||
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
|
||||
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; }
|
||||
void dumpBufferBIN(uint64_t gfxAddress, size_t size) override { dumpBufferBINCalled = true; }
|
||||
void dumpSurface(const SurfaceInfo &surfaceInfo) override { dumpSurfaceCalled = true; }
|
||||
|
||||
std::vector<aub_stream::AllocationParams> storedAllocationParams;
|
||||
bool storeAllocationParams = false;
|
||||
bool initializeCalled = false;
|
||||
bool pollForCompletionCalled = false;
|
||||
bool writeAndSubmitCalled = false;
|
||||
bool submitCalled = false;
|
||||
bool writeMemory2Called = false;
|
||||
bool freeMemoryCalled = false;
|
||||
bool expectMemoryCalled = false;
|
||||
bool readMemoryCalled = false;
|
||||
bool writeMMIOCalled = false;
|
||||
bool dumpBufferBINCalled = false;
|
||||
bool dumpSurfaceCalled = false;
|
||||
|
||||
size_t writeMemoryPageSizePassed = 0;
|
||||
uint32_t memoryBanksPassed = 0;
|
||||
|
||||
const uint32_t deviceIndex;
|
||||
};
|
||||
|
||||
class MockAubManager : public aub_stream::AubManager {
|
||||
using HardwareContext = aub_stream::HardwareContext;
|
||||
using PageInfo = aub_stream::PageInfo;
|
||||
|
||||
public:
|
||||
MockAubManager(){};
|
||||
MockAubManager(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, uint32_t stepping, bool localMemorySupported, uint32_t streamMode, uint64_t gpuAddressSpace) {
|
||||
mockAubManagerParams.productFamily = productFamily;
|
||||
mockAubManagerParams.devicesCount = devicesCount;
|
||||
mockAubManagerParams.memoryBankSize = memoryBankSize;
|
||||
mockAubManagerParams.stepping = stepping;
|
||||
mockAubManagerParams.localMemorySupported = localMemorySupported;
|
||||
mockAubManagerParams.streamMode = streamMode;
|
||||
mockAubManagerParams.gpuAddressSpace = gpuAddressSpace;
|
||||
}
|
||||
~MockAubManager() override {}
|
||||
|
||||
HardwareContext *createHardwareContext(uint32_t device, uint32_t engine) { return createHardwareContext(device, engine, 0); }
|
||||
HardwareContext *createHardwareContext(uint32_t device, uint32_t engine, uint32_t flags) override {
|
||||
contextFlags = flags;
|
||||
return new MockHardwareContext(device);
|
||||
}
|
||||
|
||||
void open(const std::string &aubFileName) override {
|
||||
fileName.assign(aubFileName);
|
||||
openCalledCnt++;
|
||||
}
|
||||
void close() override {
|
||||
fileName.clear();
|
||||
closeCalled = true;
|
||||
}
|
||||
bool isOpen() override {
|
||||
isOpenCalled = true;
|
||||
return !fileName.empty();
|
||||
}
|
||||
const std::string getFileName() override {
|
||||
getFileNameCalled = true;
|
||||
return fileName;
|
||||
}
|
||||
void pause(bool onoff) override {
|
||||
isPaused = onoff;
|
||||
}
|
||||
|
||||
void addComment(const char *message) override {
|
||||
receivedComment.assign(message);
|
||||
addCommentCalled = true;
|
||||
}
|
||||
|
||||
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) override {
|
||||
UNRECOVERABLE_IF(true); // shouldnt be used
|
||||
}
|
||||
|
||||
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
|
||||
writeMemory2Called = true;
|
||||
hintToWriteMemory = allocationParams.hint;
|
||||
writeMemoryPageSizePassed = allocationParams.pageSize;
|
||||
|
||||
if (storeAllocationParams) {
|
||||
storedAllocationParams.push_back(allocationParams);
|
||||
}
|
||||
}
|
||||
|
||||
void writePageTableEntries(uint64_t gfxAddress, size_t size, uint32_t memoryBanks, int hint,
|
||||
std::vector<PageInfo> &lastLevelPages, size_t pageSize) override {
|
||||
writePageTableEntriesCalled = true;
|
||||
}
|
||||
|
||||
void writePhysicalMemoryPages(const void *memory, std::vector<PageInfo> &pages, size_t size, int hint) override {
|
||||
writePhysicalMemoryPagesCalled = true;
|
||||
}
|
||||
|
||||
void freeMemory(uint64_t gfxAddress, size_t size) override {
|
||||
freeMemoryCalled = true;
|
||||
}
|
||||
|
||||
std::vector<aub_stream::AllocationParams> storedAllocationParams;
|
||||
uint32_t openCalledCnt = 0;
|
||||
std::string fileName = "";
|
||||
bool closeCalled = false;
|
||||
bool isOpenCalled = false;
|
||||
bool getFileNameCalled = false;
|
||||
bool isPaused = false;
|
||||
bool addCommentCalled = false;
|
||||
std::string receivedComment = "";
|
||||
bool writeMemory2Called = false;
|
||||
bool writePageTableEntriesCalled = false;
|
||||
bool writePhysicalMemoryPagesCalled = false;
|
||||
bool freeMemoryCalled = false;
|
||||
bool storeAllocationParams = false;
|
||||
uint32_t contextFlags = 0;
|
||||
int hintToWriteMemory = 0;
|
||||
size_t writeMemoryPageSizePassed = 0;
|
||||
|
||||
struct MockAubManagerParams {
|
||||
uint32_t productFamily = 0;
|
||||
int32_t devicesCount = 0;
|
||||
uint64_t memoryBankSize = 0;
|
||||
uint32_t stepping = 0;
|
||||
bool localMemorySupported = false;
|
||||
uint32_t streamMode = 0xFFFFFFFF;
|
||||
uint64_t gpuAddressSpace = 0xFFFFFFFFFFFF;
|
||||
} mockAubManagerParams;
|
||||
|
||||
protected:
|
||||
HardwareContext *hardwareContext = nullptr;
|
||||
};
|
||||
131
shared/test/common/mocks/mock_cif.cpp
Normal file
131
shared/test/common/mocks/mock_cif.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_cif.h"
|
||||
|
||||
#include "cif/builtins/memory/buffer/buffer.h"
|
||||
#include "cif/export/library_api.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool failCreateCifMain = false;
|
||||
}
|
||||
|
||||
namespace CIF {
|
||||
|
||||
namespace Builtins {
|
||||
|
||||
template <typename... ArgsT>
|
||||
Buffer<0>::Buffer(ArgsT &&...args) {
|
||||
}
|
||||
|
||||
Buffer<0>::~Buffer() {
|
||||
}
|
||||
|
||||
void BufferSimple::SetAllocator(CIF::Builtins::AllocatorT allocator, CIF::Builtins::DeallocatorT deallocator,
|
||||
CIF::Builtins::ReallocatorT reallocator) {
|
||||
}
|
||||
|
||||
void BufferSimple::SetUnderlyingStorage(void *memory, size_t size, CIF::Builtins::DeallocatorT deallocator) {
|
||||
}
|
||||
|
||||
void BufferSimple::SetUnderlyingStorage(const void *memory, size_t size) {
|
||||
}
|
||||
|
||||
void *BufferSimple::DetachAllocation() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void *BufferSimple::GetMemoryRaw() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *BufferSimple::GetMemoryRawWriteable() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t BufferSimple::GetSizeRaw() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t BufferSimple::GetCapacityRaw() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BufferSimple::Resize(size_t newSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferSimple::Reserve(size_t newCapacity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void BufferSimple::Clear() {
|
||||
}
|
||||
|
||||
void BufferSimple::Deallocate() {
|
||||
}
|
||||
|
||||
bool BufferSimple::AlignUp(uint32_t alignment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferSimple::PushBackRawBytes(const void *newData, size_t size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferSimple::IsConst() const {
|
||||
return false;
|
||||
}
|
||||
} // namespace Builtins
|
||||
} // namespace CIF
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::map<CIF::InterfaceId_t, CreatorFuncT> MockCIFMain::globalCreators;
|
||||
|
||||
bool MockCIFBuffer::failAllocations = false;
|
||||
|
||||
CIF::ICIF *MockCIFBuffer::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
||||
if (failAllocations) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (version != CIF::Builtins::BufferSimple::GetVersion()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new MockCIFBuffer();
|
||||
}
|
||||
|
||||
MockCIFBuffer::MockCIFBuffer() {
|
||||
}
|
||||
|
||||
MockCIFMain::MockCIFMain() {
|
||||
defaultCreators[CIF::Builtins::BufferSimple::GetInterfaceId()] = MockCIFBuffer::Create;
|
||||
}
|
||||
|
||||
CIF::ICIF *MockCIFMain::CreateInterfaceImpl(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
||||
auto it = globalCreators.find(intId);
|
||||
if ((it == globalCreators.end()) || (it->second == nullptr)) {
|
||||
it = defaultCreators.find(intId);
|
||||
if ((it == defaultCreators.end()) || (it->second == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return it->second(intId, version);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
extern CIF::CIFMain *CreateCIFMainImpl() {
|
||||
if (NEO::failCreateCifMain) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new NEO::MockCIFMain;
|
||||
}
|
||||
222
shared/test/common/mocks/mock_cif.h
Normal file
222
shared/test/common/mocks/mock_cif.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cif/builtins/memory/buffer/buffer.h"
|
||||
#include "cif/common/cif.h"
|
||||
#include "cif/common/cif_main.h"
|
||||
#include "cif/common/id.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
extern bool failCreateCifMain;
|
||||
|
||||
using CreatorFuncT = CIF::ICIF *(*)(CIF::InterfaceId_t intId, CIF::Version_t version);
|
||||
|
||||
template <typename BaseType = CIF::ICIF>
|
||||
struct MockCIF : BaseType {
|
||||
void Release() override { // NOLINT(readability-identifier-naming)
|
||||
auto prev = refCount--;
|
||||
assert(prev >= 1);
|
||||
if (prev == 1) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void Retain() override { // NOLINT(readability-identifier-naming)
|
||||
++refCount;
|
||||
}
|
||||
|
||||
uint32_t GetRefCount() const override { // NOLINT(readability-identifier-naming)
|
||||
return refCount;
|
||||
}
|
||||
|
||||
CIF::Version_t GetEnabledVersion() const override { // NOLINT(readability-identifier-naming)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool GetSupportedVersions(CIF::InterfaceId_t intId, CIF::Version_t &verMin, // NOLINT(readability-identifier-naming)
|
||||
CIF::Version_t &verMax) const override {
|
||||
verMin = 1;
|
||||
verMax = CIF::MaxVersion;
|
||||
return true; // by default : no sub-interface are supported
|
||||
}
|
||||
|
||||
uint32_t refCount = 1u;
|
||||
};
|
||||
|
||||
struct MockCIFMain : MockCIF<CIF::CIFMain> {
|
||||
template <typename InterfaceT>
|
||||
static void setGlobalCreatorFunc(CreatorFuncT func) {
|
||||
globalCreators[InterfaceT::GetInterfaceId()] = func;
|
||||
}
|
||||
|
||||
template <typename InterfaceT>
|
||||
void setDefaultCreatorFunc(CreatorFuncT func) {
|
||||
defaultCreators[InterfaceT::GetInterfaceId()] = func;
|
||||
}
|
||||
|
||||
template <typename InterfaceT>
|
||||
static CreatorFuncT getGlobalCreatorFunc() {
|
||||
auto it = globalCreators.find(InterfaceT::GetInterfaceId());
|
||||
if (it == globalCreators.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
template <typename InterfaceT>
|
||||
static void removeGlobalCreatorFunc() {
|
||||
auto it = globalCreators.find(InterfaceT::GetInterfaceId());
|
||||
if (it == globalCreators.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
globalCreators.erase(it);
|
||||
}
|
||||
|
||||
static void clearGlobalCreatorFuncs() {
|
||||
decltype(globalCreators) emptyCreators;
|
||||
globalCreators.swap(emptyCreators);
|
||||
}
|
||||
|
||||
static std::map<CIF::InterfaceId_t, CreatorFuncT> globalCreators;
|
||||
|
||||
MockCIFMain();
|
||||
|
||||
CIF::Version_t GetBinaryVersion() const override { // NOLINT(readability-identifier-naming)
|
||||
return 1;
|
||||
}
|
||||
|
||||
CIF::ICIF *CreateInterfaceImpl(CIF::InterfaceId_t intId, CIF::Version_t version) override; // NOLINT(readability-identifier-naming)
|
||||
|
||||
CIF::InterfaceId_t FindIncompatibleImpl(CIF::InterfaceId_t entryPointInterface, CIF::CompatibilityDataHandle handle) const override { // NOLINT(readability-identifier-naming)
|
||||
if (globalCreators.find(entryPointInterface) != globalCreators.end()) {
|
||||
return CIF::InvalidInterface;
|
||||
}
|
||||
if (defaultCreators.find(entryPointInterface) != defaultCreators.end()) {
|
||||
return CIF::InvalidInterface;
|
||||
}
|
||||
return entryPointInterface;
|
||||
}
|
||||
|
||||
bool FindSupportedVersionsImpl(CIF::InterfaceId_t entryPointInterface, CIF::InterfaceId_t interfaceToFind, CIF::Version_t &verMin, CIF::Version_t &verMax) const override { // NOLINT(readability-identifier-naming)
|
||||
if (globalCreators.find(entryPointInterface) != globalCreators.end()) {
|
||||
verMin = verMax = 1;
|
||||
return true;
|
||||
}
|
||||
if (defaultCreators.find(entryPointInterface) != defaultCreators.end()) {
|
||||
verMin = verMax = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<CIF::InterfaceId_t, CreatorFuncT> defaultCreators;
|
||||
};
|
||||
|
||||
struct MockCIFBuffer : MockCIF<CIF::Builtins::BufferSimple> {
|
||||
MockCIFBuffer();
|
||||
static CIF::ICIF *Create(CIF::InterfaceId_t intId, CIF::Version_t version); // NOLINT(readability-identifier-naming)
|
||||
static bool failAllocations;
|
||||
|
||||
void SetAllocator(CIF::Builtins::AllocatorT allocator, CIF::Builtins::DeallocatorT deallocator, // NOLINT(readability-identifier-naming)
|
||||
CIF::Builtins::ReallocatorT reallocator) override {
|
||||
// unsupported in mock
|
||||
}
|
||||
|
||||
void SetUnderlyingStorage(void *memory, size_t size, CIF::Builtins::DeallocatorT deallocator) override { // NOLINT(readability-identifier-naming)
|
||||
if ((memory == nullptr) || (size == 0)) {
|
||||
data.clear();
|
||||
return;
|
||||
}
|
||||
data.assign((char *)memory, ((char *)memory) + size);
|
||||
}
|
||||
|
||||
void SetUnderlyingStorage(const void *memory, size_t size) override { // NOLINT(readability-identifier-naming)
|
||||
if ((memory == nullptr) || (size == 0)) {
|
||||
data.clear();
|
||||
return;
|
||||
}
|
||||
data.assign((char *)memory, ((char *)memory) + size);
|
||||
}
|
||||
|
||||
void *DetachAllocation() override { // NOLINT(readability-identifier-naming)
|
||||
// unsupported in mock
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void *GetMemoryRaw() const override { // NOLINT(readability-identifier-naming)
|
||||
if (data.size() > 0) {
|
||||
return data.data();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void *GetMemoryRawWriteable() override { // NOLINT(readability-identifier-naming)
|
||||
if (data.size() > 0) {
|
||||
return data.data();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
size_t GetSizeRaw() const override { // NOLINT(readability-identifier-naming)
|
||||
return data.size();
|
||||
}
|
||||
|
||||
size_t GetCapacityRaw() const override { // NOLINT(readability-identifier-naming)
|
||||
return data.capacity();
|
||||
}
|
||||
|
||||
bool Resize(size_t newSize) override { // NOLINT(readability-identifier-naming)
|
||||
data.resize(newSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Reserve(size_t newCapacity) override { // NOLINT(readability-identifier-naming)
|
||||
data.reserve(newCapacity);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Clear() override { // NOLINT(readability-identifier-naming)
|
||||
data.clear();
|
||||
}
|
||||
|
||||
void Deallocate() override { // NOLINT(readability-identifier-naming)
|
||||
std::vector<char> rhs;
|
||||
rhs.swap(data);
|
||||
}
|
||||
|
||||
bool AlignUp(uint32_t alignment) override { // NOLINT(readability-identifier-naming)
|
||||
auto rest = data.size() & alignment;
|
||||
if (rest != 0) {
|
||||
data.resize(data.size() + alignment - rest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PushBackRawBytes(const void *newData, size_t size) override { // NOLINT(readability-identifier-naming)
|
||||
if ((newData == nullptr) || (size == 0)) {
|
||||
return true;
|
||||
}
|
||||
data.insert(data.end(), (char *)newData, ((char *)newData) + size);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsConst() const override { // NOLINT(readability-identifier-naming)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<char> data;
|
||||
};
|
||||
} // namespace NEO
|
||||
653
shared/test/common/mocks/mock_compilers.cpp
Normal file
653
shared/test/common/mocks/mock_compilers.cpp
Normal file
@@ -0,0 +1,653 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mock_compilers.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
#include "cif/macros/enable.h"
|
||||
#include "compiler_options.h"
|
||||
#include "ocl_igc_interface/fcl_ocl_device_ctx.h"
|
||||
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
namespace NEO {
|
||||
|
||||
std::unique_ptr<MockCompilerDebugVars> fclDebugVars;
|
||||
std::unique_ptr<MockCompilerDebugVars> igcDebugVars;
|
||||
|
||||
void setFclDebugVars(MockCompilerDebugVars &dbgv) {
|
||||
fclDebugVars.reset(new MockCompilerDebugVars(dbgv));
|
||||
}
|
||||
|
||||
void setIgcDebugVars(MockCompilerDebugVars &dbgv) {
|
||||
igcDebugVars.reset(new MockCompilerDebugVars(dbgv));
|
||||
}
|
||||
|
||||
MockCompilerDebugVars getFclDebugVars() {
|
||||
if (fclDebugVars == nullptr) {
|
||||
fclDebugVars.reset(new MockCompilerDebugVars());
|
||||
}
|
||||
return *fclDebugVars.get();
|
||||
}
|
||||
|
||||
MockCompilerDebugVars getIgcDebugVars() {
|
||||
if (igcDebugVars == nullptr) {
|
||||
igcDebugVars.reset(new MockCompilerDebugVars());
|
||||
}
|
||||
return *igcDebugVars.get();
|
||||
}
|
||||
|
||||
void clearFclDebugVars() {
|
||||
fclDebugVars.reset();
|
||||
}
|
||||
void clearIgcDebugVars() {
|
||||
igcDebugVars.reset();
|
||||
}
|
||||
|
||||
MockCompilerEnableGuard::MockCompilerEnableGuard(bool autoEnable) {
|
||||
if (autoEnable) {
|
||||
Enable();
|
||||
}
|
||||
}
|
||||
|
||||
MockCompilerEnableGuard::~MockCompilerEnableGuard() {
|
||||
Disable();
|
||||
}
|
||||
|
||||
void MockCompilerEnableGuard::Enable() {
|
||||
if (enabled == false) {
|
||||
// load mock from self (don't load dynamic libraries)
|
||||
this->oldFclDllName = Os::frontEndDllName;
|
||||
this->oldIgcDllName = Os::igcDllName;
|
||||
Os::frontEndDllName = "";
|
||||
Os::igcDllName = "";
|
||||
MockCIFMain::setGlobalCreatorFunc<NEO::MockIgcOclDeviceCtx>(NEO::MockIgcOclDeviceCtx::Create);
|
||||
MockCIFMain::setGlobalCreatorFunc<NEO::MockFclOclDeviceCtx>(NEO::MockFclOclDeviceCtx::Create);
|
||||
if (fclDebugVars == nullptr) {
|
||||
fclDebugVars.reset(new MockCompilerDebugVars);
|
||||
}
|
||||
if (fclDebugVars == nullptr) {
|
||||
igcDebugVars.reset(new MockCompilerDebugVars);
|
||||
}
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MockCompilerEnableGuard::Disable() {
|
||||
if (enabled) {
|
||||
Os::frontEndDllName = this->oldFclDllName;
|
||||
Os::igcDllName = this->oldIgcDllName;
|
||||
|
||||
MockCIFMain::removeGlobalCreatorFunc<NEO::MockIgcOclDeviceCtx>();
|
||||
MockCIFMain::removeGlobalCreatorFunc<NEO::MockFclOclDeviceCtx>();
|
||||
|
||||
clearFclDebugVars();
|
||||
clearIgcDebugVars();
|
||||
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
namespace IGC {
|
||||
|
||||
// Stub versions - overridable in mocks
|
||||
// IgcOclDeviceCtx stubs
|
||||
IgcOclDeviceCtx<0>::~IgcOclDeviceCtx() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
IgcOclDeviceCtx<0>::IgcOclDeviceCtx(ArgsT &&...args) {}
|
||||
|
||||
void CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 1)::SetProfilingTimerResolution(float v) {}
|
||||
|
||||
PlatformBase *CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 1)::GetPlatformHandleImpl(CIF::Version_t ver) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GTSystemInfoBase *CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 1)::GetGTSystemInfoHandleImpl(CIF::Version_t ver) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IgcFeaturesAndWorkaroundsBase *CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 1)::GetIgcFeaturesAndWorkaroundsHandleImpl(CIF::Version_t ver) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IgcOclTranslationCtxBase *CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 1)::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
CodeType::CodeType_t inType,
|
||||
CodeType::CodeType_t outType) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CIF_GET_INTERFACE_CLASS(IgcOclDeviceCtx, 2)::GetSystemRoutine(IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine,
|
||||
bool bindless,
|
||||
CIF::Builtins::BufferSimple *outSystemRoutineBuffer,
|
||||
CIF::Builtins::BufferSimple *stateSaveAreaHeaderInit) {
|
||||
return true;
|
||||
}
|
||||
// Platform stubs
|
||||
Platform<0>::~Platform() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
Platform<0>::Platform(ArgsT &&...args) {}
|
||||
|
||||
#define DEFINE_GET_SET_PREFIX(INTERFACE, VERSION, NAME, TYPE, PREFIX) \
|
||||
TYPE CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Get##NAME() const { return (TYPE)0; } \
|
||||
void CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Set##NAME(TYPE v) {}
|
||||
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, ProductFamily, TypeErasedEnum, e);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, PCHProductFamily, TypeErasedEnum, e);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, DisplayCoreFamily, TypeErasedEnum, e);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, RenderCoreFamily, TypeErasedEnum, e);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, PlatformType, TypeErasedEnum, e);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, DeviceID, unsigned short, us);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, RevId, unsigned short, us);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, DeviceID_PCH, unsigned short, us);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, RevId_PCH, unsigned short, us);
|
||||
DEFINE_GET_SET_PREFIX(Platform, 1, GTType, TypeErasedEnum, e);
|
||||
|
||||
#undef DEFINE_GET_SET_PREFIX
|
||||
|
||||
// GtSystemInfo stubs
|
||||
GTSystemInfo<0>::~GTSystemInfo() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
GTSystemInfo<0>::GTSystemInfo(ArgsT &&...args) {}
|
||||
|
||||
#define DEFINE_GET_SET(INTERFACE, VERSION, NAME, TYPE) \
|
||||
TYPE CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Get##NAME() const { return (TYPE)0; } \
|
||||
void CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Set##NAME(TYPE v) {}
|
||||
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, EUCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, ThreadCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, SliceCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, SubSliceCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, L3CacheSizeInKb, uint64_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, LLCCacheSizeInKb, uint64_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, EdramSizeInKb, uint64_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, L3BankCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, MaxFillRate, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, EuCountPerPoolMax, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, EuCountPerPoolMin, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, TotalVsThreads, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, TotalHsThreads, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, TotalDsThreads, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, TotalGsThreads, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, TotalPsThreadsWindowerRange, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, CsrSizeInMb, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, MaxEuPerSubSlice, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, MaxSlicesSupported, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, MaxSubSlicesSupported, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, IsL3HashModeEnabled, bool);
|
||||
DEFINE_GET_SET(GTSystemInfo, 1, IsDynamicallyPopulated, bool);
|
||||
|
||||
DEFINE_GET_SET(GTSystemInfo, 3, DualSubSliceCount, uint32_t);
|
||||
DEFINE_GET_SET(GTSystemInfo, 3, MaxDualSubSlicesSupported, uint32_t);
|
||||
|
||||
#undef DEFINE_GET_SET
|
||||
|
||||
// IgcFeaturesAndWorkarounds stubs
|
||||
IgcFeaturesAndWorkarounds<0>::~IgcFeaturesAndWorkarounds() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
IgcFeaturesAndWorkarounds<0>::IgcFeaturesAndWorkarounds(ArgsT &&...args) {}
|
||||
|
||||
#define DEFINE_GET_SET(INTERFACE, VERSION, NAME, TYPE) \
|
||||
TYPE CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Get##NAME() const { return (TYPE)0; } \
|
||||
void CIF_GET_INTERFACE_CLASS(INTERFACE, VERSION)::Set##NAME(TYPE v) {}
|
||||
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrDesktop, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrChannelSwizzlingXOREnabled, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGtBigDie, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGtMediumDie, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGtSmallDie, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGT1, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGT1_5, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGT2, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGT3, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGT4, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrIVBM0M1Platform, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTL, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTM, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTH, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrSGTPVSKUStrapPresent, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTA, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTC, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGTX, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, Ftr5Slice, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrGpGpuMidThreadLevelPreempt, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrIoMmuPageFaulting, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrWddm2Svm, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrPooledEuEnabled, bool);
|
||||
DEFINE_GET_SET(IgcFeaturesAndWorkarounds, 1, FtrResourceStreamer, bool);
|
||||
|
||||
#undef DEFINE_GET_SET
|
||||
|
||||
// IgcOclTranslationCtx
|
||||
IgcOclTranslationCtx<0>::~IgcOclTranslationCtx() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
IgcOclTranslationCtx<0>::IgcOclTranslationCtx(ArgsT &&...args) {}
|
||||
|
||||
OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 1)::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 2)::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtPinInput) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 3)::GetSpecConstantsInfoImpl(
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsIds,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsSizes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 3)::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *specConstantsIds,
|
||||
CIF::Builtins::BufferSimple *specConstantsValues,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtPinInput) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// OclTranslationOutput
|
||||
OclTranslationOutput<0>::~OclTranslationOutput() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
OclTranslationOutput<0>::OclTranslationOutput(ArgsT &&...args) {}
|
||||
|
||||
bool CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::Successful() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::HasWarnings() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
CIF::Builtins::BufferBase *CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::GetBuildLogImpl(CIF::Version_t bufferVersion) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CIF::Builtins::BufferBase *CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::GetOutputImpl(CIF::Version_t bufferVersion) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CIF::Builtins::BufferBase *CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::GetDebugDataImpl(CIF::Version_t bufferVersion) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CodeType::CodeType_t CIF_GET_INTERFACE_CLASS(OclTranslationOutput, 1)::GetOutputType() const {
|
||||
return IGC::CodeType::undefined;
|
||||
}
|
||||
|
||||
// FclOclTranslationCtx
|
||||
FclOclTranslationCtx<0>::~FclOclTranslationCtx() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
FclOclTranslationCtx<0>::FclOclTranslationCtx(ArgsT &&...args) {}
|
||||
|
||||
IGC::OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(FclOclTranslationCtx, 1)::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// MockFclOclDeviceCtx
|
||||
FclOclDeviceCtx<0>::~FclOclDeviceCtx() {}
|
||||
|
||||
template <typename... ArgsT>
|
||||
FclOclDeviceCtx<0>::FclOclDeviceCtx(ArgsT &&...args) {}
|
||||
|
||||
void CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 1)::SetOclApiVersion(uint32_t version) {}
|
||||
|
||||
IGC::FclOclTranslationCtxBase *CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 1)::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CodeType::CodeType_t CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 2)::GetPreferredIntermediateRepresentation() {
|
||||
return CodeType::spirV;
|
||||
}
|
||||
|
||||
IGC::FclOclTranslationCtxBase *CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 3)::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType,
|
||||
CIF::Builtins::BufferSimple *err) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IGC::PlatformBase *CIF_GET_INTERFACE_CLASS(FclOclDeviceCtx, 4)::GetPlatformHandleImpl(CIF::Version_t ver) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace IGC
|
||||
|
||||
#include "cif/macros/disable.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename StrT>
|
||||
std::unique_ptr<unsigned char[]> loadBinaryFile(StrT &&fileName, size_t &fileSize) {
|
||||
std::ifstream f{fileName, std::ios::binary | std::ios::in | std::ios::ate};
|
||||
auto end = f.tellg();
|
||||
f.seekg(0, std::ios::beg);
|
||||
auto beg = f.tellg();
|
||||
auto s = static_cast<size_t>(end - beg);
|
||||
if (s == 0) {
|
||||
fileSize = 0;
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<unsigned char[]> data{new unsigned char[s]};
|
||||
f.read(reinterpret_cast<char *>(data.get()), s);
|
||||
fileSize = s;
|
||||
return data;
|
||||
};
|
||||
|
||||
void translate(bool usingIgc, CIF::Builtins::BufferSimple *src, CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions, MockOclTranslationOutput *out) {
|
||||
MockCompilerDebugVars &debugVars = (usingIgc) ? *NEO::igcDebugVars : *fclDebugVars;
|
||||
if (debugVars.receivedInput != nullptr) {
|
||||
if (src != nullptr) {
|
||||
debugVars.receivedInput->assign(src->GetMemory<char>(),
|
||||
src->GetMemory<char>() + src->GetSizeRaw());
|
||||
}
|
||||
}
|
||||
|
||||
if (debugVars.receivedInternalOptionsOutput != nullptr) {
|
||||
if (internalOptions != nullptr) {
|
||||
debugVars.receivedInternalOptionsOutput->assign(internalOptions->GetMemory<char>(),
|
||||
internalOptions->GetMemory<char>() + internalOptions->GetSizeRaw());
|
||||
}
|
||||
}
|
||||
|
||||
if ((debugVars.forceBuildFailure == false) &&
|
||||
(out && src && src->GetMemoryRaw() && src->GetSizeRaw())) {
|
||||
|
||||
if (debugVars.internalOptionsExpected) {
|
||||
if (internalOptions->GetSizeRaw() < 1 || internalOptions->GetMemoryRaw() == nullptr) {
|
||||
if (out) {
|
||||
out->setError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string inputFile = "";
|
||||
inputFile.append(debugVars.fileName);
|
||||
|
||||
std::string debugFile;
|
||||
auto pos = inputFile.rfind(".");
|
||||
debugFile = inputFile.substr(0, pos);
|
||||
debugFile.append(".dbg");
|
||||
|
||||
if (debugVars.appendOptionsToFileName &&
|
||||
options->GetSizeRaw()) {
|
||||
std::string opts(options->GetMemory<char>(), options->GetMemory<char>() + options->GetSize<char>());
|
||||
// handle special option "-create-library" - just erase it
|
||||
size_t pos = opts.find(CompilerOptions::createLibrary.data(), 0);
|
||||
if (pos != std::string::npos) {
|
||||
opts.erase(pos, CompilerOptions::createLibrary.length());
|
||||
}
|
||||
std::replace(opts.begin(), opts.end(), ' ', '_');
|
||||
inputFile.append(opts);
|
||||
|
||||
if (debugVars.debugDataToReturn == nullptr) {
|
||||
debugFile.append(opts);
|
||||
}
|
||||
}
|
||||
|
||||
if ((debugVars.binaryToReturn != nullptr) || (debugVars.binaryToReturnSize != 0)) {
|
||||
out->setOutput(debugVars.binaryToReturn, debugVars.binaryToReturnSize);
|
||||
} else {
|
||||
size_t fileSize = 0;
|
||||
auto fileData = loadBinaryFile(inputFile, fileSize);
|
||||
|
||||
out->setOutput(fileData.get(), fileSize);
|
||||
if (fileSize == 0) {
|
||||
out->setError("error: Mock compiler could not find cached input file: " + inputFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (debugVars.debugDataToReturn != nullptr) {
|
||||
out->setDebugData(debugVars.debugDataToReturn, debugVars.debugDataToReturnSize);
|
||||
} else {
|
||||
size_t fileSize = 0;
|
||||
auto fileData = loadBinaryFile(debugFile, fileSize);
|
||||
out->setDebugData(fileData.get(), fileSize);
|
||||
}
|
||||
} else {
|
||||
out->setError();
|
||||
}
|
||||
}
|
||||
|
||||
MockIgcOclDeviceCtx::MockIgcOclDeviceCtx() {
|
||||
platform = new MockCIFPlatform;
|
||||
gtSystemInfo = new MockGTSystemInfo;
|
||||
igcFeWa = new MockIgcFeaturesAndWorkarounds;
|
||||
}
|
||||
|
||||
MockIgcOclDeviceCtx::~MockIgcOclDeviceCtx() {
|
||||
if (platform != nullptr) {
|
||||
platform->Release();
|
||||
}
|
||||
if (gtSystemInfo != nullptr) {
|
||||
gtSystemInfo->Release();
|
||||
}
|
||||
if (igcFeWa != nullptr) {
|
||||
igcFeWa->Release();
|
||||
}
|
||||
}
|
||||
|
||||
CIF::ICIF *MockIgcOclDeviceCtx::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
||||
return new MockIgcOclDeviceCtx;
|
||||
}
|
||||
|
||||
IGC::IgcOclTranslationCtxBase *MockIgcOclDeviceCtx::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) {
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
return new MockIgcOclTranslationCtx;
|
||||
}
|
||||
|
||||
bool MockIgcOclDeviceCtx::GetSystemRoutine(IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine,
|
||||
bool bindless,
|
||||
CIF::Builtins::BufferSimple *outSystemRoutineBuffer,
|
||||
CIF::Builtins::BufferSimple *stateSaveAreaHeaderInit) {
|
||||
MockCompilerDebugVars &debugVars = *NEO::igcDebugVars;
|
||||
debugVars.typeOfSystemRoutine = typeOfSystemRoutine;
|
||||
debugVars.receivedSipAddressingType = bindless ? MockCompilerDebugVars::SipAddressingType::bindless : MockCompilerDebugVars::SipAddressingType::bindful;
|
||||
|
||||
const char mockData1[64] = {'C', 'T', 'N', 'I'};
|
||||
const char mockData2[64] = {'S', 'S', 'A', 'H'};
|
||||
|
||||
if (debugVars.forceBuildFailure || typeOfSystemRoutine == IGC::SystemRoutineType::undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
outSystemRoutineBuffer->PushBackRawBytes(mockData1, 64);
|
||||
stateSaveAreaHeaderInit->PushBackRawBytes(mockData2, 64);
|
||||
return true;
|
||||
}
|
||||
|
||||
MockIgcOclTranslationCtx::MockIgcOclTranslationCtx() = default;
|
||||
MockIgcOclTranslationCtx::~MockIgcOclTranslationCtx() = default;
|
||||
|
||||
IGC::OclTranslationOutputBase *MockIgcOclTranslationCtx::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) {
|
||||
auto out = new MockOclTranslationOutput();
|
||||
translate(true, src, options, internalOptions, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
IGC::OclTranslationOutputBase *MockIgcOclTranslationCtx::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtpinInput) {
|
||||
auto out = new MockOclTranslationOutput();
|
||||
translate(true, src, options, internalOptions, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool MockIgcOclTranslationCtx::GetSpecConstantsInfoImpl(
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsIds,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsSizes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IGC::OclTranslationOutputBase *MockIgcOclTranslationCtx::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *specConstantsIds,
|
||||
CIF::Builtins::BufferSimple *specConstantsValues,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtPinInput) {
|
||||
auto out = new MockOclTranslationOutput();
|
||||
translate(true, src, options, internalOptions, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
MockOclTranslationOutput::MockOclTranslationOutput() {
|
||||
this->log = new MockCIFBuffer();
|
||||
this->output = new MockCIFBuffer();
|
||||
this->debugData = new MockCIFBuffer();
|
||||
}
|
||||
|
||||
MockOclTranslationOutput::~MockOclTranslationOutput() {
|
||||
if (this->log != nullptr) {
|
||||
this->log->Release();
|
||||
}
|
||||
|
||||
if (this->output != nullptr) {
|
||||
this->output->Release();
|
||||
}
|
||||
|
||||
if (this->debugData != nullptr) {
|
||||
this->debugData->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void MockOclTranslationOutput::setError(const std::string &message) {
|
||||
failed = true;
|
||||
this->log->SetUnderlyingStorage(message.c_str(), message.size());
|
||||
}
|
||||
|
||||
void MockOclTranslationOutput::setOutput(const void *data, size_t dataLen) {
|
||||
this->output->SetUnderlyingStorage(data, dataLen);
|
||||
}
|
||||
|
||||
void MockOclTranslationOutput::setDebugData(const void *data, size_t dataLen) {
|
||||
this->debugData->SetUnderlyingStorage(data, dataLen);
|
||||
}
|
||||
|
||||
CIF::Builtins::BufferBase *MockOclTranslationOutput::GetBuildLogImpl(CIF::Version_t bufferVersion) {
|
||||
return log;
|
||||
}
|
||||
|
||||
CIF::Builtins::BufferBase *MockOclTranslationOutput::GetOutputImpl(CIF::Version_t bufferVersion) {
|
||||
return output;
|
||||
}
|
||||
CIF::Builtins::BufferBase *MockOclTranslationOutput::GetDebugDataImpl(CIF::Version_t bufferVersion) {
|
||||
return debugData;
|
||||
}
|
||||
|
||||
MockFclOclTranslationCtx::MockFclOclTranslationCtx() {
|
||||
}
|
||||
|
||||
MockFclOclTranslationCtx::~MockFclOclTranslationCtx() {
|
||||
}
|
||||
|
||||
IGC::OclTranslationOutputBase *MockFclOclTranslationCtx::TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) {
|
||||
auto out = new MockOclTranslationOutput();
|
||||
translate(false, src, options, internalOptions, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
MockFclOclDeviceCtx::MockFclOclDeviceCtx() {
|
||||
platform = new MockCIFPlatform;
|
||||
}
|
||||
|
||||
MockFclOclDeviceCtx::~MockFclOclDeviceCtx() {
|
||||
if (nullptr != platform) {
|
||||
platform->Release();
|
||||
}
|
||||
}
|
||||
|
||||
CIF::ICIF *MockFclOclDeviceCtx::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
||||
return new MockFclOclDeviceCtx;
|
||||
}
|
||||
|
||||
IGC::FclOclTranslationCtxBase *MockFclOclDeviceCtx::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) {
|
||||
return new MockFclOclTranslationCtx;
|
||||
}
|
||||
|
||||
IGC::FclOclTranslationCtxBase *MockFclOclDeviceCtx::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType,
|
||||
CIF::Builtins::BufferSimple *err) {
|
||||
return new MockFclOclTranslationCtx;
|
||||
}
|
||||
|
||||
std::vector<char> MockCompilerInterface::getDummyGenBinary() {
|
||||
return MockSipKernel::getDummyGenBinary();
|
||||
}
|
||||
void MockCompilerInterface::releaseDummyGenBinary() {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
286
shared/test/common/mocks/mock_compilers.h
Normal file
286
shared/test/common/mocks/mock_compilers.h
Normal file
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/test/common/mocks/mock_cif.h"
|
||||
|
||||
#include "ocl_igc_interface/fcl_ocl_device_ctx.h"
|
||||
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct MockCompilerDebugVars {
|
||||
enum class SipAddressingType {
|
||||
unknown,
|
||||
bindful,
|
||||
bindless
|
||||
};
|
||||
bool forceBuildFailure = false;
|
||||
bool forceCreateFailure = false;
|
||||
bool forceRegisterFail = false;
|
||||
bool internalOptionsExpected = false;
|
||||
bool appendOptionsToFileName = true;
|
||||
void *debugDataToReturn = nullptr;
|
||||
size_t debugDataToReturnSize = 0;
|
||||
void *binaryToReturn = nullptr;
|
||||
size_t binaryToReturnSize = 0;
|
||||
bool failCreatePlatformInterface = false;
|
||||
bool failCreateGtSystemInfoInterface = false;
|
||||
bool failCreateIgcFeWaInterface = false;
|
||||
int64_t overrideFclDeviceCtxVersion = -1;
|
||||
IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined;
|
||||
SipAddressingType receivedSipAddressingType = SipAddressingType::unknown;
|
||||
std::string *receivedInternalOptionsOutput = nullptr;
|
||||
std::string *receivedInput = nullptr;
|
||||
|
||||
std::string fileName;
|
||||
};
|
||||
|
||||
struct MockCompilerEnableGuard {
|
||||
MockCompilerEnableGuard(bool autoEnable = false);
|
||||
~MockCompilerEnableGuard();
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
||||
const char *oldFclDllName;
|
||||
const char *oldIgcDllName;
|
||||
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
void setFclDebugVars(MockCompilerDebugVars &dbgv);
|
||||
void setIgcDebugVars(MockCompilerDebugVars &dbgv);
|
||||
void clearFclDebugVars();
|
||||
void clearIgcDebugVars();
|
||||
|
||||
MockCompilerDebugVars getFclDebugVars();
|
||||
MockCompilerDebugVars getIgcDebugVars();
|
||||
|
||||
struct MockCIFPlatform : MockCIF<IGC::PlatformTagOCL> {
|
||||
IGC::TypeErasedEnum GetProductFamily() const override {
|
||||
return productFamily;
|
||||
}
|
||||
void SetProductFamily(IGC::TypeErasedEnum v) override {
|
||||
productFamily = v;
|
||||
}
|
||||
IGC::TypeErasedEnum GetRenderCoreFamily() const override {
|
||||
return renderCoreFamily;
|
||||
}
|
||||
void SetRenderCoreFamily(IGC::TypeErasedEnum v) override {
|
||||
renderCoreFamily = v;
|
||||
}
|
||||
|
||||
protected:
|
||||
IGC::TypeErasedEnum productFamily;
|
||||
IGC::TypeErasedEnum renderCoreFamily;
|
||||
};
|
||||
|
||||
struct MockGTSystemInfo : MockCIF<IGC::GTSystemInfoTagOCL> {
|
||||
uint32_t GetEUCount() const override {
|
||||
return this->euCount;
|
||||
}
|
||||
void SetEUCount(uint32_t v) override {
|
||||
euCount = v;
|
||||
}
|
||||
uint32_t GetThreadCount() const override {
|
||||
return this->threadCount;
|
||||
}
|
||||
void SetThreadCount(uint32_t v) override {
|
||||
threadCount = v;
|
||||
}
|
||||
uint32_t GetSliceCount() const override {
|
||||
return this->sliceCount;
|
||||
}
|
||||
void SetSliceCount(uint32_t v) override {
|
||||
sliceCount = v;
|
||||
}
|
||||
uint32_t GetSubSliceCount() const override {
|
||||
return this->subsliceCount;
|
||||
}
|
||||
void SetSubSliceCount(uint32_t v) override {
|
||||
subsliceCount = v;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t euCount;
|
||||
uint32_t threadCount;
|
||||
uint32_t sliceCount;
|
||||
uint32_t subsliceCount;
|
||||
};
|
||||
|
||||
struct MockIgcFeaturesAndWorkarounds : MockCIF<IGC::IgcFeaturesAndWorkaroundsTagOCL> {
|
||||
};
|
||||
|
||||
struct MockIgcOclTranslationCtx : MockCIF<IGC::IgcOclTranslationCtxTagOCL> {
|
||||
using MockCIF<IGC::IgcOclTranslationCtxTagOCL>::TranslateImpl;
|
||||
MockIgcOclTranslationCtx();
|
||||
~MockIgcOclTranslationCtx() override;
|
||||
|
||||
IGC::OclTranslationOutputBase *TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) override;
|
||||
|
||||
IGC::OclTranslationOutputBase *TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtpinInput) override;
|
||||
|
||||
bool GetSpecConstantsInfoImpl(
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsIds,
|
||||
CIF::Builtins::BufferSimple *outSpecConstantsSizes) override;
|
||||
|
||||
IGC::OclTranslationOutputBase *TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *specConstantsIds,
|
||||
CIF::Builtins::BufferSimple *specConstantsValues,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount,
|
||||
void *gtPinInput) override;
|
||||
};
|
||||
|
||||
struct MockOclTranslationOutput : MockCIF<IGC::OclTranslationOutputTagOCL> {
|
||||
MockOclTranslationOutput();
|
||||
~MockOclTranslationOutput() override;
|
||||
CIF::Builtins::BufferBase *GetBuildLogImpl(CIF::Version_t bufferVersion) override;
|
||||
CIF::Builtins::BufferBase *GetOutputImpl(CIF::Version_t bufferVersion) override;
|
||||
CIF::Builtins::BufferBase *GetDebugDataImpl(CIF::Version_t bufferVersion) override;
|
||||
|
||||
bool Successful() const override {
|
||||
return failed == false;
|
||||
}
|
||||
|
||||
void setError() {
|
||||
setError("");
|
||||
}
|
||||
void setError(const std::string &message);
|
||||
void setOutput(const void *data, size_t dataLen);
|
||||
void setDebugData(const void *data, size_t dataLen);
|
||||
|
||||
bool failed = false;
|
||||
MockCIFBuffer *output = nullptr;
|
||||
MockCIFBuffer *log = nullptr;
|
||||
MockCIFBuffer *debugData = nullptr;
|
||||
};
|
||||
|
||||
struct MockIgcOclDeviceCtx : MockCIF<IGC::IgcOclDeviceCtx<2>> {
|
||||
static CIF::ICIF *Create(CIF::InterfaceId_t intId, CIF::Version_t version);
|
||||
|
||||
MockIgcOclDeviceCtx();
|
||||
~MockIgcOclDeviceCtx() override;
|
||||
|
||||
IGC::PlatformBase *GetPlatformHandleImpl(CIF::Version_t ver) override {
|
||||
if (getIgcDebugVars().failCreatePlatformInterface) {
|
||||
return nullptr;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
IGC::GTSystemInfoBase *GetGTSystemInfoHandleImpl(CIF::Version_t ver) override {
|
||||
if (getIgcDebugVars().failCreateGtSystemInfoInterface) {
|
||||
return nullptr;
|
||||
}
|
||||
return gtSystemInfo;
|
||||
}
|
||||
|
||||
IGC::IgcFeaturesAndWorkaroundsBase *GetIgcFeaturesAndWorkaroundsHandleImpl(CIF::Version_t ver) override {
|
||||
if (getIgcDebugVars().failCreateIgcFeWaInterface) {
|
||||
return nullptr;
|
||||
}
|
||||
return igcFeWa;
|
||||
}
|
||||
|
||||
IGC::IgcOclTranslationCtxBase *CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) override;
|
||||
|
||||
bool GetSystemRoutine(IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine,
|
||||
bool bindless,
|
||||
CIF::Builtins::BufferSimple *outSystemRoutineBuffer,
|
||||
CIF::Builtins::BufferSimple *stateSaveAreaHeaderInit) override;
|
||||
|
||||
void SetDebugVars(MockCompilerDebugVars &debugVars) {
|
||||
this->debugVars = debugVars;
|
||||
}
|
||||
|
||||
MockCIFPlatform *platform = nullptr;
|
||||
MockGTSystemInfo *gtSystemInfo = nullptr;
|
||||
MockIgcFeaturesAndWorkarounds *igcFeWa = nullptr;
|
||||
MockCompilerDebugVars debugVars;
|
||||
|
||||
using TranslationOpT = std::pair<IGC::CodeType::CodeType_t, IGC::CodeType::CodeType_t>;
|
||||
std::vector<TranslationOpT> requestedTranslationCtxs;
|
||||
};
|
||||
|
||||
struct MockFclOclTranslationCtx : MockCIF<IGC::FclOclTranslationCtxTagOCL> {
|
||||
MockFclOclTranslationCtx();
|
||||
~MockFclOclTranslationCtx() override;
|
||||
|
||||
IGC::OclTranslationOutputBase *TranslateImpl(
|
||||
CIF::Version_t outVersion,
|
||||
CIF::Builtins::BufferSimple *src,
|
||||
CIF::Builtins::BufferSimple *options,
|
||||
CIF::Builtins::BufferSimple *internalOptions,
|
||||
CIF::Builtins::BufferSimple *tracingOptions,
|
||||
uint32_t tracingOptionsCount) override;
|
||||
};
|
||||
|
||||
struct MockFclOclDeviceCtx : MockCIF<IGC::FclOclDeviceCtxTagOCL> {
|
||||
MockFclOclDeviceCtx();
|
||||
~MockFclOclDeviceCtx() override;
|
||||
|
||||
static CIF::ICIF *Create(CIF::InterfaceId_t intId, CIF::Version_t version);
|
||||
void SetOclApiVersion(uint32_t version) override {
|
||||
oclApiVersion = version;
|
||||
}
|
||||
|
||||
IGC::FclOclTranslationCtxBase *CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) override;
|
||||
|
||||
IGC::FclOclTranslationCtxBase *CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType,
|
||||
CIF::Builtins::BufferSimple *err) override;
|
||||
|
||||
IGC::PlatformBase *GetPlatformHandleImpl(CIF::Version_t ver) override {
|
||||
if (getFclDebugVars().failCreatePlatformInterface) {
|
||||
return nullptr;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
CIF::Version_t GetUnderlyingVersion() const override {
|
||||
if (getFclDebugVars().overrideFclDeviceCtxVersion >= 0) {
|
||||
return getFclDebugVars().overrideFclDeviceCtxVersion;
|
||||
}
|
||||
return CIF::ICIF::GetUnderlyingVersion();
|
||||
}
|
||||
|
||||
uint32_t oclApiVersion = 120;
|
||||
MockCIFPlatform *platform = nullptr;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
28
shared/test/common/mocks/mock_experimental_command_buffer.h
Normal file
28
shared/test/common/mocks/mock_experimental_command_buffer.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/experimental_command_buffer.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MockExperimentalCommandBuffer : public ExperimentalCommandBuffer {
|
||||
using BaseClass = ExperimentalCommandBuffer;
|
||||
|
||||
public:
|
||||
using BaseClass::currentStream;
|
||||
using BaseClass::experimentalAllocation;
|
||||
using BaseClass::experimentalAllocationOffset;
|
||||
using BaseClass::timestamps;
|
||||
using BaseClass::timestampsOffset;
|
||||
|
||||
MockExperimentalCommandBuffer(CommandStreamReceiver *csr) : ExperimentalCommandBuffer(csr, 80.0) {
|
||||
defaultPrint = false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
40
shared/test/common/mocks/mock_gmm_client_context.cpp
Normal file
40
shared/test/common/mocks/mock_gmm_client_context.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mock_gmm_client_context.h"
|
||||
|
||||
namespace NEO {
|
||||
MockGmmClientContext::MockGmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo) : MockGmmClientContextBase(osInterface, hwInfo) {
|
||||
}
|
||||
|
||||
MEMORY_OBJECT_CONTROL_STATE MockGmmClientContextBase::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) {
|
||||
MEMORY_OBJECT_CONTROL_STATE retVal = {};
|
||||
memset(&retVal, 0, sizeof(MEMORY_OBJECT_CONTROL_STATE));
|
||||
switch (usage) {
|
||||
case GMM_RESOURCE_USAGE_OCL_INLINE_CONST_HDC:
|
||||
retVal.DwordValue = 32u;
|
||||
break;
|
||||
case GMM_RESOURCE_USAGE_OCL_BUFFER:
|
||||
retVal.DwordValue = 16u;
|
||||
break;
|
||||
case GMM_RESOURCE_USAGE_OCL_BUFFER_CONST:
|
||||
retVal.DwordValue = 8u;
|
||||
break;
|
||||
case GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED:
|
||||
retVal.DwordValue = 0u;
|
||||
break;
|
||||
case GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER:
|
||||
retVal.DwordValue = 2u;
|
||||
break;
|
||||
default:
|
||||
retVal.DwordValue = 4u;
|
||||
break;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
16
shared/test/common/mocks/mock_gmm_client_context.h
Normal file
16
shared/test/common/mocks/mock_gmm_client_context.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context_base.h"
|
||||
|
||||
namespace NEO {
|
||||
class MockGmmClientContext : public MockGmmClientContextBase {
|
||||
public:
|
||||
MockGmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo);
|
||||
};
|
||||
} // namespace NEO
|
||||
36
shared/test/common/mocks/mock_gmm_client_context_base.cpp
Normal file
36
shared/test/common/mocks/mock_gmm_client_context_base.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context_base.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
GMM_RESOURCE_INFO *MockGmmClientContextBase::createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) {
|
||||
return reinterpret_cast<GMM_RESOURCE_INFO *>(new char[1]);
|
||||
}
|
||||
|
||||
GMM_RESOURCE_INFO *MockGmmClientContextBase::copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) {
|
||||
return reinterpret_cast<GMM_RESOURCE_INFO *>(new char[1]);
|
||||
}
|
||||
|
||||
void MockGmmClientContextBase::destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) {
|
||||
delete[] reinterpret_cast<char *>(pResInfo);
|
||||
}
|
||||
|
||||
uint8_t MockGmmClientContextBase::getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) {
|
||||
capturedFormat = format;
|
||||
getSurfaceStateCompressionFormatCalled++;
|
||||
return compressionFormatToReturn;
|
||||
}
|
||||
|
||||
uint8_t MockGmmClientContextBase::getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) {
|
||||
capturedFormat = format;
|
||||
getMediaSurfaceStateCompressionFormatCalled++;
|
||||
return compressionFormatToReturn;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
29
shared/test/common/mocks/mock_gmm_client_context_base.h
Normal file
29
shared/test/common/mocks/mock_gmm_client_context_base.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "gmm_client_context.h"
|
||||
|
||||
namespace NEO {
|
||||
class MockGmmClientContextBase : public GmmClientContext {
|
||||
public:
|
||||
MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) override;
|
||||
GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) override;
|
||||
GMM_RESOURCE_INFO *copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) override;
|
||||
void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) override;
|
||||
uint8_t getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) override;
|
||||
uint8_t getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) override;
|
||||
|
||||
GMM_RESOURCE_FORMAT capturedFormat = GMM_FORMAT_INVALID;
|
||||
uint8_t compressionFormatToReturn = 1;
|
||||
uint32_t getSurfaceStateCompressionFormatCalled = 0u;
|
||||
uint32_t getMediaSurfaceStateCompressionFormatCalled = 0u;
|
||||
|
||||
protected:
|
||||
using GmmClientContext::GmmClientContext;
|
||||
};
|
||||
} // namespace NEO
|
||||
90
shared/test/common/mocks/mock_tbx_csr.h
Normal file
90
shared/test/common/mocks/mock_tbx_csr.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/aub/aub_center.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "opencl/source/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
public:
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::writeMemory;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::allocationsForDownload;
|
||||
MockTbxCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
|
||||
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, 0, deviceBitfield) {}
|
||||
|
||||
void initializeEngine() {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine();
|
||||
initializeEngineCalled = true;
|
||||
}
|
||||
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation);
|
||||
writeMemoryWithAubManagerCalled = true;
|
||||
}
|
||||
|
||||
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits);
|
||||
writeMemoryCalled = true;
|
||||
}
|
||||
void submitBatchBuffer(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead) override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::submitBatchBuffer(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, entryBits, overrideRingHead);
|
||||
overrideRingHeadPassed = overrideRingHead;
|
||||
submitBatchBufferCalled = true;
|
||||
}
|
||||
void pollForCompletion() override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::pollForCompletion();
|
||||
pollForCompletionCalled = true;
|
||||
}
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocation(gfxAllocation);
|
||||
makeCoherentCalled = true;
|
||||
}
|
||||
void dumpAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::dumpAllocation(gfxAllocation);
|
||||
dumpAllocationCalled = true;
|
||||
}
|
||||
bool initializeEngineCalled = false;
|
||||
bool writeMemoryWithAubManagerCalled = false;
|
||||
bool writeMemoryCalled = false;
|
||||
bool submitBatchBufferCalled = false;
|
||||
bool overrideRingHeadPassed = false;
|
||||
bool pollForCompletionCalled = false;
|
||||
bool expectMemoryEqualCalled = false;
|
||||
bool expectMemoryNotEqualCalled = false;
|
||||
bool makeCoherentCalled = false;
|
||||
bool dumpAllocationCalled = false;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
using CommandStreamReceiver::latestFlushedTaskCount;
|
||||
using CommandStreamReceiver::tagsMultiAllocation;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw;
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
*reinterpret_cast<uint32_t *>(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount;
|
||||
downloadedAllocations.insert(&gfxAllocation);
|
||||
}
|
||||
bool flushBatchedSubmissions() override {
|
||||
flushBatchedSubmissionsCalled = true;
|
||||
return true;
|
||||
}
|
||||
std::set<GraphicsAllocation *> downloadedAllocations;
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
};
|
||||
} // namespace NEO
|
||||
34
shared/test/common/mocks/mock_tbx_sockets.h
Normal file
34
shared/test/common/mocks/mock_tbx_sockets.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/tbx/tbx_sockets.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MockTbxSockets : public TbxSockets {
|
||||
public:
|
||||
MockTbxSockets(){};
|
||||
~MockTbxSockets() override = default;
|
||||
|
||||
bool init(const std::string &hostNameOrIp, uint16_t port) override { return true; };
|
||||
void close() override{};
|
||||
|
||||
bool writeGTT(uint32_t gttOffset, uint64_t entry) override { return true; };
|
||||
|
||||
bool readMemory(uint64_t offset, void *data, size_t size) override { return true; };
|
||||
bool writeMemory(uint64_t offset, const void *data, size_t size, uint32_t type) override {
|
||||
typeCapturedFromWriteMemory = type;
|
||||
return true;
|
||||
};
|
||||
|
||||
bool readMMIO(uint32_t offset, uint32_t *data) override { return true; };
|
||||
bool writeMMIO(uint32_t offset, uint32_t data) override { return true; };
|
||||
|
||||
uint32_t typeCapturedFromWriteMemory = 0;
|
||||
};
|
||||
} // namespace NEO
|
||||
17
shared/test/common/mocks/mock_tbx_stream.h
Normal file
17
shared/test/common/mocks/mock_tbx_stream.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opencl/source/command_stream/tbx_command_stream_receiver.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct MockTbxStream : public TbxCommandStreamReceiver::TbxStream {
|
||||
using TbxCommandStreamReceiver::TbxStream::socket;
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/mocks/mock_cif.h"
|
||||
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
||||
#include "opencl/test/unit_test/global_environment.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_cif.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_compilers.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "hw_cmds.h"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_client_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "shared/test/common/helpers/memory_leak_listener.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.inl"
|
||||
#include "shared/test/common/mocks/mock_gmm_client_context.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
#include "shared/test/common/test_macros/test_checks_shared.h"
|
||||
#include "shared/test/unit_test/tests_configuration.h"
|
||||
@@ -24,7 +25,6 @@
|
||||
#include "opencl/test/unit_test/global_environment.h"
|
||||
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_client_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_program.h"
|
||||
#include "opencl/test/unit_test/ult_config_listener.h"
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#include "shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_aub_manager.h"
|
||||
#include "shared/test/common/mocks/mock_aub_manager.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
|
||||
#include "aub_mem_dump.h"
|
||||
|
||||
Reference in New Issue
Block a user