Algorithm
Algorithm
Section titled “Algorithm”#include <xalgospp/algorithm.hh>template<class Derived, typename Tag = ncarray::HostTag>class AlgorithmDefined in src/lib/xalgospp/algorithm.hh:90
Subclassed by:
Calibration< Policy, MemTag >,Peakfinder8< MemTag >
Base Algorithm class.
All algorithms in XAlgosPP derive from this basic class. An Algorithm is simply a wrapper which consists of the following states/life-cycle stages:
-
Construction/configuration - The algorithm is setup with input parameters.
-
Staging [OPTIONAL] - The algorithm may optionally have a staging step when appropriate. This allows for performing auxiliary actions like determining extra metadata that may be useful for processing.
-
Processing - Various APIs/interfaces are provided to run the actual algorithm.
Furthermore, each algorithm will define, via type aliases, the inputs and outputs that it can accept, along with the type of Parameters object it requires.
Template Parameters
Section titled “Template Parameters”-
DerivedCRTP subclass type. -
TagAn indicator of whether the algorithm is to operate on host or device memory.
List of all members
Section titled “List of all members”| Name | Kind | Owner |
|---|---|---|
Algorithm |
function |
Declared here |
configure |
function |
Declared here |
stage |
function |
Declared here |
get_staged_data |
function |
Declared here |
set_staged_data |
function |
Declared here |
staged_data_size |
function |
Declared here |
process |
function |
Declared here |
process |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
process_many |
function |
Declared here |
process_many |
function |
Declared here |
name |
function |
Declared here |
print_configuration |
function |
Declared here |
print_configuration |
function |
Declared here |
params |
function |
Declared here |
TypeConstraint |
variable |
Declared here |
Input |
typedef |
Declared here |
Output |
typedef |
Declared here |
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
Algorithm |
Defaulted constructor. | |
void |
configure inline |
Perform configuration of the algorithm given an input set of parameters. |
void |
stage inline |
Optional stage to perform associated actions before processing. |
const auto |
get_staged_data const inline |
For Algorithms which provide staging of associated data, retrieve what was staged. |
void |
set_staged_data inline |
For Algorithms which provide staging of associated data, alternatively set it. |
hd_std::size_t |
staged_data_size const inline |
For Algorithms which provide staging, retrieve the size (in bytes) of the staged data. |
void |
process const inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }()) |
|
void |
process inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }()) |
|
void |
operator() inline |
|
void |
operator() const inline |
|
void |
process_many const inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }()) |
|
void |
process_many inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }()) |
|
const char * |
name const inline |
|
void |
print_configuration const inline |
Print the name and current values of the Algorithm’s Parameters. |
void |
print_configuration inline |
Print the name and current values of the Algorithm’s Parameters. |
const auto & |
params const inline |
Retrieve the current Parameters for the Algorithm. |
Algorithm
Section titled “Algorithm”Algorithm() = defaultDefined in src/lib/xalgospp/algorithm.hh:92
Defaulted constructor.
configure
Section titled “configure”inline
template<typename Params> inline void configure(const Params & params)Defined in src/lib/xalgospp/algorithm.hh:125
Perform configuration of the algorithm given an input set of parameters.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
params |
const Params & |
The Algorithm-specific Parameters to use. |
inline
inline void stage()Defined in src/lib/xalgospp/algorithm.hh:137
Optional stage to perform associated actions before processing.
An algorithm implementation may optionally provide a staging routine when associated steps, e.g. for metadata retreival, would be useful.
get_staged_data
Section titled “get_staged_data”const inline
inline const auto get_staged_data() constDefined in src/lib/xalgospp/algorithm.hh:153
For Algorithms which provide staging of associated data, retrieve what was staged.
In some execution contexts, it may be desirable to control which of many parallel processing units performs staging. This function and the related setter allow for retrieving and setting staged data, allowing precise control of how and when different parallel units perform these actions.
Returns
Section titled “Returns”Any staged data for the Algorithm. If applicable.
set_staged_data
Section titled “set_staged_data”inline
template<typename... StagedData> inline void set_staged_data(StagedData &&... staged_data)Defined in src/lib/xalgospp/algorithm.hh:172
For Algorithms which provide staging of associated data, alternatively set it.
In some execution contexts, it may be desirable to control which of many parallel processing units performs staging. This function and the related getter allow for retrieving and setting staged data, allowing precise control of how and when different parallel units perform these actions.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
staged_data |
StagedData &&... |
The data that was staged somehow and should be used by the Algorithm. This is Algorithm-specific. |
staged_data_size
Section titled “staged_data_size”const inline
inline hd_std::size_t staged_data_size() constDefined in src/lib/xalgospp/algorithm.hh:185
For Algorithms which provide staging, retrieve the size (in bytes) of the staged data.
Returns
Section titled “Returns”The size in bytes of any (and all) staged data. If no data is staged, then 0.
process
Section titled “process”const inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())
template<typename InputArg, typename OutputArg> inline void process(InputArg && input, OutputArg && output) const requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())Defined in src/lib/xalgospp/algorithm.hh:205
process
Section titled “process”inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())
template<typename InputArg, typename OutputArg> inline void process(InputArg && input, OutputArg && output) requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())Defined in src/lib/xalgospp/algorithm.hh:227
operator()
Section titled “operator()”inline
template<typename InputArg, typename OutputArg> inline void operator()(InputArg && input, OutputArg && output)Defined in src/lib/xalgospp/algorithm.hh:246
operator()
Section titled “operator()”const inline
template<typename InputArg, typename OutputArg> inline void operator()(InputArg && input, OutputArg && output) constDefined in src/lib/xalgospp/algorithm.hh:251
process_many
Section titled “process_many”const inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())
template<typename InputArg, typename OutputArg> inline void process_many(hd_std::size_t count, InputArg && input, OutputArg && output) const requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())Defined in src/lib/xalgospp/algorithm.hh:268
process_many
Section titled “process_many”inline requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())
template<typename InputArg, typename OutputArg> inline void process_many(hd_std::size_t count, InputArg && input, OutputArg && output) requires ([]() { if constexpr (requires { Derived::TypeConstraint == AlgTypeConstraint::StrictOrdering; }) { return Derived::Input::template accepts_when_paired< InputArg, OutputArg, typename Derived::Output >; } else { return Derived::Input::template accepts<InputArg> && Derived::Output::template accepts<OutputArg>; } }())Defined in src/lib/xalgospp/algorithm.hh:291
const inline
inline const char * name() constDefined in src/lib/xalgospp/algorithm.hh:312
print_configuration
Section titled “print_configuration”const inline
inline void print_configuration() constDefined in src/lib/xalgospp/algorithm.hh:323
Print the name and current values of the Algorithm’s Parameters.
print_configuration
Section titled “print_configuration”inline
inline void print_configuration()Defined in src/lib/xalgospp/algorithm.hh:336
Print the name and current values of the Algorithm’s Parameters.
params
Section titled “params”const inline
inline const auto & params() constDefined in src/lib/xalgospp/algorithm.hh:349
Retrieve the current Parameters for the Algorithm.
Returns
Section titled “Returns”A const reference to the Parameters.
Public Static Attributes
Section titled “Public Static Attributes”| Return | Name | Description |
|---|---|---|
constexpr AlgTypeConstraint |
TypeConstraint static constexpr |
TypeConstraint
Section titled “TypeConstraint”static constexpr
constexpr AlgTypeConstraint TypeConstraint { }Defined in src/lib/xalgospp/algorithm.hh:116
Public Types
Section titled “Public Types”| Name | Description |
|---|---|
Input |
The list of supported input types. |
Output |
The list of supported output types. |
using Input = type_list<>Defined in src/lib/xalgospp/algorithm.hh:97
The list of supported input types.
Output
Section titled “Output”using Output = type_list<>Defined in src/lib/xalgospp/algorithm.hh:114
The list of supported output types.
Algorithm’s process data by receiving an output to write the result to. These types are those supported for that purpose.
Algorithms provide a type_list of supported inputs and outputs. These are used both to provide easy access to supported types, but also to constrain the inputs on the Algorithm’s processing routine. By default, the constraint is to allow the cartesian product of the Input and Output type_lists. An Algorithm subclass may opt instead to enforce stronger constraints, e.g., it may require strict ordering such that the first item in the Input list must be paired with the first item in the output list. Refer to each Algorithm to verify if extra constraints are in effect.