-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from occ-ai/roy.add_clblast_build
Add support for CLBlast library and clbast::clblast target
- Loading branch information
Showing
5 changed files
with
134 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ jobs: | |
matrix: | ||
config: | ||
- "Release" | ||
cublas: [cpu, 12.2.0, 11.8.0] | ||
cublas: [cpu, 12.2.0, 11.8.0, clblast] | ||
|
||
steps: | ||
- name: "Get version" | ||
|
@@ -110,14 +110,14 @@ jobs: | |
uses: "actions/checkout@v4" | ||
|
||
- name: Install CUDA Toolkit | ||
if: ${{ matrix.cublas != 'cpu' }} | ||
if: ${{ matrix.cublas != 'cpu' && matrix.cublas != 'clblast' }} | ||
id: cuda-toolkit | ||
uses: Jimver/[email protected] | ||
with: | ||
cuda: '${{ matrix.cublas }}' | ||
|
||
- name: Set CUDA_TOOLKIT_ROOT_DIR if CUDA is installed | ||
if: ${{ matrix.cublas != 'cpu' }} | ||
if: ${{ matrix.cublas != 'cpu' && matrix.cublas != 'clblast' }} | ||
run: | | ||
"CUDA_TOOLKIT_ROOT_DIR=$env:CUDA_PATH" >> $env:GITHUB_ENV | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Assume the library is called libCLBlast.a and the headers are in 'include' | ||
find_path(CLBlast_INCLUDE_DIR NAMES clblast.h | ||
PATHS ${clblast_SOURCE_DIR}/include) | ||
|
||
find_library(CLBlast_LIBRARY NAMES clblast | ||
PATHS ${clblast_SOURCE_DIR}/lib) | ||
|
||
# find opencl sdk includes | ||
find_path(OPENCL_INCLUDE_DIR NAMES CL/opencl.h | ||
PATHS ${opencl_sdk_SOURCE_DIR}/include) | ||
|
||
# find opencl sdk libraries | ||
find_library(OPENCL_LIBRARY NAMES OpenCL | ||
PATHS ${opencl_sdk_SOURCE_DIR}/lib) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(CLBlast DEFAULT_MSG | ||
CLBlast_LIBRARY CLBlast_INCLUDE_DIR) | ||
|
||
if(CLBlast_FOUND AND NOT TARGET clbast) | ||
add_library(clbast::clblast STATIC IMPORTED) | ||
set_target_properties(clbast::clblast PROPERTIES | ||
IMPORTED_LOCATION "${CLBlast_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${CLBlast_INCLUDE_DIR}") | ||
# add opencl library | ||
add_library(opencl STATIC IMPORTED) | ||
set_target_properties(opencl PROPERTIES | ||
IMPORTED_LOCATION "${OPENCL_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${OPENCL_INCLUDE_DIR}") | ||
|
||
# add clblast as an interface for clbast::clblast and opencl both | ||
add_library(clblast INTERFACE) | ||
target_link_libraries(clblast INTERFACE clbast::clblast opencl) | ||
|
||
# find the library dir and store in CLBlast_LIBRARY_DIR | ||
get_filename_component(CLBlast_LIBRARY_DIR ${CLBlast_LIBRARY} DIRECTORY) | ||
get_filename_component(OpenCL_LIBRARY_DIR ${OPENCL_LIBRARY} DIRECTORY) | ||
|
||
# Add to include directories | ||
include_directories(${CLBlast_INCLUDE_DIR} ${OPENCL_INCLUDE_DIR}) | ||
# add the link directories | ||
link_directories(${CLBlast_LIBRARY_DIR} ${OpenCL_LIBRARY_DIR}) | ||
endif() |