Skip to content

Commit

Permalink
more development of async code
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 23, 2016
1 parent 58b9466 commit fdd7d8b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/clib/pio_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,24 +617,28 @@ int put_vars_handler(iosystem_desc_t *ios)
if ((mpierr = MPI_Bcast(&start_present, 1, MPI_CHAR, 0, ios->intercomm)))
return PIO_EIO;
if (!mpierr && start_present)
if ((mpierr = MPI_Bcast(start, ndims, MPI_CHAR, 0, ios->intercomm)))
if ((mpierr = MPI_Bcast(start, ndims, MPI_OFFSET, 0, ios->intercomm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast(&count_present, 1, MPI_CHAR, 0, ios->intercomm)))
return PIO_EIO;
if (!mpierr && count_present)
if ((mpierr = MPI_Bcast(count, ndims, MPI_CHAR, 0, ios->intercomm)))
if ((mpierr = MPI_Bcast(count, ndims, MPI_OFFSET, 0, ios->intercomm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast(&stride_present, 1, MPI_CHAR, 0, ios->intercomm)))
return PIO_EIO;
if (!mpierr && stride_present)
if ((mpierr = MPI_Bcast(stride, ndims, MPI_CHAR, 0, ios->intercomm)))
if ((mpierr = MPI_Bcast(stride, ndims, MPI_OFFSET, 0, ios->intercomm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast(&xtype, 1, MPI_INT, 0, ios->intercomm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, 0, ios->intercomm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, 0, ios->intercomm)))
return PIO_EIO;
LOG((1, "put_vars_handler ncid = %d varid = %d ndims = %d start_present = %d "
"count_present = %d stride_present = %d xtype = %d num_elem = %d typelen = %d",
ncid, varid, ndims, start_present, count_present, stride_present, xtype,
num_elem, typelen));

/* Allocate room for our data. */
if (!(buf = malloc(num_elem * typelen)))
Expand All @@ -643,12 +647,10 @@ int put_vars_handler(iosystem_desc_t *ios)
/* Get the data. */
if ((mpierr = MPI_Bcast(buf, num_elem * typelen, MPI_BYTE, 0, ios->intercomm)))
return PIO_EIO;

LOG((1, "att_vars_handler ncid = %d varid = %d ndims = %d start_present = %d "
"count_present = %d stride_present = %d xtype = %d num_elem = %d typelen = %d",
ncid, varid, ndims, start_present, count_present, stride_present, xtype,
num_elem, typelen));

for (int e = 0; e < num_elem; e++)
LOG((2, "element %d = %d", e, ((int *)buf)[e]));

/* Set the non-NULL pointers. */
if (start_present)
startp = start;
Expand Down
7 changes: 6 additions & 1 deletion src/clib/pio_put_nc_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ int PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
num_elem *= (rcount[vd] - rstart[vd])/rstride[vd];
LOG((2, "PIOc_put_vars_tc num_elem = %d", num_elem));
}


sleep(2);
/* If async is in use, and this is not an IO task, bcast the parameters. */
if (ios->async_interface)
{
Expand Down Expand Up @@ -142,13 +143,17 @@ int PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm);
LOG((2, "PIOc_put_vars_tc ncid = %d varid = %d ndims = %d start_present = %d "
"count_present = %d stride_present = %d xtype = %d num_elem = %d", ncid, varid,
ndims, start_present, count_present, stride_present, xtype, num_elem));

/* Send the data. */
if (!mpierr)
mpierr = MPI_Bcast(buf, num_elem * typelen, MPI_BYTE, ios->compmaster,
ios->intercomm);
}

sleep(2);
/* Handle MPI errors. */
if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return check_mpi(file, mpierr2, __FILE__, __LINE__);
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_intercomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,15 @@ main(int argc, char **argv)
if ((ret = PIOc_enddef(ncid)))
ERR(ret);

/* Write some data. */
/* /\* Write some data. *\/ */
/* for (int i = 0; i < LOCAL_DIM_LEN; i++) */
/* data[i] = my_rank; */
/* if (verbose) */
/* printf("%d test_intercomm writing data\n", my_rank); */
/* start[0] = !my_rank ? 0 : 2; */
/* if ((ret = PIOc_put_vara_int(ncid, varid, start, count, data))) */
/* count[0] = 2; */
/* sleep(2); */
/* if ((ret = PIOc_put_vars_tc(ncid, varid, start, count, NULL, NC_INT, data))) */
/* ERR(ret); */

/* Close the file. */
Expand Down

0 comments on commit fdd7d8b

Please sign in to comment.