Skip to content

Commit a9d0c2f

Browse files
committed
Force g_num_threads = 0 in WASM
1 parent caba2d5 commit a9d0c2f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/makefiles/linux_openblas.mk

+2
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ ifneq ($(ARCH), WASM)
5353
CXXFLAGS += -pthread
5454
LDLIBS += -lpthread
5555
LDFLAGS += -rdynamic
56+
else
57+
CXXFLAGS += -DKALDI_WASM
5658
endif

src/util/kaldi-thread.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
#include "util/kaldi-thread.h"
2323

2424
namespace kaldi {
25-
int32 g_num_threads = 8; // Initialize this global variable.
2625

26+
int32 g_num_threads =
27+
#ifdef KALDI_WASM
28+
0 // Everything will run on the main thread for WASM
29+
#else
30+
8 // Initialize this global variable.
31+
#endif
32+
;
2733
MultiThreadable::~MultiThreadable() {
2834
// default implementation does nothing
2935
}

0 commit comments

Comments
 (0)