third_party_benchmark/cmake/pthread_affinity.cpp
CrazyRong f9e826db52 升级benchmark版本到版本火车要求的1.8.3版本
Signed-off-by: CrazyRong <zzr189911@163.com>
2024-04-20 16:24:00 +08:00

17 lines
389 B
C++

#include <pthread.h>
int main() {
cpu_set_t set;
CPU_ZERO(&set);
for (int i = 0; i < CPU_SETSIZE; ++i) {
CPU_SET(i, &set);
CPU_CLR(i, &set);
}
pthread_t self = pthread_self();
int ret;
ret = pthread_getaffinity_np(self, sizeof(set), &set);
if (ret != 0) return ret;
ret = pthread_setaffinity_np(self, sizeof(set), &set);
if (ret != 0) return ret;
return 0;
}