#include #include #include #include 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(stream), {}); auto w = lib94::compile_warrior(source); if (std::holds_alternative(w)) { fprintf(stderr, "error compiling %s: %s\n", file, std::get(w).c_str()); exit(1); } return std::get(w); } 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); 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]); if (comm_rank == 0) head_main(comm_size, argc - 1, warriors); else worker_main(warriors); MPI_Finalize(); }