summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2013-08-25 00:16:59 -0700
committerJosh Blum2013-08-30 08:57:16 -0700
commit6af09fa38df85ac0295b895cd35290b02d1de1f9 (patch)
treeb6fe25dd11301a64a8e3cd28ad2d7855b56f3c22
parentb2f40f754acb427a46c4c237cd89c0ee0cdd3c3b (diff)
downloadsandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.tar.gz
sandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.tar.bz2
sandhi-6af09fa38df85ac0295b895cd35290b02d1de1f9.zip
gras: use Theron's Utils.h for numa alloc
m---------Theron0
-rw-r--r--lib/alloc_on_node.hpp69
-rw-r--r--lib/sbuffer.cpp6
3 files changed, 3 insertions, 72 deletions
diff --git a/Theron b/Theron
-Subproject dc71156e01c4afc2e32f01126bdcd971aa43c59
+Subproject 9c66c4afe39a6f595c8a83bcbadee3eb2cb4c34
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)