Skip to content

Commit

Permalink
WIP: Make Fortran tests fail with a non-zero exit code (ornladios#4097)
Browse files Browse the repository at this point in the history
* Make Fortran tests fail with a non-zero exit code
Co-authored-by: anagainaru <[email protected]>
  • Loading branch information
eisenhauer authored and vicentebolea committed Apr 3, 2024
1 parent e923816 commit 5c6fac3
Show file tree
Hide file tree
Showing 31 changed files with 1,560 additions and 411 deletions.
8 changes: 0 additions & 8 deletions bindings/C/adios2/c/adios2_c_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ adios2_error adios2_set_shape(adios2_variable *variable, const size_t ndims, con

adios2::MemorySpace adios2_ToMemorySpace(const adios2_memory_space Cmem)
{
#ifdef ADIOS2_HAVE_GPU_SUPPORT
adios2::MemorySpace mem = adios2::MemorySpace::Detect;
#else
adios2::MemorySpace mem = adios2::MemorySpace::Host;
#endif
switch (Cmem)
{

Expand All @@ -104,11 +100,7 @@ adios2::MemorySpace adios2_ToMemorySpace(const adios2_memory_space Cmem)

adios2_memory_space adios2_FromMemorySpace(const adios2::MemorySpace mem)
{
#ifdef ADIOS2_HAVE_GPU_SUPPORT
adios2_memory_space Cmem = adios2_memory_space_detect;
#else
adios2_memory_space Cmem = adios2_memory_space_host;
#endif
switch (mem)
{

Expand Down
17 changes: 17 additions & 0 deletions source/adios2/common/ADIOSTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
namespace adios2
{

std::string ToString(MemorySpace value)
{
switch (value)
{
case MemorySpace::Detect:
return "MemorySpace::Detect";
case MemorySpace::Host:
return "MemorySpace::Host";
#ifdef ADIOS2_HAVE_GPU_SUPPORT
case MemorySpace::GPU:
return "MemorySpace::GPU";
#endif
default:
return "ToString: Unknown MemorySpace";
}
}

std::string ToString(ShapeID value)
{
switch (value)
Expand Down
1 change: 1 addition & 0 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ std::string ToString(SelectionType value);
std::string ToString(DataType type);
std::string ToString(const Dims &dims);
std::string ToString(const Box<Dims> &box);
std::string ToString(const MemorySpace value);

/**
* os << [adios2_type] enables output of adios2 enums/classes directly
Expand Down
4 changes: 0 additions & 4 deletions source/adios2/core/VariableBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ class VariableBase
const size_t m_ElementSize;

/* User requested memory space */
#ifdef ADIOS2_HAVE_GPU_SUPPORT
MemorySpace m_MemSpace = MemorySpace::Detect;
#else
MemorySpace m_MemSpace = MemorySpace::Host;
#endif
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
ArrayOrdering m_BaseLayout;
ArrayOrdering m_ArrayLayout = ArrayOrdering::Auto;
Expand Down
5 changes: 3 additions & 2 deletions source/adios2/engine/dataman/DataManReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ void DataManReader::GetSyncCommon(Variable<T> &variable, T *data)
template <class T>
void DataManReader::GetDeferredCommon(Variable<T> &variable, T *data)
{
auto varMemSpace = variable.GetMemorySpace(data);
if (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor)
{
while (true)
{
int ret = m_Serializer.GetData(data, variable.m_Name, variable.m_Start,
variable.m_Count, m_CurrentStep, variable.m_MemSpace,
variable.m_Count, m_CurrentStep, varMemSpace,
variable.m_MemoryStart, variable.m_MemoryCount);
if (ret == 0)
{
Expand All @@ -57,7 +58,7 @@ void DataManReader::GetDeferredCommon(Variable<T> &variable, T *data)
while (true)
{
int ret = m_Serializer.GetData(data, variable.m_Name, start, count, m_CurrentStep,
variable.m_MemSpace, memstart, memcount);
varMemSpace, memstart, memcount);
if (ret == 0)
{
break;
Expand Down
5 changes: 3 additions & 2 deletions source/adios2/engine/dataman/DataManWriter.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ void DataManWriter::PutSyncCommon(Variable<T> &variable, const T *values)
template <class T>
void DataManWriter::PutDeferredCommon(Variable<T> &variable, const T *values)
{
auto varMemSpace = variable.GetMemorySpace(values);
variable.SetData(values);
if (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor)
{
m_Serializer.PutData(variable, m_Name, CurrentStep(), m_MpiRank, "");
m_Serializer.PutData(variable, m_Name, CurrentStep(), m_MpiRank, varMemSpace, "");
}
else
{
Expand All @@ -49,7 +50,7 @@ void DataManWriter::PutDeferredCommon(Variable<T> &variable, const T *values)
std::reverse(memstart.begin(), memstart.end());
std::reverse(memcount.begin(), memcount.end());
m_Serializer.PutData(variable.m_Data, variable.m_Name, shape, start, count, memstart,
memcount, variable.m_MemSpace, m_Name, CurrentStep(), m_MpiRank, "",
memcount, varMemSpace, m_Name, CurrentStep(), m_MpiRank, "",
variable.m_Operations);
}

Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/format/dataman/DataManSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class DataManSerializer
// another wrapper for PutData which accepts adios2::core::Variable
template <class T>
void PutData(const core::Variable<T> &variable, const std::string &doid, const size_t step,
const int rank, const std::string &address, VecPtr localBuffer = nullptr,
JsonPtr metadataJson = nullptr);
const int rank, const MemorySpace varMemSpace, const std::string &address,
VecPtr localBuffer = nullptr, JsonPtr metadataJson = nullptr);

// attach attributes to local pack
void AttachAttributesToLocalPack();
Expand Down
9 changes: 5 additions & 4 deletions source/adios2/toolkit/format/dataman/DataManSerializer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ void DataManSerializer::CalculateMinMax(const T *data, const Dims &count,

template <class T>
void DataManSerializer::PutData(const core::Variable<T> &variable, const std::string &doid,
const size_t step, const int rank, const std::string &address,
VecPtr localBuffer, JsonPtr metadataJson)
const size_t step, const int rank, const MemorySpace memSpace,
const std::string &address, VecPtr localBuffer,
JsonPtr metadataJson)
{
PERFSTUBS_SCOPED_TIMER_FUNC();
PutData(variable.GetData(), variable.m_Name, variable.m_Shape, variable.m_Start,
variable.m_Count, variable.m_MemoryStart, variable.m_MemoryCount, variable.m_MemSpace,
doid, step, rank, address, variable.m_Operations, localBuffer, metadataJson);
variable.m_Count, variable.m_MemoryStart, variable.m_MemoryCount, memSpace, doid, step,
rank, address, variable.m_Operations, localBuffer, metadataJson);
}

template <class T>
Expand Down
35 changes: 28 additions & 7 deletions testing/adios2/bindings/fortran/TestAdios2BindingsFortranIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ subroutine testing_adios_io_finalize()

! FIXME, shouldn't we be able to do this by handle?
call adios2_remove_io(result, adios, "TestIo", ierr)
if ((ierr /= 0) .or. (result .neqv. .true.)) stop "FAIL: adios2_remove_io"
if ((ierr /= 0) .or. (result .neqv. .true.)) then
write(*,*) "FAIL: adios2_remove_io"
stop 1
end if
call testing_adios_finalize()

end subroutine testing_adios_io_finalize
Expand Down Expand Up @@ -88,18 +91,27 @@ subroutine testing_adios_io_engine()
call adios2_set_engine(io, "file", ierr)

call adios2_io_engine_type(engine_type, io, ierr)
if (engine_type /= "file") stop "FAIL adios2_io_engine_type"
if (engine_type /= "file") then
write(*,*) "FAIL adios2_io_engine_type"
stop 1
end if
deallocate(engine_type)

call adios2_open(engine, io, "ftypes.bp", adios2_mode_write, ierr)

if (engine%type /= "BP5Writer") stop "FAIL engine%type"
if (engine%type /= "BP5Writer") then
write(*,*) "FAIL engine%type"
stop 1
end if
! // FIXME, I'd like to check that the engine type itself is correct, but
! // there's no (function-style) API to get it
! // FIXME, I'd like to check the engine's name, but there's no API to get it

call adios2_io_engine_type(engine_type, io, ierr)
if (engine_type /= "file") stop "FAIL adios2_io_engine_type"
if (engine_type /= "file") then
write(*,*) "FAIL adios2_io_engine_type"
stop 1
end if
deallocate(engine_type)

call testing_adios_io_finalize()
Expand All @@ -123,18 +135,27 @@ subroutine testing_adios_io_engine_default()
call adios2_set_engine(io, "", ierr)

call adios2_io_engine_type(engine_type, io, ierr)
if (engine_type /= "") stop "FAIL adios2_io_engine_type"
if (engine_type /= "") then
write(*,*) "FAIL adios2_io_engine_type"
stop 1
end if
deallocate(engine_type)

call adios2_open(engine, io, "ftypes.bp", adios2_mode_write, ierr)

if (engine%type /= "BP5Writer") stop "FAIL engine%type"
if (engine%type /= "BP5Writer") then
write(*,*) "FAIL engine%type"
stop 1
end if
! // FIXME, I'd like to check that the engine type itself is correct, but
! // there's no (function-style) API to get it
! // FIXME, I'd like to check the engine's name, but there's no API to get it

call adios2_io_engine_type(engine_type, io, ierr)
if (engine_type /= "") stop "FAIL adios2_io_engine_type"
if (engine_type /= "") then
write(*,*) "FAIL adios2_io_engine_type"
stop 1
end if
deallocate(engine_type)

call testing_adios_io_finalize
Expand Down
30 changes: 24 additions & 6 deletions testing/adios2/bindings/fortran/TestBPMemorySpace.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ program TestBPMemorySpace
start_dims(1) = 0
count_dims(1) = 10

if( adios%valid .eqv. .true. ) stop 'Invalid adios default'
if( variable%valid .eqv. .true. ) stop 'Invalid variables default'
if( adios%valid .eqv. .true. ) then
write(*,*) 'Invalid adios default'
stop 1
end if
if( variable%valid .eqv. .true. ) then
write(*,*) 'Invalid variables default'
stop 1
end if

call adios2_init(adios, ierr)
if( adios%valid .eqv. .false. ) stop 'Invalid adios2_init'
if( adios%valid .eqv. .false. ) then
write(*,*) 'Invalid adios2_init'
stop 1
end if

call adios2_declare_io(ioWrite, adios, "ioWrite", ierr)
if( ioWrite%valid .eqv. .false. ) stop 'Invalid adios2_declare_io'
if( ioWrite%valid .eqv. .false. ) then
write(*,*) 'Invalid adios2_declare_io'
stop 1
end if

call adios2_set_engine(ioWrite, 'File', ierr)

Expand All @@ -31,11 +43,17 @@ program TestBPMemorySpace

! check that the default execution space is Detect
call adios2_get_memory_space(mem, variable, ierr)
if (mem /= adios2_memory_space_detect) stop 'Invalid adios2_memory_space'
if (mem /= adios2_memory_space_detect) then
write(*,*) 'Invalid default adios2_memory_space'
stop 1
end if

! check that the execution space is updated to Host
call adios2_set_memory_space(variable, adios2_memory_space_host, ierr)
call adios2_get_memory_space(mem, variable, ierr)
if (mem /= adios2_memory_space_host) stop 'Invalid adios2_memory_space'
if (mem /= adios2_memory_space_host) then
write(*,*) 'Invalid set adios2_memory_space'
stop 1
end if

end program TestBPMemorySpace
30 changes: 24 additions & 6 deletions testing/adios2/bindings/fortran/TestBPMemorySpaceGPU.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ program TestBPMemorySpace
start_dims(1) = 0
count_dims(1) = 10

if( adios%valid .eqv. .true. ) stop 'Invalid adios default'
if( variable%valid .eqv. .true. ) stop 'Invalid variables default'
if( adios%valid .eqv. .true. ) then
write(*,*) 'Invalid adios default'
stop 1
end if
if( variable%valid .eqv. .true. ) then
write(*,*) 'Invalid variables default'
stop 1
end if

call adios2_init(adios, ierr)
if( adios%valid .eqv. .false. ) stop 'Invalid adios2_init'
if( adios%valid .eqv. .false. ) then
write(*,*) 'Invalid adios2_init'
stop 1
end if

call adios2_declare_io(ioWrite, adios, "ioWrite", ierr)
if( ioWrite%valid .eqv. .false. ) stop 'Invalid adios2_declare_io'
if( ioWrite%valid .eqv. .false. ) then
write(*,*) 'Invalid adios2_declare_io'
stop 1
end if

call adios2_set_engine(ioWrite, 'File', ierr)

Expand All @@ -31,11 +43,17 @@ program TestBPMemorySpace

! check that the default execution space is Detect
call adios2_get_memory_space(mem, variable, ierr)
if (mem /= adios2_memory_space_detect) stop 'Invalid adios2_memory_space'
if (mem /= adios2_memory_space_detect) then
write(*,*) 'Invalid default adios2_memory_space'
stop 1
end if

! check that the execution space is updated to GPU
call adios2_set_memory_space(variable, adios2_memory_space_gpu, ierr)
call adios2_get_memory_space(mem, variable, ierr)
if (mem /= adios2_memory_space_gpu) stop 'Invalid adios2_memory_space'
if (mem /= adios2_memory_space_gpu) then
write(*,*) 'Invalid set adios2_memory_space'
stop 1
end if

end program TestBPMemorySpace
11 changes: 8 additions & 3 deletions testing/adios2/bindings/fortran/TestBPReadGlobalsByName.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ program TestBPReadGlobalsByName
call adios2_put(writer, "sml_outpsi", 0.295477_8, ierr)
call adios2_close(writer, ierr)

if(ierr /= 0) stop 'Problems writing'
if(ierr /= 0) then
write(*,*) 'Problems writing'
stop 1
end if
call MPI_Barrier(MPI_COMM_WORLD, ierr)

! reader
Expand All @@ -60,11 +63,13 @@ program TestBPReadGlobalsByName
print *, irank, 'sml_outpsi', sml_outpsi

if( diag_1d_nsp /= 1 ) then
stop 'diag_1d_nsp is not 1'
write(*,*) 'diag_1d_nsp is not 1'
stop 1
end if

if( sml_outpsi /= 0.295477_8 ) then
stop 'sml_outpsi is not 0.295477'
write(*,*) 'sml_outpsi is not 0.295477'
stop 1
end if

call MPI_Finalize(ierr)
Expand Down
Loading

0 comments on commit 5c6fac3

Please sign in to comment.