// emscripten_num_logical_cores corresponds to navigator.hardwareConcurrency.
// Many x86-64 processors have 2 threads per core, so we are dividing by 2.
#ifdef __EMSCRIPTEN_PTHREADS__
int num_cores = emscripten_num_logical_cores() / 2;
#else
int num_cores = 1;
#endif
int min_num_threads = 1;
int max_num_threads = 4;
int thread_pool_size = // thread_pool_size is WASM_THREAD_POOL_SIZE
std::min(std::max(num_cores, min_num_threads), max_num_threads);
Does this possible due to #ifdef __EMSCRIPTEN_PTHREADS__?
(On Intel i7-9700) By navigator.hardwareConcurrency: https://github.com/tensorflow/tfjs/pull/4994, the WASM_THREAD_POOL_SIZE is 4. WASM_THREAD_POOL_SIZE is got by:
By native pthread: https://github.com/tensorflow/tfjs/pull/4942, the WASM_THREAD_POOL_SIZE is 1. WASM_THREAD_POOL_SIZE is got by:
Does this possible due to #ifdef __EMSCRIPTEN_PTHREADS__?
BTW, code has rebased, and https://github.com/tensorflow/tfjs/pull/4957 is included.
Reproduce steps: