Skip to content

Commit

Permalink
Merge pull request #3291 from pnorbert/fix-bpls-28
Browse files Browse the repository at this point in the history
Fix bpls 28
  • Loading branch information
pnorbert authored Jul 25, 2022
2 parents 02283b1 + e1762c3 commit ac58b84
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 88 deletions.
4 changes: 2 additions & 2 deletions bindings/C/adios2/c/adios2_c_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine,
auto *b = varinfo->BlocksInfo;

varinfo->Dims = minBlocksInfo->Dims;
if (minBlocksInfo->WasLocalVar)
if (minBlocksInfo->WasLocalValue)
{
varinfo->Shape = (size_t *)malloc(sizeof(size_t));
varinfo->Shape[0] = (intptr_t)minBlocksInfo->Shape;
Expand All @@ -670,7 +670,7 @@ adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine,
{
b[i].WriterID = minBlocksInfo->BlocksInfo[i].WriterID;
b[i].BlockID = minBlocksInfo->BlocksInfo[i].BlockID;
if (minBlocksInfo->WasLocalVar)
if (minBlocksInfo->WasLocalValue)
{
b[i].Start = (size_t *)malloc(sizeof(size_t));
b[i].Start[0] =
Expand Down
2 changes: 1 addition & 1 deletion bindings/CXX11/adios2/cxx11/Variable.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Variable<T>::ToBlocksInfoMin(const MinVarInfo *coreVarInfo) const
{
blockInfo.Start.reserve(coreVarInfo->Dims);
blockInfo.Count.reserve(coreVarInfo->Dims);
if (coreVarInfo->WasLocalVar)
if (coreVarInfo->WasLocalValue)
{
/* Start and count are really values, not pointers */
blockInfo.Start.push_back((size_t)coreBlockInfo.Start);
Expand Down
1 change: 0 additions & 1 deletion examples/basics/localArray/localArray_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ int main(int argc, char *argv[])
* Inline uses single IO for write/read */
adios2::IO io = adios.DeclareIO("Input");

io.SetEngine("BP3");
io.SetParameters({{"verbose", "4"}});

adios2::Engine reader = io.Open("localArray.bp", adios2::Mode::Read);
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/localArray/localArray_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int main(int argc, char *argv[])
// Get io settings from the config file or
// create one with default settings here
adios2::IO io = adios.DeclareIO("Output");
io.SetEngine("BP3");
io.SetEngine("BP5");
io.SetParameters({{"verbose", "4"}});

/*
Expand Down
3 changes: 2 additions & 1 deletion examples/basics/values/values_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ int main(int argc, char *argv[])
// Get io settings from the config file or
// create one with default settings here
adios2::IO io = adios.DeclareIO("Output");

io.SetEngine("BP5");
io.SetParameters({{"verbose", "4"}});
/*
* Define variables
*/
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct MinBlockInfo
struct MinVarInfo
{
size_t Step;
bool WasLocalVar;
bool WasLocalValue; // writer: localValue -> reader: 1D global array
int Dims;
size_t *Shape;
bool IsValue = false;
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step)
MV->IsReverseDims =
((MV->Dims > 1) && (m_WriterIsRowMajor != m_ReaderIsRowMajor));

MV->WasLocalVar = (VarRec->OrigShapeID == ShapeID::LocalValue);
MV->WasLocalValue = (VarRec->OrigShapeID == ShapeID::LocalValue);
if ((VarRec->OrigShapeID == ShapeID::LocalValue) ||
(VarRec->OrigShapeID == ShapeID::GlobalValue))
{
Expand Down
179 changes: 99 additions & 80 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,16 +3058,18 @@ Dims get_global_array_signature(core::Engine *fp, core::IO *io,

if (minBlocks)
{
delete minBlocks;
for (size_t step = 0; step < nsteps; step++)
{
minBlocks = fp->MinBlocksInfo(*variable, step);
if (step > 0)
{
minBlocks = fp->MinBlocksInfo(*variable, step);
}
if (minBlocks->Shape)
{
for (size_t k = 0; k < ndim; k++)
{
size_t n =
(minBlocks->WasLocalVar
(minBlocks->WasLocalValue
? reinterpret_cast<size_t>(minBlocks->Shape)
: minBlocks->Shape[k]);
if (firstStep)
Expand All @@ -3083,34 +3085,36 @@ Dims get_global_array_signature(core::Engine *fp, core::IO *io,
}
delete minBlocks;
}
return dims;
}
const std::map<size_t, std::vector<size_t>> &indices =
variable->m_AvailableStepBlockIndexOffsets;
auto itStep = indices.begin();

for (size_t step = 0; step < nsteps; step++)
else
{
const size_t absstep = itStep->first;
Dims d = variable->Shape(absstep - 1);
if (d.empty())
{
continue;
}
const std::map<size_t, std::vector<size_t>> &indices =
variable->m_AvailableStepBlockIndexOffsets;
auto itStep = indices.begin();

for (size_t k = 0; k < ndim; k++)
for (size_t step = 0; step < nsteps; step++)
{
if (firstStep)
const size_t absstep = itStep->first;
Dims d = variable->Shape(absstep - 1);
if (d.empty())
{
dims[k] = d[k];
continue;
}
else if (dims[k] != d[k])

for (size_t k = 0; k < ndim; k++)
{
dims[k] = 0;
if (firstStep)
{
dims[k] = d[k];
}
else if (dims[k] != d[k])
{
dims[k] = 0;
}
}
firstStep = false;
++itStep;
}
firstStep = false;
++itStep;
}
}
return dims;
Expand Down Expand Up @@ -3149,26 +3153,29 @@ std::pair<size_t, Dims> get_local_array_signature(core::Engine *fp,
firstBlock = false;
}
}
std::vector<typename core::Variable<T>::BPInfo> blocks =
fp->BlocksInfo(*variable, fp->CurrentStep());
if (!blocks.empty())
else
{
nblocks = blocks.size();
bool firstBlock = true;
for (size_t j = 0; j < nblocks; j++)
std::vector<typename core::Variable<T>::BPInfo> blocks =
fp->BlocksInfo(*variable, fp->CurrentStep());
if (!blocks.empty())
{
for (size_t k = 0; k < ndim; k++)
nblocks = blocks.size();
bool firstBlock = true;
for (size_t j = 0; j < nblocks; j++)
{
if (firstBlock)
{
dims[k] = blocks[j].Count[k];
}
else if (dims[k] != blocks[j].Count[k])
for (size_t k = 0; k < ndim; k++)
{
dims[k] = 0;
if (firstBlock)
{
dims[k] = blocks[j].Count[k];
}
else if (dims[k] != blocks[j].Count[k])
{
dims[k] = 0;
}
}
firstBlock = false;
}
firstBlock = false;
}
}
}
Expand All @@ -3184,14 +3191,16 @@ std::pair<size_t, Dims> get_local_array_signature(core::Engine *fp,
if (minBlocksInfo)
{
dims.resize(minBlocksInfo->Dims);
delete minBlocksInfo;
size_t RelStep = 0;
for (RelStep = 0; RelStep < variable->m_AvailableStepsCount;
RelStep++)
{
minBlocksInfo = fp->MinBlocksInfo(*variable, RelStep);
if (RelStep > 0)
{
minBlocksInfo = fp->MinBlocksInfo(*variable, RelStep);
}

auto coreBlocksInfo = minBlocksInfo->BlocksInfo;
auto &coreBlocksInfo = minBlocksInfo->BlocksInfo;
if (firstStep)
{
nblocks = coreBlocksInfo.size();
Expand Down Expand Up @@ -3224,40 +3233,42 @@ std::pair<size_t, Dims> get_local_array_signature(core::Engine *fp,
firstStep = false;
}
}

std::map<size_t, std::vector<typename core::Variable<T>::BPInfo>>
allblocks = fp->AllStepsBlocksInfo(*variable);

for (auto &blockpair : allblocks)
else
{
std::vector<typename adios2::core::Variable<T>::BPInfo> &blocks =
blockpair.second;
const size_t blocksSize = blocks.size();
if (firstStep)
{
nblocks = blocksSize;
}
else if (nblocks != blocksSize)
{
nblocks = 0;
}
std::map<size_t, std::vector<typename core::Variable<T>::BPInfo>>
allblocks = fp->AllStepsBlocksInfo(*variable);

for (size_t j = 0; j < blocksSize; j++)
for (auto &blockpair : allblocks)
{
for (size_t k = 0; k < ndim; k++)
std::vector<typename adios2::core::Variable<T>::BPInfo>
&blocks = blockpair.second;
const size_t blocksSize = blocks.size();
if (firstStep)
{
if (firstBlock)
{
dims[k] = blocks[j].Count[k];
}
else if (dims[k] != blocks[j].Count[k])
nblocks = blocksSize;
}
else if (nblocks != blocksSize)
{
nblocks = 0;
}

for (size_t j = 0; j < blocksSize; j++)
{
for (size_t k = 0; k < ndim; k++)
{
dims[k] = 0;
if (firstBlock)
{
dims[k] = blocks[j].Count[k];
}
else if (dims[k] != blocks[j].Count[k])
{
dims[k] = 0;
}
}
firstBlock = false;
}
firstBlock = false;
firstStep = false;
}
firstStep = false;
}
}
return std::make_pair(nblocks, dims);
Expand All @@ -3280,8 +3291,8 @@ void print_decomp(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
// first step
if (minBlocksInfo)
{
delete minBlocksInfo;
size_t laststep = minBlocksInfo->Step; // used relative last step above
delete minBlocksInfo;
int ndigits_nsteps = ndigits(laststep);
if (variable->m_ShapeID == ShapeID::GlobalValue ||
variable->m_ShapeID == ShapeID::LocalValue)
Expand Down Expand Up @@ -3370,18 +3381,18 @@ void print_decomp(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
for (size_t k = 0; k < ndim; k++)
{
size_t c =
(minBlocksInfo->WasLocalVar
(minBlocksInfo->WasLocalValue
? reinterpret_cast<size_t>(blocks[j].Count)
: blocks[j].Count[k]);

if (c)
{
size_t s =
(minBlocksInfo->WasLocalVar
? reinterpret_cast<size_t>(blocks[j].Start)
: blocks[j].Start[k]);
if (variable->m_ShapeID == ShapeID::GlobalArray)
{
size_t s = (minBlocksInfo->WasLocalValue
? reinterpret_cast<size_t>(
blocks[j].Start)
: blocks[j].Start[k]);
fprintf(outf, "%*zu:%*zu", ndigits_dims[k], s,
ndigits_dims[k], s + c - 1);
}
Expand Down Expand Up @@ -3422,20 +3433,28 @@ void print_decomp(core::Engine *fp, core::IO *io, core::Variable<T> *variable)
fprintf(outf, "\n");
if (dump)
{
if (minBlocksInfo->WasLocalVar)
Dims s, c;
if (variable->m_ShapeID == ShapeID::GlobalArray)
{
readVarBlock(
fp, io, variable, RelStep, j,
{reinterpret_cast<size_t>(blocks[j].Count)},
{reinterpret_cast<size_t>(blocks[j].Start)});
if (minBlocksInfo->WasLocalValue)
{
c = {reinterpret_cast<size_t>(blocks[j].Count)};
s = {reinterpret_cast<size_t>(blocks[j].Start)};
}
else
{
c = Dims(blocks[j].Count,
blocks[j].Count + ndim);
s = Dims(blocks[j].Start,
blocks[j].Start + ndim);
}
}
else
{
readVarBlock(
fp, io, variable, RelStep, j,
Dims(blocks[j].Count, blocks[j].Count + ndim),
Dims(blocks[j].Start, blocks[j].Start + ndim));
c = Dims(blocks[j].Count, blocks[j].Count + ndim);
s = Dims(0, ndim);
}
readVarBlock(fp, io, variable, RelStep, j, c, s);
}
}
}
Expand Down

0 comments on commit ac58b84

Please sign in to comment.