diff --git a/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp b/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp --- a/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp +++ b/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp @@ -65,6 +65,8 @@ // HIP headers. #include "hip/hip_version.h" +#include + using namespace mlir; using namespace llvm; @@ -146,6 +148,7 @@ return success(); } +static std::mutex mutex; static LogicalResult createHsaco(const Blob &isaBlob, StringRef name, Blob &hsacoBlob) { // Save the ISA binary to a temp file. @@ -175,6 +178,7 @@ } FileRemover cleanupHsaco(tempHsacoFilename); + const std::lock_guard lock(mutex); // Invoke lld. Expect a true return value from lld. bool ret = lld::elf::link({"ld.lld", "-shared", tempIsaBinaryFilename.c_str(), "-o", tempHsacoFilename.c_str()},