Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/install-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
GarrettDMorrison committed Jul 26, 2022
2 parents 6c46dcc + 81dbdd0 commit 7c9b4d2
Show file tree
Hide file tree
Showing 57 changed files with 620 additions and 287 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ few of the API changes, other than to cfp, should impact existing code.

- `zfp::array::get_header()` has been replaced with a `zfp::array::header`
constructor that accepts an array object.
- `ZFP_VERSION_RELEASE` is no longer defined (use `ZFP_VERSION_PATCH`).

### Fixed

Expand All @@ -76,6 +77,7 @@ few of the API changes, other than to cfp, should impact existing code.
- #126: `make install` does not install Fortran module.
- #127: Reversible mode reports incorrect compressed block size.
- #150: cmocka tests do not build on macOS.
- #154: Thread safety is broken in `private_view` and `private_const_view`.
- `ZFP_MAX_BITS` is off by one.
- `diffusionC`, `iteratorC` are not being built with `gmake`.

Expand Down
6 changes: 5 additions & 1 deletion Config
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ FC = gfortran
CSTD = -std=c99
CXXSTD = -std=c++98
# CXXSTD = -std=c++11
FSTD = -std=f2003 -ffree-form -Wno-c-binding-type
FSTD = -std=f2018 -ffree-form -Wno-c-binding-type

# common compiler options -----------------------------------------------------

OPTFLAGS = -O3
FLAGS = $(OPTFLAGS) -fPIC -pedantic -Wall -Wextra
LDFLAGS =
SOFLAGS =

# OpenMP compiler options -----------------------------------------------------

# do not comment out; use "make ZFP_WITH_OPENMP=0" to disable OpenMP
OMPFLAGS = -fopenmp

# Apple clang OpenMP options
# OMPFLAGS = -Xclang -fopenmp

# optional compiler macros ----------------------------------------------------

# use smaller bit stream word type for finer rate granularity;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Additional methods are documented below.
Whereas the :ref:`read-write fixed-rate arrays <array_classes>`
(:cpp:class:`zfp::array`) require that block storage is word aligned, the
read-only arrays (:cpp:class:`zfp::const_array`) are not subject to such
restrictions and thefore support finer rate granularity. For a
restrictions and therefore support finer rate granularity. For a
*d*-dimensional :cpp:class:`const_array`, the rate granularity is
4\ :sup:`-d` bits/value, e.g., a quarter bit/value for 1D arrays.

Expand Down
12 changes: 12 additions & 0 deletions docs/source/codec.inc
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ which provides for 2:1 fixed-rate "compression" using IEEE 754 floating point.

----

.. cpp:function:: bool codec::set_thread_safety(bool safety)

Enable or disable thread safety. This function is called whenever |zfp|
is built with OpenMP support and when the number of mutable or immutable
:ref:`private views <private_immutable_view>` of an array changes. When
two or more private views of an array are accessed by separate threads,
multiple blocks may be compressed or decompressed simultaneously. The
codec then has to take care that there are no race conditions on the data
structures (e.g., :c:type:`bitstream`) used for (de)compression.

----

.. cpp:function:: size_t codec::size_bytes(uint mask = ZFP_DATA_ALL) const

Return storage size of components of codec data structure indicated by
Expand Down
7 changes: 5 additions & 2 deletions docs/source/execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ responsible for compressing a *chunk* of several contiguous blocks.

This section describes the |zfp| parallel compression algorithm and explains
how to configure |libzfp| and enable parallel compression at run time via
its :ref:`high-level C API <hl-api>`. Parallel compression is not supported
via the :ref:`low-level API <ll-api>`.
its :ref:`high-level C API <hl-api>`.

.. note::
Parallel compression is not supported via the :ref:`low-level API <ll-api>`,
which ignores all execution policy settings and always executes in serial.


Execution Policies
Expand Down
8 changes: 8 additions & 0 deletions docs/source/high-level-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,14 @@ Array Metadata
----
.. c:function:: size_t zfp_field_blocks(const zfp_field* field)
Return total number of *d*-dimensional blocks (whether partial or whole)
spanning the array. Each whole block consists of |4powd| scalars.
Available since |zfp| |fieldrelease|.
----
.. c:function:: zfp_bool zfp_field_stride(const zfp_field* field, ptrdiff_t* stride)
Return :code:`zfp_false` if the array is stored contiguously as
Expand Down
4 changes: 1 addition & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ Regardless of the settings below, |libzfp| will always be built.
.. c:macro:: BUILD_SHARED_LIBS
Build shared objects (:file:`.so`, :file:`.dylib`, or :file:`.dll` files).
On macOS, the :code:`SOFLAGS` line in the :file:`Config` file may have
to be uncommented when building with GNU make.
CMake default: on.
GNU make default: off.

