Skip to content

Commit

Permalink
[cuda] Add command-line option to drop legacy sync mode (iree-org#15582)
Browse files Browse the repository at this point in the history
Legacy sync mode forces waiting on semaphore immediately so
it effectively runs all async allocation/execution in sync mode.
Now we have proper semaphore emulation in cuda2, we don't
need this anymore. Disable it for end-to-end op tests for
experimental cuda2 driver.

Progress towards iree-org#13245
  • Loading branch information
antiagainst authored Nov 14, 2023
1 parent 14c1b4b commit 643b467
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion compiler/plugins/target/CUDA/CUDATarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct CUDAOptions {
bool clUsePtxas = false;
std::string clUsePtxasFrom;
std::string clUsePtxasParams;
bool enableLegacySync = true;

void bindOptions(OptionsBinder &binder) {
static llvm::cl::OptionCategory category("CUDA HAL Target");
Expand Down Expand Up @@ -104,6 +105,12 @@ struct CUDAOptions {
"iree-hal-cuda-use-ptxas-params", clUsePtxasParams,
llvm::cl::cat(category),
llvm::cl::desc("Passes the given additional parameters to ptxas."));

binder.opt<bool>(
"iree-hal-cuda-enable-legacy-sync", enableLegacySync,
llvm::cl::cat(category),
llvm::cl::desc(
"Enable legacy sync mode that handles semaphores synchronously."));
}
};
} // namespace
Expand Down Expand Up @@ -390,7 +397,9 @@ class CUDATargetBackend final : public TargetBackend {

// Indicates that the runtime HAL driver operates only in the legacy
// synchronous mode.
configItems.emplace_back(b.getStringAttr("legacy_sync"), b.getUnitAttr());
if (options.enableLegacySync) {
configItems.emplace_back(b.getStringAttr("legacy_sync"), b.getUnitAttr());
}

configItems.emplace_back(b.getStringAttr("executable_targets"),
getExecutableTargets(context));
Expand Down
2 changes: 2 additions & 0 deletions experimental/cuda2/tests/stablehlo_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ iree_check_single_backend_test_suite(
"--iree-input-type=stablehlo"
# TODO(#13984): We need memset emulation to workaround CUDA graph issues for now.
"--iree-stream-emulate-memset"
"--iree-hal-cuda-enable-legacy-sync=false"
RUNNER_ARGS
"--cuda2_use_streams=false"
LABELS
Expand Down Expand Up @@ -156,6 +157,7 @@ iree_check_single_backend_test_suite(
"cuda2"
COMPILER_FLAGS
"--iree-input-type=stablehlo"
"--iree-hal-cuda-enable-legacy-sync=false"
RUNNER_ARGS
"--cuda2_use_streams=true"
LABELS
Expand Down
2 changes: 2 additions & 0 deletions experimental/cuda2/tests/tosa_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ iree_check_single_backend_test_suite(
"--iree-input-type=tosa"
# TODO(#13984): We need memset emulation to workaround CUDA graph issues for now.
"--iree-stream-emulate-memset"
"--iree-hal-cuda-enable-legacy-sync=false"
RUNNER_ARGS
"--cuda2_use_streams=false"
LABELS
Expand Down Expand Up @@ -118,6 +119,7 @@ iree_check_single_backend_test_suite(
"cuda2"
COMPILER_FLAGS
"--iree-input-type=tosa"
"--iree-hal-cuda-enable-legacy-sync=false"
RUNNER_ARGS
"--cuda2_use_streams=true"
LABELS
Expand Down

0 comments on commit 643b467

Please sign in to comment.