ALP User Documentation 0.7.0
Algebraic Programming User Documentation
Public Member Functions | Static Public Member Functions | List of all members
Benchmarker< mode, implementation > Class Template Reference

A class that follows the API of the grb::Launcher, but instead of launching the given ALP program once, it launches it multiple times while benchmarking its execution times. More...

#include <benchmark.hpp>

Public Member Functions

 Benchmarker (const size_t process_id=0, size_t nprocs=1, std::string hostname="localhost", std::string port="0")
 Constructs an instance of the benchmarker class. More...
 
template<typename T , typename U >
RC exec (void(*alp_program)(const T &, U &), const T &data_in, U &data_out, const size_t inner, const size_t outer, const bool broadcast=false) const
 Benchmarks a given ALP program. More...
 
template<typename U >
RC exec (void(*alp_program)(const void *, const size_t, U &), const void *data_in, const size_t in_size, U &data_out, const size_t inner, const size_t outer, const bool broadcast=false) const
 Benchmarks a given ALP program. More...
 

Static Public Member Functions

static RC finalize ()
 Releases all ALP resources. More...
 

Detailed Description

template<enum EXEC_MODE mode, enum Backend implementation>
class grb::Benchmarker< mode, implementation >

A class that follows the API of the grb::Launcher, but instead of launching the given ALP program once, it launches it multiple times while benchmarking its execution times.

See also
Benchmarking

Constructor & Destructor Documentation

◆ Benchmarker()

Benchmarker ( const size_t  process_id = 0,
size_t  nprocs = 1,
std::string  hostname = "localhost",
std::string  port = "0" 
)
inline

Constructs an instance of the benchmarker class.

Parameters
[in]process_idA unique ID for the calling user process.
[in]nprocsThe total number of user processes participating in the benchmark. The given process_id must be strictly smaller than this given value.
[in]hostnameThe hostname where one of the user processes participating in the benchmark resides.
[in]portA free TCP/IP port at the host corresponding to the given hostname.

The hostname and port arguments are unused if nprocs equals one.

All arguments are optional– their defaults are:

  • 0 for process_id,
  • 1 for nprocs,
  • localhost for hostname, and
  • 0 for port.

This constructor may throw the same errors as grb::Launcher.

See also
grb::Launcher
Benchmarking

Member Function Documentation

◆ exec() [1/2]

RC exec ( void(*)(const T &, U &)  alp_program,
const T &  data_in,
U &  data_out,
const size_t  inner,
const size_t  outer,
const bool  broadcast = false 
) const
inline

Benchmarks a given ALP program.

This variant applies to input data as a user-defined POD struct and output data as a user-defined POD struct.

Template Parameters
TInput type of the given user program.
UOutput type of the given user program.
Parameters
[in]alp_programThe ALP program to be benchmarked
[in]data_inInput data as a raw data blob
[out]data_outOutput data
[in]innerThe number of inner repetitions of the benchmark
[in]outerThe number of outer repetitions of the benchmark
[in]broadcastAn optional argument that dictates whether the data_in argument should be broadcast across all user processes participating in the benchmark, prior to each invocation of alp_program.

The default value of broadcast is false.

Returns
grb::SUCCESS The benchmarking has completed successfully.
grb::FAILED An error during benchmarking has occurred. The benchmark attempt could be retried, and an error for the failure is reported to the standard error stream.
grb::PANIC If an unrecoverable error was encountered while starting the benchmark, while benchmarking, or while aggregating the final results.
See also
Benchmarking

◆ exec() [2/2]

RC exec ( void(*)(const void *, const size_t, U &)  alp_program,
const void *  data_in,
const size_t  in_size,
U &  data_out,
const size_t  inner,
const size_t  outer,
const bool  broadcast = false 
) const
inline

Benchmarks a given ALP program.

This variant applies to input data as a byte blob and output data as a user-defined POD struct.

Template Parameters
UOutput type of the given user program.
Parameters
[in]alp_programThe use rogram to be benchmarked
[in]data_inInput data as a raw data blob
[in]in_sizeThe size, in bytes, of the input data
[out]data_outOutput data
[in]innerThe number of inner repetitions of the benchmark
[in]outerThe number of outer repetitions of the benchmark
[in]broadcastAn optional argument that dictates whether the data_in argument should be broadcast across all user processes participating in the benchmark, prior to each invocation of alp_program.

The default value of broadcast is false.

Returns
grb::SUCCESS The benchmarking has completed successfully.
grb::ILLEGAL If in_size is nonzero but data_in compares equal to nullptr.
grb::FAILED An error during benchmarking has occurred. The benchmark attempt could be retried, and an error for the failure is reported to the standard error stream.
grb::PANIC If an unrecoverable error was encountered while starting the benchmark, while benchmarking, or while aggregating the final results.
See also
Benchmarking

◆ finalize()

static RC finalize ( )
inlinestatic

Releases all ALP resources.

Calling this function is equivalent to calling grb::Launcher::finalize.

After a call to this function, no further ALP programs may be benchmarked nor launched– i.e., both the grb::Launcher and grb::Benchmarker functionalities many no longer be used.

A well-behaving program calls this function, or grb::Launcher::finalize, exactly once and just before exiting (or just before the guaranteed last invocation of an ALP program).

Returns
grb::SUCCESS The resources have successfully and permanently been released.
grb::PANIC An unrecoverable error has been encountered and the user program is encouraged to exit as quickly as possible. The state of the ALP library has become undefined and should no longer be used.

The documentation for this class was generated from the following file: