From 6af09fa38df85ac0295b895cd35290b02d1de1f9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 25 Aug 2013 00:16:59 -0700 Subject: gras: use Theron's Utils.h for numa alloc --- Theron | 2 +- lib/alloc_on_node.hpp | 69 --------------------------------------------------- lib/sbuffer.cpp | 6 ++--- 3 files changed, 4 insertions(+), 73 deletions(-) delete mode 100644 lib/alloc_on_node.hpp diff --git a/Theron b/Theron index dc71156..9c66c4a 160000 --- a/Theron +++ b/Theron @@ -1 +1 @@ -Subproject commit dc71156e01c4afc2e32f01126bdcd971aa43c591 +Subproject commit 9c66c4afe39a6f595c8a83bcbadee3eb2cb4c343 diff --git a/lib/alloc_on_node.hpp b/lib/alloc_on_node.hpp deleted file mode 100644 index 0eba98e..0000000 --- a/lib/alloc_on_node.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. - -#ifndef INCLUDED_LIBGRAS_ALLOC_ON_NODE_HPP -#define INCLUDED_LIBGRAS_ALLOC_ON_NODE_HPP - -#include -#include - -//---------------------------------------------------------------------- -//-- 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; -} - -//---------------------------------------------------------------------- -//-- free memory allocated by AllocOnNode -- needs mem and size -//---------------------------------------------------------------------- -inline void FreeOnNode(void *mem, const size_t size) -{ -#if THERON_NUMA - -#if THERON_WINDOWS - - VirtualFree(mem, size, MEM_RELEASE); - -#elif THERON_GCC - - numa_free(mem, size); - -#endif - -#endif // THERON_NUMA -} - -#endif /*INCLUDED_LIBGRAS_ALLOC_ON_NODE_HPP*/ diff --git a/lib/sbuffer.cpp b/lib/sbuffer.cpp index 40bbc3f..bdf8a6f 100644 --- a/lib/sbuffer.cpp +++ b/lib/sbuffer.cpp @@ -1,7 +1,7 @@ // Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. #include -#include "alloc_on_node.hpp" +#include #include using namespace gras; @@ -16,7 +16,7 @@ SBufferConfig::SBufferConfig(void) static void numa_mem_deleter(SBuffer &buff) { - FreeOnNode(buff.get_actual_memory(), buff.get_actual_length()); + Theron::Detail::Utils::FreeOnNode(buff.get_actual_memory(), buff.get_actual_length()); } static void default_allocator_deleter(SBuffer &, char *m) @@ -36,7 +36,7 @@ static void default_allocator(SBufferConfig &config) } else { - config.memory = AllocOnNode(config.affinity, config.length); + config.memory = Theron::Detail::Utils::AllocOnNode(config.affinity, config.length); config.deleter = boost::bind(&numa_mem_deleter, _1); //deal with numa failue case //TODO print warning message if (config.memory == NULL) -- cgit