Skip to content

Commit

Permalink
Fix some make output issues (#126)
Browse files Browse the repository at this point in the history
* cleanup gnu make stuff
* handle zfparr test better
* handle HAS_CHUNK in CMake
* update Spack doc
* fix dir sensing logic in `config.cmake`
  • Loading branch information
markcmiller86 committed Aug 31, 2023
1 parent 51d2218 commit 7b33e4f
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 34 deletions.
39 changes: 28 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
include config.make
# Include config.make only if we're not looking for help
ifeq ($(findstring help, $(strip $(MAKECMDGOALS))),)
ifeq ($(findstring tools, $(strip $(MAKECMDGOALS))),)
ifeq ($(findstring clean, $(strip $(MAKECMDGOALS))),)
ifeq ($(findstring dist, $(strip $(MAKECMDGOALS))),)
include config.make
endif
endif
endif
endif

# Get version string from H5Z-ZFP
H5Z_ZFP_VERSINFO := $(shell grep '^\#define H5Z_FILTER_ZFP_VERSION_[MP]' src/H5Zzfp_version.h | cut -d' ' -f3 | tr '\n' '.' | cut -d'.' -f-3 2>/dev/null)

.PHONY: help all clean dist install

help:
@echo ""
@echo ""
@echo ""
@echo " This is H5Z-ZFP version $(H5Z_ZFP_VERSINFO)."
@echo " This is H5Z-ZFP version $(H5Z_ZFP_VERSINFO)."
@echo "See http://h5z-zfp.readthedocs.io/en/latest/ file for more info."
@echo ""
@echo "Typical make command is..."
@echo ""
@echo " make CC=<C-compiler> HDF5_HOME=<path> ZFP_HOME=<path> PREFIX=<path> all"
@echo ""
@echo "where <path> is a dir whose children are include/lib/bin subdirs."
@echo "HDF5_HOME can also be specified by the HDF5 include directory,"
@echo "library directory and bin directory separated by commas, i.e. HDF5_HOME=INC,LIB,BIN"
@echo "HDF5_HOME can also be set using an INC,LIB,BIN triplet specifying"
@echo "HDF5 include, library and binary dirs separated by commas."
@echo "Standard make variables (e.g. CFLAGS, LD, etc.) can be set as usual."
@echo "Optionally, add FC=<fortran-compiler> to include Fortran support and tests."
@echo ""
@echo "Available make targets are..."
@echo " all - build everything"
@echo " check - all + run tests"
@echo " install - install compiled components"
@echo " clean - clean away all derived targets"
@echo " dist - create distribution tarfile"
@echo " all - build everything needed for H5Z-ZFP plugin/lib"
@echo " check - all + run tests"
@echo " tools - build tools (currently just print_h5repack_farg)"
@echo " install - install plugin/lib"
@echo " clean - clean away all derived targets"
@echo " dist - create distribution tarfile"
@echo " help - this help message"

all:
cd src; $(MAKE) $(MAKEVARS) $@

check: all install
check: all
cd test; $(MAKE) $(MAKEVARS) $@

install:
tools:
cd test; $(MAKE) $(MAKEVARS) print_h5repack_farg

install: all
cd src; $(MAKE) $(MAKEVARS) $@

clean:
Expand Down
32 changes: 18 additions & 14 deletions config.make
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export SHELL = /bin/bash

ifeq ($(HDF5_HOME),)
$(warning WARNING: HDF5_HOME not specified)
endif

ifeq ($(ZFP_HOME),)
$(warning WARNING: ZFP_HOME not specified)
endif
#ifeq ($(HDF5_HOME),)
# $(warning WARNING: HDF5_HOME not specified)
#endif
#
#ifeq ($(ZFP_HOME),)
# $(warning WARNING: ZFP_HOME not specified)
#endif

# disallow relative paths in HOME variables
HOME_WORDS := $(subst /, ,$(HDF5_HOME))
Expand All @@ -24,18 +24,17 @@ else ifeq ($(FIRST_WORD),..)
$(error Please use absolute path for ZFP_HOME)
endif

# Construct version variable depending on what dir we're in
# Construct H5Z_ZFP_BASE variable depending on what dir this config.cmake is being included from
PWD_BASE = $(shell basename $$(pwd))
ifeq ($(PWD_BASE),src)
H5Z_ZFP_BASE := .
else ifeq ($(PWD_BASE),test)
H5Z_ZFP_BASE := ../src
else ifeq ($(findstring H5Z-ZFP, $(PWD_BASE)), H5Z-ZFP)
ifneq ($(wildcard config.make),) # we're in top-level dir
H5Z_ZFP_BASE := ./src
else ifneq ($(wildcard test_write.c),) # we're in test dir
H5Z_ZFP_BASE := ../src
else ifneq ($(wildcard H5Zzfp.c),) # we're in src dir
H5Z_ZFP_BASE := .
endif

H5Z_ZFP_PLUGIN := $(H5Z_ZFP_BASE)/plugin
H5Z_ZFP_VERSINFO := $(shell grep '^\#define H5Z_FILTER_ZFP_VERSION_[MP]' $(H5Z_ZFP_BASE)/H5Zzfp_version.h | cut -d' ' -f3 | tr '\n' '.' | cut -d'.' -f-3 2>/dev/null)
ZFP_HAS_REVERSIBLE :=
ifneq ($(ZFP_HOME),)
ZFP_HAS_REVERSIBLE := $(shell grep zfp_stream_set_reversible $(ZFP_HOME)/include/zfp.h 2>/dev/null)
Expand Down Expand Up @@ -214,6 +213,11 @@ else
MAKEVARS = HDF5_HOME=$(HDF5_HOME)
endif

HDF5_HAS_WRITE_CHUNK = 1
ifeq ($(shell grep H5Dwrite_chunk $(HDF5_INC)/*.h),)
HDF5_HAS_WRITE_CHUNK = 0
endif

ifeq ($(PREFIX),)
PREFIX := $(shell pwd)/install
endif
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = "sphinx_rtd_theme"
#html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
24 changes: 22 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,19 @@ If you do not have Spack_ installed, it is easy to install.
Assuming you are working in a Bash shell...::

git clone https://github.com/llnl/spack.git
. spack/share/spack/setup-env.sh
cd spack
git checkout releases/v0.20
. ./share/spack/setup-env.sh
spack install h5z-zfp

.. note::

It is important to work from a *released* branch of Spack_.
The command ``git checkout releases/v0.20`` ensures this.
If a newer release of Spack_ is available, by all means feel free to use it.
Just change the ``v0.20`` to indicate the release of the Spack_ you want.
The command ``git branch -r | grep releases`` will produce a list of the available release branches.

If you are using a version of Spack_ very much older than the release of H5Z-ZFP_ you intend to use, you may have to *pin* various versions of H5Z-ZFP_, ZFP_ and/or HDF5_.
This is done by using Spack_'s ``@`` modifier to specify versions.
For example, to *pin* the version of the ZFP_ library to 0.5.5, the Spack_ command would look like::
Expand All @@ -221,9 +231,19 @@ If you wish to exclude support for Fortran, use the command::

spack install h5z-zfp ~fortran

Spack_ packages can sometimes favor the use of dependencies you may not need.
For example, the HDF5_ package favors the use of MPI.
Since H5Z-ZFP_ depends on HDF5_, this behavior will then create a dependency on MPI.
To avoid this, you can force Spack_ to use a version of HDF5_ *without* MPI using.
In the example command below, we do force Spack_ to not use MPI with HDF5_ and to not use OpenMP with ZFP_::

spack install h5z-zfp~fortran ^hdf5~mpi~fortran ^zfp~openmp

This can have the effect of substantially reducing the number of dependencies Spack_ winds up having to build in order to install H5Z_ZFP_.

.. note::

These commands will build H5Z-ZFP_ **and** all of its dependencies including the HDF5_ library *as well as a number of other dependencies you may not initially expect*.
Spack_ will build H5Z-ZFP_ **and** all of its dependencies including the HDF5_ library *as well as a number of other dependencies you may not initially expect*.
Be patient and let the build complete.
It may take more than an hour.

Expand Down
4 changes: 3 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include ../config.make
ifneq ($(strip $(MAKECMDGOALS)),clean)
include ../config.make
endif

.PHONY: all lib clean

Expand Down
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ if (EXISTS ${HDF5_BIN_DIR}/h5repack-shared)
endif ()
set(HDF5_DUMP_EXECUTABLE ${HDF5_BIN_DIR}/h5dump)

# HDF5 docs say H5Dwrite_chunk was introduced in 1.10.2
set(HDF5_HAS_WRITE_CHUNK 0)
if ("${HDF5_VERSION}" VERSION_GREATER_EQUAL "1.10.2")
set(HDF5_HAS_WRITE_CHUNK 1)
endif()

#------------------------------------------------------------------------------#
# Setup HDF5_PLUGIN_PATH
#------------------------------------------------------------------------------#
Expand All @@ -39,6 +45,7 @@ target_link_libraries(test_read_plugin h5z_zfp_shared)

add_executable(test_write_lib test_write.c)
target_compile_definitions(test_write_lib PRIVATE ZFP_LIB_VERSION=0x${ZFP_LIB_VERSION})
target_compile_definitions(test_write_lib PRIVATE HDF5_HAS_WRITE_CHUNK=${HDF5_HAS_WRITE_CHUNK})
target_compile_definitions(test_write_lib PRIVATE ZFP_HAS_CFP=${ZFP_HAS_CFP})
target_link_libraries(test_write_lib h5z_zfp_static)
if (ZFP_CFP_ENABLED)
Expand Down
12 changes: 9 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
include ../config.make
# Include config.make only if we're not making this tool
ifneq ($(strip $(MAKECMDGOALS)),print_h5repack_farg)
ifneq ($(strip $(MAKECMDGOALS)),clean)
include ../config.make
endif
endif

# printf symbols for output of test results
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
Expand Down Expand Up @@ -27,7 +33,7 @@ test_write_plugin.o: test_write.c
$(CC) -c $< -o $@ -DH5Z_ZFP_USE_PLUGIN -DZFP_LIB_VERSION=0x$(ZFP_LIB_VERSION) $(CFLAGS) -I$(H5Z_ZFP_BASE) -I$(ZFP_INC) -I$(HDF5_INC)

test_write_lib.o: test_write.c
$(CC) -c $< -o $@ $(CFLAGS) -DZFP_HAS_CFP=$(ZFP_HAS_CFP) -DZFP_LIB_VERSION=0x$(ZFP_LIB_VERSION) -I$(H5Z_ZFP_BASE) -I$(ZFP_INC) -I$(HDF5_INC)
$(CC) -c $< -o $@ $(CFLAGS) -DZFP_HAS_CFP=$(ZFP_HAS_CFP) -DHDF5_HAS_WRITE_CHUNK=$(HDF5_HAS_WRITE_CHUNK) -DZFP_LIB_VERSION=0x$(ZFP_LIB_VERSION) -I$(H5Z_ZFP_BASE) -I$(ZFP_INC) -I$(HDF5_INC)

test_write_plugin: test_write_plugin.o plugin
$(CC) $< -o $@ $(CFLAGS) $(PREPATH)$(HDF5_LIB) $(PREPATH)$(ZFP_LIB) -L$(HDF5_LIB) -L$(ZFP_LIB) -lhdf5 $(ZFP_LIBS) -lm $(LDFLAGS)
Expand Down Expand Up @@ -57,7 +63,7 @@ print_h5repack_farg: print_h5repack_farg.o
$(CC) $< -o $@ $(LDFLAGS)

print_h5repack_farg.o: print_h5repack_farg.c
$(CC) -c $< -o $@ $(CFLAGS) -I$(H5Z_ZFP_BASE) -I$(HDF5_INC)
$(CC) -c $< -o $@ $(CFLAGS) -I../src

ifneq ($(FC),) # Fortran Tests [

Expand Down
4 changes: 2 additions & 2 deletions test/test_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ int main(int argc, char **argv)
sixd = 0;
#endif

#if defined(ZFP_LIB_VERSION) && ZFP_LIB_VERSION>=0x054 && ZFP_HAS_CFP>0
#if defined(ZFP_LIB_VERSION) && ZFP_LIB_VERSION>=0x054 && ZFP_HAS_CFP>0 && HDF5_HAS_WRITE_CHUNK>0
HANDLE_ARG(zfparr,(int) strtol(argv[i]+len2,0,10),"%d",run ZFP array case using H5Dwrite_chunk);
#else
HANDLE_ARG(zfparr,(int) strtol(argv[i]+len2,0,10),"%d",requires ZFP>=0.5.4 with CFP enabled);
Expand Down Expand Up @@ -534,7 +534,7 @@ int main(int argc, char **argv)
}
/* End of 6D Example */

#if ZFP_HAS_CFP
#if ZFP_HAS_CFP>0 && HDF5_HAS_WRITE_CHUNK>0
/* ZFP Array Example */
if (zfparr>0 && zfpmode==1 && rate>0)
{
Expand Down

0 comments on commit 7b33e4f

Please sign in to comment.