Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ include(HandleLLVMOptions)

set(IMEX_INCLUDE_TESTS 1 CACHE BOOL "Include targets for IMEX tests")
set(IMEX_ENABLE_SYCL_RUNTIME 0 CACHE BOOL "Enable the Sycl Runtime")
set(IMEX_ENABLE_OPENCL_RUNTIME 0 CACHE BOOL "Enable the OpenCL Runtime")
set(IMEX_ENABLE_L0_RUNTIME 0 CACHE BOOL "Enable the Level Zero Runtime")
set(IMEX_ENABLE_BENCHMARK 0 CACHE BOOL "Enable the IMEX Benchmark (Depending on SYCL Runtime)")
# Useful when building IMEX as an LLVM external project.
Expand All @@ -192,6 +193,12 @@ else ()
set(IMEX_ENABLE_SYCL_RUNTIME 0)
endif()

if (IMEX_ENABLE_OPENCL_RUNTIME)
set(IMEX_ENABLE_OPENCL_RUNTIME 1)
else ()
set(IMEX_ENABLE_OPENCL_RUNTIME 0)
endif()

if (IMEX_ENABLE_L0_RUNTIME)
set(IMEX_ENABLE_L0_RUNTIME 1)
else ()
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ cmake -G Ninja -B build -S llvm \
# For GPU support pass thes cmake variables to enable the required runtime libraries
# -DIMEX_ENABLE_L0_RUNTIME=1
# -DIMEX_ENABLE_SYCL_RUNTIME=1
# -DIMEX_ENABLE_OPENCL_RUNTIME=1
# Additional if using a non system wide Level Zero Loader built from source
# -DLEVEL_ZERO_DIR=/PATH_TO/level-zero-install

Expand Down Expand Up @@ -107,6 +108,7 @@ cmake -G Ninja -B build -S . \
# For GPU support pass thes cmake variables to enable the required runtime libraries
# -DIMEX_ENABLE_L0_RUNTIME=1
# -DIMEX_ENABLE_SYCL_RUNTIME=1
# -DIMEX_ENABLE_OPENCL_RUNTIME=1
# Additional if using a non system wide Level Zero Loader built from source
# -DLEVEL_ZERO_DIR=/PATH_TO/level-zero-install

Expand All @@ -127,6 +129,7 @@ cmake -G Ninja -B build -S . \
# For GPU support pass thes cmake variables to enable the required runtime libraries
# -DIMEX_ENABLE_L0_RUNTIME=1
# -DIMEX_ENABLE_SYCL_RUNTIME=1
# -DIMEX_ENABLE_OPENCL_RUNTIME=1
# Additional if using a non system wide Level Zero Loader built from source
# -DLEVEL_ZERO_DIR=/PATH_TO/level-zero-install

Expand Down
4 changes: 4 additions & 0 deletions lib/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if(IMEX_ENABLE_SYCL_RUNTIME)
add_subdirectory(SYCLRUNTIME)
endif()

if(IMEX_ENABLE_OPENCL_RUNTIME)
add_subdirectory(OPENCLRUNTIME)
endif()

add_mlir_library(imex_runner_utils
SHARED
ImexRunnerUtils.cpp
Expand Down
44 changes: 44 additions & 0 deletions lib/ExecutionEngine/OPENCLRUNTIME/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -Wno-return-type -Wno-cast-qual")

find_package(OpenCL REQUIRED)

if(NOT OpenCL_FOUND)
message(FATAL_ERROR "OpenCL not found.")
endif()

add_mlir_library(opencl-runtime
SHARED
OpenCLRuntimeWrappers.cpp

EXCLUDE_FROM_LIBMLIR
)

check_cxx_compiler_flag("-frtti" CXX_HAS_FRTTI_FLAG)
if(NOT CXX_HAS_FRTTI_FLAG)
message(FATAL_ERROR "CXX compiler does not accept flag -frtti")
endif()
target_compile_options (opencl-runtime PUBLIC -fexceptions -frtti)

target_include_directories(opencl-runtime PRIVATE
${MLIR_INCLUDE_DIRS}
${OpenCL_INCLUDE_DIRS}
)

message(STATUS "OpenCL Libraries: ${OpenCL_LIBRARIES}")
target_link_libraries(opencl-runtime PRIVATE ${OpenCL_LIBRARIES})

# set_property(TARGET opencl-runtime APPEND PROPERTY BUILD_RPATH "${OpenCL_LIBRARY}")
Loading