diff options
author | Benji Dial <benji@benjidial.net> | 2023-05-31 01:30:26 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-05-31 01:30:26 -0400 |
commit | 6aa768c7c840fa326596a3b40a0954a9f475ed63 (patch) | |
tree | ab7ff64d68532d69e8a9f222a88e4e84db3bbd51 /tabulator-mpi/head.cpp | |
parent | 21d36220c869e4e28d437993a082b12b67a2428f (diff) | |
download | lib94-6aa768c7c840fa326596a3b40a0954a9f475ed63.tar.gz |
new tabulator running look
Diffstat (limited to 'tabulator-mpi/head.cpp')
-rw-r--r-- | tabulator-mpi/head.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tabulator-mpi/head.cpp b/tabulator-mpi/head.cpp index bd270af..c425865 100644 --- a/tabulator-mpi/head.cpp +++ b/tabulator-mpi/head.cpp @@ -1,4 +1,5 @@ #include <lib94/lib94.hpp> +#include <csignal> #include <cstdio> #include <mpi.h> @@ -25,26 +26,54 @@ void head_main(int comm_size, int warrior_count, const lib94::warrior *const *wa score_results[i][j] = 0; } + int chunks = warrior_count * (warrior_count - 1) / 2 * CHUNKS_PER_PAIR; + int on_chunk = 0; + + int right_name_width = 0; for (int i = 0; i < warrior_count; ++i) - for (int j = i + 1; j < warrior_count; ++j) { - fprintf(stderr, "%s vs %s\n", warriors[i]->name.c_str(), warriors[j]->name.c_str()); + if ((int)warriors[i]->name.size() > right_name_width) + right_name_width = warriors[i]->name.size(); + + int rank_width = std::max(std::string("rank").size(), std::to_string(comm_size - 1).size()); + int right_round_width = std::to_string(CHUNKS_PER_PAIR * ROUNDS_PER_CHUNK).size(); + int right_chunk_width = std::to_string(chunks).size(); + + int left_name_width = std::max(right_name_width, (int)std::string("match").size() - right_name_width - 4); + int left_round_width = std::max((int)std::to_string((CHUNKS_PER_PAIR - 1) * ROUNDS_PER_CHUNK + 1).size(), (int)std::string("rounds").size() - right_round_width - 3); + int left_chunk_width = std::max(right_chunk_width, (int)std::string("chunk").size() - right_chunk_width - 3); + + fprintf(stderr, "\x1b""7\x1b[?47h\x1b[?25l\x1b[2J\x1b[0H"); + fprintf(stderr, "%*s | %*s | %*s | %*s", rank_width, "rank", + left_name_width + 4 + right_name_width, "match", + left_round_width + 3 + right_round_width, "rounds", + left_chunk_width + 3 + right_chunk_width, "chunk"); + + for (int i = 0; i < warrior_count; ++i) + for (int j = i + 1; j < warrior_count; ++j) for (int x = 0; x < CHUNKS_PER_PAIR; ++x) { + ++on_chunk; int rank = get_result(); int message[3] = {i, j, x * ROUNDS_PER_CHUNK}; MPI_Send(message, 2, MPI_INT, rank, 0, MPI_COMM_WORLD); - fprintf(stderr, "sent rounds %d through %d to worker %d\n", - x * ROUNDS_PER_CHUNK + 1, x * ROUNDS_PER_CHUNK + ROUNDS_PER_CHUNK, rank); + fprintf(stderr, "\x1b[%d;0H%*d | %*s vs %*s | %*d - %*d | %*d / %*d\x1b[0K", rank + 1, rank_width, rank, + left_name_width, warriors[i]->name.c_str(), right_name_width, warriors[j]->name.c_str(), + left_round_width, x * ROUNDS_PER_CHUNK + 1, right_round_width, x * ROUNDS_PER_CHUNK + ROUNDS_PER_CHUNK, + left_chunk_width, on_chunk, right_chunk_width, chunks); } - fputc('\n', stderr); - } - for (int i = 0; i < comm_size - 1; ++i) { int rank = get_result(); int message[3] = {-1}; MPI_Send(message, 3, MPI_INT, rank, 0, MPI_COMM_WORLD); + fprintf(stderr, "\x1b[%d;0H%*d | %*s | %*s | %*s\x1b[0K", + rank + 1, rank_width, rank, + left_name_width + 4 + right_name_width, "", + left_round_width + 3 + right_round_width, "", + left_chunk_width + 3 + right_chunk_width, "done"); } + fprintf(stderr, "\x1b[?25h\x1b[?47l\x1b""8"); + for (int i = 0; i < warrior_count; ++i) for (int j = i + 1; j < warrior_count; ++j) if (score_results[i][j] < 0) { |