Skip to content

Commit

Permalink
add support for kernel_commit_id in AIE_PARTITION (Xilinx#8335)
Browse files Browse the repository at this point in the history
* add support for kernel_commit_id in AIE_PARTITION

Signed-off-by: xilinxfei <[email protected]>

* remove comments

Signed-off-by: xilinxfei <[email protected]>

* add one line description for kernel_commit_id

Signed-off-by: xilinxfei <[email protected]>

---------

Signed-off-by: xilinxfei <[email protected]>
Co-authored-by: xilinxfei <[email protected]>
  • Loading branch information
xfreid and xilixnfei authored Aug 9, 2024
1 parent 45bbda5 commit dea5bb9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 57 deletions.
9 changes: 8 additions & 1 deletion src/runtime_src/core/include/xclbin.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,14 @@ extern "C" {
uint64_t pre_post_fingerprint; // The unique hash value of pre post
struct aie_partition_info info; // Partition information
struct array_offset aie_pdi; // PDI Array (aie_partition_info)
uint8_t reserved[54]; // Reserved
// kernel_commit_id is modeled after mpo_name
// This variable represents a zero terminated string
// that is offseted from the beginning of the section.
//
// The pointer to access the string is initialized as follows:
// char * pCharString = (address_of_section) + (mpo value)
uint32_t kernel_commit_id; // The git repo commit id for DPU_PHX_KERNEL
uint8_t reserved[52]; // Reserved
};
XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) == 184, "aie_partition structure no longer is 184 bytes in size");
XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) % sizeof(uint64_t) == 0, "aie_partition structure needs to be 64-bit word aligned");
Expand Down
22 changes: 21 additions & 1 deletion src/runtime_src/tools/xclbinutil/SectionAIEPartition.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ process_partition_info(const boost::property_tree::ptree& ptAIEPartition,

// Write out the 16-bit array.
partitionInfo.start_columns.offset = static_cast<decltype(partitionInfo.start_columns.offset)>(heap.getNextBufferOffset());
// XUtil::TRACE(boost::str(boost::format(" start_column (0x%lx)") % partitionInfo.start_columns.offset));
for (const auto element : startColumns)
heap.write(reinterpret_cast<const char*>(&element), sizeof(uint16_t), false /*align*/);

Expand Down Expand Up @@ -415,6 +416,12 @@ createAIEPartitionImage(const std::string& sectionIndexName,
aie_partitionHdr.inference_fingerprint = ptAIEPartition.get<uint64_t>("inference_fingerprint", 0);
aie_partitionHdr.pre_post_fingerprint = ptAIEPartition.get<uint64_t>("pre_post_fingerprint", 0);

// kernel_commit_id (modeled after mpo_name)
aie_partitionHdr.kernel_commit_id = static_cast<decltype(aie_partitionHdr.kernel_commit_id)>(heap.getNextBufferOffset());
auto sKernelCommitId = ptAIEPartition.get<std::string>("kernel_commit_id", "");
// XUtil::TRACE(boost::str(boost::format(" kernel_commit_id (0x%lx): '%s'") % aie_partitionHdr.kernel_commit_id % sKernelCommitId));
heap.write(sKernelCommitId.c_str(), sKernelCommitId.size() + 1 /*Null char*/);

// Process the nodes
process_partition_info(ptAIEPartition, aie_partitionHdr.info, heap);
process_PDIs(ptAIEPartition, relativeFromDir, aie_partitionHdr, heap);
Expand Down Expand Up @@ -528,7 +535,9 @@ populate_cdo_groups(const char* pBase,
boost::property_tree::ptree ptElement;

// Name
ptElement.put("name", reinterpret_cast<const char*>(pBase + element.mpo_name));
auto sName = reinterpret_cast<const char*>(pBase + element.mpo_name);
ptElement.put("name", sName);
XUtil::TRACE("Populating CDO group: " + std::string(sName));

// Type
if ((CDO_Type)element.cdo_type != CT_UNKNOWN)
Expand Down Expand Up @@ -642,6 +651,17 @@ writeAIEPartitionImage(const char* pBuffer,
ptAiePartition.put("inference_fingerprint", (boost::format("%d") % pHdr->inference_fingerprint).str());
ptAiePartition.put("pre_post_fingerprint", (boost::format("%d") % pHdr->pre_post_fingerprint).str());

// kernel_commit_id (modeled after mpo_name)
// in order to be backward compatible with old xclbin which doesn't have
// kernel_commit_id, we should make sure the offset is NOT 0
auto sKernelCommitId = "";
if (pHdr->kernel_commit_id != 0) {
sKernelCommitId = reinterpret_cast<const char*>(pBuffer + pHdr->kernel_commit_id);
} else {
XUtil::TRACE(boost::format("Open an existing xclbin: kernel_commit_id is 0x%lx") % pHdr->kernel_commit_id);
}
ptAiePartition.put("kernel_commit_id", sKernelCommitId);

// Partition info
populate_partition_info(pBuffer, pHdr->info, ptAiePartition);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
{
"aie_partition": {
"operations_per_cycle": "135",
"inference_fingerprint": "23423",
"pre_post_fingerprint": "12345",
"partition": {
"column_width": 1,
"start_columns": [1, 2, 3, 4]
},
"PDIs": [{
"uuid": "00000000-0000-0000-0000-000000001110",
"file_name": "./1110.txt",
"cdo_groups": [{
"name": "DPU",
"type": "PRIMARY",
"pdi_id": "0xF0",
"dpu_kernel_ids": ["0x100"],
"pre_cdo_groups": ["0xC0"]
},
{
"name": "PP0",
"type": "LITE",
"pdi_id": "0xF1",
"dpu_kernel_ids": ["0x101"],
"pre_cdo_groups": ["0xC0"]
"aie_partition": {
"operations_per_cycle": "135",
"inference_fingerprint": "23423",
"pre_post_fingerprint": "12345",
"kernel_commit_id": "0123456789abcdef",
"partition": {
"column_width": 1,
"start_columns": [1, 2, 3, 4]
},
"PDIs": [{
"uuid": "00000000-0000-0000-0000-000000001110",
"file_name": "./1110.txt",
"cdo_groups": [{
"name": "DPU",
"type": "PRIMARY",
"pdi_id": "0xF0",
"dpu_kernel_ids": ["0x100"],
"pre_cdo_groups": ["0xC0"]
},
{
"name": "PP0",
"type": "LITE",
"pdi_id": "0xF1",
"dpu_kernel_ids": ["0x101"],
"pre_cdo_groups": ["0xC0"]

},
{
"name": "PP1",
"type": "LITE",
"pdi_id": "0xF2",
"dpu_kernel_ids": ["0x102"],
"pre_cdo_groups": ["0xC0"]
},
{
"name": "shared",
"pdi_id": "0xC0",
"pre_cdo_groups": ["0xC1"]
},
{
"name": "routing",
"pdi_id": "0xC1"
}
]
},
{
"uuid": "00000000-0000-0000-0000-000000001111",
"file_name": "./1111.txt",
"cdo_groups": [{
"name": "PP3",
"type": "LITE",
"pdi_id": "0xF1",
"dpu_kernel_ids": ["0x104", "0x105"]
}]
}
]
}
},
{
"name": "PP1",
"type": "LITE",
"pdi_id": "0xF2",
"dpu_kernel_ids": ["0x102"],
"pre_cdo_groups": ["0xC0"]
},
{
"name": "shared",
"pdi_id": "0xC0",
"pre_cdo_groups": ["0xC1"]
},
{
"name": "routing",
"pdi_id": "0xC1"
}
]
},
{
"uuid": "00000000-0000-0000-0000-000000001111",
"file_name": "./1111.txt",
"cdo_groups": [{
"name": "PP3",
"type": "LITE",
"pdi_id": "0xF1",
"dpu_kernel_ids": ["0x104", "0x105"]
}]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"operations_per_cycle": "135",
"inference_fingerprint": "23423",
"pre_post_fingerprint": "12345",
"kernel_commit_id": "0123456789abcdef",
"partition": {
"column_width": "1",
"start_columns": [
Expand Down

0 comments on commit dea5bb9

Please sign in to comment.