Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIOc_inq_var returned value consistency check #521

Open
wkliao opened this issue Jun 2, 2023 · 0 comments
Open

PIOc_inq_var returned value consistency check #521

wkliao opened this issue Jun 2, 2023 · 0 comments
Assignees
Labels

Comments

@wkliao
Copy link
Member

wkliao commented Jun 2, 2023

FYI. In PnetCDF inq_var family APIs are independent APIs.
If PIOc_inq_var intends to be collective, then isn't it sufficient
to just check the consistency of ncid and varid? That way,
you can save those Bcast calls at the end. Such Bcast consistency
checks should be the PnetCDF/HDF5/ADIOS I/O library's responsibility.

scorpio/src/clib/pio_nc.c

Lines 1436 to 1560 in ac679a5

/* Broadcast the results for non-null pointers. */
if (ios->iomaster == MPI_ROOT)
slen = strlen(my_name);
if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
if ((mpierr = MPI_Bcast((void *)my_name, slen + 1, MPI_CHAR, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
if (name && namelen > 0)
{
assert(namelen <= PIO_MAX_NAME + 1);
strncpy(name, my_name, namelen);
}
strncpy(file->varlist[varid].vname, my_name, PIO_MAX_NAME);
#ifdef PIO_MICRO_TIMING
/* Create timers for the variable
* - Assuming that we don't reuse varids
* - Also assuming that a timer is needed if we query about a var
* */
snprintf(timer_log_fname, PIO_MAX_NAME, "piorwinfo%010dwrank.dat", ios->ioroot);
if(!mtimer_is_valid(file->varlist[varid].rd_mtimer))
{
char tmp_timer_name[PIO_MAX_NAME];
snprintf(tmp_timer_name, PIO_MAX_NAME, "%s_%s", "rd", file->varlist[varid].vname);
file->varlist[varid].rd_mtimer = mtimer_create(tmp_timer_name, ios->my_comm, timer_log_fname);
if(!mtimer_is_valid(file->varlist[varid].rd_mtimer))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return pio_err(ios, file, PIO_EINTERNAL, __FILE__, __LINE__,
"Inquiring information of variable %s (varid=%d) failed on file %s (ncid=%d) failed. Error creating micro timer (read) for variable", pio_get_vname_from_file(file, varid), varid, pio_get_fname_from_file(file), ncid);
}
assert(!mtimer_is_valid(file->varlist[varid].rd_rearr_mtimer));
snprintf(tmp_timer_name, PIO_MAX_NAME, "%s_%s", "rd_rearr", file->varlist[varid].vname);
file->varlist[varid].rd_rearr_mtimer = mtimer_create(tmp_timer_name, ios->my_comm, timer_log_fname);
if(!mtimer_is_valid(file->varlist[varid].rd_rearr_mtimer))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return pio_err(ios, file, PIO_EINTERNAL, __FILE__, __LINE__,
"Inquiring information of variable %s (varid=%d) failed on file %s (ncid=%d) failed. Error creating micro timer (read rearrange) for variable", pio_get_vname_from_file(file, varid), varid, pio_get_fname_from_file(file), ncid);
}
snprintf(tmp_timer_name, PIO_MAX_NAME, "%s_%s", "wr", file->varlist[varid].vname);
file->varlist[varid].wr_mtimer = mtimer_create(tmp_timer_name, ios->my_comm, timer_log_fname);
if(!mtimer_is_valid(file->varlist[varid].wr_mtimer))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return pio_err(ios, file, PIO_EINTERNAL, __FILE__, __LINE__,
"Inquiring information of variable %s (varid=%d) failed on file %s (ncid=%d) failed. Error creating micro timer (write) for variable", pio_get_fname_from_file(file), varid, pio_get_fname_from_file(file), ncid);
}
assert(!mtimer_is_valid(file->varlist[varid].wr_rearr_mtimer));
snprintf(tmp_timer_name, PIO_MAX_NAME, "%s_%s", "wr_rearr", file->varlist[varid].vname);
file->varlist[varid].wr_rearr_mtimer = mtimer_create(tmp_timer_name, ios->my_comm, timer_log_fname);
if(!mtimer_is_valid(file->varlist[varid].wr_rearr_mtimer))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return pio_err(ios, file, PIO_EINTERNAL, __FILE__, __LINE__,
"Inquiring information of variable %s (varid=%d) failed on file %s (ncid=%d) failed. Error creating micro timer (write rearrange) for variable", pio_get_vname_from_file(file, varid), varid, pio_get_fname_from_file(file), ncid);
}
}
#endif
if ((mpierr = MPI_Bcast(&(file->varlist[varid].rec_var), 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
if (xtypep)
if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
if (ndimsp)
{
LOG((2, "PIOc_inq_var about to Bcast ndims = %d ios->ioroot = %d ios->my_comm = %d",
*ndimsp, ios->ioroot, ios->my_comm));
if ((mpierr = MPI_Bcast(ndimsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
LOG((2, "PIOc_inq_var Bcast ndims = %d", *ndimsp));
}
if (dimidsp)
{
if ((mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
if ((mpierr = MPI_Bcast(dimidsp, ndims, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
}
if (nattsp)
if ((mpierr = MPI_Bcast(nattsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return PIO_NOERR;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants