Skip to content

Instantly share code, notes, and snippets.

@disa-mhembere
Created December 12, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disa-mhembere/85f14311e4b1ec095344629f3177b742 to your computer and use it in GitHub Desktop.
Save disa-mhembere/85f14311e4b1ec095344629f3177b742 to your computer and use it in GitHub Desktop.
Code to help with NUMA opts
// Numa allocate
void numa_alloc(double* data) {
data = static_cast<double*>(numa_alloc_onnode(data_size, node_id));
}
// Numa deallocate
void numa_dealloc(double* data, size_t data_size) {
numa_free(data, data_size);
}
// Bind to node(Call within ctor for launched thread)
void bind2node_id(id) {
struct bitmask *bmp = numa_allocate_nodemask();
numa_bitmask_setbit(bmp, id);
numa_bind(bmp);
numa_free_nodemask(bmp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment