Skip to content

Commit

Permalink
starting to add PIOc calls to test
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Sep 4, 2019
1 parent 5ff9c23 commit 3686e8b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ typedef struct io_desc_t
* everywhere (false) */
bool needsfill;

/** If the map is not monotonically increasing we will need to sort it. */
/** If the map is not monotonically increasing we will need to
* sort it. */
bool needssort;

/** The maximum number of bytes of this iodesc before flushing. */
Expand Down
15 changes: 12 additions & 3 deletions src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
pio_start_mpe_log(DARRAY_READ);
#endif /* USE_MPE */

PLOG((1, "PIOc_read_darray ncid %d varid %d ioid %d arraylen %ld ",
ncid, varid, ioid, arraylen));

/* Get the file info. */
if ((ierr = pio_get_file(ncid, &file)))
return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__);
Expand Down Expand Up @@ -942,12 +945,15 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__);
}

/* If the map is not monotonically increasing we will need to sort
* it. */
PLOG((3, "iodesc->needssort %d", iodesc->needssort));
if (iodesc->needssort)
{
if (!(tmparray = malloc(iodesc->piotype_size*iodesc->maplen)))
if (!(tmparray = malloc(iodesc->piotype_size * iodesc->maplen)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);
for(int m=0; m<iodesc->maplen;m++)
((int *) array)[m] = -1;
for (int m = 0; m < iodesc->maplen; m++)
((int *)array)[m] = -1;
}
else
tmparray = array;
Expand All @@ -956,6 +962,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
if ((ierr = rearrange_io2comp(ios, iodesc, iobuf, tmparray)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

/* If we need to sort the map, do it. */
if (iodesc->needssort)
{
pio_sorted_copy(tmparray, array, iodesc, 1, 1);
Expand All @@ -970,5 +977,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
pio_stop_mpe_log(DARRAY_READ, __func__);
#endif /* USE_MPE */

PLOG((2, "done with PIOc_read_darray()"));

return PIO_NOERR;
}
1 change: 1 addition & 0 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,7 @@ pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid,
return pio_err(ios, NULL, ierr, __FILE__, __LINE__);
#endif /* TIMING */

PLOG((2, "pio_read_darray_nc_serial complete ierr %d", ierr));
return PIO_NOERR;
}

Expand Down
11 changes: 7 additions & 4 deletions src/clib/pio_rearrange.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ define_iodesc_datatypes(iosystem_desc_t *ios, io_desc_t *iodesc)
int ret; /* Return value. */

pioassert(ios && iodesc, "invalid input", __FILE__, __LINE__);
PLOG((1, "define_iodesc_datatypes ios->ioproc = %d iodesc->rtype is %sNULL, iodesc->nrecvs",
ios->ioproc, iodesc->rtype ? "not " : "", iodesc->nrecvs));
PLOG((1, "define_iodesc_datatypes ios->ioproc = %d iodesc->rtype is %sNULL, "
"iodesc->nrecvs %d", ios->ioproc, iodesc->rtype ? "not " : "",
iodesc->nrecvs));

/* Set up the to transfer data to and from the IO tasks. */
if (ios->ioproc)
Expand Down Expand Up @@ -1014,6 +1015,7 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf,

/* Check inputs. */
pioassert(ios && iodesc, "invalid input", __FILE__, __LINE__);
PLOG((2, "rearrange_io2comp iodesc->rearranger %d", iodesc->rearranger));

#ifdef TIMING
/* Start timer if desired. */
Expand All @@ -1033,11 +1035,11 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf,
mycomm = iodesc->subset_comm;
niotasks = 1;
}
PLOG((3, "niotasks = %d", niotasks));

/* Get the size of this communicator. */
if ((mpierr = MPI_Comm_size(mycomm, &ntasks)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
PLOG((3, "niotasks %d ntasks %d", niotasks, ntasks));

/* Define the MPI data types that will be used for this
* io_desc_t. */
Expand Down Expand Up @@ -1106,7 +1108,8 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf,
}
}

/* Data in sbuf on the ionodes is sent to rbuf on the compute nodes */
/* Data in sbuf on the ionodes is sent to rbuf on the compute
* nodes. */
if ((ret = pio_swapm(sbuf, sendcounts, sdispls, sendtypes, rbuf, recvcounts,
rdispls, recvtypes, mycomm, &iodesc->rearr_opts.io2comp)))
return pio_err(ios, NULL, ret, __FILE__, __LINE__);
Expand Down
56 changes: 52 additions & 4 deletions tests/ncint/tst_pio_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ main(int argc, char **argv)
int i;

/* Turn on logging for PIO library. */
PIOc_set_log_level(3);
PIOc_set_log_level(4);
if (!my_rank)
nc_set_log_level(3);

Expand Down Expand Up @@ -93,6 +93,53 @@ main(int argc, char **argv)
if (nc_put_vard_int(ncid, varid, ioid, 0, my_data)) PERR;
if (nc_close(ncid)) PERR;

/* Reopen the file using normal PIO calls. */
{
int ndims, nvars, ngatts, unlimdimid;
nc_type xtype_in;
char var_name_in[NC_MAX_NAME + 1];
char dim_name_in[NC_MAX_NAME + 1];
int natts_in;
int dimids_in[NDIM3];
int iotype = PIO_IOTYPE_NETCDF4C;
size_t dim_len_in;

/* Open the file. */
if (PIOc_openfile(iosysid, &ncid, &iotype, FILE_NAME, 0)) PERR;
if (PIOc_closefile(ncid)) PERR;

/* Check the file. */
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) PERR; */
/* if (ndims != 3 || nvars != 1 || ngatts != 0 || */
/* unlimdimid != 0) PERR; */
/* if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims, */
/* dimids_in, &natts_in)) PERR; */
/* if (strcmp(var_name_in, VAR_NAME) || xtype_in != NC_INT || ndims != NDIM3 */
/* || dimids_in[0] != 0 || dimids_in[1] != 1 || dimids_in[2] != 2 || */
/* natts_in != 0) PERR; */
/* if (nc_inq_dim(ncid, 0, dim_name_in, &dim_len_in)) PERR; */
/* if (strcmp(dim_name_in, DIM_NAME_UNLIMITED) || dim_len_in != 1) PERR; */
/* if (nc_inq_dim(ncid, 1, dim_name_in, &dim_len_in)) PERR; */
/* if (strcmp(dim_name_in, DIM_NAME_X) || dim_len_in != DIM_LEN_X) PERR; */
/* if (nc_inq_dim(ncid, 2, dim_name_in, &dim_len_in)) PERR; */
/* if (strcmp(dim_name_in, DIM_NAME_Y) || dim_len_in != DIM_LEN_Y) PERR; */

/* /\* Read distributed arrays. *\/ */
/* if (!(data_in = malloc(elements_per_pe * sizeof(int)))) PERR; */
/* if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR; */

/* Check results. */
/* for (i = 0; i < elements_per_pe; i++) */
/* if (data_in[i] != my_data[i]) PERR; */

/* Close file. */
/* if (nc_close(ncid)) PERR; */

/* /\* Free resources. *\/ */
/* free(data_in); */
}

/* Reopen the file using netCDF integration. */
{
int ndims, nvars, ngatts, unlimdimid;
nc_type xtype_in;
Expand Down Expand Up @@ -123,18 +170,19 @@ main(int argc, char **argv)

/* Read distributed arrays. */
if (!(data_in = malloc(elements_per_pe * sizeof(int)))) PERR;
if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR;
/* if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR; */

/* Check results. */
/* for (i = 0; i < elements_per_pe; i++) */
/* if (data_in[i] != my_data[i]) PERR; */

/* Close file. */
if (nc_close(ncid)) PERR;

/* Free resources. */
free(data_in);
}

/* Free resources. */
free(data_in);
free(my_data);
if (nc_free_decomp(ioid)) PERR;
if (nc_free_iosystem(iosysid)) PERR;
Expand Down

0 comments on commit 3686e8b

Please sign in to comment.