mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Move non-ult shared files to single directory
Add SKIP_SHARED_UNIT_TESTS flag Related-To: NEO-5201 Signed-off-by: Pawel Cieslak <pawel.cieslak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1a0b7dc393
commit
8a700c5187
11
shared/test/common/CMakeLists.txt
Normal file
11
shared/test/common/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
21
shared/test/common/cmd_parse/CMakeLists.txt
Normal file
21
shared/test/common/cmd_parse/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_SHARED_TESTS_CMD_PARSE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_base_mi_arb.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_compute_mode.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_gpgpu_walker.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_mi_arb.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_sip.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gen_cmd_parse.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.inl
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
set_property(GLOBAL PROPERTY NEO_SHARED_TESTS_CMD_PARSE ${NEO_SHARED_TESTS_CMD_PARSE})
|
||||
369
shared/test/common/cmd_parse/cmd_parse_base.inl
Normal file
369
shared/test/common/cmd_parse/cmd_parse_base.inl
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
|
||||
// clang-format off
|
||||
using namespace NEO;
|
||||
using MI_ARB_CHECK = GenStruct::MI_ARB_CHECK;
|
||||
using MI_ATOMIC = GenStruct::MI_ATOMIC;
|
||||
using MI_BATCH_BUFFER_END = GenStruct::MI_BATCH_BUFFER_END;
|
||||
using MI_BATCH_BUFFER_START = GenStruct::MI_BATCH_BUFFER_START;
|
||||
using MI_LOAD_REGISTER_IMM = GenStruct::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_MEM = GenStruct::MI_LOAD_REGISTER_MEM;
|
||||
using MI_STORE_REGISTER_MEM = GenStruct::MI_STORE_REGISTER_MEM;
|
||||
using MI_NOOP = GenStruct::MI_NOOP;
|
||||
using PIPE_CONTROL = GenStruct::PIPE_CONTROL;
|
||||
using PIPELINE_SELECT = GenStruct::PIPELINE_SELECT;
|
||||
using STATE_BASE_ADDRESS = GenStruct::STATE_BASE_ADDRESS;
|
||||
using MI_REPORT_PERF_COUNT = GenStruct::MI_REPORT_PERF_COUNT;
|
||||
using MI_MATH = GenStruct::MI_MATH;
|
||||
using MI_LOAD_REGISTER_REG = GenStruct::MI_LOAD_REGISTER_REG;
|
||||
using MI_SEMAPHORE_WAIT = GenStruct::MI_SEMAPHORE_WAIT;
|
||||
using MI_STORE_DATA_IMM = GenStruct::MI_STORE_DATA_IMM;
|
||||
using MI_FLUSH_DW = GenStruct::MI_FLUSH_DW;
|
||||
using XY_COPY_BLT = GenGfxFamily::XY_COPY_BLT;
|
||||
using XY_COLOR_BLT = GenGfxFamily::XY_COLOR_BLT;
|
||||
// clang-format on
|
||||
|
||||
template <>
|
||||
STATE_BASE_ADDRESS *genCmdCast<STATE_BASE_ADDRESS *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<STATE_BASE_ADDRESS *>(buffer);
|
||||
|
||||
return STATE_BASE_ADDRESS::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
STATE_BASE_ADDRESS::COMMAND_SUBTYPE_GFXPIPE_COMMON == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
STATE_BASE_ADDRESS::_3D_COMMAND_OPCODE_GFXPIPE_NONPIPELINED == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
STATE_BASE_ADDRESS::_3D_COMMAND_SUB_OPCODE_STATE_BASE_ADDRESS == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
PIPE_CONTROL *genCmdCast<PIPE_CONTROL *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<PIPE_CONTROL *>(buffer);
|
||||
|
||||
return PIPE_CONTROL::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
PIPE_CONTROL::COMMAND_SUBTYPE_GFXPIPE_3D == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
PIPE_CONTROL::_3D_COMMAND_OPCODE_PIPE_CONTROL == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
PIPE_CONTROL::_3D_COMMAND_SUB_OPCODE_PIPE_CONTROL == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
PIPELINE_SELECT *genCmdCast<PIPELINE_SELECT *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<PIPELINE_SELECT *>(buffer);
|
||||
|
||||
return PIPELINE_SELECT::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
PIPELINE_SELECT::COMMAND_SUBTYPE_GFXPIPE_SINGLE_DW == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
PIPELINE_SELECT::_3D_COMMAND_OPCODE_GFXPIPE_NONPIPELINED == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
PIPELINE_SELECT::_3D_COMMAND_SUB_OPCODE_PIPELINE_SELECT == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_LOAD_REGISTER_IMM *genCmdCast<MI_LOAD_REGISTER_IMM *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(buffer);
|
||||
|
||||
return MI_LOAD_REGISTER_IMM::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_LOAD_REGISTER_IMM::MI_COMMAND_OPCODE_MI_LOAD_REGISTER_IMM == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_NOOP *genCmdCast<MI_NOOP *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_NOOP *>(buffer);
|
||||
|
||||
return MI_NOOP::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_NOOP::MI_COMMAND_OPCODE_MI_NOOP == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_ATOMIC *genCmdCast<MI_ATOMIC *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_ATOMIC *>(buffer);
|
||||
|
||||
return MI_ATOMIC::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_ATOMIC::MI_COMMAND_OPCODE_MI_ATOMIC == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_BATCH_BUFFER_END *genCmdCast<MI_BATCH_BUFFER_END *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_BATCH_BUFFER_END *>(buffer);
|
||||
|
||||
return MI_BATCH_BUFFER_END::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_BATCH_BUFFER_END::MI_COMMAND_OPCODE_MI_BATCH_BUFFER_END == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_BATCH_BUFFER_START *genCmdCast<MI_BATCH_BUFFER_START *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_BATCH_BUFFER_START *>(buffer);
|
||||
|
||||
return MI_BATCH_BUFFER_START::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_BATCH_BUFFER_START::MI_COMMAND_OPCODE_MI_BATCH_BUFFER_START == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_LOAD_REGISTER_MEM *genCmdCast<MI_LOAD_REGISTER_MEM *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_LOAD_REGISTER_MEM *>(buffer);
|
||||
|
||||
return MI_LOAD_REGISTER_MEM::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_LOAD_REGISTER_MEM::MI_COMMAND_OPCODE_MI_LOAD_REGISTER_MEM == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_STORE_REGISTER_MEM *genCmdCast<MI_STORE_REGISTER_MEM *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_STORE_REGISTER_MEM *>(buffer);
|
||||
|
||||
return MI_STORE_REGISTER_MEM::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_STORE_REGISTER_MEM::MI_COMMAND_OPCODE_MI_STORE_REGISTER_MEM == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_REPORT_PERF_COUNT *genCmdCast<MI_REPORT_PERF_COUNT *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_REPORT_PERF_COUNT *>(buffer);
|
||||
|
||||
return MI_REPORT_PERF_COUNT::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_REPORT_PERF_COUNT::MI_COMMAND_OPCODE_MI_REPORT_PERF_COUNT == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_MATH *genCmdCast<MI_MATH *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_MATH *>(buffer);
|
||||
|
||||
return MI_MATH::COMMAND_TYPE_MI_COMMAND == pCmd->DW0.BitField.InstructionType &&
|
||||
MI_MATH::MI_COMMAND_OPCODE_MI_MATH == pCmd->DW0.BitField.InstructionOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_LOAD_REGISTER_REG *genCmdCast<MI_LOAD_REGISTER_REG *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_LOAD_REGISTER_REG *>(buffer);
|
||||
|
||||
return MI_LOAD_REGISTER_REG::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_LOAD_REGISTER_REG::MI_COMMAND_OPCODE_MI_LOAD_REGISTER_REG == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_SEMAPHORE_WAIT *genCmdCast<MI_SEMAPHORE_WAIT *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_SEMAPHORE_WAIT *>(buffer);
|
||||
|
||||
return MI_SEMAPHORE_WAIT::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_SEMAPHORE_WAIT::MI_COMMAND_OPCODE_MI_SEMAPHORE_WAIT == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_STORE_DATA_IMM *genCmdCast<MI_STORE_DATA_IMM *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_STORE_DATA_IMM *>(buffer);
|
||||
|
||||
return MI_STORE_DATA_IMM::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_STORE_DATA_IMM::MI_COMMAND_OPCODE_MI_STORE_DATA_IMM == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MI_FLUSH_DW *genCmdCast<MI_FLUSH_DW *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_FLUSH_DW *>(buffer);
|
||||
|
||||
return MI_FLUSH_DW::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_FLUSH_DW::MI_COMMAND_OPCODE_MI_FLUSH_DW == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
XY_COPY_BLT *genCmdCast<XY_COPY_BLT *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<XY_COPY_BLT *>(buffer);
|
||||
|
||||
return XY_COPY_BLT::INSTRUCTIONTARGET_OPCODE_OPCODE == pCmd->TheStructure.Common.InstructionTarget_Opcode &&
|
||||
XY_COPY_BLT::CLIENT_2D_PROCESSOR == pCmd->TheStructure.Common.Client
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
XY_COLOR_BLT *genCmdCast<XY_COLOR_BLT *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<XY_COLOR_BLT *>(buffer);
|
||||
|
||||
return XY_COLOR_BLT::INSTRUCTIONTARGET_OPCODE_OPCODE == pCmd->TheStructure.Common.InstructionTarget_Opcode &&
|
||||
XY_COLOR_BLT::CLIENT_2D_PROCESSOR == pCmd->TheStructure.Common.Client
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t CmdParse<T>::getCommandLength(void *cmd) {
|
||||
{
|
||||
auto pCmd = genCmdCast<STATE_BASE_ADDRESS *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<PIPE_CONTROL *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_ARB_CHECK *>(cmd);
|
||||
if (pCmd)
|
||||
return SIZE32(*pCmd);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_ATOMIC *>(cmd);
|
||||
if (pCmd)
|
||||
return sizeof(MI_ATOMIC) / sizeof(uint32_t);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_BATCH_BUFFER_END *>(cmd);
|
||||
if (pCmd)
|
||||
return SIZE32(*pCmd);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_BATCH_BUFFER_START *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_LOAD_REGISTER_MEM *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_STORE_REGISTER_MEM *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_NOOP *>(cmd);
|
||||
if (pCmd)
|
||||
return SIZE32(*pCmd);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<PIPELINE_SELECT *>(cmd);
|
||||
if (pCmd)
|
||||
return SIZE32(*pCmd);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_REPORT_PERF_COUNT *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_MATH *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->DW0.BitField.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_LOAD_REGISTER_REG *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_SEMAPHORE_WAIT *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_STORE_DATA_IMM *>(cmd);
|
||||
if (pCmd)
|
||||
return SIZE32(*pCmd);
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MI_FLUSH_DW *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<XY_COPY_BLT *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<XY_COLOR_BLT *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
|
||||
auto commandLengthHwSpecific = getCommandLengthHwSpecific(cmd);
|
||||
|
||||
if (commandLengthHwSpecific != 0) {
|
||||
return commandLengthHwSpecific;
|
||||
}
|
||||
return getAdditionalCommandLength(cmd);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const char *CmdParse<T>::getCommandName(void *cmd) {
|
||||
#define RETURN_NAME_IF(CMD_NAME) \
|
||||
if (nullptr != genCmdCast<CMD_NAME *>(cmd)) \
|
||||
return #CMD_NAME;
|
||||
|
||||
RETURN_NAME_IF(STATE_BASE_ADDRESS);
|
||||
RETURN_NAME_IF(PIPE_CONTROL);
|
||||
RETURN_NAME_IF(MI_ARB_CHECK);
|
||||
RETURN_NAME_IF(MI_ATOMIC);
|
||||
RETURN_NAME_IF(MI_BATCH_BUFFER_END);
|
||||
RETURN_NAME_IF(MI_BATCH_BUFFER_START);
|
||||
RETURN_NAME_IF(MI_LOAD_REGISTER_IMM);
|
||||
RETURN_NAME_IF(MI_LOAD_REGISTER_MEM);
|
||||
RETURN_NAME_IF(MI_STORE_REGISTER_MEM);
|
||||
RETURN_NAME_IF(MI_NOOP);
|
||||
RETURN_NAME_IF(PIPELINE_SELECT);
|
||||
RETURN_NAME_IF(MI_REPORT_PERF_COUNT);
|
||||
RETURN_NAME_IF(MI_MATH);
|
||||
RETURN_NAME_IF(MI_LOAD_REGISTER_REG);
|
||||
RETURN_NAME_IF(MI_SEMAPHORE_WAIT);
|
||||
RETURN_NAME_IF(MI_STORE_DATA_IMM);
|
||||
RETURN_NAME_IF(MI_FLUSH_DW);
|
||||
RETURN_NAME_IF(XY_COPY_BLT);
|
||||
RETURN_NAME_IF(XY_COLOR_BLT);
|
||||
|
||||
#undef RETURN_NAME_IF
|
||||
|
||||
auto commandNameHwSpecific = getCommandNameHwSpecific(cmd);
|
||||
if (strcmp(commandNameHwSpecific, "UNKNOWN") != 0) {
|
||||
return commandNameHwSpecific;
|
||||
}
|
||||
|
||||
return getAdditionalCommandName(cmd);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t CmdParse<T>::getAdditionalCommandLength(void *cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const char *CmdParse<T>::getAdditionalCommandName(void *cmd) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
16
shared/test/common/cmd_parse/cmd_parse_base_mi_arb.inl
Normal file
16
shared/test/common/cmd_parse/cmd_parse_base_mi_arb.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
template <>
|
||||
MI_ARB_CHECK *genCmdCast<MI_ARB_CHECK *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_ARB_CHECK *>(buffer);
|
||||
|
||||
return MI_ARB_CHECK::MI_INSTRUCTION_TYPE_MI_INSTRUCTION == pCmd->TheStructure.Common.MiInstructionType &&
|
||||
MI_ARB_CHECK::MI_INSTRUCTION_OPCODE_MI_ARB_CHECK == pCmd->TheStructure.Common.MiInstructionOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
23
shared/test/common/cmd_parse/cmd_parse_compute_mode.inl
Normal file
23
shared/test/common/cmd_parse/cmd_parse_compute_mode.inl
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
using namespace NEO;
|
||||
using STATE_COMPUTE_MODE = GenStruct::STATE_COMPUTE_MODE;
|
||||
// clang-format on
|
||||
|
||||
template <>
|
||||
STATE_COMPUTE_MODE *genCmdCast<STATE_COMPUTE_MODE *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<STATE_COMPUTE_MODE *>(buffer);
|
||||
|
||||
return STATE_COMPUTE_MODE::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
STATE_COMPUTE_MODE::COMMAND_SUBTYPE_GFXPIPE_COMMON == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
STATE_COMPUTE_MODE::_3D_COMMAND_OPCODE_GFXPIPE_NONPIPELINED == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
STATE_COMPUTE_MODE::_3D_COMMAND_SUB_OPCODE_STATE_COMPUTE_MODE == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
162
shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl
Normal file
162
shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
using namespace NEO;
|
||||
using GPGPU_WALKER = GenStruct::GPGPU_WALKER;
|
||||
using MEDIA_INTERFACE_DESCRIPTOR_LOAD = GenStruct::MEDIA_INTERFACE_DESCRIPTOR_LOAD;
|
||||
using MEDIA_STATE_FLUSH = GenStruct::MEDIA_STATE_FLUSH;
|
||||
using MEDIA_VFE_STATE = GenStruct::MEDIA_VFE_STATE;
|
||||
// clang-format on
|
||||
|
||||
template <>
|
||||
GPGPU_WALKER *genCmdCast<GPGPU_WALKER *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<GPGPU_WALKER *>(buffer);
|
||||
|
||||
return GPGPU_WALKER::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
GPGPU_WALKER::PIPELINE_MEDIA == pCmd->TheStructure.Common.Pipeline &&
|
||||
GPGPU_WALKER::MEDIA_COMMAND_OPCODE_GPGPU_WALKER == pCmd->TheStructure.Common.MediaCommandOpcode &&
|
||||
GPGPU_WALKER::SUBOPCODE_GPGPU_WALKER_SUBOP == pCmd->TheStructure.Common.Subopcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MEDIA_INTERFACE_DESCRIPTOR_LOAD *genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(buffer);
|
||||
|
||||
return MEDIA_INTERFACE_DESCRIPTOR_LOAD::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
MEDIA_INTERFACE_DESCRIPTOR_LOAD::PIPELINE_MEDIA == pCmd->TheStructure.Common.Pipeline &&
|
||||
MEDIA_INTERFACE_DESCRIPTOR_LOAD::MEDIA_COMMAND_OPCODE_MEDIA_INTERFACE_DESCRIPTOR_LOAD == pCmd->TheStructure.Common.MediaCommandOpcode &&
|
||||
MEDIA_INTERFACE_DESCRIPTOR_LOAD::SUBOPCODE_MEDIA_INTERFACE_DESCRIPTOR_LOAD_SUBOP == pCmd->TheStructure.Common.Subopcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MEDIA_VFE_STATE *genCmdCast<MEDIA_VFE_STATE *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MEDIA_VFE_STATE *>(buffer);
|
||||
|
||||
return MEDIA_VFE_STATE::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
MEDIA_VFE_STATE::PIPELINE_MEDIA == pCmd->TheStructure.Common.Pipeline &&
|
||||
MEDIA_VFE_STATE::MEDIA_COMMAND_OPCODE_MEDIA_VFE_STATE == pCmd->TheStructure.Common.MediaCommandOpcode &&
|
||||
MEDIA_VFE_STATE::SUBOPCODE_MEDIA_VFE_STATE_SUBOP == pCmd->TheStructure.Common.Subopcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
MEDIA_STATE_FLUSH *genCmdCast<MEDIA_STATE_FLUSH *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MEDIA_STATE_FLUSH *>(buffer);
|
||||
|
||||
return MEDIA_STATE_FLUSH::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
MEDIA_STATE_FLUSH::PIPELINE_MEDIA == pCmd->TheStructure.Common.Pipeline &&
|
||||
MEDIA_STATE_FLUSH::MEDIA_COMMAND_OPCODE_MEDIA_STATE_FLUSH == pCmd->TheStructure.Common.MediaCommandOpcode &&
|
||||
MEDIA_STATE_FLUSH::SUBOPCODE_MEDIA_STATE_FLUSH_SUBOP == pCmd->TheStructure.Common.Subopcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool CmdParse<T>::parseCommandBuffer(GenCmdList &cmds, void *buffer, size_t length) {
|
||||
if (!buffer || length % sizeof(uint32_t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void *bufferEnd = reinterpret_cast<uint8_t *>(buffer) + length;
|
||||
while (buffer < bufferEnd) {
|
||||
size_t length = getCommandLength(buffer);
|
||||
if (!length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cmds.push_back(buffer);
|
||||
|
||||
buffer = reinterpret_cast<uint32_t *>(buffer) + length;
|
||||
}
|
||||
|
||||
return buffer == bufferEnd;
|
||||
}
|
||||
|
||||
// MIDL should have a MSF between it and a previous walker
|
||||
template <>
|
||||
template <>
|
||||
void CmdParse<GenGfxFamily>::validateCommand<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(GenCmdList::iterator itorBegin, GenCmdList::iterator itorEnd) {
|
||||
auto itorCurrent = itorBegin;
|
||||
auto itorWalker = itorEnd;
|
||||
|
||||
// Find last GPGPU_WALKER prior to itorCmd
|
||||
while (itorCurrent != itorEnd) {
|
||||
if (genCmdCast<GPGPU_WALKER *>(*itorCurrent)) {
|
||||
itorWalker = itorCurrent;
|
||||
}
|
||||
|
||||
++itorCurrent;
|
||||
}
|
||||
|
||||
// If we don't find a GPGPU_WALKER, assume the beginning of a cmd list
|
||||
itorWalker = itorWalker == itorEnd
|
||||
? itorBegin
|
||||
: itorWalker;
|
||||
|
||||
// Look for MEDIA_STATE_FLUSH between last GPGPU_WALKER and MIDL.
|
||||
auto itorMSF = itorEnd;
|
||||
|
||||
itorCurrent = itorWalker;
|
||||
++itorCurrent;
|
||||
while (itorCurrent != itorEnd) {
|
||||
if (genCmdCast<MEDIA_STATE_FLUSH *>(*itorCurrent)) {
|
||||
itorMSF = itorCurrent;
|
||||
break;
|
||||
}
|
||||
++itorCurrent;
|
||||
}
|
||||
|
||||
ASSERT_FALSE(itorMSF == itorEnd) << "A MEDIA_STATE_FLUSH is required before a MEDIA_INTERFACE_DESCRIPTOR_LOAD.";
|
||||
}
|
||||
|
||||
template <>
|
||||
template <>
|
||||
void CmdParse<GenGfxFamily>::validateCommand<STATE_BASE_ADDRESS *>(GenCmdList::iterator itorBegin, GenCmdList::iterator itorEnd) {
|
||||
}
|
||||
|
||||
// MVFES should have a stalling PC between it and a previous walker
|
||||
template <>
|
||||
template <>
|
||||
void CmdParse<GenGfxFamily>::validateCommand<MEDIA_VFE_STATE *>(GenCmdList::iterator itorBegin, GenCmdList::iterator itorEnd) {
|
||||
auto itorCurrent = itorBegin;
|
||||
auto itorWalker = itorEnd;
|
||||
|
||||
// Find last GPGPU_WALKER prior to itorCmd
|
||||
while (itorCurrent != itorEnd) {
|
||||
if (genCmdCast<GPGPU_WALKER *>(*itorCurrent)) {
|
||||
itorWalker = itorCurrent;
|
||||
}
|
||||
|
||||
++itorCurrent;
|
||||
}
|
||||
|
||||
// If we don't find a GPGPU_WALKER, assume the beginning of a cmd list
|
||||
itorWalker = itorWalker == itorEnd
|
||||
? itorBegin
|
||||
: itorWalker;
|
||||
|
||||
// Look for PIPE_CONTROL between last GPGPU_WALKER and MVFES.
|
||||
itorCurrent = itorWalker;
|
||||
++itorCurrent;
|
||||
while (itorCurrent != itorEnd) {
|
||||
if (genCmdCast<PIPE_CONTROL *>(*itorCurrent)) {
|
||||
auto pPC = genCmdCast<PIPE_CONTROL *>(*itorCurrent);
|
||||
if (pPC->getCommandStreamerStallEnable()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
++itorCurrent;
|
||||
}
|
||||
|
||||
ASSERT_TRUE(false) << "A PIPE_CONTROL w/ CS stall is required before a MEDIA_VFE_STATE.";
|
||||
}
|
||||
16
shared/test/common/cmd_parse/cmd_parse_mi_arb.inl
Normal file
16
shared/test/common/cmd_parse/cmd_parse_mi_arb.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
template <>
|
||||
MI_ARB_CHECK *genCmdCast<MI_ARB_CHECK *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<MI_ARB_CHECK *>(buffer);
|
||||
|
||||
return MI_ARB_CHECK::COMMAND_TYPE_MI_COMMAND == pCmd->TheStructure.Common.CommandType &&
|
||||
MI_ARB_CHECK::MI_COMMAND_OPCODE_MI_ARB_CHECK == pCmd->TheStructure.Common.MiCommandOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
36
shared/test/common/cmd_parse/cmd_parse_sip.inl
Normal file
36
shared/test/common/cmd_parse/cmd_parse_sip.inl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
using namespace NEO;
|
||||
using GPGPU_CSR_BASE_ADDRESS = GenStruct::GPGPU_CSR_BASE_ADDRESS;
|
||||
using STATE_SIP = GenStruct::STATE_SIP;
|
||||
// clang-format on
|
||||
|
||||
template <>
|
||||
GPGPU_CSR_BASE_ADDRESS *genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<GPGPU_CSR_BASE_ADDRESS *>(buffer);
|
||||
|
||||
return GPGPU_CSR_BASE_ADDRESS::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
GPGPU_CSR_BASE_ADDRESS::COMMAND_SUBTYPE_GFXPIPE_COMMON == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
GPGPU_CSR_BASE_ADDRESS::_3D_COMMAND_OPCODE_GFXPIPE_NONPIPELINED == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
GPGPU_CSR_BASE_ADDRESS::_3D_COMMAND_SUB_OPCODE_GPGPU_CSR_BASE_ADDRESS == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
STATE_SIP *genCmdCast<STATE_SIP *>(void *buffer) {
|
||||
auto pCmd = reinterpret_cast<STATE_SIP *>(buffer);
|
||||
|
||||
return STATE_SIP::COMMAND_TYPE_GFXPIPE == pCmd->TheStructure.Common.CommandType &&
|
||||
STATE_SIP::COMMAND_SUBTYPE_GFXPIPE_COMMON == pCmd->TheStructure.Common.CommandSubtype &&
|
||||
STATE_SIP::_3D_COMMAND_OPCODE_GFXPIPE_NONPIPELINED == pCmd->TheStructure.Common._3DCommandOpcode &&
|
||||
STATE_SIP::_3D_COMMAND_SUB_OPCODE_STATE_SIP == pCmd->TheStructure.Common._3DCommandSubOpcode
|
||||
? pCmd
|
||||
: nullptr;
|
||||
}
|
||||
103
shared/test/common/cmd_parse/gen_cmd_parse.h
Normal file
103
shared/test/common/cmd_parse/gen_cmd_parse.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "hw_cmds.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
typedef std::list<void *> GenCmdList;
|
||||
|
||||
template <typename Type>
|
||||
Type genCmdCast(void *cmd);
|
||||
|
||||
template <typename Type>
|
||||
static inline GenCmdList::iterator find(GenCmdList::iterator itorStart, GenCmdList::const_iterator itorEnd) {
|
||||
GenCmdList::iterator itor = itorStart;
|
||||
while (itor != itorEnd) {
|
||||
if (genCmdCast<Type>(*itor))
|
||||
break;
|
||||
++itor;
|
||||
}
|
||||
return itor;
|
||||
}
|
||||
|
||||
template <typename CommandToFind>
|
||||
static inline std::vector<GenCmdList::iterator> findAll(GenCmdList::iterator commandListStart, GenCmdList::const_iterator commandListEnd) {
|
||||
std::vector<GenCmdList::iterator> matchedCommands;
|
||||
GenCmdList::iterator currentCommand = commandListStart;
|
||||
while (currentCommand != commandListEnd) {
|
||||
if (genCmdCast<CommandToFind>(*currentCommand)) {
|
||||
matchedCommands.push_back(currentCommand);
|
||||
}
|
||||
++currentCommand;
|
||||
}
|
||||
return matchedCommands;
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
static inline GenCmdList::iterator findMmio(GenCmdList::iterator itorStart, GenCmdList::const_iterator itorEnd, uint32_t regOffset) {
|
||||
GenCmdList::iterator itor = itorStart;
|
||||
while (itor != itorEnd) {
|
||||
auto cmd = genCmdCast<typename FamilyType::MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
if (cmd && cmd->getRegisterOffset() == regOffset)
|
||||
break;
|
||||
++itor;
|
||||
}
|
||||
return itor;
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
static inline size_t countMmio(GenCmdList::iterator itorStart, GenCmdList::const_iterator itorEnd, uint32_t regOffset) {
|
||||
size_t count = 0;
|
||||
GenCmdList::iterator itor = itorStart;
|
||||
while (itor != itorEnd) {
|
||||
auto cmd = genCmdCast<typename FamilyType::MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
if (cmd && cmd->getRegisterOffset() == regOffset) {
|
||||
++count;
|
||||
}
|
||||
++itor;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
static inline typename FamilyType::MI_LOAD_REGISTER_IMM *findMmioCmd(GenCmdList::iterator itorStart, GenCmdList::const_iterator itorEnd, uint32_t regOffset) {
|
||||
auto itor = findMmio<FamilyType>(itorStart, itorEnd, regOffset);
|
||||
if (itor == itorEnd) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<typename FamilyType::MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
static inline GenCmdList::reverse_iterator reverse_find(GenCmdList::reverse_iterator itorStart, GenCmdList::const_reverse_iterator itorEnd) {
|
||||
GenCmdList::reverse_iterator itor = itorStart;
|
||||
while (itor != itorEnd) {
|
||||
if (genCmdCast<Type>(*itor))
|
||||
break;
|
||||
++itor;
|
||||
}
|
||||
return itor;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct CmdParse : public T {
|
||||
static size_t getCommandLength(void *cmd);
|
||||
static size_t getCommandLengthHwSpecific(void *cmd);
|
||||
static size_t getAdditionalCommandLength(void *cmd);
|
||||
|
||||
static bool parseCommandBuffer(GenCmdList &cmds, void *buffer, size_t length);
|
||||
|
||||
template <typename CmdType>
|
||||
static void validateCommand(GenCmdList::iterator itorBegin, GenCmdList::iterator itorEnd);
|
||||
|
||||
static const char *getCommandName(void *cmd);
|
||||
static const char *getCommandNameHwSpecific(void *cmd);
|
||||
static const char *getAdditionalCommandName(void *cmd);
|
||||
};
|
||||
231
shared/test/common/cmd_parse/hw_parse.h
Normal file
231
shared/test/common/cmd_parse/hw_parse.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/helpers/pipeline_select_helper.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
#include "opencl/source/kernel/kernel.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct HardwareParse {
|
||||
HardwareParse() {
|
||||
itorMediaInterfaceDescriptorLoad = cmdList.end();
|
||||
itorMediaVfeState = cmdList.end();
|
||||
itorPipelineSelect = cmdList.end();
|
||||
itorStateBaseAddress = cmdList.end();
|
||||
itorWalker = cmdList.end();
|
||||
itorGpgpuCsrBaseAddress = cmdList.end();
|
||||
}
|
||||
|
||||
void SetUp() {
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
cmdList.clear();
|
||||
lriList.clear();
|
||||
pipeControlList.clear();
|
||||
}
|
||||
|
||||
template <typename CmdType>
|
||||
GenCmdList getCommandsList() {
|
||||
GenCmdList list;
|
||||
for (auto it = cmdList.begin(); it != cmdList.end(); it++) {
|
||||
auto cmd = genCmdCast<CmdType *>(*it);
|
||||
if (cmd) {
|
||||
list.push_back(*it);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
void findCsrBaseAddress();
|
||||
|
||||
template <typename FamilyType>
|
||||
void findHardwareCommands();
|
||||
|
||||
template <typename FamilyType>
|
||||
void findHardwareCommands(IndirectHeap *dsh);
|
||||
|
||||
template <typename FamilyType>
|
||||
void parseCommands(NEO::LinearStream &commandStream, size_t startOffset = 0) {
|
||||
ASSERT_LE(startOffset, commandStream.getUsed());
|
||||
auto sizeToParse = commandStream.getUsed() - startOffset;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList,
|
||||
ptrOffset(commandStream.getCpuBase(), startOffset),
|
||||
sizeToParse));
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
void parseCommands(NEO::CommandQueue &commandQueue) {
|
||||
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
|
||||
auto &commandStreamCSR = commandStreamReceiver.getCS();
|
||||
|
||||
parseCommands<FamilyType>(commandStreamCSR, startCSRCS);
|
||||
startCSRCS = commandStreamCSR.getUsed();
|
||||
|
||||
auto &commandStream = commandQueue.getCS(1024);
|
||||
if (previousCS != &commandStream) {
|
||||
startCS = 0;
|
||||
}
|
||||
parseCommands<FamilyType>(commandStream, startCS);
|
||||
startCS = commandStream.getUsed();
|
||||
previousCS = &commandStream;
|
||||
|
||||
sizeUsed = commandStream.getUsed();
|
||||
findHardwareCommands<FamilyType>(&commandStreamReceiver.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 0));
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
const typename FamilyType::RENDER_SURFACE_STATE &getSurfaceState(IndirectHeap *ssh, uint32_t index) {
|
||||
typedef typename FamilyType::BINDING_TABLE_STATE BINDING_TABLE_STATE;
|
||||
typedef typename FamilyType::INTERFACE_DESCRIPTOR_DATA INTERFACE_DESCRIPTOR_DATA;
|
||||
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
|
||||
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
|
||||
const auto &interfaceDescriptorData = *(INTERFACE_DESCRIPTOR_DATA *)cmdInterfaceDescriptorData;
|
||||
|
||||
auto cmdSBA = (STATE_BASE_ADDRESS *)cmdStateBaseAddress;
|
||||
auto surfaceStateHeap = cmdSBA->getSurfaceStateBaseAddress();
|
||||
if (ssh && (ssh->getHeapGpuBase() == surfaceStateHeap)) {
|
||||
surfaceStateHeap = reinterpret_cast<uint64_t>(ssh->getCpuBase());
|
||||
}
|
||||
EXPECT_NE(0u, surfaceStateHeap);
|
||||
|
||||
auto bindingTablePointer = interfaceDescriptorData.getBindingTablePointer();
|
||||
|
||||
const auto &bindingTableState = reinterpret_cast<BINDING_TABLE_STATE *>(surfaceStateHeap + bindingTablePointer)[index];
|
||||
auto surfaceStatePointer = bindingTableState.getSurfaceStatePointer();
|
||||
|
||||
return *(RENDER_SURFACE_STATE *)(surfaceStateHeap + surfaceStatePointer);
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
const typename FamilyType::SAMPLER_STATE &getSamplerState(uint32_t index) {
|
||||
typedef typename FamilyType::INTERFACE_DESCRIPTOR_DATA INTERFACE_DESCRIPTOR_DATA;
|
||||
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
||||
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
|
||||
const auto &interfaceDescriptorData = *(INTERFACE_DESCRIPTOR_DATA *)cmdInterfaceDescriptorData;
|
||||
|
||||
auto cmdSBA = (STATE_BASE_ADDRESS *)cmdStateBaseAddress;
|
||||
auto dynamicStateHeap = cmdSBA->getDynamicStateBaseAddress();
|
||||
EXPECT_NE(0, dynamicStateHeap);
|
||||
|
||||
const auto samplerState = reinterpret_cast<SAMPLER_STATE *>(dynamicStateHeap + interfaceDescriptorData.getSamplerStatePointer());
|
||||
return samplerState[index];
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
const void *getStatelessArgumentPointer(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex);
|
||||
|
||||
template <typename CmdType>
|
||||
CmdType *getCommand(GenCmdList::iterator itorStart, GenCmdList::iterator itorEnd) {
|
||||
auto itorCmd = find<CmdType *>(itorStart, itorEnd);
|
||||
return itorCmd != cmdList.end()
|
||||
? genCmdCast<CmdType *>(*itorCmd)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
template <typename CmdType>
|
||||
CmdType *getCommand() {
|
||||
return getCommand<CmdType>(cmdList.begin(), cmdList.end());
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
int getNumberOfPipelineSelectsThatEnablePipelineSelect() {
|
||||
typedef typename FamilyType::PIPELINE_SELECT PIPELINE_SELECT;
|
||||
int numberOfGpgpuSelects = 0;
|
||||
int numberOf3dSelects = 0;
|
||||
auto itorCmd = find<PIPELINE_SELECT *>(cmdList.begin(), cmdList.end());
|
||||
while (itorCmd != cmdList.end()) {
|
||||
auto cmd = getCommand<PIPELINE_SELECT>(itorCmd, cmdList.end());
|
||||
if (cmd->getPipelineSelection() == PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU &&
|
||||
pipelineSelectEnablePipelineSelectMaskBits == (pipelineSelectEnablePipelineSelectMaskBits & cmd->getMaskBits())) {
|
||||
numberOfGpgpuSelects++;
|
||||
}
|
||||
if (cmd->getPipelineSelection() == PIPELINE_SELECT::PIPELINE_SELECTION_3D &&
|
||||
pipelineSelectEnablePipelineSelectMaskBits == (pipelineSelectEnablePipelineSelectMaskBits & cmd->getMaskBits())) {
|
||||
numberOf3dSelects++;
|
||||
}
|
||||
itorCmd = find<PIPELINE_SELECT *>(++itorCmd, cmdList.end());
|
||||
}
|
||||
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
|
||||
if (hwHelper.is3DPipelineSelectWARequired(*defaultHwInfo)) {
|
||||
auto maximalNumberOf3dSelectsRequired = 2;
|
||||
EXPECT_LE(numberOf3dSelects, maximalNumberOf3dSelectsRequired);
|
||||
EXPECT_EQ(numberOf3dSelects, numberOfGpgpuSelects);
|
||||
auto numberOfGpgpuSelectsAddedByWa = numberOf3dSelects - 1;
|
||||
numberOfGpgpuSelects -= numberOfGpgpuSelectsAddedByWa;
|
||||
} else {
|
||||
EXPECT_EQ(0, numberOf3dSelects);
|
||||
}
|
||||
return numberOfGpgpuSelects;
|
||||
}
|
||||
|
||||
template <typename CmdType>
|
||||
uint32_t getCommandCount() {
|
||||
GenCmdList::iterator cmdItor = cmdList.begin();
|
||||
uint32_t cmdCount = 0;
|
||||
|
||||
do {
|
||||
cmdItor = find<CmdType *>(cmdItor, cmdList.end());
|
||||
if (cmdItor != cmdList.end()) {
|
||||
++cmdCount;
|
||||
++cmdItor;
|
||||
}
|
||||
} while (cmdItor != cmdList.end());
|
||||
|
||||
return cmdCount;
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
static const char *getCommandName(void *cmd) {
|
||||
return FamilyType::PARSE::getCommandName(cmd);
|
||||
}
|
||||
|
||||
// The starting point of parsing commandBuffers. This is important
|
||||
// because as buffers get reused, we only want to parse the deltas.
|
||||
LinearStream *previousCS = nullptr;
|
||||
size_t startCS = 0u;
|
||||
size_t startCSRCS = 0u;
|
||||
|
||||
size_t sizeUsed = 0u;
|
||||
GenCmdList cmdList;
|
||||
GenCmdList lriList;
|
||||
GenCmdList pipeControlList;
|
||||
GenCmdList::iterator itorMediaInterfaceDescriptorLoad;
|
||||
GenCmdList::iterator itorMediaVfeState;
|
||||
GenCmdList::iterator itorPipelineSelect;
|
||||
GenCmdList::iterator itorStateBaseAddress;
|
||||
GenCmdList::iterator itorWalker;
|
||||
GenCmdList::iterator itorBBStartAfterWalker;
|
||||
GenCmdList::iterator itorGpgpuCsrBaseAddress;
|
||||
|
||||
void *cmdInterfaceDescriptorData = nullptr;
|
||||
void *cmdMediaInterfaceDescriptorLoad = nullptr;
|
||||
void *cmdMediaVfeState = nullptr;
|
||||
void *cmdPipelineSelect = nullptr;
|
||||
void *cmdStateBaseAddress = nullptr;
|
||||
void *cmdWalker = nullptr;
|
||||
void *cmdBBStartAfterWalker = nullptr;
|
||||
void *cmdGpgpuCsrBaseAddress = nullptr;
|
||||
|
||||
bool parsePipeControl = false;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
127
shared/test/common/cmd_parse/hw_parse.inl
Normal file
127
shared/test/common/cmd_parse/hw_parse.inl
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename FamilyType>
|
||||
void HardwareParse::findHardwareCommands(IndirectHeap *dsh) {
|
||||
using GPGPU_WALKER = typename FamilyType::GPGPU_WALKER;
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
using MEDIA_INTERFACE_DESCRIPTOR_LOAD = typename FamilyType::MEDIA_INTERFACE_DESCRIPTOR_LOAD;
|
||||
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
|
||||
itorWalker = find<GPGPU_WALKER *>(cmdList.begin(), cmdList.end());
|
||||
if (itorWalker != cmdList.end()) {
|
||||
cmdWalker = *itorWalker;
|
||||
}
|
||||
|
||||
itorBBStartAfterWalker = find<MI_BATCH_BUFFER_START *>(itorWalker, cmdList.end());
|
||||
if (itorBBStartAfterWalker != cmdList.end()) {
|
||||
cmdBBStartAfterWalker = *itorBBStartAfterWalker;
|
||||
}
|
||||
for (auto it = cmdList.begin(); it != cmdList.end(); it++) {
|
||||
auto lri = genCmdCast<MI_LOAD_REGISTER_IMM *>(*it);
|
||||
if (lri) {
|
||||
lriList.push_back(*it);
|
||||
}
|
||||
}
|
||||
if (parsePipeControl) {
|
||||
for (auto it = cmdList.begin(); it != cmdList.end(); it++) {
|
||||
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*it);
|
||||
if (pipeControl) {
|
||||
pipeControlList.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MEDIA_INTERFACE_DESCRIPTOR_LOAD *cmdMIDL = nullptr;
|
||||
itorMediaInterfaceDescriptorLoad = find<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmdList.begin(), itorWalker);
|
||||
if (itorMediaInterfaceDescriptorLoad != itorWalker) {
|
||||
cmdMIDL = (MEDIA_INTERFACE_DESCRIPTOR_LOAD *)*itorMediaInterfaceDescriptorLoad;
|
||||
cmdMediaInterfaceDescriptorLoad = *itorMediaInterfaceDescriptorLoad;
|
||||
}
|
||||
|
||||
itorPipelineSelect = find<PIPELINE_SELECT *>(cmdList.begin(), itorWalker);
|
||||
if (itorPipelineSelect != itorWalker) {
|
||||
cmdPipelineSelect = *itorPipelineSelect;
|
||||
}
|
||||
|
||||
itorMediaVfeState = find<MEDIA_VFE_STATE *>(itorPipelineSelect, itorWalker);
|
||||
if (itorMediaVfeState != itorWalker) {
|
||||
cmdMediaVfeState = *itorMediaVfeState;
|
||||
}
|
||||
|
||||
STATE_BASE_ADDRESS *cmdSBA = nullptr;
|
||||
uint64_t dynamicStateHeap = 0;
|
||||
itorStateBaseAddress = find<STATE_BASE_ADDRESS *>(cmdList.begin(), itorWalker);
|
||||
if (itorStateBaseAddress != itorWalker) {
|
||||
cmdSBA = (STATE_BASE_ADDRESS *)*itorStateBaseAddress;
|
||||
cmdStateBaseAddress = *itorStateBaseAddress;
|
||||
|
||||
// Extract the dynamicStateHeap
|
||||
dynamicStateHeap = cmdSBA->getDynamicStateBaseAddress();
|
||||
if (dsh && (dsh->getHeapGpuBase() == dynamicStateHeap)) {
|
||||
dynamicStateHeap = reinterpret_cast<uint64_t>(dsh->getCpuBase());
|
||||
}
|
||||
ASSERT_NE(0u, dynamicStateHeap);
|
||||
}
|
||||
|
||||
// interfaceDescriptorData should be located within dynamicStateHeap
|
||||
if (cmdMIDL && cmdSBA) {
|
||||
auto iddStart = cmdMIDL->getInterfaceDescriptorDataStartAddress();
|
||||
auto iddEnd = iddStart + cmdMIDL->getInterfaceDescriptorTotalLength();
|
||||
ASSERT_LE(iddEnd, cmdSBA->getDynamicStateBufferSize() * MemoryConstants::pageSize);
|
||||
|
||||
// Extract the interfaceDescriptorData
|
||||
cmdInterfaceDescriptorData = (INTERFACE_DESCRIPTOR_DATA *)(dynamicStateHeap + iddStart);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
void HardwareParse::findHardwareCommands() {
|
||||
findHardwareCommands<FamilyType>(nullptr);
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
const void *HardwareParse::getStatelessArgumentPointer(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex) {
|
||||
typedef typename FamilyType::GPGPU_WALKER GPGPU_WALKER;
|
||||
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
|
||||
auto cmdWalker = (GPGPU_WALKER *)this->cmdWalker;
|
||||
EXPECT_NE(nullptr, cmdWalker);
|
||||
|
||||
auto cmdSBA = (STATE_BASE_ADDRESS *)cmdStateBaseAddress;
|
||||
EXPECT_NE(nullptr, cmdSBA);
|
||||
|
||||
auto offsetCrossThreadData = cmdWalker->getIndirectDataStartAddress();
|
||||
EXPECT_LT(offsetCrossThreadData, cmdSBA->getIndirectObjectBufferSize() * MemoryConstants::pageSize);
|
||||
|
||||
offsetCrossThreadData -= static_cast<uint32_t>(ioh.getGraphicsAllocation()->getGpuAddressToPatch());
|
||||
|
||||
// Get the base of cross thread
|
||||
auto pCrossThreadData = ptrOffset(
|
||||
reinterpret_cast<const void *>(ioh.getCpuBase()),
|
||||
offsetCrossThreadData);
|
||||
|
||||
// Determine where the argument is
|
||||
auto &patchInfo = kernel.getKernelInfo(rootDeviceIndex).patchInfo;
|
||||
for (auto &arg : patchInfo.statelessGlobalMemObjKernelArgs) {
|
||||
if (arg->ArgumentNumber == indexArg) {
|
||||
return ptrOffset(pCrossThreadData, arg->DataParamOffset);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
23
shared/test/common/debug_settings/CMakeLists.txt
Normal file
23
shared/test/common/debug_settings/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_tests.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/debug_variables_helper_windows_tests.cpp
|
||||
)
|
||||
elseif(UNIX)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/debug_settings_manager_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/debug_variables_helper_linux_tests.cpp
|
||||
)
|
||||
endif()
|
||||
12
shared/test/common/debug_settings/debug_manager.cpp
Normal file
12
shared/test/common/debug_settings/debug_manager.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
DebugSettingsManager<globalDebugFunctionalityLevel> DebugManager("");
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/utilities/directory.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
|
||||
class TestDebugFlagsChecker {
|
||||
public:
|
||||
static bool isEqual(int32_t returnedValue, bool defaultValue) {
|
||||
if (returnedValue == 0) {
|
||||
return !defaultValue;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
static bool isEqual(int32_t returnedValue, int32_t defaultValue) {
|
||||
return returnedValue == defaultValue;
|
||||
}
|
||||
|
||||
static bool isEqual(int64_t returnedValue, int64_t defaultValue) {
|
||||
return returnedValue == defaultValue;
|
||||
}
|
||||
|
||||
static bool isEqual(std::string returnedValue, std::string defaultValue) {
|
||||
return returnedValue == defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
template <DebugFunctionalityLevel DebugLevel>
|
||||
class TestDebugSettingsManager : public DebugSettingsManager<DebugLevel> {
|
||||
public:
|
||||
using DebugSettingsManager<DebugLevel>::dumpFlags;
|
||||
using DebugSettingsManager<DebugLevel>::settingsDumpFileName;
|
||||
|
||||
TestDebugSettingsManager() : DebugSettingsManager<DebugLevel>("") {}
|
||||
SettingsReader *getSettingsReader() {
|
||||
return DebugSettingsManager<DebugLevel>::readerImpl.get();
|
||||
}
|
||||
};
|
||||
|
||||
using FullyEnabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::Full>;
|
||||
using FullyDisabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::None>;
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/utilities/debug_file_reader.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/utilities/base_object_utils.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "debug_settings_manager_fixture.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
TEST(DebugSettingsManager, WhenDebugManagerIsCreatedThenInjectFcnIsNull) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
|
||||
EXPECT_FALSE(debugManager.disabled());
|
||||
|
||||
EXPECT_EQ(nullptr, debugManager.injectFcn);
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, WhenDebugManagerIsCreatedThenSettingsReaderIsAvailable) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
// SettingsReader created
|
||||
EXPECT_NE(nullptr, debugManager.getSettingsReader());
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, WhenDebugManagerIsDisabledThenDebugFunctionalityIsNotAvailable) {
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
|
||||
// Should not be enabled without debug functionality
|
||||
EXPECT_TRUE(debugManager.disabled());
|
||||
|
||||
// debug variables / flags set to default
|
||||
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \
|
||||
{ \
|
||||
bool isEqual = TestDebugFlagsChecker::isEqual(debugManager.flags.variableName.get(), static_cast<dataType>(defaultValue)); \
|
||||
EXPECT_TRUE(isEqual); \
|
||||
}
|
||||
#include "shared/source/debug_settings/release_variables.inl"
|
||||
|
||||
#include "debug_variables.inl"
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, whenDebugManagerIsDisabledThenDebugFunctionalityIsNotAvailableAtCompileTime) {
|
||||
TestDebugSettingsManager<DebugFunctionalityLevel::None> debugManager;
|
||||
|
||||
static_assert(debugManager.disabled(), "");
|
||||
static_assert(false == debugManager.registryReadAvailable(), "");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, whenDebugManagerIsFullyEnabledThenAllDebugFunctionalityIsAvailableAtCompileTime) {
|
||||
TestDebugSettingsManager<DebugFunctionalityLevel::Full> debugManager;
|
||||
|
||||
static_assert(false == debugManager.disabled(), "");
|
||||
static_assert(debugManager.registryReadAvailable(), "");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, whenOnlyRegKeysAreEnabledThenAllOtherDebugFunctionalityIsNotAvailableAtCompileTime) {
|
||||
TestDebugSettingsManager<DebugFunctionalityLevel::RegKeys> debugManager;
|
||||
|
||||
static_assert(false == debugManager.disabled(), "");
|
||||
static_assert(debugManager.registryReadAvailable(), "");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenTwoPossibleVariantsOfHardwareInfoOverrideStringThenOutputStringIsTheSame) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
std::string hwInfoConfig;
|
||||
|
||||
// Set HardwareInfoOverride as regular string (i.e. as in Windows Registry)
|
||||
std::string str1 = "1x4x8";
|
||||
debugManager.flags.HardwareInfoOverride.set(str1);
|
||||
debugManager.getHardwareInfoOverride(hwInfoConfig);
|
||||
EXPECT_EQ(str1, hwInfoConfig);
|
||||
|
||||
// Set HardwareInfoOverride as quoted string (i.e. as in igdrcl.config file)
|
||||
std::string str2 = "\"1x4x8\"";
|
||||
debugManager.flags.HardwareInfoOverride.set(str2);
|
||||
hwInfoConfig = debugManager.flags.HardwareInfoOverride.get();
|
||||
EXPECT_EQ(str2, hwInfoConfig);
|
||||
debugManager.getHardwareInfoOverride(hwInfoConfig);
|
||||
EXPECT_EQ(str1, hwInfoConfig);
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenStringDebugVariableWhenLongValueExeedingSmallStringOptimizationIsAssignedThenMemoryLeakIsNotReported) {
|
||||
DebugManagerStateRestore debugManagerStateRestore;
|
||||
DebugManager.flags.AUBDumpCaptureFileName.set("ThisIsVeryLongStringValueThatExceedSizeSpecifiedBySmallStringOptimizationAndCausesInternalStringBufferResize");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenNullAsReaderImplInDebugManagerWhenSettingReaderImplThenItsSetProperly) {
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
auto readerImpl = SettingsReader::create("");
|
||||
debugManager.setReaderImpl(readerImpl);
|
||||
EXPECT_EQ(readerImpl, debugManager.getReaderImpl());
|
||||
}
|
||||
TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentReaderImplThenItsSetProperly) {
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
auto readerImpl = SettingsReader::create("");
|
||||
debugManager.setReaderImpl(readerImpl);
|
||||
|
||||
auto readerImpl2 = SettingsReader::create("");
|
||||
debugManager.setReaderImpl(readerImpl2);
|
||||
EXPECT_EQ(readerImpl2, debugManager.getReaderImpl());
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) {
|
||||
testing::internal::CaptureStdout();
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
debugManager.flags.PrintDebugSettings.set(true);
|
||||
debugManager.flags.LoopAtDriverInit.set(true);
|
||||
debugManager.flags.Enable64kbpages.set(1);
|
||||
debugManager.flags.TbxServer.set("192.168.0.1");
|
||||
|
||||
// Clear dump files and generate new
|
||||
std::remove(FullyEnabledTestDebugManager::settingsDumpFileName);
|
||||
debugManager.dumpFlags();
|
||||
|
||||
// Validate allSettingsDumpFile
|
||||
SettingsFileReader allSettingsReader{FullyEnabledTestDebugManager::settingsDumpFileName};
|
||||
#define DECLARE_DEBUG_VARIABLE(dataType, varName, defaultValue, description) \
|
||||
EXPECT_EQ(debugManager.flags.varName.get(), allSettingsReader.getSetting(#varName, defaultValue));
|
||||
|
||||
#include "debug_variables.inl"
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
std::remove(FullyEnabledTestDebugManager::settingsDumpFileName);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
ASSERT_NE(0u, output.size());
|
||||
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: TbxServer = 192.168.0.1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: LoopAtDriverInit = 1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: PrintDebugSettings = 1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: Enable64kbpages = 1"));
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledOnDisabledDebugManagerWhenCallingDumpFlagsThenFlagsAreNotWrittenToDumpFile) {
|
||||
testing::internal::CaptureStdout();
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
debugManager.flags.PrintDebugSettings.set(true);
|
||||
|
||||
std::remove(FullyDisabledTestDebugManager::settingsDumpFileName);
|
||||
debugManager.dumpFlags();
|
||||
std::remove(FullyDisabledTestDebugManager::settingsDumpFileName);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(0u, output.size());
|
||||
}
|
||||
|
||||
TEST(AllocationInfoLogging, givenBaseGraphicsAllocationWhenGettingImplementationSpecificAllocationInfoThenReturnEmptyInfoString) {
|
||||
GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull);
|
||||
EXPECT_STREQ(graphicsAllocation.getAllocationInfoString().c_str(), "");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenDisabledDebugManagerWhenCreateThenOnlyReleaseVariablesAreRead) {
|
||||
bool settingsFileExists = fileExists(SettingsReader::settingsFileName);
|
||||
if (!settingsFileExists) {
|
||||
const char data[] = "LogApiCalls = 1\nMakeAllBuffersResident = 1";
|
||||
writeDataToFile(SettingsReader::settingsFileName, &data, sizeof(data));
|
||||
}
|
||||
|
||||
SettingsReader *reader = SettingsReader::createFileReader();
|
||||
EXPECT_NE(nullptr, reader);
|
||||
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
debugManager.setReaderImpl(reader);
|
||||
debugManager.injectSettingsFromReader();
|
||||
|
||||
EXPECT_EQ(1, debugManager.flags.MakeAllBuffersResident.get());
|
||||
EXPECT_EQ(0, debugManager.flags.LogApiCalls.get());
|
||||
|
||||
if (!settingsFileExists) {
|
||||
remove(SettingsReader::settingsFileName);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenEnabledDebugManagerWhenCreateThenAllVariablesAreRead) {
|
||||
bool settingsFileExists = fileExists(SettingsReader::settingsFileName);
|
||||
if (!settingsFileExists) {
|
||||
const char data[] = "LogApiCalls = 1\nMakeAllBuffersResident = 1";
|
||||
writeDataToFile(SettingsReader::settingsFileName, &data, sizeof(data));
|
||||
}
|
||||
|
||||
SettingsReader *reader = SettingsReader::createFileReader();
|
||||
EXPECT_NE(nullptr, reader);
|
||||
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
debugManager.setReaderImpl(reader);
|
||||
debugManager.injectSettingsFromReader();
|
||||
|
||||
EXPECT_EQ(1, debugManager.flags.MakeAllBuffersResident.get());
|
||||
EXPECT_EQ(1, debugManager.flags.LogApiCalls.get());
|
||||
|
||||
if (!settingsFileExists) {
|
||||
remove(SettingsReader::settingsFileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/utilities/debug_file_reader.h"
|
||||
#include "shared/test/common/debug_settings/debug_settings_manager_fixture.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_io_functions.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
TEST(DebugSettingsManager, givenDisabledDebugManagerAndMockEnvVariableWhenCreateThenAllVariablesAreRead) {
|
||||
bool settingsFileExists = fileExists(SettingsReader::settingsFileName);
|
||||
if (!settingsFileExists) {
|
||||
const char data[] = "LogApiCalls = 1\nMakeAllBuffersResident = 1";
|
||||
writeDataToFile(SettingsReader::settingsFileName, &data, sizeof(data));
|
||||
}
|
||||
|
||||
SettingsReader *reader = SettingsReader::createFileReader();
|
||||
EXPECT_NE(nullptr, reader);
|
||||
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"NEOReadDebugKeys", "1"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
debugManager.setReaderImpl(reader);
|
||||
debugManager.injectSettingsFromReader();
|
||||
|
||||
EXPECT_EQ(1, debugManager.flags.MakeAllBuffersResident.get());
|
||||
EXPECT_EQ(1, debugManager.flags.LogApiCalls.get());
|
||||
|
||||
if (!settingsFileExists) {
|
||||
remove(SettingsReader::settingsFileName);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenPrintDebugSettingsAndDebugKeysReadEnabledOnDisabledDebugManagerWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) {
|
||||
testing::internal::CaptureStdout();
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
debugManager.flags.PrintDebugSettings.set(true);
|
||||
debugManager.flags.LoopAtDriverInit.set(true);
|
||||
debugManager.flags.Enable64kbpages.set(1);
|
||||
debugManager.flags.TbxServer.set("192.168.0.1");
|
||||
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"NEOReadDebugKeys", "1"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
// Clear dump files and generate new
|
||||
std::remove(FullyDisabledTestDebugManager::settingsDumpFileName);
|
||||
debugManager.dumpFlags();
|
||||
|
||||
// Validate allSettingsDumpFile
|
||||
SettingsFileReader allSettingsReader{FullyDisabledTestDebugManager::settingsDumpFileName};
|
||||
#define DECLARE_DEBUG_VARIABLE(dataType, varName, defaultValue, description) \
|
||||
EXPECT_EQ(debugManager.flags.varName.get(), allSettingsReader.getSetting(#varName, defaultValue));
|
||||
|
||||
#include "debug_variables.inl"
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
std::remove(FullyDisabledTestDebugManager::settingsDumpFileName);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
ASSERT_NE(0u, output.size());
|
||||
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: TbxServer = 192.168.0.1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: LoopAtDriverInit = 1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: PrintDebugSettings = 1"));
|
||||
EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: Enable64kbpages = 1"));
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_variables_helper.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_io_functions.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
TEST(DebugVariablesHelperTests, whenIsDebugKeysReadEnableIsCalledThenProperValueIsReturned) {
|
||||
{
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"NEOReadDebugKeys", "1"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
EXPECT_TRUE(isDebugKeysReadEnabled());
|
||||
}
|
||||
{
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"NEOReadDebugKeys", "0"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
EXPECT_FALSE(isDebugKeysReadEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_variables_helper.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
TEST(DebugVariablesHelperTests, whenIsDebugKeysReadEnableIsCalledThenFalseIsReturned) {
|
||||
EXPECT_FALSE(NEO::isDebugKeysReadEnabled());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
19
shared/test/common/fixtures/CMakeLists.txt
Normal file
19
shared/test/common/fixtures/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_container_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/front_window_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/front_window_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption_fixture.h
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
60
shared/test/common/fixtures/command_container_fixture.h
Normal file
60
shared/test/common/fixtures/command_container_fixture.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/kernel/kernel_descriptor.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class CommandEncodeStatesFixture : public DeviceFixture {
|
||||
public:
|
||||
class MyMockCommandContainer : public CommandContainer {
|
||||
public:
|
||||
using CommandContainer::dirtyHeaps;
|
||||
};
|
||||
|
||||
void SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
cmdContainer = std::make_unique<MyMockCommandContainer>();
|
||||
cmdContainer->initialize(pDevice);
|
||||
cmdContainer->setDirtyStateForAllHeaps(false);
|
||||
}
|
||||
void TearDown() {
|
||||
cmdContainer.reset();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
std::unique_ptr<MyMockCommandContainer> cmdContainer;
|
||||
KernelDescriptor descriptor;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
struct WalkerThreadFixture {
|
||||
void SetUp() {
|
||||
startWorkGroup[0] = startWorkGroup[1] = startWorkGroup[2] = 0u;
|
||||
numWorkGroups[0] = numWorkGroups[1] = numWorkGroups[2] = 1u;
|
||||
workGroupSizes[0] = 32u;
|
||||
workGroupSizes[1] = workGroupSizes[2] = 1u;
|
||||
simd = 32u;
|
||||
localIdDimensions = 3u;
|
||||
requiredWorkGroupOrder = 0u;
|
||||
}
|
||||
void TearDown() {}
|
||||
|
||||
uint32_t startWorkGroup[3];
|
||||
uint32_t numWorkGroups[3];
|
||||
uint32_t workGroupSizes[3];
|
||||
uint32_t simd;
|
||||
uint32_t localIdDimensions;
|
||||
uint32_t requiredWorkGroupOrder;
|
||||
};
|
||||
|
||||
using WalkerThreadTest = Test<WalkerThreadFixture>;
|
||||
37
shared/test/common/fixtures/device_fixture.cpp
Normal file
37
shared/test/common/fixtures/device_fixture.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
void DeviceFixture::SetUp() {
|
||||
hardwareInfo = *defaultHwInfo;
|
||||
SetUpImpl(&hardwareInfo);
|
||||
}
|
||||
|
||||
void DeviceFixture::SetUpImpl(const NEO::HardwareInfo *hardwareInfo) {
|
||||
pDevice = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hardwareInfo);
|
||||
ASSERT_NE(nullptr, pDevice);
|
||||
|
||||
auto &commandStreamReceiver = pDevice->getGpgpuCommandStreamReceiver();
|
||||
pTagMemory = commandStreamReceiver.getTagAddress();
|
||||
ASSERT_NE(nullptr, const_cast<uint32_t *>(pTagMemory));
|
||||
}
|
||||
|
||||
void DeviceFixture::TearDown() {
|
||||
delete pDevice;
|
||||
pDevice = nullptr;
|
||||
}
|
||||
|
||||
MockDevice *DeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) {
|
||||
hardwareInfo = *defaultHwInfo;
|
||||
hardwareInfo.platform.usDeviceID = usDeviceId;
|
||||
return MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo);
|
||||
}
|
||||
} // namespace NEO
|
||||
26
shared/test/common/fixtures/device_fixture.h
Normal file
26
shared/test/common/fixtures/device_fixture.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
namespace NEO {
|
||||
struct HardwareInfo;
|
||||
|
||||
struct DeviceFixture {
|
||||
void SetUp();
|
||||
void SetUpImpl(const NEO::HardwareInfo *hardwareInfo);
|
||||
void TearDown();
|
||||
|
||||
MockDevice *createWithUsDeviceId(unsigned short usDeviceId);
|
||||
|
||||
MockDevice *pDevice = nullptr;
|
||||
volatile uint32_t *pTagMemory = nullptr;
|
||||
HardwareInfo hardwareInfo = {};
|
||||
PLATFORM platformHelper = {};
|
||||
};
|
||||
} // namespace NEO
|
||||
54
shared/test/common/fixtures/direct_submission_fixture.h
Normal file
54
shared/test/common/fixtures/direct_submission_fixture.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
extern std::atomic<uintptr_t> lastClFlushedPtr;
|
||||
|
||||
struct DirectSubmissionFixture : public DeviceFixture {
|
||||
void SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
DeviceFactory::prepareDeviceEnvironments(*pDevice->getExecutionEnvironment());
|
||||
|
||||
osContext.reset(OsContext::create(nullptr, 0u, pDevice->getDeviceBitfield(), aub_stream::ENGINE_RCS, PreemptionMode::ThreadGroup,
|
||||
false, false, false));
|
||||
}
|
||||
|
||||
std::unique_ptr<OsContext> osContext;
|
||||
};
|
||||
|
||||
struct DirectSubmissionDispatchBufferFixture : public DirectSubmissionFixture {
|
||||
void SetUp() {
|
||||
DirectSubmissionFixture::SetUp();
|
||||
MemoryManager *memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
|
||||
const AllocationProperties commandBufferProperties{pDevice->getRootDeviceIndex(), 0x1000,
|
||||
GraphicsAllocation::AllocationType::COMMAND_BUFFER, pDevice->getDeviceBitfield()};
|
||||
commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(commandBufferProperties);
|
||||
|
||||
batchBuffer.endCmdPtr = &bbStart[0];
|
||||
batchBuffer.commandBufferAllocation = commandBuffer;
|
||||
batchBuffer.usedSize = 0x40;
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
MemoryManager *memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
|
||||
DirectSubmissionFixture::TearDown();
|
||||
}
|
||||
|
||||
BatchBuffer batchBuffer;
|
||||
uint8_t bbStart[64];
|
||||
GraphicsAllocation *commandBuffer;
|
||||
};
|
||||
27
shared/test/common/fixtures/front_window_fixture.cpp
Normal file
27
shared/test/common/fixtures/front_window_fixture.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/front_window_fixture.h"
|
||||
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
MemManagerFixture::FrontWindowMemManagerMock::FrontWindowMemManagerMock(NEO::ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {}
|
||||
void MemManagerFixture::FrontWindowMemManagerMock::forceLimitedRangeAllocator(uint32_t rootDeviceIndex, uint64_t range) { getGfxPartition(rootDeviceIndex)->init(range, 0, 0, gfxPartitions.size(), true); }
|
||||
void MemManagerFixture::SetUp() {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(true);
|
||||
DeviceFixture::SetUp();
|
||||
memManager = std::unique_ptr<FrontWindowMemManagerMock>(new FrontWindowMemManagerMock(*pDevice->getExecutionEnvironment()));
|
||||
}
|
||||
void MemManagerFixture::TearDown() {
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
27
shared/test/common/fixtures/front_window_fixture.h
Normal file
27
shared/test/common/fixtures/front_window_fixture.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MemManagerFixture : public DeviceFixture {
|
||||
public:
|
||||
struct FrontWindowMemManagerMock : public MockMemoryManager {
|
||||
FrontWindowMemManagerMock(NEO::ExecutionEnvironment &executionEnvironment);
|
||||
void forceLimitedRangeAllocator(uint32_t rootDeviceIndex, uint64_t range);
|
||||
};
|
||||
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
std::unique_ptr<FrontWindowMemManagerMock> memManager;
|
||||
};
|
||||
} // namespace NEO
|
||||
42
shared/test/common/fixtures/preemption_fixture.cpp
Normal file
42
shared/test/common/fixtures/preemption_fixture.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_kernel.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
DevicePreemptionTests::DevicePreemptionTests() = default;
|
||||
DevicePreemptionTests::~DevicePreemptionTests() = default;
|
||||
|
||||
void DevicePreemptionTests::SetUp() {
|
||||
if (dbgRestore == nullptr) {
|
||||
dbgRestore.reset(new DebugManagerStateRestore());
|
||||
}
|
||||
|
||||
device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
executionEnvironment.reset(new SPatchExecutionEnvironment);
|
||||
memset(executionEnvironment.get(), 0, sizeof(SPatchExecutionEnvironment));
|
||||
|
||||
ASSERT_NE(nullptr, device);
|
||||
|
||||
waTable = &device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable;
|
||||
}
|
||||
|
||||
void DevicePreemptionTests::TearDown() {
|
||||
dbgRestore.reset();
|
||||
}
|
||||
67
shared/test/common/fixtures/preemption_fixture.h
Normal file
67
shared/test/common/fixtures/preemption_fixture.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/preemption_mode.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace iOpenCL {
|
||||
struct SPatchExecutionEnvironment;
|
||||
}
|
||||
|
||||
namespace NEO {
|
||||
class MockCommandQueue;
|
||||
class MockContext;
|
||||
class MockDevice;
|
||||
class MockProgram;
|
||||
struct KernelInfo;
|
||||
struct WorkaroundTable;
|
||||
} // namespace NEO
|
||||
|
||||
class DevicePreemptionTests : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
DevicePreemptionTests();
|
||||
~DevicePreemptionTests() override;
|
||||
|
||||
NEO::PreemptionMode preemptionMode;
|
||||
NEO::WorkaroundTable *waTable = nullptr;
|
||||
std::unique_ptr<NEO::MockDevice> device;
|
||||
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
|
||||
std::unique_ptr<iOpenCL::SPatchExecutionEnvironment> executionEnvironment;
|
||||
};
|
||||
|
||||
struct PreemptionTestHwDetails {
|
||||
struct PreemptionModeHashT {
|
||||
auto operator()(const NEO::PreemptionMode &preemptionMode) const -> std::underlying_type<NEO::PreemptionMode>::type {
|
||||
return static_cast<std::underlying_type<NEO::PreemptionMode>::type>(preemptionMode);
|
||||
}
|
||||
};
|
||||
|
||||
bool supportsPreemptionProgramming() const {
|
||||
return modeToRegValueMap.size() > 0;
|
||||
}
|
||||
|
||||
uint32_t regAddress = 0;
|
||||
std::unordered_map<NEO::PreemptionMode, uint32_t, PreemptionModeHashT> modeToRegValueMap;
|
||||
uint32_t defaultRegValue = 0;
|
||||
};
|
||||
|
||||
template <typename FamilyType>
|
||||
PreemptionTestHwDetails GetPreemptionTestHwDetails();
|
||||
28
shared/test/common/gen11/CMakeLists.txt
Normal file
28
shared/test/common/gen11/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(TESTS_GEN11)
|
||||
set(NEO_CORE_TESTS_GEN11
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preamble_tests_gen11.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_gen11.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_gen11.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_gen11.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_GEN11 ${NEO_CORE_TESTS_GEN11})
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_gen11.cpp
|
||||
${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
|
||||
${COMPUTE_RUNTIME_ULT_GEN11}
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen11/unit_test_helper_gen11.cpp
|
||||
)
|
||||
|
||||
endif()
|
||||
89
shared/test/common/gen11/cmd_parse_gen11.cpp
Normal file
89
shared/test/common/gen11/cmd_parse_gen11.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using GenStruct = NEO::GEN11;
|
||||
using GenGfxFamily = NEO::ICLFamily;
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base_mi_arb.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_sip.inl"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.inl"
|
||||
|
||||
template <>
|
||||
size_t CmdParse<GenGfxFamily>::getCommandLengthHwSpecific(void *cmd) {
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_WALKER *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_VFE_STATE *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_STATE_FLUSH *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<STATE_SIP *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
const char *CmdParse<GenGfxFamily>::getCommandNameHwSpecific(void *cmd) {
|
||||
if (nullptr != genCmdCast<GPGPU_WALKER *>(cmd)) {
|
||||
return "GPGPU_WALKER";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd)) {
|
||||
return "MEDIA_INTERFACE_DESCRIPTOR_LOAD";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_VFE_STATE *>(cmd)) {
|
||||
return "MEDIA_VFE_STATE";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_STATE_FLUSH *>(cmd)) {
|
||||
return "MEDIA_STATE_FLUSH";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd)) {
|
||||
return "GPGPU_CSR_BASE_ADDRESS";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<STATE_SIP *>(cmd)) {
|
||||
return "STATE_SIP";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
template struct CmdParse<GenGfxFamily>;
|
||||
|
||||
namespace NEO {
|
||||
template void HardwareParse::findHardwareCommands<ICLFamily>();
|
||||
template void HardwareParse::findHardwareCommands<ICLFamily>(IndirectHeap *);
|
||||
template const void *HardwareParse::getStatelessArgumentPointer<ICLFamily>(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex);
|
||||
} // namespace NEO
|
||||
22
shared/test/common/gen11/command_encoder_tests_gen11.cpp
Normal file
22
shared/test/common/gen11/command_encoder_tests_gen11.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using Gen11CommandEncodeTest = testing::Test;
|
||||
GEN11TEST_F(Gen11CommandEncodeTest, givenGen11PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsFalse) {
|
||||
EXPECT_FALSE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::miArbCheckWaRequired());
|
||||
}
|
||||
40
shared/test/common/gen11/image_surface_state_tests_gen11.cpp
Normal file
40
shared/test/common/gen11/image_surface_state_tests_gen11.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/image/image_surface_state_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using ImageSurfaceStateTestsGen11 = ImageSurfaceStateTests;
|
||||
|
||||
GEN11TEST_F(ImageSurfaceStateTestsGen11, givenGmmWithMediaCompressedWhenSetFlagsForMediaCompressionThenAuxiliarySurfaceNoneIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
}
|
||||
|
||||
GEN11TEST_F(ImageSurfaceStateTestsGen11, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, nullptr);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u);
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, &mockGmm);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState());
|
||||
}
|
||||
50
shared/test/common/gen11/preamble_tests_gen11.cpp
Normal file
50
shared/test/common/gen11/preamble_tests_gen11.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/source_level_debugger/source_level_debugger_preamble_test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
typedef ICLFamily GfxFamily;
|
||||
|
||||
#include "shared/test/unit_test/source_level_debugger/source_level_debugger_preamble_test.inl"
|
||||
|
||||
using PreambleTestGen11 = ::testing::Test;
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenMidThreadPreemptionAndDebuggingActiveWhenStateSipIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDebuggingActiveWhenStateSipIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN11TEST_F(PreambleTestGen11, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreInlcudedTest();
|
||||
}
|
||||
16
shared/test/common/gen11/simd_helper_tests_gen11.cpp
Normal file
16
shared/test/common/gen11/simd_helper_tests_gen11.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/simd_helper_tests.inl"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using TestSimdConfigSet = ::testing::Test;
|
||||
|
||||
GEN11TEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedGen11) {
|
||||
GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned<typename FamilyType::GPGPU_WALKER>::TestBodyImpl();
|
||||
}
|
||||
66
shared/test/common/gen11/test_encode_math_gen11.cpp
Normal file
66
shared/test/common/gen11/test_encode_math_gen11.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderMathTestGen11 = Test<DeviceFixture>;
|
||||
|
||||
GEN11TEST_F(CommandEncoderMathTestGen11, WhenAppendsAGreaterThanThenPredicateCorrectlySet) {
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_MATH = typename FamilyType::MI_MATH;
|
||||
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itor = commands.begin();
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
||||
EXPECT_EQ(cmdMEM->getRegisterAddress(), CS_GPR_R0);
|
||||
EXPECT_EQ(cmdMEM->getMemoryAddress(), 0xDEADBEEFCAF0u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R1);
|
||||
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
||||
|
||||
itor = find<MI_MATH *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
||||
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
||||
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
||||
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
||||
|
||||
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
||||
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
||||
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
||||
}
|
||||
146
shared/test/common/gen11/test_preamble_gen11.cpp
Normal file
146
shared/test/common/gen11/test_preamble_gen11.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/preamble/preamble_fixture.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef PreambleFixture IclSlm;
|
||||
|
||||
GEN11TEST_F(IclSlm, WhenL3ConfigIsDispatchedThenProperRegisterAddressAndValueAreProgrammed) {
|
||||
typedef ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
|
||||
PreambleHelper<FamilyType>::programL3(&cs, l3Config);
|
||||
|
||||
parseCommands<ICLFamily>(cs);
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorLRI);
|
||||
|
||||
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
auto RegisterOffset = L3CNTLRegisterOffset<FamilyType>::registerOffset;
|
||||
EXPECT_EQ(RegisterOffset, lri.getRegisterOffset());
|
||||
EXPECT_EQ(0u, lri.getDataDword() & 1);
|
||||
}
|
||||
|
||||
GEN11TEST_F(IclSlm, givenGen11WhenProgramingL3ThenErrorDetectionBehaviorControlBitSet) {
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
|
||||
|
||||
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
||||
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
}
|
||||
|
||||
GEN11TEST_F(IclSlm, WhenCheckingL3IsConfigurableThenExpectItToBeFalse) {
|
||||
bool isL3Programmable =
|
||||
PreambleHelper<FamilyType>::isL3Configurable(*defaultHwInfo);
|
||||
|
||||
EXPECT_FALSE(isL3Programmable);
|
||||
}
|
||||
|
||||
typedef PreambleFixture Gen11UrbEntryAllocationSize;
|
||||
GEN11TEST_F(Gen11UrbEntryAllocationSize, WhenPreambleRetrievesUrbEntryAllocationSizeThenValueIsCorrect) {
|
||||
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
|
||||
EXPECT_EQ(0x782u, actualVal);
|
||||
}
|
||||
|
||||
typedef PreambleVfeState Gen11PreambleVfeState;
|
||||
GEN11TEST_F(Gen11PreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
||||
typedef typename ICLFamily::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 0;
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<ICLFamily>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<ICLFamily>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreambleVfeState, GivenWaOnWhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
||||
typedef typename ICLFamily::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 1;
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<ICLFamily>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<ICLFamily>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
typedef PreambleFixture PreemptionWatermarkGen11;
|
||||
GEN11TEST_F(PreemptionWatermarkGen11, WhenPreambleIsCreatedThenWorkAroundsIsNotProgrammed) {
|
||||
PreambleHelper<FamilyType>::programGenSpecificPreambleWorkArounds(&linearStream, *defaultHwInfo);
|
||||
|
||||
parseCommands<FamilyType>(linearStream);
|
||||
|
||||
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address);
|
||||
ASSERT_EQ(nullptr, cmd);
|
||||
|
||||
MockDevice mockDevice;
|
||||
mockDevice.setDebuggerActive(false);
|
||||
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
|
||||
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
||||
|
||||
mockDevice.setDebuggerActive(true);
|
||||
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
|
||||
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
||||
}
|
||||
|
||||
typedef PreambleFixture ThreadArbitrationGen11;
|
||||
GEN11TEST_F(ThreadArbitrationGen11, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSet) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
typedef ICLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
typedef ICLFamily::PIPE_CONTROL PIPE_CONTROL;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
|
||||
MockDevice mockDevice;
|
||||
PreambleHelper<FamilyType>::programPreamble(&linearStream, mockDevice, l3Config,
|
||||
ThreadArbitrationPolicy::RoundRobin,
|
||||
nullptr);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(ppC, cmdList.end());
|
||||
|
||||
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), RowChickenReg4::address);
|
||||
ASSERT_NE(nullptr, cmd);
|
||||
|
||||
EXPECT_EQ(RowChickenReg4::regDataForArbitrationPolicy[ThreadArbitrationPolicy::RoundRobin], cmd->getDataDword());
|
||||
|
||||
MockDevice device;
|
||||
EXPECT_EQ(0u, PreambleHelper<ICLFamily>::getAdditionalCommandsSize(device));
|
||||
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<ICLFamily>::getThreadArbitrationCommandsSize());
|
||||
}
|
||||
|
||||
GEN11TEST_F(ThreadArbitrationGen11, GivenDefaultWhenProgrammingPreambleThenArbitrationPolicyIsRoundRobin) {
|
||||
EXPECT_EQ(ThreadArbitrationPolicy::RoundRobinAfterDependency, HwHelperHw<ICLFamily>::get().getDefaultThreadArbitrationPolicy());
|
||||
}
|
||||
113
shared/test/common/gen11/test_preemption_gen11.cpp
Normal file
113
shared/test/common/gen11/test_preemption_gen11.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
template <>
|
||||
PreemptionTestHwDetails GetPreemptionTestHwDetails<ICLFamily>() {
|
||||
PreemptionTestHwDetails ret;
|
||||
ret.modeToRegValueMap[PreemptionMode::ThreadGroup] = DwordBuilder::build(1, true) | DwordBuilder::build(2, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidBatch] = DwordBuilder::build(2, true) | DwordBuilder::build(1, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidThread] = DwordBuilder::build(2, true, false) | DwordBuilder::build(1, true, false);
|
||||
ret.defaultRegValue = ret.modeToRegValueMap[PreemptionMode::MidBatch];
|
||||
ret.regAddress = 0x2580u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
using Gen11PreemptionTests = DevicePreemptionTests;
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, whenMidThreadPreemptionIsNotAvailableThenDoesNotProgramStateSip) {
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
|
||||
size_t requiredSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(*device);
|
||||
EXPECT_EQ(0U, requiredSize);
|
||||
|
||||
LinearStream cmdStream{nullptr, 0};
|
||||
PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
EXPECT_EQ(0U, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSipIsProgrammed) {
|
||||
using STATE_SIP = typename FamilyType::STATE_SIP;
|
||||
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
executionEnvironment->DisableMidThreadPreemption = 0;
|
||||
|
||||
size_t requiredCmdStreamSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
size_t expectedPreambleSize = sizeof(STATE_SIP);
|
||||
EXPECT_EQ(expectedPreambleSize, requiredCmdStreamSize);
|
||||
|
||||
StackVec<char, 8192> streamStorage(requiredCmdStreamSize);
|
||||
ASSERT_LE(requiredCmdStreamSize, streamStorage.size());
|
||||
|
||||
LinearStream cmdStream{streamStorage.begin(), streamStorage.size()};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
|
||||
HardwareParse hwParsePreamble;
|
||||
hwParsePreamble.parseCommands<FamilyType>(cmdStream);
|
||||
|
||||
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
|
||||
ASSERT_NE(nullptr, stateSipCmd);
|
||||
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, *device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, WhenGettingPreemptionWaCsSizeThenZeroIsReturned) {
|
||||
size_t expectedSize = 0;
|
||||
EXPECT_EQ(expectedSize, PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device));
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, WhenApplyingPreemptionWaCmdsThenNothingIsAdded) {
|
||||
size_t usedSize = 0;
|
||||
StackVec<char, 1024> streamStorage(1024);
|
||||
LinearStream cmdStream{streamStorage.begin(), streamStorage.size()};
|
||||
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, givenInterfaceDescriptorDataWhenMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToDisable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidThread);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
|
||||
GEN11TEST_F(Gen11PreemptionTests, givenInterfaceDescriptorDataWhenNoMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToEnable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::Disabled);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidBatch);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::ThreadGroup);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
14
shared/test/common/gen11/test_traits_gen11.h
Normal file
14
shared/test/common/gen11/test_traits_gen11.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/helpers/test_traits.h"
|
||||
|
||||
template <>
|
||||
struct TestTraits<IGFX_GEN11_CORE> {
|
||||
static constexpr bool auxBuiltinsSupported = true;
|
||||
};
|
||||
30
shared/test/common/gen12lp/CMakeLists.txt
Normal file
30
shared/test/common/gen12lp/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(TESTS_GEN12LP)
|
||||
|
||||
set(NEO_CORE_TESTS_GEN12LP
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_gen12lp.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_GEN12LP ${NEO_CORE_TESTS_GEN12LP})
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_gen12lp.cpp
|
||||
${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
|
||||
${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()
|
||||
14
shared/test/common/gen12lp/cmd_parse/cmd_parse_gen12lp.inl
Normal file
14
shared/test/common/gen12lp/cmd_parse/cmd_parse_gen12lp.inl
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
size_t getAdditionalCommandLengthHwSpecific(void *cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *getAdditionalCommandNameHwSpecific(void *cmd) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
103
shared/test/common/gen12lp/cmd_parse_gen12lp.cpp
Normal file
103
shared/test/common/gen12lp/cmd_parse_gen12lp.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using GenStruct = NEO::GEN12LP;
|
||||
using GenGfxFamily = NEO::TGLLPFamily;
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_compute_mode.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_mi_arb.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_sip.inl"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.inl"
|
||||
|
||||
#include "cmd_parse_gen12lp.inl"
|
||||
|
||||
template <>
|
||||
size_t CmdParse<GenGfxFamily>::getCommandLengthHwSpecific(void *cmd) {
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_WALKER *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_VFE_STATE *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_STATE_FLUSH *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<STATE_COMPUTE_MODE *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<STATE_SIP *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
|
||||
return getAdditionalCommandLengthHwSpecific(cmd);
|
||||
}
|
||||
|
||||
template <>
|
||||
const char *CmdParse<GenGfxFamily>::getCommandNameHwSpecific(void *cmd) {
|
||||
if (nullptr != genCmdCast<GPGPU_WALKER *>(cmd)) {
|
||||
return "GPGPU_WALKER";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd)) {
|
||||
return "MEDIA_INTERFACE_DESCRIPTOR_LOAD";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_VFE_STATE *>(cmd)) {
|
||||
return "MEDIA_VFE_STATE";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_STATE_FLUSH *>(cmd)) {
|
||||
return "MEDIA_STATE_FLUSH";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<STATE_COMPUTE_MODE *>(cmd)) {
|
||||
return "MEDIA_STATE_FLUSH";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd)) {
|
||||
return "GPGPU_CSR_BASE_ADDRESS";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<STATE_SIP *>(cmd)) {
|
||||
return "STATE_SIP";
|
||||
}
|
||||
|
||||
return getAdditionalCommandNameHwSpecific(cmd);
|
||||
}
|
||||
|
||||
template struct CmdParse<GenGfxFamily>;
|
||||
|
||||
namespace NEO {
|
||||
template void HardwareParse::findHardwareCommands<TGLLPFamily>();
|
||||
template void HardwareParse::findHardwareCommands<TGLLPFamily>(IndirectHeap *);
|
||||
template const void *HardwareParse::getStatelessArgumentPointer<TGLLPFamily>(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex);
|
||||
} // namespace NEO
|
||||
17
shared/test/common/gen12lp/command_encoder_tests_gen12lp.cpp
Normal file
17
shared/test/common/gen12lp/command_encoder_tests_gen12lp.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using Gen12LpCommandEncodeTest = testing::Test;
|
||||
GEN12LPTEST_F(Gen12LpCommandEncodeTest, givenGen12LpPlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) {
|
||||
EXPECT_FALSE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/image/image_surface_state_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using ImageSurfaceStateTestsGen12LP = ImageSurfaceStateTests;
|
||||
|
||||
GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWithMediaCompressedWhenSetFlagsForMediaCompressionThenAuxiliarySurfaceNoneIsSetAndMemoryCompressionEnable) {
|
||||
auto size = sizeof(typename TGLLPFamily::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename TGLLPFamily::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
castSurfaceState->setAuxiliarySurfaceMode(TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), false);
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), true);
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWhenSetClearColorParamsThenClearValueAddressEnable) {
|
||||
auto size = sizeof(typename TGLLPFamily::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename TGLLPFamily::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true;
|
||||
EncodeSurfaceState<TGLLPFamily>::setClearColorParams(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getClearValueAddressEnable(), true);
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, nullptr);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u);
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, &mockGmm);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState());
|
||||
}
|
||||
16
shared/test/common/gen12lp/simd_helper_tests_gen12lp.cpp
Normal file
16
shared/test/common/gen12lp/simd_helper_tests_gen12lp.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/simd_helper_tests.inl"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using TestSimdConfigSet = ::testing::Test;
|
||||
|
||||
GEN12LPTEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedGen12LP) {
|
||||
GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned<typename FamilyType::GPGPU_WALKER>::TestBodyImpl();
|
||||
}
|
||||
151
shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp
Normal file
151
shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/cmdcontainer.h"
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderTest = Test<DeviceFixture>;
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, givenAdjustStateComputeModeStateComputeModeShowsNonCoherencySet) {
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
using FORCE_NON_COHERENT = typename STATE_COMPUTE_MODE::FORCE_NON_COHERENT;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
|
||||
auto ret = cmdContainer.initialize(pDevice);
|
||||
ASSERT_EQ(ErrorCode::SUCCESS, ret);
|
||||
|
||||
auto usedSpaceBefore = cmdContainer.getCommandStream()->getUsed();
|
||||
|
||||
// Adjust the State Compute Mode which sets FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT
|
||||
EncodeStates<FamilyType>::adjustStateComputeMode(*cmdContainer.getCommandStream(), cmdContainer.lastSentNumGrfRequired, nullptr, false, false);
|
||||
|
||||
auto usedSpaceAfter = cmdContainer.getCommandStream()->getUsed();
|
||||
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
|
||||
|
||||
auto expectedCmdSize = sizeof(STATE_COMPUTE_MODE);
|
||||
auto cmdAddedSize = usedSpaceAfter - usedSpaceBefore;
|
||||
EXPECT_EQ(expectedCmdSize, cmdAddedSize);
|
||||
|
||||
auto expectedScmCmd = FamilyType::cmdInitStateComputeMode;
|
||||
expectedScmCmd.setForceNonCoherent(FORCE_NON_COHERENT::FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT);
|
||||
expectedScmCmd.setMaskBits(FamilyType::stateComputeModeForceNonCoherentMask);
|
||||
|
||||
auto scmCmd = reinterpret_cast<STATE_COMPUTE_MODE *>(ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), usedSpaceBefore));
|
||||
EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0);
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, givenCommandContainerWhenEncodeL3StateThenDoNotDispatchMMIOCommand) {
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
EXPECT_EQ(itorLRI, commands.end());
|
||||
}
|
||||
|
||||
struct MockOsContext : public OsContext {
|
||||
using OsContext::engineType;
|
||||
};
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, givenVariousEngineTypesWhenEncodeSBAThenAdditionalPipelineSelectWAIsAppliedOnlyToRcs) {
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
|
||||
auto ret = cmdContainer.initialize(pDevice);
|
||||
ASSERT_EQ(ErrorCode::SUCCESS, ret);
|
||||
|
||||
{
|
||||
STATE_BASE_ADDRESS sba;
|
||||
EncodeStateBaseAddress<FamilyType>::encode(cmdContainer, sba);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
auto itorLRI = find<PIPELINE_SELECT *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(itorLRI, commands.end());
|
||||
}
|
||||
|
||||
cmdContainer.reset();
|
||||
|
||||
{
|
||||
static_cast<MockOsContext *>(pDevice->getDefaultEngine().osContext)->engineType = aub_stream::ENGINE_CCS;
|
||||
|
||||
STATE_BASE_ADDRESS sba;
|
||||
EncodeStateBaseAddress<FamilyType>::encode(cmdContainer, sba);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
auto itorLRI = find<PIPELINE_SELECT *>(commands.begin(), commands.end());
|
||||
EXPECT_EQ(itorLRI, commands.end());
|
||||
}
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, givenVariousEngineTypesWhenEstimateCommandBufferSizeThenRcsHasAdditionalPipelineSelectWASize) {
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
|
||||
auto sizeWA = EncodeDispatchKernel<FamilyType>::estimateEncodeDispatchKernelCmdsSize(pDevice);
|
||||
static_cast<MockOsContext *>(pDevice->getDefaultEngine().osContext)->engineType = aub_stream::ENGINE_CCS;
|
||||
auto size = EncodeDispatchKernel<FamilyType>::estimateEncodeDispatchKernelCmdsSize(pDevice);
|
||||
|
||||
auto expectedDiff = 2 * PreambleHelper<FamilyType>::getCmdSizeForPipelineSelect(pDevice->getHardwareInfo());
|
||||
auto diff = sizeWA - size;
|
||||
|
||||
EXPECT_EQ(expectedDiff, diff);
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOnThenExpectNoCommandsDispatched) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, true);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
EXPECT_EQ(itorLRI, commands.end());
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOffThenExpectNoCommandsDispatched) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
EXPECT_EQ(itorLRI, commands.end());
|
||||
}
|
||||
|
||||
using Gen12lpCommandEncodeTest = testing::Test;
|
||||
|
||||
GEN12LPTEST_F(Gen12lpCommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::miArbCheckWaRequired());
|
||||
}
|
||||
67
shared/test/common/gen12lp/test_encode_math_gen12lp.cpp
Normal file
67
shared/test/common/gen12lp/test_encode_math_gen12lp.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderMathTestGen12Lp = Test<DeviceFixture>;
|
||||
|
||||
GEN12LPTEST_F(CommandEncoderMathTestGen12Lp, WhenAppendsAGreaterThanThenPredicateCorrectlySetAndRemapEnabled) {
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_MATH = typename FamilyType::MI_MATH;
|
||||
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itor = commands.begin();
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
||||
EXPECT_EQ(CS_GPR_R0, cmdMEM->getRegisterAddress());
|
||||
EXPECT_EQ(0xDEADBEEFCAF0u, cmdMEM->getMemoryAddress());
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
EXPECT_EQ(CS_GPR_R1, cmdIMM->getRegisterOffset());
|
||||
EXPECT_EQ(17u, cmdIMM->getDataDword());
|
||||
EXPECT_TRUE(cmdIMM->getMmioRemapEnable());
|
||||
|
||||
itor = find<MI_MATH *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
||||
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
||||
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
||||
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
||||
|
||||
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
||||
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
||||
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
||||
}
|
||||
198
shared/test/common/gen12lp/test_preamble_gen12lp.cpp
Normal file
198
shared/test/common/gen12lp/test_preamble_gen12lp.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/preamble/preamble_fixture.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef PreambleFixture TglLpSlm;
|
||||
|
||||
HWTEST2_F(TglLpSlm, givenTglLpWhenPreambleIsBeingProgrammedThenThreadArbitrationPolicyIsIgnored, IsTGLLP) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
typedef TGLLPFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<TGLLPFamily>::getL3Config(pDevice->getHardwareInfo(), true);
|
||||
MockDevice mockDevice;
|
||||
PreambleHelper<TGLLPFamily>::programPreamble(&linearStream, mockDevice, l3Config,
|
||||
ThreadArbitrationPolicy::RoundRobin,
|
||||
nullptr);
|
||||
|
||||
parseCommands<TGLLPFamily>(cs);
|
||||
|
||||
// parse through commands and ensure that 0xE404 is not being programmed
|
||||
EXPECT_EQ(0U, countMmio<FamilyType>(cmdList.begin(), cmdList.end(), 0xE404));
|
||||
}
|
||||
|
||||
HWTEST2_F(TglLpSlm, WhenCheckingL3IsConfigurableThenExpectItToBeFalse, IsTGLLP) {
|
||||
bool isL3Programmable =
|
||||
PreambleHelper<TGLLPFamily>::isL3Configurable(*defaultHwInfo);
|
||||
|
||||
EXPECT_FALSE(isL3Programmable);
|
||||
}
|
||||
|
||||
HWTEST2_F(TglLpSlm, WhenPreambleIsCreatedThenSlmIsDisabled, IsTGLLP) {
|
||||
typedef TGLLPFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(pDevice->getHardwareInfo(), true);
|
||||
PreambleHelper<FamilyType>::programL3(&cs, l3Config);
|
||||
|
||||
parseCommands<TGLLPFamily>(cs);
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_EQ(cmdList.end(), itorLRI);
|
||||
}
|
||||
|
||||
typedef PreambleFixture Gen12LpUrbEntryAllocationSize;
|
||||
HWTEST2_F(Gen12LpUrbEntryAllocationSize, WhenPreambleIsCreatedThenUrbEntryAllocationSizeIsCorrect, IsTGLLP) {
|
||||
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
|
||||
EXPECT_EQ(1024u, actualVal);
|
||||
}
|
||||
|
||||
typedef PreambleVfeState Gen12LpPreambleVfeState;
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsCorrect, IsTGLLP) {
|
||||
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 0;
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<FamilyType>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDepthStallEnable());
|
||||
EXPECT_FALSE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, givenCcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
|
||||
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 1;
|
||||
LinearStream &cs = linearStream;
|
||||
|
||||
PreambleHelper<FamilyType>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u,
|
||||
aub_stream::EngineType::ENGINE_CCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, givenRcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 1;
|
||||
LinearStream &cs = linearStream;
|
||||
|
||||
PreambleHelper<FamilyType>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDepthStallEnable());
|
||||
EXPECT_TRUE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, givenDefaultPipeControlWhenItIsProgrammedThenCsStallBitIsSet, IsTGLLP) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
|
||||
PIPE_CONTROL *pipeControl = static_cast<PIPE_CONTROL *>(linearStream.getSpace(sizeof(PIPE_CONTROL)));
|
||||
*pipeControl = FamilyType::cmdInitPipeControl;
|
||||
|
||||
EXPECT_EQ(1u, pipeControl->getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, givenCfeFusedEuDispatchFlagsWhenprogramAdditionalFieldsInVfeStateIsCalledThenGetDisableSlice0Subslice2ReturnsCorrectValues, IsTGLLP) {
|
||||
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
auto pHwInfo = pPlatform->getClDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
auto pMediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(linearStream.getSpace(sizeof(MEDIA_VFE_STATE)));
|
||||
*pMediaVfeState = FamilyType::cmdInitMediaVfeState;
|
||||
auto &waTable = pHwInfo->workaroundTable;
|
||||
|
||||
std::tuple<bool, bool, int32_t> testParams[]{
|
||||
{false, false, 0},
|
||||
{false, true, 0},
|
||||
{false, false, -1},
|
||||
{true, false, 1},
|
||||
{true, true, -1},
|
||||
{true, true, 1}};
|
||||
|
||||
for (auto &[expectedValue, waDisableFusedThreadScheduling, debugKeyValue] : testParams) {
|
||||
waTable.waDisableFusedThreadScheduling = waDisableFusedThreadScheduling;
|
||||
::DebugManager.flags.CFEFusedEUDispatch.set(debugKeyValue);
|
||||
PreambleHelper<FamilyType>::programAdditionalFieldsInVfeState(pMediaVfeState, *pHwInfo);
|
||||
EXPECT_EQ(expectedValue, pMediaVfeState->getDisableSlice0Subslice2());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(Gen12LpPreambleVfeState, givenMaxNumberOfDssDebugVariableWhenMediaVfeStateIsProgrammedThenFieldIsSet, IsTGLLP) {
|
||||
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.MediaVfeStateMaxSubSlices.set(2);
|
||||
auto pHwInfo = pPlatform->getClDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
auto pMediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(linearStream.getSpace(sizeof(MEDIA_VFE_STATE)));
|
||||
*pMediaVfeState = FamilyType::cmdInitMediaVfeState;
|
||||
PreambleHelper<FamilyType>::programAdditionalFieldsInVfeState(pMediaVfeState, *pHwInfo);
|
||||
EXPECT_EQ(2u, pMediaVfeState->getMaximumNumberOfDualSubslices());
|
||||
}
|
||||
|
||||
typedef PreambleFixture ThreadArbitrationGen12Lp;
|
||||
GEN12LPTEST_F(ThreadArbitrationGen12Lp, givenPolicyWhenThreadArbitrationProgrammedThenDoNothing) {
|
||||
LinearStream &cs = linearStream;
|
||||
|
||||
PreambleHelper<FamilyType>::programThreadArbitration(&cs, ThreadArbitrationPolicy::RoundRobin);
|
||||
|
||||
EXPECT_EQ(0u, cs.getUsed());
|
||||
EXPECT_EQ(0u, HwHelperHw<FamilyType>::get().getDefaultThreadArbitrationPolicy());
|
||||
}
|
||||
|
||||
typedef PreambleFixture PreemptionWatermarkGen12LP;
|
||||
GEN12LPTEST_F(PreemptionWatermarkGen12LP, WhenPreambleIsCreatedThenPreambleWorkAroundsIsNotProgrammed) {
|
||||
PreambleHelper<FamilyType>::programGenSpecificPreambleWorkArounds(&linearStream, pDevice->getHardwareInfo());
|
||||
|
||||
parseCommands<FamilyType>(linearStream);
|
||||
|
||||
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address);
|
||||
ASSERT_EQ(nullptr, cmd);
|
||||
|
||||
MockDevice mockDevice;
|
||||
mockDevice.setDebuggerActive(false);
|
||||
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
|
||||
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
||||
|
||||
mockDevice.setDebuggerActive(true);
|
||||
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
|
||||
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
||||
}
|
||||
100
shared/test/common/gen12lp/test_preemption_gen12lp.cpp
Normal file
100
shared/test/common/gen12lp/test_preemption_gen12lp.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
template <>
|
||||
PreemptionTestHwDetails GetPreemptionTestHwDetails<TGLLPFamily>() {
|
||||
PreemptionTestHwDetails ret;
|
||||
ret.modeToRegValueMap[PreemptionMode::ThreadGroup] = DwordBuilder::build(1, true) | DwordBuilder::build(2, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidBatch] = DwordBuilder::build(2, true) | DwordBuilder::build(1, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidThread] = DwordBuilder::build(2, true, false) | DwordBuilder::build(1, true, false);
|
||||
ret.defaultRegValue = ret.modeToRegValueMap[PreemptionMode::MidBatch];
|
||||
ret.regAddress = 0x2580u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
using Gen12LpPreemptionTests = DevicePreemptionTests;
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, whenProgramStateSipIsCalledThenStateSipCmdIsAddedToStream) {
|
||||
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
StackVec<char, 1024> streamStorage(1024);
|
||||
LinearStream cmdStream{streamStorage.begin(), streamStorage.size()};
|
||||
|
||||
EXPECT_NE(0U, requiredSize);
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
EXPECT_NE(0U, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, WhenGettingPreemptionWaCsSizeThenZeroIsReturned) {
|
||||
size_t expectedSize = 0;
|
||||
EXPECT_EQ(expectedSize, PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device));
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, WhenApplyingPreemptionWaCmdsThenNothingIsAdded) {
|
||||
size_t usedSize = 0;
|
||||
StackVec<char, 1024> streamStorage(1024);
|
||||
LinearStream cmdStream{streamStorage.begin(), streamStorage.size()};
|
||||
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, givenInterfaceDescriptorDataWhenMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToDisable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidThread);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, givenInterfaceDescriptorDataWhenNoMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToEnable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::Disabled);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidBatch);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::ThreadGroup);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(Gen12LpPreemptionTests, WhenProgrammingPreemptionThenExpectLoarRegisterCommandRemapFlagEnabled) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
const size_t bufferSize = 128;
|
||||
uint8_t buffer[bufferSize];
|
||||
LinearStream cmdStream(buffer, bufferSize);
|
||||
|
||||
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, PreemptionMode::ThreadGroup, PreemptionMode::Initial, nullptr);
|
||||
auto lriCommand = genCmdCast<MI_LOAD_REGISTER_IMM *>(cmdStream.getCpuBase());
|
||||
ASSERT_NE(nullptr, lriCommand);
|
||||
EXPECT_TRUE(lriCommand->getMmioRemapEnable());
|
||||
}
|
||||
14
shared/test/common/gen12lp/test_traits_gen12lp.h
Normal file
14
shared/test/common/gen12lp/test_traits_gen12lp.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/helpers/test_traits.h"
|
||||
|
||||
template <>
|
||||
struct TestTraits<IGFX_GEN12LP_CORE> {
|
||||
static constexpr bool auxBuiltinsSupported = true;
|
||||
};
|
||||
29
shared/test/common/gen8/CMakeLists.txt
Normal file
29
shared/test/common/gen8/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(TESTS_GEN8)
|
||||
|
||||
set(NEO_CORE_TESTS_GEN8
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_gen8.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_gen8.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_gen8.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_GEN8 ${NEO_CORE_TESTS_GEN8})
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_gen8.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_gen8.cpp
|
||||
${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
|
||||
${COMPUTE_RUNTIME_ULT_GEN8}
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen8/unit_test_helper_gen8.cpp
|
||||
)
|
||||
|
||||
endif()
|
||||
71
shared/test/common/gen8/cmd_parse_gen8.cpp
Normal file
71
shared/test/common/gen8/cmd_parse_gen8.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using GenStruct = NEO::GEN8;
|
||||
using GenGfxFamily = NEO::BDWFamily;
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base_mi_arb.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_sip.inl"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.inl"
|
||||
|
||||
template <>
|
||||
size_t CmdParse<GenGfxFamily>::getCommandLengthHwSpecific(void *cmd) {
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_WALKER *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_VFE_STATE *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_STATE_FLUSH *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
const char *CmdParse<GenGfxFamily>::getCommandNameHwSpecific(void *cmd) {
|
||||
if (nullptr != genCmdCast<GPGPU_WALKER *>(cmd)) {
|
||||
return "GPGPU_WALKER";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd)) {
|
||||
return "MEDIA_INTERFACE_DESCRIPTOR_LOAD";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_VFE_STATE *>(cmd)) {
|
||||
return "MEDIA_VFE_STATE";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_STATE_FLUSH *>(cmd)) {
|
||||
return "MEDIA_STATE_FLUSH";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
template struct CmdParse<GenGfxFamily>;
|
||||
|
||||
namespace NEO {
|
||||
template void HardwareParse::findHardwareCommands<BDWFamily>();
|
||||
template void HardwareParse::findHardwareCommands<BDWFamily>(IndirectHeap *);
|
||||
template const void *HardwareParse::getStatelessArgumentPointer<BDWFamily>(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex);
|
||||
} // namespace NEO
|
||||
22
shared/test/common/gen8/command_encoder_tests_gen8.cpp
Normal file
22
shared/test/common/gen8/command_encoder_tests_gen8.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using Gen8CommandEncodeTest = testing::Test;
|
||||
GEN8TEST_F(Gen8CommandEncodeTest, givenGen8PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) {
|
||||
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::miArbCheckWaRequired());
|
||||
}
|
||||
34
shared/test/common/gen8/image_surface_state_tests_gen8.cpp
Normal file
34
shared/test/common/gen8/image_surface_state_tests_gen8.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/image/image_surface_state_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using ImageSurfaceStateTestsGen8 = ImageSurfaceStateTests;
|
||||
|
||||
GEN8TEST_F(ImageSurfaceStateTestsGen8, givenGmmWithMediaCompressedWhenSetFlagsForMediaCompressionThenAuxiliarySurfaceNoneIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
}
|
||||
|
||||
GEN8TEST_F(ImageSurfaceStateTestsGen8, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, nullptr);
|
||||
}
|
||||
16
shared/test/common/gen8/simd_helper_tests_gen8.cpp
Normal file
16
shared/test/common/gen8/simd_helper_tests_gen8.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/simd_helper_tests.inl"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using TestSimdConfigSet = ::testing::Test;
|
||||
|
||||
GEN8TEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedGen8) {
|
||||
GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned<typename FamilyType::GPGPU_WALKER>::TestBodyImpl();
|
||||
}
|
||||
32
shared/test/common/gen8/state_base_address_tests_gen8.cpp
Normal file
32
shared/test/common/gen8/state_base_address_tests_gen8.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/state_base_address_tests.h"
|
||||
|
||||
BDWTEST_F(SBATest, givenUsedBindlessBuffersWhenAppendStateBaseAddressParametersIsCalledThenSBACmdHasNotBindingSurfaceStateProgrammed) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress = {};
|
||||
STATE_BASE_ADDRESS stateBaseAddressReference = {};
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(
|
||||
&stateBaseAddress,
|
||||
&ssh,
|
||||
false,
|
||||
0,
|
||||
nullptr,
|
||||
false,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
true,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(0u, ssh.getUsed());
|
||||
EXPECT_EQ(0, memcmp(&stateBaseAddressReference, &stateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
|
||||
}
|
||||
66
shared/test/common/gen8/test_encode_math_gen8.cpp
Normal file
66
shared/test/common/gen8/test_encode_math_gen8.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderMathTestGen8 = Test<DeviceFixture>;
|
||||
|
||||
GEN8TEST_F(CommandEncoderMathTestGen8, WhenAppendsAGreaterThanThenPredicateCorrectlySet) {
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_MATH = typename FamilyType::MI_MATH;
|
||||
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itor = commands.begin();
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
||||
EXPECT_EQ(cmdMEM->getRegisterAddress(), CS_GPR_R0);
|
||||
EXPECT_EQ(cmdMEM->getMemoryAddress(), 0xDEADBEEFCAF0u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R1);
|
||||
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
||||
|
||||
itor = find<MI_MATH *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
||||
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
||||
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
||||
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
||||
|
||||
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
||||
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
||||
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
||||
}
|
||||
109
shared/test/common/gen8/test_preamble_gen8.cpp
Normal file
109
shared/test/common/gen8/test_preamble_gen8.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/thread_arbitration_policy.h"
|
||||
#include "shared/source/gen8/reg_configs.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/test/unit_test/preamble/preamble_fixture.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef PreambleFixture BdwSlm;
|
||||
|
||||
BDWTEST_F(BdwSlm, WhenL3ConfigIsDispatchedThenProperRegisterAddressAndValueAreProgrammed) {
|
||||
typedef BDWFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<BDWFamily>::getL3Config(*defaultHwInfo, true);
|
||||
PreambleHelper<BDWFamily>::programL3(&cs, l3Config);
|
||||
|
||||
parseCommands<BDWFamily>(cs);
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorLRI);
|
||||
|
||||
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
auto RegisterOffset = L3CNTLRegisterOffset<BDWFamily>::registerOffset;
|
||||
EXPECT_EQ(RegisterOffset, lri.getRegisterOffset());
|
||||
EXPECT_EQ(1u, lri.getDataDword() & 1);
|
||||
}
|
||||
|
||||
typedef PreambleFixture Gen8L3Config;
|
||||
|
||||
BDWTEST_F(Gen8L3Config, GivenNoSlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
||||
bool slmUsed = false;
|
||||
uint32_t l3Config = 0;
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_BROADWELL>(slmUsed);
|
||||
EXPECT_EQ(0x80000340u, l3Config);
|
||||
|
||||
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
}
|
||||
|
||||
BDWTEST_F(Gen8L3Config, GivenlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
||||
bool slmUsed = true;
|
||||
uint32_t l3Config = 0;
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_BROADWELL>(slmUsed);
|
||||
EXPECT_EQ(0x60000321u, l3Config);
|
||||
|
||||
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
}
|
||||
|
||||
BDWTEST_F(Gen8L3Config, WhenPreambleIsCreatedThenL3ProgrammingIsCorrect) {
|
||||
bool l3ConfigDifference;
|
||||
bool isL3Programmable;
|
||||
|
||||
l3ConfigDifference =
|
||||
PreambleHelper<BDWFamily>::getL3Config(*defaultHwInfo, true) !=
|
||||
PreambleHelper<BDWFamily>::getL3Config(*defaultHwInfo, false);
|
||||
isL3Programmable =
|
||||
PreambleHelper<BDWFamily>::isL3Configurable(*defaultHwInfo);
|
||||
|
||||
EXPECT_EQ(l3ConfigDifference, isL3Programmable);
|
||||
}
|
||||
|
||||
typedef PreambleFixture ThreadArbitrationGen8;
|
||||
BDWTEST_F(ThreadArbitrationGen8, givenPolicyWhenThreadArbitrationProgrammedThenDoNothing) {
|
||||
typedef BDWFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
|
||||
PreambleHelper<BDWFamily>::programThreadArbitration(&cs, ThreadArbitrationPolicy::RoundRobin);
|
||||
|
||||
EXPECT_EQ(0u, cs.getUsed());
|
||||
|
||||
MockDevice device;
|
||||
EXPECT_EQ(0u, PreambleHelper<BDWFamily>::getAdditionalCommandsSize(device));
|
||||
EXPECT_EQ(0u, PreambleHelper<BDWFamily>::getThreadArbitrationCommandsSize());
|
||||
EXPECT_EQ(0u, HwHelperHw<BDWFamily>::get().getDefaultThreadArbitrationPolicy());
|
||||
}
|
||||
|
||||
typedef PreambleFixture Gen8UrbEntryAllocationSize;
|
||||
BDWTEST_F(Gen8UrbEntryAllocationSize, WhenPreambleIsCreatedThenUrbEntryAllocationSizeIsCorrect) {
|
||||
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
|
||||
EXPECT_EQ(0x782u, actualVal);
|
||||
}
|
||||
|
||||
BDWTEST_F(PreambleVfeState, WhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
||||
typedef BDWFamily::PIPE_CONTROL PIPE_CONTROL;
|
||||
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<BDWFamily>::programVFEState(&linearStream, *defaultHwInfo, 0u, 0, 168u, aub_stream::EngineType::ENGINE_RCS,
|
||||
AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<BDWFamily>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_TRUE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
222
shared/test/common/gen8/test_preemption_gen8.cpp
Normal file
222
shared/test/common/gen8/test_preemption_gen8.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
template <>
|
||||
PreemptionTestHwDetails GetPreemptionTestHwDetails<BDWFamily>() {
|
||||
PreemptionTestHwDetails ret;
|
||||
ret.modeToRegValueMap[PreemptionMode::ThreadGroup] = 0;
|
||||
ret.modeToRegValueMap[PreemptionMode::MidBatch] = (1 << 2);
|
||||
ret.defaultRegValue = ret.modeToRegValueMap[PreemptionMode::MidBatch];
|
||||
ret.regAddress = 0x2248u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
using Gen8PreemptionTests = DevicePreemptionTests;
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, whenProgramStateSipIsCalledThenNoCmdsAreProgrammed) {
|
||||
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
EXPECT_EQ(0U, requiredSize);
|
||||
|
||||
LinearStream cmdStream{nullptr, 0};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
EXPECT_EQ(0U, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, GivenMidBatchWhenGettingPreemptionWaCsSizeThenSizeIsZero) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::MidBatch);
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, GivenMidBatchAndNoWaWhenGettingPreemptionWaCsSizeThenSizeIsZero) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, GivenMidBatchAndWaWhenGettingPreemptionWaCsSizeThenSizeIsNonZero) {
|
||||
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM);
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, GivenMidThreadAndNoWaWhenGettingPreemptionWaCsSizeThenSizeIsZero) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, GivenMidThreadAndWaWhenGettingPreemptionWaCsSizeThenSizeNonIsZero) {
|
||||
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM);
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTests, givenInterfaceDescriptorDataWhenAnyPreemptionModeThenNoChange) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA idd;
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
int ret;
|
||||
|
||||
idd = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::Disabled);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidBatch);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::ThreadGroup);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidThread);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
struct Gen8PreemptionTestsLinearStream : public Gen8PreemptionTests {
|
||||
void SetUp() override {
|
||||
Gen8PreemptionTests::SetUp();
|
||||
cmdBufferAllocation = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
cmdBuffer.replaceBuffer(cmdBufferAllocation, MemoryConstants::pageSize);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
alignedFree(cmdBufferAllocation);
|
||||
Gen8PreemptionTests::TearDown();
|
||||
}
|
||||
|
||||
LinearStream cmdBuffer;
|
||||
void *cmdBufferAllocation;
|
||||
HardwareParse cmdBufferParser;
|
||||
};
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidBatchPreemptionWhenProgrammingWaCmdsBeginThenExpectNoCmds) {
|
||||
device->setPreemptionMode(PreemptionMode::MidBatch);
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidBatchPreemptionWhenProgrammingWaCmdsEndThenExpectNoCmds) {
|
||||
device->setPreemptionMode(PreemptionMode::MidBatch);
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) {
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionNoWaSetWhenProgrammingWaCmdsEndThenExpectNoCmd) {
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectMmioCmd) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdBuffer, *device);
|
||||
|
||||
cmdBufferParser.parseCommands<FamilyType>(cmdBuffer);
|
||||
cmdBufferParser.findHardwareCommands<FamilyType>();
|
||||
GenCmdList::iterator itMmioCmd = cmdBufferParser.lriList.begin();
|
||||
ASSERT_NE(cmdBufferParser.lriList.end(), itMmioCmd);
|
||||
MI_LOAD_REGISTER_IMM *mmioCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itMmioCmd);
|
||||
EXPECT_EQ(0x2600u, mmioCmd->getRegisterOffset());
|
||||
EXPECT_EQ(0xFFFFFFFFu, mmioCmd->getDataDword());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenThreadGroupPreemptionWaSetWhenProgrammingWaCmdsEndThenExpectMmioCmd) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdBuffer, *device);
|
||||
|
||||
cmdBufferParser.parseCommands<FamilyType>(cmdBuffer);
|
||||
cmdBufferParser.findHardwareCommands<FamilyType>();
|
||||
GenCmdList::iterator itMmioCmd = cmdBufferParser.lriList.begin();
|
||||
ASSERT_NE(cmdBufferParser.lriList.end(), itMmioCmd);
|
||||
MI_LOAD_REGISTER_IMM *mmioCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itMmioCmd);
|
||||
EXPECT_EQ(0x2600u, mmioCmd->getRegisterOffset());
|
||||
EXPECT_EQ(0x00000000u, mmioCmd->getDataDword());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) {
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionNoWaSetWhenProgrammingWaCmdsEndThenExpectNoCmd) {
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdBuffer, *device);
|
||||
EXPECT_EQ(0u, cmdBuffer.getUsed());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectMmioCmd) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdBuffer, *device);
|
||||
|
||||
cmdBufferParser.parseCommands<FamilyType>(cmdBuffer);
|
||||
cmdBufferParser.findHardwareCommands<FamilyType>();
|
||||
GenCmdList::iterator itMmioCmd = cmdBufferParser.lriList.begin();
|
||||
ASSERT_NE(cmdBufferParser.lriList.end(), itMmioCmd);
|
||||
MI_LOAD_REGISTER_IMM *mmioCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itMmioCmd);
|
||||
EXPECT_EQ(0x2600u, mmioCmd->getRegisterOffset());
|
||||
EXPECT_EQ(0xFFFFFFFFu, mmioCmd->getDataDword());
|
||||
}
|
||||
|
||||
GEN8TEST_F(Gen8PreemptionTestsLinearStream, givenMidThreadPreemptionWaSetWhenProgrammingWaCmdsEndThenExpectMmioCmd) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdBuffer, *device);
|
||||
|
||||
cmdBufferParser.parseCommands<FamilyType>(cmdBuffer);
|
||||
cmdBufferParser.findHardwareCommands<FamilyType>();
|
||||
GenCmdList::iterator itMmioCmd = cmdBufferParser.lriList.begin();
|
||||
ASSERT_NE(cmdBufferParser.lriList.end(), itMmioCmd);
|
||||
MI_LOAD_REGISTER_IMM *mmioCmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itMmioCmd);
|
||||
EXPECT_EQ(0x2600u, mmioCmd->getRegisterOffset());
|
||||
EXPECT_EQ(0x00000000u, mmioCmd->getDataDword());
|
||||
}
|
||||
14
shared/test/common/gen8/test_traits_gen8.h
Normal file
14
shared/test/common/gen8/test_traits_gen8.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/helpers/test_traits.h"
|
||||
|
||||
template <>
|
||||
struct TestTraits<IGFX_GEN8_CORE> {
|
||||
static constexpr bool auxBuiltinsSupported = true;
|
||||
};
|
||||
29
shared/test/common/gen9/CMakeLists.txt
Normal file
29
shared/test/common/gen9/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(TESTS_GEN9)
|
||||
|
||||
set(NEO_CORE_TESTS_GEN9
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preamble_tests_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_gen9.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_GEN9 ${NEO_CORE_TESTS_GEN9})
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_gen9.cpp
|
||||
${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
|
||||
${COMPUTE_RUNTIME_ULT_GEN9}
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/gen9/unit_test_helper_gen9.cpp
|
||||
)
|
||||
|
||||
endif()
|
||||
89
shared/test/common/gen9/cmd_parse_gen9.cpp
Normal file
89
shared/test/common/gen9/cmd_parse_gen9.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
using GenStruct = NEO::GEN9;
|
||||
using GenGfxFamily = NEO::SKLFamily;
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_base_mi_arb.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_gpgpu_walker.inl"
|
||||
#include "shared/test/common/cmd_parse/cmd_parse_sip.inl"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.inl"
|
||||
|
||||
template <>
|
||||
size_t CmdParse<GenGfxFamily>::getCommandLengthHwSpecific(void *cmd) {
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_WALKER *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_VFE_STATE *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<MEDIA_STATE_FLUSH *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
{
|
||||
auto pCmd = genCmdCast<STATE_SIP *>(cmd);
|
||||
if (pCmd)
|
||||
return pCmd->TheStructure.Common.DwordLength + 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
const char *CmdParse<GenGfxFamily>::getCommandNameHwSpecific(void *cmd) {
|
||||
if (nullptr != genCmdCast<GPGPU_WALKER *>(cmd)) {
|
||||
return "GPGPU_WALKER";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_INTERFACE_DESCRIPTOR_LOAD *>(cmd)) {
|
||||
return "MEDIA_INTERFACE_DESCRIPTOR_LOAD";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_VFE_STATE *>(cmd)) {
|
||||
return "MEDIA_VFE_STATE";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<MEDIA_STATE_FLUSH *>(cmd)) {
|
||||
return "MEDIA_STATE_FLUSH";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<GPGPU_CSR_BASE_ADDRESS *>(cmd)) {
|
||||
return "GPGPU_CSR_BASE_ADDRESS";
|
||||
}
|
||||
|
||||
if (nullptr != genCmdCast<STATE_SIP *>(cmd)) {
|
||||
return "STATE_SIP";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
template struct CmdParse<GenGfxFamily>;
|
||||
|
||||
namespace NEO {
|
||||
template void HardwareParse::findHardwareCommands<SKLFamily>();
|
||||
template void HardwareParse::findHardwareCommands<SKLFamily>(IndirectHeap *);
|
||||
template const void *HardwareParse::getStatelessArgumentPointer<SKLFamily>(const Kernel &kernel, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex);
|
||||
} // namespace NEO
|
||||
17
shared/test/common/gen9/command_encoder_tests_gen9.cpp
Normal file
17
shared/test/common/gen9/command_encoder_tests_gen9.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using Gen9CommandEncodeTest = testing::Test;
|
||||
GEN9TEST_F(Gen9CommandEncodeTest, givenGen9PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) {
|
||||
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
||||
}
|
||||
40
shared/test/common/gen9/image_surface_state_tests_gen9.cpp
Normal file
40
shared/test/common/gen9/image_surface_state_tests_gen9.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/image/image_surface_state_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using ImageSurfaceStateTestsGen9 = ImageSurfaceStateTests;
|
||||
|
||||
GEN9TEST_F(ImageSurfaceStateTestsGen9, givenGmmWithMediaCompressedWhenSetFlagsForMediaCompressionThenAuxiliarySurfaceNoneIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
||||
mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
|
||||
EncodeSurfaceState<FamilyType>::setFlagsForMediaCompression(castSurfaceState, &mockGmm);
|
||||
EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
||||
}
|
||||
|
||||
GEN9TEST_F(ImageSurfaceStateTestsGen9, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) {
|
||||
auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE);
|
||||
auto surfaceState = std::make_unique<char[]>(size);
|
||||
auto castSurfaceState = reinterpret_cast<typename FamilyType::RENDER_SURFACE_STATE *>(surfaceState.get());
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, nullptr);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u);
|
||||
|
||||
setMipTailStartLod<FamilyType>(castSurfaceState, &mockGmm);
|
||||
|
||||
EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState());
|
||||
}
|
||||
63
shared/test/common/gen9/preamble_tests_gen9.cpp
Normal file
63
shared/test/common/gen9/preamble_tests_gen9.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/source_level_debugger/source_level_debugger_preamble_test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
typedef SKLFamily GfxFamily;
|
||||
|
||||
#include "shared/test/unit_test/source_level_debugger/source_level_debugger_preamble_test.inl"
|
||||
|
||||
using PreambleTestGen9 = ::testing::Test;
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenMidThreadPreemptionAndDebuggingActiveWhenStateSipIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDebuggingActiveWhenStateSipIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsProgrammedThenCorrectSipKernelIsUsed) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturned) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreInlcuded) {
|
||||
SourceLevelDebuggerPreambleTest<FamilyType>::givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreInlcudedTest();
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleTestGen9, givenGen9IsL3Programing) {
|
||||
bool l3ConfigDifference;
|
||||
bool isL3Programmable;
|
||||
|
||||
l3ConfigDifference =
|
||||
PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true) !=
|
||||
PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, false);
|
||||
isL3Programmable =
|
||||
PreambleHelper<FamilyType>::isL3Configurable(*defaultHwInfo);
|
||||
|
||||
EXPECT_EQ(l3ConfigDifference, isL3Programmable);
|
||||
}
|
||||
16
shared/test/common/gen9/simd_helper_tests_gen9.cpp
Normal file
16
shared/test/common/gen9/simd_helper_tests_gen9.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/simd_helper_tests.inl"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using TestSimdConfigSet = ::testing::Test;
|
||||
|
||||
GEN9TEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedGen9) {
|
||||
GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned<typename FamilyType::GPGPU_WALKER>::TestBodyImpl();
|
||||
}
|
||||
12
shared/test/common/gen9/skl/CMakeLists.txt
Normal file
12
shared/test/common/gen9/skl/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_TESTS_GEN9_SKL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_skl.cpp
|
||||
)
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_TESTS_GEN9_SKL ${NEO_CORE_TESTS_GEN9_SKL})
|
||||
add_subdirectories()
|
||||
144
shared/test/common/gen9/skl/test_preamble_skl.cpp
Normal file
144
shared/test/common/gen9/skl/test_preamble_skl.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/command_stream/thread_arbitration_policy.h"
|
||||
#include "shared/source/gen9/reg_configs.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/preamble/preamble_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef PreambleFixture SklSlm;
|
||||
|
||||
SKLTEST_F(SklSlm, WhenL3ConfigIsDispatchedThenProperRegisterAddressAndValueAreProgrammed) {
|
||||
typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
|
||||
|
||||
PreambleHelper<SKLFamily>::programL3(&cs, l3Config);
|
||||
|
||||
parseCommands<SKLFamily>(cs);
|
||||
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorLRI);
|
||||
|
||||
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
auto RegisterOffset = L3CNTLRegisterOffset<FamilyType>::registerOffset;
|
||||
EXPECT_EQ(RegisterOffset, lri.getRegisterOffset());
|
||||
EXPECT_EQ(1u, lri.getDataDword() & 1);
|
||||
}
|
||||
|
||||
typedef PreambleFixture Gen9L3Config;
|
||||
|
||||
SKLTEST_F(Gen9L3Config, GivenNoSlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
||||
bool slmUsed = false;
|
||||
uint32_t l3Config = 0;
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_SKYLAKE>(slmUsed);
|
||||
EXPECT_EQ(0x80000340u, l3Config);
|
||||
|
||||
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_BROXTON>(slmUsed);
|
||||
EXPECT_EQ(0x80000340u, l3Config);
|
||||
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
}
|
||||
|
||||
SKLTEST_F(Gen9L3Config, GivenSlmWhenProgrammingL3ThenProgrammingIsCorrect) {
|
||||
bool slmUsed = true;
|
||||
uint32_t l3Config = 0;
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_SKYLAKE>(slmUsed);
|
||||
EXPECT_EQ(0x60000321u, l3Config);
|
||||
|
||||
uint32_t errorDetectionBehaviorControlBit = 1 << 9;
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
|
||||
l3Config = getL3ConfigHelper<IGFX_BROXTON>(slmUsed);
|
||||
EXPECT_EQ(0x60000321u, l3Config);
|
||||
|
||||
EXPECT_TRUE((l3Config & errorDetectionBehaviorControlBit) != 0);
|
||||
}
|
||||
|
||||
typedef PreambleFixture ThreadArbitration;
|
||||
SKLTEST_F(ThreadArbitration, givenPreambleWhenItIsProgrammedThenThreadArbitrationIsSetToRoundRobin) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
typedef SKLFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
typedef SKLFamily::PIPE_CONTROL PIPE_CONTROL;
|
||||
LinearStream &cs = linearStream;
|
||||
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(*defaultHwInfo, true);
|
||||
MockDevice mockDevice;
|
||||
PreambleHelper<SKLFamily>::programPreamble(&linearStream, mockDevice, l3Config,
|
||||
ThreadArbitrationPolicy::RoundRobin,
|
||||
nullptr);
|
||||
|
||||
parseCommands<SKLFamily>(cs);
|
||||
|
||||
auto ppC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(ppC, cmdList.end());
|
||||
|
||||
auto itorLRI = reverse_find<MI_LOAD_REGISTER_IMM *>(cmdList.rbegin(), cmdList.rend());
|
||||
ASSERT_NE(cmdList.rend(), itorLRI);
|
||||
|
||||
const auto &lri = *reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
EXPECT_EQ(0xE404u, lri.getRegisterOffset());
|
||||
EXPECT_EQ(0x100u, lri.getDataDword());
|
||||
|
||||
MockDevice device;
|
||||
EXPECT_EQ(0u, PreambleHelper<SKLFamily>::getAdditionalCommandsSize(device));
|
||||
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM) + sizeof(PIPE_CONTROL), PreambleHelper<SKLFamily>::getThreadArbitrationCommandsSize());
|
||||
}
|
||||
|
||||
SKLTEST_F(ThreadArbitration, GivenDefaultWhenProgrammingPreambleThenArbitrationPolicyIsRoundRobin) {
|
||||
EXPECT_EQ(ThreadArbitrationPolicy::RoundRobin, HwHelperHw<SKLFamily>::get().getDefaultThreadArbitrationPolicy());
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
||||
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 0;
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<FamilyType>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_FALSE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
GEN9TEST_F(PreambleVfeState, GivenWaOnWhenProgrammingVfeStateThenProgrammingIsCorrect) {
|
||||
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
||||
testWaTable->waSendMIFLUSHBeforeVFE = 1;
|
||||
LinearStream &cs = linearStream;
|
||||
PreambleHelper<FamilyType>::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u,
|
||||
aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable,
|
||||
KernelExecutionType::NotApplicable);
|
||||
|
||||
parseCommands<FamilyType>(cs);
|
||||
|
||||
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPC);
|
||||
|
||||
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
||||
EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDepthCacheFlushEnable());
|
||||
EXPECT_TRUE(pc.getDcFlushEnable());
|
||||
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
||||
}
|
||||
71
shared/test/common/gen9/test_command_encoder_gen9.cpp
Normal file
71
shared/test/common/gen9/test_command_encoder_gen9.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/cmdcontainer.h"
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "reg_configs_common.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderTest = Test<DeviceFixture>;
|
||||
|
||||
GEN9TEST_F(CommandEncoderTest, appendsASetMMIO) {
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
ASSERT_NE(itorLRI, commands.end());
|
||||
}
|
||||
|
||||
GEN9TEST_F(CommandEncoderTest, givenNoSLMSetCorrectMMIO) {
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
ASSERT_NE(itorLRI, commands.end());
|
||||
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
auto expectedData = PreambleHelper<FamilyType>::isL3Configurable(cmdContainer.getDevice()->getHardwareInfo()) ? 0x80000340u : 0x60000321u;
|
||||
EXPECT_EQ(cmd->getRegisterOffset(), 0x7034u);
|
||||
EXPECT_EQ(cmd->getDataDword(), expectedData);
|
||||
}
|
||||
|
||||
GEN9TEST_F(CommandEncoderTest, givenSLMSetCorrectMMIO) {
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
EncodeL3State<FamilyType>::encode(cmdContainer, true);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
||||
ASSERT_NE(itorLRI, commands.end());
|
||||
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
||||
EXPECT_EQ(cmd->getRegisterOffset(), 0x7034u);
|
||||
EXPECT_EQ(cmd->getDataDword(), 0x60000321u);
|
||||
}
|
||||
|
||||
using Gen9CommandEncodeTest = testing::Test;
|
||||
|
||||
GEN9TEST_F(Gen9CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::miArbCheckWaRequired());
|
||||
}
|
||||
66
shared/test/common/gen9/test_encode_math_gen9.cpp
Normal file
66
shared/test/common/gen9/test_encode_math_gen9.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncoderMathTestGen9 = Test<DeviceFixture>;
|
||||
|
||||
GEN9TEST_F(CommandEncoderMathTestGen9, WhenAppendsAGreaterThanThenPredicateCorrectlySet) {
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_MATH = typename FamilyType::MI_MATH;
|
||||
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itor = commands.begin();
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
||||
EXPECT_EQ(cmdMEM->getRegisterAddress(), CS_GPR_R0);
|
||||
EXPECT_EQ(cmdMEM->getMemoryAddress(), 0xDEADBEEFCAF0u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R1);
|
||||
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
||||
|
||||
itor = find<MI_MATH *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
||||
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
||||
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
||||
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
||||
|
||||
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
||||
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
||||
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
||||
}
|
||||
159
shared/test/common/gen9/test_preemption_gen9.cpp
Normal file
159
shared/test/common/gen9/test_preemption_gen9.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
template <>
|
||||
PreemptionTestHwDetails GetPreemptionTestHwDetails<SKLFamily>() {
|
||||
PreemptionTestHwDetails ret;
|
||||
ret.modeToRegValueMap[PreemptionMode::ThreadGroup] = DwordBuilder::build(1, true) | DwordBuilder::build(2, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidBatch] = DwordBuilder::build(2, true) | DwordBuilder::build(1, true, false);
|
||||
ret.modeToRegValueMap[PreemptionMode::MidThread] = DwordBuilder::build(2, true, false) | DwordBuilder::build(1, true, false);
|
||||
ret.defaultRegValue = ret.modeToRegValueMap[PreemptionMode::MidBatch];
|
||||
ret.regAddress = 0x2580u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
using Gen9PreemptionTests = DevicePreemptionTests;
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, whenMidThreadPreemptionIsNotAvailableThenDoesNotProgramPreamble) {
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
|
||||
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
EXPECT_EQ(0U, requiredSize);
|
||||
|
||||
LinearStream cmdStream{nullptr, 0};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
EXPECT_EQ(0U, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, whenMidThreadPreemptionIsAvailableThenStateSipIsProgrammed) {
|
||||
using STATE_SIP = typename FamilyType::STATE_SIP;
|
||||
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
executionEnvironment->DisableMidThreadPreemption = 0;
|
||||
|
||||
size_t minCsrSize = device->getHardwareInfo().gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
|
||||
uint64_t minCsrAlignment = 2 * 256 * MemoryConstants::kiloByte;
|
||||
MockGraphicsAllocation csrSurface((void *)minCsrAlignment, minCsrSize);
|
||||
|
||||
size_t requiredCmdStreamSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
size_t expectedPreambleSize = sizeof(STATE_SIP);
|
||||
EXPECT_EQ(expectedPreambleSize, requiredCmdStreamSize);
|
||||
|
||||
StackVec<char, 8192> streamStorage(requiredCmdStreamSize);
|
||||
ASSERT_LE(requiredCmdStreamSize, streamStorage.size());
|
||||
|
||||
LinearStream cmdStream{streamStorage.begin(), streamStorage.size()};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
|
||||
HardwareParse hwParsePreamble;
|
||||
hwParsePreamble.parseCommands<FamilyType>(cmdStream);
|
||||
|
||||
auto stateSipCmd = hwParsePreamble.getCommand<STATE_SIP>();
|
||||
ASSERT_NE(nullptr, stateSipCmd);
|
||||
EXPECT_EQ(device->getBuiltIns()->getSipKernel(SipKernelType::Csr, *device).getSipAllocation()->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenMidBatchPreemptionWhenProgrammingWaCmdsBeginThenExpectNoCmds) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::MidBatch);
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenThreadGroupPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenThreadGroupPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectCmd) {
|
||||
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM);
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionNoWaSetWhenProgrammingWaCmdsBeginThenExpectNoCmd) {
|
||||
size_t expectedSize = 0;
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = false;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionWaSetWhenProgrammingWaCmdsBeginThenExpectCmd) {
|
||||
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
size_t expectedSize = 2 * sizeof(MI_LOAD_REGISTER_IMM);
|
||||
device->setPreemptionMode(PreemptionMode::MidThread);
|
||||
device->getRootDeviceEnvironment().getMutableHardwareInfo()->workaroundTable.waModifyVFEStateAfterGPGPUPreemption = true;
|
||||
size_t size = PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device);
|
||||
EXPECT_EQ(expectedSize, size);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenInterfaceDescriptorDataWhenAnyPreemptionModeThenNoChange) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA idd;
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
int ret;
|
||||
|
||||
idd = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::Disabled);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidBatch);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::ThreadGroup);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidThread);
|
||||
ret = memcmp(&idd, &iddArg, sizeof(INTERFACE_DESCRIPTOR_DATA));
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionModeWhenStateSipIsProgrammedThenSipEqualsSipAllocationGpuAddressToPatch) {
|
||||
using STATE_SIP = typename FamilyType::STATE_SIP;
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
|
||||
mockDevice->setPreemptionMode(PreemptionMode::MidThread);
|
||||
auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*mockDevice);
|
||||
|
||||
StackVec<char, 4096> preemptionBuffer;
|
||||
preemptionBuffer.resize(cmdSizePreemptionMidThread);
|
||||
LinearStream preemptionStream(&*preemptionBuffer.begin(), preemptionBuffer.size());
|
||||
|
||||
PreemptionHelper::programStateSip<FamilyType>(preemptionStream, *mockDevice);
|
||||
|
||||
HardwareParse hwParserOnlyPreemption;
|
||||
hwParserOnlyPreemption.parseCommands<FamilyType>(preemptionStream, 0);
|
||||
auto cmd = hwParserOnlyPreemption.getCommand<STATE_SIP>();
|
||||
EXPECT_NE(nullptr, cmd);
|
||||
|
||||
auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive());
|
||||
EXPECT_EQ(mockDevice->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer());
|
||||
}
|
||||
14
shared/test/common/gen9/test_traits_gen9.h
Normal file
14
shared/test/common/gen9/test_traits_gen9.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/helpers/test_traits.h"
|
||||
|
||||
template <>
|
||||
struct TestTraits<IGFX_GEN9_CORE> {
|
||||
static constexpr bool auxBuiltinsSupported = true;
|
||||
};
|
||||
43
shared/test/common/helpers/CMakeLists.txt
Normal file
43
shared/test/common/helpers/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bindless_heaps_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager_state_restore.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_flags_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/hw_helper_extended_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_leak_listener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_management.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}/test_traits_common.h
|
||||
${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}/variable_backup.h
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/heap_assigner_shared_tests.cpp
|
||||
${NEO_CORE_HELPERS_TESTS}
|
||||
)
|
||||
281
shared/test/common/helpers/aligned_memory_tests.cpp
Normal file
281
shared/test/common/helpers/aligned_memory_tests.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
TEST(AlignedFree, GivenNullPtrWhenFreeingAlignedThenNoCrash) {
|
||||
alignedFree(nullptr);
|
||||
}
|
||||
void *ptrAlignedToPage = (void *)0x1000;
|
||||
void *ptrNotAlignedToPage = (void *)0x1001;
|
||||
|
||||
struct AlignedMalloc : public ::testing::TestWithParam<size_t> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
ptr = nullptr;
|
||||
alignAlloc = GetParam();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
alignedFree(ptr);
|
||||
}
|
||||
|
||||
void *ptr;
|
||||
size_t alignAlloc;
|
||||
};
|
||||
|
||||
TEST_P(AlignedMalloc, GivenSizeZeroWhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 0;
|
||||
ptr = alignedMalloc(sizeAlloc, alignAlloc);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % alignAlloc);
|
||||
}
|
||||
|
||||
TEST_P(AlignedMalloc, GivenSize4096WhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 4096;
|
||||
ptr = alignedMalloc(sizeAlloc, alignAlloc);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % alignAlloc);
|
||||
}
|
||||
|
||||
TEST(AlignedMallocTests, GivenSizeZeroAndAlign4096WhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 0;
|
||||
auto ptr = alignedMalloc(sizeAlloc, 4096);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % 4096);
|
||||
alignedFree(ptr);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
AlignedMallocParameterized,
|
||||
AlignedMalloc,
|
||||
testing::Values(
|
||||
1,
|
||||
4,
|
||||
8,
|
||||
64,
|
||||
4096));
|
||||
|
||||
struct AlignUp : public ::testing::TestWithParam<size_t> {
|
||||
};
|
||||
|
||||
TEST_P(AlignUp, GivenPointerBelowAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x1fffffff;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, GivenPointerAtAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x20000000;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, GivenPointerAboveAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x20000001;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, WhenAligningUpThen64BitIsPreserved) {
|
||||
uint64_t aligned = 1ULL << 48;
|
||||
auto alignment = GetParam();
|
||||
auto result = alignUp(aligned, alignment);
|
||||
EXPECT_EQ(aligned, result);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
AlignUpParameterized,
|
||||
AlignUp,
|
||||
testing::Values(
|
||||
1,
|
||||
4,
|
||||
8,
|
||||
32,
|
||||
64,
|
||||
256,
|
||||
4096));
|
||||
|
||||
TEST(AlignWholeSize, GivenSizeLessThanPageSizeWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
int size = 1;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeGreaterThanPageSizeWhenAligningWholeSizeToPageThenAlignedSizeIsMultipleOfPageSize) {
|
||||
|
||||
int size = 4097;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeGreaterThanPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsMultipleOfPageSize) {
|
||||
|
||||
int size = 4097;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
|
||||
int size = 1;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneLessThanPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
|
||||
int size = 4095;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneLessThanTwoPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsTwoPageSize) {
|
||||
|
||||
int size = 4095 + 4096;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenNonAlignedPointerThenAllocationOverlapsToAnotherPage) {
|
||||
|
||||
int size = 4096;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeofTwoPagesAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsThreePageSize) {
|
||||
|
||||
int size = 4096 * 2;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 3);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeofTwoPagesAndAlignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsTwoPageSize) {
|
||||
|
||||
int size = 4096 * 2;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrAlignedToPageWhenAligningDownToPageSizeThenReturnTheSamePointer) {
|
||||
void *ptr = (void *)0x1000;
|
||||
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(ptr, alignedDownPtr);
|
||||
}
|
||||
TEST(AlignDown, GivenPtrNotAlignedToPageWhenAligningDownToPageSizeThenPageAlignedPointerIsReturned) {
|
||||
void *ptr = (void *)0x1001;
|
||||
void *expected_ptr = (void *)0x1000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expected_ptr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToTwoPageWhenAligningDownToPageSizeThenReturnAlignedPointerToPreviousPage) {
|
||||
void *ptr = (void *)0x1241;
|
||||
void *expected_ptr = (void *)0x1000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expected_ptr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToThreePageWhenAligningDownToPageSizeThenReturnAlignedPointerToPreviousPage) {
|
||||
void *ptr = (void *)0x3241;
|
||||
void *expected_ptr = (void *)0x3000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expected_ptr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToDwordWhenAligningDownToDwordThenDwordAlignedPointerIsReturned) {
|
||||
void *ptr = (void *)0x3241;
|
||||
void *expected_ptr = (void *)0x3240;
|
||||
auto alignedDownPtr = alignDown(ptr, 4);
|
||||
EXPECT_EQ(expected_ptr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, WhenAligningDownThen64BitIsPreserved) {
|
||||
uint64_t aligned = 1ULL << 48;
|
||||
auto result = alignDown(aligned, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(aligned, result);
|
||||
}
|
||||
|
||||
TEST(DLLbitness, Given32or64BitLibraryWhenAskedIfItIs32BitThenProperValueIsReturned) {
|
||||
auto pointerSize = sizeof(void *);
|
||||
if (pointerSize == 8) {
|
||||
EXPECT_FALSE(is32bit);
|
||||
EXPECT_TRUE(is64bit);
|
||||
} else if (pointerSize == 4) {
|
||||
EXPECT_TRUE(is32bit);
|
||||
EXPECT_FALSE(is64bit);
|
||||
} else {
|
||||
FAIL() << "unrecognized bitness";
|
||||
}
|
||||
auto pointerSizeFromSizeT = sizeof(size_t);
|
||||
if (pointerSizeFromSizeT == 8) {
|
||||
EXPECT_FALSE(is32bit);
|
||||
EXPECT_TRUE(is64bit);
|
||||
} else if (pointerSizeFromSizeT == 4) {
|
||||
EXPECT_TRUE(is32bit);
|
||||
EXPECT_FALSE(is64bit);
|
||||
} else {
|
||||
FAIL() << "unrecognized bitness";
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class IsAlignedTests : public ::testing::Test {
|
||||
};
|
||||
|
||||
typedef ::testing::Types<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double> IsAlignedTypes;
|
||||
|
||||
TYPED_TEST_CASE(IsAlignedTests, IsAlignedTypes);
|
||||
TYPED_TEST(IsAlignedTests, WhenCheckingForAlignmentThenReturnCorrectValue) {
|
||||
TypeParam *ptr = reinterpret_cast<TypeParam *>(static_cast<uintptr_t>(0xdeadbeefu));
|
||||
// one byte alignment should always return true
|
||||
if (alignof(TypeParam) == 1)
|
||||
EXPECT_TRUE(isAligned(ptr));
|
||||
else
|
||||
EXPECT_FALSE(isAligned(ptr));
|
||||
|
||||
auto ptr1 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~(alignof(TypeParam) - 1));
|
||||
EXPECT_TRUE(isAligned(ptr1));
|
||||
|
||||
auto ptr2 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~((alignof(TypeParam) << 1) - 1));
|
||||
EXPECT_TRUE(isAligned(ptr2));
|
||||
|
||||
// this is hard to align in the middle of byte aligned types
|
||||
if (alignof(TypeParam) == 1)
|
||||
return;
|
||||
|
||||
auto ptr3 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~((alignof(TypeParam) >> 1) - 1));
|
||||
EXPECT_FALSE(isAligned(ptr3));
|
||||
}
|
||||
|
||||
TEST(IsAligned, GivenNonPointerTypeWhenCheckingForAlignmentThenReturnIsCorrect) {
|
||||
EXPECT_TRUE(isAligned<3>(0));
|
||||
EXPECT_FALSE(isAligned<3>(1));
|
||||
EXPECT_FALSE(isAligned<3>(2));
|
||||
EXPECT_TRUE(isAligned<3>(3));
|
||||
EXPECT_FALSE(isAligned<3>(4));
|
||||
EXPECT_FALSE(isAligned<3>(5));
|
||||
EXPECT_TRUE(isAligned<3>(6));
|
||||
}
|
||||
|
||||
TEST(IsAligned, WhenUsingConstexprEvaluationThenResultIsCorrect) {
|
||||
static_assert(false == isAligned<3>(2), "");
|
||||
static_assert(true == isAligned<3>(3), "");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
|
||||
namespace NEO {
|
||||
bool ApiSpecificConfig::getHeapConfiguration() {
|
||||
return DebugManager.flags.UseExternalAllocatorForSshAndDsh.get();
|
||||
}
|
||||
bool ApiSpecificConfig::getBindlessConfiguration() {
|
||||
if (DebugManager.flags.UseBindlessMode.get() != -1) {
|
||||
return DebugManager.flags.UseBindlessMode.get();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
194
shared/test/common/helpers/bindless_heaps_helper_tests.cpp
Normal file
194
shared/test/common/helpers/bindless_heaps_helper_tests.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||
#include "shared/test/common/fixtures/front_window_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(BindlessHeapsHelper, givenBindlessModeFlagEnabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
EXPECT_NE(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr);
|
||||
}
|
||||
|
||||
TEST(BindlessHeapsHelper, givenBindlessModeFlagDisabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(0);
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
EXPECT_EQ(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr);
|
||||
}
|
||||
|
||||
using BindlessHeapsHelperTests = Test<MemManagerFixture>;
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenItsCreatedThenSpecialSshAllocatedAtHeapBegining) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
auto specialSshAllocation = bindlessHeapHelper->specialSsh->getGraphicsAllocation();
|
||||
EXPECT_EQ(specialSshAllocation->getGpuAddress(), specialSshAllocation->getGpuBaseAddress());
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenHeapUsedSpaceGrow) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
auto usedBefore = bindlessHeapHelper->globalSsh->getUsed();
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto usedAfter = bindlessHeapHelper->globalSsh->getUsed();
|
||||
EXPECT_GT(usedAfter, usedBefore);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenMemoryAtReturnedOffsetIsCorrect) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
auto allocInHeapPtr = bindlessHeapHelper->globalSsh->getGraphicsAllocation()->getUnderlyingBuffer();
|
||||
EXPECT_EQ(ssInHeapInfo.ssPtr, allocInHeapPtr);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForTheSameAllocationThenTheSameOffsetReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo1 = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto ssInHeapInfo2 = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
EXPECT_EQ(ssInHeapInfo1.surfaceStateOffset, ssInHeapInfo2.surfaceStateOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForDifferentAllocationThenDifferentOffsetsReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
|
||||
MockGraphicsAllocation alloc1;
|
||||
MockGraphicsAllocation alloc2;
|
||||
size_t size = 0x40;
|
||||
auto ss = std::make_unique<uint8_t[]>(size);
|
||||
memset(ss.get(), 35, size);
|
||||
auto ssInHeapInfo1 = bindlessHeapHelper->allocateSSInHeap(size, &alloc1, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto ssInHeapInfo2 = bindlessHeapHelper->allocateSSInHeap(size, &alloc2, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
EXPECT_NE(ssInHeapInfo1.surfaceStateOffset, ssInHeapInfo2.surfaceStateOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThenNewHeapAllocationCreated) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
size_t ssSize = 0x40;
|
||||
auto ssCount = bindlessHeapHelper->globalSsh->getAvailableSpace() / ssSize;
|
||||
auto graphicsAllocations = std::make_unique<MockGraphicsAllocation[]>(ssCount);
|
||||
auto ssAllocationBefore = bindlessHeapHelper->globalSsh->getGraphicsAllocation();
|
||||
for (uint32_t i = 0; i < ssCount; i++) {
|
||||
bindlessHeapHelper->allocateSSInHeap(ssSize, &graphicsAllocations[i], BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
}
|
||||
MockGraphicsAllocation alloc;
|
||||
bindlessHeapHelper->allocateSSInHeap(ssSize, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
auto ssAllocationAfter = bindlessHeapHelper->globalSsh->getGraphicsAllocation();
|
||||
|
||||
EXPECT_NE(ssAllocationBefore, ssAllocationAfter);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenCreatedThenAllocationsHaveTheSameBaseAddress) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
for (auto allocation : bindlessHeapHelper->ssHeapsAllocations) {
|
||||
EXPECT_EQ(allocation->getGpuBaseAddress(), bindlessHeapHelper->getGlobalHeapsBase());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetDefaultBorderColorOffsetCalledThenCorrectOffsetReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress();
|
||||
EXPECT_EQ(bindlessHeapHelper->getDefaultBorderColorOffset(), expectedOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetAlphaBorderColorOffsetCalledThenCorrectOffsetReturned) {
|
||||
auto borderColorSize = 0x40;
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress() + borderColorSize;
|
||||
EXPECT_EQ(bindlessHeapHelper->getAlphaBorderColorOffset(), expectedOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SPECIAL_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SCRATCH_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDshThenOffsetGreaterOrEqualFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_GE(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIsCalledThenSSinHeapInfoShouldBePlacedInReuseVector) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get();
|
||||
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release());
|
||||
MockGraphicsAllocation *alloc = new MockGraphicsAllocation;
|
||||
size_t size = 0x40;
|
||||
auto ssinHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
memManager->freeGraphicsMemory(alloc);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 1u);
|
||||
auto ssInHeapInfoFromReuseVector = bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.front().get();
|
||||
EXPECT_EQ(ssInHeapInfoFromReuseVector->surfaceStateOffset, ssinHeapInfo.surfaceStateOffset);
|
||||
EXPECT_EQ(ssInHeapInfoFromReuseVector->ssPtr, ssinHeapInfo.ssPtr);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperPreviousAllocationThenItShouldBeReused) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get();
|
||||
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release());
|
||||
MockGraphicsAllocation *alloc = new MockGraphicsAllocation;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
memManager->freeGraphicsMemory(alloc);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 1u);
|
||||
MockGraphicsAllocation *alloc2 = new MockGraphicsAllocation;
|
||||
auto reusedSSinHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc2, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 0u);
|
||||
EXPECT_EQ(ssInHeapInfo.surfaceStateOffset, reusedSSinHeapInfo.surfaceStateOffset);
|
||||
EXPECT_EQ(ssInHeapInfo.ssPtr, reusedSSinHeapInfo.ssPtr);
|
||||
memManager->freeGraphicsMemory(alloc2);
|
||||
}
|
||||
539
shared/test/common/helpers/blit_commands_helper_tests.cpp
Normal file
539
shared/test/common/helpers/blit_commands_helper_tests.cpp
Normal file
@@ -0,0 +1,539 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(BlitCommandsHelperTest, GivenBufferParamsWhenConstructingPropertiesForBufferRegionsThenPropertiesCreatedCorrectly) {
|
||||
uint32_t src[] = {1, 2, 3, 4};
|
||||
uint32_t dst[] = {4, 3, 2, 1};
|
||||
uint32_t clear[] = {5, 6, 7, 8};
|
||||
uint64_t srcGpuAddr = 0x12345;
|
||||
uint64_t dstGpuAddr = 0x54321;
|
||||
uint64_t clearGpuAddr = 0x5678;
|
||||
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
|
||||
std::unique_ptr<MockGraphicsAllocation> dstAlloc(new MockGraphicsAllocation(dst, dstGpuAddr, sizeof(dst)));
|
||||
std::unique_ptr<GraphicsAllocation> clearColorAllocation(new MockGraphicsAllocation(clear, clearGpuAddr, sizeof(clear)));
|
||||
|
||||
Vec3<size_t> srcOffsets{1, 2, 3};
|
||||
Vec3<size_t> dstOffsets{3, 2, 1};
|
||||
Vec3<size_t> copySize{2, 2, 2};
|
||||
|
||||
size_t srcRowPitch = 2;
|
||||
size_t srcSlicePitch = 3;
|
||||
|
||||
size_t dstRowPitch = 2;
|
||||
size_t dstSlicePitch = 3;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopyBuffer(dstAlloc.get(), srcAlloc.get(),
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, clearColorAllocation.get());
|
||||
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::BufferToBuffer);
|
||||
EXPECT_EQ(blitProperties.dstAllocation, dstAlloc.get());
|
||||
EXPECT_EQ(blitProperties.srcAllocation, srcAlloc.get());
|
||||
EXPECT_EQ(blitProperties.clearColorAllocation, clearColorAllocation.get());
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, dstGpuAddr);
|
||||
EXPECT_EQ(blitProperties.srcGpuAddress, srcGpuAddr);
|
||||
EXPECT_EQ(blitProperties.copySize, copySize);
|
||||
EXPECT_EQ(blitProperties.dstOffset, dstOffsets);
|
||||
EXPECT_EQ(blitProperties.srcOffset, srcOffsets);
|
||||
EXPECT_EQ(blitProperties.dstRowPitch, dstRowPitch);
|
||||
EXPECT_EQ(blitProperties.dstSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(blitProperties.srcRowPitch, srcRowPitch);
|
||||
EXPECT_EQ(blitProperties.srcSlicePitch, srcSlicePitch);
|
||||
}
|
||||
|
||||
TEST(BlitCommandsHelperTest, GivenCopySizeYAndZEqual0WhenConstructingPropertiesForBufferRegionsThenCopyZAndZEqual1) {
|
||||
uint32_t src[] = {1, 2, 3, 4};
|
||||
uint32_t dst[] = {4, 3, 2, 1};
|
||||
uint32_t clear[] = {5, 6, 7, 8};
|
||||
uint64_t srcGpuAddr = 0x12345;
|
||||
uint64_t dstGpuAddr = 0x54321;
|
||||
uint64_t clearGpuAddr = 0x5678;
|
||||
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
|
||||
std::unique_ptr<MockGraphicsAllocation> dstAlloc(new MockGraphicsAllocation(dst, dstGpuAddr, sizeof(dst)));
|
||||
std::unique_ptr<GraphicsAllocation> clearColorAllocation(new MockGraphicsAllocation(clear, clearGpuAddr, sizeof(clear)));
|
||||
Vec3<size_t> srcOffsets{1, 2, 3};
|
||||
Vec3<size_t> dstOffsets{3, 2, 1};
|
||||
Vec3<size_t> copySize{2, 0, 0};
|
||||
|
||||
size_t srcRowPitch = 2;
|
||||
size_t srcSlicePitch = 3;
|
||||
|
||||
size_t dstRowPitch = 2;
|
||||
size_t dstSlicePitch = 3;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopyBuffer(dstAlloc.get(), srcAlloc.get(),
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, clearColorAllocation.get());
|
||||
Vec3<size_t> expectedSize{copySize.x, 1, 1};
|
||||
EXPECT_EQ(blitProperties.copySize, expectedSize);
|
||||
}
|
||||
|
||||
using BlitTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariablesWhenGettingMaxBlitSizeThenHonorUseProvidedValues) {
|
||||
DebugManagerStateRestore restore{};
|
||||
|
||||
ASSERT_EQ(BlitterConstants::maxBlitWidth, BlitCommandsHelper<FamilyType>::getMaxBlitWidth(pDevice->getRootDeviceEnvironment()));
|
||||
ASSERT_EQ(BlitterConstants::maxBlitHeight, BlitCommandsHelper<FamilyType>::getMaxBlitHeight(pDevice->getRootDeviceEnvironment()));
|
||||
|
||||
DebugManager.flags.LimitBlitterMaxWidth.set(50);
|
||||
EXPECT_EQ(50u, BlitCommandsHelper<FamilyType>::getMaxBlitWidth(pDevice->getRootDeviceEnvironment()));
|
||||
|
||||
DebugManager.flags.LimitBlitterMaxHeight.set(60);
|
||||
EXPECT_EQ(60u, BlitCommandsHelper<FamilyType>::getMaxBlitHeight(pDevice->getRootDeviceEnvironment()));
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariableWhenEstimatingPostBlitsCommandSizeThenReturnCorrectResult) {
|
||||
const size_t arbCheckSize = sizeof(typename FamilyType::MI_ARB_CHECK);
|
||||
|
||||
DebugManagerStateRestore restore{};
|
||||
|
||||
size_t expectedDefaultSize = arbCheckSize;
|
||||
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
expectedDefaultSize += EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
|
||||
}
|
||||
|
||||
EXPECT_EQ(expectedDefaultSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck);
|
||||
EXPECT_EQ(arbCheckSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush);
|
||||
EXPECT_EQ(EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite(), BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None);
|
||||
EXPECT_EQ(0u, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorrectCommands) {
|
||||
using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK;
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
DebugManagerStateRestore restore{};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream linearStream{streamBuffer, sizeof(streamBuffer)};
|
||||
GenCmdList commands{};
|
||||
|
||||
size_t expectedDefaultSize = sizeof(MI_ARB_CHECK);
|
||||
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
expectedDefaultSize += EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
|
||||
}
|
||||
|
||||
// -1: default
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
|
||||
EXPECT_EQ(expectedDefaultSize, linearStream.getUsed());
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
|
||||
auto iterator = commands.begin();
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
iterator = find<MI_FLUSH_DW *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), iterator);
|
||||
if (EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(MI_FLUSH_DW)) {
|
||||
iterator = find<MI_FLUSH_DW *>(++iterator, commands.end());
|
||||
EXPECT_NE(commands.end(), iterator);
|
||||
}
|
||||
}
|
||||
|
||||
auto arbCheck = find<MI_ARB_CHECK *>(iterator, commands.end());
|
||||
EXPECT_NE(commands.end(), arbCheck);
|
||||
|
||||
// 0: MI_ARB_CHECK
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
arbCheck = find<MI_ARB_CHECK *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), arbCheck);
|
||||
|
||||
// 1: MI_FLUSH_DW
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
auto miFlush = find<MI_FLUSH_DW *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), miFlush);
|
||||
|
||||
// 2: Nothing
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream);
|
||||
EXPECT_EQ(0u, linearStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemoryWhenFillPatternWithBlitThenCommandIsProgrammed) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeBiggerThanMaxWidthButLessThanTwiceMaxWidthWhenFillPatternWithBlitThenHeightIsOne) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth) - 1,
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getTransferHeight(), 1u);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBlitThenHeightIsTwo) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth * sizeof(uint32_t)),
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getTransferHeight(), 2u);
|
||||
EXPECT_EQ(cmd->getDestinationPitch(), BlitterConstants::maxBlitWidth);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeIsLessThanTwicenMaxWidthWhenFillPatternWithBlitThenHeightIsOne) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, ((BlitterConstants::maxBlitWidth + 1) * sizeof(uint32_t)),
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getTransferHeight(), 1u);
|
||||
}
|
||||
}
|
||||
|
||||
using BlitColor = IsWithinProducts<IGFX_SKYLAKE, IGFX_ICELAKE_LP>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemoryWhenFillPatternSizeIs4BytesThen32BitMaskISSetCorrectly, BlitColor) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, mockMaxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, &pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(XY_COLOR_BLT::_32BPP_BYTE_MASK::_32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL, cmd->get32BppByteMask());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getColorDepth(size_t patternSize) {
|
||||
using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
COLOR_DEPTH depth = {};
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR;
|
||||
break;
|
||||
case 2:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR1555;
|
||||
break;
|
||||
case 4:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR;
|
||||
break;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualOneWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 1;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualTwoWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 2;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualFourWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 4;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
|
||||
using BlitPlatforms = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
|
||||
template <typename FamilyType>
|
||||
typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getFastColorDepth(size_t patternSize) {
|
||||
using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
COLOR_DEPTH depth = {};
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR;
|
||||
break;
|
||||
case 2:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR;
|
||||
break;
|
||||
case 4:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR;
|
||||
break;
|
||||
case 8:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR;
|
||||
break;
|
||||
case 16:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR;
|
||||
break;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
using BlitFastColorTest = BlitColorTests;
|
||||
|
||||
HWTEST2_P(BlitFastColorTest, givenCommandStreamWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, IsGen12LP) {
|
||||
auto patternSize = GetParam();
|
||||
auto expecttedDepth = getFastColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(size_t,
|
||||
BlitFastColorTest,
|
||||
testing::Values(1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16));
|
||||
HWTEST2_F(BlitTests, givenMemoryAndImageWhenDispatchCopyImageCallThenCommandAddedToStream, BlitPlatforms) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
MockGraphicsAllocation srcAlloc;
|
||||
MockGraphicsAllocation dstAlloc;
|
||||
MockGraphicsAllocation clearColorAllocation;
|
||||
|
||||
Vec3<size_t> dstOffsets = {0, 0, 0};
|
||||
Vec3<size_t> srcOffsets = {0, 0, 0};
|
||||
|
||||
Vec3<size_t> copySize = {0x100, 0x40, 0x1};
|
||||
Vec3<uint32_t> srcSize = {0x100, 0x40, 0x1};
|
||||
Vec3<uint32_t> dstSize = {0x100, 0x40, 0x1};
|
||||
|
||||
uint32_t srcRowPitch = srcSize.x;
|
||||
uint32_t srcSlicePitch = srcSize.y;
|
||||
uint32_t dstRowPitch = dstSize.x;
|
||||
uint32_t dstSlicePitch = dstSize.y;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopyBuffer(&dstAlloc, &srcAlloc,
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, &clearColorAllocation);
|
||||
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
blitProperties.bytesPerPixel = 4;
|
||||
blitProperties.srcSize = srcSize;
|
||||
blitProperties.dstSize = dstSize;
|
||||
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsRegion(blitProperties, stream, *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COPY_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen9AndGetBlitAllocationPropertiesThenCorrectValuesAreReturned, IsGen9) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
uint32_t pitch = 0x10;
|
||||
uint32_t qPitch = 0x20;
|
||||
GMM_TILE_TYPE tileType = GMM_NOT_TILED;
|
||||
uint32_t mipTailLod = 0;
|
||||
|
||||
auto expectedPitch = pitch;
|
||||
auto expectedQPitch = qPitch;
|
||||
auto expectedtileType = tileType;
|
||||
auto expectedMipTailLod = mipTailLod;
|
||||
auto compressionDetails = 0u;
|
||||
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails, pDevice->getRootDeviceEnvironment());
|
||||
|
||||
EXPECT_EQ(expectedPitch, pitch);
|
||||
EXPECT_EQ(expectedQPitch, qPitch);
|
||||
EXPECT_EQ(expectedtileType, tileType);
|
||||
EXPECT_EQ(expectedMipTailLod, mipTailLod);
|
||||
}
|
||||
|
||||
using BlitTestsParams = BlitColorTests;
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenCopySizeAlignedWithin1and16ByteWhenGettingBytesPerPixelThenCorectPixelSizeReturned, BlitPlatforms) {
|
||||
size_t copySize = 33;
|
||||
auto aligment = GetParam();
|
||||
copySize = alignUp(copySize, aligment);
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcOrigin = dstOrigin = 0;
|
||||
srcSize = dstSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, aligment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenSrcSizeAlignedWithin1and16ByteWhenGettingBytesPerPixelThenCorectPixelSizeReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto aligment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcSize = 33;
|
||||
srcSize = alignUp(srcSize, aligment);
|
||||
srcOrigin = dstOrigin = dstSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, aligment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDstSizeAlignedWithin1and16ByteWhenGettingBytesPerPixelThenCorectPixelSizeReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto aligment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstSize = 33;
|
||||
dstSize = alignUp(dstSize, aligment);
|
||||
srcOrigin = dstOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, aligment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenSrcOriginAlignedWithin1and16ByteWhenGettingBytesPerPixelThenCorectPixelSizeReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto aligment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcOrigin = 33;
|
||||
srcOrigin = alignUp(srcOrigin, aligment);
|
||||
dstSize = dstOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, aligment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDrcOriginAlignedWithin1and16ByteWhenGettingBytesPerPixelThenCorectPixelSizeReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto aligment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstOrigin = 33;
|
||||
dstOrigin = alignUp(dstOrigin, aligment);
|
||||
dstSize = srcOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, aligment);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(size_t,
|
||||
BlitTestsParams,
|
||||
testing::Values(1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16));
|
||||
|
||||
HWTEST2_F(BlitTests, givenAllocWidthGreaterThanMaxBlitWidthWhenCheckingIfOneCommandCanBeUsedThenFalseReturned, BlitPlatforms) {
|
||||
uint32_t bytesPerPixel = 1;
|
||||
Vec3<size_t> copySize = {BlitterConstants::maxBlitWidth + 1, 1, 1};
|
||||
bool useOneCommand = NEO::BlitCommandsHelper<FamilyType>::useOneBlitCopyCommand(copySize, bytesPerPixel);
|
||||
EXPECT_FALSE(useOneCommand);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenAllocHeightGreaterThanMaxBlitHeightWhenCheckingIfOneCommandCanBeUsedThenFalseReturned, BlitPlatforms) {
|
||||
uint32_t bytesPerPixel = 1;
|
||||
Vec3<size_t> copySize = {0x10, BlitterConstants::maxBlitHeight + 1, 1};
|
||||
bool useOneCommand = NEO::BlitCommandsHelper<FamilyType>::useOneBlitCopyCommand(copySize, bytesPerPixel);
|
||||
EXPECT_FALSE(useOneCommand);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenAllocDimsLowerThanMaxSizesWhenCheckingIfOneCommandCanBeUsedThenTrueReturned, BlitPlatforms) {
|
||||
uint32_t bytesPerPixel = 1;
|
||||
Vec3<size_t> copySize = {BlitterConstants::maxBlitWidth - 1, BlitterConstants::maxBlitHeight - 1, 1};
|
||||
bool useOneCommand = NEO::BlitCommandsHelper<FamilyType>::useOneBlitCopyCommand(copySize, bytesPerPixel);
|
||||
EXPECT_TRUE(useOneCommand);
|
||||
}
|
||||
|
||||
using WithoutGen12Lp = IsNotGfxCore<IGFX_GEN12LP_CORE>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingPreBlitCommandWARequiredThenReturnsFalse, WithoutGen12Lp) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::preBlitCommandWARequired());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingEstimatePreBlitCommandSizeThenZeroIsReturned, WithoutGen12Lp) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
EXPECT_EQ(0u, BlitCommandsHelper<FamilyType>::estimatePreBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingDispatchPreBlitCommandThenNoneMiFlushDwIsProgramed, WithoutGen12Lp) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
auto miFlushBuffer = std::make_unique<MI_FLUSH_DW>();
|
||||
LinearStream linearStream(miFlushBuffer.get(), EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite());
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchPreBlitCommand(linearStream);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(linearStream);
|
||||
auto cmdIterator = find<typename FamilyType::MI_FLUSH_DW *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_EQ(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
53
shared/test/common/helpers/blit_commands_helper_tests.inl
Normal file
53
shared/test/common/helpers/blit_commands_helper_tests.inl
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct BlitColorTests : public DeviceFixture, public testing::TestWithParam<size_t> {
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename FamilyType>
|
||||
class GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed {
|
||||
public:
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed(Device *device) : device(device) {}
|
||||
void TestBodyImpl(size_t patternSize, COLOR_DEPTH expectedDepth) {
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
uint32_t patternToCommand[4];
|
||||
memset(patternToCommand, 4, patternSize);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, patternToCommand, patternSize, stream, mockAllocation.getUnderlyingBufferSize(), *device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(expectedDepth, cmd->getColorDepth());
|
||||
}
|
||||
}
|
||||
Device *device;
|
||||
};
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using BlitTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenOneBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 1;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenTwoBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 2;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenFourBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 4;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenEightBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 8;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSixteenBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 16;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenIncorrectBytePerPixelWhenAppendColorDepthThenAbortIsThrown, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 48;
|
||||
EXPECT_THROW(BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd), std::exception);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdressAreCorectOffseted, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcGpuAddress = mockAllocationSrc.getGpuAddress();
|
||||
properties.dstGpuAddress = mockAllocationDst.getGpuAddress();
|
||||
|
||||
properties.srcSize.y = 0x10;
|
||||
properties.srcRowPitch = 0x10;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSize.y * properties.srcRowPitch);
|
||||
|
||||
properties.dstSize.y = 0x20;
|
||||
properties.dstRowPitch = 0x20;
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSize.y * properties.dstRowPitch);
|
||||
|
||||
properties.srcOffset = {0x10, 0x10, 0x10};
|
||||
properties.dstOffset = {0x20, 0x20, 0x20};
|
||||
uint32_t index = 7;
|
||||
|
||||
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
auto expectesSrcOffset = (index + properties.srcOffset.z) * srcSlicePitch;
|
||||
auto expectesDstOffset = (index + properties.dstOffset.z) * dstSlicePitch;
|
||||
|
||||
EXPECT_EQ(bltCmd.getSourceBaseAddress(), ptrOffset(mockAllocationSrc.getGpuAddress(), expectesSrcOffset));
|
||||
EXPECT_EQ(bltCmd.getDestinationBaseAddress(), ptrOffset(mockAllocationDst.getGpuAddress(), expectesDstOffset));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenInputAndDefaultSlicePitchWhenAppendBlitCommandsForImagesThenSlicePitchesAreCorrect, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcSize = {10, 10, 1};
|
||||
properties.dstSize = {8, 12, 1};
|
||||
properties.srcRowPitch = 0x10;
|
||||
properties.dstRowPitch = 0x40;
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, static_cast<uint32_t>(properties.srcRowPitch * properties.srcSize.y));
|
||||
EXPECT_EQ(dstSlicePitch, static_cast<uint32_t>(properties.dstRowPitch * properties.dstSize.y));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0x40000;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, inputSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitch, inputSlicePitch);
|
||||
}
|
||||
}
|
||||
struct MyMockResourecInfo : public GmmResourceInfo {
|
||||
using GmmResourceInfo::resourceInfo;
|
||||
|
||||
MyMockResourecInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(clientContext, inputParams){};
|
||||
MyMockResourecInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(clientContext, inputGmmResourceInfo){};
|
||||
size_t getRenderPitch() override {
|
||||
return pitch;
|
||||
}
|
||||
uint32_t getQPitch() override {
|
||||
return 0;
|
||||
}
|
||||
GMM_RESOURCE_FLAG *getResourceFlags() override {
|
||||
return &flags;
|
||||
}
|
||||
uint32_t getMipTailStartLodSurfaceState() override {
|
||||
return 0;
|
||||
}
|
||||
size_t pitch = 0;
|
||||
GMM_RESOURCE_FLAG flags = {};
|
||||
};
|
||||
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0x100;
|
||||
myResourecInfo->flags.Info.TiledY = 1;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
properties.dstRowPitch = 0x4000;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_NE(bltCmd.getDestinationPitch(), static_cast<uint32_t>(properties.dstRowPitch));
|
||||
EXPECT_NE(bltCmd.getSourcePitch(), static_cast<uint32_t>(properties.srcRowPitch));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenLinearSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromProperties, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0x100;
|
||||
myResourecInfo->flags.Info.Linear = 1;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
properties.dstRowPitch = 0x4000;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_NE(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_NE(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), static_cast<uint32_t>(properties.dstRowPitch));
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), static_cast<uint32_t>(properties.srcRowPitch));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenBlitCommandWhenAppendClearColorCalledThenNothingHappens, IsGen12LP) {
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
auto expectedBlitCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
BlitCommandsHelper<FamilyType>::appendClearColor(properties, bltCmd);
|
||||
EXPECT_EQ(0, std::memcmp(&expectedBlitCmd, &bltCmd, sizeof(bltCmd)));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenPreBlitCommandWARequiredThenReturnsTrue, IsGen12LP) {
|
||||
EXPECT_TRUE(BlitCommandsHelper<FamilyType>::preBlitCommandWARequired());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenEstimatePreBlitCommandSizeThenSizeOfFlushIsReturned, IsGen12LP) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
EXPECT_EQ(EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite(), BlitCommandsHelper<FamilyType>::estimatePreBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenDispatchPreBlitCommandThenMiFlushDwIsProgramed, IsGen12LP) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
auto miFlushBuffer = std::make_unique<MI_FLUSH_DW>();
|
||||
LinearStream linearStream(miFlushBuffer.get(), EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite());
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchPreBlitCommand(linearStream);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(linearStream);
|
||||
auto cmdIterator = find<typename FamilyType::MI_FLUSH_DW *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
26
shared/test/common/helpers/built_ins_helper.cpp
Normal file
26
shared/test/common/helpers/built_ins_helper.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/built_ins_helper.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace MockSipData {
|
||||
std::unique_ptr<MockSipKernel> mockSipKernel;
|
||||
SipKernelType calledType = SipKernelType::COUNT;
|
||||
bool called = false;
|
||||
} // namespace MockSipData
|
||||
|
||||
void initSipKernel(SipKernelType type, Device &device) {
|
||||
MockSipData::calledType = type;
|
||||
MockSipData::called = true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
68
shared/test/common/helpers/debug_manager_state_restore.h
Normal file
68
shared/test/common/helpers/debug_manager_state_restore.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/utilities/debug_settings_reader.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class DebugManagerStateRestore {
|
||||
public:
|
||||
DebugManagerStateRestore() {
|
||||
debugVarSnapshot = DebugManager.flags;
|
||||
injectFcnSnapshot = DebugManager.injectFcn;
|
||||
}
|
||||
~DebugManagerStateRestore() {
|
||||
DebugManager.flags = debugVarSnapshot;
|
||||
DebugManager.injectFcn = injectFcnSnapshot;
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) shrink(DebugManager.flags.variableName.getRef());
|
||||
#include "shared/source/debug_settings/release_variables.inl"
|
||||
|
||||
#include "debug_variables.inl"
|
||||
#undef DECLARE_DEBUG_VARIABLE
|
||||
}
|
||||
DebugVariables debugVarSnapshot;
|
||||
void *injectFcnSnapshot = nullptr;
|
||||
|
||||
protected:
|
||||
void shrink(std::string &flag) {
|
||||
flag.shrink_to_fit();
|
||||
}
|
||||
void shrink(int64_t &flag) {}
|
||||
void shrink(int32_t &flag) {}
|
||||
void shrink(bool &flag) {}
|
||||
};
|
||||
|
||||
class RegistryReaderMock : public SettingsReader {
|
||||
public:
|
||||
RegistryReaderMock() {}
|
||||
~RegistryReaderMock() override {}
|
||||
|
||||
uint64_t forceRetValue = 1;
|
||||
|
||||
int32_t getSetting(const char *settingName, int32_t defaultValue) override {
|
||||
return static_cast<uint32_t>(forceRetValue);
|
||||
}
|
||||
|
||||
int64_t getSetting(const char *settingName, int64_t defaultValue) override {
|
||||
return forceRetValue;
|
||||
}
|
||||
|
||||
bool getSetting(const char *settingName, bool defaultValue) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getSetting(const char *settingName, const std::string &value) override {
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *appSpecificLocation(const std::string &name) override {
|
||||
return name.c_str();
|
||||
}
|
||||
};
|
||||
15
shared/test/common/helpers/default_hw_info.h
Normal file
15
shared/test/common/helpers/default_hw_info.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
struct HardwareInfo;
|
||||
extern std::unique_ptr<HardwareInfo> defaultHwInfo;
|
||||
} // namespace NEO
|
||||
13
shared/test/common/helpers/default_hw_info.inl
Normal file
13
shared/test/common/helpers/default_hw_info.inl
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::unique_ptr<HardwareInfo> defaultHwInfo;
|
||||
} // namespace NEO
|
||||
46
shared/test/common/helpers/dispatch_flags_helper.h
Normal file
46
shared/test/common/helpers/dispatch_flags_helper.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
|
||||
#include "csr_properties_flags.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct DispatchFlagsHelper {
|
||||
static DispatchFlags createDefaultDispatchFlags() {
|
||||
return DispatchFlags(
|
||||
{}, //csrDependencies
|
||||
nullptr, //barrierTimestampPacketNodes
|
||||
{}, //pipelineSelectArgs
|
||||
nullptr, //flushStampReference
|
||||
QueueThrottle::MEDIUM, //throttle
|
||||
PreemptionMode::Disabled, //preemptionMode
|
||||
GrfConfig::DefaultGrfNumber, //numGrfRequired
|
||||
L3CachingSettings::l3CacheOn, //l3CacheSettings
|
||||
ThreadArbitrationPolicy::NotPresent, //threadArbitrationPolicy
|
||||
AdditionalKernelExecInfo::NotApplicable, //additionalKernelExecInfo
|
||||
KernelExecutionType::NotApplicable, //kernelExecutionType
|
||||
MemoryCompressionState::NotApplicable, //memoryCompressionState
|
||||
QueueSliceCount::defaultSliceCount, //sliceCount
|
||||
false, //blocking
|
||||
false, //dcFlush
|
||||
false, //useSLM
|
||||
false, //guardCommandBufferWithPipeControl
|
||||
false, //gsba32BitRequired
|
||||
false, //requiresCoherency
|
||||
false, //lowPriority
|
||||
false, //implicitFlush
|
||||
false, //outOfOrderExecutionAllowed
|
||||
false, //epilogueRequired
|
||||
false, //usePerDssBackedBuffer
|
||||
false, //useSingleSubdevice
|
||||
false, //useGlobalAtomics
|
||||
1u); //numDevicesInContext
|
||||
}
|
||||
};
|
||||
42
shared/test/common/helpers/file_io_tests.cpp
Normal file
42
shared/test/common/helpers/file_io_tests.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/stdio.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
TEST(FileIO, GivenNonEmptyFileWhenCheckingIfHasSizeThenReturnTrue) {
|
||||
std::string fileName("fileIO.bin");
|
||||
std::remove(fileName.c_str());
|
||||
ASSERT_FALSE(fileExists(fileName.c_str()));
|
||||
|
||||
FILE *fp = nullptr;
|
||||
fopen_s(&fp, fileName.c_str(), "wb");
|
||||
ASSERT_NE(nullptr, fp);
|
||||
fprintf(fp, "TEST");
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_TRUE(fileExists(fileName.c_str()));
|
||||
EXPECT_TRUE(fileExistsHasSize(fileName.c_str()));
|
||||
}
|
||||
|
||||
TEST(FileIO, GivenEmptyFileWhenCheckingIfHasSizeThenReturnFalse) {
|
||||
std::string fileName("fileIO.bin");
|
||||
std::remove(fileName.c_str());
|
||||
ASSERT_FALSE(fileExists(fileName.c_str()));
|
||||
|
||||
FILE *fp = nullptr;
|
||||
fopen_s(&fp, fileName.c_str(), "wb");
|
||||
ASSERT_NE(nullptr, fp);
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_TRUE(fileExists(fileName.c_str()));
|
||||
EXPECT_FALSE(fileExistsHasSize(fileName.c_str()));
|
||||
}
|
||||
36
shared/test/common/helpers/hash_tests.cpp
Normal file
36
shared/test/common/helpers/hash_tests.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(HashTests, givenSamePointersWhenHashIsCalculatedThenSame32BitValuesAreGenerated) {
|
||||
uintptr_t ptr1UI = 1;
|
||||
uintptr_t ptr2UI = 1;
|
||||
void *ptr1 = reinterpret_cast<void *>(ptr1UI);
|
||||
void *ptr2 = reinterpret_cast<void *>(ptr2UI);
|
||||
|
||||
uint32_t hash1 = hashPtrToU32(ptr1);
|
||||
uint32_t hash2 = hashPtrToU32(ptr2);
|
||||
|
||||
EXPECT_EQ(hash1, hash2);
|
||||
}
|
||||
|
||||
TEST(HashTests, givenDifferentPointersWhenHashIsCalculatedThenUnique32BitValuesAreGenerated) {
|
||||
uintptr_t ptr1UI = 1;
|
||||
uintptr_t ptr2UI = ptr1UI | (ptr1UI << ((sizeof(uintptr_t) / 2) * 8));
|
||||
void *ptr1 = reinterpret_cast<void *>(ptr1UI);
|
||||
void *ptr2 = reinterpret_cast<void *>(ptr2UI);
|
||||
|
||||
uint32_t hash1 = hashPtrToU32(ptr1);
|
||||
uint32_t hash2 = hashPtrToU32(ptr2);
|
||||
|
||||
EXPECT_NE(hash1, hash2);
|
||||
}
|
||||
43
shared/test/common/helpers/heap_assigner_shared_tests.cpp
Normal file
43
shared/test/common/helpers/heap_assigner_shared_tests.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/heap_assigner.h"
|
||||
#include "shared/source/memory_manager/gfx_partition.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(HeapAssigner, givenInternalHeapIndexWhenMappingToInternalFrontWindowThenInternalFrontWindowReturned) {
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenInternalDeviceHeapIndexWhenMappingToInternalFrontWindowThenInternalDeviceFrontWindowReturned) {
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenOtherThanInternalHeapIndexWhenMappingToInternalFrontWindowThenAbortIsThrown) {
|
||||
EXPECT_THROW(HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_STANDARD), std::exception);
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenInternalHeapIndexWhenCheckingIsInternalHeapThenTrueIsReturned) {
|
||||
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL));
|
||||
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenNonInternalHeapIndexWhenCheckingIsInternalHeapThenFalseIsReturned) {
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD64KB));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_SVM));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTENDED));
|
||||
}
|
||||
27
shared/test/common/helpers/hw_helper_extended_tests.cpp
Normal file
27
shared/test/common/helpers/hw_helper_extended_tests.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef Test<DeviceFixture> HwHelperTest;
|
||||
|
||||
HWTEST_F(HwHelperTest, GivenHwInfoWithEnabledBliterWhenCheckCopyEnginesCountThenReturnedOne) {
|
||||
HardwareInfo hwInfo{};
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_EQ(HwHelper::getCopyEnginesCount(hwInfo), 1u);
|
||||
}
|
||||
|
||||
HWTEST_F(HwHelperTest, GivenHwInfoWithDisabledBliterWhenCheckCopyEnginesCountThenReturnedZero) {
|
||||
HardwareInfo hwInfo{};
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = false;
|
||||
EXPECT_EQ(HwHelper::getCopyEnginesCount(hwInfo), 0u);
|
||||
}
|
||||
12
shared/test/common/helpers/includes/test_traits_common.h
Normal file
12
shared/test/common/helpers/includes/test_traits_common.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/gen11/test_traits_gen11.h"
|
||||
#include "shared/test/common/gen12lp/test_traits_gen12lp.h"
|
||||
#include "shared/test/common/gen8/test_traits_gen8.h"
|
||||
#include "shared/test/common/gen9/test_traits_gen9.h"
|
||||
74
shared/test/common/helpers/kernel_helpers_tests.cpp
Normal file
74
shared/test/common/helpers/kernel_helpers_tests.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/kernel_helpers.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct KernelHelperMaxWorkGroupsTests : ::testing::Test {
|
||||
uint32_t simd = 8;
|
||||
uint32_t threadCount = 8 * 1024;
|
||||
uint32_t dssCount = 16;
|
||||
uint32_t availableSlm = 64 * KB;
|
||||
uint32_t usedSlm = 0;
|
||||
uint32_t maxBarrierCount = 32;
|
||||
uint32_t numberOfBarriers = 0;
|
||||
uint32_t workDim = 3;
|
||||
size_t lws[3] = {10, 10, 10};
|
||||
|
||||
uint32_t getMaxWorkGroupCount() {
|
||||
return KernelHelper::getMaxWorkGroupCount(simd, threadCount, dssCount, availableSlm, usedSlm,
|
||||
maxBarrierCount, numberOfBarriers, workDim, lws);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenNoBarriersOrSlmUsedWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithSimd) {
|
||||
auto workGroupSize = lws[0] * lws[1] * lws[2];
|
||||
auto expected = threadCount / Math::divideAndRoundUp(workGroupSize, simd);
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenBarriersWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithRegardToBarriersCount) {
|
||||
numberOfBarriers = 16;
|
||||
|
||||
auto expected = dssCount * (maxBarrierCount / numberOfBarriers);
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenUsedSlmSizeWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithRegardToUsedSlmSize) {
|
||||
usedSlm = 4 * KB;
|
||||
|
||||
auto expected = availableSlm / usedSlm;
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenVariousValuesWhenCalculatingMaxWorkGroupsCountThenLowestResultIsAlwaysReturned) {
|
||||
usedSlm = 1 * KB;
|
||||
numberOfBarriers = 1;
|
||||
dssCount = 1;
|
||||
|
||||
workDim = 1;
|
||||
lws[0] = simd;
|
||||
threadCount = 1;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
|
||||
threadCount = 1024;
|
||||
EXPECT_NE(1u, getMaxWorkGroupCount());
|
||||
|
||||
numberOfBarriers = 32;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
|
||||
numberOfBarriers = 1;
|
||||
EXPECT_NE(1u, getMaxWorkGroupCount());
|
||||
|
||||
usedSlm = availableSlm;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
}
|
||||
45
shared/test/common/helpers/memory_leak_listener.cpp
Normal file
45
shared/test/common/helpers/memory_leak_listener.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "memory_leak_listener.h"
|
||||
|
||||
#include "shared/test/common/helpers/memory_management.h"
|
||||
|
||||
using ::testing::TestInfo;
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryLeakListener::OnTestStart(const TestInfo &testInfo) {
|
||||
MemoryManagement::logTraces = MemoryManagement::captureCallStacks;
|
||||
if (MemoryManagement::captureCallStacks) {
|
||||
MemoryManagement::detailedAllocationLoggingActive = true;
|
||||
}
|
||||
MemoryManagement::fastLeakDetectionEnabled = true;
|
||||
}
|
||||
|
||||
void MemoryLeakListener::OnTestEnd(const TestInfo &testInfo) {
|
||||
MemoryManagement::fastLeakDetectionEnabled = false;
|
||||
|
||||
if (testInfo.result()->Passed()) {
|
||||
if (MemoryManagement::fastLeaksDetectionMode != MemoryManagement::LeakDetectionMode::STANDARD) {
|
||||
if (MemoryManagement::fastLeaksDetectionMode == MemoryManagement::LeakDetectionMode::EXPECT_TO_LEAK) {
|
||||
EXPECT_GT(MemoryManagement::fastEventsAllocatedCount, MemoryManagement::fastEventsDeallocatedCount);
|
||||
}
|
||||
MemoryManagement::fastLeaksDetectionMode = MemoryManagement::LeakDetectionMode::STANDARD;
|
||||
} else if (MemoryManagement::captureCallStacks && (MemoryManagement::fastEventsAllocatedCount != MemoryManagement::fastEventsDeallocatedCount)) {
|
||||
auto leak = MemoryManagement::enumerateLeak(MemoryManagement::indexAllocation.load(), MemoryManagement::indexDeallocation.load(), true, true);
|
||||
if (leak != MemoryManagement::failingAllocation) {
|
||||
printf("\n %s ", printCallStack(MemoryManagement::eventsAllocated[leak]).c_str());
|
||||
}
|
||||
EXPECT_EQ(MemoryManagement::indexAllocation.load(), MemoryManagement::indexDeallocation.load());
|
||||
} else if (MemoryManagement::fastEventsAllocatedCount != MemoryManagement::fastEventsDeallocatedCount) {
|
||||
auto leak = MemoryManagement::detectLeaks();
|
||||
EXPECT_EQ(leak, (int)MemoryManagement::failingAllocation) << "To locate call stack, change the value of captureCallStacks to true";
|
||||
}
|
||||
}
|
||||
MemoryManagement::fastEventsAllocatedCount = 0;
|
||||
MemoryManagement::fastEventsDeallocatedCount = 0;
|
||||
}
|
||||
18
shared/test/common/helpers/memory_leak_listener.h
Normal file
18
shared/test/common/helpers/memory_leak_listener.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MemoryLeakListener : public ::testing::EmptyTestEventListener {
|
||||
protected:
|
||||
void OnTestStart(const ::testing::TestInfo &) override;
|
||||
void OnTestEnd(const ::testing::TestInfo &) override;
|
||||
};
|
||||
} // namespace NEO
|
||||
403
shared/test/common/helpers/memory_management.cpp
Normal file
403
shared/test/common/helpers/memory_management.cpp
Normal file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/memory_management.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cinttypes>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <cstdio>
|
||||
#include <dlfcn.h>
|
||||
#include <execinfo.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#include <DbgHelp.h>
|
||||
#endif
|
||||
|
||||
namespace MemoryManagement {
|
||||
size_t failingAllocation = -1;
|
||||
std::atomic<size_t> numAllocations(0);
|
||||
std::atomic<size_t> indexAllocation(0);
|
||||
std::atomic<size_t> indexDeallocation(0);
|
||||
bool logTraces = false;
|
||||
bool fastLeakDetectionEnabled = false;
|
||||
|
||||
AllocationEvent eventsAllocated[maxEvents];
|
||||
AllocationEvent eventsDeallocated[maxEvents];
|
||||
|
||||
void *fastEventsAllocated[maxEvents];
|
||||
void *fastEventsDeallocated[maxEvents];
|
||||
std::atomic<int> fastEventsAllocatedCount(0);
|
||||
std::atomic<int> fastEventsDeallocatedCount(0);
|
||||
std::atomic<int> fastLeaksDetectionMode(LeakDetectionMode::STANDARD);
|
||||
|
||||
size_t breakOnAllocationEvent = -1;
|
||||
size_t breakOnDeallocationEvent = -1;
|
||||
|
||||
bool detailedAllocationLoggingActive = false;
|
||||
|
||||
// limit size of single allocation in ULT
|
||||
const size_t maxAllowedAllocationSize = 128 * 1024 * 1024 + 4096;
|
||||
|
||||
static void onAllocationEvent() {
|
||||
/*
|
||||
//switch to true to turn on dillignet breakpoint setting place
|
||||
bool setBreakPointHereForLeaks = false;
|
||||
if (setBreakPointHereForLeaks) {
|
||||
if (breakOnAllocationEvent == indexAllocation.load()) {
|
||||
//set breakpoint on line below
|
||||
setBreakPointHereForLeaks = false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
static void onDeallocationEvent(void *) {
|
||||
/*
|
||||
//switch to true to turn on dillignet breakpoint setting place
|
||||
bool setBreakPointHereForLeaks = false;
|
||||
if (setBreakPointHereForLeaks) {
|
||||
if (breakOnDeallocationEvent == indexDeallocation.load()) {
|
||||
//set breakpoint on line below
|
||||
setBreakPointHereForLeaks = false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void (*deleteCallback)(void *) = onDeallocationEvent;
|
||||
|
||||
template <AllocationEvent::EventType typeValid, AllocationEvent::EventType typeFail>
|
||||
static void *allocate(size_t size) {
|
||||
onAllocationEvent();
|
||||
|
||||
if (size > maxAllowedAllocationSize) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!fastLeakDetectionEnabled) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *p;
|
||||
|
||||
if (detailedAllocationLoggingActive) {
|
||||
|
||||
auto indexAllocation = MemoryManagement::indexAllocation.fetch_add(1);
|
||||
indexAllocation %= maxEvents;
|
||||
|
||||
auto &eventAllocation = eventsAllocated[indexAllocation];
|
||||
eventAllocation.size = size;
|
||||
|
||||
while ((p = malloc(size)) == nullptr) {
|
||||
eventAllocation.address = p;
|
||||
eventAllocation.event = typeFail;
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
eventAllocation.address = p;
|
||||
eventAllocation.event = typeValid;
|
||||
#if defined(__linux__)
|
||||
eventAllocation.frames = logTraces ? backtrace(eventAllocation.callstack, AllocationEvent::CallStackSize) : 0;
|
||||
#elif defined(_WIN32)
|
||||
eventAllocation.frames = logTraces ? CaptureStackBackTrace(0, AllocationEvent::CallStackSize, eventAllocation.callstack, NULL) : 0;
|
||||
#else
|
||||
eventAllocation.frames = 0;
|
||||
#endif
|
||||
eventAllocation.fastLeakDetectionEnabled = fastLeakDetectionEnabled;
|
||||
|
||||
numAllocations++;
|
||||
} else {
|
||||
p = malloc(size);
|
||||
}
|
||||
|
||||
if (fastLeakDetectionEnabled && p && fastLeaksDetectionMode == LeakDetectionMode::STANDARD) {
|
||||
auto currentIndex = fastEventsAllocatedCount++;
|
||||
fastEventsAllocated[currentIndex] = p;
|
||||
assert(currentIndex <= fastEvents);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
template <AllocationEvent::EventType typeValid, AllocationEvent::EventType typeFail>
|
||||
static void *allocate(size_t size, const std::nothrow_t &) {
|
||||
onAllocationEvent();
|
||||
|
||||
if (size > maxAllowedAllocationSize) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!fastLeakDetectionEnabled) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *p;
|
||||
|
||||
if (detailedAllocationLoggingActive) {
|
||||
|
||||
auto indexAllocation = MemoryManagement::indexAllocation.fetch_add(1);
|
||||
indexAllocation %= maxEvents;
|
||||
|
||||
p = indexAllocation == failingAllocation
|
||||
? nullptr
|
||||
: malloc(size);
|
||||
|
||||
auto &eventAllocation = eventsAllocated[indexAllocation];
|
||||
eventAllocation.event = p
|
||||
? typeValid
|
||||
: typeFail;
|
||||
eventAllocation.address = p;
|
||||
eventAllocation.size = size;
|
||||
#if defined(__linux__)
|
||||
eventAllocation.frames = logTraces ? backtrace(eventAllocation.callstack, AllocationEvent::CallStackSize) : 0;
|
||||
#elif defined(_WIN32)
|
||||
eventAllocation.frames = logTraces ? CaptureStackBackTrace(0, AllocationEvent::CallStackSize, eventAllocation.callstack, NULL) : 0;
|
||||
#else
|
||||
eventAllocation.frames = 0;
|
||||
#endif
|
||||
eventAllocation.fastLeakDetectionEnabled = fastLeakDetectionEnabled;
|
||||
numAllocations += p ? 1 : 0;
|
||||
} else {
|
||||
p = malloc(size);
|
||||
}
|
||||
|
||||
if (fastLeakDetectionEnabled && p && fastLeaksDetectionMode == LeakDetectionMode::STANDARD) {
|
||||
auto currentIndex = fastEventsAllocatedCount++;
|
||||
fastEventsAllocated[currentIndex] = p;
|
||||
assert(currentIndex <= fastEvents);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
template <AllocationEvent::EventType typeValid>
|
||||
static void deallocate(void *p) {
|
||||
deleteCallback(p);
|
||||
|
||||
if (!fastLeakDetectionEnabled) {
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p) {
|
||||
if (detailedAllocationLoggingActive) {
|
||||
|
||||
auto indexDeallocation = MemoryManagement::indexDeallocation.fetch_add(1);
|
||||
indexDeallocation %= maxEvents;
|
||||
|
||||
--numAllocations;
|
||||
|
||||
auto &eventDeallocation = eventsDeallocated[indexDeallocation];
|
||||
eventDeallocation.event = typeValid;
|
||||
eventDeallocation.address = p;
|
||||
eventDeallocation.size = -1;
|
||||
#if defined(__linux__)
|
||||
eventDeallocation.frames = logTraces ? backtrace(eventDeallocation.callstack, AllocationEvent::CallStackSize) : 0;
|
||||
#elif defined(_WIN32)
|
||||
eventDeallocation.frames = logTraces ? CaptureStackBackTrace(0, AllocationEvent::CallStackSize, eventDeallocation.callstack, NULL) : 0;
|
||||
#else
|
||||
eventDeallocation.frames = 0;
|
||||
#endif
|
||||
eventDeallocation.fastLeakDetectionEnabled = fastLeakDetectionEnabled;
|
||||
}
|
||||
free(p);
|
||||
|
||||
if (fastLeakDetectionEnabled && p && fastLeaksDetectionMode == LeakDetectionMode::STANDARD) {
|
||||
auto currentIndex = fastEventsDeallocatedCount++;
|
||||
fastEventsDeallocated[currentIndex] = p;
|
||||
assert(currentIndex <= fastEvents);
|
||||
}
|
||||
}
|
||||
}
|
||||
int detectLeaks() {
|
||||
int indexLeak = -1;
|
||||
|
||||
for (int allocationIndex = 0u; allocationIndex < fastEventsAllocatedCount; allocationIndex++) {
|
||||
auto &eventAllocation = fastEventsAllocated[allocationIndex];
|
||||
int deallocationIndex = 0u;
|
||||
for (; deallocationIndex < fastEventsDeallocatedCount; deallocationIndex++) {
|
||||
if (fastEventsDeallocated[deallocationIndex] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (fastEventsDeallocated[deallocationIndex] == eventAllocation) {
|
||||
fastEventsDeallocated[deallocationIndex] = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (deallocationIndex == fastEventsDeallocatedCount) {
|
||||
indexLeak = allocationIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return indexLeak;
|
||||
}
|
||||
|
||||
size_t enumerateLeak(size_t indexAllocationTop, size_t indexDeallocationTop, bool lookFromBack, bool requireCallStack) {
|
||||
using MemoryManagement::AllocationEvent;
|
||||
using MemoryManagement::eventsAllocated;
|
||||
using MemoryManagement::eventsDeallocated;
|
||||
|
||||
static auto start = MemoryManagement::invalidLeakIndex;
|
||||
auto newIndex = start == MemoryManagement::invalidLeakIndex ? 0 : start;
|
||||
bool potentialLeak = false;
|
||||
auto potentialLeakIndex = newIndex;
|
||||
|
||||
for (; newIndex < indexAllocationTop; ++newIndex) {
|
||||
auto currentIndex = lookFromBack ? indexAllocationTop - newIndex - 1 : newIndex;
|
||||
auto &eventAllocation = eventsAllocated[currentIndex];
|
||||
|
||||
if (requireCallStack && eventAllocation.frames == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (eventAllocation.event != AllocationEvent::EVENT_UNKNOWN) {
|
||||
// Should be some sort of allocation
|
||||
size_t deleteIndex = 0;
|
||||
for (; deleteIndex < indexDeallocationTop; ++deleteIndex) {
|
||||
auto &eventDeallocation = eventsDeallocated[deleteIndex];
|
||||
|
||||
if (eventDeallocation.address == eventAllocation.address &&
|
||||
eventDeallocation.event != AllocationEvent::EVENT_UNKNOWN) {
|
||||
|
||||
//this memory was once freed, now it is allocated but not freed
|
||||
if (requireCallStack && eventDeallocation.frames == 0) {
|
||||
potentialLeak = true;
|
||||
potentialLeakIndex = currentIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Clear the NEW and DELETE event.
|
||||
eventAllocation.event = AllocationEvent::EVENT_UNKNOWN;
|
||||
eventDeallocation.event = AllocationEvent::EVENT_UNKNOWN;
|
||||
potentialLeak = false;
|
||||
// Found a corresponding match
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (potentialLeak) {
|
||||
return potentialLeakIndex;
|
||||
}
|
||||
|
||||
if (deleteIndex == indexDeallocationTop) {
|
||||
start = newIndex + 1;
|
||||
return currentIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
start = MemoryManagement::invalidLeakIndex;
|
||||
return start;
|
||||
}
|
||||
|
||||
std::string printCallStack(const MemoryManagement::AllocationEvent &event) {
|
||||
std::string result = "";
|
||||
|
||||
printf("printCallStack.%d\n", event.frames);
|
||||
if (!MemoryManagement::captureCallStacks) {
|
||||
printf("for detailed stack information turn on captureCallStacks in memory_management.h\n");
|
||||
}
|
||||
if (event.frames > 0) {
|
||||
#if defined(__linux__)
|
||||
char **bt = backtrace_symbols(event.callstack, event.frames);
|
||||
char *demangled;
|
||||
int status;
|
||||
char output[1024];
|
||||
Dl_info info;
|
||||
result += "\n";
|
||||
for (int i = 0; i < event.frames; ++i) {
|
||||
dladdr(event.callstack[i], &info);
|
||||
if (info.dli_sname) {
|
||||
demangled = nullptr;
|
||||
status = -1;
|
||||
if (info.dli_sname[0] == '_') {
|
||||
demangled = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status);
|
||||
}
|
||||
snprintf(output, sizeof(output), "%-3d %*p %s + %zd\n",
|
||||
(event.frames - i - 1), (int)(sizeof(void *) + 2), event.callstack[i],
|
||||
status == 0 ? demangled : info.dli_sname == 0 ? bt[i]
|
||||
: info.dli_sname,
|
||||
(char *)event.callstack[i] - (char *)info.dli_saddr);
|
||||
free(demangled);
|
||||
} else {
|
||||
snprintf(output, sizeof(output), "%-3d %*p %s\n",
|
||||
(event.frames - i - 1), (int)(sizeof(void *) + 2), event.callstack[i], bt[i]);
|
||||
}
|
||||
result += std::string(output);
|
||||
}
|
||||
result += "\n";
|
||||
free(bt);
|
||||
#elif defined(_WIN32)
|
||||
SYMBOL_INFO *symbol;
|
||||
HANDLE process;
|
||||
process = GetCurrentProcess();
|
||||
SymInitialize(process, NULL, TRUE);
|
||||
|
||||
symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
|
||||
symbol->MaxNameLen = 255;
|
||||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
|
||||
for (int i = 0; i < event.frames; i++) {
|
||||
SymFromAddr(process, (DWORD64)(event.callstack[i]), 0, symbol);
|
||||
|
||||
printf("%i: %s - 0x%0" PRIx64 "\n", event.frames - i - 1, symbol->Name, symbol->Address);
|
||||
}
|
||||
|
||||
free(symbol);
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace MemoryManagement
|
||||
|
||||
using MemoryManagement::allocate;
|
||||
using MemoryManagement::AllocationEvent;
|
||||
using MemoryManagement::deallocate;
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4290)
|
||||
#endif
|
||||
void *operator new(size_t size) {
|
||||
return allocate<AllocationEvent::EVENT_NEW, AllocationEvent::EVENT_NEW_FAIL>(size);
|
||||
}
|
||||
|
||||
void *operator new(size_t size, const std::nothrow_t &) noexcept {
|
||||
return allocate<AllocationEvent::EVENT_NEW_NOTHROW, AllocationEvent::EVENT_NEW_NOTHROW_FAIL>(size, std::nothrow);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size) {
|
||||
return allocate<AllocationEvent::EVENT_NEW_ARRAY, AllocationEvent::EVENT_NEW_ARRAY_FAIL>(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size, const std::nothrow_t &t) noexcept {
|
||||
return allocate<AllocationEvent::EVENT_NEW_ARRAY_NOTHROW, AllocationEvent::EVENT_NEW_ARRAY_NOTHROW_FAIL>(size, std::nothrow);
|
||||
}
|
||||
|
||||
void operator delete(void *p) noexcept {
|
||||
deallocate<AllocationEvent::EVENT_DELETE>(p);
|
||||
}
|
||||
|
||||
void operator delete[](void *p) noexcept {
|
||||
deallocate<AllocationEvent::EVENT_DELETE_ARRAY>(p);
|
||||
}
|
||||
void operator delete(void *p, size_t size) noexcept {
|
||||
deallocate<AllocationEvent::EVENT_DELETE>(p);
|
||||
}
|
||||
|
||||
void operator delete[](void *p, size_t size) noexcept {
|
||||
deallocate<AllocationEvent::EVENT_DELETE_ARRAY>(p);
|
||||
}
|
||||
88
shared/test/common/helpers/memory_management.h
Normal file
88
shared/test/common/helpers/memory_management.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace MemoryManagement {
|
||||
#if defined(__clang__)
|
||||
#define NO_SANITIZE __attribute__((no_sanitize("undefined")))
|
||||
#else
|
||||
#define NO_SANITIZE
|
||||
#endif
|
||||
|
||||
enum LeakDetectionMode {
|
||||
STANDARD,
|
||||
EXPECT_TO_LEAK,
|
||||
TURN_OFF_LEAK_DETECTION
|
||||
};
|
||||
|
||||
struct AllocationEvent { // NOLINT(clang-analyzer-optin.performance.Padding)
|
||||
enum {
|
||||
CallStackSize = 16
|
||||
};
|
||||
|
||||
enum EventType {
|
||||
EVENT_UNKNOWN,
|
||||
EVENT_NEW,
|
||||
EVENT_NEW_FAIL,
|
||||
EVENT_NEW_NOTHROW,
|
||||
EVENT_NEW_NOTHROW_FAIL,
|
||||
EVENT_NEW_ARRAY,
|
||||
EVENT_NEW_ARRAY_FAIL,
|
||||
EVENT_NEW_ARRAY_NOTHROW,
|
||||
EVENT_NEW_ARRAY_NOTHROW_FAIL,
|
||||
EVENT_DELETE,
|
||||
EVENT_DELETE_ARRAY
|
||||
};
|
||||
|
||||
EventType event;
|
||||
const void *address;
|
||||
size_t size;
|
||||
int frames;
|
||||
void *callstack[CallStackSize];
|
||||
bool fastLeakDetectionEnabled = false;
|
||||
};
|
||||
enum : int {
|
||||
maxEvents = 1024 * 1024,
|
||||
fastEvents = 1024 * 1024
|
||||
};
|
||||
extern AllocationEvent eventsAllocated[maxEvents];
|
||||
extern AllocationEvent eventsDeallocated[maxEvents];
|
||||
|
||||
extern void *fastEventsAllocated[maxEvents];
|
||||
extern void *fastEventsDeallocated[maxEvents];
|
||||
extern std::atomic<int> fastEventsAllocatedCount;
|
||||
extern std::atomic<int> fastEventsDeallocatedCount;
|
||||
extern std::atomic<int> fastLeaksDetectionMode;
|
||||
extern bool memsetNewAllocations;
|
||||
|
||||
extern size_t failingAllocation;
|
||||
extern std::atomic<size_t> numAllocations;
|
||||
extern std::atomic<size_t> indexAllocation;
|
||||
extern std::atomic<size_t> indexDeallocation;
|
||||
extern size_t breakOnAllocationEvent;
|
||||
extern size_t breakOnDeallocationEvent;
|
||||
extern bool logTraces;
|
||||
extern bool detailedAllocationLoggingActive;
|
||||
extern bool fastLeakDetectionEnabled;
|
||||
extern void (*deleteCallback)(void *);
|
||||
|
||||
constexpr auto nonfailingAllocation = static_cast<size_t>(-1);
|
||||
constexpr auto invalidLeakIndex = static_cast<size_t>(-1);
|
||||
|
||||
// capture allocations call stacks to print them during memory leak in ULTs
|
||||
constexpr bool captureCallStacks = false;
|
||||
|
||||
int detectLeaks();
|
||||
std::string printCallStack(const MemoryManagement::AllocationEvent &event);
|
||||
size_t enumerateLeak(size_t indexAllocationTop, size_t indexDeallocationTop, bool lookFromEnd, bool requireCallStack);
|
||||
|
||||
} // namespace MemoryManagement
|
||||
35
shared/test/common/helpers/simd_helper_tests.inl
Normal file
35
shared/test/common/helpers/simd_helper_tests.inl
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/simd_helper.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename WALKER_TYPE>
|
||||
class GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturned {
|
||||
public:
|
||||
static void TestBodyImpl() {
|
||||
uint32_t simd = 32;
|
||||
auto result = getSimdConfig<WALKER_TYPE>(simd);
|
||||
EXPECT_EQ(result, WALKER_TYPE::SIMD_SIZE::SIMD_SIZE_SIMD32);
|
||||
|
||||
simd = 16;
|
||||
result = getSimdConfig<WALKER_TYPE>(simd);
|
||||
EXPECT_EQ(result, WALKER_TYPE::SIMD_SIZE::SIMD_SIZE_SIMD16);
|
||||
|
||||
simd = 8;
|
||||
result = getSimdConfig<WALKER_TYPE>(simd);
|
||||
EXPECT_EQ(result, WALKER_TYPE::SIMD_SIZE::SIMD_SIZE_SIMD8);
|
||||
|
||||
simd = 1;
|
||||
result = getSimdConfig<WALKER_TYPE>(simd);
|
||||
EXPECT_EQ(result, WALKER_TYPE::SIMD_SIZE::SIMD_SIZE_SIMD32);
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
232
shared/test/common/helpers/state_base_address_tests.cpp
Normal file
232
shared/test/common/helpers/state_base_address_tests.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/state_base_address_tests.h"
|
||||
|
||||
using IsBetweenSklAndTgllp = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
|
||||
|
||||
HWTEST2_F(SBATest, WhenAppendStateBaseAddressParametersIsCalledThenSBACmdHasBindingSurfaceStateProgrammed, IsBetweenSklAndTgllp) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(
|
||||
&stateBaseAddress,
|
||||
&ssh,
|
||||
false,
|
||||
0,
|
||||
nullptr,
|
||||
false,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
true,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(ssh.getMaxAvailableSpace() / 64 - 1, stateBaseAddress.getBindlessSurfaceStateSize());
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), stateBaseAddress.getBindlessSurfaceStateBaseAddress());
|
||||
EXPECT_TRUE(stateBaseAddress.getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
}
|
||||
|
||||
using IsSklOrAbove = IsAtLeastProduct<IGFX_SKYLAKE>;
|
||||
HWTEST2_F(SBATest, WhenProgramStateBaseAddressParametersIsCalledThenSBACmdHasBindingSurfaceStateProgrammed, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(0));
|
||||
*cmd = stateBaseAddress;
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(ssh.getMaxAvailableSpace() / 64 - 1, cmd->getBindlessSurfaceStateSize());
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), cmd->getBindlessSurfaceStateBaseAddress());
|
||||
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
}
|
||||
|
||||
using SbaForBindlessTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenProgramStateBaseAddressThenSbaProgrammedCorrectly, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u);
|
||||
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
EXPECT_EQ(cmd->getBindlessSurfaceStateBaseAddress(), globalBindlessHeapsBaseAddress);
|
||||
EXPECT_EQ(cmd->getBindlessSurfaceStateSize(), MemoryConstants::sizeOf4GBinPageEntities);
|
||||
}
|
||||
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenPassingIndirectBaseAddressThenIndirectBaseAddressIsSet, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
uint64_t indirectObjectBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
indirectObjectBaseAddress,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(cmd->getIndirectObjectBaseAddress(), indirectObjectBaseAddress);
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenSbaWhenOverrideBindlessSurfaceBaseIsFalseThenBindlessSurfaceBaseIsNotSet, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(
|
||||
&stateBaseAddress,
|
||||
&ssh,
|
||||
false,
|
||||
0,
|
||||
pDevice->getRootDeviceEnvironment().getGmmHelper(),
|
||||
false,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(0u, stateBaseAddress.getBindlessSurfaceStateBaseAddress());
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenGlobalBindlessBaseAddressWhenSshIsPassedThenBindlessSurfaceBaseIsGlobalHeapBase, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u);
|
||||
EXPECT_EQ(cmd->getBindlessSurfaceStateBaseAddress(), globalBindlessHeapsBaseAddress);
|
||||
}
|
||||
HWTEST2_F(SBATest, givenSurfaceStateHeapWhenNotUsingGlobalHeapBaseThenBindlessSurfaceBaseIsSshBase, IsSklOrAbove) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
false,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u);
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), cmd->getBindlessSurfaceStateBaseAddress());
|
||||
}
|
||||
44
shared/test/common/helpers/state_base_address_tests.h
Normal file
44
shared/test/common/helpers/state_base_address_tests.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/helpers/state_base_address.h"
|
||||
#include "shared/source/indirect_heap/indirect_heap.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
struct SBATest : public NEO::DeviceFixture, public ::testing::Test {
|
||||
void SetUp() override {
|
||||
NEO::DeviceFixture::SetUp();
|
||||
size_t sizeStream = 512;
|
||||
size_t alignmentStream = 0x1000;
|
||||
sshBuffer = alignedMalloc(sizeStream, alignmentStream);
|
||||
ASSERT_NE(nullptr, sshBuffer);
|
||||
|
||||
ssh.replaceBuffer(sshBuffer, sizeStream);
|
||||
auto graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream);
|
||||
ssh.replaceGraphicsAllocation(graphicsAllocation);
|
||||
|
||||
linearStreamBuffer = alignedMalloc(sizeStream, alignmentStream);
|
||||
commandStream.replaceBuffer(linearStreamBuffer, alignmentStream);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
alignedFree(linearStreamBuffer);
|
||||
delete ssh.getGraphicsAllocation();
|
||||
alignedFree(sshBuffer);
|
||||
NEO::DeviceFixture::TearDown();
|
||||
}
|
||||
IndirectHeap ssh = {nullptr};
|
||||
void *sshBuffer = nullptr;
|
||||
void *linearStreamBuffer = nullptr;
|
||||
DebugManagerStateRestore restorer;
|
||||
LinearStream commandStream;
|
||||
};
|
||||
150
shared/test/common/helpers/string_tests.cpp
Normal file
150
shared/test/common/helpers/string_tests.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrncpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
//preconditions
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
//String must be smaller than array capacity
|
||||
ASSERT_LT(strlen(src), sizeof(src));
|
||||
|
||||
auto ret = strncpy_s(nullptr, 1024, src, 1024);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strncpy_s(dst, 1024, nullptr, 1024);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strncpy_s(dst, 512, src, 1024);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = strncpy_s(dst, 1024, src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = strncpy_s(dst, strlen(src) / 2, src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
|
||||
strncpy_s(dst, 1024, src, 1024);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src)));
|
||||
for (size_t i = strlen(src); i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingMemmoveThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
|
||||
auto ret = memmove_s(nullptr, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memmove_s(dst, sizeof(dst), nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memmove_s(dst, sizeof(src) / 2, src, sizeof(src));
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = memmove_s(dst, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, sizeof(dst)));
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrcpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
|
||||
auto ret = strcpy_s(nullptr, 0, src);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, sizeof(dst), src);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, sizeof(dst), nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(dst, 0, nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(dst, strlen(src) / 2, src);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
ret = strcpy_s(dst, strlen(src), src);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
char pattern = 0x5a;
|
||||
memset(dst, pattern, sizeof(dst));
|
||||
ret = strcpy_s(dst, sizeof(dst), src);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src)));
|
||||
EXPECT_EQ(0, dst[strlen(src)]);
|
||||
for (size_t i = strlen(src) + 1; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(pattern, dst[i]);
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrnlenThenReturnIsCorrect) {
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
auto ret = strnlen_s(nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, 0u);
|
||||
|
||||
ret = strnlen_s(src, 0);
|
||||
EXPECT_EQ(ret, 0u);
|
||||
|
||||
ret = strnlen_s(src, sizeof(src));
|
||||
EXPECT_EQ(ret, strlen(src));
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingMemcpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
//preconditions
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
//String must be smaller than array capacity
|
||||
ASSERT_LT(strlen(src), sizeof(src));
|
||||
|
||||
auto ret = memcpy_s(nullptr, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memcpy_s(dst, sizeof(dst), nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memcpy_s(dst, sizeof(dst) / 2, src, sizeof(src));
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = memcpy_s(dst, sizeof(dst), src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
239
shared/test/common/helpers/string_to_hash_tests.cpp
Normal file
239
shared/test/common/helpers/string_to_hash_tests.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
|
||||
#include "opencl/source/helpers/string_helpers.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using NEO::Hash;
|
||||
|
||||
TEST(CreateCombinedStrings, GivenSingleStringWhenCreatingCombinedStringThenDstStringMatchesSrcString) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
size_t lengths = strlen(srcString);
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
&lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(lengths + 1, dstStringSizeInBytes);
|
||||
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenNullLengthWhenCreatingCombinedStringThenDstStringIsCreatedCorrectly) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenZeroLengthWhenCreatingCombinedStringThenDstStringIsCreatedCorrectly) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
size_t lengths = 0;
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
&lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
|
||||
auto srcStrings = &srcString[0];
|
||||
size_t lengths[2] = {strlen(srcString[0]), strlen(srcString[1])};
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringAndNullLengthWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
auto srcStrings = &srcString[0];
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringAndZeroLengthWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
auto srcStrings = &srcString[0];
|
||||
size_t lengths[2] = {0, strlen(srcString[1])};
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultipleStringsIncludingOneWithErrorWhenCreatingCombinedStringThenErrorIsOmittedInDstString) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleHBABA"};
|
||||
const char *expString[] = {"HelloWorld", "dlroWolleH"};
|
||||
size_t lengths[2] = {0, strlen(expString[1])};
|
||||
std::string combined(expString[0]);
|
||||
combined += expString[1];
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcString,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenInvalidInputWhenCreatingCombinedStringThenInvalidValueErrorIsReturned) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
const char *srcStrings[2] = {srcString[0], srcString[1]};
|
||||
size_t lengths[2] = {0, strlen(srcString[1])};
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
0,
|
||||
srcStrings,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
nullptr,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
srcStrings[0] = nullptr;
|
||||
retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultipleStringThatCountIsHigherThanMaximalStackSizeSizesWhenCreatingCombinedStringThenCorrectStringIsReturned) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *defaultString = "hello";
|
||||
const char *srcString[maximalStackSizeSizes + 2];
|
||||
std::string combinedString;
|
||||
for (int i = 0; i < maximalStackSizeSizes + 2; i++) {
|
||||
srcString[i] = defaultString;
|
||||
combinedString += defaultString;
|
||||
}
|
||||
|
||||
auto retVal = createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
maximalStackSizeSizes + 2,
|
||||
srcString,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combinedString.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateHash, WhenGettingHashesThenHashesAreDeterministicAndDoNotCollide) {
|
||||
char pBuffer[128];
|
||||
memset(pBuffer, 0x23, sizeof(pBuffer));
|
||||
|
||||
// make sure we can get a hash and make sure we can get the same hash
|
||||
auto hash1 = Hash::hash(pBuffer, sizeof(pBuffer));
|
||||
auto hash2 = Hash::hash(pBuffer, sizeof(pBuffer));
|
||||
EXPECT_NE(0u, hash1);
|
||||
EXPECT_NE(0u, hash2);
|
||||
EXPECT_EQ(hash1, hash2);
|
||||
|
||||
// make sure that we get a different hash for different length/data
|
||||
auto hash3 = Hash::hash(pBuffer, sizeof(pBuffer) - 1);
|
||||
EXPECT_NE(0u, hash3);
|
||||
EXPECT_NE(hash2, hash3);
|
||||
}
|
||||
|
||||
TEST(CreateHash, WhenGettingHashThenChangesPastLengthDoNotAffectOutput) {
|
||||
char pBuffer[] = {
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
|
||||
|
||||
// Use unaligned lengths. Wiggle the byte after the length
|
||||
// Shouldn't affect hash.
|
||||
for (auto length = 1u; length < sizeof(pBuffer); length++) {
|
||||
auto hash1 = Hash::hash(pBuffer, length);
|
||||
pBuffer[length]++;
|
||||
EXPECT_EQ(hash1, Hash::hash(pBuffer, length));
|
||||
}
|
||||
}
|
||||
49
shared/test/common/helpers/test_files.cpp
Normal file
49
shared/test/common/helpers/test_files.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "test_files.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
std::string testFiles("test_files/" NEO_ARCH "/");
|
||||
std::string testFilesNoRev("test_files/" NEO_ARCH "/");
|
||||
std::string clFiles("test_files/");
|
||||
std::string binaryNameSuffix("");
|
||||
|
||||
void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options) {
|
||||
if (outputFilename.length() > 0) {
|
||||
outputFilename.clear();
|
||||
}
|
||||
outputFilename.reserve(2 * testFiles.length());
|
||||
outputFilename.append(testFiles);
|
||||
outputFilename.append(kernelName);
|
||||
outputFilename.append(binaryNameSuffix);
|
||||
outputFilename.append(extension);
|
||||
outputFilename.append(options);
|
||||
|
||||
if (!fileExists(outputFilename) && (extension == ".bc")) {
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
|
||||
void retrieveBinaryKernelFilenameNoRevision(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options) {
|
||||
if (outputFilename.length() > 0) {
|
||||
outputFilename.clear();
|
||||
}
|
||||
outputFilename.reserve(2 * testFilesNoRev.length());
|
||||
outputFilename.append(testFilesNoRev);
|
||||
outputFilename.append(kernelName);
|
||||
outputFilename.append(binaryNameSuffix);
|
||||
outputFilename.append(extension);
|
||||
outputFilename.append(options);
|
||||
|
||||
if (!fileExists(outputFilename) && (extension == ".bc")) {
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
17
shared/test/common/helpers/test_files.h
Normal file
17
shared/test/common/helpers/test_files.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
extern std::string testFiles;
|
||||
extern std::string testFilesNoRev;
|
||||
extern std::string clFiles;
|
||||
extern std::string binaryNameSuffix;
|
||||
|
||||
void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
void retrieveBinaryKernelFilenameNoRevision(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
13
shared/test/common/helpers/test_traits.h
Normal file
13
shared/test/common/helpers/test_traits.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct TestTraits;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user