From 4cdc8e4bcc2481ffe59c7b2eb9c65391b9c0118d Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 1 Jul 2024 17:21:24 -0700 Subject: [PATCH] [rocm] Add --iree-rocm-legacy-sync flag (default true). (#17786) We will eventually want to disable this entirely as we enable reusable command buffers, graphs, and other optimizations. Signed-off-by: Stella Laurenzo --- compiler/plugins/target/ROCM/ROCMTarget.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/plugins/target/ROCM/ROCMTarget.cpp b/compiler/plugins/target/ROCM/ROCMTarget.cpp index 610337a59f25..1dfe81631996 100644 --- a/compiler/plugins/target/ROCM/ROCMTarget.cpp +++ b/compiler/plugins/target/ROCM/ROCMTarget.cpp @@ -59,6 +59,7 @@ struct ROCmOptions { std::string bitcodeDirectory = getDefaultBitcodeDirectory(); int wavesPerEu = 0; std::string enableROCMUkernels = "none"; + bool legacySync = true; void bindOptions(OptionsBinder &binder) { using namespace llvm; @@ -79,6 +80,9 @@ struct ROCmOptions { cl::desc("Enables microkernels in the rocm compiler backend. May be " "`default`, `none`, `all`, or a comma-separated list of " "specific unprefixed microkernels to enable, e.g. `mmt4d`.")); + binder.opt("iree-rocm-legacy-sync", legacySync, cl::cat(category), + cl::desc("Enables 'legacy-sync' mode, which is required " + "for inline execution.")); } LogicalResult verify(mlir::Builder &builder) const { @@ -176,10 +180,14 @@ class ROCMTargetDevice final : public TargetDevice { getDefaultDeviceTarget(MLIRContext *context, const TargetRegistry &targetRegistry) const override { Builder b(context); - // Indicates that the runtime HAL driver operates only in the legacy - // synchronous mode. - DictionaryAttr configAttr = b.getDictionaryAttr( - NamedAttribute(b.getStringAttr("legacy_sync"), b.getUnitAttr())); + SmallVector configAttrItems; + if (options.legacySync) { + // Indicates that the runtime HAL driver operates only in the legacy + // synchronous mode. + configAttrItems.emplace_back(b.getStringAttr("legacy_sync"), + b.getUnitAttr()); + } + DictionaryAttr configAttr = b.getDictionaryAttr(configAttrItems); // If we had multiple target environments we would generate one target attr // per environment, with each setting its own environment attribute.