23 auto data =
Generate(ctx, num_elems).Cache();
25 auto result =
Select(data, rank,
26 [](
const auto& a,
const auto& b) ->
bool 29 LOG <<
"Result: " << result;
33 auto result =
Select(data, rank);
35 LOG <<
"Result: " << result;
40 int main(
int argc,
char* argv[]) {
44 size_t num_elems = 1024 * 1024, rank = 10;
46 clp.
add_size_t(
'n',
"num_elemes", num_elems,
"Number of elements, default: 2^10");
47 clp.
add_size_t(
'k',
"rank", rank,
"Rank to select, default: 10");
48 clp.
add_bool(
'm',
"max", max,
"Select maximum, default off");
static uint_pair max()
return an uint_pair instance containing the largest value possible
auto Generate(Context &ctx, size_t size, const GenerateFunction &generate_function)
Generate is a Source-DOp, which creates a DIA of given size using a generator function.
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
void add_size_t(char key, const std::string &longkey, size_t &dest, const std::string &desc)
add size_t option -key, –longkey with description and store to dest
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
void print_result(std::ostream &os)
print nicely formatted result of processing
Command line parser which automatically fills variables and prints nice usage messages.
static auto RunSelect(api::Context &ctx, size_t num_elems, size_t rank, bool max)
void set_verbose_process(bool verbose_process)
Set verbose processing of command line arguments.
int main(int argc, char *argv[])
void add_bool(char key, const std::string &longkey, bool &dest, const std::string &desc)
ValueType Select(const DIA< ValueType, InStack > &data, size_t rank, const Compare &compare=Compare())
#define LOG
Default logging method: output if the local debug variable is true.
bool process(int argc, const char *const *argv, std::ostream &os)