Skip to content

Commit

Permalink
Another barrier correctness test which is not based on timers.
Browse files Browse the repository at this point in the history
	timer based test used to do sleep proportional to the rank
	number which resulted in a really long run with 128 ranks
	already.
  • Loading branch information
Valentin Petrov committed Nov 23, 2015
1 parent 6a2e618 commit fe52a0b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
65 changes: 58 additions & 7 deletions examples/cc_barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static int __algorithm_recursive_doubling_proc( void *context )
return rc;
}

#if 0
static int __algorithm_recursive_doubling_check( void *context )
{
int rc = 0;
Expand Down Expand Up @@ -196,6 +197,56 @@ static int __algorithm_recursive_doubling_check( void *context )

return rc;
}
#endif
static int __algorithm_recursive_doubling_check2( void *context )
{
int rc = 0;
struct cc_context *ctx = context;
int num_proc = ctx->conf.num_proc;
int my_proc = ctx->conf.my_proc;
int i;
int *check_array = NULL;
MPI_Request *reqs = NULL;
MPI_Status *statuses = NULL;
if (0 == my_proc) {
check_array = calloc(num_proc,sizeof(int));
reqs = calloc(num_proc,sizeof(MPI_Request));
statuses = calloc(num_proc, sizeof(MPI_Status));
for (i=0; i<num_proc; i++)
MPI_Irecv(&check_array[i],1,MPI_INT,MPI_ANY_SOURCE,123,MPI_COMM_WORLD,&reqs[i]);
}

for (i=0; i<num_proc; i++) {
if (my_proc == i) {
fprintf(stderr,"barrier, rank %d\n",my_proc);
usleep(1000);
MPI_Send(&my_proc,1,MPI_INT,0,123,MPI_COMM_WORLD);
}
__algorithm_recursive_doubling_proc(context);
}

if (0 == my_proc) {
MPI_Waitall(num_proc,reqs,statuses);
for (i=0; i<num_proc; i++) {
if (check_array[i] != i) {
rc = -1; break;
}
}
if (rc == -1) {
fprintf(stderr,"check=[");
for (i=0; i<num_proc-1; i++)
fprintf(stderr,"%d ",check_array[i]);
fprintf(stderr,"%d]\n",check_array[num_proc-1]);
}

free(check_array);
free(reqs);
free(statuses);
}

MPI_Allreduce(MPI_IN_PLACE,&rc,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
return rc;
}

static int __algorithm_recursive_doubling_setup( void *context )
{
Expand Down Expand Up @@ -250,11 +301,11 @@ static int __algorithm_recursive_doubling_close( void *context )
}

static struct cc_alg_info __barrier_algorithm_recursive_doubling_info = {
"Barrier: recursive doubling",
"barrier",
"This algorithm uses Managed QP, IBV_WR_CQE_WAIT, IBV_WR_SEND_ENABLE",
&__algorithm_recursive_doubling_setup,
&__algorithm_recursive_doubling_close,
&__algorithm_recursive_doubling_proc,
&__algorithm_recursive_doubling_check
"Barrier: recursive doubling",
"barrier",
"This algorithm uses Managed QP, IBV_WR_CQE_WAIT, IBV_WR_SEND_ENABLE",
&__algorithm_recursive_doubling_setup,
&__algorithm_recursive_doubling_close,
&__algorithm_recursive_doubling_proc,
&__algorithm_recursive_doubling_check2
};
2 changes: 1 addition & 1 deletion examples/cc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ int main(int argc, char *argv[])

if (!rc && ctx->conf.check && ctx->conf.algorithm->check) {
rc = ctx->conf.algorithm->check(ctx);
log_trace("check accuracy (self-test) result is %s\n", (rc ? "FAIL" : "OK"));
log_fatal("check accuracy (self-test) result is %s\n", (rc ? "FAIL" : "OK"));
}

if (!rc && ctx->conf.warmup) {
Expand Down

0 comments on commit fe52a0b

Please sign in to comment.