summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/cpu/hwlocMemory.hpp
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-29 20:32:31 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-30 23:46:08 +0200
commitcc429b68fadc502b981fd0acd64a5ff6e2ae1d15 (patch)
tree3fb23fc4db15dbdd08af4c7ea20134b9d82e58fd /xmrstak/backend/cpu/hwlocMemory.hpp
parente5b0319d5a9f58762fa934ad700113908940cb31 (diff)
downloadxmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.zip
xmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.tar.gz
group files
- move source code to `src` - categorize files and move to group folder - change upper case class files to lower case - change C++ header to `*.hpp`
Diffstat (limited to 'xmrstak/backend/cpu/hwlocMemory.hpp')
-rw-r--r--xmrstak/backend/cpu/hwlocMemory.hpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/xmrstak/backend/cpu/hwlocMemory.hpp b/xmrstak/backend/cpu/hwlocMemory.hpp
new file mode 100644
index 0000000..f471951
--- /dev/null
+++ b/xmrstak/backend/cpu/hwlocMemory.hpp
@@ -0,0 +1,55 @@
+#pragma once
+
+#include "console.h"
+
+#ifndef CONF_NO_HWLOC
+
+#include <hwloc.h>
+
+/** pin memory to NUMA node
+ *
+ * Set the default memory policy for the current thread to bind memory to the
+ * NUMA node.
+ *
+ * @param puId core id
+ */
+void bindMemoryToNUMANode( size_t puId )
+{
+ int depth;
+ hwloc_topology_t topology;
+
+ hwloc_topology_init(&topology);
+ hwloc_topology_load(topology);
+
+ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PU);
+
+ for( size_t i = 0;
+ i < hwloc_get_nbobjs_by_depth(topology, depth);
+ i++ )
+ {
+ hwloc_obj_t pu = hwloc_get_obj_by_depth(topology, depth, i);
+ if( pu->os_index == puId )
+ {
+ if( 0 > hwloc_set_membind_nodeset(
+ topology,
+ pu->nodeset,
+ HWLOC_MEMBIND_BIND,
+ HWLOC_MEMBIND_THREAD))
+ {
+ printer::inst()->print_msg(L0, "hwloc: can't bind memory");
+ }
+ else
+ {
+ printer::inst()->print_msg(L0, "hwloc: memory pinned");
+ break;
+ }
+ }
+ }
+}
+#else
+
+void bindMemoryToNUMANode( size_t )
+{
+}
+
+#endif
OpenPOWER on IntegriCloud