Spaces:
Running
Running
Vulcan
commited on
build : CLBlast support as in llama.cpp (#862)
Browse files* 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 +17 -0
- Makefile +9 -0
CMakeLists.txt
CHANGED
|
@@ -64,6 +64,7 @@ if (APPLE)
|
|
| 64 |
else()
|
| 65 |
option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF)
|
| 66 |
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
|
|
|
|
| 67 |
endif()
|
| 68 |
|
| 69 |
option(WHISPER_PERF "whisper: enable perf timings" OFF)
|
|
@@ -167,6 +168,21 @@ if (WHISPER_CUBLAS)
|
|
| 167 |
endif()
|
| 168 |
endif()
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
# compiler flags
|
| 171 |
|
| 172 |
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
@@ -274,6 +290,7 @@ add_library(${TARGET}
|
|
| 274 |
ggml.h
|
| 275 |
ggml.c
|
| 276 |
${GGML_CUDA_SOURCES}
|
|
|
|
| 277 |
whisper.h
|
| 278 |
whisper.cpp
|
| 279 |
)
|
|
|
|
| 64 |
else()
|
| 65 |
option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF)
|
| 66 |
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
|
| 67 |
+
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
|
| 68 |
endif()
|
| 69 |
|
| 70 |
option(WHISPER_PERF "whisper: enable perf timings" OFF)
|
|
|
|
| 168 |
endif()
|
| 169 |
endif()
|
| 170 |
|
| 171 |
+
if (WHISPER_CLBLAST)
|
| 172 |
+
find_package(CLBlast)
|
| 173 |
+
if (CLBlast_FOUND)
|
| 174 |
+
message(STATUS "CLBlast found")
|
| 175 |
+
|
| 176 |
+
set(GGML_OPENCL_SOURCES ggml-opencl.c ggml-opencl.h)
|
| 177 |
+
|
| 178 |
+
add_compile_definitions(GGML_USE_CLBLAST)
|
| 179 |
+
|
| 180 |
+
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} clblast)
|
| 181 |
+
else()
|
| 182 |
+
message(WARNING "CLBlast not found")
|
| 183 |
+
endif()
|
| 184 |
+
endif()
|
| 185 |
+
|
| 186 |
# compiler flags
|
| 187 |
|
| 188 |
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
| 290 |
ggml.h
|
| 291 |
ggml.c
|
| 292 |
${GGML_CUDA_SOURCES}
|
| 293 |
+
${GGML_OPENCL_SOURCES}
|
| 294 |
whisper.h
|
| 295 |
whisper.cpp
|
| 296 |
)
|
Makefile
CHANGED
|
@@ -171,6 +171,15 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
|
|
| 171 |
$(NVCC) $(NVCCFLAGS) $(CXXFLAGS) -Wno-pedantic -c $< -o $@
|
| 172 |
endif
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
ifdef WHISPER_GPROF
|
| 175 |
CFLAGS += -pg
|
| 176 |
CXXFLAGS += -pg
|
|
|
|
| 171 |
$(NVCC) $(NVCCFLAGS) $(CXXFLAGS) -Wno-pedantic -c $< -o $@
|
| 172 |
endif
|
| 173 |
|
| 174 |
+
ifdef WHISPER_CLBLAST
|
| 175 |
+
CFLAGS += -DGGML_USE_CLBLAST
|
| 176 |
+
LDFLAGS += -lclblast -lOpenCL
|
| 177 |
+
WHISPER_OBJ += ggml-opencl.o
|
| 178 |
+
|
| 179 |
+
ggml-opencl.o: ggml-opencl.c ggml-opencl.h
|
| 180 |
+
$(CC) $(CFLAGS) -c $< -o $@
|
| 181 |
+
endif
|
| 182 |
+
|
| 183 |
ifdef WHISPER_GPROF
|
| 184 |
CFLAGS += -pg
|
| 185 |
CXXFLAGS += -pg
|