4

I have a NUMA machine of 2 nodes. I want to allocate the two halves of an array on the two nodes respectively. How can I do that?

Please note that by "half" I mean a continuous chunk of virtual memory. I found the function numa_alloc_interleaved, but it doesn't satisfy my requirement.

dalibocai
  • 2,289
  • 5
  • 29
  • 45
  • Isn't a C++ data structure with an iterator and `[]` operator to make it behave like a contiguous allocation good enough? – jxh Oct 08 '13 at 21:52
  • Thanks for your suggestion. But I don't want to change the program except the allocation statement. – dalibocai Oct 08 '13 at 21:54

1 Answers1

0

You have a couple of choices.

You can have one piece of code that uses numa_alloc_onnode to allocate a block on each node you want to use, then give control/ownership of that block to the code running on that node.

Alternatively, you can start the code on each node, then have each node's code allocate its own memory locally using numa_alloc_local.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Your answer suggests that I change the program so that I manipulate two arrays instead of one, which I try to avoid. Is there a way to control the interleaving granularity? Say not page interleaved but K-page interleaved, where K is controllable. – dalibocai Oct 08 '13 at 22:10
  • @dalibocai: I'm not aware of such a function, no. – Jerry Coffin Oct 08 '13 at 22:11