Skip to content

Commit

Permalink
Mid tread (#212)
Browse files Browse the repository at this point in the history
* minor

* WIP

* WIP

* finish integer SPECK3D encoder. Now implement a decoder

* encoder and decoder complete

* WIP

* add header and more unit tests for SPECK3D_INT

* add a truly random test

* minor

* WIP

* WIP

* add a function, change header definition

* WIP

* rename

* SPERR3D_INT_Driver is working

* add a mid-tread executable

* experimental mid-tread compiles

* mid-riser SPERR doesn't do outlier correction

* minor

* reorg, WIP

* SPECK3D_INT_Driver passes unit tests

* WIP: add subclass of SPECK3D_INT_Driver

* SPERR3D compiles

* class SPERR3D appears to be working

* WIP

* implement query of number of coded values

* a fix on accounting the number of coded values

* introduce base class SPECK_INT

* minor

* a small change to Set3D data structure

* SPECK1D_INT compiles

* SPECK1D_INT passes unit test

* WIP: add base class SPECK_INT_Driver

* WIP: add SPERR_Driver

* WIP: keep working on SPERR3D unit tests

* WIP

* alias name change

* SPERR3D works

* sync

* incr

* incr

* remove a bunch of files from this branch. Will need to focus on the integer implementation

* ignore install directory

* add ZFP bitstream files

* added ZFP_bitstream

* minor

* add random read to ZFP_bitstream

* add read_n_bits function

* improvement on ZFP_stream

* add compact stream generate and parse functions

* ZFP_bitstream allocates its handle on stack now

* more improvements

* use zfp::stream_open() again

* improve ZFP_bitstream

* resolve ZFP bitstream naming and linking issues

* minor improvement

* minor improvements

* minor

* minor

* minor

* Custom bitmask for m_LSP_mask (#197)

* minor

* use bitmask for m_LSP_mask

* add Bitmask

* use a custom bitmask to store m_LSP_mask data structur, and actually speed up the program quite significantly!

* clang-format

* clang-format

* clang-format

* clang-format

---------

Co-authored-by: Samuel Li <Sam@Navada>

* minor

* Use Sam's implementation of Bitstream

* improve documentation

* Improve API, so get_bitstream() is const now

* implement write_bitstream() function in Bitstream

* update Bitstream API

* minor

* minor

* Fast bit buffer (#198)

* WIP

* class SPECK_INT compiles

* WIP: SPECK3D_INT compiles, need to work on SPECK1D_INT_ENC

* using Bitstream in SPECK3D and SPECK1D

* minor

* clang-format

* clang-format

---------

Co-authored-by: Samuel Li <shaomeng@cisl-vapor>
Co-authored-by: Samuel Li <Sam@Navada>

* minor API change

* clean up

* bring encode() and decode() functions to the base SPECK_INT class

* minor

* SPECK_INT compiles

* test branch

* Revert "test branch"

This reverts commit 18e39f6.

* Uint template (#202)

* SPECK libraries compile

* Still working on SPERR_Driver. Will need to give it a header when assembling bitstreams. Need to record the length of uint in use.

* improve SPECK_INT

* improve documentation

* add function to report integer type

* minor

* WIP: SPERR_Driver needs to be able to select integer length

* SPERR_Driver compiles

* SPERR3D compiles, but doesn't link...

* template classes compile

* WIP

* minor: comments

* Bitmask can export and import a bitstream

* add unit test for Bitmask

* re-enable unit tests for integer speck

* improv. on Bitmask

---------

Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <sam@cisl-m121a>

* WIP

* rename so that we have SPECK_FLT classes!

* SPECK3D_FLT runs well

* minor udpate to sperr_helper; better in sync with the main branch

* Use the Conditioner from the main branch

* remove the keyword virtual in a few places

* API change: append to a bitsteram always

* add function to SPECK_FLT to retrieve integer length in use

* add more unit test

* a little cleaner code

* minor optimization

* WIP: Outlier_Coder

* Outlier_Coder compiles

* minor interface change

* Outlier_Coder compiles

* finish unit test for outlier coder

* add a note on bitstream definitions

* add Outlier_Coder bitstream definition

* WIP: SPECK_FLT also corrects outlier

* add functions so Outlier Coder can report its stream length

* SPECK_FLT compiles

* WIP, want to restructure SPECK_FLT

* minor

* SPECK_INT can correctly handle all zero inputs

* outlier correction working!

* clang-tidy

* clean up

* SPECK3D_FLT add m_estimate_mse() method

* update SPECK_FLT bitstream definition

* fix an integer overflow bug in SPECK_INT.cpp

* SPECK_FLT class is more polished

* Outlier Coder uses a biased inverse quantization scheme

* minor

* WIP: working on SPERR3D_OMP_C

* SPERR3D_OMP_C compiles

* minor

* SPERR3D_OMP_D compiles

* WIP: debug a variance issue...

* Fix some bugs, but still crashes

* fix a nasty bug of not clearing LIP in SPECK1D_INT

* use the same order in variants in SPECK_FLT

* SPERR3D_OMP passing unit tests

* clean up return error values

* remove ZSTD usage

* API change of SPERR3D_OMP_C

* minor

* use std::copy()

* WIP: sperr3d.cpp

* finish settings

* sperr3d working!

* use optional in return values

* minor

* lower memory high-water mark when calculating stats

* minor API change

* minor

* LIS mask (#203)

* improve Bitmask API

* update Bitmask unit test

* WIP: m_LIP_mask, there's seg fault still

* fixes

* fix bug, pass all unit tests

* minor improvement

* make compiler happy

* remove unused variable

---------

Co-authored-by: Samuel Li <sam@cisl-m121a>
Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <shaomeng@cisl-vapor>

* minor

* minor

* fix integer overflow

* minor

* WIP: SPECK2D_INT

* minor improv on SPECK3D_INT

* WIP: SPECK2D_INT

* minor improvement on SPECK3D_INT

* WIP on SPECK2D_INT

* minor improv

* SPECK3D_INT finishes

* minor

* minor

* SPECK2D_INT_ENC compiles

* remove variable m_bit_idx

* improve on comments

* minor change

* SPECK2D_INT_DEC compiles

* SPECK2D_INT pass unit tests

* clang-format

* SPECK2D_INT is in

* remove a few virtual functions

* SPECK2D_FLT compiles

* add SPECK2D_FLT unit tests

* sperr2d compiles; need to do some tests!

* sperr2d works!

* utilities can perform decompression tasks too

* CLI11 precompiled is default ON now

* remove the option to use old GoogleTest

* minor

* change header definition; using 1 bit to indicate portion of a bitstream

* add read_sections() function to sperr_helper

* Stream Tools (#204)

* add function get_header_len()

* introduce new class: SPERR3D_Stream_Tools

* minor, robust improv

* SPERR3D_OMP_D now makes use of SPERR3D_Stream_Tools

* SPERR3D_Stream_Tools compiles

* stream_tools pass unit tests

---------

Co-authored-by: Samuel Li <Sam@Navada>

* More re-work on the code to prepare for the implementation of progressive access. (#205)

* add function get_header_len()

* introduce new class: SPERR3D_Stream_Tools

* minor, robust improv

* SPERR3D_OMP_D now makes use of SPERR3D_Stream_Tools

* SPERR3D_Stream_Tools compiles

* stream_tools pass unit tests

* WIP

* add more Bitstream unit test

* minor

* WIP

* Conditioner doesn't support custom filter anymore

* Conditioner stream has constant size now!

* minor

---------

Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <shaomeng@cisl-vapor>

* minor

* Bitmask is able to count_true()

* Add reset() function to Bitstream

* minor

* Progressive (#208)

* add function get_header_len()

* introduce new class: SPERR3D_Stream_Tools

* minor, robust improv

* SPERR3D_OMP_D now makes use of SPERR3D_Stream_Tools

* SPERR3D_Stream_Tools compiles

* stream_tools pass unit tests

* WIP

* add more Bitstream unit test

* minor

* WIP

* Conditioner doesn't support custom filter anymore

* Conditioner stream has constant size now!

* minor

* update SPERR.pc

* WIP

* WIP

* minor

* minor

* I think SPECK_INT supports partial decoding now

* I think SPECK_FLT also supports partial decoding now

* Handle the situation where only part of the outlier correction bitstream is available.

* file re-organization

* WIP sperr3d_trunc utility

* SPERR3D_Stream_Tools doesn't look correct... Need to work on this first.

* fix up SPERR3D_Stream_Tools

* utility sperr3d_trunc seems working

* minor

* The progressive access API takes a percentage of bitstream to read.

* minor

* minor

* clang-format

* clang-format

---------

Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <shaomeng@cisl-vapor>
Co-authored-by: Samuel Li <sam@cisl-m121a>

* sperr3d_trunc release more memory

* add code testing double values having less precision than ints

* re-work on some data members

* One approach to achieve fixed-rate compression (#209)

* SPECK_FLT now calculates m_q in fixed bitrate mode

* WIP

* SPECK_INT and SPECK_FLT both support a bit budget now

* target BPP seems to be working!

* add sperr2d Target BPP unit test

* sperr3d supports fixed-bitrate too

* adjust output format

* minor

* minor

* minor

* clang-format

---------

Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <sam@cisl-m121a>

* add clearer comment

* Improved progressive decoding (#210)

* minor

* improve logic of progressive decoding

* Implement the new decoding strategy!

* minor

* implement logic to use uint32_t first in fixed-rate mode, and if not enough bits produced, use uint64_t

* make sure we're comparing num of bits

* refinement_pass_decode terminates when bitstream is exhausted

* bring back fixed rate unit tests

* minor

---------

Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <sam@cisl-m121a>

* tweak quantization formula when decoding

* very minor

* use raw loops instead of std::find_if() in set significance tests

* Revert "use raw loops instead of std::find_if() in set significance tests"

This reverts commit 9b5c5ef.

* Morton (#211)

* minor change to the logic of choosing between dyadic and wavelet_packets 3D wavelet transforms

* working version!

* remove unused function: decide_significance

* minor improvement

* Set3D uses 16-bit integers to record integers

* use a more compact representation of morton offset, and also remove the use of SetType

* bring the Set3D object size down to 18 bytes!

* minor

* minor

* minor

* minor

* move 3 functions from 3D encoder/decoder to SPECK3D_INT; reduce code redundancy

* minor

* remove the use of SetType in SPECK2D_INT

* Remove the use of SetType from SPECK1D, thus from the codebase entirely

* reduce the size of Set1D down to 16 bytes

* minor

* minor

* remove [[likely]]

* minor reformatting

* m_process_P() checks pixel significance from the morton buffer too

* clang-format

* minor

---------

Co-authored-by: Samuel Li <shaomeng@cisl-vapor>
Co-authored-by: Samuel Li <sam@cisl-m121a>

* minor

* remove custom filter

* minor

* remove unused test data files

* various changes during review

* clang-tidy

* remove unused variables

* remove the use of std::vector<bool>

* code style improvement on quantization and inverse quantization

* better use of std::visit() in Outlier_Coder

* minor

* minor

---------

Co-authored-by: Samuel Li <shaomeng@cisl-vapor>
Co-authored-by: Samuel Li <Sam@Navada>
Co-authored-by: Samuel Li <sam@cisl-m121a>
  • Loading branch information
4 people authored Sep 13, 2023
1 parent 3fba60a commit ac390cb
Show file tree
Hide file tree
Showing 115 changed files with 7,702 additions and 7,406 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ QccPack-0.61-1/lib
QccPack-0.61-1/include
QccPack-0.61-1/install

# build directory
# build and install directory
build*/
install*/
.vscode/

# big test data
test_data/wmag256.float
Expand Down
100 changes: 22 additions & 78 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cmake_minimum_required(VERSION 3.14)

project(SPERR VERSION 0.6.2 DESCRIPTION "Lossy Scientific Compression with SPERR")
project(SPERR VERSION 0.7.0 DESCRIPTION "Lossy Scientific Compression with SPERR")

#
# specify the C++ standard
Expand Down Expand Up @@ -34,8 +34,6 @@ option( BUILD_SHARED_LIBS "Build shared SPERR library" ON )
option( BUILD_UNIT_TESTS "Build unit tests using GoogleTest" ON )
option( BUILD_CLI_UTILITIES "Build a set of command line utilities" ON )
option( USE_OMP "Use OpenMP parallelization on 3D volumes" ON )
option( USE_ZSTD "Incorporate ZSTD to achieve further reduction (~5%)" ON )
cmake_dependent_option(USE_BUNDLED_ZSTD "Prefer to use the bundled ZSTD to an external one" ON "USE_ZSTD" OFF)
option( SPERR_PREFER_RPATH "Set RPATH; this can fight with package managers so turn off when building for them" ON )
mark_as_advanced(FORCE SPERR_PREFER_RPATH)

Expand All @@ -44,7 +42,7 @@ if(USE_OMP)
if (OpenMP_CXX_FOUND)
message(STATUS "OpenMP found! (${OpenMP_CXX_LIB_NAMES}-${OpenMP_CXX_VERSION}: ${OpenMP_CXX_FLAGS})")
else()
message(FATAL_ERROR "OpenMP NOT found! Try turning it off!")
message(FATAL_ERROR "OpenMP NOT found! Try turning it off to continue configuring SPERR!")
endif()
endif()

Expand Down Expand Up @@ -75,51 +73,6 @@ message(STATUS "Repository Git Branch: ${GIT_BRANCH}, SHA1: ${GIT_SHA1}")
configure_file("${CMAKE_SOURCE_DIR}/SperrConfig.h.in" SperrConfig.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if( USE_ZSTD )
if(USE_BUNDLED_ZSTD)
message(STATUS "ZSTD add-on enabled; using the bundled version!")
project(zstd-download NONE)
include(ExternalProject)
ExternalProject_Add( zstd-download
GIT_REPOSITORY https://github.com/facebook/zstd.git
GIT_TAG release
GIT_SHALLOW "True"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/zstd"
UPDATE_DISCONNECTED "True" # Skip update from git step
SOURCE_SUBDIR "build/cmake/" # Specifies where the CMakeLists.txt file is
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release"
CMAKE_ARGS "-DZSTD_MULTITHREAD_SUPPORT=False"
CMAKE_ARGS "-DZSTD_BUILD_PROGRAMS=False" # Don't build zstd command line utilities
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/zstd/install"
CMAKE_ARGS "-DCMAKE_INSTALL_LIBDIR=lib"
CMAKE_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" # use the same CXX compiler
CMAKE_ARGS "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" # use the same C compiler
CMAKE_ARGS "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" # use the same CXX flags
CMAKE_ARGS "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}" # use the same C flags
CMAKE_ARGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # use the same linker flags
CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}" # use the same deployment target
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/zstd/install"
# !! <INSTALL_DIR> doesn't contain any value now !!
# But it can be used later by others to retrieve where the installation is.
LOG_CONFIGURE "True" # Save output in a file, instead of the terminal.
LOG_BUILD "True" # Save output in a file, instead of the terminal.
LOG_INSTALL "True" # Save output in a file, instead of the terminal.
)

ExternalProject_Get_Property( zstd-download INSTALL_DIR )
include_directories("${INSTALL_DIR}/include")
link_directories( "${INSTALL_DIR}/lib" )
set(SPERR_ZSTD_DEPENDENCY "")
else()
find_package(PkgConfig REQUIRED)
pkg_search_module(ZSTD REQUIRED IMPORTED_TARGET GLOBAL libzstd )
set(SPERR_ZSTD_DEPENDENCY "libzstd")
message(STATUS "ZSTD add-on enabled; using the system version: ${ZSTD_LINK_LIBRARIES}")
endif()
else()
message(STATUS "ZSTD add-on disabled!")
endif()


if(SPERR_PREFER_RPATH)
#
Expand All @@ -143,17 +96,23 @@ endif()
#
add_subdirectory( src )


#
# Build command line utilities
#
if( BUILD_CLI_UTILITIES )
# Download CLI11
# Download and build CLI11
#
if( NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CLI11.hpp )
file(DOWNLOAD https://github.com/CLIUtils/CLI11/releases/latest/download/CLI11.hpp
${CMAKE_CURRENT_BINARY_DIR}/CLI11.hpp )
endif()
include(FetchContent)

# Control internal options of CLI11
#
set( CLI11_PRECOMPILED ON CACHE INTERNAL "Save precompiled CLI11")
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 291c58789c031208f08f4f261a858b5b7083e8e2 # v2.3.2
)
FetchContent_MakeAvailable(cli11)

add_subdirectory( utilities ${CMAKE_BINARY_DIR}/bin )
endif()
Expand All @@ -163,8 +122,6 @@ endif()
# Fetch Google Test: https://google.github.io/googletest/quickstart-cmake.html
#
if( BUILD_UNIT_TESTS )
option( USE_OLDER_GTEST "Force using an older version of GoogleTest (1.10.0)" OFF )

# Control internal options of GoogleTest
#
set( INSTALL_GTEST OFF CACHE INTERNAL "Not install GoogleTest")
Expand All @@ -173,21 +130,15 @@ if( BUILD_UNIT_TESTS )
# Let's use the new mechanism to incorporate GoogleTest
#
include(FetchContent)
if( USE_OLDER_GTEST )
message (STATUS "Fetching GoogleTest Framework Version 1.10.0")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
message (STATUS "Fetching the latest GoogleTest Framework, CMake version >= 3.24")
FetchContent_Declare( googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.10.0.zip )
URL https://github.com/google/googletest/archive/refs/heads/main.zip
DOWNLOAD_EXTRACT_TIMESTAMP NEW )
else()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
message (STATUS "Fetching the latest GoogleTest Framework, CMake version >= 3.24")
FetchContent_Declare( googletest
URL https://github.com/google/googletest/archive/refs/heads/main.zip
DOWNLOAD_EXTRACT_TIMESTAMP NEW )
else()
message (STATUS "Fetching the latest GoogleTest Framework, CMake version < 3.24")
FetchContent_Declare( googletest
URL https://github.com/google/googletest/archive/refs/heads/main.zip )
endif()
message (STATUS "Fetching the latest GoogleTest Framework, CMake version < 3.24")
FetchContent_Declare( googletest
URL https://github.com/google/googletest/archive/refs/heads/main.zip )
endif()

# Prevent overriding the parent project's compiler/linker settings on Windows
Expand Down Expand Up @@ -223,8 +174,7 @@ endif()
# Install utilities
#
if( BUILD_CLI_UTILITIES )
install( TARGETS show_version compressor_3d decompressor_3d
compressor_2d decompressor_2d header_parser
install( TARGETS show_version sperr3d sperr2d sperr3d_trunc
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
endif()

Expand All @@ -234,9 +184,3 @@ configure_file("${CMAKE_SOURCE_DIR}/SPERR.pc.in" SPERR.pc @ONLY)
install( FILES "${CMAKE_BINARY_DIR}/SPERR.pc" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
install( FILES "${CMAKE_BINARY_DIR}/SperrConfig.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )

# Copy over ZSTD libraries
#
if( USE_ZSTD AND USE_BUNDLED_ZSTD )
ExternalProject_Get_Property( zstd-download INSTALL_DIR )
install( DIRECTORY "${INSTALL_DIR}/lib/" TYPE LIB )
endif()
2 changes: 1 addition & 1 deletion SPERR.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: SPERR
Description: @SPERR_DESCRIPTION@
URL: https://github.com/NCAR/SPERR
Version: @SPERR_VERSION@

Requires: @SPERR_ZSTD_DEPENDENCY@
Libs: -L${libdir} -lSPERR
Cflags: -I${includedir}
1 change: 0 additions & 1 deletion SperrConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
static const char* SPERR_GIT_SHA1 = "@GIT_SHA1@";
static const char* SPERR_GIT_BRANCH = "@GIT_BRANCH@";

#cmakedefine USE_ZSTD
#cmakedefine USE_OMP

#endif
138 changes: 0 additions & 138 deletions custom_filter/Matthias_Filter.cpp

This file was deleted.

36 changes: 0 additions & 36 deletions custom_filter/Matthias_Filter.h

This file was deleted.

Loading

0 comments on commit ac390cb

Please sign in to comment.