Skip to content

Commit 8b75bd9

Browse files
committed
Set number of OpenBLAS threads
1 parent 12f29a3 commit 8b75bd9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ else
6868
endif
6969

7070
ifeq ($(HAVE_OPENBLAS_CLAPACK), 1)
71-
CFLAGS += -I$(OPENBLAS_ROOT)/include
71+
CFLAGS += -DHAVE_OPENBLAS_CLAPACK=1 -I$(OPENBLAS_ROOT)/include
7272
ifeq ($(USE_SHARED), 0)
7373
LIBS += \
7474
$(OPENBLAS_ROOT)/lib/libopenblas.a \

src/model.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include <fst/matcher-fst.h>
2525
#include <fst/extensions/ngram/ngram-fst.h>
2626

27-
27+
#ifdef HAVE_OPENBLAS_CLAPACK
28+
#include <cblas.h>
29+
#endif
2830
#ifdef HAVE_MKL
29-
// We need to set num threads
3031
#include <mkl.h>
3132
#endif
3233

@@ -113,6 +114,9 @@ Model::Model(const char *model_path) : model_path_str_(model_path) {
113114

114115
SetLogHandler(KaldiLogHandler);
115116

117+
#ifdef HAVE_OPENBLAS_CLAPACK
118+
openblas_set_num_threads(1);
119+
#endif
116120
#ifdef HAVE_MKL
117121
mkl_set_num_threads(1);
118122
#endif

0 commit comments

Comments
 (0)