Expand Down Expand Up @@ -436,4 +434,4 @@ The necessary dependencies can be installed using ``pip`` and the |zfp|
Fortran
^^^^^^^

The optional Fortran bindings require a Fortran 2003 compiler.
The optional Fortran bindings require a Fortran 2018 compiler.
16 changes: 11 additions & 5 deletions docs/source/zforp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Fortran Bindings

|zfp| |zforprelease| adds |zforp|: a Fortran API providing wrappers around
the :ref:`high-level C API <hl-api>`. Wrappers for
:ref:`compressed arrays <arrays>` will arrive in a future release.
:ref:`compressed-array classes <arrays>` will arrive in a future release.
The |zforp| implementation is based on the standard :code:`iso_c_binding`
module available since Fortran 2003.
module available since Fortran 2003. The use of :code:`ptrdiff_t` in
the |zfp| |fieldrelease| C API, however, requires the corresponding
:code:`c_ptrdiff_t` available only since Fortran 2018.

Every high-level C API function can be called from a Fortran wrapper function.
C structs are wrapped as Fortran derived types, each containing a single C
Expand All @@ -28,9 +30,13 @@ for how the Fortran API is used to compress and decompress data.
.. _zforp_changes:
.. note::

|zfp| |fieldrelease| simplifies the |zforp| module name from zforp_module to zforp.
This will likely require changing associated use statements within existing code when
updating from prior versions of zFORp.
|zfp| |fieldrelease| simplifies the |zforp| module name from
:code:`zforp_module` to :code:`zforp`. This will likely require
changing associated use statements within existing code when updating
from prior versions of zFORp.

Furthermore, as outlined above, the |zfp| |fieldrelease| API requires
a Fortran 2018 compiler.


Types
Expand Down
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ TARGETS = $(BINDIR)/array\
$(BINDIR)/speed
INCS = -I../include
LIBS = -L../lib -lzfp
CLIBS = $(LIBS) -lm
CXXLIBS = $(LIBS)
CLIBS = $(LIBS) $(LDFLAGS) -lm
CXXLIBS = $(LIBS) $(LDFLAGS)

