Skip to content

Commit

Permalink
Merge pull request #1024 from pnorbert/hdf5-blockinfo
Browse files Browse the repository at this point in the history
Hdf5 blockinfo
  • Loading branch information
pnorbert committed Nov 30, 2018
2 parents 2dc1051 + 3fb96e6 commit debceb3
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 2 deletions.
13 changes: 13 additions & 0 deletions source/adios2/engine/hdf5/HDF5ReaderP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,22 @@ void HDF5ReaderP::PerformGets()
{ \
GetSyncCommon(variable, data); \
} \
\
void HDF5ReaderP::DoGetDeferred(Variable<T> &variable, T *data) \
{ \
GetDeferredCommon(variable, data); \
} \
\
std::map<size_t, std::vector<typename Variable<T>::Info>> \
HDF5ReaderP::DoAllStepsBlocksInfo(const Variable<T> &variable) const \
{ \
return GetAllStepsBlocksInfo(variable); \
} \
\
std::vector<typename Variable<T>::Info> HDF5ReaderP::DoBlocksInfo( \
const Variable<T> &variable, const size_t step) const \
{ \
return GetBlocksInfo(variable, step); \
}

ADIOS2_FOREACH_TYPE_1ARG(declare_type)
Expand Down
22 changes: 21 additions & 1 deletion source/adios2/engine/hdf5/HDF5ReaderP.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "adios2/core/IO.h"
#include "adios2/toolkit/interop/hdf5/HDF5Common.h"

#include <map>
#include <vector>

namespace adios2
{
namespace core
Expand Down Expand Up @@ -56,7 +59,12 @@ class HDF5ReaderP : public Engine
unsigned int m_StreamAt = 0; // stream step counter
#define declare_type(T) \
void DoGetSync(Variable<T> &, T *) final; \
void DoGetDeferred(Variable<T> &, T *) final;
void DoGetDeferred(Variable<T> &, T *) final; \
std::map<size_t, std::vector<typename Variable<T>::Info>> \
DoAllStepsBlocksInfo(const Variable<T> &variable) const final; \
\
std::vector<typename Variable<T>::Info> DoBlocksInfo( \
const Variable<T> &variable, const size_t step) const final;
ADIOS2_FOREACH_TYPE_1ARG(declare_type)
#undef declare_type

Expand All @@ -72,6 +80,18 @@ class HDF5ReaderP : public Engine
template <class T>
void GetDeferredCommon(Variable<T> &variable, T *data);

template <class T>
std::map<size_t, std::vector<typename Variable<T>::Info>>
GetAllStepsBlocksInfo(const Variable<T> &variable) const;

template <class T>
std::vector<typename Variable<T>::Info>
GetBlocksInfo(const Variable<T> &variable, const size_t step) const;

template <class T>
std::vector<typename core::Variable<T>::Info>
BlocksInfoCommon(const core::Variable<T> &variable) const;

template <class T>
void UseHDFRead(Variable<T> &variable, T *values, hid_t h5Type);

Expand Down
46 changes: 46 additions & 0 deletions source/adios2/engine/hdf5/HDF5ReaderP.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,52 @@ void HDF5ReaderP::GetDeferredCommon(Variable<T> &variable, T *data)
#endif
}

template <class T>
std::vector<typename core::Variable<T>::Info>
HDF5ReaderP::BlocksInfoCommon(const core::Variable<T> &variable) const
{
std::vector<typename core::Variable<T>::Info> blocksInfo;

typename core::Variable<T>::Info blockInfo;
blockInfo.Start = variable.m_Start;
blockInfo.Count = variable.m_Shape;
if (variable.m_ShapeID == ShapeID::GlobalValue ||
variable.m_ShapeID == ShapeID::LocalValue)
{
blockInfo.IsValue = true;
}
else
{
blockInfo.IsValue = false;
}
blocksInfo.push_back(blockInfo);

return blocksInfo;
}

template <class T>
std::map<size_t, std::vector<typename Variable<T>::Info>>
HDF5ReaderP::GetAllStepsBlocksInfo(const Variable<T> &variable) const
{
std::map<size_t, std::vector<typename core::Variable<T>::Info>>
allStepsBlocksInfo;

for (size_t step = variable.m_AvailableStepsStart;
step < variable.m_AvailableStepsCount; ++step)
{
allStepsBlocksInfo[step - variable.m_AvailableStepsStart] =
BlocksInfoCommon(variable);
}
return allStepsBlocksInfo;
}

