Changes to get mpimain running.

This commit is contained in:
Cotton Seed 2012-05-03 15:49:26 -04:00
parent 417fe1ea4d
commit 6d133e0622
3 changed files with 35 additions and 21 deletions

View File

@ -60,7 +60,7 @@ main: main.o $(COMMON_OBJS)
$(CXX) $(LDFLAGS) -o main $^ $(LIBS) $(CXX) $(LDFLAGS) -o main $^ $(LIBS)
mpimain: mpimain.o mpi_aux.o $(COMMON_OBJS) mpimain: mpimain.o mpi_aux.o $(COMMON_OBJS)
$(CXX) $(LDFLAGS) -o main $^ $(LIBS) $(CXX) $(LDFLAGS) -o mpimain $^ $(LIBS)
testlib: testlib.o $(COMMON_OBJS) testlib: testlib.o $(COMMON_OBJS)
$(CXX) $(LDFLAGS) -o testlib $^ $(CXX) $(LDFLAGS) -o testlib $^

View File

@ -9,12 +9,14 @@ void send_int (int v, int dest);
void send_string (const char *s, int dest); void send_string (const char *s, int dest);
void send_string (const std::string &s, int dest); void send_string (const std::string &s, int dest);
void send_htw_knot (unsigned n, bool alternating, unsigned k, int dest);
int recv_int (int *src); int recv_int (int *src);
knot_diagram recv_knot (int *src);
std::string recv_string (int *src); std::string recv_string (int *src);
inline int recv_int () { return recv_int (0); } inline int recv_int () { return recv_int (0); }
inline std::string recv_string () { return recv_string (0); }
#if 0
void send_htw_knot (unsigned n, bool alternating, unsigned k, int dest);
knot_diagram recv_knot (int *src);
knot_diagram recv_knot () { return recv_knot (0); } knot_diagram recv_knot () { return recv_knot (0); }
std::string recv_string () { return recv_string (0); } #endif

View File

@ -1,4 +1,4 @@
s
#include <knotkit.h> #include <knotkit.h>
#include <mpi.h> #include <mpi.h>
@ -42,8 +42,6 @@ master ()
int ntasks = num_tasks (); int ntasks = num_tasks ();
assert (work.size () > ntasks);
set<unsigned> active; set<unsigned> active;
for (int rank = 1; rank < ntasks && work.size () > 0; rank ++) for (int rank = 1; rank < ntasks && work.size () > 0; rank ++)
@ -51,9 +49,9 @@ master ()
send_int (CMD_DO, rank); send_int (CMD_DO, rank);
knot_desc desc = work.pop (); knot_desc desc = work.pop ();
send_int ((int)desc.t); send_int ((int)desc.t, rank);
send_int ((int)desc.i); send_int ((int)desc.i, rank);
send_int ((int)desc.j); send_int ((int)desc.j, rank);
active.push (rank); active.push (rank);
} }
@ -65,9 +63,9 @@ master ()
send_int (CMD_DO, rank); send_int (CMD_DO, rank);
knot_desc desc = work.pop (); knot_desc desc = work.pop ();
send_int ((int)desc.t); send_int ((int)desc.t, rank);
send_int ((int)desc.i); send_int ((int)desc.i, rank);
send_int ((int)desc.j); send_int ((int)desc.j, rank);
} }
while (active.card () > 0) while (active.card () > 0)
@ -129,18 +127,20 @@ slave ()
desc.i = (knot_desc::table)recv_int (); desc.i = (knot_desc::table)recv_int ();
desc.j = (knot_desc::table)recv_int (); desc.j = (knot_desc::table)recv_int ();
printf ("[% 2d] CMD_DO %s\n", rank, desc.name ().c_str ());
map<knot_desc, map<knot_desc,
triple<ptr<const module<Z2> >, mod_map<Z2>, mod_map<Z2> > > knot_kh_sq; triple<ptr<const module<Z2> >, mod_map<Z2>, mod_map<Z2> > > knot_kh_sq;
char buf[1000]; char buf[1000];
if (desc.t == TORUS) if (desc.t == knot_desc::TORUS)
{ {
sprintf (buf, "T.dat"); sprintf (buf, "T.dat");
for (unsigned t = 3; t <= 16; t ++) // twists for (unsigned t = 3; t <= 16; t ++) // twists
for (unsigned s = 2; s <= t; s ++) // strands for (unsigned s = 2; s <= t; s ++) // strands
{ {
if ((s - 1) * t > 16) if ((s - 1) * t > 18)
continue; continue;
desc.i = s; desc.i = s;
@ -153,10 +153,22 @@ slave ()
{ {
unsigned j0 = desc.j; unsigned j0 = desc.j;
assert (desc.t == knot_desc::HTW || desc.t == knot_desc::MT); switch (desc.t)
sprintf (buf, "%c%d.dat", {
desc.t == knot_desc::HTW ? 'K' : 'L', case knot_desc::ROLFSEN:
j0); sprintf (buf, "%d_%d.dat", desc.i, j0);
break;
case knot_desc::HTW:
sprintf (buf, "K%d_%d.dat", desc.i, j0);
break;
case knot_desc::MT:
sprintf (buf, "L%d_%d.dat", desc.i, j0);
break;
default: abort ();
}
for (unsigned j = j0; for (unsigned j = j0;
j <= std::min (j0 + block_size - 1, j <= std::min (j0 + block_size - 1,
@ -171,7 +183,7 @@ slave ()
{ {
writer w (buf); writer w (buf);
write (w, kh_knot_map); write (w, knot_kh_sq);
} }
send_int (0, 0); send_int (0, 0);