From d1620f040ebc57ab19933df24bca54fa4dae3163 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 22 Dec 2021 14:55:38 -0800 Subject: [PATCH] Promote HAL driver and target backend CMake variables to options. (#7936) Following up on https://github.com/google/iree/pull/7905#discussion_r771022062, this uses regular options for these settings, which are easier to search for and set. The CMakeLists from Tint was used as a reference: https://dawn.googlesource.com/tint/+/refs/heads/main/CMakeLists.txt. The main focus is to use explicit names instead of dynamic name construction, but using [option](https://cmake.org/cmake/help/latest/command/option.html) is a nice bonus. New `IREE_HAL_DRIVER_DEFAULTS` and `IREE_TARGET_BACKEND_DEFAULTS` options can be used to set only a specific subset (set to `OFF` by default, then enable just the features you want). --- CMakeLists.txt | 130 +++++++----------- bindings/tflite/java/build.gradle | 7 +- build_tools/cmake/build_runtime_emscripten.sh | 3 +- build_tools/cmake/iree_check_test.cmake | 14 +- build_tools/cmake/iree_macros.cmake | 4 +- .../cmake/iree_trace_runner_test.cmake | 14 +- build_tools/cmake/riscv.toolchain.cmake | 4 +- .../cmake_options_and_variables.md | 21 +-- .../deployment-configurations/bare-metal.md | 5 +- .../deployment-configurations/cpu-dylib.md | 10 +- .../deployment-configurations/gpu-vulkan.md | 10 +- iree/compiler/Dialect/HAL/Target/LLVM/BUILD | 2 +- .../Dialect/HAL/Target/LLVM/CMakeLists.txt | 2 +- .../Dialect/HAL/Target/MetalSPIRV/BUILD | 2 +- .../HAL/Target/MetalSPIRV/CMakeLists.txt | 2 +- .../Dialect/HAL/Target/VulkanSPIRV/BUILD | 2 +- .../HAL/Target/VulkanSPIRV/CMakeLists.txt | 2 +- iree/compiler/Dialect/Vulkan/Utils/test/BUILD | 2 +- .../Dialect/Vulkan/Utils/test/CMakeLists.txt | 2 +- iree/runtime/instance.h | 4 +- iree/samples/simple_embedding/BUILD | 4 +- iree/samples/simple_embedding/CMakeLists.txt | 4 +- iree/samples/static_library/CMakeLists.txt | 2 +- iree/samples/static_library/README.md | 6 +- iree/samples/vision/CMakeLists.txt | 2 +- iree/samples/vulkan/CMakeLists.txt | 2 +- iree/tools/CMakeLists.txt | 6 +- 27 files changed, 124 insertions(+), 144 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f986cb230b1..13ecbb0f3ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,6 @@ option(IREE_BUILD_TENSORFLOW_COMPILER "Builds TensorFlow compiler frontend." "${ option(IREE_BUILD_TFLITE_COMPILER "Builds the TFLite compiler frontend." "${IREE_BUILD_TENSORFLOW_ALL}") option(IREE_BUILD_XLA_COMPILER "Builds TensorFlow XLA compiler frontend." "${IREE_BUILD_TENSORFLOW_ALL}") -set(IREE_HAL_DRIVERS_TO_BUILD "default" - CACHE STRING "Semicolon-separated list of HAL drivers to build, or \"default\"") -set(IREE_TARGET_BACKENDS_TO_BUILD "default" - CACHE STRING "Semicolon-separated list of target backends to build, or \"default\"") - # Properties controlling version and naming of release artifacts. set(IREE_RELEASE_PACKAGE_SUFFIX "-dev" CACHE STRING "Suffix to append to distributed package names") set(IREE_RELEASE_VERSION "0.1a1" CACHE STRING "Version to embed in distributed packages") @@ -90,86 +85,56 @@ option(IREE_ENABLE_EMITC "Enables MLIR EmitC dependencies." ${IREE_BUILD_COMPILE # Target and backend configuration #------------------------------------------------------------------------------- -# List of all runtime HAL drivers included in the project: -set(IREE_ALL_HAL_DRIVERS - CUDA - Dylib - Dylib_Sync - VMVX - VMVX_Sync - Vulkan -) - -if(IREE_HAL_DRIVERS_TO_BUILD STREQUAL "default") - set(IREE_HAL_DRIVERS_TO_BUILD ${IREE_ALL_HAL_DRIVERS}) +option(IREE_HAL_DRIVER_DEFAULTS "Sets the default value for all runtime HAL drivers" ON) +option(IREE_TARGET_BACKEND_DEFAULTS "Sets the default value for all compiler target backends" ${IREE_BUILD_COMPILER}) - # Vulkan is not natively supported on Apple platforms. - # Metal should generally be used instead, though MoltenVK may also work. - if(APPLE) - list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Vulkan) - endif() - - # CUDA is not natively supported on Android or Apple platforms. - if(ANDROID OR APPLE) - list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD CUDA) - endif() +# CUDA is not natively supported on Android or Apple platforms. +if(ANDROID OR APPLE) + set(IREE_HAL_DRIVER_CUDA_DEFAULT OFF) +else() + set(IREE_HAL_DRIVER_CUDA_DEFAULT ${IREE_HAL_DRIVER_DEFAULTS}) endif() -message(STATUS "Building runtime HAL drivers: ${IREE_HAL_DRIVERS_TO_BUILD}") - -# Start each IREE_HAL_DRIVER_* OFF, then enable from IREE_HAL_DRIVERS_TO_BUILD. -foreach(_backend ${IREE_ALL_HAL_DRIVERS}) - string(TOUPPER "${_backend}" uppercase_backend) - set(IREE_HAL_DRIVER_${uppercase_backend} OFF CACHE BOOL "" FORCE) -endforeach() -foreach(_backend ${IREE_HAL_DRIVERS_TO_BUILD}) - string(TOUPPER "${_backend}" uppercase_backend) - string(REPLACE "\"" "" uppercase_backend ${uppercase_backend}) - set(IREE_HAL_DRIVER_${uppercase_backend} ON CACHE BOOL "" FORCE) -endforeach() - -# List of all compiler target backends included in the project: -set(IREE_ALL_TARGET_BACKENDS - CUDA - Dylib-LLVM-AOT - WASM-LLVM-AOT - Metal-SPIRV - ROCm - Vulkan-SPIRV - VMVX - WebGPU -) -if(${IREE_BUILD_COMPILER}) - if(IREE_TARGET_BACKENDS_TO_BUILD STREQUAL "default") - set(IREE_TARGET_BACKENDS_TO_BUILD ${IREE_ALL_TARGET_BACKENDS}) - - # Disable the WebGPU backend by default, as it has complex dependencies and - # is still early in its development. - list(REMOVE_ITEM IREE_TARGET_BACKENDS_TO_BUILD WebGPU) - endif() - message(STATUS "Building compiler target backends: ${IREE_TARGET_BACKENDS_TO_BUILD}") +# Vulkan is not natively supported on Apple platforms. +# Metal should generally be used instead, though MoltenVK may also work. +if (APPLE) + set(IREE_HAL_DRIVER_VULKAN_DEFAULT OFF) else() - set(IREE_TARGET_BACKENDS_TO_BUILD "" CACHE STRING "" FORCE) - message(STATUS "Compiler is disabled, building no target backends") + set(IREE_HAL_DRIVER_VULKAN_DEFAULT ${IREE_HAL_DRIVER_DEFAULTS}) endif() -# Default every IREE_TARGET_BACKEND_* to OFF -foreach(_backend ${IREE_ALL_TARGET_BACKENDS}) - string(TOUPPER "${_backend}" uppercase_backend) - set(IREE_TARGET_BACKEND_${uppercase_backend} OFF CACHE BOOL "" FORCE) -endforeach() - -# Set IREE_TARGET_BACKEND_* based on configuration -foreach(_backend ${IREE_TARGET_BACKENDS_TO_BUILD}) - string(TOUPPER "${_backend}" uppercase_backend) - string(REPLACE "\"" "" uppercase_backend ${uppercase_backend}) - set(IREE_TARGET_BACKEND_${uppercase_backend} ON CACHE BOOL "" FORCE) -endforeach() - -list(APPEND CMAKE_MODULE_PATH - ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ - ${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/ -) +option(IREE_HAL_DRIVER_CUDA "Enables the 'cuda' runtime HAL driver" ${IREE_HAL_DRIVER_CUDA_DEFAULT}) +option(IREE_HAL_DRIVER_DYLIB "Enables the 'dylib' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS}) +option(IREE_HAL_DRIVER_DYLIB_SYNC "Enables the 'dylib-sync' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS}) +option(IREE_HAL_DRIVER_VMVX "Enables the 'vmvx' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS}) +option(IREE_HAL_DRIVER_VMVX_SYNC "Enables the 'vmvx-sync' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS}) +option(IREE_HAL_DRIVER_VULKAN "Enables the 'vulkan' runtime HAL driver" ${IREE_HAL_DRIVER_VULKAN_DEFAULT}) + +option(IREE_TARGET_BACKEND_CUDA "Enables the 'cuda' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_DYLIB_LLVM_AOT "Enables the 'dylib-llvm-aot' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_METAL_SPIRV "Enables the 'metal-spirv' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_ROCM "Enables the 'rocm' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_VMVX "Enables the 'vmvx' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_VULKAN_SPIRV "Enables the 'vulkan-spirv' compiler target backend" ${IREE_BUILD_COMPILER}) +option(IREE_TARGET_BACKEND_WASM_LLVM_AOT "Enables the 'wasm-llvm-aot' compiler target backend" ${IREE_BUILD_COMPILER}) +# Disable WebGPU by default - it has complex deps and is under development. +option(IREE_TARGET_BACKEND_WEBGPU "Enables the 'webgpu' compiler target backend" OFF) + +message(VERBOSE "IREE build runtime HAL driver 'cuda': ${IREE_HAL_DRIVER_CUDA}") +message(VERBOSE "IREE build runtime HAL driver 'dylib': ${IREE_HAL_DRIVER_DYLIB}") +message(VERBOSE "IREE build runtime HAL driver 'dylib-sync': ${IREE_HAL_DRIVER_DYLIB_SYNC}") +message(VERBOSE "IREE build runtime HAL driver 'vmvx': ${IREE_HAL_DRIVER_VMVX}") +message(VERBOSE "IREE build runtime HAL driver 'vmvx-sync': ${IREE_HAL_DRIVER_VMVX_SYNC}") +message(VERBOSE "IREE build runtime HAL driver 'vulkan': ${IREE_HAL_DRIVER_VULKAN}") + +message(VERBOSE "IREE build compiler target backend 'cuda': ${IREE_TARGET_BACKEND_CUDA}") +message(VERBOSE "IREE build compiler target backend 'dylib-llvm-aot': ${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT}") +message(VERBOSE "IREE build compiler target backend 'wasm-llvm-aot': ${IREE_TARGET_BACKEND_WASM_LLVM_AOT}") +message(VERBOSE "IREE build compiler target backend 'metal-spirv': ${IREE_TARGET_BACKEND_METAL_SPIRV}") +message(VERBOSE "IREE build compiler target backend 'rocm': ${IREE_TARGET_BACKEND_ROCM}") +message(VERBOSE "IREE build compiler target backend 'vulkan-spirv': ${IREE_TARGET_BACKEND_VULKAN_SPIRV}") +message(VERBOSE "IREE build compiler target backend 'vmvx': ${IREE_TARGET_BACKEND_VMVX}") +message(VERBOSE "IREE build compiler target backend 'webgpu': ${IREE_TARGET_BACKEND_WEBGPU}") #------------------------------------------------------------------------------- # IREE compilation toolchain configuration @@ -244,6 +209,11 @@ iree_fix_ndebug() # IREE utility definitions #------------------------------------------------------------------------------- +list(APPEND CMAKE_MODULE_PATH + ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ + ${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/ +) + include(iree_macros) include(iree_copts) include(sanitizers) @@ -479,7 +449,7 @@ if(IREE_BUILD_PYTHON_BINDINGS) endif() endif() -if(IREE_TARGET_BACKEND_METAL-SPIRV) +if(IREE_TARGET_BACKEND_METAL_SPIRV) iree_set_spirv_cross_cmake_options() # SPIRV-Cross is needed to cross compile SPIR-V into MSL source code. add_subdirectory(third_party/spirv_cross EXCLUDE_FROM_ALL) diff --git a/bindings/tflite/java/build.gradle b/bindings/tflite/java/build.gradle index 325f6f159bae..09638f4037ca 100644 --- a/bindings/tflite/java/build.gradle +++ b/bindings/tflite/java/build.gradle @@ -31,7 +31,8 @@ android { cmake { arguments "-DIREE_BUILD_BINDINGS_TFLITE=ON", "-DIREE_BUILD_BINDINGS_TFLITE_JAVA=ON", - "-DIREE_HAL_DRIVERS_TO_BUILD=VMVX", + "-DIREE_HAL_DRIVER_DEFAULTS=OFF", + "-DIREE_HAL_DRIVER_VMVX=ON", // Disable all but the runtime components needed for the // java bindings. @@ -79,8 +80,8 @@ task cmakeConfigureHost(type: Exec) { commandLine "cmake", "-G" , "Ninja", "-B", hostBuildDir , - "-DIREE_TARGET_BACKENDS_TO_BUILD=vmvx", - "-DIREE_HAL_DRIVERS_TO_BUILD=vmvx", + "-DIREE_HAL_DRIVER_DEFAULTS=OFF", + "-DIREE_HAL_DRIVER_VMVX=ON", "-DIREE_BUILD_COMPILER=OFF", "-DIREE_BUILD_TESTS=OFF ", "-DIREE_BUILD_SAMPLES=OFF", diff --git a/build_tools/cmake/build_runtime_emscripten.sh b/build_tools/cmake/build_runtime_emscripten.sh index 614673d5b992..a0f8db8c54b8 100755 --- a/build_tools/cmake/build_runtime_emscripten.sh +++ b/build_tools/cmake/build_runtime_emscripten.sh @@ -41,7 +41,8 @@ cd build-emscripten # Configure using Emscripten's CMake wrapper, then build. emcmake "${CMAKE_BIN?}" -G Ninja .. \ -DIREE_HOST_BINARY_ROOT=$PWD/../build-host/install \ - -DIREE_HAL_DRIVERS_TO_BUILD=VMVX\;DyLib \ + -DIREE_HAL_DRIVER_DEFAULTS=OFF \ + -DIREE_HAL_DRIVER_VMVX=ON \ -DIREE_BUILD_COMPILER=OFF \ -DIREE_BUILD_TESTS=OFF \ -DIREE_BUILD_SAMPLES=ON diff --git a/build_tools/cmake/iree_check_test.cmake b/build_tools/cmake/iree_check_test.cmake index 9b3a79ee12a6..4a75a94d717e 100644 --- a/build_tools/cmake/iree_check_test.cmake +++ b/build_tools/cmake/iree_check_test.cmake @@ -223,15 +223,17 @@ function(iree_check_single_backend_test_suite) # Omit tests for which the specified driver or target backend is not enabled. # This overlaps with directory exclusions and other filtering mechanisms. string(TOUPPER ${_RULE_DRIVER} _UPPERCASE_DRIVER) - if(NOT DEFINED IREE_HAL_DRIVER_${_UPPERCASE_DRIVER}) - message(SEND_ERROR "Unknown driver '${_RULE_DRIVER}'. Check IREE_ALL_HAL_DRIVERS.") + string(REPLACE "-" "_" _NORMALIZED_DRIVER ${_UPPERCASE_DRIVER}) + if(NOT DEFINED IREE_HAL_DRIVER_${_NORMALIZED_DRIVER}) + message(SEND_ERROR "Unknown driver '${_RULE_DRIVER}'. Check IREE_HAL_DRIVER_* options.") endif() - if(NOT IREE_HAL_DRIVER_${_UPPERCASE_DRIVER}) + if(NOT IREE_HAL_DRIVER_${_NORMALIZED_DRIVER}) return() endif() string(TOUPPER ${_RULE_TARGET_BACKEND} _UPPERCASE_TARGET_BACKEND) - if(NOT DEFINED IREE_TARGET_BACKEND_${_UPPERCASE_TARGET_BACKEND}) - message(SEND_ERROR "Unknown backend '${_RULE_TARGET_BACKEND}'. Check IREE_ALL_TARGET_BACKENDS.") + string(REPLACE "-" "_" _NORMALIZED_TARGET_BACKEND ${_UPPERCASE_TARGET_BACKEND}) + if(NOT DEFINED IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND}) + message(SEND_ERROR "Unknown backend '${_RULE_TARGET_BACKEND}'. Check IREE_TARGET_BACKEND_* options.") endif() if(DEFINED IREE_HOST_BINARY_ROOT) # If we're not building the host tools from source under this configuration, @@ -240,7 +242,7 @@ function(iree_check_single_backend_test_suite) # rely on the runtime HAL driver check above for filtering. else() # We are building the host tools, so check enabled compiler target backends. - if(NOT IREE_TARGET_BACKEND_${_UPPERCASE_TARGET_BACKEND}) + if(NOT IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND}) return() endif() endif() diff --git a/build_tools/cmake/iree_macros.cmake b/build_tools/cmake/iree_macros.cmake index 22cdf685f6ae..143fc8c5b73c 100644 --- a/build_tools/cmake/iree_macros.cmake +++ b/build_tools/cmake/iree_macros.cmake @@ -295,10 +295,10 @@ function(iree_add_test_environment_properties TEST_NAME) # # Tests which only depend on a compiler target backend or a runtime HAL # driver, but not both, should generally use a different method of filtering. - if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}" OR NOT "${IREE_HAL_DRIVER_VULKAN}") + if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}" OR NOT "${IREE_HAL_DRIVER_VULKAN}") set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "IREE_VULKAN_DISABLE=1") endif() - if(NOT "${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT}" OR NOT "${IREE_HAL_DRIVER_DYLIB}" + if(NOT "${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT}" OR NOT "${IREE_HAL_DRIVER_DYLIB}" OR NOT "${IREE_HAL_DRIVER_DYLIB_SYNC}") set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "IREE_LLVMAOT_DISABLE=1") endif() diff --git a/build_tools/cmake/iree_trace_runner_test.cmake b/build_tools/cmake/iree_trace_runner_test.cmake index b214a35c79ec..13e97fcaa553 100644 --- a/build_tools/cmake/iree_trace_runner_test.cmake +++ b/build_tools/cmake/iree_trace_runner_test.cmake @@ -166,15 +166,17 @@ function(iree_single_backend_generated_trace_runner_test) # Omit tests for which the specified driver or target backend is not enabled. # This overlaps with directory exclusions and other filtering mechanisms. string(TOUPPER ${_RULE_DRIVER} _UPPERCASE_DRIVER) - if(NOT DEFINED IREE_HAL_DRIVER_${_UPPERCASE_DRIVER}) - message(SEND_ERROR "Unknown driver '${_RULE_DRIVER}'. Check IREE_ALL_HAL_DRIVERS.") + string(REPLACE "-" "_" _NORMALIZED_DRIVER ${_UPPERCASE_DRIVER}) + if(NOT DEFINED IREE_HAL_DRIVER_${_NORMALIZED_DRIVER}) + message(SEND_ERROR "Unknown driver '${_RULE_DRIVER}'. Check IREE_HAL_DRIVER_* options.") endif() - if(NOT IREE_HAL_DRIVER_${_UPPERCASE_DRIVER}) + if(NOT IREE_HAL_DRIVER_${_NORMALIZED_DRIVER}) return() endif() string(TOUPPER ${_RULE_TARGET_BACKEND} _UPPERCASE_TARGET_BACKEND) - if(NOT DEFINED IREE_TARGET_BACKEND_${_UPPERCASE_TARGET_BACKEND}) - message(SEND_ERROR "Unknown backend '${_RULE_TARGET_BACKEND}'. Check IREE_ALL_TARGET_BACKENDS.") + string(REPLACE "-" "_" _NORMALIZED_TARGET_BACKEND ${_UPPERCASE_TARGET_BACKEND}) + if(NOT DEFINED IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND}) + message(SEND_ERROR "Unknown backend '${_RULE_TARGET_BACKEND}'. Check IREE_TARGET_BACKEND_* options.") endif() if(DEFINED IREE_HOST_BINARY_ROOT) # If we're not building the host tools from source under this configuration, @@ -183,7 +185,7 @@ function(iree_single_backend_generated_trace_runner_test) # rely on the runtime HAL driver check above for filtering. else() # We are building the host tools, so check enabled compiler target backends. - if(NOT IREE_TARGET_BACKEND_${_UPPERCASE_TARGET_BACKEND}) + if(NOT IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND}) return() endif() endif() diff --git a/build_tools/cmake/riscv.toolchain.cmake b/build_tools/cmake/riscv.toolchain.cmake index 4394e76c7a4b..9e6a5fa00559 100644 --- a/build_tools/cmake/riscv.toolchain.cmake +++ b/build_tools/cmake/riscv.toolchain.cmake @@ -47,7 +47,9 @@ elseif(RISCV_CPU STREQUAL "rv32-baremetal") set(CMAKE_C_EXTENSIONS OFF) # Force the usage of _ISOC11_SOURCE set(IREE_BUILD_BINDINGS_TFLITE OFF CACHE BOOL "" FORCE) set(IREE_BUILD_BINDINGS_TFLITE_JAVA OFF CACHE BOOL "" FORCE) - set(IREE_HAL_DRIVERS_TO_BUILD "Dylib_sync;VMVX_sync" CACHE STRING "" FORCE) + set(IREE_HAL_DRIVER_DEFAULTS OFF CACHE BOOL "" FORCE) + set(IREE_HAL_DRIVER_VMVX_SYNC ON CACHE BOOL "" FORCE) + set(IREE_HAL_DRIVER_DYLIB_SYNC ON CACHE BOOL "" FORCE) set(CMAKE_SYSTEM_LIBRARY_PATH "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/lib") set(IREE_ENABLE_THREADING OFF CACHE BOOL "" FORCE) set(RISCV_COMPILER_FLAGS "${RISCV_COMPILER_FLAGS} -march=rv32imf -mabi=ilp32 -DIREE_PLATFORM_GENERIC=1 -DIREE_SYNCHRONIZATION_DISABLE_UNSAFE=1 \ diff --git a/docs/developers/get_started/cmake_options_and_variables.md b/docs/developers/get_started/cmake_options_and_variables.md index 2212600b9248..6a340bb7300b 100644 --- a/docs/developers/get_started/cmake_options_and_variables.md +++ b/docs/developers/get_started/cmake_options_and_variables.md @@ -62,18 +62,21 @@ Builds the IREE TFLite Java bindings with the C API compatibility shim. Defaults Builds experimental remoting component. Defaults to `OFF`. -#### `IREE_HAL_DRIVERS_TO_BUILD`:STRING +#### `IREE_HAL_DRIVER_DEFAULTS`:BOOL -Semicolon-separated list of HAL drivers to build, or `all` for building all HAL -drivers. Case-insensitive. If an empty list is provided, will build no HAL -drivers. Defaults to `all`. Example: `-DIREE_HAL_DRIVERS_TO_BUILD=Vulkan;VMLA`. +Default setting for each `IREE_HAL_DRIVER_*` option. -#### `IREE_TARGET_BACKENDS_TO_BUILD`:STRING +#### `IREE_HAL_DRIVER_*`:BOOL -Semicolon-separated list of target backend to build, or `all` for building all -compiler target backends. Case-insensitive. If an empty list is provided, will -build no target backends. Defaults to `all`. Example: -`-DIREE_TARGET_BACKENDS_TO_BUILD=Vulkan-SPIRV;VMLA`. +Individual options enabling the build for each runtime HAL driver. + +#### `IREE_TARGET_BACKEND_DEFAULTS`:BOOL + +Default setting for each `IREE_TARGET_BACKEND_*` option. + +#### `IREE_TARGET_BACKEND_*`:BOOL + +Individual options enabling the build for each compiler target backend. #### `IREE_DEV_MODE`:BOOL diff --git a/docs/website/docs/deployment-configurations/bare-metal.md b/docs/website/docs/deployment-configurations/bare-metal.md index 945a98353697..227797480f2b 100644 --- a/docs/website/docs/deployment-configurations/bare-metal.md +++ b/docs/website/docs/deployment-configurations/bare-metal.md @@ -83,8 +83,9 @@ model execution is in a single-thread synchronous fashion. operating system * `set(IREE_BINDINGS_TFLITE OFF)`: Disable the TFLite binding support * `set(IREE_ENABLE_THREADING OFF)`: Disable multi-thread library support -* `set(IREE_HAL_DRIVERS_TO_BUILD "Dylib_Sync;VMVX_Sync")`: Build only the -dynamic library and VMVX runtime synchronous HAL drivers +* `set(IREE_HAL_DRIVER_DEFAULTS OFF)`: Disable HAL drivers by default, then +enable the synchronous HAL drivers with `set(IREE_HAL_DRIVER_VMVX_SYNC ON)` and +`set(IREE_HAL_DRIVER_DYLIB_SYNC ON)` * `set(IREE_BUILD_TESTS OFF)`: Disable tests until IREE supports running them on bare-metal platforms * `set(IREE_BUILD_SAMPLES ON)`: Build diff --git a/docs/website/docs/deployment-configurations/cpu-dylib.md b/docs/website/docs/deployment-configurations/cpu-dylib.md index f633ecc24810..e5a5ef4883e2 100644 --- a/docs/website/docs/deployment-configurations/cpu-dylib.md +++ b/docs/website/docs/deployment-configurations/cpu-dylib.md @@ -35,9 +35,8 @@ in by default on all platforms. -If you want to explicitly specify HAL drivers to support, you will need to add -`DyLib` to the `IREE_HAL_DRIVERS_TO_BUILD` CMake list variable when configuring -(for target). +Ensure that the `IREE_HAL_DRIVER_DYLIB` CMake option is `ON` when configuring +for the target. ### Get compiler for CPU native instructions @@ -69,9 +68,8 @@ to build IREE for your host platform and the page if you are cross compiling for Android. The dylib compiler backend is compiled in by default on all platforms. -If you want to explicitly specify HAL drivers to support, you will need to add -`DYLIB-LLVM-AOT` to the `IREE_TARGET_BACKENDS_TO_BUILD` CMake list variable when -configuring (for host). +Ensure that the `IREE_TARGET_BACKEND_DYLIB_LLVM_AOT` CMake option is `ON` when +configuring for the host. ## Compile and run the model diff --git a/docs/website/docs/deployment-configurations/gpu-vulkan.md b/docs/website/docs/deployment-configurations/gpu-vulkan.md index 3523fb9e3109..ab7178ee73fd 100644 --- a/docs/website/docs/deployment-configurations/gpu-vulkan.md +++ b/docs/website/docs/deployment-configurations/gpu-vulkan.md @@ -84,9 +84,8 @@ platforms. -If you want to explicitly specify HAL drivers to support, you will need to add -`Vulkan` to the `IREE_HAL_DRIVERS_TO_BUILD` CMake list variable when -configuring (for target). +Ensure that the `IREE_HAL_DRIVER_VULKAN` CMake option is `ON` when configuring +for the target. ### Get compiler for SPIR-V exchange format @@ -120,9 +119,8 @@ to build IREE for Linux/Windows and the [Android cross-compilation][android-cc] page for Android. The SPIR-V compiler backend is compiled in by default on all platforms. -If you want to explicitly specify HAL drivers to support, you will need to add -`Vulkan-SPIRV` to the `IREE_TARGET_BACKENDS_TO_BUILD` CMake list variable when -configuring (for host). +Ensure that the `IREE_TARGET_BACKEND_VULKAN_SPIRV` CMake option is `ON` when +configuring for the host. ## Compile and run the model diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/BUILD index d85a65269536..045cea0a7f20 100644 --- a/iree/compiler/Dialect/HAL/Target/LLVM/BUILD +++ b/iree/compiler/Dialect/HAL/Target/LLVM/BUILD @@ -14,7 +14,7 @@ package( iree_cmake_extra_content( content = """ -if(NOT "${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT}" AND NOT "${IREE_TARGET_BACKEND_WASM-LLVM-AOT}") +if(NOT "${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT}" AND NOT "${IREE_TARGET_BACKEND_WASM_LLVM_AOT}") return() endif() """, diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt index f75ba2db794b..6455ef5a234e 100644 --- a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt @@ -8,7 +8,7 @@ # To disable autogeneration for this file entirely, delete this header. # ################################################################################ -if(NOT "${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT}" AND NOT "${IREE_TARGET_BACKEND_WASM-LLVM-AOT}") +if(NOT "${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT}" AND NOT "${IREE_TARGET_BACKEND_WASM_LLVM_AOT}") return() endif() diff --git a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/BUILD b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/BUILD index 6fd21ab87791..f0a6c812cbc1 100644 --- a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/BUILD +++ b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/BUILD @@ -14,7 +14,7 @@ package( iree_cmake_extra_content( content = """ -if(NOT "${IREE_TARGET_BACKEND_METAL-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_METAL_SPIRV}") return() endif() """, diff --git a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt index d01431a31b30..36e57f1e4cb4 100644 --- a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt @@ -8,7 +8,7 @@ # To disable autogeneration for this file entirely, delete this header. # ################################################################################ -if(NOT "${IREE_TARGET_BACKEND_METAL-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_METAL_SPIRV}") return() endif() diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD index 9b430e1731ca..813426b1088a 100644 --- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD +++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD @@ -14,7 +14,7 @@ package( iree_cmake_extra_content( content = """ -if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}") return() endif() """, diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt index 0a6eadb6bbd3..7d32a9d558f1 100644 --- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt @@ -8,7 +8,7 @@ # To disable autogeneration for this file entirely, delete this header. # ################################################################################ -if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}") return() endif() diff --git a/iree/compiler/Dialect/Vulkan/Utils/test/BUILD b/iree/compiler/Dialect/Vulkan/Utils/test/BUILD index 0118d67c2333..4328124b750e 100644 --- a/iree/compiler/Dialect/Vulkan/Utils/test/BUILD +++ b/iree/compiler/Dialect/Vulkan/Utils/test/BUILD @@ -16,7 +16,7 @@ package( iree_cmake_extra_content( content = """ -if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}") return() endif() """, diff --git a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt index 52386a414e2d..84d52d924b43 100644 --- a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt +++ b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt @@ -8,7 +8,7 @@ # To disable autogeneration for this file entirely, delete this header. # ################################################################################ -if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}") +if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}") return() endif() diff --git a/iree/runtime/instance.h b/iree/runtime/instance.h index 780e97efebc3..6bf54231e570 100644 --- a/iree/runtime/instance.h +++ b/iree/runtime/instance.h @@ -68,8 +68,8 @@ IREE_API_EXPORT void iree_runtime_instance_options_initialize( iree_runtime_instance_options_t* out_options); // Sets the instance to use all available drivers registered in the current -// binary. This allows for control over driver selection from the build system: -// if you have IREE_HAL_DRIVERS_TO_BUILD=Vulkan then you'll only get Vulkan. +// binary. This allows for control over driver selection from the build system +// using the IREE_HAL_DRIVER_* CMake options. // Sessions may query for the driver listing and select one(s) that are // appropriate. IREE_API_EXPORT void iree_runtime_instance_options_use_all_available_drivers( diff --git a/iree/samples/simple_embedding/BUILD b/iree/samples/simple_embedding/BUILD index 43d61257192a..27912081f228 100644 --- a/iree/samples/simple_embedding/BUILD +++ b/iree/samples/simple_embedding/BUILD @@ -67,7 +67,7 @@ endif() iree_cmake_extra_content( content = """ if((${IREE_HAL_DRIVER_DYLIB} OR ${IREE_HAL_DRIVER_DYLIB_SYNC}) - AND (${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT} OR DEFINED IREE_HOST_BINARY_ROOT)) + AND (${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT} OR DEFINED IREE_HOST_BINARY_ROOT)) """, inline = True, ) @@ -227,7 +227,7 @@ iree_cmake_extra_content( content = """ endif() -if(${IREE_HAL_DRIVER_VULKAN} AND (${IREE_TARGET_BACKEND_VULKAN-SPIRV} OR DEFINED IREE_HOST_BINARY_ROOT)) +if(${IREE_HAL_DRIVER_VULKAN} AND (${IREE_TARGET_BACKEND_VULKAN_SPIRV} OR DEFINED IREE_HOST_BINARY_ROOT)) """, inline = True, ) diff --git a/iree/samples/simple_embedding/CMakeLists.txt b/iree/samples/simple_embedding/CMakeLists.txt index dedb908ff0be..555052b09aba 100644 --- a/iree/samples/simple_embedding/CMakeLists.txt +++ b/iree/samples/simple_embedding/CMakeLists.txt @@ -55,7 +55,7 @@ iree_run_binary_test( endif() if((${IREE_HAL_DRIVER_DYLIB} OR ${IREE_HAL_DRIVER_DYLIB_SYNC}) - AND (${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT} OR DEFINED IREE_HOST_BINARY_ROOT)) + AND (${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT} OR DEFINED IREE_HOST_BINARY_ROOT)) iree_cc_binary( NAME @@ -217,7 +217,7 @@ endif() endif() -if(${IREE_HAL_DRIVER_VULKAN} AND (${IREE_TARGET_BACKEND_VULKAN-SPIRV} OR DEFINED IREE_HOST_BINARY_ROOT)) +if(${IREE_HAL_DRIVER_VULKAN} AND (${IREE_TARGET_BACKEND_VULKAN_SPIRV} OR DEFINED IREE_HOST_BINARY_ROOT)) iree_cc_binary( NAME diff --git a/iree/samples/static_library/CMakeLists.txt b/iree/samples/static_library/CMakeLists.txt index 1b57d24c0733..927b049856e3 100644 --- a/iree/samples/static_library/CMakeLists.txt +++ b/iree/samples/static_library/CMakeLists.txt @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -if(NOT ${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT} +if(NOT ${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT} OR NOT ${IREE_HAL_DRIVER_DYLIB} OR NOT ${IREE_BUILD_COMPILER}) return() diff --git a/iree/samples/static_library/README.md b/iree/samples/static_library/README.md index 4a8dbd047b19..f52771766dfe 100644 --- a/iree/samples/static_library/README.md +++ b/iree/samples/static_library/README.md @@ -41,8 +41,10 @@ for general instructions on building using CMake): ```shell cmake -B ../iree-build/ -DIREE_BUILD_SAMPLES=ON \ - -DIREE_TARGET_BACKENDS_TO_BUILD=DYLIB-LLVM-AOT \ - -DIREE_HAL_DRIVERS_TO_BUILD=Dylib_Sync \ + -DIREE_TARGET_BACKEND_DEFAULTS=OFF \ + -DIREE_TARGET_BACKEND_DYLIB_LLVM_AOT=ON \ + -DIREE_HAL_DRIVER_DEFAULTS=OFF \ + -DIREE_HAL_DRIVER_DYLIB_SYNC=ON \ -DIREE_BUILD_COMPILER=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo . ``` diff --git a/iree/samples/vision/CMakeLists.txt b/iree/samples/vision/CMakeLists.txt index 5762b5b53009..355da60f5770 100644 --- a/iree/samples/vision/CMakeLists.txt +++ b/iree/samples/vision/CMakeLists.txt @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -if(NOT ${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT} OR NOT ${IREE_HAL_DRIVER_DYLIB}) +if(NOT ${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT} OR NOT ${IREE_HAL_DRIVER_DYLIB}) return() endif() diff --git a/iree/samples/vulkan/CMakeLists.txt b/iree/samples/vulkan/CMakeLists.txt index fccf6ab3ad72..f02e460b850c 100644 --- a/iree/samples/vulkan/CMakeLists.txt +++ b/iree/samples/vulkan/CMakeLists.txt @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}" OR +if(NOT "${IREE_TARGET_BACKEND_VULKAN_SPIRV}" OR NOT "${IREE_HAL_DRIVER_VULKAN}") return() endif() diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt index 5c1fc8ba0eb6..4e8acbd5c19e 100644 --- a/iree/tools/CMakeLists.txt +++ b/iree/tools/CMakeLists.txt @@ -19,11 +19,11 @@ add_subdirectory(utils) # Enable compiler targets based on options. set(IREE_COMPILER_TARGETS "") set(IREE_COMPILER_TARGET_COPTS "") -if("${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT}" OR "${IREE_TARGET_BACKEND_WASM-LLVM-AOT}") +if("${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT}" OR "${IREE_TARGET_BACKEND_WASM_LLVM_AOT}") list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::LLVM) list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_LLVMAOT_TARGET") endif() -if("${IREE_TARGET_BACKEND_METAL-SPIRV}") +if("${IREE_TARGET_BACKEND_METAL_SPIRV}") list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::MetalSPIRV) list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_METALSPIRV_TARGET") endif() @@ -31,7 +31,7 @@ if("${IREE_TARGET_BACKEND_VMVX}") list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::VMVX) list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_VMVX_TARGET") endif() -if("${IREE_TARGET_BACKEND_VULKAN-SPIRV}") +if("${IREE_TARGET_BACKEND_VULKAN_SPIRV}") list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::VulkanSPIRV) list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_VULKANSPIRV_TARGET") endif()