Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ void RnExecutorchInstaller::injectJSIBindings(

threads::utils::unsafeSetupThreadPool();
threads::GlobalThreadPool::initialize();

#if defined(__ANDROID__) && defined(__aarch64__)
auto num_of_perf_cores =
::executorch::extension::cpuinfo::get_num_performant_cores();
log(LOG_LEVEL::Info, "Detected ", num_of_perf_cores, " performant cores");
// setting num_of_cores to floor(num_of_perf_cores / 2) + 1) because depending
// on cpu arch as when possible we want to leave at least 2 performant cores
// for other tasks (setting more actually results in drop of performance). For
// older devices (i.e. samsung s22) resolves to 3 cores, and for newer ones
// (like OnePlus 12) resolves to 4, which when benchamrked gives highest
// throughput.
auto num_of_cores = static_cast<uint32_t>(num_of_perf_cores / 2) + 1;
::executorch::extension::threadpool::get_threadpool()
->_unsafe_reset_threadpool(num_of_cores);
log(LOG_LEVEL::Info, "Configuring xnnpack for ", num_of_cores, " threads");
#endif
}

} // namespace rnexecutorch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <executorch/extension/threadpool/cpuinfo_utils.h>
#include <memory>
#include <mutex>
#include <opencv2/opencv.hpp>
#include <optional>
#include <rnexecutorch/Log.h>
#include <rnexecutorch/threads/HighPerformanceThreadPool.h>
Expand Down Expand Up @@ -38,6 +39,9 @@ class GlobalThreadPool {
numThreads, "threads");
instance = std::make_unique<HighPerformanceThreadPool>(numThreads.value(),
config);
// Disable OpenCV's internal threading to prevent it from overriding our
// thread pool configuration, which would cause degraded performance
cv::setNumThreads(0);
});
}

Expand Down
Loading