Make MemoryOperationsHandler adapter specific

Change-Id: I978ecaf0fbe3cfc3b645b84d978b7d9234b28bd1
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-11-28 13:02:11 +01:00
committed by sys_ocldev
parent ec22a08785
commit 44a9ec5c1a
22 changed files with 107 additions and 56 deletions

View File

@@ -18,6 +18,8 @@
#include "gtest/gtest.h"
#include <set>
using namespace NEO;
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
@@ -183,7 +185,7 @@ TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeForTgllpProductF
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
}
TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeWhenGetDevicesForProductFamilyOverrideIsCalledThenAllAubCentersAreInitializedCorrectly) {
TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeWhenGetDevicesForProductFamilyOverrideIsCalledThenAllRootDeviceEnvironmentMembersAreInitialized) {
DeviceFactoryCleaner cleaner;
DebugManagerStateRestore stateRestore;
auto requiredDeviceCount = 2u;
@@ -198,10 +200,40 @@ TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeWhenGetDevicesFo
ASSERT_TRUE(success);
EXPECT_EQ(requiredDeviceCount, numDevices);
std::set<MemoryOperationsHandler *> memoryOperationHandlers;
for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) {
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get());
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
auto memoryOperationInterface = rootDeviceEnvironment->memoryOperationsInterface.get();
EXPECT_NE(nullptr, memoryOperationInterface);
EXPECT_EQ(memoryOperationHandlers.end(), memoryOperationHandlers.find(memoryOperationInterface));
memoryOperationHandlers.insert(memoryOperationInterface);
}
}
TEST_F(DeviceFactoryTest, whenGetDevicesIsCalledThenAllRootDeviceEnvironmentMembersAreInitialized) {
DeviceFactoryCleaner cleaner;
DebugManagerStateRestore stateRestore;
auto requiredDeviceCount = 2u;
DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount);
MockExecutionEnvironment executionEnvironment(*platformDevices, true, requiredDeviceCount);
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(numDevices, executionEnvironment);
ASSERT_TRUE(success);
EXPECT_EQ(requiredDeviceCount, numDevices);
std::set<MemoryOperationsHandler *> memoryOperationHandlers;
for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) {
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get());
auto memoryOperationInterface = rootDeviceEnvironment->memoryOperationsInterface.get();
EXPECT_NE(nullptr, memoryOperationInterface);
EXPECT_EQ(memoryOperationHandlers.end(), memoryOperationHandlers.find(memoryOperationInterface));
memoryOperationHandlers.insert(memoryOperationInterface);
}
}
@@ -224,4 +256,4 @@ TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAlloca
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
EXPECT_TRUE(success);
EXPECT_NE(nullptr, executionEnvironment->osInterface);
}
}