You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having added about 6 variations of private IREE HALs including the public ROCM HAL it would be good to support out of tree HALs. We have a few more HALs that require carry forks that we would rather have built out of tree.
There is no need for binary compatibility etc in this ask -- all sources will be built together but we would like IREE HAL to look for "external" modules in some CMAKE specified path.
I’ll add a cmake list var to supersede what we have in iree/hal/drivers/ - you’ll then ensure you have a static library with the right name and a function that registers the driver and it’ll get linked and called by any iree tool using the driver registry. You can still manually register things in your own binaries if you want smaller binary sizes/deps but I suspect what you’re asking for here is for them to appear in iree-benchmark-module and such.
then have a file with the registration function in it:
iree_status_trocm_hal_driver_register(iree_hal_driver_registry_t*registry) {
// do registration stuff here
}
and in iree/hal/drivers/ we'd include it:
foreach(driver ${IREE_EXTERNAL_HAL_DRIVERS})
# include cmakelists that contains the library and fetches/finds/etc deps
get_external_hal_driver_var(source_dir ${driver} SOURCE_DIR)
add_subdirectory(${source_dir})
# allow the external cmakelists to decide whether it's actually enabled (find_package success, etc)
get_external_hal_driver_var(driver_usable ${driver} FOUND)
if(${driver_usable})
# add dep on the target so that it gets pulled into the build
get_external_hal_driver_var(target ${driver} TARGET)
list(APPEND IREE_HAL_DRIVER_MODULES ${target})
# add the registration call to the list
list(APPEND IREE_HAL_DRIVER_REGISTRATION_CALLS "${driver}_register")
endif()
endforeach()
...
# produce an init_external.c with calls to each of the IREE_HAL_DRIVER_REGISTRATION_CALLS
configure_file(init_external.c.in init_external.c)
...
iree_cc_library(
drivers ...
SRCS "init.c" "init_external.c"
DEPS ${IREE_HAL_DRIVER_MODULES}
COPTS "-DIREE_HAL_EXTERNAL_DRIVER_REGISTRATION=1"
Or something like this with the cmake goo resolved.
For bazel we could check in a file with the backends or genrule a templated one, but the cmake stuff should be this straightforward and make it possible to include external drivers without changing any IREE code.
I think it would also be possible to do all the built-in HAL drivers like this as well, which would help solve for things like vulkan sdk deps/webgpu stuff/etc.
We may want something similar for executable loaders - that'd let us solve the #4298 issue by having vmvx/dylib/etc optional alongside static libraries and bigger deps (wasm/jits/etc).
A gotcha here will be that the benchmark infra is not setup to handle external drivers; it currently relies on knowing about the drivers in python instead of relying on what's available in cmake (what we can easily extend). There will need to be some work to remove all references to driver names in the code if we care about letting people use the benchmark infra (which would be really nice); basically the only place that should know about compilation targets/driver names/etc should be the definition of the benchmark suite and then those should be passed unmodified down to the lower level tooling (iree-compile/iree-benchmark-module/etc).
Activity
benvanik commentedon Jun 6, 2022
I’ll add a cmake list var to supersede what we have in iree/hal/drivers/ - you’ll then ensure you have a static library with the right name and a function that registers the driver and it’ll get linked and called by any iree tool using the driver registry. You can still manually register things in your own binaries if you want smaller binary sizes/deps but I suspect what you’re asking for here is for them to appear in iree-benchmark-module and such.
benvanik commentedon Jun 6, 2022
Rough idea is that we add an
IREE_EXTERNAL_HAL_DRIVERScmake var similar toLLVM_EXTERNAL_PROJECTS- you'd then declare your driver:then have a file with the registration function in it:
and in
iree/hal/drivers/we'd include it:then in the init.c we do:
Or something like this with the cmake goo resolved.
For bazel we could check in a file with the backends or genrule a templated one, but the cmake stuff should be this straightforward and make it possible to include external drivers without changing any IREE code.
I think it would also be possible to do all the built-in HAL drivers like this as well, which would help solve for things like vulkan sdk deps/webgpu stuff/etc.
/cc @ScottTodd
powderluv commentedon Jun 6, 2022
Nice this is exactly what we want on the CMake side. We haven't had to use bazel with externals so whatever is best on bazel side we are ok.
benvanik commentedon Jun 6, 2022
We may want something similar for executable loaders - that'd let us solve the #4298 issue by having vmvx/dylib/etc optional alongside static libraries and bigger deps (wasm/jits/etc).
Moving CUDA and Vulkan HAL drivers to iree/hal/drivers/.
Moving legacy dylib/vmvx driver modules to iree/hal/drivers/.
Moving CUDA and Vulkan HAL drivers to iree/hal/drivers/.
Moving legacy dylib/vmvx driver modules to iree/hal/drivers/.
Moving CUDA and Vulkan HAL drivers to iree/hal/drivers/.
Moving legacy dylib/vmvx driver modules to iree/hal/drivers/.
benvanik commentedon Jun 7, 2022
A gotcha here will be that the benchmark infra is not setup to handle external drivers; it currently relies on knowing about the drivers in python instead of relying on what's available in cmake (what we can easily extend). There will need to be some work to remove all references to driver names in the code if we care about letting people use the benchmark infra (which would be really nice); basically the only place that should know about compilation targets/driver names/etc should be the definition of the benchmark suite and then those should be passed unmodified down to the lower level tooling (iree-compile/iree-benchmark-module/etc).
powderluv commentedon Jun 8, 2022
Thanks thanks