mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 09:30:36 +08:00
Changes to SW tags
Add SW tags to synchronization points Add ID sequence numbers Add new allocation type Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5f491ed22b
commit
5c236a62fd
@@ -116,6 +116,8 @@ const char *AppResourceHelper::getResourceTagStr(GraphicsAllocation::AllocationT
|
||||
return "WRPRTSRF";
|
||||
case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER:
|
||||
return "GPUTSDBF";
|
||||
case GraphicsAllocation::AllocationType::SW_TAG_BUFFER:
|
||||
return "SWTAGBF";
|
||||
default:
|
||||
return "NOTFOUND";
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
UNIFIED_SHARED_MEMORY,
|
||||
WORK_PARTITION_SURFACE,
|
||||
GPU_TIMESTAMP_DEVICE_BUFFER,
|
||||
SW_TAG_BUFFER,
|
||||
COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -364,6 +364,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
|
||||
case GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA:
|
||||
case GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER:
|
||||
case GraphicsAllocation::AllocationType::SW_TAG_BUFFER:
|
||||
allocationData.flags.useSystemMemory = true;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -103,7 +103,7 @@ void KernelNameTag::bxml(std::ostream &os) {
|
||||
BaseTag::bxml(os, OpCode::KernelName, sizeof(KernelNameTag), "KERNEL_NAME");
|
||||
|
||||
unsigned int stringDWORDSize = KENEL_NAME_STR_LENGTH / sizeof(uint32_t);
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize << "\">\n";
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"KernelName\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Name of the kernel.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
@@ -119,7 +119,7 @@ void PipeControlReasonTag::bxml(std::ostream &os) {
|
||||
BaseTag::bxml(os, OpCode::PipeControlReason, sizeof(PipeControlReasonTag), "PIPE_CONTROL_REASON");
|
||||
|
||||
unsigned int stringDWORDSize = REASON_STR_LENGTH / sizeof(uint32_t);
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize << "\">\n";
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"PipeControlReason\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Reason of the PIPE_CONTROL.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
@@ -128,6 +128,48 @@ void PipeControlReasonTag::bxml(std::ostream &os) {
|
||||
os << "</Instruction>\n";
|
||||
}
|
||||
|
||||
void CallNameBeginTag::bxml(std::ostream &os) {
|
||||
os << "<Instruction Name=\"CallNameBegin\" Source=\"Driver\" Project=\"All\" LengthBias=\"2\">\n";
|
||||
os << " <Description>ZE Call where the GPU originated from.</Description>\n";
|
||||
|
||||
BaseTag::bxml(os, OpCode::CallNameBegin, sizeof(CallNameBeginTag), "ZE_CALL_NAME_BEGIN");
|
||||
|
||||
unsigned int stringDWORDSize = ZE_CALL_NAME_STR_LENGTH / sizeof(uint32_t);
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"CallNameBegin\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Entry of ZE Call where the GPU originated from.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
os << " </Dword>\n";
|
||||
os << " <Dword Name=\"" << 2 + stringDWORDSize << ".." << 2 + 2 * stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"SWTagId\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Exit of ZE Call where the GPU originated from.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
os << " </Dword>\n";
|
||||
|
||||
os << "</Instruction>\n";
|
||||
}
|
||||
|
||||
void CallNameEndTag::bxml(std::ostream &os) {
|
||||
os << "<Instruction Name=\"CallNameEnd\" Source=\"Driver\" Project=\"All\" LengthBias=\"2\">\n";
|
||||
os << " <Description>ZE Call where the GPU originated from.</Description>\n";
|
||||
|
||||
BaseTag::bxml(os, OpCode::CallNameEnd, sizeof(CallNameEndTag), "ZE_CALL_NAME_END");
|
||||
|
||||
unsigned int stringDWORDSize = ZE_CALL_NAME_STR_LENGTH / sizeof(uint32_t);
|
||||
os << " <Dword Name=\"2.." << 2 + stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"CallNameEnd\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Exit of ZE Call where the GPU originated from.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
os << " </Dword>\n";
|
||||
os << " <Dword Name=\"" << 2 + stringDWORDSize << ".." << 2 + 2 * stringDWORDSize - 1 << "\">\n";
|
||||
os << " <BitField Name=\"SWTagId\" HighBit=\"" << 32 * stringDWORDSize - 1 << "\" LowBit=\"0\" Format=\"string\">\n";
|
||||
os << " <Description>Exit of ZE Call where the GPU originated from.</Description>\n";
|
||||
os << " </BitField>\n";
|
||||
os << " </Dword>\n";
|
||||
|
||||
os << "</Instruction>\n";
|
||||
}
|
||||
|
||||
SWTagBXML::SWTagBXML() {
|
||||
std::ostringstream ss;
|
||||
|
||||
@@ -139,6 +181,8 @@ SWTagBXML::SWTagBXML() {
|
||||
|
||||
KernelNameTag::bxml(ss);
|
||||
PipeControlReasonTag::bxml(ss);
|
||||
CallNameBeginTag::bxml(ss);
|
||||
CallNameEndTag::bxml(ss);
|
||||
|
||||
ss << "</BSpec>";
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace SWTags {
|
||||
enum class OpCode : uint32_t {
|
||||
Unknown,
|
||||
KernelName,
|
||||
PipeControlReason
|
||||
PipeControlReason,
|
||||
CallNameBegin,
|
||||
CallNameEnd
|
||||
};
|
||||
|
||||
enum class Component : uint32_t {
|
||||
@@ -84,7 +86,7 @@ struct BaseTag {
|
||||
|
||||
struct KernelNameTag : public BaseTag {
|
||||
public:
|
||||
KernelNameTag(const char *name)
|
||||
KernelNameTag(const char *name, uint32_t callId)
|
||||
: BaseTag(OpCode::KernelName, sizeof(KernelNameTag)) {
|
||||
strcpy_s(kernelName, KENEL_NAME_STR_LENGTH, name);
|
||||
}
|
||||
@@ -98,7 +100,7 @@ struct KernelNameTag : public BaseTag {
|
||||
|
||||
struct PipeControlReasonTag : public BaseTag {
|
||||
public:
|
||||
PipeControlReasonTag(const char *reason)
|
||||
PipeControlReasonTag(const char *reason, uint32_t callId)
|
||||
: BaseTag(OpCode::PipeControlReason, sizeof(PipeControlReasonTag)) {
|
||||
strcpy_s(reasonString, REASON_STR_LENGTH, reason);
|
||||
}
|
||||
@@ -110,6 +112,38 @@ struct PipeControlReasonTag : public BaseTag {
|
||||
char reasonString[REASON_STR_LENGTH] = {};
|
||||
};
|
||||
|
||||
struct CallNameBeginTag : public BaseTag {
|
||||
public:
|
||||
CallNameBeginTag(const char *name, uint32_t callId)
|
||||
: BaseTag(OpCode::CallNameBegin, sizeof(CallNameBeginTag)) {
|
||||
strcpy_s(zeCallName, ZE_CALL_NAME_STR_LENGTH, name);
|
||||
snprintf(zeCallId, sizeof(uint32_t), "%x", callId);
|
||||
}
|
||||
|
||||
static void bxml(std::ostream &os);
|
||||
|
||||
private:
|
||||
static constexpr unsigned int ZE_CALL_NAME_STR_LENGTH = sizeof(uint32_t) * 32; // Dword aligned
|
||||
char zeCallName[ZE_CALL_NAME_STR_LENGTH] = {};
|
||||
char zeCallId[ZE_CALL_NAME_STR_LENGTH] = {};
|
||||
};
|
||||
|
||||
struct CallNameEndTag : public BaseTag {
|
||||
public:
|
||||
CallNameEndTag(const char *name, uint32_t callId)
|
||||
: BaseTag(OpCode::CallNameEnd, sizeof(CallNameEndTag)) {
|
||||
strcpy_s(zeCallName, ZE_CALL_NAME_STR_LENGTH, name);
|
||||
snprintf(zeCallId, sizeof(uint32_t), "%x", callId);
|
||||
}
|
||||
|
||||
static void bxml(std::ostream &os);
|
||||
|
||||
private:
|
||||
static constexpr unsigned int ZE_CALL_NAME_STR_LENGTH = sizeof(uint32_t) * 32; // Dword aligned
|
||||
char zeCallName[ZE_CALL_NAME_STR_LENGTH] = {};
|
||||
char zeCallId[ZE_CALL_NAME_STR_LENGTH] = {};
|
||||
};
|
||||
|
||||
struct SWTagBXML {
|
||||
SWTagBXML();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void SWTagsManager::allocateBXMLHeap(Device &device) {
|
||||
const AllocationProperties properties{
|
||||
device.getRootDeviceIndex(),
|
||||
heapSizeInBytes,
|
||||
GraphicsAllocation::AllocationType::LINEAR_STREAM,
|
||||
GraphicsAllocation::AllocationType::SW_TAG_BUFFER,
|
||||
device.getDeviceBitfield()};
|
||||
bxmlHeap = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
@@ -44,7 +44,7 @@ void SWTagsManager::allocateSWTagHeap(Device &device) {
|
||||
const AllocationProperties properties{
|
||||
device.getRootDeviceIndex(),
|
||||
MAX_TAG_HEAP_SIZE,
|
||||
GraphicsAllocation::AllocationType::LINEAR_STREAM,
|
||||
GraphicsAllocation::AllocationType::SW_TAG_BUFFER,
|
||||
device.getDeviceBitfield()};
|
||||
tagHeap = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
|
||||
@@ -37,8 +37,10 @@ class SWTagsManager {
|
||||
template <typename GfxFamily>
|
||||
static size_t estimateSpaceForSWTags();
|
||||
|
||||
static const unsigned int MAX_TAG_COUNT = 20;
|
||||
static const unsigned int MAX_TAG_HEAP_SIZE = 1024;
|
||||
static const unsigned int MAX_TAG_COUNT = 200;
|
||||
static const unsigned int MAX_TAG_HEAP_SIZE = 16384;
|
||||
unsigned int currentCallCount = 0;
|
||||
unsigned int getCurrentHeapOffset() { return currentHeapOffset; }
|
||||
|
||||
private:
|
||||
void allocateBXMLHeap(Device &device);
|
||||
@@ -88,7 +90,7 @@ void SWTagsManager::insertTag(LinearStream &cmdStream, Device &device, Params...
|
||||
|
||||
unsigned int tagSize = sizeof(Tag);
|
||||
|
||||
if (currentTagCount >= MAX_TAG_COUNT || currentHeapOffset + tagSize > MAX_TAG_HEAP_SIZE) {
|
||||
if (currentTagCount >= MAX_TAG_COUNT || getCurrentHeapOffset() + tagSize > MAX_TAG_HEAP_SIZE) {
|
||||
return;
|
||||
}
|
||||
++currentTagCount;
|
||||
|
||||
@@ -138,7 +138,8 @@ AllocationTypeTagTestCase allocationTypeTagValues[static_cast<int>(GraphicsAlloc
|
||||
{GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER, "DBSBATRB"},
|
||||
{GraphicsAllocation::AllocationType::DEBUG_MODULE_AREA, "DBMDLARE"},
|
||||
{GraphicsAllocation::AllocationType::UNIFIED_SHARED_MEMORY, "USHRDMEM"},
|
||||
{GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, "GPUTSDBF"}};
|
||||
{GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, "GPUTSDBF"},
|
||||
{GraphicsAllocation::AllocationType::SW_TAG_BUFFER, "SWTAGBF"}};
|
||||
class AllocationTypeTagString : public ::testing::TestWithParam<AllocationTypeTagTestCase> {};
|
||||
|
||||
TEST_P(AllocationTypeTagString, givenGraphicsAllocationTypeWhenCopyTagToStorageInfoThenCorrectTagIsReturned) {
|
||||
|
||||
@@ -156,16 +156,6 @@ HWTEST_F(SoftwareTagsManagerTests, whenTestTagIsInsertedThenItIsSuccessful) {
|
||||
freeTestCmdStream();
|
||||
}
|
||||
|
||||
HWTEST_F(SoftwareTagsManagerTests, whenVeryLargeTagIsInsertedThenItIsNotSuccessful) {
|
||||
initializeTestCmdStream<FamilyType>();
|
||||
|
||||
tagsManager->insertTag<FamilyType, VeryLargeTag>(*testCmdStream.get(), *pDevice);
|
||||
|
||||
EXPECT_EQ(0u, testCmdStream->getUsed());
|
||||
|
||||
freeTestCmdStream();
|
||||
}
|
||||
|
||||
HWTEST_F(SoftwareTagsManagerTests, givenSoftwareManagerWithMaxTagsReachedWhenTagIsInsertedThenItIsNotSuccessful) {
|
||||
using MI_NOOP = typename FamilyType::MI_NOOP;
|
||||
|
||||
@@ -186,6 +176,28 @@ HWTEST_F(SoftwareTagsManagerTests, givenSoftwareManagerWithMaxTagsReachedWhenTag
|
||||
freeTestCmdStream();
|
||||
}
|
||||
|
||||
HWTEST_F(SoftwareTagsManagerTests, givenSoftwareManagerWithMaxHeapReachedWhenTagIsInsertedThenItIsNotSuccessful) {
|
||||
using MI_NOOP = typename FamilyType::MI_NOOP;
|
||||
|
||||
initializeTestCmdStream<FamilyType>();
|
||||
|
||||
size_t prevHeapOffset = tagsManager->getCurrentHeapOffset();
|
||||
|
||||
uint32_t i = 0;
|
||||
while (tagsManager->getCurrentHeapOffset() + sizeof(VeryLargeTag) <= NEO::SWTagsManager::MAX_TAG_HEAP_SIZE) {
|
||||
tagsManager->insertTag<FamilyType, VeryLargeTag>(*testCmdStream.get(), *pDevice);
|
||||
i++;
|
||||
}
|
||||
|
||||
EXPECT_EQ(tagsManager->getCurrentHeapOffset(), prevHeapOffset + (i * sizeof(VeryLargeTag)));
|
||||
|
||||
tagsManager->insertTag<FamilyType, VeryLargeTag>(*testCmdStream.get(), *pDevice);
|
||||
|
||||
EXPECT_EQ(tagsManager->getCurrentHeapOffset(), prevHeapOffset + (i * sizeof(VeryLargeTag)));
|
||||
|
||||
freeTestCmdStream();
|
||||
}
|
||||
|
||||
TEST(SoftwareTagsManagerMultiDeviceTests, givenEnableSWTagsAndCreateMultipleSubDevicesWhenDeviceCreatedThenSWTagsManagerIsInitializedOnlyOnce) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.EnableSWTags.set(true);
|
||||
@@ -202,8 +214,8 @@ TEST(SoftwareTagsManagerMultiDeviceTests, givenEnableSWTagsAndCreateMultipleSubD
|
||||
|
||||
struct SoftwareTagsParametrizedTests : public ::testing::TestWithParam<SWTags::OpCode> {
|
||||
void SetUp() override {
|
||||
tagMap.emplace(OpCode::KernelName, std::make_unique<KernelNameTag>(""));
|
||||
tagMap.emplace(OpCode::PipeControlReason, std::make_unique<PipeControlReasonTag>(""));
|
||||
tagMap.emplace(OpCode::KernelName, std::make_unique<KernelNameTag>("", 0u));
|
||||
tagMap.emplace(OpCode::PipeControlReason, std::make_unique<PipeControlReasonTag>("", 0u));
|
||||
}
|
||||
|
||||
std::map<OpCode, std::unique_ptr<BaseTag>> tagMap;
|
||||
|
||||
Reference in New Issue
Block a user