ALP User Documentation
0.8.preview
Algebraic Programming User Documentation
|
A group of user processes that together execute ALP programs. More...
Public Member Functions | |
Launcher (const size_t process_id=0, const size_t nprocs=1, const std::string hostname="localhost", const std::string port="0") | |
Constructs a new grb::Launcher. More... | |
template<typename T , typename U > | |
RC | exec (AlpTypedFunc< T, U > alp_program, const T &data_in, U &data_out, const bool broadcast=false) const |
Executes a given ALP program using the user processes encapsulated by this launcher group. More... | |
template<typename U > | |
RC | exec (AlpUntypedFunc< U > alp_program, const void *data_in, const size_t in_size, U &data_out, const bool broadcast=false) const |
Executes a given ALP program using the user processes encapsulated by this launcher group. More... | |
Static Public Member Functions | |
static RC | finalize () |
Releases all ALP resources. More... | |
A group of user processes that together execute ALP programs.
Allows an application to run any ALP program. Input data may be passed through a user-defined type. Output data will be retrieved via another user- defined type.
For backends that support multiple user processes, the caller may explicitly set the process ID and total number of user processes. If the launcher is requested to spawn new user processes, i.e., if it is constructed using the AUTOMATIC mode, then the backend spawns an implementation-defined number of additional user processes beyond that corresponding to the process constructing the launcher instance, that then jointly execute ALP programs in parallel.
The intended use is to ‘just call’ the exec function, which must be accepted by any backend in any implementation, to execute any ALP program.
|
inline |
Constructs a new grb::Launcher.
In AUTOMATIC mode, a single root user processes issues a call to this constructor. In all other modes, a call to this constructor is collective: all nprocs processes that are to form a single launcher group, must make a simultaneous call to this constructor and must do so with consistent arguments.
There is an implementation-defined time-out for the creation of a launcher group. The default arguments to the below are consistent with the automatic launcher mode.
[in] | process_id | The user process ID of the calling process. The value must be larger or equal to 0. This value must be strictly smaller than nprocs. This value must be unique to the calling process within this collective call across all nprocs user processes. This number must be strictly smaller than nprocs. Optional: the default is 0. |
[in] | nprocs | The total number of user processes making a collective call to this function. Optional: the default is 1. |
[in] | hostname | The hostname of one of the user processes. Optional: the default is ‘localhost’. |
[in] | port | A free port number at hostname. This port will be used for TCP connections to hostname if and only if nprocs is larger than one. Optional: the default value is ‘0’. |
While these arguments are generic and would work with most network fabrics, some modes such as indeed FROM_MPI may require other arguments for constructing a launcher. In terms of specification, only AUTOMATIC and MANUAL are required to implement this specific constructor signature, including the specified defaults for each argument. All aforementioned default values must be legal for the AUTOMATIC and MANUAL modes.
Any other mode in grb::EXEC_MODE, with possibly different constructor signatures from those listed here, are both optional and implementation- specific.
invalid_argument | If nprocs is zero. |
invalid_argument | If process_id is greater than or equal to nprocs. |
std::invalid_argument | If nprocs is zero. |
std::invalid_argument | If process_id is larger than or equal to nprocs. |
|
inline |
Executes a given ALP program using the user processes encapsulated by this launcher group.
Calling this function, depending on whether the automatic, manual, or from MPI mode was selected, will either:
This is a collective function call– all processes in the launcher group must make a simultaneous call to this function and must do so using consistent arguments.
T | The type of the data to pass to the ALP program as input. This must be a POD type that contains no pointers. |
For calls with broadcast false
, T must furthermore be default-constructible (and have meaningful default values that allow for successful multi-process execution).
For programs or entry points that are solely to be called from manual or from MPI modes with broadcast false
, there are no constraints on the type T since instances of T are only ever passed within the pre-existing user process, and never communicated across user processes.
U | The type of the output data to pass back to the caller. This may be of any type. |
When mode is AUTOMATIC, the type U must be default-constructible.
[in] | alp_program | The user program to be executed. |
[in] | data_in | Input data of user-defined type T. |
[out] | data_out | Output data of user-defined type U. |
[in] | broadcast | Whether the input should be broadcast from user process 0 to all other user processes. Optional; the default value is false . |
When in automatic mode and broadcast is false
, the input data data_in will only be available at user process with ID 0– any other user processes will receive a default-constructed data_in instead. When in automatic mode and broadcast is true
, the input data data_in will be available at all user processes instead.
When in MANUAL or FROM_MPI mode, each user process should collectively call this function. If broadcast is false
, the input data will be passed from the external calling process to the corresponding ALP user processes in a one-to-one manner. Should broadcast be true
, then the initial input data passed this way is overwritten for user processes \( s > 0 \) with the data_in passed at user process zero.
Only in MANUAL or FROM_MPI modes will the output of any user processes with ID \( s > 0 \) be returned to all the processes that collectively call this function.
In AUTOMATIC mode, the output at \( s > 0 \) is lost. Only the output of the first user process \( s = 0 \) will be passed back to the root process that called this function.
false
as it is the variant that implies the least cost when launching a program.false
and mode was AUTOMATIC, but T not default-constructible. int
or grb::RC), or that b) U is a struct that contains such an error code.
|
inline |
Executes a given ALP program using the user processes encapsulated by this launcher group.
This variant of exec has that data_in is of a variable byte size, instead of a fixed (POD pointer-less) type. We refer to the given function as an untyped ALP function (since the input is a raw pointer), whereas the other variant executes typed ALP functions instead.
If broadcast is true
, all bytes are broadcast from the user process with ID zero to all other user processes.
If broadcast is false
and the launcher in AUTOMATIC mode, then the user processes with ID \( s > 0 \) will receive data_in equal to nullptr
and in_size equal to zero.
See the typed ALP exec variant for more detailed comments, which also transfer to this untyped variant.
[in] | alp_program | The (untyped) user program to be executed. |
[in] | data_in | Pointer to raw input byte data. |
[in] | in_size | The number of bytes the input data consists of. |
[out] | data_out | Output data of user-defined type U. The output data should be available at user process with ID zero. |
[in] | broadcast | Whether the input should be broadcast from user process 0 to all other user processes. Optional; the default value is false. |
nullptr
.
|
inlinestatic |
Releases all ALP resources.
After a call to this function, no further ALP programs may launched using any grb::Launcher or grb::Benchmarker instance. Implementations and backends shall under no circumstance require a call to this function; any use of this function shall remain purely optional.
After a call to this function, the only way to once again run ALP programs is to use the grb::Launcher from a different process.
MPI_Finalize()
.MPI_Finalize()
.