Difference between pages "r7.1.1:Function benchmark pal numa free" and "r7.1.1:Function benchmark pal numa malloc"
(Difference between pages)
Jump to navigation
Jump to search
m (1 revision imported) |
m (1 revision imported) |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:function | {{DISPLAYTITLE:function benchmark_pal_numa_malloc}} | ||
==Source Files== | ==Source Files== | ||
└───test_and_benchmark | └───test_and_benchmark | ||
└───benchmark | └───benchmark | ||
└───src | └───src | ||
└───porting_abstraction_layer_numa_malloc.c | |||
==Prototype== | ==Prototype== | ||
void | void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes ); | ||
==Parameters== | ==Parameters== | ||
'' | ''lfds711_pal_uint_t numa_node_id'' | ||
: A | : A NUMA node ID. This is the ID used by the system to identify a NUMA node. | ||
''lfds711_pal_uint_t size_in_bytes'' | ''lfds711_pal_uint_t size_in_bytes'' | ||
: The number of bytes | : The number of bytes to allocate. | ||
==Return Value== | ==Return Value== | ||
A pointer to the allocate memory, or NULL on failure. | |||
==Example== | ==Example== | ||
void | 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 | // 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; | return memory; | ||
} | } | ||
==Notes== | ==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== | ==See Also== | ||
* [[r7.1.1:Porting Guide (benchmark)|Porting Guide (benchmark)]] | * [[r7.1.1:Porting Guide (benchmark)|Porting Guide (benchmark)]] |
Latest revision as of 20:16, 17 February 2017
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.