Dynamic Load Balance 3.6.1+32-59d1
Functions
DLB_interface.c File Reference
#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>
Include dependency graph for DLB_interface.c:

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_tDLB_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)
 

Function Documentation

◆ __attribute__()

__attribute__ ( (constructor)  )

◆ DLB_Init()

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.

Parameters
[in]ncpusoptional, initial number of CPUs, or 0
[in]maskoptional, initial CPU mask to register, or NULL
[in]dlb_argsoptional parameter to overwrite DLB_ARGS options, or NULL
Returns
DLB_SUCCESS on success
DLB_ERR_INIT if DLB is already initialized
DLB_ERR_PERM if DLB cannot register the mask passed by argument
DLB_ERR_NOMEM if DLB cannot allocate more processes
DLB_ERR_NOCOMP if initialization options are incompatible

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_Finalize()

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.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if DLB is not initialized

◆ DLB_PreInit()

DLB_EXPORT_SYMBOL int DLB_PreInit ( const_dlb_cpu_set_t  mask,
char ***  next_environ 
)

Pre-Initialize process.

Parameters
[in]maskinitial CPU mask to register
[in,out]next_environenvironment to modify if the process is going to fork-exec
Returns
DLB_SUCCESS on success
DLB_ERR_PERM if DLB cannot register the mask passed by argument
DLB_ERR_NOMEM if DLB cannot allocate more processes

◆ DLB_Enable()

DLB_EXPORT_SYMBOL int DLB_Enable ( void  )

Enable DLB and all its features in case it was previously disabled, otherwise it has no effect.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if DLB is already enabled
DLB_ERR_NOINIT if DLB is not initialized

It can be used in conjunction with DLB_Disable() to delimit sections of the code where DLB calls will not have effect.

◆ DLB_Disable()

DLB_EXPORT_SYMBOL int DLB_Disable ( void  )

Disable DLB actions for the calling process.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if DLB is already disabled
DLB_ERR_NOINIT if DLB is not initialized

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_SetMaxParallelism()

DLB_EXPORT_SYMBOL int DLB_SetMaxParallelism ( int  max)

Set the maximum number of resources to be used by the calling process.

Parameters
[in]maxmax number of CPUs
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled

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_UnsetMaxParallelism()

DLB_EXPORT_SYMBOL int DLB_UnsetMaxParallelism ( void  )

Unset the maximum number of resources to be used by the calling process.

Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled

Unset the maximum number of CPUs previously assigned to this process. Subsequent calls to borrow will not be delimited by this parameter.

◆ DLB_CallbackSet()

DLB_EXPORT_SYMBOL int DLB_CallbackSet ( dlb_callbacks_t  which,
dlb_callback_t  callback,
void *  arg 
)

Setter for DLB callbacks.

Parameters
[in]whichcallback type
[in]callbackfunction pointer to register
[in]argopaque argument to pass in each callback invocation
Returns
DLB_SUCCESS on success
DLB_ERR_NOCBK if the callback type does not exist

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_CallbackGet()

DLB_EXPORT_SYMBOL int DLB_CallbackGet ( dlb_callbacks_t  which,
dlb_callback_t callback,
void **  arg 
)

Getter for DLB callbacks.

Parameters
[in]whichcallback type
[out]callbackregistered callback function for the specified callback type
[out]argopaque argument to pass in each callback invocation
Returns
DLB_SUCCESS on success
DLB_ERR_NOCBK if the callback type does not exist

Obtain the previously registered callback and arg for the specified which callback type.

◆ DLB_Lend()

DLB_EXPORT_SYMBOL int DLB_Lend ( void  )

Lend all the current CPUs.

Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

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_LendCpu()

DLB_EXPORT_SYMBOL int DLB_LendCpu ( int  cpuid)

Lend a specific CPU.

Parameters
[in]cpuidCPU id to lend
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

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_LendCpus()

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.

Parameters
[in]ncpusnumber of CPUs to lend
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

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_LendCpuMask()

DLB_EXPORT_SYMBOL int DLB_LendCpuMask ( const_dlb_cpu_set_t  mask)

