summaryrefslogtreecommitdiff
path: root/tabulator-mpi
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-05-31 01:30:26 -0400
committerBenji Dial <benji@benjidial.net>2023-05-31 01:30:26 -0400
commit6aa768c7c840fa326596a3b40a0954a9f475ed63 (patch)
treeab7ff64d68532d69e8a9f222a88e4e84db3bbd51 /tabulator-mpi
parent21d36220c869e4e28d437993a082b12b67a2428f (diff)
downloadlib94-6aa768c7c840fa326596a3b40a0954a9f475ed63.tar.gz
new tabulator running look
Diffstat (limited to 'tabulator-mpi')
-rw-r--r--tabulator-mpi/constants.hpp4
-rw-r--r--tabulator-mpi/head.cpp43
-rw-r--r--tabulator-mpi/main.cpp5
3 files changed, 43 insertions, 9 deletions
diff --git a/tabulator-mpi/constants.hpp b/tabulator-mpi/constants.hpp
index c8f18e2..3f80bff 100644
--- a/tabulator-mpi/constants.hpp
+++ b/tabulator-mpi/constants.hpp
@@ -1,3 +1,3 @@
#define STEPS_TO_TIE 1000000
-#define ROUNDS_PER_CHUNK 100
-#define CHUNKS_PER_PAIR 10
+#define ROUNDS_PER_CHUNK 500
+#define CHUNKS_PER_PAIR 5
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) {
diff --git a/tabulator-mpi/main.cpp b/tabulator-mpi/main.cpp
index 959cd8c..cb60ecb 100644
--- a/tabulator-mpi/main.cpp
+++ b/tabulator-mpi/main.cpp
@@ -33,6 +33,11 @@ int main(int argc, char **argv) {
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
+ if (comm_size < 2) {
+ fprintf(stderr, "at least two processes are required\n");
+ return 1;
+ }
+
const lib94::warrior **warriors = new const lib94::warrior *[argc - 1];
for (int i = 0; i < argc - 1; ++i)
warriors[i] = load_warrior(argv[i + 1]);