# add cfp examples when BUILD_CFP is enabled
ifneq ($(BUILD_CFP),0)
Expand Down
2 changes: 1 addition & 1 deletion examples/inplace.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ process(double* buffer, uint blocks, double tolerance)
ptr = buffer;
for (i = 0; i < blocks; i++) {
offset[i] = stream_wtell(stream);
bits = zfp_encode_block_double_2(zfp, ptr);
bits = (uint)zfp_encode_block_double_2(zfp, ptr);
if (!bits) {
fprintf(stderr, "compression failed\n");
return 0;
Expand Down
18 changes: 10 additions & 8 deletions fortran/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
include ../Config

.SUFFIXES: .f90

LIBDIR = ../lib
MODDIR = ../modules
TARGETS = $(LIBDIR)/libzFORp.a $(LIBDIR)/libzFORp.so $(MODDIR)/zfp.mod
OBJECTS = ../src/zfp.o
MODULES = zfp.mod
TARGETS = $(LIBDIR)/libzFORp.a $(LIBDIR)/libzFORp.so $(MODDIR)/zforp.mod
OBJECTS = zfp.o
MODULES = zforp.mod

static: $(LIBDIR)/libzFORp.a $(MODDIR)/zfp.mod
static: $(LIBDIR)/libzFORp.a $(MODDIR)/zforp.mod

shared: $(LIBDIR)/libzFORp.so $(MODDIR)/zfp.mod
shared: $(LIBDIR)/libzFORp.so $(MODDIR)/zforp.mod

clean:
rm -f $(TARGETS) $(OBJECTS)
Expand All @@ -22,9 +24,9 @@ $(LIBDIR)/libzFORp.so: $(OBJECTS)
mkdir -p $(LIBDIR)
$(FC) $(FFLAGS) -shared $^ -o $@

$(MODDIR)/zfp.mod: $(OBJECTS)
$(MODDIR)/zforp.mod: $(OBJECTS)
mkdir -p $(MODDIR)
mv zfp.mod $(MODDIR)
mv zforp.mod $(MODDIR)

.f.o:
.f90.o:
$(FC) $(FFLAGS) -c $<
6 changes: 6 additions & 0 deletions include/zfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ zfp_field_size_bytes(
const zfp_field* field /* field metadata */
);

/* field size in number of blocks */
size_t /* total number of blocks */
zfp_field_blocks(
const zfp_field* field /* field metadata */
);

/* field strides per dimension */
zfp_bool /* true if array is not contiguous */
zfp_field_stride(
Expand Down
70 changes: 32 additions & 38 deletions include/zfp/codec/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,7 @@ class generic_base {
// conservative buffer size for current codec settings
size_t buffer_size(const zfp_field* field) const
{
// empty field case
if (!field->nx && !field->ny && !field->nz && !field->nw)
return 0;
// count number of blocks spanned by field
size_t bx = (std::max(field->nx, size_t(1)) + 3) / 4;
size_t by = (std::max(field->ny, size_t(1)) + 3) / 4;
size_t bz = (std::max(field->nz, size_t(1)) + 3) / 4;
size_t bw = (std::max(field->nw, size_t(1)) + 3) / 4;
size_t blocks = bx * by * bz * bw;
return blocks * block_size * sizeof(InternalType);
return zfp_field_blocks(field) * block_size * sizeof(InternalType);
}

// open
Expand Down Expand Up @@ -129,6 +120,9 @@ class generic_base {
return false;
}

// set thread safety mode (not required by this codec)
void set_thread_safety(bool) {}

// byte size of codec data structure components indicated by mask
size_t size_bytes(uint mask = ZFP_DATA_ALL) const
{
Expand Down Expand Up @@ -193,6 +187,13 @@ class generic1 : public generic_base<1, ExternalType, InternalType> {
: encode_block(offset, block);
}

// decode contiguous 1D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1)
: decode_block(offset, block);
}

// encode 1D block from strided storage
size_t encode_block_strided(bitstream_offset offset, uint shape, const ExternalType* p, ptrdiff_t sx) const
{
Expand All @@ -206,13 +207,6 @@ class generic1 : public generic_base<1, ExternalType, InternalType> {
return block_size_bits;
}

// decode contiguous 1D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1)
: decode_block(offset, block);
}

// decode 1D block to strided storage
size_t decode_block_strided(bitstream_offset offset, uint shape, ExternalType* p, ptrdiff_t sx) const
{
Expand Down Expand Up @@ -244,6 +238,13 @@ class generic2 : public generic_base<2, ExternalType, InternalType> {
: encode_block(offset, block);
}

// decode contiguous 2D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4)
: decode_block(offset, block);
}

// encode 2D block from strided storage
size_t encode_block_strided(bitstream_offset offset, uint shape, const ExternalType* p, ptrdiff_t sx, ptrdiff_t sy) const
{
Expand All @@ -260,13 +261,6 @@ class generic2 : public generic_base<2, ExternalType, InternalType> {
return block_size_bits;
}

// decode contiguous 2D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4)
: decode_block(offset, block);
}

// decode 2D block to strided storage
size_t decode_block_strided(bitstream_offset offset, uint shape, ExternalType* p, ptrdiff_t sx, ptrdiff_t sy) const
{
Expand Down Expand Up @@ -301,6 +295,13 @@ class generic3 : public generic_base<3, ExternalType, InternalType> {
: encode_block(offset, block);
}

// decode contiguous 3D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4, 16)
: decode_block(offset, block);
}

// encode 3D block from strided storage
size_t encode_block_strided(bitstream_offset offset, uint shape, const ExternalType* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz) const
{
Expand All @@ -320,13 +321,6 @@ class generic3 : public generic_base<3, ExternalType, InternalType> {
return block_size_bits;
}

// decode contiguous 3D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4, 16)
: decode_block(offset, block);
}

// decode 3D block to strided storage
size_t decode_block_strided(bitstream_offset offset, uint shape, ExternalType* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz) const
{
Expand Down Expand Up @@ -364,6 +358,13 @@ class generic4 : public generic_base<4, ExternalType, InternalType> {
: encode_block(offset, block);
}

// decode contiguous 4D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4, 16, 64)
: decode_block(offset, block);
}

// encode 4D block from strided storage
size_t encode_block_strided(bitstream_offset offset, uint shape, const ExternalType* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw) const
{
Expand All @@ -386,13 +387,6 @@ class generic4 : public generic_base<4, ExternalType, InternalType> {
return block_size_bits;
}

// decode contiguous 4D block
size_t decode_block(bitstream_offset offset, uint shape, ExternalType* block) const
{
return shape ? decode_block_strided(offset, shape, block, 1, 4, 16, 64)
: decode_block(offset, block);
}

// decode 4D block to strided storage
size_t decode_block_strided(bitstream_offset offset, uint shape, ExternalType* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw) const
{
Expand Down
Loading

0 comments on commit 7c9b4d2

Please sign in to comment.