Move unit test helper to shared code

Related-To: NEO-5161

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2021-04-13 14:00:07 +02:00
committed by Compute-Runtime-Automation
parent e5eba8be53
commit 9839b3049d
73 changed files with 126 additions and 122 deletions

View File

@@ -21,8 +21,8 @@ if(TESTS_GEN11)
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_gen11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_gen11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_gen11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_gen11.cpp
${COMPUTE_RUNTIME_ULT_GEN11}
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen11/unit_test_helper_gen11.cpp
)
endif()

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gen11/hw_info.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/unit_test_helper.inl"
namespace NEO {
template struct UnitTestHelper<ICLFamily>;
} // namespace NEO

View File

@@ -22,9 +22,9 @@ if(TESTS_GEN12LP)
${CMAKE_CURRENT_SOURCE_DIR}/test_command_encoder_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_gen12lp.cpp
${COMPUTE_RUNTIME_ULT_GEN12LP}
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen12lp/special_ult_helper_gen12lp.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen12lp/unit_test_helper_gen12lp.cpp
)
endif()

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gen12lp/hw_info.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/unit_test_helper.inl"
#include "opencl/test/unit_test/gen12lp/special_ult_helper_gen12lp.h"
namespace NEO {
using Family = TGLLPFamily;
template <>
bool UnitTestHelper<Family>::isL3ConfigProgrammable() {
return false;
};
template <>
bool UnitTestHelper<Family>::isPageTableManagerSupported(const HardwareInfo &hwInfo) {
return hwInfo.capabilityTable.ftrRenderCompressedBuffers || hwInfo.capabilityTable.ftrRenderCompressedImages;
}
template <>
bool UnitTestHelper<Family>::isPipeControlWArequired(const HardwareInfo &hwInfo) {
return SpecialUltHelperGen12lp::isPipeControlWArequired(hwInfo.platform.eProductFamily);
}
template struct UnitTestHelper<Family>;
} // namespace NEO

View File

@@ -22,8 +22,8 @@ if(TESTS_GEN8)
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_gen8.cpp
${COMPUTE_RUNTIME_ULT_GEN8}
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen8/unit_test_helper_gen8.cpp
)
endif()

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gen8/hw_info.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/unit_test_helper.inl"
namespace NEO {
template struct UnitTestHelper<BDWFamily>;
} // namespace NEO

View File

@@ -22,8 +22,8 @@ if(TESTS_GEN9)
${CMAKE_CURRENT_SOURCE_DIR}/test_command_encoder_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_gen9.cpp
${COMPUTE_RUNTIME_ULT_GEN9}
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen9/unit_test_helper_gen9.cpp
)
endif()

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gen9/hw_info.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/unit_test_helper.inl"
namespace NEO {
using Family = SKLFamily;
template <>
bool UnitTestHelper<Family>::isPipeControlWArequired(const HardwareInfo &hwInfo) {
return true;
}
template struct UnitTestHelper<Family>;
} // namespace NEO

View File

@@ -30,6 +30,8 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.h
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.inl
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper.inl
${CMAKE_CURRENT_SOURCE_DIR}/variable_backup.h
)

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/aux_translation.h"
#include "hw_cmds.h"
namespace NEO {
struct KernelDescriptor;
struct HardwareInfo;
template <typename GfxFamily>
struct UnitTestHelper {
using COHERENCY_TYPE = typename GfxFamily::RENDER_SURFACE_STATE::COHERENCY_TYPE;
static bool isL3ConfigProgrammable();
static bool evaluateDshUsage(size_t sizeBeforeEnqueue, size_t sizeAfterEnqueue, const KernelDescriptor *kernelDescriptor, uint32_t rootDeviceIndex);
static bool isPageTableManagerSupported(const HardwareInfo &hwInfo);
static bool isTimestampPacketWriteSupported();
static bool isExpectMemoryNotEqualSupported();
static uint32_t getDefaultSshUsage();
static uint32_t getAppropriateThreadArbitrationPolicy(uint32_t policy);
static auto getCoherencyTypeSupported(COHERENCY_TYPE coherencyType) -> decltype(coherencyType);
static bool evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress);
static bool isPipeControlWArequired(const HardwareInfo &hwInfo);
static bool isAdditionalSynchronizationRequired();
static bool isAdditionalMiSemaphoreWaitRequired(const HardwareInfo &hwInfo);
static bool isAdditionalMiSemaphoreWait(const typename GfxFamily::MI_SEMAPHORE_WAIT &semaphoreWait);
static uint64_t getMemoryAddress(const typename GfxFamily::MI_ATOMIC &atomic);
static bool requiresTimestampPacketsInSystemMemory();
static const bool tiledImagesSupported;
static const uint32_t smallestTestableSimdSize;
static const AuxTranslationMode requiredAuxTranslationMode;
static const bool useFullRowForLocalIdsGeneration;
static const bool additionalMiFlushDwRequired;
};
} // namespace NEO

