253 #ifdef MCBSP_ALLOW_MULTIPLE_REGS
482 const size_t version,
643 bool mcbsp_util_contains(
const size_t *
const array,
const size_t value,
const size_t lo,
const size_t hi );
747 #ifdef MCBSP_CPLUSPLUS
748 void mcbsp_util_memcpy(
void *
const __restrict__ dest,
const void *
const __restrict__ src,
const size_t size );
750 void mcbsp_util_memcpy(
void *
const restrict dest,
const void *
const restrict src,
const size_t size );
size_t size
Length of global area.
Definition: mcutil.h:201
void * mcbsp_util_stack_peek(const struct mcbsp_util_stack *const stack)
Returns the top stack item.
void mcbsp_util_address_table_setsize(struct mcbsp_util_address_table *const table, const size_t target_size)
Ensures the address table is of at least the given size.
size_t cores
The number of hardware cores available on the current system.
Definition: mcutil.h:115
size_t num_reserved_cores
Number of entries in the reserved_cores array.
Definition: mcutil.h:141
void * mcbsp_util_varstack_peek(const struct mcbsp_util_stack *const stack, const size_t size)
Peeks for a variably-sized item on the stack.
void ** keys
Keys.
Definition: mcutil.h:187
void mcbsp_util_stack_destroy(struct mcbsp_util_stack *const stack)
Frees all memory related to a given stack.
void mcbsp_util_stack_initialize(struct mcbsp_util_stack *const stack, const size_t elementSize)
Initialises the mcbsp_util_stack struct.
struct mcbsp_util_stack mcbsp_util_partition(const struct mcbsp_util_machine_partition subpart, const size_t P, const enum mcbsp_affinity_mode affinity)
Derives a P-way subpartition from a given machine partition.
bool Cset
Whether the cores field has been set manually.
Definition: mcutil.h:78
A map from pointers to unsigned long ints.
Definition: mcutil.h:178
size_t mcbsp_util_sort_unique_integers(size_t *const array, const size_t length, const size_t lower_bound, const size_t upper_bound)
Sorts an array of integers.
void mcbsp_util_address_map_insert(struct mcbsp_util_address_map *const address_map, void *const key, const size_t value)
Inserts a key-value pair in the map.
Structure representing the machine hardware information.
Definition: mcutil.h:69
size_t threads
The total number of threads available for computation.
Definition: mcutil.h:102
Self-growing stack.
Definition: mcutil.h:206
size_t cap
Capacity.
Definition: mcutil.h:247
void mcbsp_util_address_table_set(struct mcbsp_util_address_table *const table, const size_t key, const size_t version, void *const value, const size_t size)
Sets an entry in a given address table.
size_t * pinning
Pinning array.
Definition: mcutil.h:266
bool mcbsp_util_contains(const size_t *const array, const size_t value, const size_t lo, const size_t hi)
Returns whether an array contains a given value.
size_t size
Size of a single entry in bytes.
Definition: mcutil.h:215
size_t mcbsp_util_log2(size_t x)
Binary logarithm, unsigned integer version, rounding up.
size_t top
Number of entries in the stack.
Definition: mcutil.h:212
size_t safe_cp_f
The checkpointing frequency used when trouble is imminent.
Definition: mcutil.h:174
mcbsp_affinity_mode
Pre-defined strategies for pinning threads.
Definition: mcbsp-affinity.h:204
bool Tset
Whether the threads field has been set manually.
Definition: mcutil.h:72
size_t * manual_affinity
Pointer to the manually-defined affinity definition.
Definition: mcutil.h:136
void * mcbsp_util_varstack_pop(struct mcbsp_util_stack *const stack, const size_t size)
Returns the top stack item of variable size, and shortens the stack by that item size.
void mcbsp_util_varstack_regpush(struct mcbsp_util_stack *const stack, const void *const item)
Pushes a fixed-size item on the stack.
Definition: mcutil.h:418
size_t threads_per_core
The number of hardware threads per core on the system MulticoreBSP is executing on.
Definition: mcutil.h:121
void * mcbsp_util_varstack_regpeek(const struct mcbsp_util_stack *const stack)
Peeks for a fixed-sized item on the stack.
Definition: mcutil.h:395
struct mcbsp_util_stack partition
Stack of machine partitions, one for each pinning.
Definition: mcutil.h:269
struct mcbsp_util_machine_partition mcbsp_util_derive_partition(const struct mcbsp_util_machine_info *const info)
Derives an initial machine partition from a machine_info object.
size_t * reserved_cores
Pointer to the manually-defined reversed-cores list.
Definition: mcutil.h:152
enum mcbsp_thread_numbering thread_numbering
Currently active thread-numbering method.
Definition: mcutil.h:124
mcbsp_thread_numbering
Enumerates ways of hardware thread numbering.
Definition: mcbsp-affinity.h:234
struct mcbsp_util_machine_info * mcbsp_util_createMachineInfo(void)
Creates a new machine info struct.
void mcbsp_util_address_table_grow(struct mcbsp_util_address_table *const table, const size_t target_size)
Increases the capacity of a given address table to match at least a given capacity.
void mcbsp_util_memcpy(void *const restrict dest, const void *const restrict src, const size_t size)
Copies the data in [src,src+size) to [dest,dest+size).
Return type of mcbsp_util_pinning.
Definition: mcutil.h:263
size_t start
Start hardware thread index.
Definition: mcutil.h:56
void * mcbsp_util_malloc(const size_t size, const char *const name)
Memory allocation function used for internal MulticoreBSP for C memory areas.
void mcbsp_util_address_table_initialize(struct mcbsp_util_address_table *const table, const size_t P)
Initialises the mcbsp_util_address_table struct.
struct mcbsp_util_pinning_info mcbsp_util_pinning(const size_t P, struct mcbsp_util_machine_info *const machine, const struct mcbsp_util_machine_partition *const super_machine)
Function that yields a pinning of P threads according to the given machine info.
void mcbsp_util_filter_standard_pinning(const struct mcbsp_util_machine_info *const info, size_t *const array, const size_t P)
Filters reserved cores from a standard pinning list.
size_t end
What the last hardware thread is.
Definition: mcutil.h:62
void mcbsp_util_address_map_initialize(struct mcbsp_util_address_map *const address_map)
Initialises a mcbsp_util_address_map struct.
bool CPFset
Whether the checkpoint_frequency field has been overridden.
Definition: mcutil.h:96
bool Aset
Whether the affinity field as been set manually.
Definition: mcutil.h:75
size_t mcbsp_util_array_sizet_lbound(const size_t *const array, const size_t key, size_t lo, size_t hi)
Searches an array for the largest value lower or equal to a given key.
void mcbsp_util_varstack_push(struct mcbsp_util_stack *const stack, const void *const item, const size_t size)
Pushes a variably-sized item on the stack.
bool mcbsp_util_address_table_delete(struct mcbsp_util_address_table *const table, const size_t key, const size_t version)
Removes an entry from a given address table.
void mcbsp_util_translate_standard_pinning(const struct mcbsp_util_machine_info *const info, size_t *const array, const size_t P)
Translates thread numbers in the standard pinning format (consecutive), to the numbering format activ...
void mcbsp_util_destroyMachineInfo(void *machine_info)
If a current machine info instance exists, destroys it.
size_t mcbsp_util_address_map_binsearch(const struct mcbsp_util_address_map *const address_map, const void *const key, size_t lo, size_t hi)
Helper-function for mcbsp_util_address_map_insert, and mcbsp_util_address_map_remove.
void * array
Stack entries.
Definition: mcutil.h:218
void mcbsp_util_address_map_remove(struct mcbsp_util_address_map *const address_map, void *const key)
Removes a key-value pair from the map.
void mcbsp_util_fatal(void)
Handles a fatal error in a uniform fashion.
size_t cap
Stack capacity in the number of elements.
Definition: mcutil.h:209
void * mcbsp_util_stack_pop(struct mcbsp_util_stack *const stack)
Returns the newest item in the stack.
void mcbsp_util_varstack_grow(struct mcbsp_util_stack *const stack, const size_t requested_size)
Doubles the capacity of a given stack that consists of elements of variable size. ...
size_t P
Number of local versions.
Definition: mcutil.h:250
size_t * values
Values.
Definition: mcutil.h:190
int mcbsp_util_integer_compare(const void *a, const void *b)
Comparison function for use with qsort on arrays of size_t's.
void * address
Local address.
Definition: mcutil.h:198
A table of local address locations per SPMD variable.
Definition: mcutil.h:241
size_t * mcbsp_util_derive_standard_pinning(const struct mcbsp_util_machine_partition *iterator, const size_t size)
Derives a pinning from an array of machine partitions.
void mcbsp_util_address_map_destroy(struct mcbsp_util_address_map *const address_map)
Frees the memory related to a given address map.
bool TNset
Whether the thread numbering field has been set manually.
Definition: mcutil.h:84
bool TpCset
Whether the threads_per_core field has been set manually.
Definition: mcutil.h:81
size_t mcbsp_util_address_map_get(const struct mcbsp_util_address_map *const address_map, const void *const key)
Address map accessor.
pthread_mutex_t mutex
Mutex for locking-out write access to the global table.
Definition: mcutil.h:244
size_t size
Size.
Definition: mcutil.h:184
void * mcbsp_util_varstack_regpop(struct mcbsp_util_stack *const stack)
Returns the top fixed-size item of the stack.
Definition: mcutil.h:372
size_t mcbsp_util_detect_hardware_threads(void)
Attempts to detect the number of hard-ware threads supported on the current machine.
bool UTset
Whether the unused_threads_per_core field has been set.
Definition: mcutil.h:93
bool Pset
Whether the manual pinning field has been set.
Definition: mcutil.h:87
size_t unused_threads_per_core
Number of threads per core that should remain unused.
Definition: mcutil.h:158
Structure representing a part of the current machine.
Definition: mcutil.h:53
void mcbsp_util_address_map_grow(struct mcbsp_util_address_map *const address_map)
Doubles the capacity of a given address map.
void mcbsp_util_stack_grow(struct mcbsp_util_stack *const stack, const size_t target_size)
Increases the capacity of a given stack to match or exceed a given target capacity.
void mcbsp_util_stack_push(struct mcbsp_util_stack *const stack, const void *const item)
Pushes a new item on the stack.
void mcbsp_util_address_table_destroy(struct mcbsp_util_address_table *const table)
Frees the memory associated with a given address table.
bool SCFset
Whether the safe_checkpoint_frequency field has been overridden.
Definition: mcutil.h:99
bool Rset
Whether the reserved cores field has been set.
Definition: mcutil.h:90
size_t cp_f
The default checkpointing frequency.
Definition: mcutil.h:166
bool mcbsp_util_stack_empty(const struct mcbsp_util_stack *const stack)
Checks whether a given stack is empty.
struct mcbsp_util_address_table_entry * mcbsp_util_address_table_get(const struct mcbsp_util_address_table *const table, const size_t key, const size_t version)
Gets an entry from a given address table.
size_t cap
Capacity.
Definition: mcutil.h:181
struct mcbsp_util_address_table_entry ** table
Table entries.
Definition: mcutil.h:256
A single address table entry.
Definition: mcutil.h:195
struct mcbsp_util_address_map MCBSP_UTIL_EMPTY_ADDRESS_MAP
A default initialiser of type mcbsp_util_address_map.
void mcbsp_util_check_machine_info(struct mcbsp_util_machine_info *const machine)
Function that prepares a mcbsp_util_machine_info for use.
enum mcbsp_affinity_mode affinity
Currently active affinity strategy.
Definition: mcutil.h:105
size_t stride
How much farther away the next hardware thread is.
Definition: mcutil.h:59