27 template <
typename AlphabetType>
32 return std::tie(ch[0], ch[1], ch[2], ch[3], ch[4], ch[5], ch[6])
33 == std::tie(b.ch[0], b.ch[1], b.ch[2], b.ch[3],
34 b.ch[4], b.ch[5], b.ch[6]);
38 return std::tie(ch[0], ch[1], ch[2], ch[3], ch[4], ch[5], ch[6])
39 < std::tie(b.ch[0], b.ch[1], b.ch[2], b.ch[3],
40 b.ch[4], b.ch[5], b.ch[6]);
43 friend std::ostream&
operator << (std::ostream& os,
const Chars& chars) {
44 return os <<
'[' << chars.ch[0] <<
',' << chars.ch[1]
45 <<
',' << chars.ch[2] <<
',' << chars.ch[3]
46 <<
',' << chars.ch[4] <<
',' << chars.ch[5]
47 <<
',' << chars.ch[6] <<
']';
50 static Chars EndSentinel() {
53 std::numeric_limits<AlphabetType>::lowest(),
54 std::numeric_limits<AlphabetType>::lowest(),
55 std::numeric_limits<AlphabetType>::lowest(),
56 std::numeric_limits<AlphabetType>::lowest(),
57 std::numeric_limits<AlphabetType>::lowest(),
58 std::numeric_limits<AlphabetType>::lowest(),
59 std::numeric_limits<AlphabetType>::lowest()
66 template <
typename Index,
typename AlphabetType>
69 Chars<AlphabetType> chars;
71 friend std::ostream&
operator << (std::ostream& os,
const IndexChars& tc) {
72 return os <<
'[' << tc.index <<
'|' << tc.chars <<
']';
76 int main(
int argc,
char* argv[]) {
84 uint64_t input_size = 50000000;
85 cp.
add_bytes(
's',
"input_size", input_size,
86 "Number of DC7 tuples to sort.");
90 "select sort algo: '1' pivot, '2' pivots, '3' pivots");
95 using IndexChars = ::IndexChars<uint32_t, uint8_t>;
96 std::vector<IndexChars> input;
98 std::default_random_engine rng_(123456);
100 for (
size_t i = 0; i < input_size; ++i) {
104 { uint8_t(rng_()), uint8_t(rng_()), uint8_t(rng_()),
105 uint8_t(rng_()), uint8_t(rng_()), uint8_t(rng_()),
111 LOG1 <<
"Sorting " << input_size <<
" DC7 tuples, total size = " 117 std::vector<IndexChars> vec = input;
118 auto compare_function_ =
119 [](
const IndexChars& a,
const IndexChars& b) {
120 return a.chars < b.chars;
127 std::sort(vec.begin(), vec.end(), compare_function_);
130 vec.begin(), vec.end(), compare_function_);
133 vec.begin(), vec.end(), compare_function_);
136 ctx.PrintCollectiveMeanStdev(
137 "sort_time", sort_time.SecondsDouble());
void qsort_three_pivots(Iterator left, Iterator right, Compare cmp)
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
void qsort_two_pivots_yaroslavskiy(Iterator lo, Iterator hi, Compare cmp)
void add_bytes(char key, const std::string &longkey, uint32_t &dest, const std::string &desc)
struct Chars TLX_ATTRIBUTE_PACKED
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
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
bool operator==(const uint_pair &b) const
equality checking operator
int main(int argc, char *argv[])
bool operator<(const uint_pair &b) const
less-than comparison operator
void set_author(const std::string &author)
Set author of program, will be wrapped.
std::string format_iec_units(uint64_t number, int precision=3)
Format number as something like 1 TiB.
bool process(int argc, const char *const *argv, std::ostream &os)
std::ostream & operator<<(std::ostream &os, const DIABase &d)
make ostream-able.