[Mlir-commits] [mlir] 9c21ddb - [MLIR] Make MLIR cmake variable names consistent

Uday Bondhugula llvmlistbot at llvm.org
Sun May 23 20:14:41 PDT 2021


Author: Uday Bondhugula
Date: 2021-05-24T08:43:10+05:30
New Revision: 9c21ddb70ab56eb3ca5b0f99faa18bb3af17b3df

URL: https://github.com/llvm/llvm-project/commit/9c21ddb70ab56eb3ca5b0f99faa18bb3af17b3df
DIFF: https://github.com/llvm/llvm-project/commit/9c21ddb70ab56eb3ca5b0f99faa18bb3af17b3df.diff

LOG: [MLIR] Make MLIR cmake variable names consistent

Fix inconsistent MLIR CMake variable names. Consistently name them as
MLIR_ENABLE_<feature>.

Eg: MLIR_CUDA_RUNNER_ENABLED -> MLIR_ENABLE_CUDA_RUNNER

MLIR follows (or has mostly followed) the convention of naming
cmake enabling variables in the from MLIR_ENABLE_... etc. Using a
convention here is easy and also important for convenience. A counter
pattern was started with variables named MLIR_..._ENABLED. This led to a
sequence of related counter patterns: MLIR_CUDA_RUNNER_ENABLED,
MLIR_ROCM_RUNNER_ENABLED, etc.. From a naming standpoint, the imperative
form is more meaningful. Additional discussion at:
https://llvm.discourse.group/t/mlir-cmake-enable-variable-naming-convention/3520

Switch all inconsistent ones to the ENABLE form. Keep the couple of old
mappings needed until buildbot config is migrated.

Differential Revision: https://reviews.llvm.org/D102976

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/cmake/modules/AddMLIRPython.cmake
    mlir/docs/Bindings/Python.md
    mlir/docs/SPIRVToLLVMDialectConversion.md
    mlir/docs/Tools/LinalgOpDsl.md
    mlir/lib/Bindings/CMakeLists.txt
    mlir/lib/Conversion/GPUCommon/CMakeLists.txt
    mlir/lib/Dialect/GPU/CMakeLists.txt
    mlir/lib/ExecutionEngine/CMakeLists.txt
    mlir/test/CMakeLists.txt
    mlir/test/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 5b5339b47e1ee..93b6d00b45bba 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -56,26 +56,33 @@ add_custom_target(mlir-doc)
 # Build the CUDA conversions and run according tests if the NVPTX backend
 # is available
 if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
-  set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
+  set(MLIR_ENABLE_CUDA_CONVERSIONS 1)
 else()
-  set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
+  set(MLIR_ENABLE_CUDA_CONVERSIONS 0)
 endif()
 # TODO: we should use a config.h file like LLVM does
-add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED})
+add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_ENABLE_CUDA_CONVERSIONS})
 
 # Build the ROCm conversions and run according tests if the AMDGPU backend
 # is available
 if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
-  set(MLIR_ROCM_CONVERSIONS_ENABLED 1)
+  set(MLIR_ENABLE_ROCM_CONVERSIONS 1)
 else()
-  set(MLIR_ROCM_CONVERSIONS_ENABLED 0)
+  set(MLIR_ENABLE_ROCM_CONVERSIONS 0)
 endif()
