Skip to content

ReidAtcheson/numaallocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

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. You will need numa.h header file as well as a [shared] object file to link against.

Example

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

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

  typedef NumaAlloc::NumaAlloc<float> na_t;


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

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


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




  return 0;

}

About

Simple C++11 and beyond allocator to control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages