diff options
author | Benji Dial <benji6283@gmail.com> | 2023-11-25 18:15:30 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2023-11-25 18:15:30 -0500 |
commit | eab56a7f006f5a73c2b7eb984b2aae72bc898212 (patch) | |
tree | 9a88abaf9fc474948cf0f0055d39c6911d2d8a92 /tabulator-mpi/worker.cpp | |
parent | 5141b88157d02040e20a59b923cc672dd7fdc875 (diff) | |
download | lib94-eab56a7f006f5a73c2b7eb984b2aae72bc898212.tar.gz |
allow more control over init_round, rewrite tabulator and make it run every possible separation and turn order exactly once
Diffstat (limited to 'tabulator-mpi/worker.cpp')
-rw-r--r-- | tabulator-mpi/worker.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/tabulator-mpi/worker.cpp b/tabulator-mpi/worker.cpp deleted file mode 100644 index 486d107..0000000 --- a/tabulator-mpi/worker.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include <lib94/lib94.hpp> -#include <cassert> -#include <ctime> -#include <mpi.h> - -#include "constants.hpp" - -static void do_round(const lib94::warrior *w1, const lib94::warrior *w2, int &w1_wins, int& w2_wins) { - const lib94::warrior *ws[2] = {w1, w2}; - - lib94::instruction background = { - .op = lib94::DAT, .mod = lib94::F, - .amode = lib94::DIRECT, .bmode = lib94::DIRECT, - .anumber = 0, .bnumber = 0 - }; - - lib94::clear_core(background); - - assert(lib94::init_round(ws, 2)); - - for (int i = 0; i < STEPS_TO_TIE; ++i) { - const lib94::warrior *result = lib94::single_step<false>(); - if (result == w1) { - ++w2_wins; - return; - } - if (result == w2) { - ++w1_wins; - return; - } - } -} - -void worker_main(const lib94::warrior *const *warriors) { - lib94::seed_prng(time(0)); - int buffer[4] = {-1}; - - while (1) { - MPI_Send(buffer, 4, MPI_INT, 0, 1, MPI_COMM_WORLD); - MPI_Recv(buffer, 4, MPI_INT, 0, 0, MPI_COMM_WORLD, 0); - - if (buffer[0] == -1) - return; - - buffer[2] = 0; - buffer[3] = 0; - - for (int i = 0; i < ROUNDS_PER_CHUNK; ++i) - do_round(warriors[buffer[0]], warriors[buffer[1]], buffer[2], buffer[3]); - } -} |