/* * Circuit Satisfiability, Version 1 * * This MPI program determines whether a circuit is * satisfiable, that is, whether there is a combination of * inputs that causes the output of the circuit to be 1. * The particular circuit being tested is "wired" into the * logic of function 'check_circuit'. All combinations of * inputs that satisfy the circuit are printed. * * Programmed by Michael J. Quinn * * Last modification: 3 September 2002 */ #include #include int main (int argc, char *argv[]) { int i; int id; /* Process rank */ int p; /* Number of processes */ void check_circuit (int, int); MPI_Init (&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &id); MPI_Comm_size (MPI_COMM_WORLD, &p); for (i = id; i < 65536; i += p) check_circuit (id, i); printf ("Process %d is done\n", id); fflush (stdout); MPI_Finalize(); return 0; } /* Return 1 if 'i'th bit of 'n' is 1; 0 otherwise */ #define EXTRACT_BIT(n,i) ((n&(1<