Skip to content

Commit 0b42d32

Browse files
committed
[SYCL][Fusion] Interface with kernel fusion JIT
Signed-off-by: Lukas Sommer <[email protected]>
1 parent abdc0fe commit 0b42d32

File tree

12 files changed

+1283
-3
lines changed

12 files changed

+1283
-3
lines changed

buildbot/configure.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def do_configure(args):
2323
libclc_amd_target_names = ';amdgcn--;amdgcn--amdhsa'
2424
libclc_nvidia_target_names = ';nvptx64--;nvptx64--nvidiacl'
2525

26+
sycl_enable_fusion = "OFF"
27+
if not args.disable_fusion:
28+
llvm_external_projects += ";sycl-fusion"
29+
sycl_enable_fusion = "ON"
30+
2631
if args.llvm_external_projects:
2732
llvm_external_projects += ";" + args.llvm_external_projects.replace(",", ";")
2833

@@ -32,6 +37,7 @@ def do_configure(args):
3237
xpti_dir = os.path.join(abs_src_dir, "xpti")
3338
xptifw_dir = os.path.join(abs_src_dir, "xptifw")
3439
libdevice_dir = os.path.join(abs_src_dir, "libdevice")
40+
fusion_dir = os.path.join(abs_src_dir, "sycl-fusion")
3541
llvm_targets_to_build = args.host_target
3642
llvm_enable_projects = 'clang;' + llvm_external_projects
3743
libclc_targets_to_build = ''
@@ -144,6 +150,7 @@ def do_configure(args):
144150
"-DXPTI_SOURCE_DIR={}".format(xpti_dir),
145151
"-DLLVM_EXTERNAL_XPTIFW_SOURCE_DIR={}".format(xptifw_dir),
146152
"-DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR={}".format(libdevice_dir),
153+
"-DLLVM_EXTERNAL_SYCL_FUSION_SOURCE_DIR={}".format(fusion_dir),
147154
"-DLLVM_ENABLE_PROJECTS={}".format(llvm_enable_projects),
148155
"-DLIBCLC_TARGETS_TO_BUILD={}".format(libclc_targets_to_build),
149156
"-DLIBCLC_GENERATE_REMANGLED_VARIANTS={}".format(libclc_gen_remangled_variants),
@@ -159,7 +166,8 @@ def do_configure(args):
159166
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
160167
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror),
161168
"-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags),
162-
"-DSYCL_ENABLE_PLUGINS={}".format(';'.join(set(sycl_enabled_plugins)))
169+
"-DSYCL_ENABLE_PLUGINS={}".format(';'.join(set(sycl_enabled_plugins))),
170+
"-DSYCL_ENABLE_KERNEL_FUSION={}".format(sycl_enable_fusion)
163171
]
164172

165173
if args.l0_headers and args.l0_loader:
@@ -238,6 +246,7 @@ def main():
238246
parser.add_argument("--llvm-external-projects", help="Add external projects to build. Add as comma seperated list.")
239247
parser.add_argument("--ci-defaults", action="store_true", help="Enable default CI parameters")
240248
parser.add_argument("--enable-plugin", action='append', help="Enable SYCL plugin")
249+
parser.add_argument("--disable-fusion", action="store_true", help="Disable the kernel fusion JIT compiler")
241250
args = parser.parse_args()
242251

243252
print("args:{}".format(args))

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ install(DIRECTORY ${OpenCL_INCLUDE_DIR}/CL
145145
COMPONENT OpenCL-Headers)
146146

147147
# Option to enable online kernel fusion via a JIT compiler
148-
option(SYCL_ENABLE_KERNEL_FUSION "Enable kernel fusion via JIT compiler" OFF)
148+
option(SYCL_ENABLE_KERNEL_FUSION "Enable kernel fusion via JIT compiler" ON)
149149

150150
# Needed for feature_test.hpp
151151
if ("cuda" IN_LIST SYCL_ENABLE_PLUGINS)

sycl/cmake/modules/AddSYCLUnitTest.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ macro(add_sycl_unittest test_dirname link_variant)
5656
OpenCL-Headers
5757
${SYCL_LINK_LIBS}
5858
)
59+
60+
if(SYCL_ENABLE_KERNEL_FUSION)
61+
target_link_libraries(${test_dirname} PRIVATE sycl-fusion)
62+
endif(SYCL_ENABLE_KERNEL_FUSION)
63+
5964
target_include_directories(${test_dirname}
6065
PRIVATE SYSTEM
6166
${sycl_inc_dir}

sycl/doc/GetStartedGuide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and a wide range of compute accelerators such as GPU and FPGA.
1212
- [Build DPC++ toolchain with support for HIP AMD](#build-dpc-toolchain-with-support-for-hip-amd)
1313
- [Build DPC++ toolchain with support for HIP NVIDIA](#build-dpc-toolchain-with-support-for-hip-nvidia)
1414
- [Build DPC++ toolchain with support for ESIMD CPU Emulation](#build-dpc-toolchain-with-support-for-esimd-emulator)
15+
- [Build DPC++ toolchain with support for runtime kernel fusion](#build-dpc-toolchain-with-support-for-runtime-kernel-fusion)
1516
- [Build Doxygen documentation](#build-doxygen-documentation)
1617
- [Deployment](#deployment)
1718
- [Use DPC++ toolchain](#use-dpc-toolchain)
@@ -298,6 +299,14 @@ Enabling this flag requires following packages installed.
298299
Currently, this feature was tested and verified on Ubuntu 20.04
299300
environment.
300301

302+
### Build DPC++ toolchain with support for runtime kernel fusion
303+
304+
Support for the experimental SYCL extension for user-driven kernel fusion
305+
at runtime is enabled by default.
306+
307+
To disable support for this feature, follow the instructions for the
308+
Linux DPC++ toolchain, but add the `--disable-fusion` flag.
309+
301310
### Build Doxygen documentation
302311

303312
Building Doxygen documentation is similar to building the product itself. First,

sycl/include/sycl/detail/cg.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class CG {
9898

9999
CGTYPE getType() { return MType; }
100100

101+
std::vector<std::vector<char>> &getArgsStorage() { return MArgsStorage; }
102+
103+
std::vector<detail::AccessorImplPtr> &getAccStorage() { return MAccStorage; }
104+
101105
virtual ~CG() = default;
102106

103107
private:

sycl/source/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
8787
PRIVATE OpenCL-Headers
8888
)
8989

90+
if(SYCL_ENABLE_KERNEL_FUSION)
91+
target_link_libraries(${LIB_NAME} PRIVATE sycl-fusion)
92+
target_link_libraries(${LIB_OBJ_NAME} PRIVATE sycl-fusion)
93+
set_property(GLOBAL APPEND PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONENTS
94+
sycl-fusion)
95+
endif(SYCL_ENABLE_KERNEL_FUSION)
96+
9097
find_package(Threads REQUIRED)
9198

9299
target_link_libraries(${LIB_NAME}
@@ -139,6 +146,8 @@ set(SYCL_SOURCES
139146
"detail/handler_proxy.cpp"
140147
"detail/image_accessor_util.cpp"
141148
"detail/image_impl.cpp"
149+
"detail/jit_compiler.cpp"
150+
"detail/jit_device_binaries.cpp"
142151
"detail/kernel_impl.cpp"
143152
"detail/kernel_program_cache.cpp"
144153
"detail/memory_manager.cpp"

0 commit comments

Comments
 (0)