Move builtins and compiler interface to RootDeviceEnvironment

Resolves: NEO-4355
Change-Id: Id1a3365673165d775a60a7e0a3f463e1b8f5a496
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-02-27 15:32:57 +01:00
committed by sys_ocldev
parent ab3ae5fea7
commit 7cf57e04f9
45 changed files with 187 additions and 156 deletions

View File

@@ -16,6 +16,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/kernel_helpers.h"
#include "shared/source/memory_manager/unified_memory_manager.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/source/utilities/api_intercept.h"
#include "shared/source/utilities/stackvec.h"

View File

@@ -714,7 +714,7 @@ class BuiltInOp<EBuiltInOps::FillImage3d> : public BuiltinDispatchInfoBuilder {
BuiltinDispatchInfoBuilder &BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::Type operation, Device &device) {
uint32_t operationId = static_cast<uint32_t>(operation);
auto kernelsLib = device.getExecutionEnvironment()->getBuiltIns();
auto kernelsLib = device.getBuiltIns();
auto &operationBuilder = kernelsLib->BuiltinOpsBuilders[operationId];
switch (operation) {
case EBuiltInOps::CopyBufferToBuffer:

View File

@@ -100,7 +100,7 @@ const char *getAdditionalBuiltinAsString(EBuiltInOps::Type builtin) {
}
BuiltinDispatchInfoBuilder &Vme::getBuiltinDispatchInfoBuilder(EBuiltInOps::Type operation, Device &device) {
auto &builtins = *device.getExecutionEnvironment()->getBuiltIns();
auto &builtins = *device.getBuiltIns();
uint32_t operationId = static_cast<uint32_t>(operation);
auto &operationBuilder = builtins.BuiltinOpsBuilders[operationId];
switch (operation) {

View File

@@ -13,7 +13,7 @@
namespace NEO {
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
return device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(type, device);
return device.getBuiltIns()->getSipKernel(type, device);
}
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
Context *context,

View File

@@ -164,12 +164,12 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
}
}
auto hwInfo = clDevices[0]->getHardwareInfo();
const bool debuggerActive = executionEnvironment.debugger && executionEnvironment.debugger->isDebuggerActive();
if (clDevices[0]->getPreemptionMode() == PreemptionMode::MidThread || debuggerActive) {
auto sipType = SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, clDevices[0]->isDebuggerActive());
initSipKernel(sipType, clDevices[0]->getDevice());
for (auto &clDevice : clDevices) {
auto hwInfo = clDevice->getHardwareInfo();
if (clDevice->getPreemptionMode() == PreemptionMode::MidThread || clDevice->isDebuggerActive()) {
auto sipType = SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, clDevice->isDebuggerActive());
initSipKernel(sipType, clDevice->getDevice());
}
}
this->fillGlobalDispatchTable();

View File

@@ -70,7 +70,7 @@ cl_int Program::build(
extractInternalOptions(options);
applyAdditionalOptions();
CompilerInterface *pCompilerInterface = this->executionEnvironment.getCompilerInterface();
CompilerInterface *pCompilerInterface = pDevice->getCompilerInterface();
if (!pCompilerInterface) {
retVal = CL_OUT_OF_HOST_MEMORY;
break;

View File

@@ -120,7 +120,7 @@ cl_int Program::compile(
std::vector<uint8_t> compileData = elfEncoder.encode();
CompilerInterface *pCompilerInterface = this->executionEnvironment.getCompilerInterface();
CompilerInterface *pCompilerInterface = pDevice->getCompilerInterface();
if (!pCompilerInterface) {
retVal = CL_OUT_OF_HOST_MEMORY;
break;

View File

@@ -105,7 +105,7 @@ cl_int Program::link(
auto clLinkInput = elfEncoder.encode();
CompilerInterface *pCompilerInterface = this->executionEnvironment.getCompilerInterface();
CompilerInterface *pCompilerInterface = pDevice->getCompilerInterface();
if (!pCompilerInterface) {
retVal = CL_OUT_OF_HOST_MEMORY;
break;

View File

@@ -224,7 +224,7 @@ cl_int Program::setProgramSpecializationConstant(cl_uint specId, size_t specSize
std::lock_guard<std::mutex> lock(mutex);
if (!areSpecializationConstantsInitialized) {
auto pCompilerInterface = this->executionEnvironment.getCompilerInterface();
auto pCompilerInterface = this->pDevice->getCompilerInterface();
if (nullptr == pCompilerInterface) {
return CL_OUT_OF_HOST_MEMORY;
}

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/helpers/ult_hw_config.h"

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/unit_test/helpers/ult_hw_config.h"
#include "opencl/source/context/context.h"

View File

@@ -936,7 +936,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, BuiltInTests, getSchedulerKernelForSecondTimeDoesNot
}
TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderReturnFalseIfUnsupportedBuildType) {
auto &bs = *pDevice->getExecutionEnvironment()->getBuiltIns();
auto &bs = *pDevice->getBuiltIns();
BuiltinDispatchInfoBuilder bdib{bs};
MultiDispatchInfo multiDispatchInfo;
BuiltinOpParams params;
@@ -951,14 +951,14 @@ TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderReturnFalseIfUnsupportedBuildType
}
TEST_F(BuiltInTests, GeivenDefaultBuiltinDispatchInfoBuilderWhendValidateDispatchIsCalledThenClSuccessIsReturned) {
auto &bs = *pDevice->getExecutionEnvironment()->getBuiltIns();
auto &bs = *pDevice->getBuiltIns();
BuiltinDispatchInfoBuilder bdib{bs};
auto ret = bdib.validateDispatch(nullptr, 1, Vec3<size_t>{0, 0, 0}, Vec3<size_t>{0, 0, 0}, Vec3<size_t>{0, 0, 0});
EXPECT_EQ(CL_SUCCESS, ret);
}
TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderReturnTrueIfExplicitKernelArgNotTakenCareOfInBuiltinDispatchBInfoBuilder) {
auto &bs = *pDevice->getExecutionEnvironment()->getBuiltIns();
auto &bs = *pDevice->getBuiltIns();
BuiltinDispatchInfoBuilder bdib{bs};
MultiDispatchInfo multiDispatchInfo;
BuiltinOpParams params;
@@ -2002,7 +2002,7 @@ TEST_F(BuiltInTests, createBuiltInProgramForInvalidBuiltinKernelName) {
TEST_F(BuiltInTests, getSipKernelReturnsProgramCreatedOutOfIsaAcquiredFromCompilerInterface) {
MockBuiltins mockBuiltins;
auto mockCompilerInterface = new MockCompilerInterface();
pDevice->getExecutionEnvironment()->compilerInterface.reset(mockCompilerInterface);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(mockCompilerInterface);
mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary();
cl_int errCode = CL_BUILD_PROGRAM_FAILURE;
auto p = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(),
@@ -2026,13 +2026,13 @@ TEST_F(BuiltInTests, getSipKernelReturnsProgramCreatedOutOfIsaAcquiredFromCompil
}
TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationForKernel) {
const SipKernel &sipKern = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
const SipKernel &sipKern = pDevice->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
auto sipAllocation = sipKern.getSipAllocation();
EXPECT_NE(nullptr, sipAllocation);
}
TEST_F(BuiltInTests, givenSameDeviceIsUsedWhenUsingStaticGetterThenExpectRetrieveSameAllocation) {
const SipKernel &sipKern = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
const SipKernel &sipKern = pDevice->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
auto sipAllocation = sipKern.getSipAllocation();
EXPECT_NE(nullptr, sipAllocation);
auto staticSipAllocation = SipKernel::getSipKernelAllocation(*pDevice);

View File

@@ -134,7 +134,7 @@ TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKerne
igcDebugVars.fileName = builtInGenFile;
gEnvironment->igcPushDebugVars(igcDebugVars);
auto &builtins = *mockDevice->getExecutionEnvironment()->getBuiltIns();
auto &builtins = *mockDevice->getBuiltIns();
auto &sipKernel = builtins.getSipKernel(SipKernelType::DbgCsr, *mockDevice);
EXPECT_NE(nullptr, &sipKernel);

View File

@@ -750,7 +750,7 @@ struct BuiltinParamsCommandQueueHwTests : public CommandQueueHwTest {
void SetUpImpl(EBuiltInOps::Type operation) {
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto swapBuilder = builtIns->setBuiltinDispatchInfoBuilder(
operation,
@@ -971,7 +971,7 @@ HWTEST_F(CommandQueueHwTest, GivenBuiltinKernelWhenBuiltinDispatchInfoBuilderIsP
CommandQueueHw<FamilyType> *cmdQHw = static_cast<CommandQueueHw<FamilyType> *>(this->pCmdQ);
MockKernelWithInternals mockKernelToUse(*pClDevice);
MockBuilder builder(*pDevice->getExecutionEnvironment()->getBuiltIns());
MockBuilder builder(*pDevice->getBuiltIns());
builder.paramsToUse.gws.x = 11;
builder.paramsToUse.elws.x = 13;
builder.paramsToUse.offset.x = 17;

View File

@@ -193,7 +193,7 @@ typedef EnqueueCopyBufferToImageMipMapTest MipMapCopyBufferToImageTest;
HWTEST_P(MipMapCopyBufferToImageTest, GivenImageWithMipLevelNonZeroWhenCopyBufferToImageIsCalledThenProperMipLevelIsSet) {
auto image_type = (cl_mem_object_type)GetParam();
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyBufferToImage3d,
pCmdQ->getDevice());

View File

@@ -202,7 +202,7 @@ HWTEST_P(MipMapCopyImageTest, GivenImagesWithNonZeroMipLevelsWhenCopyImageIsCall
cl_mem_object_type srcImageType, dstImageType;
std::tie(srcImageType, dstImageType) = GetParam();
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyImageToImage3d,
pCmdQ->getDevice());

View File

@@ -194,7 +194,7 @@ typedef EnqueueCopyImageToBufferMipMapTest MipMapCopyImageToBufferTest;
HWTEST_P(MipMapCopyImageToBufferTest, GivenImageWithMipLevelNonZeroWhenCopyImageToBufferIsCalledThenProperMipLevelIsSet) {
auto image_type = (cl_mem_object_type)GetParam();
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyImage3dToBuffer,
pCmdQ->getDevice());

View File

@@ -405,7 +405,7 @@ TEST_F(EnqueueKernelTest, GivenKernelWithBuiltinDispatchInfoBuilderWhenBeingDisp
mutable bool wasValidateDispatchCalled = false;
};
MockBuiltinDispatchBuilder mockNuiltinDispatchBuilder(*pCmdQ->getDevice().getExecutionEnvironment()->getBuiltIns());
MockBuiltinDispatchBuilder mockNuiltinDispatchBuilder(*pCmdQ->getDevice().getBuiltIns());
MockKernelWithInternals mockKernel(*pClDevice);
mockKernel.kernelInfo.builtinDispatchBuilder = &mockNuiltinDispatchBuilder;

View File

@@ -243,7 +243,7 @@ HWTEST_F(EnqueueReadImageTest, GivenImage1DarrayWhenReadImageIsCalledThenHostPtr
HWTEST_F(EnqueueReadImageTest, GivenImage1DarrayWhenReadImageIsCalledThenRowPitchIsSetToSlicePitch) {
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
EBuiltInOps::Type copyBuiltIn = EBuiltInOps::CopyImage3dToBuffer;
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
copyBuiltIn,
@@ -489,7 +489,7 @@ typedef EnqueueReadImageMipMapTest MipMapReadImageTest;
HWTEST_P(MipMapReadImageTest, GivenImageWithMipLevelNonZeroWhenReadImageIsCalledThenProperMipLevelIsSet) {
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto image_type = (cl_mem_object_type)GetParam();
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyImage3dToBuffer,

View File

@@ -69,7 +69,7 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
}
pDevice->mockMemoryManager.reset(new MockMemoryManager());
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
// retrieve original builder
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyBufferToBuffer,
@@ -143,7 +143,7 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
}
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
void *srcHostPtr = alignedMalloc(512, 64);
size_t hostPtrOffset = 2;
@@ -225,7 +225,7 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
}
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto dstHostPtr = alignedMalloc(512, 64);
size_t hostPtrOffset = 2;

View File

@@ -75,7 +75,7 @@ HWTEST_P(EnqueueSvmMemFillTest, givenEnqueueSVMMemFillWhenUsingFillBufferBuilder
};
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
// retrieve original builder
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(

View File

@@ -222,7 +222,7 @@ HWTEST_F(EnqueueWriteImageTest, GivenImage1DarrayWhenReadWriteImageIsCalledThenH
HWTEST_F(EnqueueWriteImageTest, GivenImage1DarrayWhenWriteImageIsCalledThenRowPitchIsSetToSlicePitch) {
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
EBuiltInOps::Type copyBuiltIn = EBuiltInOps::CopyBufferToImage3d;
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
@@ -418,7 +418,7 @@ typedef EnqueueWriteImageMipMapTest MipMapWriteImageTest;
HWTEST_P(MipMapWriteImageTest, GivenImageWithMipLevelNonZeroWhenReadImageIsCalledThenProperMipLevelIsSet) {
auto image_type = (cl_mem_object_type)GetParam();
auto builtIns = new MockBuiltins();
pCmdQ->getDevice().getExecutionEnvironment()->builtins.reset(builtIns);
pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()]->builtins.reset(builtIns);
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
EBuiltInOps::CopyBufferToImage3d,

View File

@@ -183,7 +183,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndMidThread
*pDevice);
auto cmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead();
auto sipAllocation = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, *pDevice).getSipAllocation();
auto sipAllocation = pDevice->getBuiltIns()->getSipKernel(SipKernelType::Csr, *pDevice).getSipAllocation();
bool found = false;
for (auto allocation : cmdBuffer->surfaces) {
if (allocation == sipAllocation) {
@@ -213,7 +213,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInDefaultModeAndMidThreadP
dispatchFlags,
*pDevice);
auto sipAllocation = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, *pDevice).getSipAllocation();
auto sipAllocation = pDevice->getBuiltIns()->getSipKernel(SipKernelType::Csr, *pDevice).getSipAllocation();
bool found = false;
for (auto allocation : mockCsr->copyOfAllocations) {
if (allocation == sipAllocation) {

View File

@@ -228,9 +228,9 @@ TEST_F(DeviceGetCapsTest, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedT
auto executionEnvironment = new ExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->builtins.reset(builtIns);
executionEnvironment->rootDeviceEnvironments[0u]->builtins.reset(builtIns);
auto device = std::unique_ptr<Device>(MockDevice::createWithExecutionEnvironment<MockDevice>(platformDevices[0], executionEnvironment, 0u));
ASSERT_EQ(builtIns, device->getExecutionEnvironment()->getBuiltIns());
ASSERT_EQ(builtIns, device->getBuiltIns());
EXPECT_FALSE(MockSipData::called);
}
}

View File

@@ -12,6 +12,7 @@
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/utilities/destructor_counted.h"
@@ -150,21 +151,20 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI
executionEnvironment->initializeMemoryManager();
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::mutex) +
sizeof(std::unique_ptr<HardwareInfo>) +
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr<HardwareInfo>) +
sizeof(std::vector<RootDeviceEnvironment>) +
(is64bit ? 48 : 28),
(is64bit ? 32 : 20),
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
uint32_t destructorId = 0u;
struct GmmHelperMock : public DestructorCounted<GmmHelper, 6> {
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, nullptr, hwInfo) {}
};
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 7> {
MemoryMangerMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
};
struct GmmHelperMock : public DestructorCounted<GmmHelper, 6> {
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, nullptr, hwInfo) {}
};
struct OsInterfaceMock : public DestructorCounted<OSInterface, 5> {
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
@@ -174,12 +174,12 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
struct AubCenterMock : public DestructorCounted<AubCenter, 3> {
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {}
};
struct BuiltinsMock : public DestructorCounted<BuiltIns, 2> {
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct CompilerInterfaceMock : public DestructorCounted<CompilerInterface, 1> {
struct CompilerInterfaceMock : public DestructorCounted<CompilerInterface, 2> {
CompilerInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct BuiltinsMock : public DestructorCounted<BuiltIns, 1> {
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct SourceLevelDebuggerMock : public DestructorCounted<SourceLevelDebugger, 0> {
SourceLevelDebuggerMock(uint32_t &destructorId) : DestructorCounted(destructorId, nullptr) {}
};
@@ -192,8 +192,8 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<MemoryOperationsHandlerMock>(destructorId);
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);
executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::make_unique<AubCenterMock>(destructorId);
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
executionEnvironment->rootDeviceEnvironments[0]->builtins = std::make_unique<BuiltinsMock>(destructorId);
executionEnvironment->rootDeviceEnvironments[0]->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
executionEnvironment->debugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
executionEnvironment.reset(nullptr);

View File

@@ -21,7 +21,7 @@ BuiltInFixture::BuiltInFixture() : pBuiltIns(nullptr) {
void BuiltInFixture::SetUp(Device *pDevice) {
// create an instance of the builtins
pBuiltIns = pDevice->getExecutionEnvironment()->getBuiltIns();
pBuiltIns = pDevice->getBuiltIns();
pBuiltIns->setCacheingEnableState(false);
// set mock compiler to return expected kernel...

View File

@@ -35,7 +35,7 @@ GEN9TEST_F(gen9SipTests, DISABLED_givenDebugCsrSipKernelWithLocalMemoryWhenAsked
igcDebugVars.fileName = builtInGenFile;
gEnvironment->igcPushDebugVars(igcDebugVars);
auto &builtins = *mockDevice->getExecutionEnvironment()->getBuiltIns();
auto &builtins = *mockDevice->getBuiltIns();
auto &sipKernel = builtins.getSipKernel(SipKernelType::DbgCsrLocal, *mockDevice);
EXPECT_NE(nullptr, &sipKernel);

View File

@@ -9,6 +9,7 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/sku_info/operations/sku_info_transfer.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"

View File

@@ -2576,7 +2576,7 @@ TEST(KernelTest, setKernelArgUsesBuiltinDispatchInfoBuilderIfAvailable) {
kernel.kernelInfo.resizeKernelArgInfoAndRegisterParameter(1);
kernel.mockKernel->initialize();
MockBuiltinDispatchBuilder mockBuilder(*device->getExecutionEnvironment()->getBuiltIns());
MockBuiltinDispatchBuilder mockBuilder(*device->getBuiltIns());
kernel.kernelInfo.builtinDispatchBuilder = &mockBuilder;
mockBuilder.valueToReturn = false;

View File

@@ -157,6 +157,7 @@ class MockClDevice : public ClDevice {
}
SubDevice *createSubDevice(uint32_t subDeviceIndex) { return device.createSubDevice(subDeviceIndex); }
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const { return device.createCommandStreamReceiver(); }
BuiltIns *getBuiltIns() const { return getDevice().getBuiltIns(); }
MockDevice &device;
DeviceInfo &deviceInfo;

View File

@@ -8,6 +8,7 @@
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "shared/source/device/device.h"
#include "shared/source/os_interface/device_factory.h"
namespace NEO {

View File

@@ -11,6 +11,7 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/array_count.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/os_library.h"
#include "shared/source/os_interface/windows/os_context_win.h"
#include "shared/source/os_interface/windows/wddm_residency_controller.h"

View File

@@ -7,6 +7,7 @@
#include "shared/source/device/device.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/helpers/ult_hw_config.h"
@@ -113,7 +114,9 @@ TEST_F(PlatformTest, givenMidThreadPreemptionWhenInitializingPlatformThenCallGet
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
auto builtIns = new MockBuiltins();
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
EXPECT_FALSE(MockSipData::called);
@@ -127,7 +130,9 @@ TEST_F(PlatformTest, givenDisabledPreemptionAndNoSourceLevelDebuggerWhenInitiali
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto builtIns = new MockBuiltins();
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
EXPECT_FALSE(MockSipData::called);
@@ -141,7 +146,9 @@ TEST_F(PlatformTest, givenDisabledPreemptionInactiveSourceLevelDebuggerWhenIniti
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto builtIns = new MockBuiltins();
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
auto sourceLevelDebugger = new MockSourceLevelDebugger();
sourceLevelDebugger->setActive(false);
pPlatform->peekExecutionEnvironment()->debugger.reset(sourceLevelDebugger);
@@ -158,7 +165,9 @@ TEST_F(PlatformTest, givenDisabledPreemptionActiveSourceLevelDebuggerWhenInitial
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto builtIns = new MockBuiltins();
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
pPlatform->peekExecutionEnvironment()->debugger.reset(new MockActiveSourceLevelDebugger());
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);

View File

@@ -85,16 +85,14 @@ std::vector<const char *> KernelNames{
"CopyBuffer",
};
class MockCompIfaceExecutionEnvironment : public ExecutionEnvironment {
class NoCompilerInterfaceRootDeviceEnvironment : public RootDeviceEnvironment {
public:
MockCompIfaceExecutionEnvironment(CompilerInterface *compilerInterface) : compilerInterface(compilerInterface) {}
CompilerInterface *getCompilerInterface() override {
return compilerInterface;
NoCompilerInterfaceRootDeviceEnvironment(ExecutionEnvironment &executionEnvironment) : RootDeviceEnvironment(executionEnvironment) {
}
protected:
CompilerInterface *compilerInterface;
CompilerInterface *getCompilerInterface() override {
return nullptr;
}
};
class FailingGenBinaryProgram : public MockProgram {
@@ -680,6 +678,7 @@ HWTEST_P(ProgramFromBinaryTest, givenIsaAllocationUsedByMultipleCsrsWhenItIsDele
TEST_P(ProgramFromSourceTest, CreateWithSource_Build) {
KernelBinaryHelper kbHelper(BinaryFileName, true);
auto device = pPlatform->getClDevice(0);
cl_device_id deviceList = {0};
char data[4] = {0};
@@ -718,12 +717,16 @@ TEST_P(ProgramFromSourceTest, CreateWithSource_Build) {
pMockProgram->SetBuildStatus(CL_BUILD_NONE);
// fail build - CompilerInterface cannot be obtained
auto noCompilerInterfaceExecutionEnvironment = std::make_unique<MockCompIfaceExecutionEnvironment>(nullptr);
auto p2 = std::make_unique<MockProgram>(*noCompilerInterfaceExecutionEnvironment);
auto executionEnvironment = device->getExecutionEnvironment();
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
auto p2 = std::make_unique<MockProgram>(*executionEnvironment);
p2->setDevice(&device->getDevice());
retVal = p2->build(0, nullptr, nullptr, nullptr, nullptr, false);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
p2.reset(nullptr);
noCompilerInterfaceExecutionEnvironment.reset();
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
// fail build - any build error (here caused by specifying unrecognized option)
retVal = pProgram->build(0, nullptr, "-invalid-option", nullptr, nullptr, false);
@@ -731,7 +734,6 @@ TEST_P(ProgramFromSourceTest, CreateWithSource_Build) {
// fail build - linked code is corrupted and cannot be postprocessed
auto p3 = std::make_unique<FailingGenBinaryProgram>(*pPlatform->getDevice(0)->getExecutionEnvironment());
ClDevice *device = pPlatform->getClDevice(0);
p3->setDevice(&device->getDevice());
std::string testFile;
size_t sourceSize;
@@ -985,12 +987,16 @@ TEST_P(ProgramFromSourceTest, CreateWithSource_Compile) {
delete p3;
// fail compilation - CompilerInterface cannot be obtained
auto noCompilerInterfaceExecutionEnvironment = std::make_unique<MockCompIfaceExecutionEnvironment>(nullptr);
auto p2 = std::make_unique<MockProgram>(*noCompilerInterfaceExecutionEnvironment);
auto device = pContext->getDevice(0);
auto executionEnvironment = device->getExecutionEnvironment();
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
auto p2 = std::make_unique<MockProgram>(*executionEnvironment);
p2->setDevice(&device->getDevice());
retVal = p2->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
p2.reset(nullptr);
noCompilerInterfaceExecutionEnvironment.reset();
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
// fail compilation - any compilation error (here caused by specifying unrecognized option)
retVal = pProgram->compile(0, nullptr, "-invalid-option", 0, nullptr, nullptr, nullptr, nullptr);
@@ -1029,11 +1035,10 @@ struct MockCompilerInterfaceCaptureBuildOptions : CompilerInterface {
};
TEST_P(ProgramFromSourceTest, CompileProgramWithInternalFlags) {
auto cip = std::make_unique<MockCompilerInterfaceCaptureBuildOptions>();
MockCompIfaceExecutionEnvironment executionEnvironment(cip.get());
auto program = std::make_unique<SucceedingGenBinaryProgram>(executionEnvironment);
cl_device_id deviceId = pContext->getDevice(0);
ClDevice *pDevice = castToObject<ClDevice>(deviceId);
auto cip = new MockCompilerInterfaceCaptureBuildOptions();
auto pDevice = pContext->getDevice(0);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
auto program = std::make_unique<SucceedingGenBinaryProgram>(*pDevice->getExecutionEnvironment());
program->setDevice(&pDevice->getDevice());
program->sourceCode = "__kernel mock() {}";
@@ -1214,8 +1219,6 @@ TEST_P(ProgramFromSourceTest, CreateWithSource_Link) {
}
TEST_P(ProgramFromSourceTest, CreateWithSource_CreateLibrary) {
auto noCompilerInterfaceExecutionEnvironment = std::make_unique<MockCompIfaceExecutionEnvironment>(nullptr);
auto p = std::make_unique<MockProgram>(*noCompilerInterfaceExecutionEnvironment);
cl_program program = pProgram;
// Order of following microtests is important - do not change.
@@ -1233,9 +1236,16 @@ TEST_P(ProgramFromSourceTest, CreateWithSource_CreateLibrary) {
retVal = pProgram->link(0, nullptr, CompilerOptions::concatenate(CompilerOptions::createLibrary, "-invalid-option").c_str(), 1, &program, nullptr, nullptr);
EXPECT_EQ(CL_LINK_PROGRAM_FAILURE, retVal);
auto device = pContext->getDevice(0);
auto executionEnvironment = device->getExecutionEnvironment();
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
auto failingProgram = std::make_unique<MockProgram>(*executionEnvironment);
failingProgram->setDevice(&device->getDevice());
// fail library creation - CompilerInterface cannot be obtained
retVal = p->link(0, nullptr, CompilerOptions::createLibrary, 1, &program, nullptr, nullptr);
retVal = failingProgram->link(0, nullptr, CompilerOptions::createLibrary, 1, &program, nullptr, nullptr);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
}
class PatchTokenFromBinaryTest : public ProgramSimpleFixture {
@@ -1901,11 +1911,12 @@ TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimit
}
TEST_F(ProgramTests, RebuildBinaryButNoCompilerInterface) {
auto noCompilerInterfaceExecutionEnvironment = std::make_unique<MockCompIfaceExecutionEnvironment>(nullptr);
auto program = std::make_unique<MockProgram>(*noCompilerInterfaceExecutionEnvironment);
auto pDevice = pContext->getDevice(0);
auto executionEnvironment = pDevice->getExecutionEnvironment();
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
auto program = std::make_unique<MockProgram>(*executionEnvironment);
EXPECT_NE(nullptr, program);
cl_device_id deviceId = pContext->getDevice(0);
ClDevice *pDevice = castToObject<ClDevice>(deviceId);
program->setDevice(&pDevice->getDevice());
// Load a binary program file
@@ -1922,14 +1933,14 @@ TEST_F(ProgramTests, RebuildBinaryButNoCompilerInterface) {
// Ask to rebuild program from its IR binary - it should fail (no Compiler Interface)
retVal = program->rebuildProgramFromIr();
EXPECT_NE(CL_SUCCESS, retVal);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
}
TEST_F(ProgramTests, BuildProgramWithReraFlag) {
auto cip = std::make_unique<MockCompilerInterfaceCaptureBuildOptions>();
MockCompIfaceExecutionEnvironment executionEnvironment(cip.get());
auto program = std::make_unique<SucceedingGenBinaryProgram>(executionEnvironment);
cl_device_id deviceId = pContext->getDevice(0);
ClDevice *pDevice = castToObject<ClDevice>(deviceId);
auto cip = new MockCompilerInterfaceCaptureBuildOptions();
auto pDevice = pContext->getDevice(0);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
auto program = std::make_unique<SucceedingGenBinaryProgram>(*pDevice->getExecutionEnvironment());
program->setDevice(&pDevice->getDevice());
program->sourceCode = "__kernel mock() {}";
program->createdFrom = Program::CreatedFrom::SOURCE;
@@ -2472,7 +2483,7 @@ TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildProgramIsCalledThenSpirvPat
compilerInterface->SetIgcMain(compilerMain);
compilerMain->setDefaultCreatorFunc<NEO::MockIgcOclDeviceCtx>(NEO::MockIgcOclDeviceCtx::Create);
compilerMain->setDefaultCreatorFunc<NEO::MockFclOclDeviceCtx>(NEO::MockFclOclDeviceCtx::Create);
pDevice->getExecutionEnvironment()->compilerInterface.reset(compilerInterface);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(compilerInterface);
std::string receivedInput;
MockCompilerDebugVars debugVars = {};
@@ -2500,7 +2511,7 @@ TEST_F(ProgramTests, whenRebuildingProgramThenStoreDeviceBinaryProperly) {
auto device = castToObject<ClDevice>(pContext->getDevice(0));
auto compilerInterface = new MockCompilerInterface();
pDevice->getExecutionEnvironment()->compilerInterface.reset(compilerInterface);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(compilerInterface);
auto compilerMain = new MockCIFMain();
compilerInterface->SetIgcMain(compilerMain);
compilerMain->setDefaultCreatorFunc<NEO::MockIgcOclDeviceCtx>(NEO::MockIgcOclDeviceCtx::Create);
@@ -2608,6 +2619,7 @@ class AdditionalOptionsMockProgram : public MockProgram {
TEST_F(ProgramTests, givenProgramWhenBuiltThenAdditionalOptionsAreApplied) {
AdditionalOptionsMockProgram program;
program.setDevice(pDevice);
cl_device_id device = pClDevice;
program.build(1, &device, nullptr, nullptr, nullptr, false);
@@ -2673,8 +2685,8 @@ struct SpecializationConstantCompilerInterfaceMock : public CompilerInterface {
}
};
struct SpecializationConstantExecutionEnvironmentMock : public ExecutionEnvironment {
SpecializationConstantExecutionEnvironmentMock() {
struct SpecializationConstantRootDeviceEnvironemnt : public RootDeviceEnvironment {
SpecializationConstantRootDeviceEnvironemnt(ExecutionEnvironment &executionEnvironment) : RootDeviceEnvironment(executionEnvironment) {
compilerInterface.reset(new SpecializationConstantCompilerInterfaceMock());
}
CompilerInterface *getCompilerInterface() override {
@@ -2684,18 +2696,20 @@ struct SpecializationConstantExecutionEnvironmentMock : public ExecutionEnvironm
struct setProgramSpecializationConstantTests : public ::testing::Test {
void SetUp() override {
mockProgram.reset(new SpecializationConstantProgramMock(executionEnvironment));
mockCompiler = new SpecializationConstantCompilerInterfaceMock();
auto rootDeviceEnvironment = device.getExecutionEnvironment()->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->compilerInterface.reset(mockCompiler);
mockProgram.reset(new SpecializationConstantProgramMock(*device.getExecutionEnvironment()));
mockProgram->isSpirV = true;
mockProgram->SetDevice(&device.getDevice());
mockProgram->setDevice(&device);
EXPECT_FALSE(mockProgram->areSpecializationConstantsInitialized);
EXPECT_EQ(0, mockCompiler->counter);
}
SpecializationConstantExecutionEnvironmentMock executionEnvironment;
SpecializationConstantCompilerInterfaceMock *mockCompiler = reinterpret_cast<SpecializationConstantCompilerInterfaceMock *>(executionEnvironment.getCompilerInterface());
SpecializationConstantCompilerInterfaceMock *mockCompiler = nullptr;
std::unique_ptr<SpecializationConstantProgramMock> mockProgram;
MockClDevice device{new MockDevice};
MockDevice device;
int specValue = 1;
};
@@ -2715,7 +2729,7 @@ TEST_F(setProgramSpecializationConstantTests, whenSetProgramSpecializationConsta
}
TEST_F(setProgramSpecializationConstantTests, givenInvalidGetSpecConstantsInfoReturnValueWhenSetProgramSpecializationConstantThenErrorIsReturned) {
reinterpret_cast<SpecializationConstantCompilerInterfaceMock *>(executionEnvironment.getCompilerInterface())->returnError();
mockCompiler->returnError();
auto retVal = mockProgram->setProgramSpecializationConstant(1, sizeof(int), &specValue);
@@ -2725,14 +2739,12 @@ TEST_F(setProgramSpecializationConstantTests, givenInvalidGetSpecConstantsInfoRe
}
TEST(setProgramSpecializationConstantTest, givenUninitializedCompilerinterfaceWhenSetProgramSpecializationConstantThenErrorIsReturned) {
struct MockExecutionEnvironment : public ExecutionEnvironment {
CompilerInterface *getCompilerInterface() override {
return compilerInterface.get();
}
};
auto executionEnvironment = new MockExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0] = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
MockDevice mockDevice(executionEnvironment, 0);
SpecializationConstantProgramMock mockProgram(*executionEnvironment);
mockProgram.setDevice(&mockDevice);
MockExecutionEnvironment executionEnvironment;
SpecializationConstantProgramMock mockProgram(executionEnvironment);
mockProgram.isSpirV = true;
int specValue = 1;

View File

@@ -59,6 +59,8 @@ HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebugger
std::unique_ptr<MockGraphicsAllocation> allocation(new MockGraphicsAllocation(buffer, MemoryConstants::pageSize));
std::unique_ptr<IndirectHeap> heap(new IndirectHeap(allocation.get()));
auto &baseDevice = device->getDevice();
mockCsr->flushTask(commandStream,
0,
*heap.get(),
@@ -66,10 +68,10 @@ HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebugger
*heap.get(),
0,
dispatchFlags,
device->getDevice());
baseDevice);
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().platform.eRenderCoreFamily, true);
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device->getDevice()).getSipAllocation();
auto sipType = SipKernel::getSipKernelType(baseDevice.getHardwareInfo().platform.eRenderCoreFamily, true);
auto sipAllocation = baseDevice.getBuiltIns()->getSipKernel(sipType, baseDevice).getSipAllocation();
bool found = false;
for (auto allocation : mockCsr->copyOfAllocations) {
if (allocation == sipAllocation) {
@@ -109,7 +111,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
device->getDevice());
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().platform.eRenderCoreFamily, true);
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device->getDevice()).getSipAllocation();
auto sipAllocation = device->getBuiltIns()->getSipKernel(sipType, device->getDevice()).getSipAllocation();
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(preambleStream);
@@ -171,7 +173,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
device->getDevice());
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().platform.eRenderCoreFamily, true);
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device->getDevice()).getSipAllocation();
auto sipAllocation = device->getBuiltIns()->getSipKernel(sipType, device->getDevice()).getSipAllocation();
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(preambleStream);

View File

@@ -137,10 +137,10 @@ inline GmmHelper *Device::getGmmHelper() const {
}
inline CompilerInterface *Device::getCompilerInterface() const {
return executionEnvironment->getCompilerInterface();
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getCompilerInterface();
}
inline BuiltIns *Device::getBuiltIns() const {
return executionEnvironment->getBuiltIns();
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getBuiltIns();
}
inline std::atomic<uint32_t> &Device::getSelectorCopyEngine() {

View File

@@ -24,8 +24,9 @@ ExecutionEnvironment::ExecutionEnvironment() {
ExecutionEnvironment::~ExecutionEnvironment() {
debugger.reset();
compilerInterface.reset();
builtins.reset();
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
rootDeviceEnvironment->builtins.reset();
}
if (memoryManager) {
memoryManager->commonCleanup();
}
@@ -77,27 +78,6 @@ void ExecutionEnvironment::calculateMaxOsContextCount() {
}
}
CompilerInterface *ExecutionEnvironment::getCompilerInterface() {
if (this->compilerInterface.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->compilerInterface.get() == nullptr) {
auto cache = std::make_unique<CompilerCache>(getDefaultCompilerCacheConfig());
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), true));
}
}
return this->compilerInterface.get();
}
BuiltIns *ExecutionEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->builtins.get() == nullptr) {
this->builtins = std::make_unique<BuiltIns>();
}
}
return this->builtins.get();
}
bool ExecutionEnvironment::isFullRangeSvm() const {
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47);
}

View File

@@ -6,25 +6,17 @@
*/
#pragma once
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/utilities/reference_tracked_object.h"
#include <mutex>
#include <vector>
namespace NEO {
class BuiltIns;
class CompilerInterface;
class GmmClientContext;
class GmmHelper;
class MemoryManager;
class Debugger;
struct RootDeviceEnvironment;
struct HardwareInfo;
class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> {
private:
std::mutex mtx;
protected:
std::unique_ptr<HardwareInfo> hwInfo;
@@ -42,13 +34,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
bool isFullRangeSvm() const;
void prepareRootDeviceEnvironments(uint32_t numRootDevices);
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
BuiltIns *getBuiltIns();
std::unique_ptr<MemoryManager> memoryManager;
std::vector<std::unique_ptr<RootDeviceEnvironment>> rootDeviceEnvironments;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<CompilerInterface> compilerInterface;
std::unique_ptr<Debugger> debugger;
};
} // namespace NEO

View File

@@ -7,6 +7,9 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/default_cache_config.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/page_table_mngr.h"
@@ -42,4 +45,24 @@ void RootDeviceEnvironment::initGmm() {
}
}
CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {
if (this->compilerInterface.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->compilerInterface.get() == nullptr) {
auto cache = std::make_unique<CompilerCache>(getDefaultCompilerCacheConfig());
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), true));
}
}
return this->compilerInterface.get();
}
BuiltIns *RootDeviceEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
if (this->builtins.get() == nullptr) {
this->builtins = std::make_unique<BuiltIns>();
}
}
return this->builtins.get();
}
} // namespace NEO

View File

@@ -10,10 +10,13 @@
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
namespace NEO {
class BuiltIns;
class CompilerInterface;
class AubCenter;
class GmmClientContext;
class GmmHelper;
@@ -35,12 +38,20 @@ struct RootDeviceEnvironment {
void initGmm();
GmmHelper *getGmmHelper() const;
GmmClientContext *getGmmClientContext() const;
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
BuiltIns *getBuiltIns();
std::unique_ptr<GmmHelper> gmmHelper;
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<GmmPageTableMngr> pageTableManager;
std::unique_ptr<MemoryOperationsHandler> memoryOperationsInterface;
std::unique_ptr<AubCenter> aubCenter;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<CompilerInterface> compilerInterface;
ExecutionEnvironment &executionEnvironment;
private:
std::mutex mtx;
};
} // namespace NEO

View File

@@ -41,7 +41,7 @@ class CompilerInterfaceTest : public DeviceFixture,
this->pCompilerInterface = new MockCompilerInterface();
bool initRet = pCompilerInterface->initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), true);
ASSERT_TRUE(initRet);
pDevice->getExecutionEnvironment()->compilerInterface.reset(pCompilerInterface);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(pCompilerInterface);
std::string testFile;

View File

@@ -61,7 +61,7 @@ GEN11TEST_F(Gen11PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSip
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
ASSERT_NE(nullptr, stateSipCmd);
EXPECT_EQ(device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, device->getDevice()).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, device->getDevice()).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
}
GEN11TEST_F(Gen11PreemptionTests, getRequiredCmdQSize) {

View File

@@ -83,7 +83,7 @@ GEN9TEST_F(Gen9PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSipIs
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
ASSERT_NE(nullptr, stateSipCmd);
EXPECT_EQ(device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, device->getDevice()).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, device->getDevice()).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
}
GEN9TEST_F(Gen9ThreadGroupPreemptionEnqueueKernelTest, givenSecondEnqueueWithTheSamePreemptionRequestThenDontReprogramThreadGroupNoWa) {
@@ -531,5 +531,5 @@ GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionModeWhenStateSipIsProgra
EXPECT_NE(nullptr, cmd);
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer());
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer());
}

View File

@@ -355,7 +355,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturns0WhenPreemptionModeIsN
auto builtIns = new MockBuiltins();
builtIns->overrideSipKernel(std::unique_ptr<NEO::SipKernel>(new NEO::SipKernel{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramWithCustomBinary()}));
mockDevice->getExecutionEnvironment()->builtins.reset(builtIns);
mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->builtins.reset(builtIns);
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, mode, mode, nullptr);
}
EXPECT_EQ(0U, cmdStream.getUsed());

View File

@@ -30,7 +30,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebu
auto sipAddress = stateSipCmd->getSystemInstructionPointer();
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
}
template <typename GfxFamily>
@@ -56,7 +56,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisa
auto sipAddress = stateSipCmd->getSystemInstructionPointer();
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
}
template <typename GfxFamily>
@@ -82,7 +82,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebug
auto sipAddress = stateSipCmd->getSystemInstructionPointer();
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress);
}
template <typename GfxFamily>