mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Correct dimension order in local ids generated for implicit args
when local ids are generated by HW, use same dim order for runtime generation move common logic to separated file Related-To: NEO-5081 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ca5a8162eb
commit
b697d75695
@@ -64,7 +64,7 @@ struct EncodeDispatchKernel {
|
||||
static void *getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset);
|
||||
|
||||
static bool isRuntimeLocalIdsGenerationRequired(uint32_t activeChannels,
|
||||
size_t *lws,
|
||||
const size_t *lws,
|
||||
std::array<uint8_t, 3> walkOrder,
|
||||
bool requireInputWalkOrder,
|
||||
uint32_t &requiredWalkOrder,
|
||||
|
||||
@@ -263,7 +263,7 @@ void EncodeMediaInterfaceDescriptorLoad<Family>::encode(CommandContainer &contai
|
||||
|
||||
template <typename Family>
|
||||
inline bool EncodeDispatchKernel<Family>::isRuntimeLocalIdsGenerationRequired(uint32_t activeChannels,
|
||||
size_t *lws,
|
||||
const size_t *lws,
|
||||
std::array<uint8_t, 3> walkOrder,
|
||||
bool requireInputWalkOrder,
|
||||
uint32_t &requiredWalkOrder,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_walk_order.h"
|
||||
#include "shared/source/helpers/pipe_control_args.h"
|
||||
#include "shared/source/helpers/pipeline_select_helper.h"
|
||||
#include "shared/source/helpers/ray_tracing_helper.h"
|
||||
@@ -298,7 +299,7 @@ inline void EncodeDispatchKernel<Family>::encodeAdditionalWalkerFields(const Har
|
||||
|
||||
template <typename Family>
|
||||
bool EncodeDispatchKernel<Family>::isRuntimeLocalIdsGenerationRequired(uint32_t activeChannels,
|
||||
size_t *lws,
|
||||
const size_t *lws,
|
||||
std::array<uint8_t, 3> walkOrder,
|
||||
bool requireInputWalkOrder,
|
||||
uint32_t &requiredWalkOrder,
|
||||
@@ -324,18 +325,6 @@ bool EncodeDispatchKernel<Family>::isRuntimeLocalIdsGenerationRequired(uint32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
//make sure table below matches Hardware Spec
|
||||
constexpr uint32_t walkOrderPossibilties = 6u;
|
||||
constexpr uint8_t X = 0;
|
||||
constexpr uint8_t Y = 1;
|
||||
constexpr uint8_t Z = 2;
|
||||
constexpr uint8_t possibleWalkOrders[walkOrderPossibilties][3] = {{X, Y, Z}, // 0 1 2
|
||||
{X, Z, Y}, // 0 2 1
|
||||
{Y, X, Z}, // 1 0 2
|
||||
{Z, X, Y}, // 1 2 0
|
||||
{Y, Z, X}, // 2 0 1
|
||||
{Z, Y, X}}; // 2 1 0
|
||||
|
||||
//check if we need to follow kernel requirements
|
||||
if (requireInputWalkOrder) {
|
||||
for (uint32_t dimension = 0; dimension < activeChannels - 1; dimension++) {
|
||||
@@ -345,24 +334,24 @@ bool EncodeDispatchKernel<Family>::isRuntimeLocalIdsGenerationRequired(uint32_t
|
||||
}
|
||||
|
||||
auto index = 0u;
|
||||
while (index < walkOrderPossibilties) {
|
||||
if (walkOrder[0] == possibleWalkOrders[index][0] &&
|
||||
walkOrder[1] == possibleWalkOrders[index][1]) {
|
||||
while (index < HwWalkOrderHelper::walkOrderPossibilties) {
|
||||
if (walkOrder[0] == HwWalkOrderHelper::compatibleDimensionOrders[index][0] &&
|
||||
walkOrder[1] == HwWalkOrderHelper::compatibleDimensionOrders[index][1]) {
|
||||
break;
|
||||
};
|
||||
index++;
|
||||
}
|
||||
DEBUG_BREAK_IF(index >= walkOrderPossibilties);
|
||||
DEBUG_BREAK_IF(index >= HwWalkOrderHelper::walkOrderPossibilties);
|
||||
|
||||
requiredWalkOrder = index;
|
||||
return false;
|
||||
}
|
||||
|
||||
//kernel doesn't specify any walk order requirements, check if we have any compatible
|
||||
for (uint32_t walkOrder = 0; walkOrder < walkOrderPossibilties; walkOrder++) {
|
||||
for (uint32_t walkOrder = 0; walkOrder < HwWalkOrderHelper::walkOrderPossibilties; walkOrder++) {
|
||||
bool allDimensionsCompatible = true;
|
||||
for (uint32_t dimension = 0; dimension < activeChannels - 1; dimension++) {
|
||||
if (!Math::isPow2<size_t>(lws[possibleWalkOrders[walkOrder][dimension]])) {
|
||||
if (!Math::isPow2<size_t>(lws[HwWalkOrderHelper::compatibleDimensionOrders[walkOrder][dimension]])) {
|
||||
allDimensionsCompatible = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ set(NEO_CORE_HELPERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}hw_info_extended.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_walk_order.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.h
|
||||
|
||||
27
shared/source/helpers/hw_walk_order.h
Normal file
27
shared/source/helpers/hw_walk_order.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
namespace HwWalkOrderHelper {
|
||||
//make sure table below matches Hardware Spec
|
||||
constexpr uint32_t walkOrderPossibilties = 6u;
|
||||
constexpr uint8_t X = 0;
|
||||
constexpr uint8_t Y = 1;
|
||||
constexpr uint8_t Z = 2;
|
||||
constexpr std::array<uint8_t, 3> compatibleDimensionOrders[walkOrderPossibilties] = {{X, Y, Z}, // 0 1 2
|
||||
{X, Z, Y}, // 0 2 1
|
||||
{Y, X, Z}, // 1 0 2
|
||||
{Z, X, Y}, // 1 2 0
|
||||
{Y, Z, X}, // 2 0 1
|
||||
{Z, Y, X}}; // 2 1 0
|
||||
} // namespace HwWalkOrderHelper
|
||||
} // namespace NEO
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
# Copyright (C) 2019-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -10,6 +10,7 @@ set(NEO_CORE_KERNEL
|
||||
${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}/implicit_args_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor_extended_device_side_enqueue.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor_extended_vme.h
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -36,4 +37,8 @@ static_assert((sizeof(ImplicitArgs) & 31) == 0, "Implicit args size need to be a
|
||||
static_assert(std::is_pod<ImplicitArgs>::value);
|
||||
|
||||
constexpr const char *implicitArgsRelocationSymbolName = "INTEL_PATCH_CROSS_THREAD_OFFSET_OFF_R0";
|
||||
|
||||
namespace ImplicitArgsHelper {
|
||||
std::array<uint8_t, 3> getDimensionOrderForLocalIds(const uint8_t *workgroupDimensionsOrder, bool generationOfLocalIdsByRuntime, uint32_t walkOrderForHwGenerationOfLocalIds);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
27
shared/source/kernel/implicit_args_helper.cpp
Normal file
27
shared/source/kernel/implicit_args_helper.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_walk_order.h"
|
||||
#include "shared/source/kernel/implicit_args.h"
|
||||
#include "shared/source/kernel/kernel_descriptor.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::array<uint8_t, 3> ImplicitArgsHelper::getDimensionOrderForLocalIds(const uint8_t *workgroupDimensionsOrder, bool generationOfLocalIdsByRuntime, uint32_t walkOrderForHwGenerationOfLocalIds) {
|
||||
if (generationOfLocalIdsByRuntime) {
|
||||
UNRECOVERABLE_IF(!workgroupDimensionsOrder);
|
||||
return {{
|
||||
workgroupDimensionsOrder[0],
|
||||
workgroupDimensionsOrder[1],
|
||||
workgroupDimensionsOrder[2],
|
||||
}};
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(walkOrderForHwGenerationOfLocalIds >= HwWalkOrderHelper::walkOrderPossibilties);
|
||||
return HwWalkOrderHelper::compatibleDimensionOrders[walkOrderForHwGenerationOfLocalIds];
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,11 +1,12 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
# Copyright (C) 2020-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/implicit_args_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_descriptor_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_metadata_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_descriptor_from_patchtokens_tests.cpp
|
||||
|
||||
34
shared/test/unit_test/kernel/implicit_args_helper_tests.cpp
Normal file
34
shared/test/unit_test/kernel/implicit_args_helper_tests.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_walk_order.h"
|
||||
#include "shared/source/kernel/implicit_args.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(ImplicitArgsHelperTest, whenLocalIdsAreGeneratedByRuntimeThenDimensionOrderIsTakedFromInput) {
|
||||
for (auto i = 0u; i < HwWalkOrderHelper::walkOrderPossibilties; i++) {
|
||||
uint8_t inputDimensionOrder[3] = {2, 0, 1};
|
||||
auto dimOrderForImplicitArgs = ImplicitArgsHelper::getDimensionOrderForLocalIds(inputDimensionOrder, true, i);
|
||||
EXPECT_EQ(inputDimensionOrder[0], dimOrderForImplicitArgs[0]);
|
||||
EXPECT_EQ(inputDimensionOrder[1], dimOrderForImplicitArgs[1]);
|
||||
EXPECT_EQ(inputDimensionOrder[2], dimOrderForImplicitArgs[2]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ImplicitArgsHelperTest, givenIncorrectcInputWhenGettingDimensionOrderThenAbortIsCalled) {
|
||||
EXPECT_THROW(ImplicitArgsHelper::getDimensionOrderForLocalIds(nullptr, true, 0), std::runtime_error);
|
||||
EXPECT_THROW(ImplicitArgsHelper::getDimensionOrderForLocalIds(nullptr, false, HwWalkOrderHelper::walkOrderPossibilties), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(ImplicitArgsHelperTest, whenLocalIdsAreGeneratedByHwThenProperDimensionOrderIsReturned) {
|
||||
for (auto i = 0u; i < HwWalkOrderHelper::walkOrderPossibilties; i++) {
|
||||
auto dimOrderForImplicitArgs = ImplicitArgsHelper::getDimensionOrderForLocalIds(nullptr, false, i);
|
||||
EXPECT_EQ(HwWalkOrderHelper::compatibleDimensionOrders[i], dimOrderForImplicitArgs);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user