refactor: define initial value for TimestampPacket

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-05-30 09:12:10 +00:00
committed by Compute-Runtime-Automation
parent 501c8e87d7
commit 5aeffbf673
13 changed files with 52 additions and 52 deletions

View File

@@ -1098,7 +1098,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::synchronizeInOrderExe
for (uint32_t i = 0; i < this->partitionCount; i++) { for (uint32_t i = 0; i < this->partitionCount; i++) {
auto hostAddress = static_cast<TSPacketType const *>(node->getContextEndAddress(i)); auto hostAddress = static_cast<TSPacketType const *>(node->getContextEndAddress(i));
if (!NEO::WaitUtils::waitFunctionWithPredicate<const TSPacketType>(hostAddress, 1, std::not_equal_to<TSPacketType>())) { if (!NEO::WaitUtils::waitFunctionWithPredicate<const TSPacketType>(hostAddress, NEO::TimestampPacketConstants::initValue, std::not_equal_to<TSPacketType>())) {
signaled = false; signaled = false;
break; break;
} }

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "shared/source/helpers/timestamp_packet_constants.h"
#include "shared/source/helpers/timestamp_packet_container.h" #include "shared/source/helpers/timestamp_packet_container.h"
#include "shared/source/helpers/timestamp_packet_size_control.h"
#include "shared/source/memory_manager/multi_graphics_allocation.h" #include "shared/source/memory_manager/multi_graphics_allocation.h"
#include <level_zero/ze_api.h> #include <level_zero/ze_api.h>
@@ -57,7 +57,7 @@ static_assert(sizeof(IpcEventPoolData) <= ZE_MAX_IPC_HANDLE_SIZE, "IpcEventPoolD
namespace EventPacketsCount { namespace EventPacketsCount {
inline constexpr uint32_t maxKernelSplit = 3; inline constexpr uint32_t maxKernelSplit = 3;
inline constexpr uint32_t eventPackets = maxKernelSplit * NEO ::TimestampPacketSizeControl::preferredPacketCount; inline constexpr uint32_t eventPackets = maxKernelSplit * NEO ::TimestampPacketConstants::preferredPacketCount;
} // namespace EventPacketsCount } // namespace EventPacketsCount
struct Event : _ze_event_handle_t { struct Event : _ze_event_handle_t {

View File

@@ -138,7 +138,7 @@ ze_result_t EventImp<TagSizeT>::queryInOrderEventStatus() {
for (uint32_t i = 0; i < this->getPacketsInUse(); i++) { for (uint32_t i = 0; i < this->getPacketsInUse(); i++) {
auto hostAddress = static_cast<TagSizeT const *>(node->getContextEndAddress(i)); auto hostAddress = static_cast<TagSizeT const *>(node->getContextEndAddress(i));
if (!NEO::WaitUtils::waitFunctionWithPredicate<const TagSizeT>(hostAddress, 1, std::not_equal_to<TagSizeT>())) { if (!NEO::WaitUtils::waitFunctionWithPredicate<const TagSizeT>(hostAddress, NEO::TimestampPacketConstants::initValue, std::not_equal_to<TagSizeT>())) {
signaled = false; signaled = false;
break; break;
} }
@@ -271,7 +271,7 @@ ze_result_t EventImp<TagSizeT>::hostEventSetValueTimestamps(TagSizeT eventVal) {
setRemainingPackets(eventVal, reinterpret_cast<void *>(baseAddr), packets); setRemainingPackets(eventVal, reinterpret_cast<void *>(baseAddr), packets);
} }
const auto dataSize = 4u * EventPacketsCount::maxKernelSplit * NEO::TimestampPacketSizeControl::preferredPacketCount; const auto dataSize = 4u * EventPacketsCount::maxKernelSplit * NEO::TimestampPacketConstants::preferredPacketCount;
TagSizeT tagValues[dataSize]; TagSizeT tagValues[dataSize];
for (uint32_t index = 0u; index < dataSize; index++) { for (uint32_t index = 0u; index < dataSize; index++) {
@@ -408,7 +408,7 @@ void EventImp<TagSizeT>::resetDeviceCompletionData(bool resetAllPackets) {
if (resetAllPackets) { if (resetAllPackets) {
this->kernelCount = this->maxKernelCount; this->kernelCount = this->maxKernelCount;
for (uint32_t i = 0; i < kernelCount; i++) { for (uint32_t i = 0; i < kernelCount; i++) {
this->kernelEventCompletionData[i].setPacketsUsed(NEO::TimestampPacketSizeControl::preferredPacketCount); this->kernelEventCompletionData[i].setPacketsUsed(NEO::TimestampPacketConstants::preferredPacketCount);
} }
} }

View File

@@ -607,7 +607,7 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenCommandListWhenAppendLaunchKernelS
EXPECT_EQ(1u, event->getPacketsInUse()); EXPECT_EQ(1u, event->getPacketsInUse());
ze_group_count_t groupCount{1, 1, 1}; ze_group_count_t groupCount{1, 1, 1};
CmdListKernelLaunchParams launchParams = {}; CmdListKernelLaunchParams launchParams = {};
for (uint32_t i = 0; i < NEO::TimestampPacketSizeControl::preferredPacketCount + 4; i++) { for (uint32_t i = 0; i < NEO::TimestampPacketConstants::preferredPacketCount + 4; i++) {
auto result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, event->toHandle(), 0, nullptr, launchParams, false); auto result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, event->toHandle(), 0, nullptr, launchParams, false);
EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_EQ(ZE_RESULT_SUCCESS, result);
} }

View File

@@ -178,7 +178,7 @@ HWTEST_F(EventPoolCreate, givenTimestampEventsThenEventSizeSufficientForAllKerne
auto &l0GfxCoreHelper = device->getNEODevice()->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>(); auto &l0GfxCoreHelper = device->getNEODevice()->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
auto &gfxCoreHelper = device->getGfxCoreHelper(); auto &gfxCoreHelper = device->getGfxCoreHelper();
uint32_t maxPacketCount = EventPacketsCount::maxKernelSplit * NEO::TimestampPacketSizeControl::preferredPacketCount; uint32_t maxPacketCount = EventPacketsCount::maxKernelSplit * NEO::TimestampPacketConstants::preferredPacketCount;
if (l0GfxCoreHelper.useDynamicEventPacketsCount(hwInfo)) { if (l0GfxCoreHelper.useDynamicEventPacketsCount(hwInfo)) {
maxPacketCount = l0GfxCoreHelper.getEventBaseMaxPacketCount(device->getNEODevice()->getRootDeviceEnvironment()); maxPacketCount = l0GfxCoreHelper.getEventBaseMaxPacketCount(device->getNEODevice()->getRootDeviceEnvironment());
} }
@@ -1330,7 +1330,7 @@ TEST_F(EventCreate, givenEventWhenSignaledAndResetFromTheHostThenCorrectDataAndO
} }
uint32_t *eventCompletionMemory = reinterpret_cast<uint32_t *>(event->getCompletionFieldHostAddress()); uint32_t *eventCompletionMemory = reinterpret_cast<uint32_t *>(event->getCompletionFieldHostAddress());
uint32_t maxPacketsCount = EventPacketsCount::maxKernelSplit * NEO::TimestampPacketSizeControl::preferredPacketCount; uint32_t maxPacketsCount = EventPacketsCount::maxKernelSplit * NEO::TimestampPacketConstants::preferredPacketCount;
if (l0GfxCoreHelper.useDynamicEventPacketsCount(hwInfo)) { if (l0GfxCoreHelper.useDynamicEventPacketsCount(hwInfo)) {
maxPacketsCount = l0GfxCoreHelper.getEventBaseMaxPacketCount(device->getNEODevice()->getRootDeviceEnvironment()); maxPacketsCount = l0GfxCoreHelper.getEventBaseMaxPacketCount(device->getNEODevice()->getRootDeviceEnvironment());
} }
@@ -1804,7 +1804,7 @@ TEST_F(TimestampEventCreate, givenEventTimestampsCreatedWhenResetIsInvokeThenCor
EXPECT_NE(nullptr, event->kernelEventCompletionData); EXPECT_NE(nullptr, event->kernelEventCompletionData);
for (auto j = 0u; j < maxKernelCount; j++) { for (auto j = 0u; j < maxKernelCount; j++) {
for (auto i = 0u; i < NEO::TimestampPacketSizeControl::preferredPacketCount; i++) { for (auto i = 0u; i < NEO::TimestampPacketConstants::preferredPacketCount; i++) {
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextStartValue(i)); EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextStartValue(i));
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getGlobalStartValue(i)); EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getGlobalStartValue(i));
EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextEndValue(i)); EXPECT_EQ(static_cast<uint64_t>(Event::State::STATE_INITIAL), event->kernelEventCompletionData[j].getContextEndValue(i));
@@ -1869,7 +1869,7 @@ TEST_F(TimestampEventCreate, givenEventWhenSignaledAndResetFromTheHostThenCorrec
result = event->queryStatus(); result = event->queryStatus();
EXPECT_EQ(ZE_RESULT_NOT_READY, result); EXPECT_EQ(ZE_RESULT_NOT_READY, result);
for (auto j = 0u; j < event->getKernelCount(); j++) { for (auto j = 0u; j < event->getKernelCount(); j++) {
for (auto i = 0u; i < NEO::TimestampPacketSizeControl::preferredPacketCount; i++) { for (auto i = 0u; i < NEO::TimestampPacketConstants::preferredPacketCount; i++) {
EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getContextStartValue(i)); EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getContextStartValue(i));
EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getGlobalStartValue(i)); EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getGlobalStartValue(i));
EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getContextEndValue(i)); EXPECT_EQ(Event::State::STATE_INITIAL, event->kernelEventCompletionData[j].getContextEndValue(i));

View File

@@ -64,7 +64,7 @@ struct TimestampPacketTests : public ::testing::Test {
typename FamilyType::TimestampPacketType zeros[4] = {}; typename FamilyType::TimestampPacketType zeros[4] = {};
for (uint32_t i = 0; i < TimestampPacketSizeControl::preferredPacketCount; i++) { for (uint32_t i = 0; i < TimestampPacketConstants::preferredPacketCount; i++) {
tagNode->assignDataToAllTimestamps(i, zeros); tagNode->assignDataToAllTimestamps(i, zeros);
} }
tagNode->setPacketsUsed(packetsUsed); tagNode->setPacketsUsed(packetsUsed);

View File

@@ -153,7 +153,7 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet.cpp ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet.h ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet.h
${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_container.h ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_container.h
${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_size_control.h ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_constants.h
${CMAKE_CURRENT_SOURCE_DIR}/topology_map.h ${CMAKE_CURRENT_SOURCE_DIR}/topology_map.h
${CMAKE_CURRENT_SOURCE_DIR}/uint16_avx2.h ${CMAKE_CURRENT_SOURCE_DIR}/uint16_avx2.h
${CMAKE_CURRENT_SOURCE_DIR}/uint16_sse4.h ${CMAKE_CURRENT_SOURCE_DIR}/uint16_sse4.h

View File

@@ -14,8 +14,8 @@
#include "shared/source/helpers/non_copyable_or_moveable.h" #include "shared/source/helpers/non_copyable_or_moveable.h"
#include "shared/source/helpers/pipe_control_args.h" #include "shared/source/helpers/pipe_control_args.h"
#include "shared/source/helpers/string.h" #include "shared/source/helpers/string.h"
#include "shared/source/helpers/timestamp_packet_constants.h"
#include "shared/source/helpers/timestamp_packet_container.h" #include "shared/source/helpers/timestamp_packet_container.h"
#include "shared/source/helpers/timestamp_packet_size_control.h"
#include "shared/source/utilities/tag_allocator.h" #include "shared/source/utilities/tag_allocator.h"
#include <cstdint> #include <cstdint>
@@ -27,14 +27,6 @@ class LinearStream;
#pragma pack(1) #pragma pack(1)
template <typename TSize> template <typename TSize>
class TimestampPackets : public TagTypeBase { class TimestampPackets : public TagTypeBase {
protected:
struct Packet {
TSize contextStart = 1u;
TSize globalStart = 1u;
TSize contextEnd = 1u;
TSize globalEnd = 1u;
};
public: public:
static constexpr AllocationType getAllocationType() { static constexpr AllocationType getAllocationType() {
return AllocationType::TIMESTAMP_PACKET_TAG_BUFFER; return AllocationType::TIMESTAMP_PACKET_TAG_BUFFER;
@@ -46,10 +38,10 @@ class TimestampPackets : public TagTypeBase {
void initialize() { void initialize() {
for (auto &packet : packets) { for (auto &packet : packets) {
packet.contextStart = 1u; packet.contextStart = TimestampPacketConstants::initValue;
packet.globalStart = 1u; packet.globalStart = TimestampPacketConstants::initValue;
packet.contextEnd = 1u; packet.contextEnd = TimestampPacketConstants::initValue;
packet.globalEnd = 1u; packet.globalEnd = TimestampPacketConstants::initValue;
} }
} }
@@ -71,11 +63,18 @@ class TimestampPackets : public TagTypeBase {
void const *getContextStartAddress(uint32_t packetIndex) const { return static_cast<void const *>(&packets[packetIndex].contextStart); } void const *getContextStartAddress(uint32_t packetIndex) const { return static_cast<void const *>(&packets[packetIndex].contextStart); }
protected: protected:
Packet packets[TimestampPacketSizeControl::preferredPacketCount]; struct alignas(1) Packet {
TSize contextStart = TimestampPacketConstants::initValue;
TSize globalStart = TimestampPacketConstants::initValue;
TSize contextEnd = TimestampPacketConstants::initValue;
TSize globalEnd = TimestampPacketConstants::initValue;
};
Packet packets[TimestampPacketConstants::preferredPacketCount];
}; };
#pragma pack() #pragma pack()
static_assert(((4 * TimestampPacketSizeControl::preferredPacketCount) * sizeof(uint32_t)) == sizeof(TimestampPackets<uint32_t>), static_assert(((4 * TimestampPacketConstants::preferredPacketCount) * sizeof(uint32_t)) == sizeof(TimestampPackets<uint32_t>),
"This structure is consumed by GPU and has to follow specific restrictions for padding and size"); "This structure is consumed by GPU and has to follow specific restrictions for padding and size");
struct TimestampPacketHelper { struct TimestampPacketHelper {
@@ -100,7 +99,7 @@ struct TimestampPacketHelper {
for (uint32_t packetId = 0; packetId < timestampPacketNode.getPacketsUsed(); packetId++) { for (uint32_t packetId = 0; packetId < timestampPacketNode.getPacketsUsed(); packetId++) {
uint64_t compareOffset = packetId * timestampPacketNode.getSinglePacketSize(); uint64_t compareOffset = packetId * timestampPacketNode.getSinglePacketSize();
EncodeSemaphore<GfxFamily>::addMiSemaphoreWaitCommand(cmdStream, compareAddress + compareOffset, 1, COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD); EncodeSemaphore<GfxFamily>::addMiSemaphoreWaitCommand(cmdStream, compareAddress + compareOffset, TimestampPacketConstants::initValue, COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
} }
} }
@@ -111,7 +110,7 @@ struct TimestampPacketHelper {
for (uint32_t packetId = 0; packetId < timestampPacketNode.getPacketsUsed(); packetId++) { for (uint32_t packetId = 0; packetId < timestampPacketNode.getPacketsUsed(); packetId++) {
uint64_t compareOffset = packetId * timestampPacketNode.getSinglePacketSize(); uint64_t compareOffset = packetId * timestampPacketNode.getSinglePacketSize();
EncodeBatchBufferStartOrEnd<GfxFamily>::programConditionalDataMemBatchBufferStart(cmdStream, 0, compareAddress + compareOffset, 1, EncodeBatchBufferStartOrEnd<GfxFamily>::programConditionalDataMemBatchBufferStart(cmdStream, 0, compareAddress + compareOffset, TimestampPacketConstants::initValue,
NEO::CompareOperation::Equal, true); NEO::CompareOperation::Equal, true);
} }
} }

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "cstdint"
namespace NEO {
namespace TimestampPacketConstants {
static constexpr uint32_t preferredPacketCount = 16;
static constexpr uint32_t initValue = 1;
} // namespace TimestampPacketConstants
} // namespace NEO

View File

@@ -1,17 +0,0 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "cstdint"
namespace NEO {
namespace TimestampPacketSizeControl {
constexpr uint32_t preferredPacketCount = 16u;
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022 Intel Corporation * Copyright (C) 2022-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -20,7 +20,7 @@ class MockTimestampPackets32 : public TimestampPackets<uint32_t> {
uint32_t zeros[4] = {}; uint32_t zeros[4] = {};
for (uint32_t i = 0; i < TimestampPacketSizeControl::preferredPacketCount; i++) { for (uint32_t i = 0; i < TimestampPacketConstants::preferredPacketCount; i++) {
assignDataToAllTimestamps(i, zeros); assignDataToAllTimestamps(i, zeros);
} }
} }

View File

@@ -383,7 +383,7 @@ struct CommandStreamReceiverTagTests : public ::testing::Test {
typename FamilyType::TimestampPacketType zeros[4] = {}; typename FamilyType::TimestampPacketType zeros[4] = {};
for (uint32_t i = 0; i < TimestampPacketSizeControl::preferredPacketCount; i++) { for (uint32_t i = 0; i < TimestampPacketConstants::preferredPacketCount; i++) {
tag->assignDataToAllTimestamps(i, zeros); tag->assignDataToAllTimestamps(i, zeros);
} }

View File

@@ -31,7 +31,7 @@ void setTagToReadyState(TagNodeBase *tagNode) {
typename FamilyType::TimestampPacketType zeros[4] = {}; typename FamilyType::TimestampPacketType zeros[4] = {};
for (uint32_t i = 0; i < TimestampPacketSizeControl::preferredPacketCount; i++) { for (uint32_t i = 0; i < TimestampPacketConstants::preferredPacketCount; i++) {
tagNode->assignDataToAllTimestamps(i, zeros); tagNode->assignDataToAllTimestamps(i, zeros);
} }
tagNode->setPacketsUsed(packetsUsed); tagNode->setPacketsUsed(packetsUsed);
@@ -202,7 +202,7 @@ HWTEST_F(TimestampPacketTests, whenNewTagIsTakenThenReinitialize) {
TEST_F(TimestampPacketTests, whenObjectIsCreatedThenInitializeAllStamps) { TEST_F(TimestampPacketTests, whenObjectIsCreatedThenInitializeAllStamps) {
MockTimestampPackets32 timestampPacketStorage; MockTimestampPackets32 timestampPacketStorage;
EXPECT_EQ(TimestampPacketSizeControl::preferredPacketCount * sizeof(timestampPacketStorage.packets[0]), sizeof(timestampPacketStorage.packets)); EXPECT_EQ(TimestampPacketConstants::preferredPacketCount * sizeof(timestampPacketStorage.packets[0]), sizeof(timestampPacketStorage.packets));
for (const auto &packet : timestampPacketStorage.packets) { for (const auto &packet : timestampPacketStorage.packets) {
EXPECT_EQ(1u, packet.contextStart); EXPECT_EQ(1u, packet.contextStart);