Repository navigation
Add --iree-hal-list-target-backends flag. - #10629
Conversation
Sample usage (note the awkward required positional arg, similar to `--iree-llvm-list-targets`): ``` λ iree-compile.exe --iree-hal-list-target-backends /dev/null Registered target backends: cuda llvm-cpu metal metal-spirv vmvx vmvx-inline vulkan vulkan-spirv webgpu webgpu-wgsl λ iree-compile.exe --iree-hal-list-target-backends iree-compile.exe: Not enough positional command line arguments specified! Must specify at least 1 positional argument: See: ..\iree-build\tools\iree-compile.exe --help ```
There was a problem hiding this comment.
I suspect there's a better way to do this but I can't immediately find it - maybe llvm::cl::callback that prints out the list and then calls exit(0)? this would prevent the need to pass in a source file or get a bunch of random garbage output. something like:
cl::callback([](const bool &) {
// do the printing here
exit(0);
}
looks like you can also add this (this is what llvm does for its own list flags):
cl::ValueDisallowed,
Yeah, I'd like to find an elegant solution for this (especially if the list can just appear in the |
|
I think at least giving the callback + exit a shot would be worth it - needing documentation on how to use a help flag is pretty self-defeating :P |
| llvm::cl::desc( | ||
| "Lists all registered target backends for executable compilation."), | ||
| llvm::cl::init(false), llvm::cl::ValueDisallowed, | ||
| llvm::cl::callback([&](const bool &) { |
| llvm::cl::opt<bool> listHalTargets( | ||
| "iree-hal-list-target-backends", | ||
| llvm::cl::desc( | ||
| "Lists all registered target backends for executable compilation."), |
There was a problem hiding this comment.
I considered adding this flag to TargetRegistry.cpp or TargetBackend.cpp, but it didn't quite fit in, without a bit of refactoring. Is this location (iree_compile_lib.cc) okay?
The HAL target backends are registered outside of the typical flags system, so `--help` output just appears as ``` --iree-hal-target-backends=<string> - Target backends for executable compilation. ``` This adds a new flag with sample usage: ``` λ iree-compile.exe --iree-hal-list-target-backends Registered target backends: cuda llvm-cpu metal metal-spirv vmvx vmvx-inline vulkan vulkan-spirv webgpu webgpu-wgsl ``` Part of addressing iree-org#10432 --- I think we should also plumb something similar through to the Python bindings. This is what we have today: ```python # Omit `target_backends`: _ = compile_str(asm) ValueError: Expected a non-empty list for 'target_backends' # Try a backend that does not exist: _ = compile_str(asm, target_backends=["unknown"]) CompilerToolError: Error invoking IREE compiler tool iree-compile Diagnostics: <stdin>:2:3: error: target backend 'unknown' not registered; registered backends: cuda, llvm-cpu, metal, metal, vmvx, vmvx-inline, vulkan, vulkan module @Arithmetic { ^ compilation failed # See a runtime helper method that we could model this after: ireert.query_available_drivers() ['cuda', 'local-sync', 'local-task', 'vulkan'] ```
The HAL target backends are registered outside of the typical flags system, so
--helpoutput just appears asThis adds a new flag with sample usage:
Part of addressing #10432
I think we should also plumb something similar through to the Python bindings. This is what we have today: