diff --git a/CMakeLists.txt b/CMakeLists.txt index dd5c005ec5..e20b01040e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -833,6 +833,7 @@ include_directories(${NEO_SHARED_DIRECTORY}/command_container/definitions${BRANC include_directories(${NEO_SHARED_DIRECTORY}/command_stream/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SHARED_DIRECTORY}/debug_settings/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}) +include_directories(${NEO_SHARED_DIRECTORY}/kernel/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SHARED_DIRECTORY}/gen_common${BRANCH_DIR_SUFFIX}) if(WIN32) include_directories(${NEO_SHARED_DIRECTORY}/gmm_helper/windows/gmm_memory${BRANCH_DIR_SUFFIX}) diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index a70c06235b..ff390bbb72 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -24,7 +24,7 @@ #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/string.h" #include "shared/source/helpers/surface_format_info.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_arg_descriptor.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/memory_manager/allocation_properties.h" @@ -1020,7 +1020,7 @@ ze_result_t KernelImp::initialize(const ze_kernel_desc_t *desc) { if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) { pImplicitArgs = std::make_unique(); *pImplicitArgs = {}; - pImplicitArgs->structSize = offsetof(NEO::ImplicitArgs, reserved); + pImplicitArgs->structSize = NEO::ImplicitArgs::getSize(); pImplicitArgs->structVersion = 0; pImplicitArgs->simdWidth = kernelDescriptor.kernelAttributes.simdSize; } diff --git a/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp b/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp index 47a6370541..53446d5cad 100644 --- a/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp +++ b/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp @@ -6,7 +6,7 @@ */ #include "shared/source/helpers/hw_info.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_assert_handler.h" diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp index 73b81e46be..88dca5a2dd 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp @@ -8,7 +8,7 @@ #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/indirect_heap/indirect_heap.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp index 46c6c67b76..06d93deb71 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp @@ -11,7 +11,7 @@ #include "shared/source/helpers/local_id_gen.h" #include "shared/source/helpers/per_thread_data.h" #include "shared/source/indirect_heap/indirect_heap.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/utilities/software_tags_manager.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/unit_test_helper.h" @@ -931,6 +931,9 @@ struct CmdlistAppendLaunchKernelWithImplicitArgsTests : CmdlistAppendLaunchKerne void SetUp() override { CmdlistAppendLaunchKernelTests::SetUp(); + memset(&expectedImplicitArgs, 0, sizeof(ImplicitArgs)); + expectedImplicitArgs.structSize = ImplicitArgs::getSize(); + expectedImplicitArgs.numWorkDim = 3; expectedImplicitArgs.simdWidth = 32; expectedImplicitArgs.localSizeX = 2; @@ -1006,7 +1009,7 @@ struct CmdlistAppendLaunchKernelWithImplicitArgsTests : CmdlistAppendLaunchKerne } std::unique_ptr commandList; GraphicsAllocation *indirectHeapAllocation = nullptr; - ImplicitArgs expectedImplicitArgs = {offsetof(ImplicitArgs, reserved)}; + ImplicitArgs expectedImplicitArgs = {ImplicitArgs::getSize()}; std::array workgroupDimOrder{0, 1, 2}; uint32_t implicitArgsProgrammingSize = 0u; @@ -1025,27 +1028,27 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CmdlistAppendLaunchKernelWithImplicitArgsTests, giv dispatchKernelWithImplicitArgs(); auto grfSize = ImplicitArgsHelper::getGrfSize(expectedImplicitArgs.simdWidth); - auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - sizeof(ImplicitArgs), MemoryConstants::cacheLineSize); + auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - ImplicitArgs::getSize(), MemoryConstants::cacheLineSize); const auto &gfxCoreHelper = device->getNEODevice()->getGfxCoreHelper(); generateLocalIDs(expectedLocalIds, expectedImplicitArgs.simdWidth, localSize, workgroupDimOrder, false, grfSize, gfxCoreHelper); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); size_t sizeForLocalIds = NEO::PerThreadDataHelper::getPerThreadDataSizeTotal(expectedImplicitArgs.simdWidth, grfSize, 3u, totalLocalSize, !kernelRequiresGenerationOfLocalIdsByRuntime, gfxCoreHelper); EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeForLocalIds)); alignedFree(expectedLocalIds); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWCMDTEST_F(IGFX_GEN8_CORE, CmdlistAppendLaunchKernelWithImplicitArgsTests, givenPreXeHpPlatformWhenAppendLaunchKernelWithImplicitArgsThenImplicitArgsAreSentToIndirectHeapWithoutLocalIds) { dispatchKernelWithImplicitArgs(); auto implicitArgsInIndirectData = indirectHeapAllocation->getUnderlyingBuffer(); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); - auto crossThreadDataInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), 0x80); + auto crossThreadDataInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), alignUp(ImplicitArgs::getSize(), 64)); auto programmedImplicitArgsGpuVA = reinterpret_cast(crossThreadDataInIndirectData)[0]; EXPECT_EQ(indirectHeapAllocation->getGpuAddress(), programmedImplicitArgsGpuVA); @@ -1071,18 +1074,18 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CmdlistAppendLaunchKernelWithImplicitArgsTests, giv dispatchKernelWithImplicitArgs(); auto grfSize = ImplicitArgsHelper::getGrfSize(expectedImplicitArgs.simdWidth); - auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - sizeof(ImplicitArgs), MemoryConstants::cacheLineSize); + auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - ImplicitArgs::getSize(), MemoryConstants::cacheLineSize); const auto &gfxCoreHelper = device->getNEODevice()->getGfxCoreHelper(); generateLocalIDs(expectedLocalIds, expectedImplicitArgs.simdWidth, localSize, expectedDimOrder, false, grfSize, gfxCoreHelper); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); size_t sizeForLocalIds = NEO::PerThreadDataHelper::getPerThreadDataSizeTotal(expectedImplicitArgs.simdWidth, grfSize, 3u, totalLocalSize, !kernelRequiresGenerationOfLocalIdsByRuntime, gfxCoreHelper); EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeForLocalIds)); alignedFree(expectedLocalIds); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWCMDTEST_F(IGFX_XE_HP_CORE, CmdlistAppendLaunchKernelWithImplicitArgsTests, givenXeHpAndLaterPlatformWhenAppendLaunchKernelWithImplicitArgsAndSimd1ThenLocalIdsAreGeneratedCorrectly) { @@ -1104,12 +1107,12 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CmdlistAppendLaunchKernelWithImplicitArgsTests, giv EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeof(expectedLocalIds))); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); EXPECT_EQ(alignUp(sizeof(expectedLocalIds), MemoryConstants::cacheLineSize), localIdsProgrammingSize); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWTEST_F(CmdlistAppendLaunchKernelTests, givenKernelWithoutImplicitArgsWhenAppendLaunchKernelThenImplicitArgsAreNotSentToIndirectHeap) { diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp index 8621dd6136..35a80aedec 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp @@ -15,7 +15,7 @@ #include "shared/source/helpers/preamble.h" #include "shared/source/helpers/register_offsets.h" #include "shared/source/indirect_heap/indirect_heap.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/internal_allocation_storage.h" #include "shared/source/os_interface/os_context.h" #include "shared/source/os_interface/product_helper.h" @@ -5715,7 +5715,7 @@ struct CommandListAppendLaunchKernelWithImplicitArgs : CommandListAppendLaunchKe if (FamilyType::supportsCmdSet(IGFX_XE_HP_CORE)) { const auto &gfxCoreHelper = device->getGfxCoreHelper(); auto implicitArgsProgrammingSize = ImplicitArgsHelper::getSizeForImplicitArgsPatching(kernel.pImplicitArgs.get(), kernel.getKernelDescriptor(), !kernel.kernelRequiresGenerationOfLocalIdsByRuntime, gfxCoreHelper); - return implicitArgsProgrammingSize - sizeof(ImplicitArgs); + return implicitArgsProgrammingSize - ImplicitArgs::getSize(); } else { return 0u; } diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index e849446024..4fac681fcf 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -15,7 +15,7 @@ #include "shared/source/helpers/per_thread_data.h" #include "shared/source/helpers/ray_tracing_helper.h" #include "shared/source/indirect_heap/indirect_heap.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/program/kernel_info.h" #include "shared/source/program/kernel_info_from_patchtokens.h" @@ -3477,7 +3477,7 @@ TEST_F(KernelImplicitArgTests, givenImplicitArgsRequiredWhenCreatingKernelThenIm auto pImplicitArgs = kernel->getImplicitArgs(); ASSERT_NE(nullptr, pImplicitArgs); - EXPECT_EQ(112u, pImplicitArgs->structSize); + EXPECT_EQ(ImplicitArgs::getSize(), pImplicitArgs->structSize); EXPECT_EQ(0u, pImplicitArgs->structVersion); } @@ -3497,7 +3497,7 @@ TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenSettingKernelParam auto pImplicitArgs = kernel->getImplicitArgs(); ASSERT_NE(nullptr, pImplicitArgs); - ImplicitArgs expectedImplicitArgs{offsetof(ImplicitArgs, reserved)}; + ImplicitArgs expectedImplicitArgs{ImplicitArgs::getSize()}; expectedImplicitArgs.numWorkDim = 3; expectedImplicitArgs.simdWidth = simd; @@ -3519,7 +3519,7 @@ TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenSettingKernelParam kernel->setGroupCount(3, 2, 1); kernel->setGlobalOffsetExp(1, 2, 3); kernel->patchGlobalOffset(); - EXPECT_EQ(0, memcmp(pImplicitArgs, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(pImplicitArgs, &expectedImplicitArgs, ImplicitArgs::getSize())); } using BindlessKernelTest = Test; diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index 092835abd6..f3bae3ef2d 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -18,7 +18,7 @@ #include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/helpers/file_io.h" #include "shared/source/helpers/gfx_core_helper.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/os_interface/os_inc_base.h" #include "shared/source/program/kernel_info.h" #include "shared/test/common/compiler_interface/linker_mock.h" @@ -1732,7 +1732,7 @@ TEST_F(ModuleDynamicLinkTests, givenModuleWithInternalRelocationAndUnresolvedExt uint32_t internalRelocationOffset = 0x10; linkerInput->textRelocations.push_back({{implicitArgsRelocationSymbolName, internalRelocationOffset, LinkerInput::RelocationInfo::Type::Address, SegmentType::Instructions}}); - uint32_t expectedInternalRelocationValue = sizeof(ImplicitArgs); + uint32_t expectedInternalRelocationValue = ImplicitArgs::getSize(); uint32_t externalRelocationOffset = 0x20; constexpr auto externalSymbolName = "unresolved"; @@ -4437,7 +4437,7 @@ TEST_F(ModuleTests, givenImplicitArgsRelocationAndStackCallsWhenLinkingModuleThe auto status = pModule->linkBinary(); EXPECT_TRUE(status); - EXPECT_EQ(sizeof(ImplicitArgs), *reinterpret_cast(ptrOffset(isaCpuPtr, 0x8))); + EXPECT_EQ(ImplicitArgs::getSize(), *reinterpret_cast(ptrOffset(isaCpuPtr, 0x8))); EXPECT_TRUE(kernelInfo->kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs); } diff --git a/opencl/source/gen11/gtpin_setup_gen11.cpp b/opencl/source/gen11/gtpin_setup_gen11.cpp index b7d86981dc..90e3bd7ad4 100644 --- a/opencl/source/gen11/gtpin_setup_gen11.cpp +++ b/opencl/source/gen11/gtpin_setup_gen11.cpp @@ -7,7 +7,7 @@ #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/gen11/hw_cmds_base.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.inl" diff --git a/opencl/source/gen12lp/gtpin_setup_gen12lp.cpp b/opencl/source/gen12lp/gtpin_setup_gen12lp.cpp index 9317a37853..c5f3c09fa7 100644 --- a/opencl/source/gen12lp/gtpin_setup_gen12lp.cpp +++ b/opencl/source/gen12lp/gtpin_setup_gen12lp.cpp @@ -7,7 +7,7 @@ #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/gen12lp/hw_cmds_base.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.inl" diff --git a/opencl/source/gen8/gtpin_setup_gen8.cpp b/opencl/source/gen8/gtpin_setup_gen8.cpp index 06d6882b20..daed0e279a 100644 --- a/opencl/source/gen8/gtpin_setup_gen8.cpp +++ b/opencl/source/gen8/gtpin_setup_gen8.cpp @@ -7,7 +7,7 @@ #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/gen8/hw_cmds_base.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.inl" diff --git a/opencl/source/gen9/gtpin_setup_gen9.cpp b/opencl/source/gen9/gtpin_setup_gen9.cpp index e123e95fe9..59717030a4 100644 --- a/opencl/source/gen9/gtpin_setup_gen9.cpp +++ b/opencl/source/gen9/gtpin_setup_gen9.cpp @@ -7,7 +7,7 @@ #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/gen9/hw_cmds_base.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.inl" diff --git a/opencl/source/helpers/hardware_commands_helper_base.inl b/opencl/source/helpers/hardware_commands_helper_base.inl index b5a364cf05..6b693a34e9 100644 --- a/opencl/source/helpers/hardware_commands_helper_base.inl +++ b/opencl/source/helpers/hardware_commands_helper_base.inl @@ -18,7 +18,7 @@ #include "shared/source/helpers/local_id_gen.h" #include "shared/source/indirect_heap/indirect_heap.h" #include "shared/source/kernel/dispatch_kernel_encoder_interface.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/memory_manager.h" #include "opencl/source/cl_device/cl_device.h" diff --git a/opencl/source/helpers/hardware_commands_helper_xehp_and_later.inl b/opencl/source/helpers/hardware_commands_helper_xehp_and_later.inl index faae9dad02..247ec5c70f 100644 --- a/opencl/source/helpers/hardware_commands_helper_xehp_and_later.inl +++ b/opencl/source/helpers/hardware_commands_helper_xehp_and_later.inl @@ -11,7 +11,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/l3_range.h" #include "shared/source/helpers/pipe_control_args.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "opencl/source/command_queue/command_queue.h" #include "opencl/source/helpers/hardware_commands_helper.h" @@ -94,7 +94,7 @@ size_t HardwareCommandsHelper::sendCrossThreadData( const auto &gfxCoreHelper = kernel.getGfxCoreHelper(); auto sizeForImplicitArgsProgramming = ImplicitArgsHelper::getSizeForImplicitArgsPatching(pImplicitArgs, kernelDescriptor, !generationOfLocalIdsByRuntime, gfxCoreHelper); - auto sizeForLocalIdsProgramming = sizeForImplicitArgsProgramming - sizeof(ImplicitArgs); + auto sizeForLocalIdsProgramming = sizeForImplicitArgsProgramming - ImplicitArgs::getSize(); offsetCrossThreadData += sizeForLocalIdsProgramming; auto ptrToPatchImplicitArgs = indirectHeap.getSpace(sizeForImplicitArgsProgramming); diff --git a/opencl/source/kernel/image_transformer.cpp b/opencl/source/kernel/image_transformer.cpp index 46839967c2..ee504ab6d8 100644 --- a/opencl/source/kernel/image_transformer.cpp +++ b/opencl/source/kernel/image_transformer.cpp @@ -9,7 +9,7 @@ #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/helpers/ptr_math.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/program/kernel_info.h" #include "opencl/source/mem_obj/image.h" diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 9338aa1057..d370e6e881 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -27,7 +27,7 @@ #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/surface_format_info.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_arg_descriptor_extended_vme.h" #include "shared/source/kernel/local_ids_cache.h" #include "shared/source/memory_manager/allocation_properties.h" @@ -176,7 +176,7 @@ cl_int Kernel::initialize() { if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) { pImplicitArgs = std::make_unique(); *pImplicitArgs = {}; - pImplicitArgs->structSize = offsetof(ImplicitArgs, reserved); + pImplicitArgs->structSize = ImplicitArgs::getSize(); pImplicitArgs->structVersion = 0; pImplicitArgs->simdWidth = maxSimdSize; } @@ -426,7 +426,7 @@ cl_int Kernel::cloneKernel(Kernel *pSourceKernel) { } if (pImplicitArgs) { - memcpy_s(pImplicitArgs.get(), sizeof(ImplicitArgs), pSourceKernel->getImplicitArgs(), sizeof(ImplicitArgs)); + memcpy_s(pImplicitArgs.get(), ImplicitArgs::getSize(), pSourceKernel->getImplicitArgs(), ImplicitArgs::getSize()); } this->isBuiltIn = pSourceKernel->isBuiltIn; diff --git a/opencl/source/kernel/kernel.h b/opencl/source/kernel/kernel.h index 85ccded5dc..cc721b804f 100644 --- a/opencl/source/kernel/kernel.h +++ b/opencl/source/kernel/kernel.h @@ -11,7 +11,7 @@ #include "shared/source/device/device.h" #include "shared/source/helpers/aux_translation.h" #include "shared/source/helpers/vec.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_execution_type.h" #include "shared/source/program/kernel_info.h" #include "shared/source/unified_memory/unified_memory.h" diff --git a/opencl/source/program/printf_handler.cpp b/opencl/source/program/printf_handler.cpp index d761637baf..624ca3cdb3 100644 --- a/opencl/source/program/printf_handler.cpp +++ b/opencl/source/program/printf_handler.cpp @@ -13,7 +13,7 @@ #include "shared/source/helpers/blit_properties.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/ptr_math.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/allocation_properties.h" #include "shared/source/memory_manager/compression_selector.h" #include "shared/source/memory_manager/memory_manager.h" diff --git a/opencl/source/xe_hpc_core/gtpin_setup_xe_hpc_core.cpp b/opencl/source/xe_hpc_core/gtpin_setup_xe_hpc_core.cpp index f68ede6530..3ff1fc923e 100644 --- a/opencl/source/xe_hpc_core/gtpin_setup_xe_hpc_core.cpp +++ b/opencl/source/xe_hpc_core/gtpin_setup_xe_hpc_core.cpp @@ -6,7 +6,7 @@ */ #include "shared/source/compiler_interface/external_functions.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" diff --git a/opencl/source/xe_hpg_core/gtpin_setup_xe_hpg_core.cpp b/opencl/source/xe_hpg_core/gtpin_setup_xe_hpg_core.cpp index 062ec09c36..0dc45efafe 100644 --- a/opencl/source/xe_hpg_core/gtpin_setup_xe_hpg_core.cpp +++ b/opencl/source/xe_hpg_core/gtpin_setup_xe_hpg_core.cpp @@ -6,7 +6,7 @@ */ #include "shared/source/compiler_interface/external_functions.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" #include "opencl/source/gtpin/gtpin_gfx_core_helper.h" diff --git a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp index dbf0d2ddb8..9cb32923d5 100644 --- a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp +++ b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp @@ -10,7 +10,7 @@ #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/local_work_size.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/internal_allocation_storage.h" #include "shared/source/utilities/hw_timestamps.h" #include "shared/source/utilities/perf_counter.h" diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp index 412113f179..bc6f2b8b63 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp @@ -10,7 +10,7 @@ #include "shared/source/command_stream/scratch_space_controller.h" #include "shared/source/command_stream/wait_status.h" #include "shared/source/helpers/gfx_core_helper.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/allocations_list.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" diff --git a/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp b/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp index 5d75d87d6b..3a9165f78a 100644 --- a/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp @@ -12,7 +12,7 @@ #include "shared/source/helpers/address_patch.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/engine_node_helper.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/unified_memory_manager.h" #include "shared/source/os_interface/os_context.h" #include "shared/test/common/cmd_parse/hw_parse.h" @@ -1101,6 +1101,9 @@ struct HardwareCommandsImplicitArgsTests : Test { ClDeviceFixture::setUp(); indirectHeapAllocation = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); + memset(&expectedImplicitArgs, 0, sizeof(ImplicitArgs)); + expectedImplicitArgs.structSize = ImplicitArgs::getSize(); + expectedImplicitArgs.numWorkDim = 3; expectedImplicitArgs.simdWidth = 32; expectedImplicitArgs.localSizeX = 2; @@ -1170,7 +1173,7 @@ struct HardwareCommandsImplicitArgsTests : Test { } } - ImplicitArgs expectedImplicitArgs = {offsetof(ImplicitArgs, reserved)}; + ImplicitArgs expectedImplicitArgs = {ImplicitArgs::getSize()}; GraphicsAllocation *indirectHeapAllocation = nullptr; std::array workgroupDimOrder{0, 1, 2}; uint32_t implicitArgsProgrammingSize = 0u; @@ -1179,18 +1182,18 @@ struct HardwareCommandsImplicitArgsTests : Test { HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenXeHpAndLaterPlatformWhenSendingIndirectStateForKernelWithImplicitArgsThenImplicitArgsAreSentToIndirectHeapWithLocalIds) { dispatchKernelWithImplicitArgs(); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWCMDTEST_F(IGFX_GEN8_CORE, HardwareCommandsImplicitArgsTests, givenPreXeHpPlatformWhenSendingIndirectStateForKernelWithImplicitArgsThenImplicitArgsAreSentToIndirectHeapWithoutLocalIds) { dispatchKernelWithImplicitArgs(); auto implicitArgsInIndirectData = indirectHeapAllocation->getUnderlyingBuffer(); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); - auto crossThreadDataInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), 0x80); + auto crossThreadDataInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), alignUp(ImplicitArgs::getSize(), MemoryConstants::cacheLineSize)); auto programmedImplicitArgsGpuVA = reinterpret_cast(crossThreadDataInIndirectData)[0]; EXPECT_EQ(indirectHeapAllocation->getGpuAddress(), programmedImplicitArgsGpuVA); @@ -1214,18 +1217,18 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenKernelWithI dispatchKernelWithImplicitArgs(); auto grfSize = ImplicitArgsHelper::getGrfSize(expectedImplicitArgs.simdWidth); - auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - sizeof(ImplicitArgs), MemoryConstants::cacheLineSize); + auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - ImplicitArgs::getSize(), MemoryConstants::cacheLineSize); const auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); generateLocalIDs(expectedLocalIds, expectedImplicitArgs.simdWidth, localSize, workgroupDimOrder, false, grfSize, gfxCoreHelper); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); size_t sizeForLocalIds = PerThreadDataHelper::getPerThreadDataSizeTotal(expectedImplicitArgs.simdWidth, grfSize, 3u, totalLocalSize, false, gfxCoreHelper); EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeForLocalIds)); alignedFree(expectedLocalIds); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenKernelWithImplicitArgsAndHwLocalIdsGenerationWhenSendingIndirectStateThenLocalIdsAreGeneratedAndCorrectlyProgrammedInCrossThreadData) { @@ -1248,18 +1251,18 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenKernelWithI dispatchKernelWithImplicitArgs(); auto grfSize = ImplicitArgsHelper::getGrfSize(expectedImplicitArgs.simdWidth); - auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - sizeof(ImplicitArgs), MemoryConstants::cacheLineSize); + auto expectedLocalIds = alignedMalloc(implicitArgsProgrammingSize - ImplicitArgs::getSize(), MemoryConstants::cacheLineSize); const auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); generateLocalIDs(expectedLocalIds, expectedImplicitArgs.simdWidth, localSize, expectedDimOrder, false, grfSize, gfxCoreHelper); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); size_t sizeForLocalIds = PerThreadDataHelper::getPerThreadDataSizeTotal(expectedImplicitArgs.simdWidth, grfSize, 3u, totalLocalSize, false, gfxCoreHelper); EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeForLocalIds)); alignedFree(expectedLocalIds); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenKernelWithImplicitArgsWhenSendingIndirectStateWithSimd1ThenLocalIdsAreGeneratedCorrectly) { @@ -1281,12 +1284,12 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsImplicitArgsTests, givenKernelWithI EXPECT_EQ(0, memcmp(expectedLocalIds, indirectHeapAllocation->getUnderlyingBuffer(), sizeof(expectedLocalIds))); - auto localIdsProgrammingSize = implicitArgsProgrammingSize - sizeof(ImplicitArgs); + auto localIdsProgrammingSize = implicitArgsProgrammingSize - ImplicitArgs::getSize(); EXPECT_EQ(alignUp(sizeof(expectedLocalIds), MemoryConstants::cacheLineSize), localIdsProgrammingSize); auto implicitArgsInIndirectData = ptrOffset(indirectHeapAllocation->getUnderlyingBuffer(), localIdsProgrammingSize); - EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(implicitArgsInIndirectData, &expectedImplicitArgs, ImplicitArgs::getSize())); } using HardwareCommandsTestXeHpAndLater = HardwareCommandsTest; diff --git a/opencl/test/unit_test/helpers/test_preamble_dg2_and_later.cpp b/opencl/test/unit_test/helpers/test_preamble_dg2_and_later.cpp index 206daf9eed..0018b8d1ae 100644 --- a/opencl/test/unit_test/helpers/test_preamble_dg2_and_later.cpp +++ b/opencl/test/unit_test/helpers/test_preamble_dg2_and_later.cpp @@ -8,7 +8,7 @@ #include "shared/source/command_stream/stream_properties.h" #include "shared/source/compiler_interface/external_functions.h" #include "shared/source/debug_settings/debug_settings_manager.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/os_interface/product_helper.h" #include "shared/test/common/fixtures/preamble_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 7b36b61a86..fb26b07c6c 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -14,7 +14,7 @@ #include "shared/source/helpers/flush_stamp.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/surface_format_info.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/allocations_list.h" #include "shared/source/memory_manager/unified_memory_manager.h" #include "shared/source/os_interface/os_context.h" @@ -3322,8 +3322,8 @@ TEST_F(KernelImplicitArgsTest, WhenKernelRequiresImplicitArgsThenImplicitArgsStr ASSERT_NE(nullptr, pImplicitArgs); - ImplicitArgs expectedImplicitArgs = {offsetof(ImplicitArgs, reserved), 0, 0, 32}; - EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, sizeof(ImplicitArgs))); + ImplicitArgs expectedImplicitArgs = {ImplicitArgs::getSize(), 0, 0, 32}; + EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, ImplicitArgs::getSize())); } } @@ -3341,7 +3341,7 @@ TEST_F(KernelImplicitArgsTest, givenKernelWithImplicitArgsWhenSettingKernelParam ASSERT_NE(nullptr, pImplicitArgs); - ImplicitArgs expectedImplicitArgs = {offsetof(ImplicitArgs, reserved)}; + ImplicitArgs expectedImplicitArgs = {ImplicitArgs::getSize()}; expectedImplicitArgs.numWorkDim = 3; expectedImplicitArgs.simdWidth = 32; expectedImplicitArgs.localSizeX = 4; @@ -3363,7 +3363,7 @@ TEST_F(KernelImplicitArgsTest, givenKernelWithImplicitArgsWhenSettingKernelParam kernel.setGlobalWorkOffsetValues(1, 2, 3); kernel.setNumWorkGroupsValues(3, 2, 1); - EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, ImplicitArgs::getSize())); } TEST_F(KernelImplicitArgsTest, givenKernelWithImplicitArgsWhenCloneKernelThenImplicitArgsAreCopied) { @@ -3379,7 +3379,7 @@ TEST_F(KernelImplicitArgsTest, givenKernelWithImplicitArgsWhenCloneKernelThenImp ASSERT_EQ(CL_SUCCESS, kernel.initialize()); ASSERT_EQ(CL_SUCCESS, kernel2.initialize()); - ImplicitArgs expectedImplicitArgs = {offsetof(ImplicitArgs, reserved)}; + ImplicitArgs expectedImplicitArgs = {ImplicitArgs::getSize()}; expectedImplicitArgs.numWorkDim = 3; expectedImplicitArgs.simdWidth = 32; expectedImplicitArgs.localSizeX = 4; @@ -3407,7 +3407,7 @@ TEST_F(KernelImplicitArgsTest, givenKernelWithImplicitArgsWhenCloneKernelThenImp ASSERT_NE(nullptr, pImplicitArgs); - EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, sizeof(ImplicitArgs))); + EXPECT_EQ(0, memcmp(&expectedImplicitArgs, pImplicitArgs, ImplicitArgs::getSize())); } TEST_F(KernelImplicitArgsTest, givenKernelWithoutImplicitArgsWhenSettingKernelParamsThenImplicitArgsAreNotSet) { diff --git a/opencl/test/unit_test/program/printf_handler_tests.cpp b/opencl/test/unit_test/program/printf_handler_tests.cpp index a13485f750..81eaf4b2b6 100644 --- a/opencl/test/unit_test/program/printf_handler_tests.cpp +++ b/opencl/test/unit_test/program/printf_handler_tests.cpp @@ -7,7 +7,7 @@ #include "shared/source/command_stream/wait_status.h" #include "shared/source/helpers/local_memory_access_modes.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_device.h" diff --git a/opencl/test/unit_test/program/program_data_tests.cpp b/opencl/test/unit_test/program/program_data_tests.cpp index 8d1308f629..645c8b0162 100644 --- a/opencl/test/unit_test/program/program_data_tests.cpp +++ b/opencl/test/unit_test/program/program_data_tests.cpp @@ -6,7 +6,7 @@ */ #include "shared/source/helpers/string.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/memory_manager/allocations_list.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/unified_memory_manager.h" diff --git a/opencl/test/unit_test/test_macros/test_checks_ocl.cpp b/opencl/test/unit_test/test_macros/test_checks_ocl.cpp index 350da12719..7e1ca92571 100644 --- a/opencl/test/unit_test/test_macros/test_checks_ocl.cpp +++ b/opencl/test/unit_test/test_macros/test_checks_ocl.cpp @@ -12,7 +12,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/hw_info.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/test/common/helpers/default_hw_info.h" #include "opencl/source/cl_device/cl_device.h" diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 212306c4eb..e462e51b1f 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -26,7 +26,7 @@ #include "shared/source/image/image_surface_state.h" #include "shared/source/indirect_heap/indirect_heap.h" #include "shared/source/kernel/dispatch_kernel_encoder_interface.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/program/kernel_info.h" diff --git a/shared/source/command_container/command_encoder_bdw_and_later.inl b/shared/source/command_container/command_encoder_bdw_and_later.inl index fcf8aca815..bea96a336b 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -22,7 +22,7 @@ #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/state_base_address.h" #include "shared/source/kernel/dispatch_kernel_encoder_interface.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 60ad476248..3848f7de20 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -27,7 +27,7 @@ #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/state_base_address.h" #include "shared/source/kernel/dispatch_kernel_encoder_interface.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/os_interface/product_helper.h" @@ -255,7 +255,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis offsetThreadData = (is64bit ? heap->getHeapGpuStartOffset() : heap->getHeapGpuBase()) + static_cast(heap->getUsed() - sizeThreadData); if (pImplicitArgs) { - offsetThreadData -= sizeof(ImplicitArgs); + offsetThreadData -= ImplicitArgs::getSize(); pImplicitArgs->localIdTablePtr = heap->getGraphicsAllocation()->getGpuAddress() + heap->getUsed() - iohRequiredSize; ptr = NEO::ImplicitArgsHelper::patchImplicitArgs(ptr, *pImplicitArgs, kernelDescriptor, std::make_pair(localIdsGenerationByRuntime, requiredWorkgroupOrder), gfxCoreHelper); } @@ -269,7 +269,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis auto gpuPtr = heap->getGraphicsAllocation()->getGpuAddress() + static_cast(heap->getUsed() - sizeThreadData - inlineDataProgrammingOffset); uint64_t implicitArgsGpuPtr = 0u; if (pImplicitArgs) { - implicitArgsGpuPtr = gpuPtr + inlineDataProgrammingOffset - sizeof(ImplicitArgs); + implicitArgsGpuPtr = gpuPtr + inlineDataProgrammingOffset - ImplicitArgs::getSize(); } EncodeIndirectParams::encode(container, gpuPtr, args.dispatchInterface, implicitArgsGpuPtr); } diff --git a/shared/source/compiler_interface/linker.cpp b/shared/source/compiler_interface/linker.cpp index f9d59cb6b5..ae9fbdb58c 100644 --- a/shared/source/compiler_interface/linker.cpp +++ b/shared/source/compiler_interface/linker.cpp @@ -16,7 +16,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/string.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/memory_manager.h" @@ -648,7 +648,7 @@ void Linker::resolveImplicitArgs(const KernelDescriptorsT &kernelDescriptors, De UNRECOVERABLE_IF(!pDevice); kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs = kernelDescriptor.kernelAttributes.flags.useStackCalls || pDevice->getDebugger() != nullptr; if (kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs) { - *pImplicitArgsReloc = sizeof(ImplicitArgs); + *pImplicitArgsReloc = ImplicitArgs::getSize(); } } } diff --git a/shared/source/kernel/CMakeLists.txt b/shared/source/kernel/CMakeLists.txt index 0febcb5655..bc7b231202 100644 --- a/shared/source/kernel/CMakeLists.txt +++ b/shared/source/kernel/CMakeLists.txt @@ -9,8 +9,9 @@ set(NEO_CORE_KERNEL ${CMAKE_CURRENT_SOURCE_DIR}/debug_data.h ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_kernel_encoder_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/grf_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/implicit_args.h + ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}implicit_args.h ${CMAKE_CURRENT_SOURCE_DIR}/implicit_args_helper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/implicit_args_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor_extended_vme.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_metadata.h diff --git a/shared/source/kernel/definitions/implicit_args.h b/shared/source/kernel/definitions/implicit_args.h new file mode 100644 index 0000000000..f76a1803c5 --- /dev/null +++ b/shared/source/kernel/definitions/implicit_args.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include +#include +#include + +namespace NEO { + +struct alignas(32) ImplicitArgs { + uint8_t structSize; + uint8_t structVersion; + uint8_t numWorkDim; + uint8_t simdWidth; + uint32_t localSizeX; + uint32_t localSizeY; + uint32_t localSizeZ; + uint64_t globalSizeX; + uint64_t globalSizeY; + uint64_t globalSizeZ; + uint64_t printfBufferPtr; + uint64_t globalOffsetX; + uint64_t globalOffsetY; + uint64_t globalOffsetZ; + uint64_t localIdTablePtr; + uint32_t groupCountX; + uint32_t groupCountY; + uint32_t groupCountZ; + uint32_t padding0; + uint64_t rtGlobalBufferPtr; + uint64_t assertBufferPtr; + uint8_t reserved[16]; + + static constexpr uint8_t getSize() { return static_cast((offsetof(ImplicitArgs, reserved))); } +}; + +static_assert(std::alignment_of_v == 32, "Implicit args size need to be aligned to 32"); +static_assert(sizeof(ImplicitArgs) == (32 * sizeof(uint32_t))); +static_assert(ImplicitArgs::getSize() == (28 * sizeof(uint32_t))); +static_assert(std::is_pod::value); + +} // namespace NEO diff --git a/shared/source/kernel/implicit_args_helper.cpp b/shared/source/kernel/implicit_args_helper.cpp index 240557c5d8..2bba449f2e 100644 --- a/shared/source/kernel/implicit_args_helper.cpp +++ b/shared/source/kernel/implicit_args_helper.cpp @@ -5,6 +5,8 @@ * */ +#include "shared/source/kernel/implicit_args_helper.h" + #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/hw_walk_order.h" @@ -13,7 +15,6 @@ #include "shared/source/helpers/simd_helper.h" #include "shared/source/helpers/string.h" #include "shared/source/helpers/vec.h" -#include "shared/source/kernel/implicit_args.h" #include "shared/source/kernel/kernel_descriptor.h" namespace NEO { @@ -46,7 +47,7 @@ uint32_t getSizeForImplicitArgsPatching(const ImplicitArgs *pImplicitArgs, const if (!pImplicitArgs) { return 0; } - auto implicitArgsSize = static_cast(sizeof(NEO::ImplicitArgs)); + auto implicitArgsSize = static_cast(ImplicitArgs::getSize()); auto patchImplicitArgsBufferInCrossThread = NEO::isValidOffset<>(kernelDescriptor.payloadMappings.implicitArgs.implicitArgsBuffer); if (patchImplicitArgsBufferInCrossThread) { return alignUp(implicitArgsSize, MemoryConstants::cacheLineSize); @@ -82,10 +83,10 @@ void *patchImplicitArgs(void *ptrToPatch, const ImplicitArgs &implicitArgs, cons static_cast(implicitArgs.localSizeZ)}}, dimensionOrder, false, grfSize, gfxCoreHelper); - auto sizeForLocalIdsProgramming = totalSizeToProgram - sizeof(NEO::ImplicitArgs); + auto sizeForLocalIdsProgramming = totalSizeToProgram - ImplicitArgs::getSize(); ptrToPatch = ptrOffset(ptrToPatch, sizeForLocalIdsProgramming); } - memcpy_s(ptrToPatch, sizeof(NEO::ImplicitArgs), &implicitArgs, sizeof(NEO::ImplicitArgs)); + memcpy_s(ptrToPatch, ImplicitArgs::getSize(), &implicitArgs, ImplicitArgs::getSize()); return retVal; } diff --git a/shared/source/kernel/implicit_args.h b/shared/source/kernel/implicit_args_helper.h similarity index 60% rename from shared/source/kernel/implicit_args.h rename to shared/source/kernel/implicit_args_helper.h index 5e72622d13..71b07ad8db 100644 --- a/shared/source/kernel/implicit_args.h +++ b/shared/source/kernel/implicit_args_helper.h @@ -7,6 +7,8 @@ #pragma once +#include "implicit_args.h" + #include #include #include @@ -17,35 +19,6 @@ namespace NEO { struct KernelDescriptor; class GfxCoreHelper; -struct ImplicitArgs { - uint8_t structSize; - uint8_t structVersion; - uint8_t numWorkDim; - uint8_t simdWidth; - uint32_t localSizeX; - uint32_t localSizeY; - uint32_t localSizeZ; - uint64_t globalSizeX; - uint64_t globalSizeY; - uint64_t globalSizeZ; - uint64_t printfBufferPtr; - uint64_t globalOffsetX; - uint64_t globalOffsetY; - uint64_t globalOffsetZ; - uint64_t localIdTablePtr; - uint32_t groupCountX; - uint32_t groupCountY; - uint32_t groupCountZ; - uint32_t padding0; - uint64_t rtGlobalBufferPtr; - uint64_t assertBufferPtr; - uint8_t reserved[16]; -}; - -static_assert((sizeof(ImplicitArgs) & 31) == 0, "Implicit args size need to be aligned to 32"); -static_assert(sizeof(ImplicitArgs) == 128); -static_assert(std::is_pod::value); - inline constexpr const char *implicitArgsRelocationSymbolName = "__INTEL_PATCH_CROSS_THREAD_OFFSET_OFF_R0"; namespace ImplicitArgsHelper { diff --git a/shared/test/unit_test/compiler_interface/linker_tests.cpp b/shared/test/unit_test/compiler_interface/linker_tests.cpp index 05b99dd49a..ac995e6210 100644 --- a/shared/test/unit_test/compiler_interface/linker_tests.cpp +++ b/shared/test/unit_test/compiler_interface/linker_tests.cpp @@ -9,7 +9,7 @@ #include "shared/source/device_binary_format/zebin/zebin_elf.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/string.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/program/program_initialization.h" @@ -1977,7 +1977,7 @@ TEST_F(LinkerTests, givenImplicitArgRelocationAndStackCallsThenPatchRelocationWi EXPECT_EQ(0U, relocatedSymbols.size()); auto addressToPatch = reinterpret_cast(instructionSegment.data() + reloc.r_offset); - EXPECT_EQ(sizeof(ImplicitArgs), *addressToPatch); + EXPECT_EQ(ImplicitArgs::getSize(), *addressToPatch); EXPECT_EQ(initData, *(addressToPatch - 1)); EXPECT_EQ(initData, *(addressToPatch + 1)); EXPECT_TRUE(kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs); @@ -2039,7 +2039,7 @@ TEST_F(LinkerDebuggingSupportedTests, givenImplicitArgRelocationAndEnabledDebugg EXPECT_EQ(0U, relocatedSymbols.size()); auto addressToPatch = reinterpret_cast(instructionSegment.data() + reloc.r_offset); - EXPECT_EQ(sizeof(ImplicitArgs), *addressToPatch); + EXPECT_EQ(ImplicitArgs::getSize(), *addressToPatch); EXPECT_EQ(initData, *(addressToPatch - 1)); EXPECT_EQ(initData, *(addressToPatch + 1)); EXPECT_TRUE(kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs); @@ -2246,7 +2246,7 @@ TEST_F(LinkerTests, givenMultipleImplicitArgsRelocationsWithinSingleKernelWhenLi for (const auto &reloc : relocs) { auto addressToPatch = reinterpret_cast(instructionSegment.data() + reloc.r_offset); - EXPECT_EQ(sizeof(ImplicitArgs), *addressToPatch); + EXPECT_EQ(ImplicitArgs::getSize(), *addressToPatch); EXPECT_TRUE(kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs); } } diff --git a/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp b/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp index 1a1dcf5cdd..ecf3389085 100644 --- a/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp +++ b/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp @@ -10,7 +10,7 @@ #include "shared/source/helpers/hw_walk_order.h" #include "shared/source/helpers/per_thread_data.h" #include "shared/source/helpers/ptr_math.h" -#include "shared/source/kernel/implicit_args.h" +#include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/kernel/kernel_descriptor.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/test_macros/hw_test.h" @@ -62,7 +62,7 @@ TEST(ImplicitArgsHelperTest, givenNoImplicitArgsWhenGettingSizeForImplicitArgsPr } TEST(ImplicitArgsHelperTest, givenImplicitArgsWithoutImplicitArgsBufferOffsetInPayloadMappingWhenGettingSizeForImplicitArgsProgrammingThenCorrectSizeIsReturned) { - ImplicitArgs implicitArgs{offsetof(ImplicitArgs, reserved)}; + ImplicitArgs implicitArgs{ImplicitArgs::getSize()}; KernelDescriptor kernelDescriptor{}; @@ -77,11 +77,11 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithoutImplicitArgsBufferOffsetInP auto gfxCoreHelper = GfxCoreHelper::create(defaultHwInfo->platform.eRenderCoreFamily); auto localIdsSize = alignUp(PerThreadDataHelper::getPerThreadDataSizeTotal(implicitArgs.simdWidth, 32u /* grfSize */, 3u /* num channels */, totalWorkgroupSize, false, *gfxCoreHelper.get()), MemoryConstants::cacheLineSize); - EXPECT_EQ(localIdsSize + sizeof(NEO::ImplicitArgs), ImplicitArgsHelper::getSizeForImplicitArgsPatching(&implicitArgs, kernelDescriptor, false, *gfxCoreHelper.get())); + EXPECT_EQ(localIdsSize + ImplicitArgs::getSize(), ImplicitArgsHelper::getSizeForImplicitArgsPatching(&implicitArgs, kernelDescriptor, false, *gfxCoreHelper.get())); } TEST(ImplicitArgsHelperTest, givenImplicitArgsWithImplicitArgsBufferOffsetInPayloadMappingWhenGettingSizeForImplicitArgsProgrammingThenCorrectSizeIsReturned) { - ImplicitArgs implicitArgs{offsetof(ImplicitArgs, reserved)}; + ImplicitArgs implicitArgs{ImplicitArgs::getSize()}; KernelDescriptor kernelDescriptor{}; kernelDescriptor.payloadMappings.implicitArgs.implicitArgsBuffer = 0x10; @@ -96,7 +96,7 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithImplicitArgsBufferOffsetInPayl } TEST(ImplicitArgsHelperTest, givenImplicitArgsWithoutImplicitArgsBufferOffsetInPayloadMappingWhenPatchingImplicitArgsThenOnlyProperRegionIsPatched) { - ImplicitArgs implicitArgs{offsetof(ImplicitArgs, reserved)}; + ImplicitArgs implicitArgs{ImplicitArgs::getSize()}; KernelDescriptor kernelDescriptor{}; kernelDescriptor.kernelAttributes.workgroupDimensionsOrder[0] = 0; @@ -131,7 +131,7 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithoutImplicitArgsBufferOffsetInP EXPECT_NE(pattern, memoryToPatch.get()[offset]) << offset; } - for (; offset < totalSizeForPatching - sizeof(implicitArgs); offset++) { + for (; offset < totalSizeForPatching - ImplicitArgs::getSize(); offset++) { EXPECT_EQ(pattern, memoryToPatch.get()[offset]); } @@ -141,7 +141,7 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithoutImplicitArgsBufferOffsetInP } TEST(ImplicitArgsHelperTest, givenImplicitArgsWithImplicitArgsBufferOffsetInPayloadMappingWhenPatchingImplicitArgsThenOnlyProperRegionIsPatched) { - ImplicitArgs implicitArgs{offsetof(ImplicitArgs, reserved)}; + ImplicitArgs implicitArgs{ImplicitArgs::getSize()}; KernelDescriptor kernelDescriptor{}; kernelDescriptor.payloadMappings.implicitArgs.implicitArgsBuffer = 0x10; @@ -154,7 +154,7 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithImplicitArgsBufferOffsetInPayl auto gfxCoreHelper = GfxCoreHelper::create(defaultHwInfo->platform.eRenderCoreFamily); auto totalSizeForPatching = ImplicitArgsHelper::getSizeForImplicitArgsPatching(&implicitArgs, kernelDescriptor, false, *gfxCoreHelper.get()); - EXPECT_EQ(0x80u, totalSizeForPatching); + EXPECT_EQ(alignUp(ImplicitArgs::getSize(), MemoryConstants::cacheLineSize), totalSizeForPatching); auto memoryToPatch = std::make_unique(totalSizeForPatching); @@ -168,7 +168,7 @@ TEST(ImplicitArgsHelperTest, givenImplicitArgsWithImplicitArgsBufferOffsetInPayl uint32_t offset = 0; - for (; offset < sizeof(implicitArgs); offset++) { + for (; offset < ImplicitArgs::getSize(); offset++) { EXPECT_NE(pattern, memoryToPatch.get()[offset]); }