Skip to content

Commit

Permalink
Implement memory selection in BP4 reader
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Apr 25, 2023
1 parent aeed4f6 commit b5e92fa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
54 changes: 49 additions & 5 deletions source/adios2/toolkit/format/bp/bp4/BP4Deserializer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,55 @@ void BP4Deserializer::PostDataRead(
? Dims(blockInfo.Count.size(), 0)
: blockInfo.Start;

helper::ClipContiguousMemory(
blockInfo.Data, blockInfoStart, blockInfo.Count,
m_ThreadBuffers[threadID][0].data(), subStreamBoxInfo.BlockBox,
subStreamBoxInfo.IntersectionBox, m_IsRowMajor, m_ReverseDimensions,
endianReverse, blockInfo.MemSpace);
if (!blockInfo.MemoryStart.empty())
{
if (endianReverse)
{
helper::Throw<std::invalid_argument>(
"Toolkit", "format::bp::BP3Deserializer", "PostDataRead",
"endianReverse "
"not supported with MemorySelection");
}

if (m_ReverseDimensions)
{
helper::Throw<std::invalid_argument>(
"Toolkit", "format::bp::BP3Deserializer", "PostDataRead",
"ReverseDimensions not supported with "
"MemorySelection");
}

helper::DimsArray intersectStart(
subStreamBoxInfo.IntersectionBox.first);
helper::DimsArray intersectCount(
subStreamBoxInfo.IntersectionBox.second);
helper::DimsArray blockStart(subStreamBoxInfo.BlockBox.first);
helper::DimsArray blockCount(subStreamBoxInfo.BlockBox.second);
helper::DimsArray memoryStart(blockInfoStart);
for (size_t d = 0; d < intersectStart.size(); d++)
{
// change {intersect,block}Count from [start, end] to {start, count}
intersectCount[d] -= (intersectStart[d] - 1);
blockCount[d] -= (blockStart[d] - 1);
// shift everything by MemoryStart
intersectStart[d] += blockInfo.MemoryStart[d];
blockStart[d] += blockInfo.MemoryStart[d];
}
helper::NdCopy(m_ThreadBuffers[threadID][0].data(), intersectStart,
intersectCount, true, true,
reinterpret_cast<char *>(blockInfo.Data), intersectStart,
intersectCount, true, true, sizeof(T), intersectStart,
blockCount, memoryStart,
helper::DimsArray(blockInfo.MemoryCount), false);
}
else
{
helper::ClipContiguousMemory(
blockInfo.Data, blockInfoStart, blockInfo.Count,
m_ThreadBuffers[threadID][0].data(), subStreamBoxInfo.BlockBox,
subStreamBoxInfo.IntersectionBox, m_IsRowMajor, m_ReverseDimensions,
endianReverse, blockInfo.MemSpace);
}
}

void BP4Deserializer::BackCompatDecompress(
Expand Down
7 changes: 2 additions & 5 deletions testing/adios2/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ gtest_add_tests_helper(DefineVariable MPI_ALLOW ADIOS Interface. "")
gtest_add_tests_helper(DefineAttribute MPI_ALLOW ADIOS Interface. "")
gtest_add_tests_helper(Selection MPI_NONE ADIOS Interface. .BP3
WORKING_DIRECTORY ${BP3_DIR} EXTRA_ARGS "BP3")
# Some selection only supported by BP3 and BP5. BPfile might default to BP4, so don't run
if(ADIOS2_HAVE_BP5)
gtest_add_tests_helper(Selection MPI_NONE ADIOS Interface. .BPfile
WORKING_DIRECTORY ${BPfile_DIR} EXTRA_ARGS "BPfile")
endif()
gtest_add_tests_helper(Selection MPI_NONE ADIOS Interface. .BPfile
WORKING_DIRECTORY ${BPfile_DIR} EXTRA_ARGS "BPfile")
gtest_add_tests_helper(NoMpi MPI_NONE ADIOS Interface. "")

0 comments on commit b5e92fa

Please sign in to comment.