Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2025 Sungsik Kong <ss.kong@samsung.com>
4 : *
5 : * @file bs_threadpool_manager.hpp
6 : * @date 20 May 2025
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Sungsik Kong <ss.kong@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief BS threadpool manager class header file
11 : */
12 :
13 : #ifndef THREAD_POOL_MANAGER_HPP
14 : #define THREAD_POOL_MANAGER_HPP
15 :
16 : #pragma once
17 : #include "bs_thread_pool.h"
18 : #include "singleton.h"
19 :
20 : namespace nntrainer {
21 : /**
22 : * @brief ThreadPoolManager is a singleton class that manages a thread pool
23 : *
24 : */
25 : class ThreadPoolManager : public Singleton<ThreadPoolManager> {
26 : public:
27 : /**
28 : * @brief Select optimal number of thread to use in K-quantized GEMM and GEMV
29 : *
30 : * @param M M for GEMM (M != 1) or GEMV (M = 1)
31 : * @param N N for GEMM or GEMV
32 : * @param K K for GEMM or GEMV
33 : * @return std::size_t number of thread to use
34 : */
35 : std::size_t select_k_quant_thread_count(unsigned int M, unsigned int N,
36 : unsigned int K);
37 :
38 71 : BS::thread_pool<> &getThreadPool() { return pool_; }
39 :
40 : /**
41 : * @brief Construct a new Thread Pool Manager object
42 : *
43 : */
44 2 : ThreadPoolManager() : pool_(std::thread::hardware_concurrency()) {}
45 : /**
46 : * @brief Destroy the Thread Pool Manager object
47 : *
48 : */
49 2 : ~ThreadPoolManager() = default;
50 :
51 : private:
52 : BS::thread_pool<> pool_;
53 : };
54 : } // namespace nntrainer
55 :
56 : #endif // THREAD_POOL_MANAGER_HPP
57 :
|