Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ReidAtcheson/numaallocator

Simple C++11 and beyond allocator to control
https://github.com/ReidAtcheson/numaallocator

Last synced: 3 months ago
JSON representation

Simple C++11 and beyond allocator to control

Awesome Lists containing this project

README

        

# NumaAllocator

This *very* simple code is a C++ allocator that gives some control
over where C++ containers allocate memory.

In a multithreaded code it is often enough to rely on the OS
first touch policy to achieve this implicitly, but sometimes
the different memory "nodes" can have wildly
different performance characteristics requiring programmer
to take more control.

#Dependencies

This simple include-only library does depend
on [libnuma](http://oss.sgi.com/projects/libnuma/).
You will need numa.h header file as well as
a [shared] object file to link against.

# Example

```c++

#include
#include "numaalloc.h"
int main(int argc,char** argv){

int n1=0;
int n2=1;
int sz=5000;

typedef NumaAlloc::NumaAlloc na_t;

//Allocate vector of floats bound to numa node n1
std::vector x(sz,0.0,na_t(n1));

//Allocate vector of floats bound to numa node n2
std::vector y(sz,0.0,na_t(n2));

//Do something with x,y in parallel for win.

return 0;

}

```