Skip to content

Commit

Permalink
Add windows support?
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenneuendorffer committed May 24, 2024
1 parent ef6c37f commit 6ae574e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ find_library(ELF_LIB elf)
cmake_dependent_option(AIE_ENABLE_AIRBIN
"Enables emitting AIRBIN ELF binaries." OFF "ELF_LIB" OFF)

# If we need runtime libs, then statically link them.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

add_flag_if_supported("-Werror=sign-compare" WERROR_SIGN_COMPARE)
add_flag_if_supported("-Werror=unused" WERROR_USED)
Expand Down
2 changes: 0 additions & 2 deletions tools/aie2xclbin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ 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 Down
38 changes: 30 additions & 8 deletions tools/aie2xclbin/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/ToolOutputFile.h"

#include <uuid/uuid.h>

#include <regex>
#include <sstream>
#include <unordered_map>

#ifdef _WIN32
#include "windows.h"
// For UUID stuff
#include "rpcdce.h"

#define setenv(name, var, ignore) _putenv_s(name, var)
#else
#include <uuid/uuid.h>
#endif

using namespace llvm;
Expand Down Expand Up @@ -128,6 +132,28 @@ void xilinx::findVitis(XCLBinGenConfig &TK) {
}
}

static std::string getUUIDString() {
std::string val;
#ifdef _WIN32
UUID *uuid;
RPC_STATUS status;
status = UuidCreate(uuid);
if(status != RPC_S_OK) errs() << "Failed to create UUID\n";
RPC_CSTR *uuidstring;
status = UuidToStringA(uuid, uuidstring);
if(status != RPC_S_OK) errs() << "Failed to convert UUID to string\n";
val = std::string(uuidstring);

Check failure on line 145 in tools/aie2xclbin/XCLBinGen.cpp

View workflow job for this annotation

GitHub Actions / windows-2019 msvc assert=ON rtti=ON

'<function-style-cast>': cannot convert from 'RPC_CSTR *' to 'std::string'

Check failure on line 145 in tools/aie2xclbin/XCLBinGen.cpp

View workflow job for this annotation

GitHub Actions / windows-2019 msvc assert=OFF rtti=OFF

'<function-style-cast>': cannot convert from 'RPC_CSTR *' to 'std::string'

Check failure on line 145 in tools/aie2xclbin/XCLBinGen.cpp

View workflow job for this annotation

GitHub Actions / windows-2019 msvc assert=ON rtti=OFF

'<function-style-cast>': cannot convert from 'RPC_CSTR *' to 'std::string'

Check failure on line 145 in tools/aie2xclbin/XCLBinGen.cpp

View workflow job for this annotation

GitHub Actions / windows-2019 msvc assert=OFF rtti=ON

'<function-style-cast>': cannot convert from 'RPC_CSTR *' to 'std::string'
status = RpcStringFreeA(uuidstring);
if(status != RPC_S_OK) errs() << "Failed to free UUID string\n";
#else
uuid_t binuuid;
uuid_generate_random(binuuid);
char uuid[37];
uuid_unparse_lower(binuuid, uuid);
val = std::string(uuid);
#endif
return val;
}
static void addAIELoweringPasses(OpPassManager &pm) {
pm.addPass(createLowerAffinePass());
pm.addPass(AIE::createAIECanonicalizeDevicePass());
Expand Down Expand Up @@ -455,11 +481,7 @@ 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 uuid_str = getUUIDString();
std::string aie_partition_json_data = R"(
{
"aie_partition": {
Expand All @@ -475,7 +497,7 @@ static LogicalResult generateXCLBin(MLIRContext *context, ModuleOp moduleOp,
},
"PDIs": [
{
"uuid": ")" + std::string(uuid) + R"(",
"uuid": ")" + uuid_str + R"(",
"file_name": "./design.pdi",
"cdo_groups": [
{
Expand Down

0 comments on commit 6ae574e

Please sign in to comment.