提交 1b0dd8ee 编写于 作者: S starlord

MS-312 Set openmp thread number by config


Former-commit-id: 7ddafa3aa22d0455b343d07cc37b1a30d1ac29a1
上级 e9bb2e77
......@@ -44,4 +44,4 @@ engine_config:
nlist: 16384
use_blas_threshold: 20
metric_type: L2 # compare vectors by euclidean distance(L2) or inner product(IP), optional: L2 or IP
omp_thread_occupancy: 0.75 # how many compute threads be used, this is a percent value compare to system cpu core number(for instance: cpu core is 4, then 0.75 means use 3 compute threads)
omp_thread_num: 0 # how many compute threads be used by engine, 0 means use all cpu core to compute
......@@ -62,13 +62,11 @@ DBWrapper::DBWrapper() {
// engine config
ConfigNode& engine_config = ServerConfig::GetInstance().GetConfig(CONFIG_ENGINE);
float omp_thread_rate = engine_config.GetFloatValue(CONFIG_OMP_THREAD_RATE, 0.75);
uint32_t cpu_count = 1;
CommonUtil::GetSystemAvailableThreads(cpu_count);
float thread_count = omp_thread_rate*(float)cpu_count;
int32_t omp_thread = (int32_t)round(thread_count);
omp_set_num_threads(omp_thread);
SERVER_LOG_DEBUG << "Openmp thread number = " << omp_thread;
int32_t omp_thread = engine_config.GetInt32Value(CONFIG_OMP_THREAD_NUM, 0);
if(omp_thread > 0) {
omp_set_num_threads(omp_thread);
SERVER_LOG_DEBUG << "Specify openmp thread number: " << omp_thread;
}
//set archive config
engine::ArchiveConf::CriteriaT criterial;
......
......@@ -53,7 +53,7 @@ static const std::string CONFIG_NPROBE = "nprobe";
static const std::string CONFIG_NLIST = "nlist";
static const std::string CONFIG_DCBT = "use_blas_threshold";
static const std::string CONFIG_METRICTYPE = "metric_type";
static const std::string CONFIG_OMP_THREAD_RATE = "omp_thread_occupancy";
static const std::string CONFIG_OMP_THREAD_NUM = "omp_thread_num";
class ServerConfig {
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册