mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
committed by
Compute-Runtime-Automation
parent
67deb0377f
commit
c238d75ba6
137
level_zero/core/test/unit_tests/aub_tests/CMakeLists.txt
Normal file
137
level_zero/core/test/unit_tests/aub_tests/CMakeLists.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
project(ze_intel_gpu_aub_tests)
|
||||
|
||||
set(L0_AUB_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
get_property(NEO_SHARED_aub_tests_configurations GLOBAL PROPERTY NEO_SHARED_aub_tests_configurations)
|
||||
|
||||
list(APPEND L0_AUB_TESTS__TARGET_OBJECTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_hello_world_test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/main.cpp
|
||||
${NEO_SHARED_aub_tests_configurations}
|
||||
${NEO_SHARED_TEST_DIRECTORY}/unit_test/tests_configuration.h
|
||||
)
|
||||
|
||||
add_executable(ze_intel_gpu_aub_tests
|
||||
${L0_AUB_TESTS__TARGET_OBJECTS}
|
||||
)
|
||||
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${L0_CORE_ENABLERS}
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/main.cpp
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/mock.h
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/white_box.h
|
||||
${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp
|
||||
${NEO_SOURCE_DIR}/level_zero/core/source/dll/create_builtin_functions_lib.cpp
|
||||
${NEO_SOURCE_DIR}/level_zero/core/source/dll/disallow_deferred_deleter.cpp
|
||||
)
|
||||
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/libult/os_interface.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/ult_device_factory.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/ult_device_factory.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks${BRANCH_SUFIX_DIR}/mock_gmm_client_context.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_cif.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_command_stream_receiver.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compiler_interface_spirv.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compiler_interface_spirv.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.cpp
|
||||
${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_sip.cpp
|
||||
${NEO_SHARED_DIRECTORY}/debug_settings/debug_settings_manager.cpp
|
||||
${NEO_SHARED_DIRECTORY}/aub/aub_stream_interface.cpp
|
||||
)
|
||||
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
$<TARGET_OBJECTS:${L0_MOCKABLE_LIB_NAME}>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_fixtures>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_mocks>
|
||||
$<TARGET_OBJECTS:igdrcl_libult_common>
|
||||
$<TARGET_OBJECTS:${BUILTINS_SPIRV_LIB_NAME}>
|
||||
$<TARGET_OBJECTS:${BUILTINS_BINARIES_BINDFUL_LIB_NAME}>
|
||||
$<TARGET_OBJECTS:${BUILTINS_BINARIES_BINDLESS_LIB_NAME}>
|
||||
)
|
||||
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers${BRANCH_DIR_SUFFIX}/kernel_binary_helper_hash_value.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/io_functions.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/abort.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_gmm_page_table_mngr.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_memory_manager.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/utilities/debug_settings_reader_creator.cpp
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
if(NOT DISABLE_WDDM_LINUX)
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${NEO_SHARED_DIRECTORY}/gmm_helper/windows/gmm_memory.cpp
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/wddm/wddm_create.cpp
|
||||
)
|
||||
endif()
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${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/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/drm_mock.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()
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${NEO_SHARED_DIRECTORY}/gmm_helper/windows/gmm_memory.cpp
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/gmm_interface_win.cpp
|
||||
${NEO_SHARED_DIRECTORY}/dll/windows/environment_variables.cpp
|
||||
${NEO_SOURCE_DIR}/shared/source/dll/windows/environment_variables.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/create_wddm_memory_manager.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/options.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/sys_calls.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/ult_dxcore_factory.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/wddm_calls.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/os_interface/windows/wddm_create.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_wddm.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
copy_gmm_dll_for(ze_intel_gpu_aub_tests)
|
||||
add_subdirectories()
|
||||
|
||||
target_link_libraries(ze_intel_gpu_aub_tests ${NEO_STATICALLY_LINKED_LIBRARIES_MOCKABLE})
|
||||
target_link_libraries(ze_intel_gpu_aub_tests ${HW_LIBS_ULT})
|
||||
target_link_libraries(ze_intel_gpu_aub_tests gmock-gtest)
|
||||
target_link_libraries(ze_intel_gpu_aub_tests ${IGDRCL_EXTRA_LIBS})
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(ze_intel_gpu_aub_tests rt)
|
||||
target_link_libraries(ze_intel_gpu_aub_tests ${GMM_LINK_NAME})
|
||||
else()
|
||||
target_link_libraries(ze_intel_gpu_aub_tests dbghelp)
|
||||
add_dependencies(ze_intel_gpu_aub_tests ${GMM_TARGET_NAME})
|
||||
endif()
|
||||
|
||||
target_include_directories(ze_intel_gpu_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${NEO_SOURCE_DIR}/shared/test/common/helpers/includes${BRANCH_DIR_SUFFIX}
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/header${BRANCH_DIR_SUFFIX}
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/gmm_memory
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests
|
||||
${ENGINE_NODE_DIR}
|
||||
${CIF_BASE_DIR}
|
||||
${NEO__GMM_INCLUDE_DIR}
|
||||
${THIRD_PARTY_DIR}
|
||||
${WDK_DIR}
|
||||
)
|
||||
|
||||
create_project_source_tree(ze_intel_gpu_aub_tests)
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/aub_tests/fixtures/aub_fixture.h"
|
||||
|
||||
#include "test_mode.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class AUBHelloWorldL0 : public AUBFixtureL0,
|
||||
public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() {
|
||||
AUBFixtureL0::SetUp(NEO::defaultHwInfo.get());
|
||||
}
|
||||
void TearDown() {
|
||||
AUBFixtureL0::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(AUBHelloWorldL0, whenAppendMemoryCopyIsCalledThenMemoryIsProperlyCopied) {
|
||||
uint8_t size = 8;
|
||||
uint8_t val = 255;
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY,
|
||||
context->rootDeviceIndices,
|
||||
context->deviceBitfields);
|
||||
|
||||
auto srcMemory = driverHandle->svmAllocsManager->createHostUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
auto dstMemory = driverHandle->svmAllocsManager->createHostUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
|
||||
memset(srcMemory, val, size);
|
||||
commandList->appendMemoryCopy(dstMemory, srcMemory, size, 0, 0, nullptr);
|
||||
commandList->close();
|
||||
auto pHCmdList = std::make_unique<ze_command_list_handle_t>(commandList->toHandle());
|
||||
|
||||
pCmdq->executeCommandLists(1, pHCmdList.get(), nullptr, false);
|
||||
pCmdq->synchronize(std::numeric_limits<uint32_t>::max());
|
||||
|
||||
EXPECT_TRUE(csr->expectMemory(dstMemory, srcMemory, val, AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual));
|
||||
|
||||
driverHandle->svmAllocsManager->freeSVMAlloc(srcMemory);
|
||||
driverHandle->svmAllocsManager->freeSVMAlloc(dstMemory);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(ze_intel_gpu_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_fixture.h
|
||||
|
||||
)
|
||||
add_subdirectories()
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "aub_fixture.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
void AUBFixtureL0::SetUp(const HardwareInfo *hardwareInfo) {
|
||||
const HardwareInfo &hwInfo = hardwareInfo ? *hardwareInfo : *defaultHwInfo;
|
||||
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
auto engineType = getChosenEngineType(hwInfo);
|
||||
|
||||
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
|
||||
std::stringstream strfilename;
|
||||
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name;
|
||||
|
||||
executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1u);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo);
|
||||
|
||||
neoDevice = MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0u);
|
||||
|
||||
this->csr = AUBCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0, neoDevice->getDeviceBitfield());
|
||||
neoDevice->resetCommandStreamReceiver(this->csr);
|
||||
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<ult::Mock<DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
context = static_cast<ContextImp *>(Context::fromHandle(hContext));
|
||||
|
||||
ze_result_t returnValue;
|
||||
commandList.reset(ult::whitebox_cast(CommandList::create(hwInfo.platform.eProductFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)));
|
||||
|
||||
ze_event_pool_desc_t eventPoolDesc = {};
|
||||
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE;
|
||||
eventPoolDesc.count = 2;
|
||||
|
||||
ze_event_desc_t eventDesc = {};
|
||||
eventDesc.index = 0;
|
||||
eventDesc.wait = 0;
|
||||
eventDesc.signal = 0;
|
||||
|
||||
eventPool = std::unique_ptr<EventPool>(EventPool::create(device->getDriverHandle(), context, 0, nullptr, &eventPoolDesc));
|
||||
|
||||
returnValue = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
ze_command_queue_desc_t queueDesc = {};
|
||||
pCmdq = CommandQueue::create(hwInfo.platform.eProductFamily, device, csr, &queueDesc, false, false, returnValue);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
void AUBFixtureL0::TearDown() {
|
||||
context->destroy();
|
||||
pCmdq->destroy();
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_event.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h"
|
||||
|
||||
#include "third_party/gtest/gtest/gtest.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class AUBFixtureL0 {
|
||||
public:
|
||||
void SetUp(const HardwareInfo *hardwareInfo);
|
||||
void TearDown();
|
||||
|
||||
const uint32_t rootDeviceIndex = 0;
|
||||
NEO::ExecutionEnvironment *executionEnvironment;
|
||||
NEO::MemoryManager *memoryManager = nullptr;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
|
||||
std::unique_ptr<ult::Mock<DriverHandleImp>> driverHandle;
|
||||
std::unique_ptr<ult::CommandList> commandList;
|
||||
std::unique_ptr<EventPool> eventPool;
|
||||
std::unique_ptr<Event> event;
|
||||
|
||||
Device *device = nullptr;
|
||||
ContextImp *context = nullptr;
|
||||
CommandQueue *pCmdq = nullptr;
|
||||
|
||||
CommandStreamReceiver *csr = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
14
level_zero/core/test/unit_tests/aub_tests/test_mode.h
Normal file
14
level_zero/core/test/unit_tests/aub_tests/test_mode.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/unit_test/tests_configuration.h"
|
||||
|
||||
namespace NEO {
|
||||
constexpr TestMode defaultTestMode = TestMode::AubTests;
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user