Difference between pages "r7.1.1:Function benchmark pal numa malloc" and "r7.1.1:Function libbenchmark misc pal helper add cache node to topology tree"

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_malloc}}
{{DISPLAYTITLE:function libbenchmark_misc_pal_helper_new_topology_node}}
==Source Files==
==Source Files==
  └───test_and_benchmark
  └───test_and_benchmark
     └───benchmark
     └───libbenchmark
        ├───inc
        │  └───libbenchmark
        │          libbenchmark_porting_abstraction_layer.h
         └───src
         └───src
             └───porting_abstraction_layer_numa_malloc.c
             └───libbenchmark_misc
                    libbenchmark_misc_pal_helpers.c
 
==Enums==
enum [[r7.1.1:enum libbenchmark_topology_node_cache_type|libbenchmark_topology_node_cache_type]];
 
==Opaque Structures==
struct [[r7.1.1:struct libbenchmark_topology_state|libbenchmark_topology_state]];
struct [[r7.1.1:struct libbenchmark_topology_node_state|libbenchmark_topology_node_state]];


==Prototype==
==Prototype==
  void *benchmark_pal_numa_malloc( lfds711_pal_uint_t numa_node_id, lfds711_pal_uint_t size_in_bytes );
  void libbenchmark_misc_pal_helper_add_cache_node_to_topology_tree( struct libbenchmark_topology_state *ts,
                                                                    struct libbenchmark_topology_node_state *tns,
                                                                    lfds711_pal_uint_t level,
                                                                    enum libbenchmark_topology_node_cache_type type );


==Parameters==
==Parameters==
''lfds711_pal_uint_t numa_node_id''
''struct libbenchmark_topology_state *ts''
: A NUMA node ID.  This is the ID used by the system to identify a NUMA node.
: A pointer a ''struct libbenchmark_topology'' obtained from ''libbenchmark_pal_populate_topology''.


''lfds711_pal_uint_t size_in_bytes''
''struct libbenchmark_topology_node_state *tns''
: The number of bytes to allocate.
: A pointer a ''struct libbenchmark_topology_node'' obtained from ''libbenchmark_misc_pal_helper_new_topology_node''.
 
''lfds711_pal_uint_t level''
: The cache's level (typically 1 to 3).
 
''enum libbenchmark_topology_node_cache_type type''
: This argument indicates the type of the cache (data, instruction or unified).


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


==Example==
==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==
==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.
This helper function is used by ''libbenchmark_pal_populate_topology'' to add a cache node to the topology tree.
 
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 (libbenchmark)|Porting Guide (libbenchmark)]]
* ''[[r7.1.1:function libbenchmark_pal_populate_topology|libbenchmark_pal_populate_topology]]''

Latest revision as of 20:16, 17 February 2017

Source Files

└───test_and_benchmark
    └───libbenchmark
        ├───inc
        │   └───libbenchmark
        │           libbenchmark_porting_abstraction_layer.h
        └───src
            └───libbenchmark_misc
                    libbenchmark_misc_pal_helpers.c

Enums

enum libbenchmark_topology_node_cache_type;

Opaque Structures

struct libbenchmark_topology_state;
struct libbenchmark_topology_node_state;

Prototype

void libbenchmark_misc_pal_helper_add_cache_node_to_topology_tree( struct libbenchmark_topology_state *ts,
                                                                   struct libbenchmark_topology_node_state *tns,
                                                                   lfds711_pal_uint_t level,
                                                                   enum libbenchmark_topology_node_cache_type type );

Parameters

struct libbenchmark_topology_state *ts

A pointer a struct libbenchmark_topology obtained from libbenchmark_pal_populate_topology.

struct libbenchmark_topology_node_state *tns

A pointer a struct libbenchmark_topology_node obtained from libbenchmark_misc_pal_helper_new_topology_node.

lfds711_pal_uint_t level

The cache's level (typically 1 to 3).

enum libbenchmark_topology_node_cache_type type

This argument indicates the type of the cache (data, instruction or unified).

Return Value

No return value.

Example

Notes

This helper function is used by libbenchmark_pal_populate_topology to add a cache node to the topology tree.

See Also