]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
build : CLBlast support as in llama.cpp (#862)
authorVulcan <redacted>
Tue, 2 May 2023 19:50:32 +0000 (01:20 +0530)
committerGitHub <redacted>
Tue, 2 May 2023 19:50:32 +0000 (22:50 +0300)
* ggml : CLBlast support as in llama.cpp

Building with CLBlast speeds up whisper.cpp ~2x on low end / older AMD APUs (CPU with integrated GPU) such as the A9.

Usage:
WHISPER_CLBLAST=1 make

* CMake/Makefile : CLBlast support as in llama.cpp

Building with CLBlast speeds up whisper.cpp ~2x on low end / older AMD APUs (CPU with integrated GPU) such as the A9.

Usage:
```
Makefile:
cd whisper.cpp
WHISPER_CLBLAST=1 make

CMake:
cd whisper.cpp ; mkdir build ; cd build
cmake -DWHISPER_CLBLAST=ON  ..
make
```

CMakeLists.txt
Makefile

index c4c7aa88b459c897286bbd15335d49c04ec6ddf2..f17bb24b8d49c7abf0047595f74f4044f4cb4da1 100644 (file)
@@ -64,6 +64,7 @@ if (APPLE)
 else()
     option(WHISPER_OPENBLAS              "whisper: support for OpenBLAS" OFF)
     option(WHISPER_CUBLAS                "whisper: support for cuBLAS" OFF)
+    option(WHISPER_CLBLAST               "whisper: use CLBlast" OFF)
 endif()
 
 option(WHISPER_PERF "whisper: enable perf timings" OFF)
@@ -167,6 +168,21 @@ if (WHISPER_CUBLAS)
     endif()
 endif()
 
+if (WHISPER_CLBLAST)
+    find_package(CLBlast)
+    if (CLBlast_FOUND)
+        message(STATUS "CLBlast found")
+
+        set(GGML_OPENCL_SOURCES ggml-opencl.c ggml-opencl.h)
+
+        add_compile_definitions(GGML_USE_CLBLAST)
+
+        set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} clblast)
+    else()
+        message(WARNING "CLBlast not found")
+    endif()
+endif()
+
 # compiler flags
 
 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -274,6 +290,7 @@ add_library(${TARGET}
     ggml.h
     ggml.c
     ${GGML_CUDA_SOURCES}
+    ${GGML_OPENCL_SOURCES}
     whisper.h
     whisper.cpp
     )
index 87ce8c415e88c23e8d5e69a01917a2ac6c7a7506..078713620df6ba01d8d5f472e50a5783bb38ee51 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,15 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
        $(NVCC) $(NVCCFLAGS) $(CXXFLAGS) -Wno-pedantic -c $< -o $@
 endif
 
+ifdef WHISPER_CLBLAST
+       CFLAGS          += -DGGML_USE_CLBLAST
+       LDFLAGS         += -lclblast -lOpenCL
+       WHISPER_OBJ     += ggml-opencl.o
+       
+ggml-opencl.o: ggml-opencl.c ggml-opencl.h
+       $(CC) $(CFLAGS) -c $< -o $@
+endif
+
 ifdef WHISPER_GPROF
        CFLAGS   += -pg
        CXXFLAGS += -pg