diff options
author | Josh Blum | 2013-08-25 00:16:59 -0700 |
---|---|---|
committer | Josh Blum | 2013-08-30 08:57:16 -0700 |
commit | 6af09fa38df85ac0295b895cd35290b02d1de1f9 (patch) | |
tree | b6fe25dd11301a64a8e3cd28ad2d7855b56f3c22 /lib | |
parent | b2f40f754acb427a46c4c237cd89c0ee0cdd3c3b (diff) | |
download | sandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.tar.gz sandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.tar.bz2 sandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.zip |
gras: use Theron's Utils.h for numa alloc
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alloc_on_node.hpp | 69 | ||||
-rw-r--r-- | lib/sbuffer.cpp | 6 |
2 files changed, 3 insertions, 72 deletions
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 <Theron/Assert.h> -#include <Theron/Detail/Threading/Utils.h> - -//---------------------------------------------------------------------- -//-- 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 <gras/sbuffer.hpp> -#include "alloc_on_node.hpp" +#include <Theron/Detail/Threading/Utils.h> #include <boost/bind.hpp> 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) |