Skip to content
Snippets Groups Projects
Commit 8a2f65db authored by William F Godoy's avatar William F Godoy
Browse files

Fix collective metadata for attributes

parent 1c424334
No related branches found
No related tags found
1 merge request!299Fix collective metadata for attributes
...@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) ...@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
/** Engine derived class, spawned to start IO operations */ /** Engine derived class, spawned to start IO operations */
adios2::Engine &bpWriter = adios2::Engine &bpWriter =
bpIO.Open("myVector.bp", adios2::Mode::Write); bpIO.Open("fileAttributes.bp", adios2::Mode::Write);
/** Write variable for buffering */ /** Write variable for buffering */
bpWriter.PutSync<float>(bpFloats, myFloats.data()); bpWriter.PutSync<float>(bpFloats, myFloats.data());
......
...@@ -130,7 +130,6 @@ void BPFileReader::ReadVariables( ...@@ -130,7 +130,6 @@ void BPFileReader::ReadVariables(
const std::string subFile( const std::string subFile(
m_BP3Deserializer.GetBPSubFileName(m_Name, subFileIndex)); m_BP3Deserializer.GetBPSubFileName(m_Name, subFileIndex));
// TODO: fix this part
if (m_SubFileManager.m_Transports.count(subFileIndex) == 0) if (m_SubFileManager.m_Transports.count(subFileIndex) == 0)
{ {
m_SubFileManager.OpenFiles({subFile}, adios2::Mode::Read, m_SubFileManager.OpenFiles({subFile}, adios2::Mode::Read,
......
...@@ -300,7 +300,8 @@ BP3Base::ParseCharacteristics(const std::vector<char> &buffer, size_t &position, ...@@ -300,7 +300,8 @@ BP3Base::ParseCharacteristics(const std::vector<char> &buffer, size_t &position,
while (localPosition < characteristics.EntryLength) while (localPosition < characteristics.EntryLength)
{ {
const uint8_t id = ReadValue<uint8_t>(buffer, position); const CharacteristicID id =
static_cast<CharacteristicID>(ReadValue<uint8_t>(buffer, position));
switch (id) switch (id)
{ {
...@@ -321,9 +322,21 @@ BP3Base::ParseCharacteristics(const std::vector<char> &buffer, size_t &position, ...@@ -321,9 +322,21 @@ BP3Base::ParseCharacteristics(const std::vector<char> &buffer, size_t &position,
case (characteristic_value): case (characteristic_value):
{ {
characteristics.Statistics.Value = // we are relying that count contains the dimensions
ReadValue<typename TypeInfo<T>::ValueType>(buffer, position); if (characteristics.Count.empty() || characteristics.Count[0] == 1)
characteristics.Statistics.IsValue = true; {
characteristics.Statistics.Value =
ReadValue<typename TypeInfo<T>::ValueType>(buffer,
position);
characteristics.Statistics.IsValue = true;
}
else // used for attributes
{
const size_t size = characteristics.Count[0];
characteristics.Statistics.Values.resize(size);
CopyFromBuffer(buffer, position,
characteristics.Statistics.Values.data(), size);
}
break; break;
} }
......
...@@ -297,6 +297,8 @@ void BP3Serializer::PutAttributes(IO &io) ...@@ -297,6 +297,8 @@ void BP3Serializer::PutAttributes(IO &io)
Stats<T> stats; \ Stats<T> stats; \
stats.Offset = absolutePosition; \ stats.Offset = absolutePosition; \
stats.MemberID = memberID; \ stats.MemberID = memberID; \
stats.Step = m_MetadataSet.TimeStep; \
stats.FileIndex = static_cast<uint32_t>(m_RankMPI); \
Attribute<T> &attribute = *io.InquireAttribute<T>(name); \ Attribute<T> &attribute = *io.InquireAttribute<T>(name); \
PutAttributeInData(attribute, stats); \ PutAttributeInData(attribute, stats); \
PutAttributeInIndex(attribute, stats); \ PutAttributeInIndex(attribute, stats); \
...@@ -789,7 +791,9 @@ void BP3Serializer::MergeSerializeIndices( ...@@ -789,7 +791,9 @@ void BP3Serializer::MergeSerializeIndices(
uint32_t &timeStep) uint32_t &timeStep)
{ {
switch (dataType) const DataTypes dataTypeEnum = static_cast<DataTypes>(dataType);
switch (dataTypeEnum)
{ {
case (type_string): case (type_string):
...@@ -803,6 +807,17 @@ void BP3Serializer::MergeSerializeIndices( ...@@ -803,6 +807,17 @@ void BP3Serializer::MergeSerializeIndices(
break; break;
} }
case (type_string_array):
{
const auto characteristics =
ReadElementIndexCharacteristics<std::string>(
buffer, position, type_string_array, true);
count = characteristics.EntryCount;
length = characteristics.EntryLength;
timeStep = characteristics.Statistics.Step;
break;
}
case (type_byte): case (type_byte):
{ {
const auto characteristics = ReadElementIndexCharacteristics<char>( const auto characteristics = ReadElementIndexCharacteristics<char>(
...@@ -907,7 +922,13 @@ void BP3Serializer::MergeSerializeIndices( ...@@ -907,7 +922,13 @@ void BP3Serializer::MergeSerializeIndices(
timeStep = characteristics.Statistics.Step; timeStep = characteristics.Statistics.Step;
break; break;
} }
default:
// TODO: complex, string array, long double // TODO: complex, string array, long double
throw std::invalid_argument("ERROR: type " +
std::to_string(dataType) +
" not supported in Merge\n");
} // end switch } // end switch
}; };
......
...@@ -272,6 +272,12 @@ void BP3Serializer::PutAttributeInIndex(const Attribute<T> &attribute, ...@@ -272,6 +272,12 @@ void BP3Serializer::PutAttributeInIndex(const Attribute<T> &attribute,
uint8_t characteristicsCounter = 0; uint8_t characteristicsCounter = 0;
// DIMENSIONS // DIMENSIONS
PutCharacteristicRecord(characteristic_time_index, characteristicsCounter,
stats.Step, buffer);
PutCharacteristicRecord(characteristic_file_index, characteristicsCounter,
stats.FileIndex, buffer);
uint8_t characteristicID = characteristic_dimensions; uint8_t characteristicID = characteristic_dimensions;
InsertToBuffer(buffer, &characteristicID); InsertToBuffer(buffer, &characteristicID);
constexpr uint8_t dimensions = 1; constexpr uint8_t dimensions = 1;
...@@ -285,13 +291,6 @@ void BP3Serializer::PutAttributeInIndex(const Attribute<T> &attribute, ...@@ -285,13 +291,6 @@ void BP3Serializer::PutAttributeInIndex(const Attribute<T> &attribute,
PutAttributeCharacteristicValueInIndex(characteristicsCounter, attribute, PutAttributeCharacteristicValueInIndex(characteristicsCounter, attribute,
buffer); buffer);
// TIME Index
PutCharacteristicRecord(characteristic_time_index, characteristicsCounter,
stats.Step, buffer);
PutCharacteristicRecord(characteristic_file_index, characteristicsCounter,
stats.FileIndex, buffer);
PutCharacteristicRecord(characteristic_offset, characteristicsCounter, PutCharacteristicRecord(characteristic_offset, characteristicsCounter,
stats.Offset, buffer); stats.Offset, buffer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment