|
Dynamic Load Balance 3.6.1+32-59d1
|
#include "apis/dlb_sp.h"#include "LB_core/spd.h"#include "LB_core/DLB_kernel.h"#include "support/atomic.h"#include "support/dlb_common.h"#include <stdlib.h>#include <unistd.h>
Functions | |
| DLB_EXPORT_SYMBOL dlb_handler_t | DLB_Init_sp (int ncpus, const_dlb_cpu_set_t mask, const char *dlb_args) |
| Initialize DLB library and all its internal data structures. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Finalize_sp (dlb_handler_t handler) |
| Finalize DLB library and clean up all its data structures for the specified handler. Must be called once by each created handler before exiting the system. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Enable_sp (dlb_handler_t handler) |
| Enable DLB and all its features in case it was previously disabled, otherwise it has no effect. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Disable_sp (dlb_handler_t handler) |
| Disable DLB actions for the specified handler. More... | |
| DLB_EXPORT_SYMBOL int | DLB_SetMaxParallelism_sp (dlb_handler_t handler, int max) |
| Set the maximum number of resources to be used by the handler. More... | |
| DLB_EXPORT_SYMBOL int | DLB_UnsetMaxParallelism_sp (dlb_handler_t handler) |
| Unset the maximum number of resources to be used by the handler. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CallbackSet_sp (dlb_handler_t handler, dlb_callbacks_t which, dlb_callback_t callback, void *arg) |
| Setter for DLB callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CallbackGet_sp (dlb_handler_t handler, dlb_callbacks_t which, dlb_callback_t *callback, void **arg) |
| Getter for DLB callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Lend_sp (dlb_handler_t handler) |
| Lend all the current CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_LendCpu_sp (dlb_handler_t handler, int cpuid) |
| Lend a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_LendCpus_sp (dlb_handler_t handler, 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_sp (dlb_handler_t handler, const_dlb_cpu_set_t mask) |
| Lend a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Reclaim_sp (dlb_handler_t handler) |
| Reclaim all the CPUs that are owned by the subprocess. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpu_sp (dlb_handler_t handler, int cpuid) |
| Reclaim a specific CPU that are owned by the subprocess. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpus_sp (dlb_handler_t handler, int ncpus) |
| Reclaim a specific amount of CPUs that are owned by the subprocess. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReclaimCpuMask_sp (dlb_handler_t handler, const_dlb_cpu_set_t mask) |
| Reclaim a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpu_sp (dlb_handler_t handler, int cpuid) |
| Acquire a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpus_sp (dlb_handler_t handler, int ncpus) |
| Acquire a specific amount of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpuMask_sp (dlb_handler_t handler, const_dlb_cpu_set_t mask) |
| Acquire a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_AcquireCpusInMask_sp (dlb_handler_t handler, int ncpus, const_dlb_cpu_set_t mask) |
| Acquire some CPUs from a subset of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Borrow_sp (dlb_handler_t handler) |
| Borrow all the possible CPUs registered on DLB. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpu_sp (dlb_handler_t handler, int cpuid) |
| Borrow a specific CPU. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpus_sp (dlb_handler_t handler, int ncpus) |
| Borrow a specific amount of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpuMask_sp (dlb_handler_t handler, const_dlb_cpu_set_t mask) |
| Borrow a set of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_BorrowCpusInMask_sp (dlb_handler_t handler, int ncpus, const_dlb_cpu_set_t mask) |
| Borrow some CPUs from a subset of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_Return_sp (dlb_handler_t handler) |
| Return claimed CPUs of other subprocesses. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReturnCpu_sp (dlb_handler_t handler, int cpuid) |
| Return the specific CPU if it has been reclaimed. More... | |
| DLB_EXPORT_SYMBOL int | DLB_ReturnCpuMask_sp (dlb_handler_t handler, 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_sp (dlb_handler_t handler, int *ncpus, dlb_cpu_set_t mask) |
| Poll DROM module to check if the subprocess needs to adapt to a new mask or number of CPUs. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PollDROM_Update_sp (dlb_handler_t handler) |
| Poll DROM module to check if the subprocess needs to adapt to a new mask and update it if necessary using the registered callbacks. More... | |
| DLB_EXPORT_SYMBOL int | DLB_CheckCpuAvailability_sp (dlb_handler_t handler, int cpuid) |
| Check whether the specified CPU is being used by another subprocess. More... | |
| DLB_EXPORT_SYMBOL int | DLB_SetVariable_sp (dlb_handler_t handler, const char *variable, const char *value) |
| Change the value of a DLB internal variable. More... | |
| DLB_EXPORT_SYMBOL int | DLB_GetVariable_sp (dlb_handler_t handler, const char *variable, char *value) |
| Query the value of a DLB internal variable. More... | |
| DLB_EXPORT_SYMBOL int | DLB_PrintVariables_sp (dlb_handler_t handler, int print_extended) |
| Print DLB internal variables. More... | |
| DLB_EXPORT_SYMBOL dlb_handler_t DLB_Init_sp | ( | int | ncpus, |
| const_dlb_cpu_set_t | mask, | ||
| const char * | dlb_args | ||
| ) |
Initialize DLB library and all its internal data structures.
| [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 subprocess into the system. DLB advanced usage requires mask information so it is recommended to provide a CPU mask, but DLB also accepts an integer in case the program does not have the mask affinity details. Parameter dlb_args can be used in conjunction with DLB_ARGS, the former takes precedence in case of conflicting options.
| DLB_EXPORT_SYMBOL int DLB_Finalize_sp | ( | dlb_handler_t | handler | ) |
Finalize DLB library and clean up all its data structures for the specified handler. Must be called once by each created handler before exiting the system.
| [in] | handler | subprocess identifier |
| DLB_EXPORT_SYMBOL int DLB_Enable_sp | ( | dlb_handler_t | handler | ) |
Enable DLB and all its features in case it was previously disabled, otherwise it has no effect.
| [in] | handler | subprocess identifier |
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_sp | ( | dlb_handler_t | handler | ) |
Disable DLB actions for the specified handler.
| [in] | handler | subprocess identifier |
This call resets the original resources for the subprocess 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 subprocess.
| DLB_EXPORT_SYMBOL int DLB_SetMaxParallelism_sp | ( | dlb_handler_t | handler, |
| int | max | ||
| ) |
Set the maximum number of resources to be used by the handler.
| [in] | handler | subprocess identifier |
| [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 subprocess 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_sp | ( | dlb_handler_t | handler | ) |
Unset the maximum number of resources to be used by the handler.
| [in] | handler | subprocess identifier |
Unset the maximum number of CPUs previously assigned to this subprocess. Subsequent calls to borrow will not be delimited by this parameter.
| DLB_EXPORT_SYMBOL int DLB_CallbackSet_sp | ( | dlb_handler_t | handler, |
| dlb_callbacks_t | which, | ||
| dlb_callback_t | callback, | ||
| void * | arg | ||
| ) |
Setter for DLB callbacks.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| dlb_callbacks_t | which, | ||
| dlb_callback_t * | callback, | ||
| void ** | arg | ||
| ) |
Getter for DLB callbacks.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler | ) |
Lend all the current CPUs.
| [in] | handler | subprocess identifier |
Lend CPUs of the subprocess to the system. A lent CPU may be assigned to other subprocess that demands more resources. If the CPU was originally owned by the subprocess it may be reclaimed.
| DLB_EXPORT_SYMBOL int DLB_LendCpu_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Lend a specific CPU.
| [in] | handler | subprocess identifier |
| [in] | cpuid | CPU id to lend |
Lend CPUs of the subprocess to the system. A lent CPU may be assigned to other subprocess that demands more resources. If the CPU was originally owned by the subprocess it may be reclaimed.
| DLB_EXPORT_SYMBOL int DLB_LendCpus_sp | ( | dlb_handler_t | handler, |
| int | ncpus | ||
| ) |
Lend a specific amount of CPUs, only useful for systems that do not work with cpu masks.
| [in] | handler | subprocess identifier |
| [in] | ncpus | number of CPUs to lend |
Lend CPUs of the subprocess to the system. A lent CPU may be assigned to other subprocess that demands more resources. If the CPU was originally owned by the subprocess it may be reclaimed.
| DLB_EXPORT_SYMBOL int DLB_LendCpuMask_sp | ( | dlb_handler_t | handler, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Lend a set of CPUs.
| [in] | handler | subprocess identifier |
| [in] | mask | CPU mask to lend |
Lend CPUs of the subprocess to the system. A lent CPU may be assigned to other subprocess that demands more resources. If the CPU was originally owned by the subprocess it may be reclaimed.
| DLB_EXPORT_SYMBOL int DLB_Reclaim_sp | ( | dlb_handler_t | handler | ) |
Reclaim all the CPUs that are owned by the subprocess.
| [in] | handler | subprocess identifier |
Reclaim CPUs that were previously lent. It is mandatory that the CPUs belong to the calling subprocess.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpu_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Reclaim a specific CPU that are owned by the subprocess.
| [in] | handler | subprocess identifier |
| [in] | cpuid | CPU id to reclaim |
Reclaim CPUs that were previously lent. It is mandatory that the CPUs belong to the calling subprocess.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpus_sp | ( | dlb_handler_t | handler, |
| int | ncpus | ||
| ) |
Reclaim a specific amount of CPUs that are owned by the subprocess.
| [in] | handler | subprocess identifier |
| [in] | ncpus | Number of CPUs to reclaim |
Reclaim CPUs that were previously lent. It is mandatory that the CPUs belong to the calling subprocess.
| DLB_EXPORT_SYMBOL int DLB_ReclaimCpuMask_sp | ( | dlb_handler_t | handler, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Reclaim a set of CPUs.
| [in] | handler | subprocess identifier |
| [in] | mask | CPU mask to reclaim |
Reclaim CPUs that were previously lent. It is mandatory that the CPUs belong to the calling subprocess.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpu_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Acquire a specific CPU.
| [in] | handler | subprocess identifier |
| [in] | cpuid | CPU to acquire |
Acquire CPUs from the system. If the CPU belongs to the subprocess the call is equivalent to a reclaim action. Otherwise the subprocess attempts to acquire a specific CPU in case it is available or enqueue a request if it's not.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpus_sp | ( | dlb_handler_t | handler, |
| int | ncpus | ||
| ) |
Acquire a specific amount of CPUs.
| [in] | handler | subprocess identifier |
| [in] | ncpus | Number of CPUs to acquire |
Acquire CPUs from the system. If the CPU belongs to the subprocess the call is equivalent to a reclaim action. Otherwise the subprocess attempts to acquire a specific CPU in case it is available or enqueue a request if it's not.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpuMask_sp | ( | dlb_handler_t | handler, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Acquire a set of CPUs.
| [in] | handler | subprocess identifier |
| [in] | mask | CPU set to acquire |
Acquire CPUs from the system. If the CPU belongs to the subprocess the call is equivalent to a reclaim action. Otherwise the subprocess attempts to acquire a specific CPU in case it is available or enqueue a request if it's not.
| DLB_EXPORT_SYMBOL int DLB_AcquireCpusInMask_sp | ( | dlb_handler_t | handler, |
| int | ncpus, | ||
| const_dlb_cpu_set_t | mask | ||
| ) |
Acquire some CPUs from a subset of CPUs.
| [in] | handler | subprocess identifier |
| [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 specific CPU in case it is available or enqueue a request if it's not.
| DLB_EXPORT_SYMBOL int DLB_Borrow_sp | ( | dlb_handler_t | handler | ) |
Borrow all the possible CPUs registered on DLB.
| [in] | handler | subprocess identifier |
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_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Borrow a specific CPU.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| int | ncpus | ||
| ) |
Borrow a specific amount of CPUs.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Borrow a set of CPUs.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| int | ncpus, | ||
| const_dlb_cpu_set_t | mask | ||
| ) |
Borrow some CPUs from a subset of CPUs.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler | ) |
Return claimed CPUs of other subprocesses.
| [in] | handler | subprocess identifier |
Return CPUs to the system commonly triggered by a reclaim action from other subprocess but stating that the current subprocess still demands the usage of these CPUs. This action will enqueue a request for when the resources are available again. If the caller does not want to keep the resource after receiving a reclaim, the correct action is lend.
| DLB_EXPORT_SYMBOL int DLB_ReturnCpu_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Return the specific CPU if it has been reclaimed.
| [in] | handler | subprocess identifier |
| [in] | cpuid | CPU to return |
Return CPUs to the system commonly triggered by a reclaim action from other subprocess but stating that the current subprocess still demands the usage of these CPUs. This action will enqueue a request for when the resources are available again. If the caller does not want to keep the resource after receiving a reclaim, the correct action is lend.
| DLB_EXPORT_SYMBOL int DLB_ReturnCpuMask_sp | ( | dlb_handler_t | handler, |
| const_dlb_cpu_set_t | mask | ||
| ) |
Return a set of CPUs if some of them have been reclaimed.
| [in] | handler | subprocess identifier |
| [in] | mask | CPU set to return |
Return CPUs to the system commonly triggered by a reclaim action from other subprocess but stating that the current subprocess still demands the usage of these CPUs. This action will enqueue a request for when the resources are available again. If the caller does not want to keep the resource after receiving a reclaim, the correct action is lend.
| DLB_EXPORT_SYMBOL int DLB_PollDROM_sp | ( | dlb_handler_t | handler, |
| int * | ncpus, | ||
| dlb_cpu_set_t | mask | ||
| ) |
Poll DROM module to check if the subprocess needs to adapt to a new mask or number of CPUs.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler | ) |
Poll DROM module to check if the subprocess needs to adapt to a new mask and update it if necessary using the registered callbacks.
| [in] | handler | subprocess identifier |
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_sp | ( | dlb_handler_t | handler, |
| int | cpuid | ||
| ) |
Check whether the specified CPU is being used by another subprocess.
| [in] | handler | subprocess identifier |
| [in] | cpuid | CPU to be checked |
| DLB_EXPORT_SYMBOL int DLB_SetVariable_sp | ( | dlb_handler_t | handler, |
| const char * | variable, | ||
| const char * | value | ||
| ) |
Change the value of a DLB internal variable.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| const char * | variable, | ||
| char * | value | ||
| ) |
Query the value of a DLB internal variable.
| [in] | handler | subprocess identifier |
| [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_sp | ( | dlb_handler_t | handler, |
| int | print_extended | ||
| ) |
Print DLB internal variables.
| [in] | handler | subprocess identifier |
| [in] | print_extended | If different to 0, print all options, including experimental, and its description |