|
Dynamic Load Balance 3.6.1+32-59d1
|
#include "apis/dlb.h"#include "LB_core/node_barrier.h"#include "LB_core/spd.h"#include "LB_core/DLB_kernel.h"#include "LB_comm/shmem_procinfo.h"#include "support/env.h"#include "support/error.h"#include "support/dlb_common.h"#include "support/options.h"#include <unistd.h>#include <stdbool.h>#include <stdlib.h>#include <string.h>#include <stdio.h>
Functions | |
| __attribute__ ((constructor)) | |
| DLB_EXPORT_SYMBOL int | DLB_Init (int ncpus, const_dlb_cpu_set_t mask, const char *dlb_args) |
| Initialize DLB library and all its internal data structures. Must be called once and only once by each process in the DLB system. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Finalize (void) |
| Finalize DLB library and clean up all its data structures. Must be called by each process before exiting the system. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PreInit (const_dlb_cpu_set_t mask, char ***next_environ) |
| Pre-Initialize process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Enable (void) |
| Enable DLB and all its features in case it was previously disabled, otherwise it has no effect. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Disable (void) |
| Disable DLB actions for the calling process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_SetMaxParallelism (int max) |
| Set the maximum number of resources to be used by the calling process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_UnsetMaxParallelism (void) |
| Unset the maximum number of resources to be used by the calling process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CallbackSet (dlb_callbacks_t which, dlb_callback_t callback, void *arg) |
| Setter for DLB callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CallbackGet (dlb_callbacks_t which, dlb_callback_t *callback, void **arg) |
| Getter for DLB callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Lend (void) |
| Lend all the current CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_LendCpu (int cpuid) |
| Lend a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_LendCpus (int ncpus) |
| Lend a specific amount of CPUs, only useful for systems that do not work with cpu masks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_LendCpuMask (const_dlb_cpu_set_t mask) |
| Lend a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Reclaim (void) |
| Reclaim all the CPUs that are owned by the process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpu (int cpuid) |
| Reclaim a specific CPU that are owned by the process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpus (int ncpus) |
| Reclaim a specific amount of CPUs that are owned by the process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpuMask (const_dlb_cpu_set_t mask) |
| Reclaim a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpu (int cpuid) |
| Acquire a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpus (int ncpus) |
| Acquire a specific amount of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpuMask (const_dlb_cpu_set_t mask) |
| Acquire a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpusInMask (int ncpus, const_dlb_cpu_set_t mask) |
| Acquire some CPUs from a subset of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Borrow (void) |
| Borrow all the possible CPUs registered on DLB. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpu (int cpuid) |
| Borrow a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpus (int ncpus) |
| Borrow a specific amount of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpuMask (const_dlb_cpu_set_t mask) |
| Borrow a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpusInMask (int ncpus, const_dlb_cpu_set_t mask) |
| Borrow some CPUs from a subset of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Return (void) |
| Return claimed CPUs of other processes. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReturnCpu (int cpuid) |
| Return the specific CPU if it has been reclaimed. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReturnCpuMask (const_dlb_cpu_set_t mask) |
| Return a set of CPUs if some of them have been reclaimed. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PollDROM (int *ncpus, dlb_cpu_set_t mask) |
| Poll DROM module to check if the process needs to adapt to a new mask or number of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PollDROM_Update (void) |
| Poll DROM module to check if the process needs to adapt to a new mask and update it if necessary using the registered callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CheckCpuAvailability (int cpuid) |
| Check whether the specified CPU is being used by another process. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Barrier (void) |
| Perform a DLB Barrier among processes in the node. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BarrierAttach (void) |
| Attach process to the DLB Barrier team. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BarrierDetach (void) |
| Detach process from the DLB Barrier team. More... | |
| DLB_EXPORT_SYMBOL dlb_barrier_t * | DLB_BarrierNamedRegister (const char *barrier_name, dlb_barrier_flags_t flags) |
| Register, or obtain, a named barrier. More... | |
| DLB_EXPORT_SYMBOL | DLB_ALIAS (dlb_barrier_t *, DLB_BarrierNamedGet,(const char *barrier_name, dlb_barrier_flags_t flags),(barrier_name, flags), DLB_BarrierNamedRegister) |
| DLB_EXPORT_SYMBOL int | DLB_BarrierNamedAttach (dlb_barrier_t *barrier) |
| Attach process to the named barrier team. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BarrierNamedDetach (dlb_barrier_t *barrier) |
| Detach process from the named barrier team. More... | |
| DLB_EXPORT_SYMBOL int | DLB_SetVariable (const char *variable, const char *value) |
| Change the value of a DLB internal variable. More... | |
| DLB_EXPORT_SYMBOL int | DLB_GetVariable (const char *variable, char *value) |
| Query the value of a DLB internal variable. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PrintVariables (int print_extended) |
| Print DLB internal variables. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PrintShmem (int num_columns, dlb_printshmem_flags_t print_flags) |
| Print the data stored in the shmem. More... | |
| DLB_EXPORT_SYMBOL const char * | DLB_Strerror (int errnum) |
| Obtain a pointer to a string that describes the error code passed by argument. More... | |
| DLB_EXPORT_SYMBOL int | DLB_SetObserverRole (bool thread_is_observer) |
| Modify the current thread DLB role to either observer or particpant. More... | |
| DLB_EXPORT_SYMBOL int | DLB_GetVersion (int *major, int *minor, int *patch) |
| Return the DLB version. More... | |
| DLB_EXPORT_SYMBOL int | DLB_GetGPUAffinity (char *buffer, size_t buffer_size, bool full_uuid) |
| __attribute__ | ( | (constructor) | ) |
| DLB_EXPORT_SYMBOL int DLB_Init | ( | int | ncpus, |
| const_dlb_cpu_set_t | mask, | ||
| const char * | dlb_args | ||
| ) |
Initialize DLB library and all its internal data structures. Must be called once and only once by each process in the DLB system.
| [in] | ncpus | optional, initial number of CPUs, or 0 |
| [in] | mask | optional, initial CPU mask to register, or NULL |
| [in] | dlb_args | optional parameter to overwrite DLB_ARGS options, or NULL |
Parameters ncpus and mask are used to register CPUs owned by the calling process into the system. Both are optional but, if provided, mask takes precedence. Parameter dlb_args can be used in conjunction with DLB_ARGS; the latter takes precedence in case of conflicting options.
| DLB_EXPORT_SYMBOL int DLB_Finalize | ( | void | ) |
Finalize DLB library and clean up all its data structures. Must be called by each process before exiting the system.
| DLB_EXPORT_SYMBOL int DLB_PreInit | ( | const_dlb_cpu_set_t | mask, |
| char *** | next_environ | ||
| ) |
Pre-Initialize process.
| [in] | mask | initial CPU mask to register |
| [in,out] | next_environ | environment to modify if the process is going to fork-exec |
| DLB_EXPORT_SYMBOL int DLB_Enable | ( | void | ) |
Enable DLB and all its features in case it was previously disabled, otherwise it has no effect.
It can be used in conjunction with DLB_Disable() to delimit sections of the code where DLB calls will not have effect.
| DLB_EXPORT_SYMBOL int DLB_Disable | ( | void | ) |
Disable DLB actions for the calling process.
This call resets the original resources for the process and returns any external CPU it may be using at that time. While DLB is disabled there will not be any resource sharing for this process.
| DLB_EXPORT_SYMBOL int DLB_SetMaxParallelism | ( | int | max | ) |
Set the maximum number of resources to be used by the calling process.
| [in] | max | max number of CPUs |
Used to delimit sections of the code that the developer knows that only a maximum number of CPUs can benefit the execution. If a process reaches its maximum number of resources used at any time, subsequent calls to borrow CPUs will be ignored until some of them are returned. If the maximum number of CPUs exceeds the current number of assigned CPUs at the time of this function call, DLB will readjust as needed.
| DLB_EXPORT_SYMBOL int DLB_UnsetMaxParallelism | ( | void | ) |
Unset the maximum number of resources to be used by the calling process.
Unset the maximum number of CPUs previously assigned to this process. Subsequent calls to borrow will not be delimited by this parameter.
| DLB_EXPORT_SYMBOL int DLB_CallbackSet | ( | dlb_callbacks_t | which, |
| dlb_callback_t | callback, | ||
| void * | arg | ||
| ) |
Setter for DLB callbacks.
| [in] | which | callback type |
| [in] | callback | function pointer to register |
| [in] | arg | opaque argument to pass in each callback invocation |
Register a new callback for the callback type which. The callback type comes predefined by the enum values of dlb_callbacks_t. It is highly recommended to register at least callbacks for dlb_callback_enable_cpu and dlb_callback_disable_cpu.
| DLB_EXPORT_SYMBOL int DLB_CallbackGet | ( | dlb_callbacks_t | which, |
| dlb_callback_t * | callback, | ||
| void ** | arg | ||
| ) |
Getter for DLB callbacks.
| [in] | which | callback type |
| [out] | callback | registered callback function for the specified callback type |
| [out] | arg | opaque argument to pass in each callback invocation |
Obtain the previously registered callback and arg for the specified which callback type.
| DLB_EXPORT_SYMBOL int DLB_Lend | ( | void | ) |
Lend all the current CPUs.
Lend CPUs of the process to the system. A lent CPU may be assigned to other process that requests more resources. After lending a CPU, it can be reclaimed if it was originally owned by the process.
| DLB_EXPORT_SYMBOL int DLB_LendCpu | ( | int | cpuid | ) |
Lend a specific CPU.
| [in] | cpuid | CPU id to lend |
Lend CPUs of the process to the system. A lent CPU may be assigned to other process that requests more resources. After lending a CPU, it can be reclaimed if it was originally owned by the process.
| DLB_EXPORT_SYMBOL int DLB_LendCpus | ( | int | ncpus | ) |
Lend a specific amount of CPUs, only useful for systems that do not work with cpu masks.
| [in] | ncpus | number of CPUs to lend |
Lend CPUs of the process to the system. A lent CPU may be assigned to other process that requests more resources. After lending a CPU, it can be reclaimed if it was originally owned by the process.
| DLB_EXPORT_SYMBOL int DLB_LendCpuMask | ( | const_dlb_cpu_set_t | mask | ) |
Lend a set of CPUs.
| [in] | mask | CPU mask to lend |
Lend CPUs of the process to the system. A lent CPU may be assigned to other process that requests more resources. After lending a CPU, it can be reclaimed if it was originally owned by the process.
| DLB_EXPORT_SYMBOL int DLB_Reclaim | ( | void | ) |
Reclaim all the CPUs that are owned by the process.
Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpu | ( | int | cpuid | ) |
Reclaim a specific CPU that are owned by the process.
| [in] | cpuid | CPU id to reclaim |
Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpus | ( | int | ncpus | ) |
Reclaim a specific amount of CPUs that are owned by the process.
| [in] | ncpus | Number of CPUs to reclaim |
Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpuMask | ( | const_dlb_cpu_set_t | mask | ) |
Reclaim a set of CPUs.
| [in] | mask | CPU mask to reclaim |
Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpu | ( | int | cpuid | ) |
Acquire a specific CPU.
| [in] | cpuid | CPU to acquire |
Acquire CPUs from the system. If the CPU belongs to the process, the call is equivalent to a reclaim action. Otherwise, the process attempts to acquire a CPU. In asynchronous mode, it may enqueue a request for the CPU.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpus | ( | int | ncpus | ) |
Acquire a specific amount of CPUs.
| [in] | ncpus | Number of CPUs to acquire |
Acquire CPUs from the system. If the CPU belongs to the process, the call is equivalent to a reclaim action. Otherwise, the process attempts to acquire a CPU. In asynchronous mode, it may enqueue a request for the CPU.
This function allows these two special values for ncpus in asynchronous mode:
| DLB_EXPORT_SYMBOL int DLB_AcquireCpuMask | ( | const_dlb_cpu_set_t | mask | ) |
Acquire a set of CPUs.
| [in] | mask | CPU set to acquire |
Acquire CPUs from the system. If the CPU belongs to the process, the call is equivalent to a reclaim action. Otherwise, the process attempts to acquire a CPU. In asynchronous mode, it may enqueue a request for the CPU.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpusInMask | ( | int | ncpus, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Acquire some CPUs from a subset of CPUs.
| [in] | ncpus | Number of CPUs to acquire |
| [in] | mask | CPU set to acquire from |
Acquire CPUs from the system. If the CPU belongs to the process, the call is equivalent to a reclaim action. Otherwise, the process attempts to acquire a CPU. In asynchronous mode, it may enqueue a request for the CPU.
| DLB_EXPORT_SYMBOL int DLB_Borrow | ( | void | ) |
Borrow all the possible CPUs registered on DLB.
Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.
| DLB_EXPORT_SYMBOL int DLB_BorrowCpu | ( | int | cpuid | ) |
Borrow a specific CPU.
| [in] | cpuid | cpu CPU to borrow |
Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.
| DLB_EXPORT_SYMBOL int DLB_BorrowCpus | ( | int | ncpus | ) |
Borrow a specific amount of CPUs.
| [in] | ncpus | Number of CPUs to borrow |
Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.
| DLB_EXPORT_SYMBOL int DLB_BorrowCpuMask | ( | const_dlb_cpu_set_t | mask | ) |
Borrow a set of CPUs.
| [in] | mask | CPU set to borrow |
Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.
| DLB_EXPORT_SYMBOL int DLB_BorrowCpusInMask | ( | int | ncpus, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Borrow some CPUs from a subset of CPUs.
| [in] | ncpus | Number of CPUs to borrow |
| [in] | mask | CPU set to borrow from |
Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.
| DLB_EXPORT_SYMBOL int DLB_Return | ( | void | ) |
Return claimed CPUs of other processes.
In polling mode (the default), this routine checks whether the CPUs assigned to the calling process needs to be returned. On success, a disable callback is triggered.
In asynchronous mode, this routine has no effect.
| DLB_EXPORT_SYMBOL int DLB_ReturnCpu | ( | int | cpuid | ) |
Return the specific CPU if it has been reclaimed.
| [in] | cpuid | CPU to return |
In polling mode (the default), this routine checks whether the CPUs assigned to the calling process needs to be returned. On success, a disable callback is triggered.
In asynchronous mode, this routine has no effect.
| DLB_EXPORT_SYMBOL int DLB_ReturnCpuMask | ( | const_dlb_cpu_set_t | mask | ) |
Return a set of CPUs if some of them have been reclaimed.
| [in] | mask | CPU set to return |
In polling mode (the default), this routine checks whether the CPUs assigned to the calling process needs to be returned. On success, a disable callback is triggered.
In asynchronous mode, this routine has no effect.
| DLB_EXPORT_SYMBOL int DLB_PollDROM | ( | int * | ncpus, |
| dlb_cpu_set_t | mask | ||
| ) |
Poll DROM module to check if the process needs to adapt to a new mask or number of CPUs.
| [out] | ncpus | optional, variable to receive the new number of CPUs |
| [out] | mask | optional, variable to receive the new mask |
If DROM is enabled and the interaction mode is not asynchronous, this function can be called to poll the status of the CPU ownership.
| DLB_EXPORT_SYMBOL int DLB_PollDROM_Update | ( | void | ) |
Poll DROM module to check if the process needs to adapt to a new mask and update it if necessary using the registered callbacks.
Same as DLB_PollDROM(), but calling the registered callbacks to update the ownership info instead of returning the data by argument.
| DLB_EXPORT_SYMBOL int DLB_CheckCpuAvailability | ( | int | cpuid | ) |
Check whether the specified CPU is being used by another process.
| [in] | cpuid | CPU to be checked |
| DLB_EXPORT_SYMBOL int DLB_Barrier | ( | void | ) |
Perform a DLB Barrier among processes in the node.
This function performs a shared-memory-based barrier among all DLB processes in the node, unless thay have previously detached. The number of participants in the barrier is adaptive, which may produce undesired results if there is no synchronization between the attach/detach process and the barrier itself.
| DLB_EXPORT_SYMBOL int DLB_BarrierAttach | ( | void | ) |
Attach process to the DLB Barrier team.
If the process had previusly called DLB_BarrierDetach, this function allows a process to become part again of the DLB Barrier team. Otherwise, it has no effect.
| DLB_EXPORT_SYMBOL int DLB_BarrierDetach | ( | void | ) |
Detach process from the DLB Barrier team.
Remove process from the DLB Barrier team. Subsequent calls to DLB_Barrier from this process will have no effect. Other processes in the team will not synchronize with this process on their respective calls to DLB_Barrier.
| DLB_EXPORT_SYMBOL dlb_barrier_t * DLB_BarrierNamedRegister | ( | const char * | barrier_name, |
| dlb_barrier_flags_t | flags | ||
| ) |
Register, or obtain, a named barrier.
| [in] | barrier_name | the name for the new barrier, or barrier to obtain |
| [in] | flags | barrier flags, see below |
This function registers a new barrier or obtains the pointer to an already created barrier with the same name. The returned pointer is an opaque handle to use in other named barrier functions. This functions allows the following flags: DLB_BARRIER_LEWI_ON: the barrier may be used to perform LeWI operations DLB_BARRIER_LEWI_OFF: the barrier will not be used to perform LeWI operations DLB_BARRIER_LEWI_RUNTIME: whether this barrier will be used for LewI operations will be decided at run time
Names with commas (,) are supported, but will not work properly when using the –lewi-barrier-select option to select LeWI barriers at run time.
Note: DLB_BarrierNamedRegister and DLB_BarrierNamedGet are equivalent.
| DLB_EXPORT_SYMBOL DLB_ALIAS | ( | dlb_barrier_t * | , |
| DLB_BarrierNamedGet | , | ||
| (const char *barrier_name, dlb_barrier_flags_t flags) | , | ||
| (barrier_name, flags) | , | ||
| DLB_BarrierNamedRegister | |||
| ) |
| DLB_EXPORT_SYMBOL int DLB_BarrierNamedAttach | ( | dlb_barrier_t * | barrier | ) |
Attach process to the named barrier team.
| [in] | barrier | named barrier to attach to |
This function is equivalent to DLB_BarrierAttach, but providing a named barrier
| DLB_EXPORT_SYMBOL int DLB_BarrierNamedDetach | ( | dlb_barrier_t * | barrier | ) |
Detach process from the named barrier team.
| [in] | barrier | named barrier to detach from |
This function is equivalent to DLB_BarrierDetach, but providing a named barrier
| DLB_EXPORT_SYMBOL int DLB_SetVariable | ( | const char * | variable, |
| const char * | value | ||
| ) |
Change the value of a DLB internal variable.
| [in] | variable | Internal variable to set |
| [in] | value | New value |
Set a DLB internal variable. These variables are the same ones specified in DLB_ARGS, although not all of them can be modified at runtime. If the variable is readonly the setter function will return an error.
| DLB_EXPORT_SYMBOL int DLB_GetVariable | ( | const char * | variable, |
| char * | value | ||
| ) |
Query the value of a DLB internal variable.
| [in] | variable | Internal variable to set |
| [out] | value | Current DLB variable value |
Get a DLB internal variable. See DLB_SetVariable().
| DLB_EXPORT_SYMBOL int DLB_PrintVariables | ( | int | print_extended | ) |
Print DLB internal variables.
| [in] | print_extended | If different to 0, print all options, including experimental, and its description |
| DLB_EXPORT_SYMBOL int DLB_PrintShmem | ( | int | num_columns, |
| dlb_printshmem_flags_t | print_flags | ||
| ) |
Print the data stored in the shmem.
| [in] | num_columns | Number of columns to use when printing |
| [in] | print_flags | Print options |
| DLB_EXPORT_SYMBOL const char * DLB_Strerror | ( | int | errnum | ) |
Obtain a pointer to a string that describes the error code passed by argument.
| [in] | errnum | error code to consult |
| DLB_EXPORT_SYMBOL int DLB_SetObserverRole | ( | bool | thread_is_observer | ) |
Modify the current thread DLB role to either observer or particpant.
| [in] | thread_is_observer | true to set current thread to 'observer', false to 'participant' |
By default, all threads are DLB participants, meaning that they invoke LeWI when needed or measure performance metrics when TALP is enabled. A thread that sets its role to 'observer' will still be able to invoke MPI calls or TALP functions, including managing monitoring regions, but it will not trigger LeWI nor any TALP measuring metrics.
| DLB_EXPORT_SYMBOL int DLB_GetVersion | ( | int * | major, |
| int * | minor, | ||
| int * | patch | ||
| ) |
Return the DLB version.
| [out] | major | major version number |
| [out] | minor | minor version number |
| [out] | patch | patch version number |
| DLB_EXPORT_SYMBOL int DLB_GetGPUAffinity | ( | char * | buffer, |
| size_t | buffer_size, | ||
| bool | full_uuid | ||
| ) |