From 367d4aa5285c3f33267ec5d3ec3f3bee74ba5e65 Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Mon, 5 Feb 2024 20:31:55 -0700 Subject: [PATCH 1/5] better warning message when multi-resolution is not supported --- utilities/sperr2d.cpp | 1 + utilities/sperr3d.cpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/utilities/sperr2d.cpp b/utilities/sperr2d.cpp index aa557f91..cef36c49 100644 --- a/utilities/sperr2d.cpp +++ b/utilities/sperr2d.cpp @@ -130,6 +130,7 @@ int main(int argc, char* argv[]) // auto bitstream = std::string(); app.add_option("--bitstream", bitstream, "Output compressed bitstream.") + ->needs(cptr) ->group("Output settings"); auto decomp_f32 = std::string(); diff --git a/utilities/sperr3d.cpp b/utilities/sperr3d.cpp index bb4ffc1d..743db535 100644 --- a/utilities/sperr3d.cpp +++ b/utilities/sperr3d.cpp @@ -141,6 +141,7 @@ int main(int argc, char* argv[]) // auto bitstream = std::string(); app.add_option("--bitstream", bitstream, "Output compressed bitstream.") + ->needs(cptr) ->group("Output settings"); auto decomp_f32 = std::string(); @@ -232,6 +233,22 @@ int main(int argc, char* argv[]) std::cout << "SPERR needs an output destination when decoding!" << std::endl; return __LINE__; } + // Also check if the chunk dims can support multi-resolution decoding. + if (cflag && (!decomp_lowres_f64.empty() || !decomp_lowres_f32.empty())) { + auto name = decomp_lowres_f64; + if (name.empty()) + name = decomp_lowres_f32; + assert(!name.empty()); + auto filenames = create_filenames(name, dims, chunks); + if (filenames.empty()) { + std::printf(" Warning: the combo of volume dimension (%lu, %lu, %lu) and chunk dimension" + " (%lu, %lu, %lu)\n cannot support multi-resolution decoding. " + " Try to use chunk dimensions that\n are similar in length and" + " can divide the volume dimension.\n", + dims[0], dims[1], dims[2], chunks[0], chunks[1], chunks[2]); + return __LINE__ % 256; + } + } // // Really starting the real work! @@ -242,7 +259,7 @@ int main(int argc, char* argv[]) if ((ftype == 32 && (total_vals * 4 != input.size())) || (ftype == 64 && (total_vals * 8 != input.size()))) { std::cout << "Input file size wrong!" << std::endl; - return __LINE__; + return __LINE__ % 256; } auto encoder = std::make_unique(); encoder->set_dims_and_chunks(dims, chunks); From 24f67070872c273d2f118f49623d4bf2ac402358 Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Tue, 6 Feb 2024 10:41:59 -0700 Subject: [PATCH 2/5] add empty input detection --- utilities/sperr2d.cpp | 8 ++++++-- utilities/sperr3d.cpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/utilities/sperr2d.cpp b/utilities/sperr2d.cpp index cef36c49..0a8a1f51 100644 --- a/utilities/sperr2d.cpp +++ b/utilities/sperr2d.cpp @@ -189,6 +189,10 @@ int main(int argc, char* argv[]) // // A little extra sanity check. // + if (input_file.empty()) { + std::cout << "What's the input file?" << std::endl; + return __LINE__; + } if (!cflag && !dflag) { std::cout << "Is this compressing (-c) or decompressing (-d) ?" << std::endl; return __LINE__; @@ -229,7 +233,7 @@ int main(int argc, char* argv[]) if ((ftype == 32 && (total_vals * 4 != input.size())) || (ftype == 64 && (total_vals * 8 != input.size()))) { std::cout << "Input file size wrong!" << std::endl; - return __LINE__; + return __LINE__ % 256; } auto encoder = std::make_unique(); encoder->set_dims(dims); @@ -260,7 +264,7 @@ int main(int argc, char* argv[]) auto rtn = encoder->compress(); if (rtn != sperr::RTNType::Good) { std::cout << "Compression failed!" << std::endl; - return __LINE__; + return __LINE__ % 256; } // Assemble the output bitstream. diff --git a/utilities/sperr3d.cpp b/utilities/sperr3d.cpp index 743db535..0c845195 100644 --- a/utilities/sperr3d.cpp +++ b/utilities/sperr3d.cpp @@ -206,6 +206,10 @@ int main(int argc, char* argv[]) // // A little extra sanity check. // + if (input_file.empty()) { + std::cout << "What's the input file?" << std::endl; + return __LINE__; + } if (!cflag && !dflag) { std::cout << "Is this compressing (-c) or decompressing (-d) ?" << std::endl; return __LINE__; From c68b5993d23e8f01e0eb1d79c61afa4965e1abc3 Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Tue, 6 Feb 2024 10:58:05 -0700 Subject: [PATCH 3/5] add view_hierarchy() interface to SPERR3D_OMP_D --- include/SPERR3D_OMP_D.h | 1 + src/SPERR3D_OMP_D.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/SPERR3D_OMP_D.h b/include/SPERR3D_OMP_D.h index 81117676..6b7d56b1 100644 --- a/include/SPERR3D_OMP_D.h +++ b/include/SPERR3D_OMP_D.h @@ -24,6 +24,7 @@ class SPERR3D_OMP_D { auto decompress(const void* bitstream, bool multi_res = false) -> RTNType; auto view_decoded_data() const -> const sperr::vecd_type&; + auto view_hierarchy() const -> const std::vector&; auto release_decoded_data() -> sperr::vecd_type&&; auto release_hierarchy() -> std::vector&&; diff --git a/src/SPERR3D_OMP_D.cpp b/src/SPERR3D_OMP_D.cpp index 0546191c..a487bff0 100644 --- a/src/SPERR3D_OMP_D.cpp +++ b/src/SPERR3D_OMP_D.cpp @@ -144,6 +144,11 @@ auto sperr::SPERR3D_OMP_D::release_hierarchy() -> std::vector&& return std::move(m_hierarchy); } +auto sperr::SPERR3D_OMP_D::view_hierarchy() const -> const std::vector& +{ + return m_hierarchy; +} + auto sperr::SPERR3D_OMP_D::view_decoded_data() const -> const sperr::vecd_type& { return m_vol_buf; From dd691e43eff4b8790382cd6a2338ec9755b5880a Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Sat, 10 Feb 2024 22:29:08 -0700 Subject: [PATCH 4/5] update CLI11 v 2.4.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 816757ae..96a12665 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ if( BUILD_CLI_UTILITIES ) set( CLI11_SINGLE_FILE OFF CACHE INTERNAL "Don't use single file CLI11") FetchContent_Declare( cli11 GIT_REPOSITORY https://github.com/CLIUtils/CLI11 - GIT_TAG 88e9bb17418ee730817d5942894d99a4bdd78fb3 # v2.4.0 + GIT_TAG f4d0731cebb123ff0ace712c099dffbcd2c58e5a # v2.4.1 ) FetchContent_MakeAvailable(cli11) From ca77e23ffb184198a506faae3a11d634d2b5bed5 Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Sat, 10 Feb 2024 22:34:24 -0700 Subject: [PATCH 5/5] clang-format --- utilities/sperr3d.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utilities/sperr3d.cpp b/utilities/sperr3d.cpp index 0c845195..0e4b71a4 100644 --- a/utilities/sperr3d.cpp +++ b/utilities/sperr3d.cpp @@ -245,11 +245,12 @@ int main(int argc, char* argv[]) assert(!name.empty()); auto filenames = create_filenames(name, dims, chunks); if (filenames.empty()) { - std::printf(" Warning: the combo of volume dimension (%lu, %lu, %lu) and chunk dimension" - " (%lu, %lu, %lu)\n cannot support multi-resolution decoding. " - " Try to use chunk dimensions that\n are similar in length and" - " can divide the volume dimension.\n", - dims[0], dims[1], dims[2], chunks[0], chunks[1], chunks[2]); + std::printf( + " Warning: the combo of volume dimension (%lu, %lu, %lu) and chunk dimension" + " (%lu, %lu, %lu)\n cannot support multi-resolution decoding. " + " Try to use chunk dimensions that\n are similar in length and" + " can divide the volume dimension.\n", + dims[0], dims[1], dims[2], chunks[0], chunks[1], chunks[2]); return __LINE__ % 256; } }