Domanda

Simple C code can use libnuma library to allocate memory in specific memory node in a NUMA system. For example, it can be done using following function:

void *numa_alloc_onnode(size_t size, int node)

How one instantiate a class in some memory node? One way, I can think of is:

numa_set_membind(<nodemask>);
o = new Object();
numa_set_localalloc();

Will this work?

È stato utile?

Soluzione

Placement new is what you are looking for. Example:

void *blob = numa_alloc_onnode(sizeof(Object), ...);
Object *object = new(blob) Object;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top