Rob*_*its 10 c linux memory multithreading numa
我已经设置了我的代码,以便在我的NUMA系统上本地小心地加载和处理数据.我认为.也就是说,出于调试目的,我真的希望能够使用在许多其他函数设置的特定函数内访问的指针地址来直接识别内存指向的NUMA节点.正在居住,所以我可以检查一切都在它应该位于的位置.这可能吗?
我在msdn http://social.msdn.microsoft.com/Forums/en-US/parallelcppnative/thread/37a02e17-e160-48d9-8625-871ff6b21f72上找到了同样的请求,但答案是使用QueryWorkingSetEx()似乎是Windows特定的.这可以在Linux上完成吗?确切地说,我正在使用Debian Squeeze.
谢谢.
osg*_*sgx 20
有一个move_pages功能-lnuma:http://linux.die.net/man/2/move_pages
它可以向节点映射报告当前的地址状态(页面):
节点也可以是NULL,在这种情况下,move_pages()不会移动任何页面,而是返回状态数组中每个页面当前所在的节点.可能需要获取每个页面的状态以确定需要移动的页面.
所以,电话可能是这样的:
void * ptr_to_check = your_address;
/*here you should align ptr_to_check to page boundary */
int status[1];
int ret_code;
status[0]=-1;
ret_code=move_pages(0 /*self memory */, 1, &ptr_to_check,
NULL, status, 0);
printf("Memory at %p is at %d node (retcode %d)\n", ptr_to_check, status[0], ret_code);
Run Code Online (Sandbox Code Playgroud)
小智 9
或者,get_mempolicy在http://linux.die.net/man/2/get_mempolicy中有一个函数-lnuma:
If flags specifies both MPOL_F_NODE and MPOL_F_ADDR, get_mempolicy() will
return the node ID of the node on which the address addr is allocated into
the location pointed to by mode. If no page has yet been allocated for the
specified address, get_mempolicy() will allocate a page as if the process had
performed a read [load] access to that address, and return the ID of the node
where that page was allocated.
Run Code Online (Sandbox Code Playgroud)
因此,通过以下ptr方式检查被指向的页面的numa节点:
int numa_node = -1;
get_mempolicy(&numa_node, NULL, 0, (void*)ptr, MPOL_F_NODE | MPOL_F_ADDR);
return numa_node;
Run Code Online (Sandbox Code Playgroud)