Create TestEnvironment in ze_intel_gpu_core_tests

Change-Id: I85306b59e220c34ee6b43790b59f5ad96ea51eca
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-09-10 12:29:04 +02:00
committed by sys_ocldev
parent 2590a87baf
commit a5c556fe11
10 changed files with 50 additions and 12 deletions

View File

@@ -65,12 +65,12 @@ KernelImmutableData::KernelImmutableData(L0::Device *l0device) : device(l0device
KernelImmutableData::~KernelImmutableData() {
if (nullptr != isaGraphicsAllocation) {
this->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(&*isaGraphicsAllocation);
this->getDevice()->getNEODevice()->getMemoryManager()->freeGraphicsMemory(&*isaGraphicsAllocation);
isaGraphicsAllocation.release();
}
crossThreadDataTemplate.reset();
if (nullptr != privateMemoryGraphicsAllocation) {
this->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(&*privateMemoryGraphicsAllocation);
this->getDevice()->getNEODevice()->getMemoryManager()->freeGraphicsMemory(&*privateMemoryGraphicsAllocation);
privateMemoryGraphicsAllocation.release();
}
surfaceStateHeapTemplate.reset();
@@ -199,7 +199,7 @@ KernelImp::~KernelImp() {
alignedFree(perThreadDataForWholeThreadGroup);
}
if (printfBuffer != nullptr) {
module->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(printfBuffer);
module->getDevice()->getNEODevice()->getMemoryManager()->freeGraphicsMemory(printfBuffer);
}
slmArgSizes.clear();
crossThreadData.reset();

View File

@@ -331,7 +331,7 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
kernelImmDatas.reserve(this->translationUnit->programInfo.kernelInfos.size());
for (auto &ki : this->translationUnit->programInfo.kernelInfos) {
std::unique_ptr<KernelImmutableData> kernelImmData{new KernelImmutableData(this->device)};
kernelImmData->initialize(ki, *(getDevice()->getDriverHandle()->getMemoryManager()),
kernelImmData->initialize(ki, *(device->getNEODevice()->getMemoryManager()),
device->getNEODevice(),
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
this->translationUnit->globalConstBuffer, this->translationUnit->globalVarBuffer);

View File

@@ -43,6 +43,7 @@ target_sources(${TARGET_NAME} PRIVATE
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/io_functions.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
$<TARGET_OBJECTS:${L0_MOCKABLE_LIB_NAME}>
)
@@ -103,6 +104,7 @@ if(UNIX)
target_link_libraries(${TARGET_NAME} pthread rt)
else()
target_link_libraries(${TARGET_NAME} dbghelp)
add_dependencies(${TARGET_NAME} mock_gdi)
endif()
target_link_libraries(${TARGET_NAME}
@@ -114,6 +116,7 @@ target_link_libraries(${TARGET_NAME}
if(SKIP_NEO_UNIT_TESTS)
add_subdirectory(${NEO_SOURCE_DIR}/opencl/test/unit_test/mock_gmm ${CMAKE_BINARY_DIR}/mock_gmm)
add_subdirectory(${NEO_SOURCE_DIR}/opencl/test/unit_test/mock_gdi ${CMAKE_BINARY_DIR}/mock_gdi)
endif()
target_sources(${TARGET_NAME} PRIVATE

View File

@@ -16,6 +16,7 @@
#include "opencl/source/program/kernel_info.h"
#include "opencl/source/utilities/logger.h"
#include "opencl/test/unit_test/custom_event_listener.h"
#include "opencl/test/unit_test/global_environment.h"
#include "opencl/test/unit_test/mocks/mock_gmm_client_context.h"
#include "opencl/test/unit_test/mocks/mock_sip.h"
@@ -45,7 +46,7 @@ TEST(Should, pass) { EXPECT_TRUE(true); }
namespace L0 {
namespace ult {
::testing::Environment *environment = nullptr;
TestEnvironment *environment = nullptr;
}
} // namespace L0
@@ -219,10 +220,6 @@ int main(int argc, char **argv) {
NEO::GmmHelper::createGmmContextWrapperFunc =
NEO::GmmClientContextBase::create<NEO::MockGmmClientContext>;
if (environment) {
::testing::AddGlobalTestEnvironment(environment);
}
uint64_t hwInfoConfig = NEO::defaultHardwareInfoConfigTable[productFamily];
NEO::setHwInfoValuesFromConfig(hwInfoConfig, hwInfoForTests);
@@ -235,6 +232,13 @@ int main(int argc, char **argv) {
NEO::useKernelDescriptor = true;
NEO::MockSipData::mockSipKernel.reset(new NEO::MockSipKernel());
environment = reinterpret_cast<TestEnvironment *>(::testing::AddGlobalTestEnvironment(new TestEnvironment));
MockCompilerDebugVars fclDebugVars;
MockCompilerDebugVars igcDebugVars;
environment->setDefaultDebugVars(fclDebugVars, igcDebugVars, hwInfoForTests);
auto retVal = RUN_ALL_TESTS();
return retVal;

View File

@@ -62,6 +62,11 @@ TEST(zeCommandListCreateImmediate, DISABLED_redirectsToObject) {
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
}
TEST_F(CommandListCreate, givenNonValidProductFamilyWhenCommandListIsCreatedThenNullptrIsReturned) {
std::unique_ptr<L0::CommandList> commandList(CommandList::create(PRODUCT_FAMILY::IGFX_MAX_PRODUCT, device, false));
EXPECT_EQ(nullptr, commandList);
}
TEST_F(CommandListCreate, whenCommandListIsCreatedThenItIsInitialized) {
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
ASSERT_NE(nullptr, commandList);
@@ -153,6 +158,18 @@ TEST_F(CommandListCreate, givenValidPtrThenAppendMemoryPrefetchReturnsSuccess) {
ASSERT_EQ(res, ZE_RESULT_SUCCESS);
}
TEST_F(CommandListCreate, givenNonValidProductFamilyWhenCommandListImmediateIsCreatedThenNullptrIsReturned) {
const ze_command_queue_desc_t desc = {};
bool internalEngine = false;
std::unique_ptr<L0::CommandList> commandList0(CommandList::createImmediate(PRODUCT_FAMILY::IGFX_MAX_PRODUCT,
device,
&desc,
internalEngine,
false));
EXPECT_EQ(nullptr, commandList0);
}
TEST_F(CommandListCreate, givenImmediateCommandListThenInternalEngineIsUsedIfRequested) {
const ze_command_queue_desc_t desc = {};
bool internalEngine = true;

View File

@@ -305,6 +305,8 @@ TEST_F(AllocHostMemoryTest,
whenCallingAllocHostMemThenAllocateGraphicsMemoryWithPropertiesIsCalledTheNumberOfTimesOfRootDevices) {
void *ptr = nullptr;
memoryManager->allocateGraphicsMemoryWithPropertiesCount = 0;
ze_result_t result = driverHandle->allocHostMem(0u,
4096u, 0u, &ptr);
EXPECT_EQ(memoryManager->allocateGraphicsMemoryWithPropertiesCount, numRootDevices);
@@ -321,6 +323,8 @@ TEST_F(AllocHostMemoryTest,
void *ptr = nullptr;
memoryManager->allocateGraphicsMemoryWithPropertiesCount = 0;
ze_result_t result = driverHandle->allocHostMem(0u,
4096u, 0u, &ptr);
EXPECT_EQ(memoryManager->allocateGraphicsMemoryWithPropertiesCount, 1u);
@@ -335,6 +339,8 @@ TEST_F(AllocHostMemoryTest,
void *ptr = nullptr;
memoryManager->allocateGraphicsMemoryWithPropertiesCount = 0;
ze_result_t result = driverHandle->allocHostMem(0u,
4096u, 0u, &ptr);
EXPECT_EQ(memoryManager->allocateGraphicsMemoryWithPropertiesCount, numRootDevices);

View File

@@ -49,6 +49,7 @@ target_sources(
PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/io_functions.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
$<TARGET_OBJECTS:${L0_MOCKABLE_LIB_NAME}>
)
@@ -107,6 +108,7 @@ if(UNIX)
target_link_libraries(${TARGET_NAME} pthread rt)
else()
target_link_libraries(${TARGET_NAME} dbghelp)
add_dependencies(${TARGET_NAME} mock_gdi)
endif()
target_link_libraries(

View File

@@ -40,6 +40,7 @@ target_sources(${TARGET_NAME} PRIVATE
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/io_functions.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
$<TARGET_OBJECTS:${L0_MOCKABLE_LIB_NAME}>
)
@@ -92,6 +93,7 @@ if(UNIX)
target_link_libraries(${TARGET_NAME} pthread rt)
else()
target_link_libraries(${TARGET_NAME} dbghelp)
add_dependencies(${TARGET_NAME} mock_gdi)
endif()
target_link_libraries(${TARGET_NAME}
@@ -104,6 +106,8 @@ target_link_libraries(${TARGET_NAME}
target_sources(${TARGET_NAME} PRIVATE
$<TARGET_OBJECTS:mock_gmm>
$<TARGET_OBJECTS:${TARGET_NAME_L0}_mocks>
$<TARGET_OBJECTS:${BUILTINS_SPIRV_LIB_NAME}>
$<TARGET_OBJECTS:${BUILTINS_BINARIES_LIB_NAME}>
)
option(L0_ULT_VERBOSE "Use the default/verbose test output" OFF)

View File

@@ -502,6 +502,11 @@ apply_macro_for_each_gen("TESTED")
add_subdirectories()
create_project_source_tree(igdrcl_tests)
if(MSVC)
add_dependencies(unit_tests mock_gdi)
add_dependencies(igdrcl_tests mock_gdi)
endif()
set(UltPchHeader "${CMAKE_CURRENT_SOURCE_DIR}/igdrcl_tests_pch.h")
set(UltPchSource "${CMAKE_CURRENT_SOURCE_DIR}/igdrcl_tests_pch.cpp")
get_target_property(UltSources igdrcl_tests SOURCES)

View File

@@ -41,7 +41,4 @@ if(WIN32)
set_target_properties(mock_gdi PROPERTIES FOLDER "test mocks")
target_compile_definitions(mock_gdi PUBLIC MOCKABLE_VIRTUAL=virtual)
add_dependencies(unit_tests mock_gdi)
add_dependencies(igdrcl_tests mock_gdi)
endif()