Skip to content

Add OpenCL runtime #191

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

Merged
merged 6 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ cmake --build . --target gc-check
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.
* If GPU components are on (`-DGC_USE_GPU=ON`), make sure the Level-zero runtime is installed in your system. Either install Level-zero runtime via system package managers (e.g. `apt`), or follow the instructions of [IMEX](https://github.com/intel/mlir-extensions).

More notes if GPU components are on (`-DGC_USE_GPU=ON`):
* make sure the OpenCL runtime is installed in your system. You can either
install using OS-provided package (Ubuntu 22.04)
```sh
sudo apt install -y intel-opencl-icd opencl-c-headers
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the dev package needed btw?

Copy link
Author

Choose a reason for hiding this comment

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

I was following this link https://dgpu-docs.intel.com/installation-guides/ubuntu/ubuntu-jammy-arc.html

Seems like intel-opencl-icd is for the libraries and opencl-c-headers for the headers?

```
Or, download and install package from: https://github.com/intel/compute-runtime/releases
* the LLVM codebase needs to be patched to support XeGPU lowering (from IMEX). Please follow instructions of [IMEX](https://github.com/intel/mlir-extensions) on patching LLVM.

Graph Compiler supports the following build-time options.

Expand Down
4 changes: 2 additions & 2 deletions cmake/imex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ get_property(IMEX_INCLUDES GLOBAL PROPERTY IMEX_INCLUDES)
if (NOT DEFINED IMEX_INCLUDES)
include(functions)
set(IMEX_CHECK_LLVM_VERSION ON)
set(IMEX_ENABLE_L0_RUNTIME 1)
set(IMEX_ENABLE_L0_RUNTIME 0)
# TODO: Change to main https://github.com/oneapi-src/oneDNN.git when all the
# required functionality is merged.
gc_fetch_content(imex 496b240093b5e132b60c5ee69878300fe69be300 https://github.com/Menooker/mlir-extensions
CMAKE_ARGS "-DMLIR_DIR=${MLIR_DIR};-DIMEX_CHECK_LLVM_VERSION=ON;-DIMEX_ENABLE_L0_RUNTIME=1"
CMAKE_ARGS "-DMLIR_DIR=${MLIR_DIR};-DIMEX_CHECK_LLVM_VERSION=ON;-DIMEX_ENABLE_L0_RUNTIME=0"
)

set(IMEX_INCLUDES
Expand Down
5 changes: 4 additions & 1 deletion lib/gc/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
add_subdirectory(CPURuntime)
add_subdirectory(Driver)
add_subdirectory(Driver)
if(GC_USE_GPU)
add_subdirectory(OpenCLRuntime)
endif()
26 changes: 26 additions & 0 deletions lib/gc/ExecutionEngine/OpenCLRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
find_package(OpenCL REQUIRED)

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

Choose a reason for hiding this comment

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

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

This is redundant when the REQUIRED option is used.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Removed now.


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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
target_compile_options (opencl-runtime PUBLIC -fexceptions -frtti)
target_compile_options (GcOpenclRuntime 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})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
target_link_libraries(opencl-runtime PRIVATE ${OpenCL_LIBRARIES})
target_link_libraries(GcOpenclRuntime PUBLIC ${OpenCL_LIBRARIES})

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, changed. Also use PUBLIC as suggested.

Loading
Loading