From ec1b82d824fe5f1c43ce4a96cea6322ecfb99baf Mon Sep 17 00:00:00 2001 From: wangxin Date: Mon, 27 Dec 2021 11:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsetThreadAffinity(-1)?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Util/util.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Util/util.cpp b/src/Util/util.cpp index 6361cce..a34ebab 100644 --- a/src/Util/util.cpp +++ b/src/Util/util.cpp @@ -503,6 +503,11 @@ bool setThreadAffinity(int i) { CPU_ZERO(&mask); if(i >= 0){ CPU_SET(i, &mask); + } else { + auto cpus = thread::hardware_concurrency(); + for (int i = 0; i < cpus; ++i) { + CPU_SET(i, &mask); + } } if (!pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask)) { return true; -- Gitee