From 11fcb28eaa078af16616929c317fefd9c25b0d7b Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 25 Apr 2023 08:12:25 -0400 Subject: [PATCH] Implement memory selection in BP4 reader --- .../toolkit/format/bp/bp4/BP4Deserializer.tcc | 54 +++++++++++++++++-- testing/adios2/interface/CMakeLists.txt | 7 +-- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/source/adios2/toolkit/format/bp/bp4/BP4Deserializer.tcc b/source/adios2/toolkit/format/bp/bp4/BP4Deserializer.tcc index c1494afbfb..111b468b0a 100644 --- a/source/adios2/toolkit/format/bp/bp4/BP4Deserializer.tcc +++ b/source/adios2/toolkit/format/bp/bp4/BP4Deserializer.tcc @@ -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( + "Toolkit", "format::bp::BP3Deserializer", "PostDataRead", + "endianReverse " + "not supported with MemorySelection"); + } + + if (m_ReverseDimensions) + { + helper::Throw( + "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(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( diff --git a/testing/adios2/interface/CMakeLists.txt b/testing/adios2/interface/CMakeLists.txt index 65ef387f01..050be805b9 100644 --- a/testing/adios2/interface/CMakeLists.txt +++ b/testing/adios2/interface/CMakeLists.txt @@ -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. "")