Skip to content

Commit 5540c6f

Browse files
committed
decouple IMEX and GPU
1 parent 1be438f commit 5540c6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+310
-82
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2024 Intel Corporation
2+
# Copyright (C) 2025 Intel Corporation
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -45,7 +45,8 @@ option(GC_ENABLE_TEST_DNNL_API "Build the dnnl tests" ${GC_ENABLE_DNNL_API})
4545
option(GC_ENABLE_TEST_MLIR "Build the mlir tests" ON)
4646
option(GC_ENABLE_TOOLS "Build the tools" ON)
4747
option(GC_ENABLE_OPT "Build gc-opt" ${GC_ENABLE_TOOLS})
48-
option(GC_ENABLE_IMEX "Enable Intel® Extension for MLIR" OFF)
48+
option(GC_ENABLE_IMEX "Enable Intel® Extension for MLIR (implicitly enables GPU compilation)" OFF)
49+
option(GC_ENABLE_GPU "Enable GPU runtime and tools components" OFF)
4950
option(GC_ENABLE_BINDINGS_PYTHON "Enable Graph Complier Python Binding" ON)
5051
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)
5152
option(GC_ENABLE_RUNTIME_NAIVE_BRGEMM "Use naive BRGEMM as runtime backend for debug purpose." OFF)
@@ -55,6 +56,10 @@ if(GC_ENABLE_LEGACY)
5556
add_subdirectory(legacy/core)
5657
endif()
5758

