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

finish up polishing tests and examples #3196

Merged
merged 4 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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