template <class T>
std::vector<typename Variable<T>::Info>
HDF5ReaderP::GetBlocksInfo(const Variable<T> &variable, const size_t step) const
{
BlocksInfoCommon(variable);
}

} // end namespace engine
} // end namespace core
} // end namespace adios2
Expand Down
72 changes: 71 additions & 1 deletion testing/utils/iotest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(mpicmd ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG})
#------------------------------------------

#
# Pipe2 InsituMPI version
# Pipe2 BP version
#
set(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}/Pipe2.BP)
file(MAKE_DIRECTORY ${WORKDIR})
Expand Down Expand Up @@ -83,6 +83,76 @@ set_property(TEST Utils.IOTest.Pipe2.BP.ValidateRead
)


if (ADIOS2_HAVE_HDF5)
#
# Pipe2 HDF5 version
#
set(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}/Pipe2.HDF5)
file(MAKE_DIRECTORY ${WORKDIR})

# HDF5 file version Write part
add_test(NAME Utils.IOTest.Pipe2.HDF5.Write
COMMAND ${mpicmd} 2 ${PROJECT_BINARY_DIR}/bin/adios_iotest -a 1 -c ${CMAKE_CURRENT_SOURCE_DIR}/pipe2-HDF5.txt -x ${CMAKE_CURRENT_SOURCE_DIR}/pipe2-HDF5.xml -d 2 1 --strong-scaling
WORKING_DIRECTORY ${WORKDIR}
)

add_test(NAME Utils.IOTest.Pipe2.HDF5.DumpWrite
COMMAND ${CMAKE_COMMAND}
-DARGS=-laD
-DINPUT_FILE=pipe2_write.h5
-DOUTPUT_FILE=IOTest.Pipe2.HDF5.Write.bpls.txt
-P "${PROJECT_BINARY_DIR}/$<CONFIG>/bpls.cmake"
WORKING_DIRECTORY ${WORKDIR}
)

set_property(TEST Utils.IOTest.Pipe2.HDF5.DumpWrite
PROPERTY DEPENDS Utils.IOTest.Pipe2.HDF5.Write
)

add_test(NAME Utils.IOTest.Pipe2.HDF5.ValidateWrite
COMMAND ${CMAKE_COMMAND}
-E compare_files
${CMAKE_CURRENT_SOURCE_DIR}/IOTest.Pipe2.HDF5.Write.bpls.txt
${WORKDIR}/IOTest.Pipe2.HDF5.Write.bpls.txt
WORKING_DIRECTORY ${WORKDIR}
)
set_property(TEST Utils.IOTest.Pipe2.HDF5.ValidateWrite
PROPERTY DEPENDS Utils.IOTest.Pipe2.HDF5.DumpWrite
)

# HDF5 file version Read part

add_test(NAME Utils.IOTest.Pipe2.HDF5.Read
COMMAND ${mpicmd} 2 ${PROJECT_BINARY_DIR}/bin/adios_iotest -a 2 -c ${CMAKE_CURRENT_SOURCE_DIR}/pipe2-HDF5.txt -x ${CMAKE_CURRENT_SOURCE_DIR}/pipe2-HDF5.xml -d 2 1 --strong-scaling
WORKING_DIRECTORY ${WORKDIR}
)

add_test(NAME Utils.IOTest.Pipe2.HDF5.DumpRead
COMMAND ${CMAKE_COMMAND}
-DARGS=-laD
-DINPUT_FILE=pipe2_read.h5
-DOUTPUT_FILE=IOTest.Pipe2.HDF5.Read.bpls.txt
-P "${PROJECT_BINARY_DIR}/$<CONFIG>/bpls.cmake"
WORKING_DIRECTORY ${WORKDIR}
)

set_property(TEST Utils.IOTest.Pipe2.HDF5.DumpRead
PROPERTY DEPENDS Utils.IOTest.Pipe2.HDF5.Read
)

add_test(NAME Utils.IOTest.Pipe2.HDF5.ValidateRead
COMMAND ${CMAKE_COMMAND}
-E compare_files
${CMAKE_CURRENT_SOURCE_DIR}/IOTest.Pipe2.HDF5.Read.bpls.txt
${WORKDIR}/IOTest.Pipe2.HDF5.Read.bpls.txt
WORKING_DIRECTORY ${WORKDIR}
)
set_property(TEST Utils.IOTest.Pipe2.HDF5.ValidateRead
PROPERTY DEPENDS Utils.IOTest.Pipe2.HDF5.DumpRead
)

