Skip to content

Commit

Permalink
ADD Support for CLBLAST
Browse files Browse the repository at this point in the history
Enable support for the RISCV architecture

This addresses ggerganov#129
  • Loading branch information
apcameron committed May 27, 2023
1 parent 73ad593 commit 435dd8d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ option(GGML_BUILD_EXAMPLES "ggml: build examples" ${GGML_STANDALONE})
option(GGML_PERF "ggml: enable perf timings" OFF)
option(GGML_NO_ACCELERATE "ggml: disable Accelerate framework" OFF)
option(GGML_OPENBLAS "ggml: use OpenBLAS" OFF)
option(GGML_CLBLAST "ggml: use clBLAST" OFF)
option(GGML_CUBLAS "ggml: use cuBLAS" OFF)

# sanitizers
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ For more information, checkout the corresponding programs in the [examples](exam
cmake -DGGML_CUBLAS=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.1/bin/nvcc ..
```

## Using clBLAST

```bash
cmake -DGGML_CLBLAST=ON ..
```

## Resources

- [GGML - Large Language Models for Everyone](https://github.com/rustformers/llm/blob/main/crates/ggml/README.md): a description of the GGML format provided by the maintainers of the `llm` Rust crate, which provides Rust bindings for GGML
Expand Down
23 changes: 22 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ if (GGML_OPENBLAS)
endif()
endif()

if (GGML_CLBLAST)
set(CLBLAST_INCLUDE_SEARCH_PATHS
/usr/include
/usr/local/include
$ENV{CLBLAST_HOME}
$ENV{CLBLAST_HOME}/include
)
find_path(CLBLAST_INC NAMES cblast.h PATHS ${CLBLAST_INCLUDE_SEARCH_PATHS})
find_library(CLBLAST_LIB NAMES clblast)
if (CLBLAST_LIB)
message(STATUS "clBLAST found")

set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} ${CLBLAST_LIB})
set(GGML_OPENCL_SOURCES ggml-opencl.c ggml-opencl.h)
set(GGML_EXTRA_FLAGS ${GGML_EXTRA_FLAGS} -DGGML_USE_CLBLAST)
link_libraries("-Wl,--copy-dt-needed-entries")
else()
message(WARNING "clBLAST not found")
endif()
endif()
if (GGML_CUBLAS)
cmake_minimum_required(VERSION 3.17)

Expand Down Expand Up @@ -189,7 +209,8 @@ endif()
add_library(${TARGET}
ggml.c
../include/ggml/ggml.h
${GGML_CUDA_SOURCES})
${GGML_CUDA_SOURCES}
${GGML_OPENCL_SOURCES})

target_include_directories(${TARGET} PUBLIC
.
Expand Down
2 changes: 2 additions & 0 deletions src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ typedef double ggml_float;
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <intrin.h>
#else
#if !defined(__riscv)
#include <immintrin.h>
#endif
#endif
#endif
#endif

#ifdef __F16C__

Expand Down

0 comments on commit 435dd8d

Please sign in to comment.