Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename GC_ENABLE_GPU to GC_ENABLE_IMEX & clean up properties usage #205

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |

4 changes: 2 additions & 2 deletions include/gc/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{
Expand All @@ -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
5 changes: 2 additions & 3 deletions lib/gc/CAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/gc/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_subdirectory(CPURuntime)
add_subdirectory(Driver)
if(GC_USE_GPU)
if(GC_USE_IMEX)
add_subdirectory(OpenCLRuntime)
endif()
7 changes: 2 additions & 5 deletions lib/gc/ExecutionEngine/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,6 +38,6 @@ add_mlir_library(GCJitWrapper
${MLIR_LINK_COMPONENTS}
${dialect_libs}
${conversion_libs}
${GC_PASSES}
${gc_passes_libs}
)

4 changes: 1 addition & 3 deletions lib/gc/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions lib/gc/Transforms/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
11 changes: 6 additions & 5 deletions src/gc-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
6 changes: 3 additions & 3 deletions src/gc-opt/gc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "mlir/InitAllPasses.h"
#include "mlir/Tools/mlir-opt/MlirOptMain.h"

#ifdef GC_USE_GPU
#ifdef GC_USE_IMEX
#include <imex/InitIMEXDialects.h>
#include <imex/InitIMEXPasses.h>
#endif
Expand All @@ -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();
Expand All @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
registry.insert<mlir::linalgx::LinalgxDialect>();
registry.insert<mlir::microkernel::MicrokernelDialect>();
mlir::registerAllDialects(registry);
#ifdef GC_USE_GPU
#ifdef GC_USE_IMEX
registry.insert<::imex::xetile::XeTileDialect, ::imex::gpux::GPUXDialect>();
#endif
mlir::cpuruntime::registerConvertCPURuntimeToLLVMInterface(registry);
Expand Down
2 changes: 1 addition & 1 deletion test/mlir/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/mlir/test/gc/Transforms/GPU/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
if not config.gc_use_gpu:
if not config.gc_use_imex:
config.unsupported = True
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This subdirectory was originally designed for general GPU tests. Shall we rename this directory to IMEX? Or maybe we can add a new subdirectory in test/gc/transforms/GPU/IMEX ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so it should either be less strict and allow some of the tests to run. Another option is to split the tests into different folders. Let's decide once we have them.

2 changes: 1 addition & 1 deletion test/mlir/test/gc/gpu-runner/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
if not config.gc_use_gpu:
if not config.gc_use_imex:
config.unsupported = True
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above... Do we need to distinguish general GPU tests from IMEX tests?

2 changes: 1 addition & 1 deletion test/mlir/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion test/mlir/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@"
Expand Down
Loading