Skip to content

Commit

Permalink
added progress bar and better parallelization for column intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
karasikov committed Apr 10, 2021
1 parent 97a8749 commit 95d34c9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions metagraph/src/cli/transform_annotation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "transform_annotation.hpp"

#include <progress_bar.hpp>

#include "common/logger.hpp"
#include "common/unix_tools.hpp"
#include "common/threads/threading.hpp"
Expand Down Expand Up @@ -379,7 +381,9 @@ int transform_annotation(Config *config) {
}

sdsl::int_vector<> sum(0, 0, sdsl::bits::hi(num_columns) + 1);

ProgressBar progress_bar(num_columns, "Intersect columns",
std::cerr, !get_verbose());
ThreadPool thread_pool(get_num_threads(), 1);
std::mutex mu;
auto on_column = [&](uint64_t, const auto &, auto&& col) {
#pragma omp critical
Expand All @@ -392,19 +396,23 @@ int transform_annotation(Config *config) {
exit(1);
}
}
col->call_ones([&](uint64_t i) {
atomic_fetch_and_add(sum, i, 1, mu, __ATOMIC_RELAXED);
thread_pool.enqueue([&,col{std::move(col)}]() {
col->call_ones([&](uint64_t i) {
atomic_fetch_and_add(sum, i, 1, mu, __ATOMIC_RELAXED);
});
++progress_bar;
});
};

if (!ColumnCompressed<>::merge_load(files, on_column, get_num_threads())) {
logger->error("Couldn't load annotations");
exit(1);
}
thread_pool.join();
std::atomic_thread_fence(std::memory_order_acquire);

uint64_t min_cols = num_columns * config->intersect_ratio;
logger->trace("Selecting k-mers supported in at least {} / {} columns",
logger->trace("Selecting k-mers annotated in >= {} / {} columns",
min_cols, num_columns);

sdsl::bit_vector intersection(sum.size(), false);
Expand Down

0 comments on commit 95d34c9

Please sign in to comment.