Skip to content

Initial ADIOS2 implementation #338

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions example/adios/karman.adios.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<adios-config>

<!--====================================
Configuration for the Writer
====================================-->

<io name="FlaggedGeometry">
<engine type="SST">
<parameter key="verbose" value="5"/>
</engine>
</io>


<!--====================================
Configuration for the Reader
====================================-->

<io name="FlaggedGeometry">
<engine type="SST">
<parameter key="verbose" value="5"/>
</engine>
</io>
</adios-config>
41 changes: 41 additions & 0 deletions example/adios/karman.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>

<CLBConfig version="2.0" output="output/" permissive="true">
<Geometry nx="800" ny="800" nz="1">
<MRT>
<Box/>
</MRT>
<!-- <WVelocity name="Inlet">
<Inlet/>
</WVelocity>
<EPressure name="Outlet">
<Outlet/>
</EPressure>
<Inlet nx="1" dx="5">
<Box/>
</Inlet>
<Outlet nx="1" dx="-5">
<Box/>
</Outlet> -->
<Wall mask="ALL" dx="33" dy="10" nx="734" ny="734">
<Channel/>
<ADIOS2 Stream="globalArray" Variable="GlobalArray" IOName="FlaggedGeometry" AdiosConfig="karman.adios.xml"/>

</Wall>
</Geometry>
<Model>
<Param name="VelocityX" value="0.01"/>
<Param name="Viscosity" value="0.02"/>
<Param name="Smag" value="0.16"/>
<Param name="PressDiffInObj" value="1"/>
<Param name="EOSScale" value="0.05"/>
<Param name="Tension" value="0.01"/>
<Param name="Coriolis" value="0.001"/>
<Param name="SolidAlfa" value="0.166"/>
<Param name="FluidAlfa" value="0.01"/>
<Param name="InitTemperature" value="0"/>
<Param name="InletTemperature" value="1"/>
</Model>
<VTK/>
<!-- <Solve Iterations="10000"/> -->
</CLBConfig>
137 changes: 137 additions & 0 deletions src/Geometry.cpp.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif


#ifdef ADIOS2_USE_MPI
#include <adios2.h>
#endif


