Skip to content

Commit

Permalink
Generate unique UUIDs for PDIs
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenneuendorffer committed May 23, 2024
1 parent 465049f commit ef6c37f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions python/compiler/aiecc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tempfile
from textwrap import dedent
import time
import uuid

from aie.extras.runtime.passes import Pipeline

Expand Down Expand Up @@ -207,7 +208,8 @@ def emit_partition(mlir_module_str, kernel_id="0x901", start_columns=None):
else:
start_columns = list(range(1, 6 - num_cols))

uuid = random.randint(2222, 9999)
# Generate a uuid
pdi_uuid = uuid.uuid4()
return {
"aie_partition": {
"name": "QoS",
Expand All @@ -220,7 +222,7 @@ def emit_partition(mlir_module_str, kernel_id="0x901", start_columns=None):
},
"PDIs": [
{
"uuid": "00000000-0000-0000-0000-00000000" + str(uuid),
"uuid": str(pdi_uuid),
"file_name": "./design.pdi",
"cdo_groups": [
{
Expand Down
5 changes: 4 additions & 1 deletion tools/aie2xclbin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
configure_file(configure.h.in configure.h)
target_include_directories(aie2xclbin PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")

find_library (UUID uuid)

target_link_libraries(aie2xclbin
${dialect_libs}
MLIRParser
Expand All @@ -37,7 +39,8 @@ target_link_libraries(aie2xclbin
AIEX
AIEXTransforms
MLIRAIEVecDialect
MLIRXLLVMDialect)
MLIRXLLVMDialect
${UUID})

install(TARGETS aie2xclbin
EXPORT AIE2XCLBIN
Expand Down
9 changes: 8 additions & 1 deletion tools/aie2xclbin/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/ToolOutputFile.h"

#include <uuid/uuid.h>

#include <regex>
#include <sstream>
#include <unordered_map>
Expand Down Expand Up @@ -453,6 +455,11 @@ static LogicalResult generateXCLBin(MLIRContext *context, ModuleOp moduleOp,
if (!aiePartitionJsonOut)
return moduleOp.emitOpError(errorMessage);

uuid_t binuuid;
uuid_generate_random(binuuid);
char uuid[37];
uuid_unparse_lower(binuuid, uuid);

std::string aie_partition_json_data = R"(
{
"aie_partition": {
Expand All @@ -468,7 +475,7 @@ static LogicalResult generateXCLBin(MLIRContext *context, ModuleOp moduleOp,
},
"PDIs": [
{
"uuid": "00000000-0000-0000-0000-000000008025",
"uuid": ")" + std::string(uuid) + R"(",
"file_name": "./design.pdi",
"cdo_groups": [
{
Expand Down

0 comments on commit ef6c37f

Please sign in to comment.