Skip to content

Commit ee4801e

Browse files
authored
ggml-blas: set mkl threads from thread context (ggml-org#20602)
* ggml blas: set mkl threads from thread context * add code to run blas locally
1 parent d2ecd2d commit ee4801e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ci/run.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
# # with KLEIDIAI support
2626
# GG_BUILD_KLEIDIAI=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
2727
#
28-
# # with OPENVINO support
28+
# # with BLAS support
29+
# GG_BUILD_BLAS=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
30+
#
31+
# with BLAS support (custom vendor)
32+
# GG_BUILD_BLAS=1 GG_BUILD_BLAS_VENDOR=Intel10_64lp bash ./ci/run.sh ./tmp/results ./tmp/mnt
33+
#
34+
# with OPENVINO support
2935
# GG_BUILD_OPENVINO=1 GG_BUILD_LOW_PERF=1 GGML_OPENVINO_DEVICE=CPU bash ./ci/run.sh ./tmp/results ./tmp/mnt
3036
#
3137

@@ -169,6 +175,10 @@ if [ -n "${GG_BUILD_KLEIDIAI}" ]; then
169175
-DBUILD_SHARED_LIBS=OFF"
170176
fi
171177

178+
if [ ! -z ${GG_BUILD_BLAS} ]; then
179+
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=${GG_BUILD_BLAS_VENDOR:-OpenBLAS}"
180+
fi
181+
172182
if [ ! -z ${GG_BUILD_OPENVINO} ]; then
173183
if [ -z ${OpenVINO_DIR} ]; then
174184
echo "OpenVINO_DIR not found, please install OpenVINO via archives and enable it by:"

ggml/src/ggml-blas/ggml-blas.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ static void ggml_backend_blas_mul_mat(ggml_backend_blas_context * ctx, struct gg
121121
bli_thread_set_num_threads(ctx->n_threads);
122122
#elif defined(GGML_BLAS_USE_NVPL)
123123
nvpl_blas_set_num_threads(ctx->n_threads);
124+
#elif defined(GGML_BLAS_USE_MKL)
125+
mkl_set_num_threads(ctx->n_threads);
124126
#endif
125127

126128
for (int64_t i13 = 0; i13 < ne13; i13++) {

0 commit comments

Comments
 (0)