/* * numamemory.cpp * * Created on: Jan 6, 2015 * Author: gregor */ #ifdef WIN32 #include #else #include #endif #include #include #include namespace gltb { #ifdef WIN32 void *numAllocLocal(unsigned long long size) { unsigned int processor = Thread::getCurrentProcessor(); unsigned int node = numaNodeOfProcessor(processor); return numaAllocOnNode(node, size); } void *numaAllocOnNode(unsigned int node, unsigned long long size) { HANDLE process = GetCurrentProcess(); return VirtualAllocExNuma(process, NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE, node); } void numaFree(void *pointer, unsigned long long size) { HANDLE process = GetCurrentProcess(); VirtualFreeEx(process, pointer, size, MEM_RELEASE); } #else void *numAllocLocal(unsigned long long size) { return numa_alloc_local(size); } void *numaAllocOnNode(unsigned int node, unsigned long long size) { return numa_alloc_onnode(size, node); } void numaFree(void *pointer, unsigned long long size) { numa_free(pointer, size); } #endif }