NUMA获取当前节点/核心 [英] NUMA Get Current Node/Core
本文介绍了NUMA获取当前节点/核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Linux上使用libnuma.我的线程应该知道它们正在运行的节点/核心.是否有可能以某种方式获取当前线程的节点/核心?我已经看过文档,但是没有找到这样的功能...
I'm using libnuma on Linux. My threads should be aware of the node/core they're running on. Is it possible to get the current threads's node/core somehow? I've been through the documentation, but I didn't find such a function...
推荐答案
我找到了这个解决方案:
I found this solution:
#include <stdio.h>
#include <utmpx.h>
int main(void) {
printf("CPU: %d\n", sched_getcpu());
return 0;
}
然后,如果需要cpu的节点,则可以使用numa.h:
Then, if you need the node of the cpu, you can use numa.h:
int cpu = sched_getcpu();
int node = numa_node_of_cpu(cpu);
这篇关于NUMA获取当前节点/核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文