Improving OS abstraction

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2021-05-21 01:17:57 +02:00
committed by Compute-Runtime-Automation
parent 7bec5d5d3b
commit 0e9aa45e46
127 changed files with 558 additions and 606 deletions

View File

@@ -6,8 +6,8 @@
*/
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "shared/source/os_interface/os_interface.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "test.h"
@@ -35,8 +35,8 @@ class MetricQueryPoolLinuxTest : public MetricContextFixture,
void SetUp() override {
MetricContextFixture::SetUp();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new DrmMock(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
auto &osInterface = device->getOsInterface();
osInterface.setDriverModel(std::make_unique<DrmMock>(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
}
void TearDown() override {
@@ -59,9 +59,9 @@ TEST_F(MetricQueryPoolLinuxTest, givenCorrectArgumentsWhenGetContextDataIsCalled
EXPECT_EQ(mockMetricsLibrary->metricsLibraryGetContextData(*device, contextData), true);
auto osInterface = device->getOsInterface().get();
auto &osInterface = device->getOsInterface();
EXPECT_EQ(contextData.ClientData->Linux.Adapter->DrmFileDescriptor, osInterface->getDrm()->getFileDescriptor());
EXPECT_EQ(contextData.ClientData->Linux.Adapter->DrmFileDescriptor, osInterface.getDriverModel()->as<Drm>()->getFileDescriptor());
EXPECT_EQ(contextData.ClientData->Linux.Adapter->Type, LinuxAdapterType::DrmFileDescriptor);
}
@@ -71,8 +71,8 @@ class MetricEnumerationTestLinux : public MetricContextFixture,
void SetUp() override {
MetricContextFixture::SetUp();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new DrmMock(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
auto &osInterface = device->getOsInterface();
osInterface.setDriverModel(std::make_unique<DrmMock>(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
}
void TearDown() override {

View File

@@ -5,7 +5,7 @@
*
*/
#include "shared/source/os_interface/windows/os_interface.h"
#include "shared/source/os_interface/os_interface.h"
#include "opencl/test/unit_test/mocks/mock_wddm.h"
#include "test.h"
@@ -32,7 +32,7 @@ TEST_F(MetricEnumerationTestWindows, givenCorrectWindowsAdapterWhenGetMetricsAda
auto adapterParams = TAdapterParams_1_9{};
osInterface = std::make_unique<NEO::OSInterface>();
osInterface->get()->setWddm(wddm);
osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
adapterGroupParams.AdapterCount = 1;
adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_LUID;

View File

@@ -8,7 +8,7 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "shared/source/os_interface/os_interface.h"
#include "test.h"
@@ -45,8 +45,8 @@ class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
void SetUp() override {
DeviceFixture::SetUp();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new SysmanMockDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
auto &osInterface = device->getOsInterface();
osInterface.setDriverModel(std::make_unique<SysmanMockDrm>(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
setenv("ZES_ENABLE_SYSMAN", "1", 1);
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
pSysmanDevice = device->getSysmanHandle();
@@ -72,8 +72,8 @@ class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Te
device = driverHandle->devices[0];
neoDevice = device->getNEODevice();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new SysmanMockDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
auto &osInterface = device->getOsInterface();
osInterface.setDriverModel(std::make_unique<SysmanMockDrm>(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
setenv("ZES_ENABLE_SYSMAN", "1", 1);
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
pSysmanDevice = device->getSysmanHandle();

View File

@@ -28,7 +28,7 @@ TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleInSysmanInitThenValidSysmanHan
}
TEST_F(SysmanDeviceFixture, GivenSetValidDrmHandleForDeviceWhenDoingOsSysmanDeviceInitThenSameDrmHandleIsRetrieved) {
EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().get()->getDrm());
EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().getDriverModel()->as<Drm>());
}
TEST_F(SysmanDeviceFixture, GivenCreateFsAccessHandleWhenCallinggetFsAccessThenCreatedFsAccessHandleWillBeRetrieved) {

View File

@@ -62,8 +62,8 @@ class ZesPciFixture : public ::testing::Test {
device = driverHandle->devices[0];
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
auto osInterface = device->getOsInterface().get();
osInterface->setDrm(new SysmanMockDrm(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
auto &osInterface = device->getOsInterface();
osInterface.setDriverModel(std::make_unique<SysmanMockDrm>(const_cast<NEO::RootDeviceEnvironment &>(neoDevice->getRootDeviceEnvironment())));
setenv("ZES_ENABLE_SYSMAN", "1", 1);
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
pSysmanDevice = device->getSysmanHandle();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,7 +7,7 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/windows/os_interface.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "test.h"