Skip to content

Commit

Permalink
Fix warnings and multi-threading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hmusta authored and adamant-pwn committed Jun 20, 2024
1 parent 2a66378 commit 29b6c6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions include/minimizers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct minimizers {
mphf_config.seed = util::get_seed_for_hash_function(build_config);
mphf_config.minimal_output = true;
mphf_config.verbose_output = false;
mphf_config.num_threads = std::thread::hardware_concurrency();
mphf_config.num_threads = build_config.num_threads;
mphf_config.num_partitions = 4 * mphf_config.num_threads;

if (size / mphf_config.num_partitions < pthash::constants::min_partition_size) {
Expand All @@ -29,6 +29,10 @@ struct minimizers {

mphf_config.ram = 4 * essentials::GB;
mphf_config.tmp_dir = build_config.tmp_dirname;
if (size <= 1) {
throw std::runtime_error(
"each partition must contain more than one key: use less partitions");
}
m_mphf.build_in_external_memory(begin, size, mphf_config);
}

Expand All @@ -49,4 +53,4 @@ struct minimizers {
minimizers_pthash_type m_mphf;
};

} // namespace sshash
} // namespace sshash
5 changes: 4 additions & 1 deletion include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <array>
#include <cassert>
#include <fstream>
#include <thread>
#include <cmath> // for std::ceil on linux

#include "hash_util.hpp"
Expand Down Expand Up @@ -74,6 +75,7 @@ struct build_configuration {
: k(31)
, m(17)
, seed(constants::seed)
, num_threads(std::thread::hardware_concurrency())

, l(constants::min_l)
, c(constants::c)
Expand All @@ -87,6 +89,7 @@ struct build_configuration {
uint64_t k; // kmer size
uint64_t m; // minimizer size
uint64_t seed;
uint64_t num_threads;

uint64_t l; // drive dictionary trade-off
double c; // drive PTHash trade-off
Expand Down Expand Up @@ -302,4 +305,4 @@ struct buffered_lines_iterator {
uint64_t m_read_chars;
};

} // namespace sshash
} // namespace sshash

0 comments on commit 29b6c6b

Please sign in to comment.