22#include <unordered_set>
27int32_t countPhysicalCores()
31 std::unordered_set<std::string> siblings;
32 for (uint32_t cpu = 0; cpu < UINT32_MAX; ++cpu)
34 std::ifstream thread_siblings(
"/sys/devices/system/cpu/cpu" + std::to_string(cpu) +
35 "/topology/thread_siblings");
36 if (!thread_siblings.is_open())
42 if (std::getline(thread_siblings, line))
44 siblings.insert(line);
47 if (!siblings.empty())
49 return static_cast<int32_t
>(siblings.size());
53 unsigned int n_threads = std::thread::hardware_concurrency();
54 return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2) : 1;
63 : _max_num_threads(
onert::util::getConfigInt(
onert::util::config::NUM_THREADS)),
64 _ggml_context(
std::unique_ptr<ggml_context, decltype(&ggml_free)>(
65 ggml_init({.mem_size = 0, .mem_buffer =
nullptr, .no_alloc =
true}), &ggml_free))
67 if (_max_num_threads <= -1)