endif (ADIOS2_HAVE_HDF5)

#
math(EXPR HAVE_2_PROCS "${MPIEXEC_MAX_NUMPROCS} - 1")
if (${HAVE_2_PROCS})
Expand Down
14 changes: 14 additions & 0 deletions testing/utils/iotest/IOTest.Pipe2.HDF5.Read.bpls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
double a 3*{100, 200} = 0 / 0
step 0:
block 0: [ 0:99, 0:199] = 0 / 0
step 1:
block 0: [ 0:99, 0:199] = 0 / 0
step 2:
block 0: [ 0:99, 0:199] = 0 / 0
float b 3*{100} = 0 / 0
step 0:
block 0: [ 0:99] = 0 / 0
step 1:
block 0: [ 0:99] = 0 / 0
step 2:
block 0: [ 0:99] = 0 / 0
21 changes: 21 additions & 0 deletions testing/utils/iotest/IOTest.Pipe2.HDF5.Write.bpls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
double a 3*{100, 200} = 0 / 0
step 0:
block 0: [ 0:99, 0:199] = 0 / 0
step 1:
block 0: [ 0:99, 0:199] = 0 / 0
step 2:
block 0: [ 0:99, 0:199] = 0 / 0
float b 3*{100} = 0 / 0
step 0:
block 0: [ 0:99] = 0 / 0
step 1:
block 0: [ 0:99] = 0 / 0
step 2:
block 0: [ 0:99] = 0 / 0
float c 3*{100, 200, 300} = 0 / 0
step 0:
block 0: [ 0:99, 0:199, 0:299] = 0 / 0
step 1:
block 0: [ 0:99, 0:199, 0:299] = 0 / 0
step 2:
block 0: [ 0:99, 0:199, 0:299] = 0 / 0
50 changes: 50 additions & 0 deletions testing/utils/iotest/pipe2-HDF5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Config file for Task 1 in a pipeline
# - Produce variables a b c
# - Write variables a b c to pipe2_write.h5

# Config file for Task 2 in a pipeline
# - Read in variables a b from Task 1 (ignore c) from pipe2_write.h5
# using a different decomposition
# - Write variables a b to pipe2_read.h5


group io_T1
# item type varname N [dim1 dim2 ... dimN decomp1 decomp2 ... decompN]
array double a 2 100 200 X YZ
array float b 1 100 XYZ
array float c 3 100 200 300 XY z 1

group io_T2_in
# item type varname N [dim1 dim2 ... dimN decomp1 decomp2 ... decompN]
array double a 2 100 200 XY Z
array float b 1 100 XYZ

group io_T2_out
# use all variables read into io_T2_in in the output
link group io_T2_in



# Task 1 actions
app 1
steps 3
sleep 0.1
# write all of io_T1 into pipe2_write.h5
write pipe2_write.h5 io_T1

# Task 2 actions
app 2
steps over pipe2_write.h5
# read a & b from pipe2_write.h5 using io_T2_in definition with blocking wait
read next pipe2_write.h5 io_T2_in -1 a b

# Sleep and write only if read was successful:
cond pipe2_write.h5 sleep 0.1
# write io_T2 into pipe2_read.h5
cond pipe2_write.h5 write pipe2_read.h5 io_T2_out

sleep 0.123456789




44 changes: 44 additions & 0 deletions testing/utils/iotest/pipe2-HDF5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<adios-config>

<!-- example engines
<engine type="BPFile"/>
<engine type="HDF5"/>
<engine type="SST"/>
<engine type="InSituMPI"/>
-->


<!--===========================================
Configuration for io_T1 group
==========================================-->

<io name="io_T1">
<engine type="HDF5">
</engine>
</io>


<!--=========================================
Configuration for io_T2_in group
It should match the io_T1 output group
=========================================-->

<io name="io_T2_in">
<engine type="HDF5">
</engine>
</io>

<!--=========================================
Configuration for io_T2_out group
=========================================-->

<io name="io_T2_out">
<engine type="HDF5">
</engine>
</io>


</adios-config>

0 comments on commit debceb3

Please sign in to comment.