Lend a set of CPUs.

Parameters
[in]maskCPU mask to lend
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

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_Reclaim()

DLB_EXPORT_SYMBOL int DLB_Reclaim ( void  )

Reclaim all the CPUs that are owned by the process.

Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if there is no CPUs to reclaim
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.

◆ DLB_ReclaimCpu()

DLB_EXPORT_SYMBOL int DLB_ReclaimCpu ( int  cpuid)

Reclaim a specific CPU that are owned by the process.

Parameters
[in]cpuidCPU id to reclaim
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if there is no CPUs to reclaim
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be reclaimed

Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.

◆ DLB_ReclaimCpus()

DLB_EXPORT_SYMBOL int DLB_ReclaimCpus ( int  ncpus)

Reclaim a specific amount of CPUs that are owned by the process.

Parameters
[in]ncpusNumber of CPUs to reclaim
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if there is no CPUs to reclaim
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.

◆ DLB_ReclaimCpuMask()

DLB_EXPORT_SYMBOL int DLB_ReclaimCpuMask ( const_dlb_cpu_set_t  mask)

Reclaim a set of CPUs.

Parameters
[in]maskCPU mask to reclaim
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if there is no CPUs to reclaim
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be reclaimed

Reclaim CPUs that were previously lent. The CPUs must originally belong to the calling process.

◆ DLB_AcquireCpu()

DLB_EXPORT_SYMBOL int DLB_AcquireCpu ( int  cpuid)

Acquire a specific CPU.

Parameters
[in]cpuidCPU to acquire
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if the CPU is already acquired
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be acquired
DLB_ERR_REQST if there are too many requests for this resource

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_AcquireCpus()

DLB_EXPORT_SYMBOL int DLB_AcquireCpus ( int  ncpus)

Acquire a specific amount of CPUs.

Parameters
[in]ncpusNumber of CPUs to acquire
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if cannot acquire any CPU
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_REQST if there are too many requests for this resource

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_MAX_CPUS: add a request for the maximum amount of resources.
  • DLB_DELETE_REQUESTS: delete previous requests

◆ DLB_AcquireCpuMask()

DLB_EXPORT_SYMBOL int DLB_AcquireCpuMask ( const_dlb_cpu_set_t  mask)

Acquire a set of CPUs.

Parameters
[in]maskCPU set to acquire
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if cannot acquire any CPU
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be acquired
DLB_ERR_REQST if there are too many requests for these resources

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_AcquireCpusInMask()

DLB_EXPORT_SYMBOL int DLB_AcquireCpusInMask ( int  ncpus,
const_dlb_cpu_set_t  mask 
)

Acquire some CPUs from a subset of CPUs.

Parameters
[in]ncpusNumber of CPUs to acquire
[in]maskCPU set to acquire from
Returns
DLB_SUCCESS on success
DLB_NOTED if the petition cannot be immediately fulfilled
DLB_NOUPDT if cannot acquire any CPU
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be acquired
DLB_ERR_REQST if there are too many requests for these resources

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_Borrow()

DLB_EXPORT_SYMBOL int DLB_Borrow ( void  )

Borrow all the possible CPUs registered on DLB.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if cannot borrow any resources
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.

◆ DLB_BorrowCpu()

DLB_EXPORT_SYMBOL int DLB_BorrowCpu ( int  cpuid)

Borrow a specific CPU.

Parameters
[in]cpuidcpu CPU to borrow
Returns
DLB_SUCCESS on success
DLB_NOUPDT if CPU cannot borrowed
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.

◆ DLB_BorrowCpus()

DLB_EXPORT_SYMBOL int DLB_BorrowCpus ( int  ncpus)

Borrow a specific amount of CPUs.

Parameters
[in]ncpusNumber of CPUs to borrow
Returns
DLB_SUCCESS on success
DLB_NOUPDT if cannot borrow any resources
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.

◆ DLB_BorrowCpuMask()

DLB_EXPORT_SYMBOL int DLB_BorrowCpuMask ( const_dlb_cpu_set_t  mask)

Borrow a set of CPUs.