-add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ROCM_CONVERSIONS_ENABLED})
+add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
-set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
-set(MLIR_ROCM_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir ROCm runner")
-set(MLIR_SPIRV_CPU_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir SPIR-V cpu runner")
-set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
+# Until the buildbot configuration is updated, preserve old names.
+if (${MLIR_CUDA_RUNNER_ENABLED})
+  set(MLIR_ENABLE_CUDA_RUNNER_DEFAULT ${MLIR_CUDA_RUNNER_ENABLED})
+else()
+  set(MLIR_ENABLE_CUDA_RUNNER_DEFAULT 0)
+endif()
+
+set(MLIR_ENABLE_CUDA_RUNNER ${MLIR_ENABLE_CUDA_RUNNER_DEFAULT} CACHE BOOL "Enable building the mlir CUDA runner")
+set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm runner")
+set(MLIR_ENABLE_SPIRV_CPU_RUNNER 0 CACHE BOOL "Enable building the mlir SPIR-V cpu runner")
+set(MLIR_ENABLE_VULKAN_RUNNER 0 CACHE BOOL "Enable building the mlir Vulkan runner")
 
 option(MLIR_INCLUDE_TESTS
        "Generate build targets for the MLIR unit tests."
@@ -96,15 +103,22 @@ option(MLIR_INCLUDE_INTEGRATION_TESTS
 # This linking mode is somewhat more consistent across platforms and surfaces
 # undefined symbols at link time (vs runtime). It is suitable for development
 # workflows but can be disabled for more flexible deployment by
-# setting -DMLIR_PYTHON_BINDINGS_VERSION_LOCKED=OFF
+# setting -DMLIR_BINDINGS_PYTHON_LOCK_VERSION=OFF
 #-------------------------------------------------------------------------------
 
-set(MLIR_BINDINGS_PYTHON_ENABLED 0 CACHE BOOL
+# Until the buildbot configuration is updated, support old name.
+if (${MLIR_BINDINGS_PYTHON_ENABLED})
+  set(MLIR_ENABLE_BINDINGS_PYTHON_DEFAULT ${MLIR_BINDINGS_PYTHON_ENABLED})
+else()
+  set(MLIR_ENABLE_BINDINGS_PYTHON_DEFAULT 0)
+endif()
+
+set(MLIR_ENABLE_BINDINGS_PYTHON ${MLIR_ENABLE_BINDINGS_PYTHON_DEFAULT} CACHE BOOL
        "Enables building of Python bindings.")
-set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
+set(MLIR_BINDINGS_PYTHON_LOCK_VERSION 1 CACHE BOOL
        "Links to specific python libraries, resolving all symbols.")
 
-if(MLIR_BINDINGS_PYTHON_ENABLED)
+if(MLIR_ENABLE_BINDINGS_PYTHON)
   include(MLIRDetectPythonEnv)
   find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
     COMPONENTS Interpreter Development NumPy REQUIRED)
@@ -146,7 +160,7 @@ endif()
 # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
 add_subdirectory(tools)
 
-if(MLIR_BINDINGS_PYTHON_ENABLED)
+if(MLIR_ENABLE_BINDINGS_PYTHON)
   # Python sources: built extensions come in via lib/Bindings/Python
   add_subdirectory(python)
 endif()

diff  --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index a0ac69d668792..06d2a9a278bd5 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -24,7 +24,7 @@ function(add_mlir_python_extension libname extname)
   # symbols, which is better for development. Note that not all python
   # configurations provide build-time libraries to link against, in which
   # case, we fall back to MODULE linking.
-  if(Python3_LIBRARIES STREQUAL "" OR NOT MLIR_PYTHON_BINDINGS_VERSION_LOCKED)
+  if(Python3_LIBRARIES STREQUAL "" OR NOT MLIR_BINDINGS_PYTHON_LOCK_VERSION)
     set(PYEXT_LINK_MODE MODULE)
     set(PYEXT_LIBADD)
   else()

diff  --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md
index 48c70724b4b20..d00c7ab616ccc 100644
--- a/mlir/docs/Bindings/Python.md
+++ b/mlir/docs/Bindings/Python.md
@@ -12,7 +12,7 @@ Current status: Under development and not enabled by default
 
 ### CMake variables
 
-* **`MLIR_BINDINGS_PYTHON_ENABLED`**`:BOOL`
+* **`MLIR_ENABLE_BINDINGS_PYTHON`**`:BOOL`
 
   Enables building the Python bindings. Defaults to `OFF`.
 
@@ -23,7 +23,7 @@ Current status: Under development and not enabled by default
   multiple Python implementations, setting this explicitly to the preferred
   `python3` executable is strongly recommended.
 
-* **`MLIR_PYTHON_BINDINGS_VERSION_LOCKED`**`:BOOL`
+* **`MLIR_BINDINGS_PYTHON_LOCK_VERSION`**`:BOOL`
 
   Links the native extension against the Python runtime library, which is
   optional on some platforms. While setting this to `OFF` can yield some greater

diff  --git a/mlir/docs/SPIRVToLLVMDialectConversion.md b/mlir/docs/SPIRVToLLVMDialectConversion.md
index 3ab17b5d430e4..718234330d01c 100644
--- a/mlir/docs/SPIRVToLLVMDialectConversion.md
+++ b/mlir/docs/SPIRVToLLVMDialectConversion.md
@@ -820,7 +820,7 @@ supported.
 
 To build the runner, add the following option to `cmake`:
 ```bash
--DMLIR_SPIRV_CPU_RUNNER_ENABLED=1
+-DMLIR_ENABLE_SPIRV_CPU_RUNNER=1
 ```
 
 ### Pipeline

diff  --git a/mlir/docs/Tools/LinalgOpDsl.md b/mlir/docs/Tools/LinalgOpDsl.md
index 4ef6fb1f74497..d944fc83829d5 100644
--- a/mlir/docs/Tools/LinalgOpDsl.md
+++ b/mlir/docs/Tools/LinalgOpDsl.md
@@ -12,7 +12,7 @@ emit corresponding `linalg.generic` IR for the composition.
 
 The tool is bundled with the MLIR Python bindings. To use from the CMake build
 tree, MLIR must be build with Python bindings enabled
-(`-DMLIR_BINDINGS_PYTHON_ENABLED=ON`). Then add the `python` directory in the
+(`-DMLIR_ENALBE_BINDINGS_PYTHON=ON`). Then add the `python` directory in the
 build tree to your `PYTHONPATH` environment variable (i.e.
 `export PYTHONPATH=$PWD/build/python`). Optionally, use an installed MLIR
 package, if available, to avoid building.

diff  --git a/mlir/lib/Bindings/CMakeLists.txt b/mlir/lib/Bindings/CMakeLists.txt
index b41f480b6dcf0..41227a414a10e 100644
--- a/mlir/lib/Bindings/CMakeLists.txt
+++ b/mlir/lib/Bindings/CMakeLists.txt
@@ -1,3 +1,3 @@
-if(MLIR_BINDINGS_PYTHON_ENABLED)
+if(MLIR_ENABLE_BINDINGS_PYTHON)
   add_subdirectory(Python)
 endif()

diff  --git a/mlir/lib/Conversion/GPUCommon/CMakeLists.txt b/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
index 65ad9de0b20ca..4cc3bcec5a0c5 100644
--- a/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
@@ -1,4 +1,4 @@
-if (MLIR_CUDA_CONVERSIONS_ENABLED)
+if (MLIR_ENABLE_CUDA_CONVERSIONS)
   set(NVPTX_LIBS
     NVPTXCodeGen
     NVPTXDesc
@@ -6,7 +6,7 @@ if (MLIR_CUDA_CONVERSIONS_ENABLED)
   )
 endif()
 
-if (MLIR_ROCM_CONVERSIONS_ENABLED)
+if (MLIR_ENABLE_ROCM_CONVERSIONS)
   set(AMDGPU_LIBS
     AMDGPUCodeGen
     AMDGPUDesc

diff  --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt
index a633d6c843848..75be2165c344a 100644
--- a/mlir/lib/Dialect/GPU/CMakeLists.txt
+++ b/mlir/lib/Dialect/GPU/CMakeLists.txt
@@ -1,4 +1,4 @@
-if (MLIR_CUDA_CONVERSIONS_ENABLED)
+if (MLIR_ENABLE_CUDA_CONVERSIONS)
   set(NVPTX_LIBS
     NVPTXCodeGen
     NVPTXDesc
@@ -6,7 +6,7 @@ if (MLIR_CUDA_CONVERSIONS_ENABLED)
   )
 endif()
 
-if (MLIR_ROCM_CONVERSIONS_ENABLED)
+if (MLIR_ENABLE_ROCM_CONVERSIONS)
   set(AMDGPU_LIBS
     MCParser
     AMDGPUAsmParser
@@ -59,8 +59,8 @@ add_mlir_dialect_library(MLIRGPU
   MLIRTransformUtils
   )
 
-if(MLIR_CUDA_RUNNER_ENABLED)
-  if(NOT MLIR_CUDA_CONVERSIONS_ENABLED)
+if(MLIR_ENABLE_CUDA_RUNNER)
+  if(NOT MLIR_ENABLE_CUDA_CONVERSIONS)
     message(SEND_ERROR
       "Building mlir with cuda support requires the NVPTX backend")
   endif()
@@ -98,7 +98,7 @@ if(MLIR_CUDA_RUNNER_ENABLED)
 
 endif()
 
-if(MLIR_ROCM_RUNNER_ENABLED)
+if(MLIR_ENABLE_ROCM_RUNNER)
   if (NOT ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD))
     message(SEND_ERROR
       "Building mlir with ROCm support requires the AMDGPU backend")

diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index 978bf1adedd52..97e354cdba299 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -106,7 +106,7 @@ add_mlir_library(mlir_async_runtime
 set_property(TARGET mlir_async_runtime PROPERTY CXX_VISIBILITY_PRESET hidden)
 target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)
 
-if(MLIR_CUDA_RUNNER_ENABLED)
+if(MLIR_ENABLE_CUDA_RUNNER)
   # Configure CUDA support. Using check_language first allows us to give a
   # custom error message.
   include(CheckLanguage)
@@ -138,7 +138,7 @@ if(MLIR_CUDA_RUNNER_ENABLED)
   )
 endif()
 
-if(MLIR_ROCM_RUNNER_ENABLED)
+if(MLIR_ENABLE_ROCM_RUNNER)
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
     if (NOT DEFINED ENV{ROCM_PATH})

diff  --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index 07db8fd6d09e8..fabcf7a960cf2 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -2,19 +2,19 @@ add_subdirectory(CAPI)
 add_subdirectory(SDBM)
 add_subdirectory(lib)
 
-if(MLIR_BINDINGS_PYTHON_ENABLED)
+if(MLIR_ENABLE_BINDINGS_PYTHON)
   add_subdirectory(python)
 endif()
 
 llvm_canonicalize_cmake_booleans(
-  MLIR_BINDINGS_PYTHON_ENABLED
+  MLIR_ENABLE_BINDINGS_PYTHON
   LLVM_BUILD_EXAMPLES
-  MLIR_CUDA_CONVERSIONS_ENABLED
-  MLIR_CUDA_RUNNER_ENABLED
-  MLIR_ROCM_CONVERSIONS_ENABLED
-  MLIR_ROCM_RUNNER_ENABLED
-  MLIR_SPIRV_CPU_RUNNER_ENABLED
-  MLIR_VULKAN_RUNNER_ENABLED
+  MLIR_ENABLE_CUDA_CONVERSIONS
+  MLIR_ENABLE_CUDA_RUNNER
+  MLIR_ENABLE_ROCM_CONVERSIONS
+  MLIR_ENABLE_ROCM_RUNNER
+  MLIR_ENABLE_SPIRV_CPU_RUNNER
+  MLIR_ENABLE_VULKAN_RUNNER
   )
 
 # Passed to lit.site.cfg.py.in to set up the path where to find the libraries
@@ -76,11 +76,11 @@ set(MLIR_TEST_DEPENDS
   mlir_async_runtime
   )
 
-if(MLIR_CUDA_RUNNER_ENABLED)
+if(MLIR_ENABLE_CUDA_RUNNER)
   list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
 endif()
 
-if(MLIR_ROCM_RUNNER_ENABLED)
+if(MLIR_ENABLE_ROCM_RUNNER)
   list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
 endif()
 
@@ -98,7 +98,7 @@ if(LLVM_BUILD_EXAMPLES)
     )
 endif()
 
-if(MLIR_SPIRV_CPU_RUNNER_ENABLED)
+if(MLIR_ENABLE_SPIRV_CPU_RUNNER)
   add_subdirectory(mlir-spirv-cpu-runner)
   list(APPEND MLIR_TEST_DEPENDS
     mlir-spirv-cpu-runner
@@ -106,13 +106,13 @@ if(MLIR_SPIRV_CPU_RUNNER_ENABLED)
   )
 endif()
 
-if(MLIR_VULKAN_RUNNER_ENABLED)
+if(MLIR_ENABLE_VULKAN_RUNNER)
   list(APPEND MLIR_TEST_DEPENDS
     mlir-vulkan-runner
   )
 endif()
 
-if(MLIR_BINDINGS_PYTHON_ENABLED)
+if(MLIR_ENABLE_BINDINGS_PYTHON)
   list(APPEND MLIR_TEST_DEPENDS
     MLIRBindingsPythonExtension
     MLIRBindingsPythonSources

diff  --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in
index 1cee32b189f86..dbf5eec57ef67 100644
--- a/mlir/test/lit.site.cfg.py.in
+++ b/mlir/test/lit.site.cfg.py.in
@@ -36,15 +36,15 @@ config.mlir_runner_utils_dir = "@MLIR_RUNNER_UTILS_DIR@"
 config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
 config.linalg_test_lib_dir = "@MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR@"
 config.build_examples = @LLVM_BUILD_EXAMPLES@
-config.run_cuda_tests = @MLIR_CUDA_CONVERSIONS_ENABLED@
-config.enable_cuda_runner = @MLIR_CUDA_RUNNER_ENABLED@
-config.run_rocm_tests = @MLIR_ROCM_CONVERSIONS_ENABLED@
-config.enable_rocm_runner = @MLIR_ROCM_RUNNER_ENABLED@
+config.run_cuda_tests = @MLIR_ENABLE_CUDA_CONVERSIONS@
+config.enable_cuda_runner = @MLIR_ENABLE_CUDA_RUNNER@
+config.run_rocm_tests = @MLIR_ENABLE_ROCM_CONVERSIONS@
+config.enable_rocm_runner = @MLIR_ENABLE_ROCM_RUNNER@
 config.spirv_wrapper_library_dir = "@MLIR_SPIRV_WRAPPER_LIBRARY_DIR@"
-config.enable_spirv_cpu_runner = @MLIR_SPIRV_CPU_RUNNER_ENABLED@
+config.enable_spirv_cpu_runner = @MLIR_ENABLE_SPIRV_CPU_RUNNER@
 config.vulkan_wrapper_library_dir = "@MLIR_VULKAN_WRAPPER_LIBRARY_DIR@"
-config.enable_vulkan_runner = @MLIR_VULKAN_RUNNER_ENABLED@
-config.enable_bindings_python = @MLIR_BINDINGS_PYTHON_ENABLED@
+config.enable_vulkan_runner = @MLIR_ENABLE_VULKAN_RUNNER@
+config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@
 config.mlir_integration_test_dir = "@MLIR_INTEGRATION_TEST_DIR@"
 config.intel_sde_executable = "@INTEL_SDE_EXECUTABLE@"
 config.mlir_run_amx_tests = "@MLIR_RUN_AMX_TESTS@"


        


More information about the Mlir-commits mailing list