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/main.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/main.cpp')
-rw-r--r-- | tabulator-mpi/main.cpp | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/tabulator-mpi/main.cpp b/tabulator-mpi/main.cpp deleted file mode 100644 index cd17044..0000000 --- a/tabulator-mpi/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include <lib94/lib94.hpp> -#include <fstream> -#include <cstdio> -#include <mpi.h> - -void head_main(int comm_size, int warrior_count, const lib94::warrior *const *warriors); - -void worker_main(const lib94::warrior *const *warriors); - -const lib94::warrior *load_warrior(const char *file) { - std::ifstream stream(file); - if (!stream) { - fprintf(stderr, "could not open %s\n", file); - exit(1); - } - - std::string source(std::istreambuf_iterator<char>(stream), {}); - - try { - return lib94::compile_warrior(source); - } - - catch (const lib94::compiler_exception &ex) { - fprintf(stderr, "error in %s on line %u: %s\n", file, ex.source_line_number, ex.message.c_str()); - exit(1); - } -} - -int main(int argc, char **argv) { - MPI_Init(&argc, &argv); - - int comm_rank, comm_size; - 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]); - - for (int i = 0; i < argc - 1; ++i) - for (int j = i + 1; j < argc - 1; ++j) { - const lib94::warrior *wbuf[2] = {warriors[i], warriors[j]}; - if (!lib94::init_round(wbuf, 2)) { - fprintf(stderr, "warriors do not fit in core\n"); - return 1; - } - } - - if (comm_rank == 0) - head_main(comm_size, argc - 1, warriors); - else - worker_main(warriors); - - MPI_Finalize(); -} |