Add support for L3 cache information

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2021-01-29 22:23:06 +00:00
committed by Compute-Runtime-Automation
parent e64f3db55c
commit d399613f25
15 changed files with 189 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -14,6 +14,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/device_os_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_cache_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_mm_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_debug_tests.cpp

View File

@ -0,0 +1,18 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/cache_info_impl.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenCallingGetCacheRegionThenReturnZero) {
CacheInfoImpl cacheInfo;
EXPECT_FALSE(cacheInfo.getCacheRegion(1024, CacheRegion::Default));
}

View File

@ -40,6 +40,7 @@
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_cache_info.h"
#include "test.h"
#include "drm/i915_drm.h"
@ -4183,4 +4184,48 @@ TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenC
allocation.freeRegisteredBOBindExtHandles(&drm);
EXPECT_EQ(2u, drm.unregisterCalledCount);
}
TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFalse) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.cacheInfo.reset(new MockCacheInfo());
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory);
EXPECT_FALSE(allocation.setCacheRegion(&drm, 1024, CacheRegion::None));
}
TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenReturnTrue) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.cacheInfo.reset(new MockCacheInfo());
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory);
EXPECT_TRUE(allocation.setCacheRegion(&drm, 1024, CacheRegion::Region1));
}
TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSetRegionInBufferObject) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.cacheInfo.reset(new MockCacheInfo());
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory);
allocation.bufferObjects[0] = &bo;
EXPECT_TRUE(allocation.setCacheRegion(&drm, 1024, CacheRegion::Region1));
for (auto bo : allocation.bufferObjects) {
if (bo != nullptr) {
EXPECT_EQ(CacheRegion::Region1, bo->peekCacheRegion());
}
}
}
} // namespace NEO

View File

@ -30,6 +30,7 @@ using namespace NEO;
class DrmMock : public Drm {
public:
using Drm::bindAvailable;
using Drm::cacheInfo;
using Drm::checkQueueSliceSupport;
using Drm::classHandles;
using Drm::contextDebugSupported;

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/linux/cache_info.h"
namespace NEO {
struct MockCacheInfo : public CacheInfo {
MockCacheInfo() {}
~MockCacheInfo() override = default;
bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override {
return (regionIndex > CacheRegion::None) ? true : false;
}
};
} // namespace NEO