Skip to content

Commit

Permalink
prevent use of bad comm if user forgot to pass one
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrush committed Dec 12, 2024
1 parent ffc94bb commit d961df8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/libs/ascent/ascent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ ParRank(int comm_id)
int rank = 0;

#if defined(ASCENT_MPI_ENABLED)
if(mpi_comm_id == -1)
{
// do nothing, an error will be thrown later
// so we can respect the exception handling
return 0;
}
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);
MPI_Comm_rank(mpi_comm, &rank);
#endif
Expand All @@ -63,6 +69,12 @@ ParSize(int comm_id)
int comm_size=1;

#if defined(ASCENT_MPI_ENABLED)
if(mpi_comm_id == -1)
{
// do nothing, an error will be thrown later
// so we can respect the exception handling
return 1;
}
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);
MPI_Comm_size(mpi_comm, &comm_size);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ascent/t_ascent_mpi_ascent_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TEST(ascent_mpi_runtime, test_error_for_mpi_vs_non_mpi)
Ascent ascent;
Node ascent_opts;
ascent_opts["exceptions"] = "forward";
// we throw an error if an mpi_comm is NO provided to a mpi ver of ascent
// we throw an error if an mpi_comm is NOT provided to a mpi ver of ascent
EXPECT_THROW(ascent.open(ascent_opts),conduit::Error);
}

Expand Down

0 comments on commit d961df8

Please sign in to comment.