From 3a5efc94872400aab9f734cc10ffe5b5de203945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:57:16 +0000 Subject: [PATCH 1/5] Bump cryptography from 38.0.2 to 39.0.1 in /docs Bumps [cryptography](https://github.com/pyca/cryptography) from 38.0.2 to 39.0.1. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/38.0.2...39.0.1) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] (cherry picked from commit 1e2d0584e853b77b21d98f14a0c31a90931d858d) --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 0880ee66ed..a4c9f56942 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -7,7 +7,7 @@ certifi==2022.12.7 cffi==1.15.1 charset-normalizer==2.1.1 colorama==0.4.6 -cryptography==38.0.2 +cryptography==39.0.1 docutils==0.17 funcparserlib==1.0.1 idna==3.4 From 832702380730c2bac2da712276aaacbf1ddd6f47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:57:20 +0000 Subject: [PATCH 2/5] Bump numpy from 1.21.6 to 1.22.0 in /docs Bumps [numpy](https://github.com/numpy/numpy) from 1.21.6 to 1.22.0. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.21.6...v1.22.0) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production ... Signed-off-by: dependabot[bot] (cherry picked from commit e054144c1e89f8ec1fa1e086dba8c86732e0c4f6) --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index a4c9f56942..542cffd5aa 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -16,7 +16,7 @@ importlib-metadata==4.11.4 Jinja2==3.1.2 MarkupSafe==2.1.1 mpi4py==3.1.3 -numpy==1.21.6 +numpy==1.22.0 packaging==22.0 Pillow==9.4.0 pip==22.3.1 From 4f75c5ae3bac79767abc6c7bcc99a8051fb12bf5 Mon Sep 17 00:00:00 2001 From: anagainaru Date: Wed, 15 Mar 2023 18:32:07 -0400 Subject: [PATCH 3/5] Bug fix in BP5 when used with MemorySelection and GPU buffers --- source/adios2/engine/bp5/BP5Writer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index 0b0eaea8bd..bec7794e55 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -1803,7 +1803,7 @@ void BP5Writer::PutCommon(VariableBase &variable, const void *values, bool sync) variable.m_MemoryCount, sourceRowMajor, false, (char *)ptr, variable.m_MemoryStart, variable.m_Count, sourceRowMajor, false, ObjSize, helper::CoreDims(), helper::CoreDims(), helper::CoreDims(), - helper::CoreDims(), false /* safemode */, MemorySpace::Host); + helper::CoreDims(), false /* safemode */, variable.m_MemSpace); } else { From 8e213ee333726e7b472e49f955990407003c83f2 Mon Sep 17 00:00:00 2001 From: anagainaru Date: Wed, 15 Mar 2023 18:32:33 -0400 Subject: [PATCH 4/5] Testing for SetMemorySelection with CUDA buffers --- .../adios2/engine/bp/TestBPWriteReadCuda.cpp | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/testing/adios2/engine/bp/TestBPWriteReadCuda.cpp b/testing/adios2/engine/bp/TestBPWriteReadCuda.cpp index c0497f2340..83689bbc8e 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadCuda.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadCuda.cpp @@ -199,6 +199,107 @@ void CUDADetectMemSpace(const std::string mode) } } +void CUDAWriteReadMemorySelection() +{ + const std::string fname("BPWRCUSel1D.bp"); + const size_t Nx = 10; + const size_t NSteps = 2; + const size_t ghostCells = 1; + std::vector r32s(Nx + 2 * ghostCells); + std::iota(r32s.begin(), r32s.end(), .0f); + + adios2::ADIOS adios; + { + // cuda simulation buffer + float *gpuSimData = nullptr; + cudaMalloc(&gpuSimData, (Nx + 2 * ghostCells) * sizeof(float)); + cudaMemcpy(gpuSimData, r32s.data(), + (Nx + 2 * ghostCells) * sizeof(float), + cudaMemcpyHostToDevice); + + adios2::IO io = adios.DeclareIO("TestIO"); + io.SetEngine("BP5"); + if (!engineName.empty()) + { + io.SetEngine(engineName); + } + + const adios2::Dims shape{static_cast(Nx)}; + const adios2::Dims start{static_cast(0)}; + const adios2::Dims count{Nx}; + auto var_r32 = io.DefineVariable("r32", shape, start, count); + + const adios2::Dims memoryStart = {ghostCells}; + const adios2::Dims memoryCount = {Nx + 2 * ghostCells}; + var_r32.SetMemorySelection({memoryStart, memoryCount}); + + adios2::Engine bpWriter = io.Open(fname, adios2::Mode::Write); + + for (size_t step = 0; step < NSteps; ++step) + { + cuda_increment(Nx + 2 * ghostCells, 1, 0, gpuSimData, INCREMENT); + + bpWriter.BeginStep(); + var_r32.SetMemorySpace(adios2::MemorySpace::GPU); + bpWriter.Put(var_r32, gpuSimData); + bpWriter.EndStep(); + } + + bpWriter.Close(); + } + { + // remove ghost cells from the input vector when checking correctness + r32s.erase(r32s.begin(), r32s.begin() + ghostCells); + r32s.erase(r32s.end() - ghostCells, r32s.end()); + + adios2::IO io = adios.DeclareIO("ReadIO"); + io.SetEngine("BP5"); + if (!engineName.empty()) + { + io.SetEngine(engineName); + } + + adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + + unsigned int t = 0; + for (; bpReader.BeginStep() == adios2::StepStatus::OK; ++t) + { + auto var_r32 = io.InquireVariable("r32"); + EXPECT_TRUE(var_r32); + ASSERT_EQ(var_r32.ShapeID(), adios2::ShapeID::GlobalArray); + ASSERT_EQ(var_r32.Shape()[0], Nx); + + auto mmR32 = std::minmax_element(r32s.begin(), r32s.end()); + EXPECT_EQ(var_r32.Min() - (t + 1) * INCREMENT, *mmR32.first); + EXPECT_EQ(var_r32.Max() - (t + 1) * INCREMENT, *mmR32.second); + + std::vector r32o(Nx); + float *gpuSimData; + cudaMalloc(&gpuSimData, Nx * sizeof(float)); + var_r32.SetMemorySpace(adios2::MemorySpace::GPU); + bpReader.Get(var_r32, gpuSimData); + bpReader.EndStep(); + cudaMemcpy(r32o.data(), gpuSimData, Nx * sizeof(float), + cudaMemcpyDeviceToHost); + + // Remove INCREMENT from each element + std::transform(r32o.begin(), r32o.end(), r32o.begin(), + std::bind(std::minus(), std::placeholders::_1, + (t + 1) * INCREMENT)); + for (size_t i = 0; i < Nx; i++) + { + char msg[1 << 8] = {0}; + snprintf(msg, sizeof(msg), "t=%d i=%zu r32o=%f r32s=%f", t, i, + r32o[i], r32s[i]); + ASSERT_LT(std::abs(r32o[i] - r32s[i]), EPSILON) << msg; + } + } + EXPECT_EQ(t, NSteps); + + bpReader.Close(); + } +} + void CUDAWriteReadMPI1D(const std::string mode) { const std::string fname("BPWRCU1D_" + mode + ".bp"); @@ -343,6 +444,7 @@ class BPWRCUDA : public ::testing::TestWithParam TEST_P(BPWRCUDA, ADIOS2BPWRCUDA1D) { CUDAWriteReadMPI1D(GetParam()); } TEST_P(BPWRCUDA, ADIOS2BPCUDADetect) { CUDADetectMemSpace(GetParam()); } TEST_P(BPWRCUDA, ADIOS2BPCUDAWrong) { CUDAWrongMemSpace(); } +TEST_P(BPWRCUDA, ADIOS2BPCUDAMemSel) { CUDAWriteReadMemorySelection(); } INSTANTIATE_TEST_SUITE_P(CudaRW, BPWRCUDA, ::testing::Values("deferred", "sync")); From cc5dce6750d39c905828a851493c3d39fdccf97e Mon Sep 17 00:00:00 2001 From: anagainaru Date: Fri, 17 Mar 2023 11:12:19 -0400 Subject: [PATCH 5/5] Do not call putOperationInBuffer if all blocks have 0 elements Co-authored-by: lizdulac Co-authored-by: Norbert Podhorszki --- source/adios2/toolkit/format/bp/bp4/BP4Serializer.tcc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/adios2/toolkit/format/bp/bp4/BP4Serializer.tcc b/source/adios2/toolkit/format/bp/bp4/BP4Serializer.tcc index 4f13df82e5..07af6e8a5f 100644 --- a/source/adios2/toolkit/format/bp/bp4/BP4Serializer.tcc +++ b/source/adios2/toolkit/format/bp/bp4/BP4Serializer.tcc @@ -118,7 +118,13 @@ inline void BP4Serializer::PutVariablePayload( } else { - PutOperationPayloadInBuffer(variable, blockInfo); + const bool isZeroCount = + std::all_of(blockInfo.Count.begin(), blockInfo.Count.end(), + [](const size_t i) { return i == 0; }); + if (!isZeroCount) + { + PutOperationPayloadInBuffer(variable, blockInfo); + } } /* Now we can update the varLength including payload size including the