36 return std::lexicographical_compare(key, key + 10, b.key, b.key + 10);
38 friend std::ostream&
operator << (std::ostream& os,
const Record& c) {
43 static_assert(
sizeof(Record) == 100,
"struct Record packing incorrect.");
51 bool operator < (
const RecordSigned& b)
const {
52 return std::lexicographical_compare(key, key + 10, b.key, b.key + 10);
54 friend std::ostream&
operator << (std::ostream& os,
const RecordSigned& c) {
66 Record operator () (
size_t index) {
70 for (
size_t i = 0; i < 10; ++i)
71 r.key[i] = static_cast<unsigned char>(rng_());
80 static constexpr uint8_t hexdigits[16] = {
81 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
82 '8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' 85 for (
size_t i = 0; i != 2 *
sizeof(rec); ++i)
86 *v++ = hexdigits[(rec >> (4 * i)) & 0x0F];
87 for (
size_t i = 0; i != 16; ++i)
97 for (
size_t i = 0; i < 12; ++i) {
98 uint8_t f = hexdigits[((20 + rec) >> (4 * i)) & 0x0F];
111 assert(v == r.value + 90);
117 std::default_random_engine rng_ { std::random_device { } () };
120 int main(
int argc,
char* argv[]) {
124 bool use_signed_char =
false;
125 clp.
add_bool(
's',
"signed_char", use_signed_char,
126 "compare with signed chars to compare with broken Java " 127 "implementations, default: false");
129 bool generate =
false;
130 clp.
add_bool(
'g',
"generate", generate,
131 "generate binary record on-the-fly for testing." 132 " size: first input pattern, default: false");
134 bool generate_only =
false;
135 clp.
add_bool(
'G',
"generate-only", generate_only,
136 "write unsorted generated binary records to output.");
140 "output file pattern");
142 std::vector<std::string> input;
144 "input file pattern(s)");
146 if (!clp.
process(argc, argv)) {
165 Generate(ctx, size /
sizeof(Record), GenerateRecord())
166 .WriteBinary(output);
176 Generate(ctx, size /
sizeof(Record), GenerateRecord())
180 r.WriteBinary(output);
185 if (use_signed_char) {
186 auto r = ReadBinary<RecordSigned>(ctx, input).Sort();
189 r.WriteBinary(output);
194 auto r = ReadBinary<Record>(ctx, input).Sort();
197 r.WriteBinary(output);
207 <<
" benchmark=terasort" 209 <<
" traffic=" << traffic.total()
net::FlowControlChannel & net
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.
size_t num_hosts() const
Returns the total number of hosts.
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
void Barrier()
A trivial global barrier.
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
void enable_consume(bool consume=true)
Sets consume-mode flag such that DIA contents may be consumed during PushData().
int main(int argc, char *argv[])
bool parse_si_iec_units(const char *str, uint64_t *out_size, char default_unit)
Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes.
void print_result(std::ostream &os)
print nicely formatted result of processing
#define die_unequal(X, Y)
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
struct Record TLX_ATTRIBUTE_PACKED
Command line parser which automatically fills variables and prints nice usage messages.
void add_string(char key, const std::string &longkey, std::string &dest, const std::string &desc)
add string option -key, –longkey and store to dest
net::Traffic Traffic() const
calculate overall traffic for final stats
size_t my_rank() const
Global rank of this worker among all other workers in the system.
void add_param_stringlist(const std::string &name, std::vector< std::string > &dest, const std::string &desc)
void add_bool(char key, const std::string &longkey, bool &dest, const std::string &desc)
net::Manager & net_manager()
std::string hexdump(const void *const data, size_t size)
Dump a (binary) string as a sequence of uppercase hexadecimal pairs.
bool operator<(const uint_pair &b) const
less-than comparison operator
bool process(int argc, const char *const *argv, std::ostream &os)
std::ostream & operator<<(std::ostream &os, const DIABase &d)
make ostream-able.