mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Move mock gmm resource info to shared
Remove allocator_helper.cpp files Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a51b385e80
commit
6e64c24df3
@@ -255,7 +255,6 @@ if(BUILD_WITH_L0)
|
||||
${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}devices.inl
|
||||
${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}devices_additional.inl
|
||||
${NEO_SHARED_DIRECTORY}/dll/devices/devices_base.inl
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/allocator_helper.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/options_linux.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/os_interface.cpp
|
||||
)
|
||||
|
||||
@@ -40,11 +40,11 @@ add_library(compute_runtime_mockable_extra
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_deferred_deleter.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_device.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_gmm_client_context_base.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_gmm_resource_info_common.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_sip.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/unit_test/helpers/debug_helpers.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/unit_test/utilities/cpuintrinsics.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_gmm_page_table_mngr.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_gmm_resource_info.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_program.cpp
|
||||
${NEO_SHARED_DIRECTORY}/debug_settings/debug_settings_manager.cpp
|
||||
)
|
||||
@@ -86,7 +86,8 @@ endif()
|
||||
if(UNIX)
|
||||
target_sources(compute_runtime_mockable_extra
|
||||
PRIVATE
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/linux/allocator_helper.cpp
|
||||
${NEO_SHARED_DIRECTORY}/gmm_helper/resource_info_impl.cpp
|
||||
${NEO_SHARED_DIRECTORY}/gmm_helper${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp
|
||||
${NEO_SHARED_DIRECTORY}/tbx/tbx_sockets_imp.cpp
|
||||
)
|
||||
target_link_libraries(compute_runtime_mockable_extra
|
||||
|
||||
@@ -61,6 +61,7 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_deferred_deleter.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_device.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_gmm_client_context_base.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_gmm_resource_info_common.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_sip.cpp
|
||||
${NEO_SHARED_DIRECTORY}/debug_settings/debug_settings_manager.cpp
|
||||
${NEO_SHARED_DIRECTORY}/aub/aub_stream_interface.cpp
|
||||
@@ -97,7 +98,6 @@ if(UNIX)
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/options.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/allocator_helper.cpp
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/linux/gmm_interface_linux.cpp
|
||||
)
|
||||
else()
|
||||
|
||||
@@ -1,88 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
#include "level_zero/core/source/image/image_formats.h"
|
||||
|
||||
using namespace ::testing;
|
||||
|
||||
namespace NEO {
|
||||
GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams) {
|
||||
if (resourceCreateParams->Type == GMM_RESOURCE_TYPE::RESOURCE_INVALID) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ::testing::NiceMock<MockGmmResourceInfo>(resourceCreateParams);
|
||||
}
|
||||
|
||||
GmmResourceInfo *GmmResourceInfo::create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||
return new ::testing::NiceMock<MockGmmResourceInfo>(inputGmmResourceInfo);
|
||||
}
|
||||
|
||||
MockGmmResourceInfo::MockGmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) {
|
||||
mockResourceCreateParams = *resourceCreateParams;
|
||||
setupDefaultActions();
|
||||
}
|
||||
|
||||
MockGmmResourceInfo::MockGmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||
mockResourceCreateParams = reinterpret_cast<MockGmmResourceInfo *>(inputGmmResourceInfo)->mockResourceCreateParams;
|
||||
setupDefaultActions();
|
||||
};
|
||||
|
||||
// Simulate GMM behaviour. We dont want to test 3rd party lib
|
||||
void MockGmmResourceInfo::setupDefaultActions() {
|
||||
setSurfaceFormat();
|
||||
if (surfaceFormatInfo == nullptr) {
|
||||
ASSERT_TRUE(false);
|
||||
return;
|
||||
}
|
||||
computeRowPitch();
|
||||
|
||||
size = rowPitch;
|
||||
size *= static_cast<size_t>(mockResourceCreateParams.BaseHeight);
|
||||
|
||||
qPitch = alignUp((uint32_t)size, 64);
|
||||
|
||||
size *= mockResourceCreateParams.Depth ? static_cast<size_t>(mockResourceCreateParams.Depth) : 1;
|
||||
size *= mockResourceCreateParams.ArraySize ? static_cast<size_t>(mockResourceCreateParams.ArraySize) : 1;
|
||||
size = alignUp(size, MemoryConstants::pageSize);
|
||||
}
|
||||
|
||||
GMM_STATUS MockGmmResourceInfo::getOffset(GMM_REQ_OFFSET_INFO &reqOffsetInfo) {
|
||||
arrayIndexPassedToGetOffset = reqOffsetInfo.ArrayIndex;
|
||||
getOffsetCalled++;
|
||||
|
||||
reqOffsetInfo.Lock.Offset = 16;
|
||||
reqOffsetInfo.Lock.Pitch = 2;
|
||||
reqOffsetInfo.Render.YOffset = 1;
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_NV12) {
|
||||
reqOffsetInfo.Render.XOffset = 32;
|
||||
reqOffsetInfo.Render.Offset = 64;
|
||||
}
|
||||
if (reqOffsetInfo.Slice == 1) {
|
||||
reqOffsetInfo.Render.YOffset = mockResourceCreateParams.BaseHeight;
|
||||
}
|
||||
if (reqOffsetInfo.MipLevel > 0) {
|
||||
reqOffsetInfo.Lock.Offset = 32;
|
||||
}
|
||||
|
||||
return GMM_SUCCESS;
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::computeRowPitch() {
|
||||
if (mockResourceCreateParams.OverridePitch) {
|
||||
rowPitch = mockResourceCreateParams.OverridePitch;
|
||||
} else {
|
||||
rowPitch = static_cast<size_t>(mockResourceCreateParams.BaseWidth64 * (surfaceFormatInfo->ImageElementSizeInBytes));
|
||||
rowPitch = alignUp(rowPitch, 64);
|
||||
}
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
auto iterateL0Formats = [&](const std::array<L0::ImageFormats::FormatTypes, L0::ImageFormats::ZE_IMAGE_FORMAT_RENDER_LAYOUT_MAX> &formats) {
|
||||
@@ -108,41 +37,4 @@ void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
|
||||
ASSERT_NE(nullptr, surfaceFormatInfo);
|
||||
}
|
||||
|
||||
uint32_t MockGmmResourceInfo::getBitsPerPixel() {
|
||||
return static_cast<uint32_t>(surfaceFormatInfo->ImageElementSizeInBytes * 8);
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::setUnifiedAuxTranslationCapable() {
|
||||
mockResourceCreateParams.Flags.Gpu.CCS = 1;
|
||||
mockResourceCreateParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
||||
mockResourceCreateParams.Flags.Info.RenderCompressed = 1;
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::setMultisampleControlSurface() {
|
||||
mockResourceCreateParams.Flags.Gpu.MCS = 1;
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::setUnifiedAuxPitchTiles(uint32_t value) {
|
||||
this->unifiedAuxPitch = value;
|
||||
}
|
||||
void MockGmmResourceInfo::setAuxQPitch(uint32_t value) {
|
||||
this->auxQPitch = value;
|
||||
}
|
||||
|
||||
uint32_t MockGmmResourceInfo::getTileModeSurfaceState() {
|
||||
if (mockResourceCreateParams.Flags.Info.Linear == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mockResourceCreateParams.Type == GMM_RESOURCE_TYPE::RESOURCE_2D ||
|
||||
mockResourceCreateParams.Type == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
||||
return 3;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
MockGmmResourceInfo::MockGmmResourceInfo() {}
|
||||
MockGmmResourceInfo::~MockGmmResourceInfo() {}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -41,7 +41,6 @@ set(RUNTIME_SRCS_DLL_BASE
|
||||
append_sources_from_properties(RUNTIME_SRCS_DLL_BASE NEO_CORE_SRCS_LINK)
|
||||
|
||||
set(RUNTIME_SRCS_DLL_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/allocator_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/drm_neo_create.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/options_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/os_interface.cpp
|
||||
|
||||
@@ -11,4 +11,8 @@ namespace NEO {
|
||||
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvironment &executionEnvironment, DriverModelType driverModel) {
|
||||
return DrmMemoryManager::create(executionEnvironment);
|
||||
}
|
||||
|
||||
size_t getSizeToReserve() {
|
||||
return (maxNBitValue(47) + 1) / 4;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -16,4 +16,7 @@ std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvir
|
||||
return std::make_unique<WddmMemoryManager>(executionEnvironment);
|
||||
}
|
||||
}
|
||||
size_t getSizeToReserve() {
|
||||
return (maxNBitValue(47) + 1) / 4;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/allocator_helper.h"
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
size_t getSizeToReserve() {
|
||||
return (maxNBitValue(47) + 1) / 4;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "opencl/source/mem_obj/buffer.h"
|
||||
@@ -16,7 +17,6 @@
|
||||
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
@@ -72,7 +72,6 @@ set(IGDRCL_SRCS_LIB_ULT_ENV_WINDOWS
|
||||
)
|
||||
|
||||
set(IGDRCL_SRCS_LIB_ULT_ENV_LINUX
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/allocator_helper.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/create_drm_memory_manager.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/options.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp
|
||||
|
||||
@@ -23,14 +23,13 @@ add_executable(igdrcl_${target_name}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/linux/sys_calls_linux.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/aub_stream_mocks/aub_stream_interface_mock.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/linux/allocator_helper.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/create_memory_manager_drm.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/linux/drm_neo_create.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/linux/options_linux.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/dll/linux/os_interface.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/helpers/api_specific_config_ocl.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/source/os_interface/linux/platform_teardown_linux.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/linux${BRANCH_DIR_SUFFIX}drm_other_requests.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/create_drm_memory_manager.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/linux/device_command_stream_fixture.cpp
|
||||
)
|
||||
if(NEO__LIBVA_FOUND)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/surface.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "opencl/source/helpers/surface_formats.h"
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_kernel.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_program.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/kernel_binary_helper.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
#include "opencl/source/cl_device/cl_device_get_cap.inl"
|
||||
#include "opencl/source/helpers/cl_memory_properties_helpers.h"
|
||||
@@ -19,7 +20,6 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_buffer.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"
|
||||
#include "test.h"
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ set(IGDRCL_SRCS_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_page_table_mngr.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info_ocl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_image.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_internal_allocation_storage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_kernel.cpp
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "opencl/source/helpers/surface_formats.h"
|
||||
#include "opencl/source/mem_obj/image.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
namespace NEO {
|
||||
namespace MockGmmParams {
|
||||
|
||||
58
opencl/test/unit_test/mocks/mock_gmm_resource_info_ocl.cpp
Normal file
58
opencl/test/unit_test/mocks/mock_gmm_resource_info_ocl.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
#include "opencl/source/helpers/surface_formats.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
auto iterate = [&](ArrayRef<const ClSurfaceFormatInfo> formats) {
|
||||
if (!surfaceFormatInfo) {
|
||||
for (auto &format : formats) {
|
||||
if (mockResourceCreateParams.Format == format.surfaceFormat.GMMSurfaceFormat) {
|
||||
surfaceFormatInfo = &format.surfaceFormat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010 || mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_P016) {
|
||||
tempSurface.GMMSurfaceFormat = mockResourceCreateParams.Format;
|
||||
tempSurface.NumChannels = 1;
|
||||
tempSurface.ImageElementSizeInBytes = 16;
|
||||
tempSurface.PerChannelSizeInBytes = 16;
|
||||
|
||||
surfaceFormatInfo = &tempSurface;
|
||||
}
|
||||
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_RGBP) {
|
||||
tempSurface.GMMSurfaceFormat = GMM_RESOURCE_FORMAT::GMM_FORMAT_RGBP;
|
||||
tempSurface.NumChannels = 1;
|
||||
tempSurface.ImageElementSizeInBytes = 8;
|
||||
tempSurface.PerChannelSizeInBytes = 8;
|
||||
|
||||
surfaceFormatInfo = &tempSurface;
|
||||
}
|
||||
|
||||
iterate(SurfaceFormats::readOnly12());
|
||||
iterate(SurfaceFormats::readOnly20());
|
||||
iterate(SurfaceFormats::writeOnly());
|
||||
iterate(SurfaceFormats::readWrite());
|
||||
|
||||
iterate(SurfaceFormats::packedYuv());
|
||||
iterate(SurfaceFormats::planarYuv());
|
||||
iterate(SurfaceFormats::packed());
|
||||
|
||||
iterate(SurfaceFormats::readOnlyDepth());
|
||||
iterate(SurfaceFormats::readWriteDepth());
|
||||
|
||||
ASSERT_NE(nullptr, surfaceFormatInfo);
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/allocator_helper.h"
|
||||
|
||||
#include "shared/source/helpers/constants.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
size_t getSizeToReserve() {
|
||||
// 4 x sizeof(Heap32) + 2 x sizeof(Standard/Standard64k)
|
||||
return (4 * 4 + 2 * 4) * GB;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -19,4 +19,8 @@ std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvir
|
||||
}
|
||||
return DrmMemoryManager::create(executionEnvironment);
|
||||
}
|
||||
size_t getSizeToReserve() {
|
||||
// 4 x sizeof(Heap32) + 2 x sizeof(Standard/Standard64k)
|
||||
return (4 * 4 + 2 * 4) * GB;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_gfx_partition.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_wddm_residency_logger.h"
|
||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/ult_dxcore_factory.h"
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
@@ -34,7 +35,6 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_event.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "gl_types.h"
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
#include "opencl/source/mem_obj/image.h"
|
||||
#include "opencl/source/sharings/unified/unified_image.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/os_interface/raii_hw_info_config.h"
|
||||
#include "opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h"
|
||||
#include "opencl/test/unit_test/sharings/unified/unified_sharing_mocks.h"
|
||||
|
||||
@@ -45,6 +45,8 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gfx_partition.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}/mock_gmm_resource_info_common.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_graphics_allocation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_host_ptr_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_hw_info_config.cpp
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
|
||||
#include "opencl/source/helpers/surface_formats.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
using namespace ::testing;
|
||||
|
||||
@@ -38,6 +35,9 @@ MockGmmResourceInfo::MockGmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo
|
||||
// Simulate GMM behaviour. We dont want to test 3rd party lib
|
||||
void MockGmmResourceInfo::setupDefaultActions() {
|
||||
setSurfaceFormat();
|
||||
if (surfaceFormatInfo == nullptr) {
|
||||
return;
|
||||
}
|
||||
computeRowPitch();
|
||||
|
||||
size = rowPitch;
|
||||
@@ -80,51 +80,6 @@ void MockGmmResourceInfo::computeRowPitch() {
|
||||
}
|
||||
}
|
||||
|
||||
void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
auto iterate = [&](ArrayRef<const ClSurfaceFormatInfo> formats) {
|
||||
if (!surfaceFormatInfo) {
|
||||
for (auto &format : formats) {
|
||||
if (mockResourceCreateParams.Format == format.surfaceFormat.GMMSurfaceFormat) {
|
||||
surfaceFormatInfo = &format.surfaceFormat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_P010 || mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_P016) {
|
||||
tempSurface.GMMSurfaceFormat = mockResourceCreateParams.Format;
|
||||
tempSurface.NumChannels = 1;
|
||||
tempSurface.ImageElementSizeInBytes = 16;
|
||||
tempSurface.PerChannelSizeInBytes = 16;
|
||||
|
||||
surfaceFormatInfo = &tempSurface;
|
||||
}
|
||||
|
||||
if (mockResourceCreateParams.Format == GMM_RESOURCE_FORMAT::GMM_FORMAT_RGBP) {
|
||||
tempSurface.GMMSurfaceFormat = GMM_RESOURCE_FORMAT::GMM_FORMAT_RGBP;
|
||||
tempSurface.NumChannels = 1;
|
||||
tempSurface.ImageElementSizeInBytes = 8;
|
||||
tempSurface.PerChannelSizeInBytes = 8;
|
||||
|
||||
surfaceFormatInfo = &tempSurface;
|
||||
}
|
||||
|
||||
iterate(SurfaceFormats::readOnly12());
|
||||
iterate(SurfaceFormats::readOnly20());
|
||||
iterate(SurfaceFormats::writeOnly());
|
||||
iterate(SurfaceFormats::readWrite());
|
||||
|
||||
iterate(SurfaceFormats::packedYuv());
|
||||
iterate(SurfaceFormats::planarYuv());
|
||||
iterate(SurfaceFormats::packed());
|
||||
|
||||
iterate(SurfaceFormats::readOnlyDepth());
|
||||
iterate(SurfaceFormats::readWriteDepth());
|
||||
|
||||
ASSERT_NE(nullptr, surfaceFormatInfo);
|
||||
}
|
||||
|
||||
uint32_t MockGmmResourceInfo::getBitsPerPixel() {
|
||||
return static_cast<uint32_t>(surfaceFormatInfo->ImageElementSizeInBytes * 8);
|
||||
}
|
||||
@@ -97,6 +97,7 @@ if(NOT SKIP_UNIT_TESTS)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${NEO_SHARED_TEST_DIRECTORY}/common "${NEO_BUILD_DIR}/shared/test/common")
|
||||
add_subdirectory_unique(mocks)
|
||||
|
||||
if(NOT SKIP_SHARED_UNIT_TESTS)
|
||||
add_subdirectories()
|
||||
|
||||
@@ -8,8 +8,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 "shared/test/common/mocks/mock_gmm_resource_info.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"
|
||||
|
||||
|
||||
10
shared/test/unit_test/mocks/CMakeLists.txt
Normal file
10
shared/test/unit_test/mocks/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info.cpp
|
||||
)
|
||||
14
shared/test/unit_test/mocks/mock_gmm_resource_info.cpp
Normal file
14
shared/test/unit_test/mocks/mock_gmm_resource_info.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MockGmmResourceInfo::setSurfaceFormat() {
|
||||
}
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user