Skip to content

Commit ceb79ba

Browse files
committed
decouple IMEX and GPU
1 parent 1be438f commit ceb79ba

Some content is hidden

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

44 files changed

+277
-64
lines changed

CMakeLists.txt

Lines changed: 12 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 compilation for GPU (e.g., XeVM)" 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,9 +56,15 @@ 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)
66+
# IMEX is a subset of GPU
67+
set(GC_ENABLE_GPU ON)
6168
endif()
6269

6370
if(GC_ENABLE_DNNL_API)
@@ -70,6 +77,9 @@ endif()
7077
############################## Targets #########################################
7178
# All common options, includes etc. are added to this interface target.
7279
add_library(GcInterface INTERFACE)
80+
if (GC_ENABLE_GPU)
81+
target_compile_options(GcInterface INTERFACE -DGC_USE_GPU)
82+
endif()
7383
target_compile_features(GcInterface INTERFACE cxx_std_17)
7484
target_include_directories(GcInterface INTERFACE
7585
$<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 (implictly sets GC_ENABLE_GPU to ON) |
80+
| GC_ENABLE_GPU | ON, **OFF** | Whether to enable the GPU 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ std::unique_ptr<Pass> createMergeAllocPass();
115115
void populateFrontendPasses(mlir::OpPassManager &);
116116
void populateCPUPipeline(mlir::OpPassManager &);
117117

118-
#ifdef GC_USE_IMEX
118+
#ifdef GC_USE_GPU
119119
struct GPUPipelineOptions : PassPipelineOptions<GPUPipelineOptions> {
120120
Option<bool> isUsmArgs{
121121
*this, "is-usm-args",
@@ -136,6 +136,9 @@ struct GPUPipelineOptions : PassPipelineOptions<GPUPipelineOptions> {
136136
llvm::cl::init(false)};
137137
};
138138
void populateGPUPipeline(mlir::OpPassManager &, const GPUPipelineOptions &);
139+
#ifdef GC_USE_IMEX
140+
void populateIMEXPipeline(mlir::OpPassManager &, const GPUPipelineOptions &);
141+
#endif
139142
#endif
140143

141144
#define GEN_PASS_DECL

include/gc/Transforms/Passes.td

Lines changed: 3 additions & 1 deletion
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,7 @@ def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> {
9394
"DPAS register block sizes MxNxK">,
9495
];
9596
}
97+
#endif
9698

9799
def AddContextArg : Pass<"add-ctx-arg", "func::FuncOp"> {
98100
let summary = "Add a context argument.";
@@ -185,7 +187,7 @@ def GpuXeVMAttachTarget: Pass<"xevm-attach-target", ""> {
185187
];
186188
}
187189

188-
#endif // GC_USE_IMEX
190+
#endif // GC_USE_GPU
189191

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

lib/gc/CAPI/CMakeLists.txt

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

7-
if(GC_ENABLE_IMEX)
7+
if(GC_ENABLE_GPU)
88
list(APPEND GC_ALL_LIBS GcGpuPasses)
99
endif()
1010

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828
get_property(extension_libs GLOBAL PROPERTY MLIR_EXTENSION_LIBS)
2929

3030
set(GC_PASSES GcInterface GcPasses)
31-
if(GC_ENABLE_IMEX)
31+
if(GC_ENABLE_GPU)
3232
list(APPEND GC_PASSES GcGpuPasses)
3333
endif()
3434

lib/gc/Transforms/CMakeLists.txt

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

43-
if(GC_ENABLE_IMEX)
43+
if(GC_ENABLE_GPU)
4444
add_subdirectory(GPU)
4545
endif()
4646

0 commit comments

Comments
 (0)