MulticoreBSP for C
Version 1.2
|
Go to the source code of this file.
Enumerations | |
enum | mcbsp_affinity_mode { SCATTER = 0, COMPACT, MANUAL } |
Pre-defined strategies for pinning threads. More... | |
enum | mcbsp_thread_numbering { CONSECUTIVE = 0, WRAPPED } |
Enumerates ways of hardware thread numbering. More... | |
Functions | |
void | mcbsp_set_maximum_threads (const size_t max) |
Changes the maxmimum amount of threads MulticoreBSP can allocate. More... | |
void | mcbsp_set_affinity_mode (const enum mcbsp_affinity_mode mode) |
Changes the currently active affinity strategy. More... | |
void | mcbsp_set_available_cores (const size_t num_cores) |
Changes the number of available cores. More... | |
void | mcbsp_set_threads_per_core (const size_t threads_per_core) |
Changes the number of threads per core. More... | |
void | mcbsp_set_thread_numbering (const enum mcbsp_thread_numbering numbering) |
Changes the thread numbering strategy this machines adheres to. More... | |
void | mcbsp_set_pinning (const size_t *const pinning, const size_t length) |
Supplies a manually defined pinning strategy for MulticoreBSP to use. More... | |
void | mcbsp_set_reserved_cores (const size_t *const reserved, const size_t length) |
Supplies a list of core IDs that are NOT to be used by MulticoreBSP SPMD runs. More... | |
size_t | mcbsp_get_maximum_threads (void) |
enum mcbsp_affinity_mode | mcbsp_get_affinity_mode (void) |
size_t | mcbsp_get_available_cores (void) |
size_t | mcbsp_get_threads_per_core (void) |
enum mcbsp_thread_numbering | mcbsp_get_thread_numbering (void) |
size_t * | mcbsp_get_pinning (void) |
size_t | mcbsp_get_reserved_cores_number (void) |
size_t * | mcbsp_get_reserved_cores (void) |
Variables | |
enum mcbsp_affinity_mode | MCBSP_DEFAULT_AFFINITY |
Default affinity strategy (SCATTER). More... | |
size_t | MCBSP_DEFAULT_THREADS_PER_CORE |
Default number of threads per core (1). More... | |
enum mcbsp_thread_numbering | MCBSP_DEFAULT_THREAD_NUMBERING |
Default thread numbering (CONSECUTIVE). More... | |
The MulticoreBSP for C affinity interface
The functions and data types defined in this class allow a user to take control of the way MulticoreBSP pins BSP processes to hardware threads, at run-time.
Changes made to the machine layout using these functions take effect only at the next call to bsp_begin; calling these functions does not affect running SPMD sections.
Values set using this interface supercede values defined in
The default values can be changed by directly setting the MCBSP_DEFAULT_AFFINITY, MCBSP_DEFAULT_THREADS_PER_CORE, or MCBSP_DEFAULT_THREAD_NUMBERING globals.
All fields are thread-local. Setting values manually should occur on each thread separately. This is only useful if multiple threads call bsp_begin simultaneously. This is useful when employing hierarchical BSP computations.
enum mcbsp_affinity_mode |
Pre-defined strategies for pinning threads.
Enumerates ways of hardware thread numbering.
enum mcbsp_affinity_mode mcbsp_get_affinity_mode | ( | void | ) |
size_t mcbsp_get_available_cores | ( | void | ) |
size_t mcbsp_get_maximum_threads | ( | void | ) |
size_t* mcbsp_get_pinning | ( | void | ) |
size_t* mcbsp_get_reserved_cores | ( | void | ) |
size_t mcbsp_get_reserved_cores_number | ( | void | ) |
enum mcbsp_thread_numbering mcbsp_get_thread_numbering | ( | void | ) |
size_t mcbsp_get_threads_per_core | ( | void | ) |
void mcbsp_set_affinity_mode | ( | const enum mcbsp_affinity_mode | mode | ) |
Changes the currently active affinity strategy.
Users should use this function to set the affinity strategy to something other than the default strategy (SCATTER).
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
Will override defaults, and will override values given in `machine.info'.
void mcbsp_set_available_cores | ( | const size_t | num_cores | ) |
Changes the number of available cores.
Will override defaults, and will override values given in `machine.info'.
By default, MulticoreBSP will set this value equal to the number of hardware threads detected, divided by threads_per_core.
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
void mcbsp_set_maximum_threads | ( | const size_t | max | ) |
Changes the maxmimum amount of threads MulticoreBSP can allocate.
Setting this higher than the (auto-detected) maximum of your machine will cause your MulticoreBSP applications to hang, unless combined with a manually set affinity strategy preventing this.
void mcbsp_set_pinning | ( | const size_t *const | pinning, |
const size_t | length | ||
) |
Supplies a manually defined pinning strategy for MulticoreBSP to use.
Implies `mcbsp_set_affinity_mode( MANUAL );' Will override values given in `machine.info'.
The supplied pinning array must be of size equal to the maximum number of threads supported by the current machine, and is buffered (copied) internally.
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
Note: the user-supplied array must also be freed by the user.
void mcbsp_set_reserved_cores | ( | const size_t *const | reserved, |
const size_t | length | ||
) |
Supplies a list of core IDs that are NOT to be used by MulticoreBSP SPMD runs.
The user should NOT update the number of threads of the machine; MulticoreBSP will automatically infer the number of threads available at run- time, whenever necessary.
Please do make sure to set the number of threads_per_core and thread_numbering correctly to ensure the pinning strategy works properly.
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
Note: the user-supplied array must also be freed by the user.
void mcbsp_set_thread_numbering | ( | const enum mcbsp_thread_numbering | numbering | ) |
Changes the thread numbering strategy this machines adheres to.
Will override defaults, and will override values given in `machine.info'.
The default is CONSECUTIVE. This value affects only the SCATTER and COMPACT strategies.
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
void mcbsp_set_threads_per_core | ( | const size_t | threads_per_core | ) |
Changes the number of threads per core.
Will override defaults, and will override values given in `machine.info'.
The default value is 1. The value affects only the SCATTER and COMPACT strategies.
This will only affect new SPMD instances.
This function is thread-safe in that upon exit, valid machine info is guaranteed. Concurrent calls with bsp_begin still constitutes a programming error, however (but will not result in crashes).
threads_per_core | The number of hardware threads that is supported by each core on this machine. |
enum mcbsp_affinity_mode MCBSP_DEFAULT_AFFINITY |
Default affinity strategy (SCATTER).
enum mcbsp_thread_numbering MCBSP_DEFAULT_THREAD_NUMBERING |
Default thread numbering (CONSECUTIVE).
size_t MCBSP_DEFAULT_THREADS_PER_CORE |
Default number of threads per core (1).