Skip to content

Commit

Permalink
Merge pull request #3196 from JasonRuonanWang/ssc
Browse files Browse the repository at this point in the history
finish up polishing tests and examples
  • Loading branch information
JasonRuonanWang authored May 2, 2022
2 parents d5c30c3 + 1b2754c commit 03e3e66
Show file tree
Hide file tree
Showing 25 changed files with 1,802 additions and 1,894 deletions.
23 changes: 11 additions & 12 deletions examples/hello/datamanReader/helloDataManReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ int main(int argc, char *argv[])

// initialize adios2
adios2::ADIOS adios(MPI_COMM_WORLD);
adios2::IO dataManIO = adios.DeclareIO("whatever");
dataManIO.SetEngine("DataMan");
dataManIO.SetParameters(
adios2::IO io = adios.DeclareIO("whatever");
io.SetEngine("DataMan");
io.SetParameters(
{{"IPAddress", "127.0.0.1"}, {"Port", "12306"}, {"Timeout", "5"}});

// open stream
adios2::Engine dataManReader =
dataManIO.Open("HelloDataMan", adios2::Mode::Read);
adios2::Engine engine = io.Open("HelloDataMan", adios2::Mode::Read);

// define variable
adios2::Variable<float> floatArrayVar;
Expand All @@ -54,18 +53,18 @@ int main(int argc, char *argv[])
std::vector<float> floatVector;
while (true)
{
auto status = dataManReader.BeginStep();
auto status = engine.BeginStep();
if (status == adios2::StepStatus::OK)
{
floatArrayVar = dataManIO.InquireVariable<float>("FloatArray");
floatArrayVar = io.InquireVariable<float>("FloatArray");
auto shape = floatArrayVar.Shape();
size_t datasize = std::accumulate(shape.begin(), shape.end(), 1,
std::multiplies<size_t>());
floatVector.resize(datasize);
dataManReader.Get<float>(floatArrayVar, floatVector.data(),
adios2::Mode::Sync);
dataManReader.EndStep();
PrintData(floatVector, dataManReader.CurrentStep());
engine.Get<float>(floatArrayVar, floatVector.data(),
adios2::Mode::Sync);
engine.EndStep();
PrintData(floatVector, engine.CurrentStep());
}
else if (status == adios2::StepStatus::EndOfStream)
{
Expand All @@ -75,7 +74,7 @@ int main(int argc, char *argv[])
}

// clean up
dataManReader.Close();
engine.Close();
MPI_Finalize();

return 0;
Expand Down
22 changes: 10 additions & 12 deletions examples/hello/datamanReader/helloDataManReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@
size = comm.Get_size()

adios = adios2.ADIOS(comm)
dataManIO = adios.DeclareIO("whatever")
dataManIO.SetEngine("DataMan")
dataManIO.SetParameters({"IPAddress": "127.0.0.1",
"Port": "12306",
"Timeout": "5"})
io = adios.DeclareIO("whatever")
io.SetEngine("DataMan")
io.SetParameters({"IPAddress": "127.0.0.1", "Port": "12306", "Timeout": "5"})

dataManReader = dataManIO.Open('HelloDataMan', adios2.Mode.Read, comm)
engine = io.Open('HelloDataMan', adios2.Mode.Read, comm)

while True:
stepStatus = dataManReader.BeginStep()
stepStatus = engine.BeginStep()
if stepStatus == adios2.StepStatus.OK:
var = dataManIO.InquireVariable("FloatArray")
var = io.InquireVariable("FloatArray")
shape = var.Shape()
floatArray = np.zeros(np.prod(shape), dtype=np.float32)
dataManReader.Get(var, floatArray, adios2.Mode.Sync)
currentStep = dataManReader.CurrentStep()
dataManReader.EndStep()
engine.Get(var, floatArray, adios2.Mode.Sync)
currentStep = engine.CurrentStep()
engine.EndStep()
print("Step", currentStep, floatArray)
elif stepStatus == adios2.StepStatus.EndOfStream:
print("End of stream")
break

dataManReader.Close()
engine.Close()
28 changes: 13 additions & 15 deletions examples/hello/datamanWriter/helloDataManWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,31 @@ int main(int argc, char *argv[])

// initialize adios2
adios2::ADIOS adios(MPI_COMM_WORLD);
adios2::IO dataManIO = adios.DeclareIO("whatever");
dataManIO.SetEngine("DataMan");
dataManIO.SetParameters({{"IPAddress", "127.0.0.1"},
{"Port", "12306"},
{"Timeout", "5"},
{"RendezvousReaderCount", "1"}});
adios2::IO io = adios.DeclareIO("whatever");
io.SetEngine("DataMan");
io.SetParameters({{"IPAddress", "127.0.0.1"},
{"Port", "12306"},
{"Timeout", "5"},
{"RendezvousReaderCount", "1"}});

// open stream
adios2::Engine dataManWriter =
dataManIO.Open("HelloDataMan", adios2::Mode::Write);
adios2::Engine engine = io.Open("HelloDataMan", adios2::Mode::Write);

// define variable
auto floatArrayVar =
dataManIO.DefineVariable<float>("FloatArray", shape, start, count);
io.DefineVariable<float>("FloatArray", shape, start, count);

// write data
for (size_t i = 0; i < steps; ++i)
{
auto floatVector = GenerateData<float>(i);
dataManWriter.BeginStep();
dataManWriter.Put(floatArrayVar, floatVector.data(),
adios2::Mode::Sync);
PrintData(floatVector, dataManWriter.CurrentStep());
dataManWriter.EndStep();
engine.BeginStep();
engine.Put(floatArrayVar, floatVector.data(), adios2::Mode::Sync);
PrintData(floatVector, engine.CurrentStep());
engine.EndStep();
}

dataManWriter.Close();
engine.Close();
MPI_Finalize();

return 0;
Expand Down
22 changes: 10 additions & 12 deletions examples/hello/datamanWriter/helloDataManWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

Nx = 10
Ny = 10
steps = 100000
steps = 10000

count = [Nx, Ny]
start = [rank * Nx, 0]
Expand All @@ -31,22 +31,20 @@
floatArray[i, j] = (start[0] + i) * shape[1] + (j + start[1])

adios = adios2.ADIOS(comm)
dataManIO = adios.DeclareIO("whatever")
dataManIO.SetEngine("DataMan")
dataManIO.SetParameters({"IPAddress": "127.0.0.1",
"Port": "12306",
"Timeout": "5"})
io = adios.DeclareIO("whatever")
io.SetEngine("DataMan")
io.SetParameters({"IPAddress": "127.0.0.1", "Port": "12306", "Timeout": "5"})

var = dataManIO.DefineVariable(
var = io.DefineVariable(
"FloatArray", floatArray, shape, start, count, adios2.ConstantDims)

dataManWriter = dataManIO.Open('HelloDataMan', adios2.Mode.Write)
engine = io.Open('HelloDataMan', adios2.Mode.Write)

for i in range(steps):
floatArray = floatArray + 1
print("Step", i, floatArray)
dataManWriter.BeginStep()
dataManWriter.Put(var, floatArray)
dataManWriter.EndStep()
engine.BeginStep()
engine.Put(var, floatArray)
engine.EndStep()

dataManWriter.Close()
engine.Close()
Loading

0 comments on commit 03e3e66

Please sign in to comment.