Parameters
[in]maskCPU set to borrow
Returns
DLB_SUCCESS on success
DLB_NOUPDT if cannot borrow any resources
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.

◆ DLB_BorrowCpusInMask()

DLB_EXPORT_SYMBOL int DLB_BorrowCpusInMask ( int  ncpus,
const_dlb_cpu_set_t  mask 
)

Borrow some CPUs from a subset of CPUs.

Parameters
[in]ncpusNumber of CPUs to borrow
[in]maskCPU set to borrow from
Returns
DLB_SUCCESS on success
DLB_NOUPDT if cannot borrow any resources
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled

Borrow CPUs from the system only if they are idle. No other action is done if the CPU is not available.

◆ DLB_Return()

DLB_EXPORT_SYMBOL int DLB_Return ( void  )

Return claimed CPUs of other processes.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if no need to return
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be returned
DLB_ERR_NOCOMP if the mode asynchronous is enabled

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_ReturnCpu()

DLB_EXPORT_SYMBOL int DLB_ReturnCpu ( int  cpuid)

Return the specific CPU if it has been reclaimed.

Parameters
[in]cpuidCPU to return
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be returned

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_ReturnCpuMask()

DLB_EXPORT_SYMBOL int DLB_ReturnCpuMask ( const_dlb_cpu_set_t  mask)

Return a set of CPUs if some of them have been reclaimed.

Parameters
[in]maskCPU set to return
Returns
DLB_SUCCESS on success
DLB_ERR_NOINIT if DLB is not initialized
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_DISBLD if DLB is disabled
DLB_ERR_PERM if the resources cannot be returned

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_PollDROM()

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.

Parameters
[out]ncpusoptional, variable to receive the new number of CPUs
[out]maskoptional, variable to receive the new mask
Returns
DLB_SUCCESS on success
DLB_NOUPDT if no update id needed
DLB_ERR_NOCOMP if DROM is not enabled (option –drom)

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_PollDROM_Update()

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.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if no update id needed
DLB_ERR_NOCOMP if DROM is not enabled (option –drom)

Same as DLB_PollDROM(), but calling the registered callbacks to update the ownership info instead of returning the data by argument.

◆ DLB_CheckCpuAvailability()

DLB_EXPORT_SYMBOL int DLB_CheckCpuAvailability ( int  cpuid)

Check whether the specified CPU is being used by another process.

Parameters
[in]cpuidCPU to be checked
Returns
DLB_SUCCESS if the CPU is available
DLB_NOTED if the CPU is owned but still guested by other process
DLB_NOUPDT if the CPU is owned but still not reclaimed
DLB_ERR_NOLEWI if –lewi is not enabled
DLB_ERR_PERM if the CPU cannot be acquired or has been disabled
DLB_ERR_DISBLD if DLB is disabled

◆ DLB_Barrier()

DLB_EXPORT_SYMBOL int DLB_Barrier ( void  )

Perform a DLB Barrier among processes in the node.

Returns
DLB_SUCCESS on success
DLB_NOUPDT if the process has detached from the default barrier
DLB_ERR_NOCOMP if DLB Barrier is not enabled (option –barrier)

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_BarrierAttach()

DLB_EXPORT_SYMBOL int DLB_BarrierAttach ( void  )

Attach process to the DLB Barrier team.

Returns
a positive integer with the updated number of participants
DLB_ERR_PERM if process was already attached, or if all processes detached
DLB_ERR_NOMEM if the process cannot attach to more barriers
DLB_ERR_NOCOMP if DLB Barrier is not enabled (option –barrier)
DLB_ERR_NOSHMEM if cannot find shared memory

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_BarrierDetach()

DLB_EXPORT_SYMBOL int DLB_BarrierDetach ( void  )

Detach process from the DLB Barrier team.

Returns
a non-negative integer with the updated number of participants
DLB_ERR_PERM if process was already detached
DLB_ERR_NOCOMP if DLB Barrier is not enabled (option –barrier)
DLB_ERR_NOSHMEM if cannot find shared memory

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_BarrierNamedRegister()

