示例#1
0
//----------------------------------------------------------------------
//-- a little cross platform numa allocator
//-- use the existing theron defines for convenience
//----------------------------------------------------------------------
inline void *AllocOnNode(const long node, const size_t size)
{

#if THERON_NUMA

#if THERON_WINDOWS

    #if _WIN32_WINNT >= 0x0600
    return VirtualAllocExNuma(
        GetCurrentProcess(),
        NULL,
        size,
        MEM_RESERVE | MEM_COMMIT,
        PAGE_READWRITE,
        node
    );
    #else
    return NULL;
    #endif

#elif THERON_GCC

    if ((numa_available() < 0))
    {
        return NULL;
    }

    return numa_alloc_onnode(size, node);

#endif

#endif // THERON_NUMA

    return NULL;
}
示例#2
0
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    // Allocates the specified amount of bytes from virtual memory.
    // Tries to allocate the memory from the specified NUMA node.
    static void* AllocateNuma(size_t size, unsigned int prefferedNode) {
        Statistics::BlockAllocated();

#if defined(PLATFORM_WINDOWS)
        if(VirtualAllocExNumaFct != nullptr) {
            // Under Vista+, allocate using the special NUMA method.
            return VirtualAllocExNuma(GetCurrentProcess(), nullptr, size,
                                      MEM_COMMIT, PAGE_READWRITE, prefferedNode);
        }
        else {
            return VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
        }
#else
        static_assert(false, "Not yet implemented.");
#endif
    }