Difference between pages "r7.1.1:Function benchmark pal numa free" and "r7.1.1:Function benchmark pal numa malloc"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
{{DISPLAYTITLE:function benchmark_pal_numa_free}}
{{DISPLAYTITLE:function benchmark_pal_numa_malloc}}
==Source Files==
==Source Files==
  └───test_and_benchmark
  └───test_and_benchmark
     └───benchmark
     └───benchmark
         └───src
         └───src
             └───porting_abstraction_layer_numa_free.c
             └───porting_abstraction_layer_numa_malloc.c


==Prototype==
==Prototype==
  void benchmark_pal_numa_free( void *memory, lfds711_pal_uint_t size_in_bytes );
  void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes );


==Parameters==
==Parameters==
''void *memory''
''lfds711_pal_uint_t numa_node_id''
: A pointer to an allocation returned by ''benchmark_pal_numa_malloc''.
: 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 in the allocation pointed to by ''memory''.  Some NUMA ''free'' functions require this information, so the abstraction has to support it.
: The number of bytes to allocate.


==Return Value==
==Return Value==
No return value.
A pointer to the allocate memory, or NULL on failure.


==Example==
==Example==
  void benchmark_pal_numa_free( void *memory, lfds711_pal_uint_t size_in_bytes )
  void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes )
  {
  {
   assert( memory != NULL );
   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
   
   
   numa_free( memory, size_in_bytes );
   process_handle = GetCurrentProcess();
  memory = VirtualAllocExNuma( process_handle, NULL, size_in_bytes, MEM_COMMIT, PAGE_READWRITE, (DWORD) numa_node_id );
   
   
   return;
   return memory;
  }
  }


==Notes==
==Notes==
Returns an allocation made by ''libbenchmark_pal_numa_malloc'' to the system.
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.

See Also