function benchmark_pal_numa_malloc

From liblfds.org
Revision as of 20:16, 17 February 2017 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source Files

└───test_and_benchmark
    └───benchmark
        └───src
            └───porting_abstraction_layer_numa_malloc.c

Prototype

void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes );

Parameters

lfds711_pal_uint_t numa_node_id

A NUMA node ID. This is the ID used by the system to identify a NUMA node.

lfds711_pal_uint_t size_in_bytes

The number of bytes to allocate.

Return Value

A pointer to the allocate memory, or NULL on failure.

Example

void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes )
{
  HANDLE
    process_handle;

  LPVOID
    memory;

  // TRD : numa_node_id can be any value in its range
  // TRD : size_in_bytes can be any value in its range

  process_handle = GetCurrentProcess();

  memory = VirtualAllocExNuma( process_handle, NULL, size_in_bytes, MEM_COMMIT, PAGE_READWRITE, (DWORD) numa_node_id );

  return memory;
}

Notes

The libbenchmark library performs no memory allocations, rather it expects allocated memory to be passed to it, which it then uses. As such the benchmark programme does perform allocations, as it is calling the libbenchmark functions to perform benchmarking.

The benchmark programme requires a hosted implementation and as such on SMP systems, simply calls malloc. However, on NUMA systems, the standard library offers no NUMA-aware allocator, so this abstraction function is required.

See Also