<?R
library(gvector,quiet=TRUE,warn.conflicts=FALSE)
library(polyAlgebra,quiet=TRUE,warn.conflicts=FALSE)
Expand Down Expand Up @@ -1038,6 +1044,137 @@ int Geometry::Draw(pugi::xml_node & node)
Dot(x, y, z);
}
fclose(f);
} else if (strcmp(n.name(), "ADIOS2") == 0) {
lbRegion crop = getRegion(n.parent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also has to be in #ifdef

crop = region.intersect(crop);
crop.print();
if (!n.attribute("IOName")) {
error("No 'IOName' attribute in 'ADIOS2' element in xml conf\n");
return -1;
}


if (!n.attribute("Stream")) {
error("No 'Stream' attribute in 'ADIOS2' element in xml conf\n");
return -1;
}

if (!n.attribute("Variable")) {
error("No 'Variable' attribute in 'ADIOS2' element in xml conf\n");
return -1;
}

if (!n.attribute("AdiosConfig")) {
error("No 'AdiosConfig' attribute in 'ADIOS2' element in xml conf\n");
return -1;
}

/** ADIOS class factory of IO class objects */

adios2::ADIOS adios(n.attribute("AdiosConfig").value(),MPI_COMM_WORLD);

/*** IO class object: settings and factory of Settings: Variables,
* Parameters, Transports, and Execution: Engines */
adios2::IO adioIO = adios.DeclareIO(n.attribute("IOName").value());

/** Engine derived class, spawned to start IO operations */
adios2::Engine AdiosReader = adioIO.Open(n.attribute("Stream").value(), adios2::Mode::Read);

const std::map<std::string, adios2::Params> variables = adioIO.AvailableVariables();

for (const auto variablePair : variables)
{
std::cout << "Name: " << variablePair.first;

for (const auto &parameter : variablePair.second)
{
std::cout << "\t" << parameter.first << ": " << parameter.second
<< "\n";
}
}

/** Write variable for buffering */
typedef std::uint8_t FTYPE; //TODO: this should be char_to_bool to save A LOT memory

adios2::Variable<FTYPE> Flags;

if (true)
{


std::cout << reg.dy << " R " << reg.ny<< std::endl;
std::cout << crop.dy << " C " << crop.ny<< std::endl;

size_t local_y0 = crop.dy - reg.dy;
size_t local_ny = crop.ny;

std::cout << "I need Y: " << local_y0 << " COUNT "<< local_ny << std::endl;


std::vector<FTYPE> FlagsBuffer((size_t)reg.nx*local_ny);

// read only the chunk corresponding to our rank
// myFloats.data is pre-allocated


for (int z = reg.dz; z < reg.dz + reg.nz; z++) {

size_t index = 0;

adios2::StepStatus status = AdiosReader.BeginStep(adios2::StepMode::Read, 60.0f);
if (status != adios2::StepStatus::OK)
{
ERROR("ADIOS stream ended or broken - NZ > Number of steps avalible");
break;
}

Flags = adioIO.InquireVariable<FTYPE>(n.attribute("Variable").value());



Flags.SetSelection({{0,local_y0}, {(size_t)reg.nx, local_ny}});

AdiosReader.Get<FTYPE>(Flags, FlagsBuffer.data());

AdiosReader.EndStep();

size_t white = 0;




for (int x = reg.dx; x < reg.dx + reg.nx; x++)
for (int y = reg.dy; y < reg.dy + reg.ny; y++){
if (crop.isIn(x, y, z)){
const bool v = FlagsBuffer[index] == 1;
white = white + FlagsBuffer[index];
if (v) Dot(x, y, z);
index++;
}
}

std::cout << "I've read: MARKED: " << white << " ALL: " << index << std::endl;

}

}
AdiosReader.Close();
/**
for (int x = reg.dx; x < reg.dx + reg.nx; x++)
for (int y = reg.dy; y < reg.dy + reg.ny; y++)
for (int z = reg.dz; z < reg.dz + reg.nz; z++) {
int v;
int ret = fscanf(f, "%d", &v);
if (ret == EOF) {
ERROR("File (%s) ended while reading\n", n.attribute("file").value());
return -1;
}
if ((v != 0) && (crop.isIn(x, y, z)))
Dot(x, y, z);
}
**/


} else {
pugi::xml_node node = fg_xml.find_child_by_attribute("Zone", "name", n.name());
if (node) {
Expand Down
28 changes: 28 additions & 0 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ AC_ARG_WITH([hdf5-include],
AC_HELP_STRING([--with-hdf5-include=hdf5],
[specify the full path to your hdf5 installation (headers)]))

AC_ARG_WITH([adios_dir],
AC_HELP_STRING([--with-adios_dir=adios_dir],
[specify the directory containing bin/adios_config /usr/local/adios2]),
[ADIOS_DIR="$withval"])

AC_ARG_WITH([adios],
AC_HELP_STRING([--enable-adios],
[Enable ADIOS2 support (experimental)]),
[with_adios="$withval"])

AC_ARG_ENABLE([graphics],
AC_HELP_STRING([--enable-graphics],
[make a GUI version]))
Expand Down Expand Up @@ -383,6 +393,24 @@ if test "x${with_hdf5}" != "xno"; then
fi
fi

if test "x${with_adios}" != "xno"; then
adios2_config="${ADIOS_DIR}/bin/adios2-config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where ADIOS2_USE_MPI is set to true.

It has to be:

  1. Add ADIOS2_USE_MPI=1 in the if in configure.ac
  2. Add AC_SUBST(ADIOS2_USE_MPI) at the bottom of configure.ac
  3. Add #undef ADIOS2_USE_MPI to in src/config.h.in

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADIOS2_USE_MPI is an ADIOS config flag (the adios2-config returns it in --flags string) - I'm abusing it a little now

This is to be changed I think:

  • Option 1: If TCLB is MPI then ADIOS must be MPI and vice versa, nice but it doesn't make sense even for testing imho?
  • Option 2: Enable adios in MPI version of TCLB and require ADIOS2_USE_MPI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need our own flag for enabling ADIOS then. Remember that if an flag is in the compilation (like -DFLAG) and not in the source (like #define FLAG 1) then make cannot see the change and will not recompile properly. Please make a flag for the ADIOS support as described above (maybe WITH_ADIOS)

TCLB is always MPI, we don't have an option for that.

AC_CHECK_PROG(adios2_config,${adios2_config},${adios2_config},adios2-config)

AC_MSG_NOTICE([ADIOS2 config: ${adios2_config}])

AC_MSG_CHECKING([ADIOS2 embandinng: linker flags])
LD=$(${adios2_config} --cxx-libs)
LDFLAGS="${LDFLAGS} ${LD}"
AC_MSG_RESULT(["${LD}"])


AC_MSG_CHECKING([ADIOS2 embandinng: linker flags])
LD=$(${adios2_config} --cxx-flags)

CPPFLAGS="${CPPFLAGS} ${LD}"
AC_MSG_RESULT(["${LD}"])
fi

if test "x${with_python}" == "xyes"; then

Expand Down