DLB_EXPORT_SYMBOL dlb_barrier_t * DLB_BarrierNamedRegister ( const char *  barrier_name,
dlb_barrier_flags_t  flags 
)

Register, or obtain, a named barrier.

Parameters
[in]barrier_namethe name for the new barrier, or barrier to obtain
[in]flagsbarrier flags, see below
Returns
barrier associated to that name, or NULL on error

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_ALIAS()

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_BarrierNamedAttach()

DLB_EXPORT_SYMBOL int DLB_BarrierNamedAttach ( dlb_barrier_t barrier)

Attach process to the named barrier team.

Parameters
[in]barriernamed barrier to attach to
Returns
a positive integer with the updated number of participants
DLB_NOUPDT if process was already attached
DLB_ERR_NOCOMP if DLB Barrier is not enabled (option –barrier)
DLB_ERR_NOSHMEM if cannot find shared memory

This function is equivalent to DLB_BarrierAttach, but providing a named barrier

◆ DLB_BarrierNamedDetach()

DLB_EXPORT_SYMBOL int DLB_BarrierNamedDetach ( dlb_barrier_t barrier)

Detach process from the named barrier team.

Parameters
[in]barriernamed barrier to detach from
Returns
a non-negative integer with the updated number of participants
DLB_NOUPDT if process was already detached
DLB_ERR_NOCOMP if DLB Barrier is not enabled (option –barrier)
DLB_ERR_NOSHMEM if cannot find shared memory
DLB_ERR_PERM if all processes have detached from the barrier

This function is equivalent to DLB_BarrierDetach, but providing a named barrier

◆ DLB_SetVariable()

DLB_EXPORT_SYMBOL int DLB_SetVariable ( const char *  variable,
const char *  value 
)

Change the value of a DLB internal variable.

Parameters
[in]variableInternal variable to set
[in]valueNew value
Returns
DLB_SUCCESS on success
DLB_ERR_PERM if the variable is readonly
DLB_ERR_NOENT if the variable does not exist

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_GetVariable()

DLB_EXPORT_SYMBOL int DLB_GetVariable ( const char *  variable,
char *  value 
)

Query the value of a DLB internal variable.

Parameters
[in]variableInternal variable to set
[out]valueCurrent DLB variable value
Returns
DLB_SUCCESS on success
DLB_ERR_NOENT if the variable does not exist

Get a DLB internal variable. See DLB_SetVariable().

◆ DLB_PrintVariables()

DLB_EXPORT_SYMBOL int DLB_PrintVariables ( int  print_extended)

Print DLB internal variables.

Parameters
[in]print_extendedIf different to 0, print all options, including experimental, and its description
Returns
DLB_SUCCESS on success

◆ DLB_PrintShmem()

DLB_EXPORT_SYMBOL int DLB_PrintShmem ( int  num_columns,
dlb_printshmem_flags_t  print_flags 
)

Print the data stored in the shmem.

Parameters
[in]num_columnsNumber of columns to use when printing
[in]print_flagsPrint options
Returns
DLB_SUCCESS on success

◆ DLB_Strerror()

DLB_EXPORT_SYMBOL const char * DLB_Strerror ( int  errnum)

Obtain a pointer to a string that describes the error code passed by argument.

Parameters
[in]errnumerror code to consult
Returns
pointer to string with the error description

◆ DLB_SetObserverRole()

DLB_EXPORT_SYMBOL int DLB_SetObserverRole ( bool  thread_is_observer)

Modify the current thread DLB role to either observer or particpant.

Parameters
[in]thread_is_observertrue to set current thread to 'observer', false to 'participant'
Returns
DLB_SUCCESS on success

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_GetVersion()

DLB_EXPORT_SYMBOL int DLB_GetVersion ( int *  major,
int *  minor,
int *  patch 
)

Return the DLB version.

Parameters
[out]majormajor version number
[out]minorminor version number
[out]patchpatch version number
Returns
DLB_SUCCESS on success

◆ DLB_GetGPUAffinity()

DLB_EXPORT_SYMBOL int DLB_GetGPUAffinity ( char *  buffer,
size_t  buffer_size,
bool  full_uuid 
)