Skip to content

Commit b69abc5

Browse files
committed
Remove old implementation
1 parent f636145 commit b69abc5

1 file changed

Lines changed: 3 additions & 251 deletions

File tree

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 3 additions & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,6 @@ void ADIOS2IOHandlerImpl::readAttribute(
12471247
*parameters.dtype = ret;
12481248
}
12491249

1250-
#define openPMD_PREPARSE_EVERYTHING 1
12511250
namespace
12521251
{
12531252
/* Used by both readAttribute() and readAttributeAllsteps() tasks.
@@ -1360,9 +1359,7 @@ namespace
13601359
return determineDatatype<T>();
13611360
}
13621361

1363-
#if openPMD_PREPARSE_EVERYTHING
1364-
1365-
struct ReadAttributeAllstepsFullPreparsing
1362+
struct ReadAttributeAllsteps
13661363
{
13671364
struct GetAttribute
13681365
{
@@ -1383,7 +1380,7 @@ namespace
13831380
Parameter<Operation::READ_ATT_ALLSTEPS>::result_type
13841381
&put_result_here)
13851382
{
1386-
std::vector<T> res;
1383+
auto &res = put_result_here.emplace<std::vector<T>>();
13871384
res.reserve(preload.size());
13881385
for (auto const &p : preload)
13891386
{
@@ -1408,216 +1405,10 @@ namespace
14081405
name,
14091406
GetAttribute{p});
14101407
}
1411-
put_result_here = std::move(res);
1412-
}
1413-
1414-
static constexpr char const *errorMsg =
1415-
"ReadAttributeAllstepsFullPreparsing";
1416-
};
1417-
1418-
#else
1419-
struct ReadAttributeAllsteps
1420-
{
1421-
struct GetAttribute
1422-
{
1423-
adios2::IO &IO;
1424-
template <typename AdiosType>
1425-
[[nodiscard]] auto call(std::string const &name) const
1426-
-> detail::AttributeWithShapeAndResource<AdiosType>
1427-
{
1428-
return {IO.InquireAttribute<AdiosType>(name)};
1429-
}
1430-
};
1431-
1432-
template <typename T>
1433-
static void call(
1434-
adios2::IO &IO,
1435-
adios2::Engine &engine,
1436-
std::string const &name,
1437-
adios2::StepStatus status,
1438-
Parameter<Operation::READ_ATT_ALLSTEPS>::result_type
1439-
&put_result_here)
1440-
{
1441-
std::vector<T> res;
1442-
res.reserve(engine.Steps());
1443-
while (status == adios2::StepStatus::OK)
1444-
{
1445-
genericReadAttribute<T>(
1446-
[&res](auto &&val) {
1447-
using type = std::remove_reference_t<decltype(val)>;
1448-
if constexpr (std::is_same_v<type, bool>)
1449-
{
1450-
throw error::ReadError(
1451-
error::AffectedObject::Attribute,
1452-
error::Reason::UnexpectedContent,
1453-
"ADIOS2",
1454-
"[ReadAttributeAllsteps] No support for "
1455-
"Boolean attributes.");
1456-
}
1457-
else
1458-
{
1459-
res.emplace_back(static_cast<decltype(val)>(val));
1460-
}
1461-
},
1462-
IO,
1463-
name,
1464-
GetAttribute{IO});
1465-
engine.EndStep();
1466-
status = engine.BeginStep();
1467-
}
1468-
switch (status)
1469-
{
1470-
case adios2::StepStatus::OK:
1471-
throw error::Internal("Control flow error.");
1472-
case adios2::StepStatus::NotReady:
1473-
case adios2::StepStatus::OtherError:
1474-
throw error::ReadError(
1475-
error::AffectedObject::File,
1476-
error::Reason::CannotRead,
1477-
"ADIOS2",
1478-
"Unexpected step status while preparsing snapshots.");
1479-
case adios2::StepStatus::EndOfStream:
1480-
break;
1481-
}
1482-
put_result_here = std::move(res);
14831408
}
14841409

14851410
static constexpr char const *errorMsg = "ReadAttributeAllsteps";
14861411
};
1487-
1488-
#if openPMD_HAVE_MPI
1489-
struct DistributeToAllRanks
1490-
{
1491-
template <typename T>
1492-
static void call(
1493-
Parameter<Operation::READ_ATT_ALLSTEPS>::result_type
1494-
&put_result_here_in,
1495-
MPI_Comm comm,
1496-
int rank)
1497-
{
1498-
if (rank != 0)
1499-
{
1500-
put_result_here_in = std::vector<T>{};
1501-
}
1502-
std::vector<T> &put_result_here =
1503-
std::get<std::vector<T>>(put_result_here_in);
1504-
size_t num_items = put_result_here.size();
1505-
MPI_CHECK(MPI_Bcast(
1506-
&num_items, 1, auxiliary::openPMD_MPI_type<size_t>(), 0, comm));
1507-
if constexpr (
1508-
std::is_same_v<T, std::string> ||
1509-
std::is_same_v<T, std::vector<std::string>> ||
1510-
std::is_same_v<T, bool> ||
1511-
std::is_same_v<T, std::vector<bool>> ||
1512-
auxiliary::IsArray_v<T> || isComplexFloatingPoint<T>())
1513-
{
1514-
throw error::OperationUnsupportedInBackend(
1515-
"ADIOS2",
1516-
"[readAttributeAllsteps] No support for attributes of type "
1517-
"std::string, bool, std::complex or std::array in "
1518-
"parallel.");
1519-
}
1520-
else if constexpr (
1521-
// auxiliary::IsArray_v<T> ||
1522-
auxiliary::IsVector_v<T>)
1523-
{
1524-
std::vector<size_t> sizes;
1525-
sizes.reserve(num_items);
1526-
if (rank == 0)
1527-
{
1528-
std::transform(
1529-
put_result_here.begin(),
1530-
put_result_here.end(),
1531-
std::back_inserter(sizes),
1532-
[](T const &arr) { return arr.size(); });
1533-
}
1534-
sizes.resize(num_items);
1535-
MPI_CHECK(MPI_Bcast(
1536-
sizes.data(),
1537-
num_items,
1538-
auxiliary::openPMD_MPI_type<size_t>(),
1539-
0,
1540-
comm));
1541-
size_t total_flat_size =
1542-
std::accumulate(sizes.begin(), sizes.end(), size_t(0));
1543-
using flat_type = typename T::value_type;
1544-
std::vector<flat_type> flat_vector;
1545-
flat_vector.reserve(total_flat_size);
1546-
if (rank == 0)
1547-
{
1548-
for (auto const &arr : put_result_here)
1549-
{
1550-
for (auto val : arr)
1551-
{
1552-
flat_vector.push_back(val);
1553-
}
1554-
}
1555-
}
1556-
flat_vector.resize(total_flat_size);
1557-
MPI_CHECK(MPI_Bcast(
1558-
flat_vector.data(),
1559-
total_flat_size,
1560-
auxiliary::openPMD_MPI_type<flat_type>(),
1561-
0,
1562-
comm));
1563-
if (rank != 0)
1564-
{
1565-
size_t offset = 0;
1566-
put_result_here.reserve(num_items);
1567-
for (size_t current_extent : sizes)
1568-
{
1569-
put_result_here.emplace_back(
1570-
flat_vector.begin() + offset,
1571-
flat_vector.begin() + offset + current_extent);
1572-
offset += current_extent;
1573-
}
1574-
}
1575-
}
1576-
else
1577-
{
1578-
std::vector<T> receive;
1579-
if (rank != 0)
1580-
{
1581-
receive.resize(num_items);
1582-
}
1583-
MPI_CHECK(MPI_Bcast(
1584-
rank == 0 ? put_result_here.data() : receive.data(),
1585-
num_items,
1586-
auxiliary::openPMD_MPI_type<T>(),
1587-
0,
1588-
comm));
1589-
if (rank != 0)
1590-
{
1591-
put_result_here = std::move(receive);
1592-
}
1593-
}
1594-
}
1595-
static constexpr char const *errorMsg = "DistributeToAllRanks";
1596-
};
1597-
1598-
void warn_ignored_modifiable_attributes(adios2::IO &IO)
1599-
{
1600-
auto modifiable_flag = IO.InquireAttribute<detail::bool_representation>(
1601-
adios_defaults::str_useModifiableAttributes);
1602-
auto print_warning = [](std::string const &note) {
1603-
std::cerr << "Warning: " << note << R"(
1604-
Random-access for variable-encoding in ADIOS2 is currently
1605-
experimental. Support for modifiable attributes is currently not implemented
1606-
yet, meaning that attributes such as /data/time will show useless values.
1607-
Use Access::READ_LINEAR to retrieve those values if needed.
1608-
)";
1609-
};
1610-
if (!modifiable_flag)
1611-
{
1612-
print_warning("File might be using modifiable attributes.");
1613-
}
1614-
else if (modifiable_flag.Data().at(0) != 0)
1615-
{
1616-
print_warning("File uses modifiable attributes.");
1617-
}
1618-
}
1619-
#endif // openPMD_HAVE_MPI
1620-
#endif // openPMD_PREPARSE_EVERYTHING
16211412
} // namespace
16221413

16231414
void ADIOS2IOHandlerImpl::readAttributeAllsteps(
@@ -1628,7 +1419,6 @@ void ADIOS2IOHandlerImpl::readAttributeAllsteps(
16281419
auto name = nameOfAttribute(writable, param.name);
16291420
detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError);
16301421

1631-
#if openPMD_PREPARSE_EVERYTHING
16321422
auto type = detail::attributeInfo(ba.m_IO, name, /* verbose = */ true);
16331423
#if openPMD_HAVE_MPI
16341424
auto adios = [&]() {
@@ -1667,46 +1457,8 @@ void ADIOS2IOHandlerImpl::readAttributeAllsteps(
16671457
}
16681458
engine.Close();
16691459
auto &attributes = ba.attributes();
1670-
switchType<ReadAttributeAllstepsFullPreparsing>(
1671-
type, preload, IO, name, *param.resource);
1460+
switchType<ReadAttributeAllsteps>(type, preload, IO, name, *param.resource);
16721461
attributes.m_data = std::move(preload);
1673-
#else
1674-
auto read_from_file_in_serial = [&]() {
1675-
adios2::ADIOS adios;
1676-
auto IO = adios.DeclareIO("PreparseSnapshots");
1677-
IO.SetEngine(ba.m_IO.EngineType());
1678-
IO.SetParameters(ba.m_IO.Parameters());
1679-
IO.SetParameter("StreamReader", "ON"); // this be for BP4
1680-
auto engine = IO.Open(fullPath(*file), adios2::Mode::Read);
1681-
auto status = engine.BeginStep();
1682-
warn_ignored_modifiable_attributes(IO);
1683-
auto type = detail::attributeInfo(IO, name, /* verbose = */ true);
1684-
switchType<ReadAttributeAllsteps>(
1685-
type, IO, engine, name, status, *param.resource);
1686-
engine.Close();
1687-
return type;
1688-
};
1689-
#if openPMD_HAVE_MPI
1690-
if (!m_communicator.has_value())
1691-
{
1692-
read_from_file_in_serial();
1693-
return;
1694-
}
1695-
int rank, size;
1696-
MPI_Comm_rank(*m_communicator, &rank);
1697-
MPI_Comm_size(*m_communicator, &size);
1698-
Datatype type;
1699-
if (rank == 0)
1700-
{
1701-
type = read_from_file_in_serial();
1702-
}
1703-
MPI_CHECK(MPI_Bcast(&type, 1, MPI_INT, 0, *m_communicator));
1704-
switchType<DistributeToAllRanks>(
1705-
type, *param.resource, *m_communicator, rank);
1706-
#else
1707-
read_from_file_in_serial();
1708-
#endif
1709-
#endif
17101462
}
17111463

17121464
void ADIOS2IOHandlerImpl::listPaths(

0 commit comments

Comments
 (0)