Skip to content

Commit

Permalink
optimizing some code
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Apr 5, 2019
1 parent a936f8f commit ee2ed3e
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 140 deletions.
48 changes: 48 additions & 0 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,3 +2153,51 @@ int pio_sorted_copy(const void *array, void *sortedarray, io_desc_t *iodesc, int
}
return PIO_NOERR;
}

/**
* Compute the maximum aggregate number of bytes. This is called by
* subset_rearrange_create() and box_rearrange_create().
*
* @param ios pointer to the IO system structure.
* @param iodesc a pointer to decomposition description.
* @returns 0 for success, error code otherwise.
* @author Jim Edwards
*/
int compute_maxaggregate_bytes(iosystem_desc_t *ios, io_desc_t *iodesc)
{
int maxbytesoniotask = INT_MAX;
int maxbytesoncomputetask = INT_MAX;
int maxbytes;
int mpierr; /* Return code from MPI functions. */

/* Check inputs. */
pioassert(iodesc, "invalid input", __FILE__, __LINE__);

LOG((2, "compute_maxaggregate_bytes iodesc->maxiobuflen = %d iodesc->ndof = %d",
iodesc->maxiobuflen, iodesc->ndof));

/* Determine the max bytes that can be held on IO task. */
if (ios->ioproc && iodesc->maxiobuflen > 0)
maxbytesoniotask = pio_buffer_size_limit / iodesc->maxiobuflen;

/* Determine the max bytes that can be held on computation task. */
if (ios->comp_rank >= 0 && iodesc->ndof > 0)
maxbytesoncomputetask = pio_cnbuffer_limit / iodesc->ndof;

/* Take the min of the max IO and max comp bytes. */
maxbytes = min(maxbytesoniotask, maxbytesoncomputetask);
LOG((2, "compute_maxaggregate_bytes maxbytesoniotask = %d maxbytesoncomputetask = %d",
maxbytesoniotask, maxbytesoncomputetask));

/* Get the min value of this on all tasks. */
LOG((3, "before allreaduce maxbytes = %d", maxbytes));
if ((mpierr = MPI_Allreduce(MPI_IN_PLACE, &maxbytes, 1, MPI_INT, MPI_MIN,
ios->union_comm)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
LOG((3, "after allreaduce maxbytes = %d", maxbytes));

/* Remember the result. */
iodesc->maxbytes = maxbytes;

return PIO_NOERR;
}
2 changes: 2 additions & 0 deletions src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ extern "C" {
/* Flush contents of multi-buffer to disk. */
int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize);

int compute_maxaggregate_bytes(iosystem_desc_t *ios, io_desc_t *iodesc);

/* Compute the size that the IO tasks will need to hold the data. */
int compute_maxIObuffersize(MPI_Comm io_comm, io_desc_t *iodesc);

Expand Down
Loading

0 comments on commit ee2ed3e

Please sign in to comment.