Skip to content

Commit

Permalink
Set number of OpenBLAS threads
Browse files Browse the repository at this point in the history
  • Loading branch information
johngebbie committed Jul 16, 2023
1 parent 12f29a3 commit db942f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ else
endif

ifeq ($(HAVE_OPENBLAS_CLAPACK), 1)
CFLAGS += -I$(OPENBLAS_ROOT)/include
CFLAGS += -DHAVE_OPENBLAS_CLAPACK=1 -I$(OPENBLAS_ROOT)/include
ifeq ($(USE_SHARED), 0)
LIBS += \
$(OPENBLAS_ROOT)/lib/libopenblas.a \
Expand Down
8 changes: 6 additions & 2 deletions src/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#include <fst/matcher-fst.h>
#include <fst/extensions/ngram/ngram-fst.h>


#ifdef HAVE_OPENBLAS_CLAPACK
#include <openblas.h>
#endif
#ifdef HAVE_MKL
// We need to set num threads
#include <mkl.h>
#endif

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

SetLogHandler(KaldiLogHandler);

#ifdef HAVE_OPENBLAS_CLAPACK
openblas_set_num_threads(1);
#endif
#ifdef HAVE_MKL
mkl_set_num_threads(1);
#endif
Expand Down

0 comments on commit db942f8

Please sign in to comment.