remove some debug output etc.
This commit is contained in:
parent
d2d91d68b3
commit
a6815a1314
23
parallel.c
23
parallel.c
@ -10,7 +10,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define DEBUG(msg, ...) fprintf(stderr, "[%003d%10.3f] " msg, mpi_rank(0), runtime(), ##__VA_ARGS__)
|
#define DEBUG(msg, ...)
|
||||||
|
#define INFO(msg, ...) fprintf(stderr, "[%003d%10.3f] " msg, mpi_rank(0), runtime(), ##__VA_ARGS__)
|
||||||
//#define DEBUG(msg, ...) fprintf(stderr, "[ %10.3f] " msg, runtime(), ##__VA_ARGS__)
|
//#define DEBUG(msg, ...) fprintf(stderr, "[ %10.3f] " msg, runtime(), ##__VA_ARGS__)
|
||||||
//#define DEBUG_MPI(msg, node, ...) fprintf(stderr, "[%003d%10.3f] " msg, node, runtime(), ##__VA_ARGS__)
|
//#define DEBUG_MPI(msg, node, ...) fprintf(stderr, "[%003d%10.3f] " msg, node, runtime(), ##__VA_ARGS__)
|
||||||
#define DONE(x) *((int*)(x))
|
#define DONE(x) *((int*)(x))
|
||||||
@ -144,7 +145,7 @@ int parallel_work(parallel_context *ctx)
|
|||||||
MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD,
|
MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD,
|
||||||
&status);
|
&status);
|
||||||
|
|
||||||
DEBUG("Message received: source = %d, tag = %d\n", status.MPI_SOURCE, status.MPI_TAG);
|
// DEBUG("Message received: source = %d, tag = %d\n", status.MPI_SOURCE, status.MPI_TAG);
|
||||||
|
|
||||||
if(status.MPI_TAG == PARALLEL_SHUTDOWN) {
|
if(status.MPI_TAG == PARALLEL_SHUTDOWN) {
|
||||||
DEBUG("Shutting down\n");
|
DEBUG("Shutting down\n");
|
||||||
@ -257,9 +258,9 @@ int parallel_run(parallel_context *ctx, const void *global_data, const void *inp
|
|||||||
fsync(restartf);
|
fsync(restartf);
|
||||||
|
|
||||||
if(continuing) {
|
if(continuing) {
|
||||||
DEBUG("Continuing from restart file, %d/%d jobs completed, %d nodes\n", completed, njobs, ctx->size);
|
INFO("Continuing from restart file, %d/%d jobs completed, %d nodes\n", completed, njobs, ctx->size);
|
||||||
} else {
|
} else {
|
||||||
DEBUG("Starting from scratch, %d jobs, %d nodes\n", njobs, ctx->size);
|
INFO("Starting from scratch, %d jobs, %d nodes\n", njobs, ctx->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(completed >= njobs)
|
if(completed >= njobs)
|
||||||
@ -307,31 +308,27 @@ int parallel_run(parallel_context *ctx, const void *global_data, const void *inp
|
|||||||
DONE(alljobs + id*itemsize) = 1;
|
DONE(alljobs + id*itemsize) = 1;
|
||||||
completed++;
|
completed++;
|
||||||
|
|
||||||
DEBUG("job %d completed by node %d\n", id, status.MPI_SOURCE);
|
|
||||||
|
|
||||||
// todo: deal with unresponsive nodes
|
// todo: deal with unresponsive nodes
|
||||||
// strategy: when no jobs left, go through unfinished list again, incrementing oversubscribe counter
|
// strategy: when no jobs left, go through unfinished list again, incrementing oversubscribe counter
|
||||||
// if oversubscribe counter is at limit, shut node down instead
|
// if oversubscribe counter is at limit, shut node down instead
|
||||||
//
|
//
|
||||||
|
|
||||||
if(current >= njobs) { // all jobs are assigned, shut down node
|
if(current >= njobs) { // all jobs are assigned, shut down node
|
||||||
|
INFO("job %d completed by node %d, shut down\n", id, status.MPI_SOURCE);
|
||||||
MPI_Send(NULL, 0, MPI_BYTE, status.MPI_SOURCE, PARALLEL_SHUTDOWN, MPI_COMM_WORLD);
|
MPI_Send(NULL, 0, MPI_BYTE, status.MPI_SOURCE, PARALLEL_SHUTDOWN, MPI_COMM_WORLD);
|
||||||
active_worker_nodes--;
|
active_worker_nodes--;
|
||||||
if(active_worker_nodes)
|
if(!active_worker_nodes)
|
||||||
continue;
|
|
||||||
else
|
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
|
INFO("job %d completed by node %d, continues with %d\n", id, status.MPI_SOURCE, current);
|
||||||
*((int*)input_message_buffer) = current;
|
*((int*)input_message_buffer) = current;
|
||||||
memcpy(input_message_buffer + sizeof(int), input_array + current*ctx->input_size, ctx->input_size);
|
memcpy(input_message_buffer + sizeof(int), input_array + current*ctx->input_size, ctx->input_size);
|
||||||
MPI_Send(input_message_buffer, 1, ctx->order_datatype,
|
MPI_Send(input_message_buffer, 1, ctx->order_datatype,
|
||||||
status.MPI_SOURCE, PARALLEL_ORDER, MPI_COMM_WORLD);
|
status.MPI_SOURCE, PARALLEL_ORDER, MPI_COMM_WORLD);
|
||||||
|
|
||||||
DEBUG("Job %d sent to node %d\n", current, status.MPI_SOURCE);
|
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < njobs; i++) {
|
for(int i = 0; i < njobs; i++) {
|
||||||
memcpy(output_array + i*ctx->output_size, alljobs + i*itemsize + sizeof(int), ctx->output_size);
|
memcpy(output_array + i*ctx->output_size, alljobs + i*itemsize + sizeof(int), ctx->output_size);
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
|
|
||||||
#define SWAP(t,x,y) do { t _tmp = (x); (x) = (y); (y) = _tmp; } while (0);
|
#define SWAP(t,x,y) do { t _tmp = (x); (x) = (y); (y) = _tmp; } while (0);
|
||||||
|
|
||||||
#define DEBUG(msg, ...) fprintf(stderr, "[%003d%10.3f] " msg, mpi_rank(0), runtime(), ##__VA_ARGS__)
|
//#define DEBUG(msg, ...) fprintf(stderr, "[%003d%10.3f] " msg, mpi_rank(0), runtime(), ##__VA_ARGS__)
|
||||||
//#define DEBUG(msg, ...)
|
#define DEBUG(msg, ...)
|
||||||
|
#define INFO(msg, ...) fprintf(stderr, "[%003d%10.3f] " msg, mpi_rank(0), runtime(), ##__VA_ARGS__)
|
||||||
|
|
||||||
struct result {
|
struct result {
|
||||||
int id;
|
int id;
|
||||||
@ -118,8 +119,6 @@ int compute_invariants(group_t *group, mat *matrices, struct result **invariants
|
|||||||
int ntraces = *n, nuniq;
|
int ntraces = *n, nuniq;
|
||||||
int retval;
|
int retval;
|
||||||
double evs[3];
|
double evs[3];
|
||||||
int max_slope_id;
|
|
||||||
double max_slope;
|
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
|
||||||
// DEBUG("Compute traces\n");
|
// DEBUG("Compute traces\n");
|
||||||
@ -156,7 +155,6 @@ int compute_invariants(group_t *group, mat *matrices, struct result **invariants
|
|||||||
mps_context_set_output_prec(solver, 20); // relative precision
|
mps_context_set_output_prec(solver, 20); // relative precision
|
||||||
mps_context_set_output_goal(solver, MPS_OUTPUT_GOAL_APPROXIMATE);
|
mps_context_set_output_goal(solver, MPS_OUTPUT_GOAL_APPROXIMATE);
|
||||||
|
|
||||||
max_slope = 0;
|
|
||||||
for(int i = 0; i < nuniq; i++) {
|
for(int i = 0; i < nuniq; i++) {
|
||||||
retval = solve_characteristic_polynomial(solver, poly, invariants[i]->tr, invariants[i]->trinv, evs);
|
retval = solve_characteristic_polynomial(solver, poly, invariants[i]->tr, invariants[i]->trinv, evs);
|
||||||
|
|
||||||
@ -180,21 +178,13 @@ int compute_invariants(group_t *group, mat *matrices, struct result **invariants
|
|||||||
invariants[i]->x = x;
|
invariants[i]->x = x;
|
||||||
invariants[i]->y = y;
|
invariants[i]->y = y;
|
||||||
invariants[i]->slope = y/x;
|
invariants[i]->slope = y/x;
|
||||||
|
|
||||||
if(y/x > max_slope + 1e-12 && (x > 0.1 || y > 0.1)) {
|
|
||||||
max_slope_id = invariants[i]->id;
|
|
||||||
max_slope = y/x;
|
|
||||||
} else if(y/x > max_slope - 1e-12 && (x > 0.1 || y > 0.1)) {
|
|
||||||
// DEBUG("%s didn't quite make it\n",
|
|
||||||
// print_word(&group->elements[invariants[i]->id], buf));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mps_context_free(solver);
|
mps_context_free(solver);
|
||||||
|
|
||||||
qsort(invariants, nuniq, sizeof(struct result*), compare_result_by_id);
|
qsort(invariants, nuniq, sizeof(struct result*), compare_result_by_id);
|
||||||
|
|
||||||
*n = nuniq;
|
*n = nuniq;
|
||||||
return max_slope_id;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long check_memory_usage(mat *matrices, int n)
|
long check_memory_usage(mat *matrices, int n)
|
||||||
@ -257,6 +247,20 @@ int init_node(const void *_g, void *_n)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int process_output(group_t *group, mat *matrices, struct result **invariants, int invariants_length, struct output_data *out)
|
||||||
|
{
|
||||||
|
out->max_slope = 0;
|
||||||
|
for(int i = 0; i < invariants_length; i++) {
|
||||||
|
double x = invariants[i]->x;
|
||||||
|
double y = invariants[i]->y;
|
||||||
|
|
||||||
|
if(y/x > out->max_slope + 1e-12 && (x > 0.1 || y > 0.1)) {
|
||||||
|
out->max_slope_id = invariants[i]->id;
|
||||||
|
out->max_slope = y/x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int do_computation(const void *_g, void *_n, const void *_in, void *_out)
|
int do_computation(const void *_g, void *_n, const void *_in, void *_out)
|
||||||
{
|
{
|
||||||
struct global_data *g = (struct global_data *)_g;
|
struct global_data *g = (struct global_data *)_g;
|
||||||
@ -270,7 +274,7 @@ int do_computation(const void *_g, void *_n, const void *_in, void *_out)
|
|||||||
mpq_set_ui(s, in->snum, in->sden);
|
mpq_set_ui(s, in->snum, in->sden);
|
||||||
mpq_set_ui(q, in->qnum, in->qden);
|
mpq_set_ui(q, in->qnum, in->qden);
|
||||||
|
|
||||||
DEBUG("Computing max slope element for s = %d/%d and q = %d/%d.\n",
|
INFO("Computing max slope element for s = %d/%d and q = %d/%d.\n",
|
||||||
in->snum, in->sden,
|
in->snum, in->sden,
|
||||||
in->qnum, in->qden);
|
in->qnum, in->qden);
|
||||||
|
|
||||||
@ -305,10 +309,12 @@ int do_computation(const void *_g, void *_n, const void *_in, void *_out)
|
|||||||
enumerate(n->group, n->matrices, g->p1, g->p2, g->p3, s, q);
|
enumerate(n->group, n->matrices, g->p1, g->p2, g->p3, s, q);
|
||||||
|
|
||||||
DEBUG("Compute invariants\n");
|
DEBUG("Compute invariants\n");
|
||||||
out->max_slope_id = compute_invariants(
|
compute_invariants(
|
||||||
n->group, n->matrices,
|
n->group, n->matrices,
|
||||||
n->distinct_invariants, &n->distinct_invariants_length, 1);
|
n->distinct_invariants, &n->distinct_invariants_length, 1);
|
||||||
out->max_slope = n->invariants[out->max_slope_id].slope;
|
|
||||||
|
DEBUG("Find max slopes\n");
|
||||||
|
process_output(n->group, n->matrices, n->distinct_invariants, n->distinct_invariants_length, out);
|
||||||
|
|
||||||
mpq_clears(s, q, NULL);
|
mpq_clears(s, q, NULL);
|
||||||
|
|
||||||
@ -326,7 +332,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// parse command line arguments
|
// parse command line arguments
|
||||||
if(argc < 11) {
|
if(argc < 11) {
|
||||||
fprintf(stderr, "Usage: %s <N> <p1> <p2> <p3> <s start> <s end> <s denom> <q start> <q end> <q denom>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <N> <p1> <p2> <p3> <s start> <s end> <s denom> <q start> <q end> <q denom> [restart]\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
int nmax = atoi(argv[1]);
|
int nmax = atoi(argv[1]);
|
||||||
@ -403,14 +409,18 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(argc >= 12)
|
||||||
|
parallel_run(ctx, g, inputs, outputs, njobs, argv[11]);
|
||||||
|
else
|
||||||
parallel_run(ctx, g, inputs, outputs, njobs, NULL);
|
parallel_run(ctx, g, inputs, outputs, njobs, NULL);
|
||||||
|
|
||||||
// DEBUG("Loop for s = %d/%d, q = %d/%d\n", sloop, g->sdenom, qloop, g->qdenom);
|
// DEBUG("Loop for s = %d/%d, q = %d/%d\n", sloop, g->sdenom, qloop, g->qdenom);
|
||||||
|
|
||||||
for(int i = 0; i < njobs; i++)
|
for(int i = 0; i < njobs; i++)
|
||||||
{
|
{
|
||||||
gmp_printf("%d/%d %d/%d %s %f\n",
|
gmp_printf("%d/%d %d/%d %d %s %f\n",
|
||||||
inputs[i].snum, inputs[i].sden, inputs[i].qnum, inputs[i].qden,
|
inputs[i].snum, inputs[i].sden, inputs[i].qnum, inputs[i].qden,
|
||||||
|
outputs[i].max_slope_id,
|
||||||
print_word(&n.group->elements[outputs[i].max_slope_id], buf),
|
print_word(&n.group->elements[outputs[i].max_slope_id], buf),
|
||||||
outputs[i].max_slope);
|
outputs[i].max_slope);
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,10 @@ int main(int argc, char *argv[])
|
|||||||
min_slope_index = w;
|
min_slope_index = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode != 2)
|
if(mode != 2) {
|
||||||
gmp_printf("%s %.9f %Qd %Qd\n", argv[w+3], slope, tr, trinv);
|
// gmp_printf("%s %.9f %Qd %Qd\n", argv[w+3], slope, tr, trinv);
|
||||||
|
gmp_printf("%s %.9f %.9f %.9f\n", argv[w+3], slope, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode != 0)
|
if(mode != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user