diff --git a/CMakeLists.txt b/CMakeLists.txt index 636b33ad2..5488d716c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") option(GC_LEGACY_ENABLE ON) option(GC_TEST_ENABLE "Build the tests" ON) -option(GC_USE_GPU "Enable GPU backend" OFF) +option(GC_USE_IMEX "Enable GPU backend with IMEX support" OFF) option(GC_ENABLE_BINDINGS_PYTHON "Enable Graph Complier Python Binding" ON) option(GC_DEV_LINK_LLVM_DYLIB "Link dynamic libraries of LLVM and MLIR. For developers only. Do not use it in packing the library." OFF) @@ -53,10 +53,10 @@ include(AddLLVM) include(AddMLIR) include(HandleLLVMOptions) -if(GC_USE_GPU) +if(GC_USE_IMEX) include(imex) if(GC_DEV_LINK_LLVM_DYLIB) - message(WARN "GPU backend may not be compatible with dynamic linking to LLVM") + message(WARN "GPU IMEX backend may not be compatible with dynamic linking to LLVM") endif() endif() diff --git a/README.md b/README.md index 958878fae..df8287bf2 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Notes: * `/PATH/TO/llvm-project/llvm-install` should be the install path of LLVM. If you installed LLVM elsewhere by `-DCMAKE_INSTALL_PREFIX` option when building LLVM, you need to change the path in `-DMLIR_DIR` accordingly. * The cmake option `-DLLVM_EXTERNAL_LIT` is for the tests of this project. It requires the `lit` tool to be installed in the system. You can install it via `pip install lit`. If you don't need to run the tests of this repo, you can omit this option in the command line. -More notes if GPU components are on (`-DGC_USE_GPU=ON`): +More notes if GPU IMEX components are on (`-DGC_USE_IMEX=ON`): * make sure the OpenCL runtime is installed in your system. You can either install using OS-provided package (Ubuntu 22.04) ```sh @@ -76,5 +76,5 @@ Graph Compiler supports the following build-time options. | GC_TEST_ENABLE | **ON**, OFF | Controls building the tests | | GC_DEV_LINK_LLVM_DYLIB | ON, **OFF** | Controls dynamic link LLVM/MLIR libraries, mainly for developer | | GC_ENABLE_BINDINGS_PYTHON | **ON**, OFF | Controls building the Python API | -| GC_USE_GPU | ON, **OFF** | Whether to enable the GPU components | +| GC_USE_IMEX | ON, **OFF** | Whether to enable the GPU IMEX components | diff --git a/include/gc/Transforms/Passes.td b/include/gc/Transforms/Passes.td index 79a62f028..ce840edb9 100644 --- a/include/gc/Transforms/Passes.td +++ b/include/gc/Transforms/Passes.td @@ -32,7 +32,7 @@ def ConvertOneDNNGraphToLinalg : Pass<"convert-onednn-graph-to-linalg"> { ]; } -#ifdef GC_USE_GPU +#ifdef GC_USE_IMEX def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> { let summary = "Convert linalg dialect to XeGPU dialect."; let description = [{ @@ -57,6 +57,6 @@ def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> { "DPAS register block sizes MxNxK">, ]; } -#endif +#endif // GC_USE_IMEX #endif // GC_DIALECT_GC_PASSES diff --git a/lib/gc/CAPI/CMakeLists.txt b/lib/gc/CAPI/CMakeLists.txt index f7738c064..ab488de10 100644 --- a/lib/gc/CAPI/CMakeLists.txt +++ b/lib/gc/CAPI/CMakeLists.txt @@ -4,9 +4,8 @@ set(GC_ALL_LIBS GCPasses MLIRCPURuntimeTransforms) -if(GC_USE_GPU) - list(APPEND GC_ALL_LIBS GCGPUPasses) -endif() +get_property(gc_passes_libs GLOBAL PROPERTY GC_PASS_LIBS) +list(APPEND GC_ALL_LIBS ${gc_passes_libs}) add_mlir_public_c_api_library(GcCAPI Dialects.cpp diff --git a/lib/gc/ExecutionEngine/CMakeLists.txt b/lib/gc/ExecutionEngine/CMakeLists.txt index d5279b044..af2c787d0 100644 --- a/lib/gc/ExecutionEngine/CMakeLists.txt +++ b/lib/gc/ExecutionEngine/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(CPURuntime) add_subdirectory(Driver) -if(GC_USE_GPU) +if(GC_USE_IMEX) add_subdirectory(OpenCLRuntime) endif() \ No newline at end of file diff --git a/lib/gc/ExecutionEngine/Driver/CMakeLists.txt b/lib/gc/ExecutionEngine/Driver/CMakeLists.txt index 8742ef6e9..3f3cd366f 100644 --- a/lib/gc/ExecutionEngine/Driver/CMakeLists.txt +++ b/lib/gc/ExecutionEngine/Driver/CMakeLists.txt @@ -26,10 +26,7 @@ else() ) endif() -set(GC_PASSES GCPasses) -if(GC_USE_GPU) - list(APPEND GC_PASSES GCGPUPasses) -endif() +get_property(gc_passes_libs GLOBAL PROPERTY GC_PASS_LIBS) add_mlir_library(GCJitWrapper Driver.cpp @@ -41,6 +38,6 @@ add_mlir_library(GCJitWrapper ${MLIR_LINK_COMPONENTS} ${dialect_libs} ${conversion_libs} - ${GC_PASSES} + ${gc_passes_libs} ) diff --git a/lib/gc/Transforms/CMakeLists.txt b/lib/gc/Transforms/CMakeLists.txt index f60c8cec2..1b4f2cb73 100644 --- a/lib/gc/Transforms/CMakeLists.txt +++ b/lib/gc/Transforms/CMakeLists.txt @@ -28,6 +28,4 @@ add_mlir_library(GCPasses ) set_property(GLOBAL APPEND PROPERTY GC_PASS_LIBS GCPasses) -if(GC_USE_GPU) - add_subdirectory(GPU) -endif() +add_subdirectory(GPU) diff --git a/lib/gc/Transforms/GPU/CMakeLists.txt b/lib/gc/Transforms/GPU/CMakeLists.txt index d730db5a3..c861d7b4e 100644 --- a/lib/gc/Transforms/GPU/CMakeLists.txt +++ b/lib/gc/Transforms/GPU/CMakeLists.txt @@ -1,4 +1,9 @@ -add_mlir_library(GCGPUPasses +# todo: populate with default sources +# add_mlir_library(GCGPUPasses) + +# todo: relax this to not require imex +if(GC_ENABLE_IMEX) +add_mlir_library(GCGPUIMEXPasses LinalgToXeGPU.cpp ADDITIONAL_HEADER_DIRS @@ -20,4 +25,5 @@ add_mlir_library(GCGPUPasses GCUtilsIR ) -set_property(GLOBAL APPEND PROPERTY GC_PASS_LIBS GCGPUPasses) +set_property(GLOBAL APPEND PROPERTY GC_PASS_LIBS GCGPUIMEXPasses) +endif() diff --git a/src/gc-opt/CMakeLists.txt b/src/gc-opt/CMakeLists.txt index f127653de..64540fd02 100644 --- a/src/gc-opt/CMakeLists.txt +++ b/src/gc-opt/CMakeLists.txt @@ -29,19 +29,20 @@ else() get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) endif() +get_property(gc_passes_libs GLOBAL PROPERTY GC_PASS_LIBS) + set(gc_opt_libs ${dialect_libs} ${conversion_libs} ${MLIR_LINK_COMPONENTS} - GCPasses) + ${gc_passes_libs}) -if(GC_USE_GPU) - add_definitions(-DGC_USE_GPU=1) +if(GC_USE_IMEX) + add_definitions(-DGC_USE_IMEX=1) get_property(IMEX_INCLUDES GLOBAL PROPERTY IMEX_INCLUDES) include_directories(${IMEX_INCLUDES}) list(APPEND gc_opt_libs IMEXGPUXDialect IMEXXeTileDialect IMEXRegionDialect IMEXRegionTransforms - IMEXTransforms IMEXGPUToGPUX IMEXGPUToSPIRV IMEXGPUXToLLVM IMEXXeGPUToVC IMEXXeTileToXeGPU IMEXUtil - GCGPUPasses) + IMEXTransforms IMEXGPUToGPUX IMEXGPUToSPIRV IMEXGPUXToLLVM IMEXXeGPUToVC IMEXXeTileToXeGPU IMEXUtil) endif() if(GC_MLIR_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_MLIR_CXX_FLAGS}") diff --git a/src/gc-opt/gc-opt.cpp b/src/gc-opt/gc-opt.cpp index 5aa0bfc1d..499fef3f0 100644 --- a/src/gc-opt/gc-opt.cpp +++ b/src/gc-opt/gc-opt.cpp @@ -26,7 +26,7 @@ #include "mlir/InitAllPasses.h" #include "mlir/Tools/mlir-opt/MlirOptMain.h" -#ifdef GC_USE_GPU +#ifdef GC_USE_IMEX #include #include #endif @@ -36,7 +36,7 @@ void registerCPUPipeline(); } // namespace mlir::gc int main(int argc, char *argv[]) { -#ifdef GC_USE_GPU +#ifdef GC_USE_IMEX imex::registerTransformsPasses(); // Conversion passes imex::registerConvertGPUToGPUX(); @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) { registry.insert(); registry.insert(); mlir::registerAllDialects(registry); -#ifdef GC_USE_GPU +#ifdef GC_USE_IMEX registry.insert<::imex::xetile::XeTileDialect, ::imex::gpux::GPUXDialect>(); #endif mlir::cpuruntime::registerConvertCPURuntimeToLLVMInterface(registry); diff --git a/test/mlir/test/CMakeLists.txt b/test/mlir/test/CMakeLists.txt index 7ac5a89c6..d5b79fd72 100644 --- a/test/mlir/test/CMakeLists.txt +++ b/test/mlir/test/CMakeLists.txt @@ -23,7 +23,7 @@ set(GC_OPT_TEST_DEPENDS GCUnitTests ) -if(GC_USE_GPU) +if(GC_USE_IMEX) include(imex) list(APPEND GC_OPT_TEST_DEPENDS mlir_opencl_runtime) endif() diff --git a/test/mlir/test/gc/Transforms/GPU/lit.local.cfg b/test/mlir/test/gc/Transforms/GPU/lit.local.cfg index f086e9be8..f180dd41b 100644 --- a/test/mlir/test/gc/Transforms/GPU/lit.local.cfg +++ b/test/mlir/test/gc/Transforms/GPU/lit.local.cfg @@ -1,2 +1,2 @@ -if not config.gc_use_gpu: +if not config.gc_use_imex: config.unsupported = True \ No newline at end of file diff --git a/test/mlir/test/gc/gpu-runner/lit.local.cfg b/test/mlir/test/gc/gpu-runner/lit.local.cfg index f086e9be8..f180dd41b 100644 --- a/test/mlir/test/gc/gpu-runner/lit.local.cfg +++ b/test/mlir/test/gc/gpu-runner/lit.local.cfg @@ -1,2 +1,2 @@ -if not config.gc_use_gpu: +if not config.gc_use_imex: config.unsupported = True \ No newline at end of file diff --git a/test/mlir/test/lit.cfg.py b/test/mlir/test/lit.cfg.py index d53e105e1..b618568e7 100644 --- a/test/mlir/test/lit.cfg.py +++ b/test/mlir/test/lit.cfg.py @@ -33,7 +33,7 @@ config.substitutions.append(('%mlir_runner_utils', config.mlir_runner_utils)) config.substitutions.append(('%mlir_c_runner_utils', config.mlir_c_runner_utils)) -if config.gc_use_gpu: +if config.gc_use_imex: config.substitutions.append(('%opencl_runtime', config.opencl_runtime)) llvm_config.with_system_environment(["HOME", "INCLUDE", "LIB", "TMP", "TEMP"]) diff --git a/test/mlir/test/lit.site.cfg.py.in b/test/mlir/test/lit.site.cfg.py.in index 6bea6d13e..215329191 100644 --- a/test/mlir/test/lit.site.cfg.py.in +++ b/test/mlir/test/lit.site.cfg.py.in @@ -34,7 +34,7 @@ config.gc_src_root = "@CMAKE_SOURCE_DIR@" config.gc_obj_root = "@CMAKE_BINARY_DIR@" config.gc_lib_dir = os.path.join(config.gc_obj_root, "lib") config.mlir_obj_dir = "@MLIR_BINARY_DIR@" -config.gc_use_gpu = "@GC_USE_GPU@" in ["ON", "1"] +config.gc_use_imex = "@GC_USE_IMEX@" in ["ON", "1"] config.enable_bindings_python = @GC_ENABLE_BINDINGS_PYTHON@ config.llvm_shlib_dir = "@SHLIBDIR@" config.llvm_shlib_ext = "@SHLIBEXT@"