View File

@@ -0,0 +1,103 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
namespace NEO {
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isL3ConfigProgrammable() {
return true;
};
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::evaluateDshUsage(size_t sizeBeforeEnqueue, size_t sizeAfterEnqueue, const KernelDescriptor *kernelDescriptor, uint32_t rootDeviceIndex) {
if (sizeBeforeEnqueue != sizeAfterEnqueue) {
return true;
}
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isPageTableManagerSupported(const HardwareInfo &hwInfo) {
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isTimestampPacketWriteSupported() {
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isExpectMemoryNotEqualSupported() {
return false;
}
template <typename GfxFamily>
uint32_t UnitTestHelper<GfxFamily>::getDefaultSshUsage() {
return sizeof(typename GfxFamily::RENDER_SURFACE_STATE);
}
template <typename GfxFamily>
inline uint32_t UnitTestHelper<GfxFamily>::getAppropriateThreadArbitrationPolicy(uint32_t policy) {
return policy;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress) {
return usedScratchGpuAddress == retrievedGshAddress;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isPipeControlWArequired(const HardwareInfo &hwInfo) {
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isAdditionalSynchronizationRequired() {
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isAdditionalMiSemaphoreWaitRequired(const HardwareInfo &hwInfo) {
return false;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isAdditionalMiSemaphoreWait(const typename GfxFamily::MI_SEMAPHORE_WAIT &semaphoreWait) {
return false;
}
template <typename GfxFamily>
inline uint64_t UnitTestHelper<GfxFamily>::getMemoryAddress(const typename GfxFamily::MI_ATOMIC &atomic) {
return atomic.getMemoryAddress() | ((static_cast<uint64_t>(atomic.getMemoryAddressHigh())) << 32);
}
template <typename GfxFamily>
inline bool UnitTestHelper<GfxFamily>::requiresTimestampPacketsInSystemMemory() {
return true;
}
template <typename GfxFamily>
auto UnitTestHelper<GfxFamily>::getCoherencyTypeSupported(COHERENCY_TYPE coherencyType) -> decltype(coherencyType) {
return coherencyType;
}
template <typename GfxFamily>
const bool UnitTestHelper<GfxFamily>::tiledImagesSupported = true;
template <typename GfxFamily>
const uint32_t UnitTestHelper<GfxFamily>::smallestTestableSimdSize = 8;
template <typename GfxFamily>
const AuxTranslationMode UnitTestHelper<GfxFamily>::requiredAuxTranslationMode = AuxTranslationMode::Builtin;
template <typename GfxFamily>
const bool UnitTestHelper<GfxFamily>::useFullRowForLocalIdsGeneration = false;
template <typename GfxFamily>
const bool UnitTestHelper<GfxFamily>::additionalMiFlushDwRequired = false;
} // namespace NEO

View File

@@ -7,8 +7,8 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
#include "test.h"
using namespace NEO;

View File

@@ -12,10 +12,9 @@
#include "shared/test/common/fixtures/command_container_fixture.h"
#include "shared/test/common/fixtures/front_window_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/mocks/mock_device.h"
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
using namespace NEO;
using CommandEncodeStatesTest = Test<CommandEncodeStatesFixture>;