Skip to content
Snippets Groups Projects
Unverified Commit 7f340155 authored by williamfgc's avatar williamfgc Committed by GitHub
Browse files

Merge pull request #299 from williamfgc/attribute_meta

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