59+
if (GC_ENABLE_GPU)
60+
set(GC_ENABLE_GPU ON)
61+
endif()
62+
5863
if (GC_ENABLE_IMEX)
5964
# normalize the value for lit config
6065
set(GC_ENABLE_IMEX ON)
@@ -70,6 +75,9 @@ endif()
7075
############################## Targets #########################################
7176
# All common options, includes etc. are added to this interface target.
7277
add_library(GcInterface INTERFACE)
78+
if (GC_ENABLE_GPU)
79+
target_compile_options(GcInterface INTERFACE -DGC_USE_GPU)
80+
endif()
7381
target_compile_features(GcInterface INTERFACE cxx_std_17)
7482
target_include_directories(GcInterface INTERFACE
7583
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@ Graph Compiler supports the following build-time options.
7676
| GC_ENABLE_TEST | **ON**, OFF | Controls building the tests |
7777
| GC_DEV_LINK_LLVM_DYLIB | ON, **OFF** | Controls dynamic link LLVM/MLIR libraries, mainly for developer |
7878
| GC_ENABLE_BINDINGS_PYTHON | **ON**, OFF | Controls building the Python API |
79-
| GC_ENABLE_IMEX | ON, **OFF** | Whether to enable the GPU components |
79+
| GC_ENABLE_IMEX | ON, **OFF** | Whether to enable the IMEX components |
80+
| GC_ENABLE_GPU | ON, **OFF** | Whether to enable the GPU tools and components |
8081

include/gc/Conversion/Passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define GC_CONVERSION_PASSES_H
1111

1212
#include "gc/Conversion/XeVMToLLVM/XeVMToLLVM.h"
13+
#include "mlir/Pass/Pass.h"
1314

1415
namespace mlir {
1516

include/gc/Transforms/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
if(GC_ENABLE_DNNL_API)
22
list(APPEND TABLEGEN_MACROS -DGC_HAS_ONEDNN_DIALECT)
33
endif()
4+
if(GC_ENABLE_GPU)
5+
list(APPEND TABLEGEN_MACROS -DGC_USE_GPU)
6+
endif()
47
if(GC_ENABLE_IMEX)
5-
list(APPEND TABLEGEN_MACROS -DGC_USE_IMEX)
8+
list(APPEND TABLEGEN_MACROS -DGC_USE_IMEX -DGC_USE_GPU)
69
endif()
710

811
set(LLVM_TARGET_DEFINITIONS Passes.td)

include/gc/Transforms/Passes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ std::unique_ptr<Pass> createMergeAllocPass();
115115
void populateFrontendPasses(mlir::OpPassManager &);
116116
void populateCPUPipeline(mlir::OpPassManager &);
117117

118-
#ifdef GC_USE_IMEX
119118
struct GPUPipelineOptions : PassPipelineOptions<GPUPipelineOptions> {
120119
Option<bool> isUsmArgs{
121120
*this, "is-usm-args",
@@ -136,6 +135,8 @@ struct GPUPipelineOptions : PassPipelineOptions<GPUPipelineOptions> {
136135
llvm::cl::init(false)};
137136
};
138137
void populateGPUPipeline(mlir::OpPassManager &, const GPUPipelineOptions &);
138+
#ifdef GC_USE_IMEX
139+
void populateIMEXPipeline(mlir::OpPassManager &, const GPUPipelineOptions &);
139140
#endif
140141

141142
#define GEN_PASS_DECL

include/gc/Transforms/Passes.td

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def ConvertMemRefToCPURuntime : Pass<"convert-memref-to-cpuruntime", "func::Func
7474
"cpuruntime::CPURuntimeDialect"
7575
];
7676
}
77+
#ifdef GC_USE_GPU
7778

7879
#ifdef GC_USE_IMEX
7980
def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> {
@@ -93,6 +94,20 @@ def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> {
9394
"DPAS register block sizes MxNxK">,
9495
];
9596
}
97+
#endif
98+
99+
def GpuToGpuOcl : Pass<"gpu-to-gpuocl", "ModuleOp"> {
100+
let summary = "Convert the GPU operations to GpuOclRuntime calls.";
101+
let description = [{
102+
Convert the gpu alloc, dealloc, memcpy and launch operations to GpuOclRuntime calls.
103+
}];
104+
let options = [
105+
Option<"callFinish", "call-finish", "bool",
106+
/*default=*/"false",
107+
"Call finish() after each kernel launch.">
108+
];
109+
}
110+
#endif // GC_USE_GPU
96111

97112
def AddContextArg : Pass<"add-ctx-arg", "func::FuncOp"> {
98113
let summary = "Add a context argument.";
@@ -109,17 +124,6 @@ def AllocsToSLM : Pass<"allocs-to-slm", "func::FuncOp"> {
109124
];
110125
}
111126

112-
def GpuToGpuOcl : Pass<"gpu-to-gpuocl", "ModuleOp"> {
113-
let summary = "Convert the GPU operations to GpuOclRuntime calls.";
114-
let description = [{
115-
Convert the gpu alloc, dealloc, memcpy and launch operations to GpuOclRuntime calls.
116-
}];
117-
let options = [
118-
Option<"callFinish", "call-finish", "bool",
119-
/*default=*/"false",
120-
"Call finish() after each kernel launch.">
121-
];
122-
}
123127

124128
def GpuTilingAndFusion : Pass<"gpu-tiling", "func::FuncOp"> {
125129
let summary = "GPU tiling and fusion path.";
@@ -185,7 +189,6 @@ def GpuXeVMAttachTarget: Pass<"xevm-attach-target", ""> {
185189
];
186190
}
187191

188-
#endif // GC_USE_IMEX
189192

190193
def IterativeTilingAndFusion : Pass<"iterative-tiling-and-fusion",
191194
"func::FuncOp"> {

lib/gc/CAPI/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ set(GC_ALL_LIBS
44
GcAnalysis
55
MLIRCPURuntimeTransforms)
66

7-
if(GC_ENABLE_IMEX)
8-
list(APPEND GC_ALL_LIBS GcGpuPasses)
9-
endif()
7+
list(APPEND GC_ALL_LIBS GcGpuPasses)
108

119
add_mlir_public_c_api_library(GcCAPI
1210
Dialects.cpp
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_subdirectory(CPURuntime)
22
add_subdirectory(Driver)
3-
if(GC_ENABLE_IMEX)
3+
if(GC_ENABLE_GPU)
44
add_subdirectory(GPURuntime)
55
add_subdirectory(OpenCLRuntime)
66
endif()

lib/gc/ExecutionEngine/Driver/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ else()
2727
endif()
2828
get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)
2929

30-
set(GC_PASSES GcInterface GcPasses)
31-
if(GC_ENABLE_IMEX)
32-
list(APPEND GC_PASSES GcGpuPasses)
33-
endif()
30+
set(GC_PASSES GcInterface GcPasses GcGpuPasses)
3431

3532
gc_add_mlir_library(GcJitWrapper
3633
Driver.cpp

lib/gc/Transforms/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ gc_add_mlir_library(GcPasses
4040
MLIRMicrokernelTransforms
4141
)
4242

43-
if(GC_ENABLE_IMEX)
44-
add_subdirectory(GPU)
45-
endif()
43+
add_subdirectory(GPU)
4644

4745
add_subdirectory(Microkernel)

0 commit comments

Comments
 (0)