Skip to content

Commit

Permalink
make seed to generate the input dependant from construction seed
Browse files Browse the repository at this point in the history
  • Loading branch information
jermp committed Dec 10, 2024
1 parent 0887680 commit a175b20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion external/cmd_line_parser
2 changes: 2 additions & 0 deletions include/builders/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ static uint64_t compute_avg_partition_size(const uint64_t num_keys,
}

static uint64_t compute_num_buckets(const uint64_t num_keys, const double avg_bucket_size) {
assert(avg_bucket_size != 0.0);
return std::ceil(static_cast<double>(num_keys) / avg_bucket_size);
}

static uint64_t compute_num_partitions(const uint64_t num_keys, const double avg_partition_size) {
assert(avg_partition_size != 0.0);
return std::ceil(static_cast<double>(num_keys) / avg_partition_size);
}

Expand Down
18 changes: 11 additions & 7 deletions src/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ void build_benchmark(Builder& builder, build_timings const& timings,
result.add("secondary_sort", config.secondary_sort);
result.add("avg_partition_size", config.avg_partition_size);
result.add("num_partitions",
compute_num_partitions(params.num_keys, config.avg_partition_size));
config.avg_partition_size > 0
? compute_num_partitions(params.num_keys, config.avg_partition_size)
: 0);
result.add("dense_partitioning", config.dense_partitioning ? "true" : "false");

if (config.seed != constants::invalid_seed) result.add("seed", config.seed);

result.add("seed", f.seed());
result.add("num_threads", config.num_threads);
result.add("external_memory", params.external_memory ? "true" : "false");

result.add("partitioning_microseconds", timings.partitioning_microseconds);
result.add("mapping_ordering_microseconds", timings.mapping_ordering_microseconds);
result.add("searching_microseconds", timings.searching_microseconds);
Expand Down Expand Up @@ -681,8 +680,13 @@ int main(int argc, char** argv) {
if (external_memory) {
std::cout << "Warning: external memory construction with in-memory input" << std::endl;
}
// build(parser, distinct_strings(num_keys, random_value()).begin(), num_keys);
build(parser, distinct_uints<uint64_t>(num_keys, random_value()).begin(), num_keys);

/* ensure that if we specify the seed for the construction, we work on the same input */
const uint64_t random_input_seed =
default_hash64(0, parser.parsed("seed") ? parser.get<uint64_t>("seed") : 0);

// build(parser, distinct_strings(num_keys, random_input_seed).begin(), num_keys);
build(parser, distinct_uints<uint64_t>(num_keys, random_input_seed).begin(), num_keys);
}

return 0;
Expand Down

0 comments on commit a175b20

Please sign in to comment.