mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
fb40a72b45
re: Issue https://github.com/Unidata/netcdf-c/issues/2685 re: PR https://github.com/Unidata/netcdf-c/pull/2179 As noted in PR https://github.com/Unidata/netcdf-c/pull/2179, the old code did not allow for reclaiming instances of types, nor for properly copying them. That PR provided new functions capable of reclaiming/copying instances of arbitrary types. However, as noted by Issue https://github.com/Unidata/netcdf-c/issues/2685, using these most general functions resulted in a significant performance degradation, even for common cases. This PR attempts to mitigate the cost of using the general reclaim/copy functions in two ways. First, the previous functions operating at the top level by using ncid and typeid arguments. These functions were augmented with equivalent versions that used the netcdf-c library internal data structures to allow direct access to needed information. These new functions are used internally to the library. The second mitigation involves optimizing the internal functions by providing early tests for common cases. This avoids unnecessary recursive function calls. The overall result is a significant improvement in speed by a factor of roughly twenty -- your mileage may vary. These optimized functions are still not as fast as the original (more limited) functions, but they are getting close. Additional optimizations are possible. But the cost is a significant "uglification" of the code that I deemed a step too far, at least for now. ## Misc. Changes 1. Added a test case to check the proper reclamation/copy of complex types. 2. Found and fixed some places where nc_reclaim/copy should have been used. 3. Replaced, in the netcdf-c library, (almost all) occurrences of nc_reclaim_copy with calls to NC_reclaim/copy. This plus the optimizations is the primary speed-up mechanism. 4. In DAP4, the metadata is held in a substrate in-memory file; this required some changes so that the reclaim/copy code accessed that substrate dispatcher rather than the DAP4 dispatcher. 5. Re-factored and isolated the code that computes if a type is (transitively) variable-sized or not. 6. Clean up the reclamation code in ncgen; adding the use of nc_reclaim exposed some memory problems.
160 lines
4.6 KiB
Makefile
160 lines
4.6 KiB
Makefile
# Copyright 2018, UCAR/Unidata
|
|
# See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
# Put Together AM_CPPFLAGS and AM_LDFLAGS
|
|
include $(top_srcdir)/lib_flags.am
|
|
|
|
# This linker flag specifies libtool version info.
|
|
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
|
|
# for information regarding incrementing `-version-info`.
|
|
plugin_version_info = -version-info 0:0:0
|
|
|
|
AM_LDFLAGS += -module -shared -export-dynamic $(NOUNDEFINED)
|
|
|
|
if ISMINGW
|
|
AM_LDFLAGS += -avoid-version
|
|
else !ISMINGW
|
|
if ISCYGWIN
|
|
AM_LDFLAGS += -avoid-version
|
|
else !ISCYGWIN
|
|
AM_LDFLAGS += $(plugin_version_info)
|
|
endif !ISCYGWIN
|
|
endif !ISMINGW
|
|
|
|
# Create an alternate directory if not installing.
|
|
ALTPLUGINDIR = ${abs_top_builddir}/plugins/plugindir
|
|
|
|
RPATH = -rpath $(abs_builddir)/.libs
|
|
|
|
# This is where the plugins are to be installed
|
|
if ENABLE_PLUGIN_DIR
|
|
plugindir = @PLUGIN_INSTALL_DIR@
|
|
else
|
|
plugindir = ${ALTPLUGINDIR}
|
|
AM_LDFLAGS += ${RPATH}
|
|
endif
|
|
|
|
plugin_LTLIBRARIES =
|
|
plugins_to_install =
|
|
|
|
# These libraries are for testing only
|
|
check_LTLIBRARIES =
|
|
|
|
if ISMINGW
|
|
LDADD = ${top_builddir}/liblib/libnetcdf.la
|
|
LIBADD = $(LDADD)
|
|
endif
|
|
if ISCYGWIN
|
|
LDADD = $(top_builddir)/liblib/libnetcdf.la
|
|
LIBADD = $(top_builddir)/liblib/libnetcdf.la
|
|
endif
|
|
|
|
EXTRA_DIST = CMakeLists.txt
|
|
|
|
# The HDF5 filter wrappers
|
|
EXTRA_DIST += \
|
|
H5Ztemplate.c H5Zmisc.c H5Zutil.c H5Znoop.c h5noop.h NCZmisc.c \
|
|
H5Zshuffle.c H5Zdeflate.c H5Zszip.c H5Zszip.h \
|
|
H5Zbzip2.c h5bzip2.h H5Zblosc.c H5Zblosc.h H5Zzstd.c H5Zzstd.h
|
|
|
|
# The Codec filter wrappers
|
|
EXTRA_DIST += NCZhdf5filters.c NCZstdfilters.c
|
|
# The Filter implementations
|
|
EXTRA_DIST += H5checksum.c
|
|
|
|
if ENABLE_FILTER_TESTING
|
|
|
|
if ENABLE_NCZARR_FILTERS
|
|
plugins_to_install += lib__nch5fletcher32.la lib__nch5shuffle.la
|
|
lib__nch5shuffle_la_SOURCES = H5Zshuffle.c
|
|
lib__nch5fletcher32_la_SOURCES = H5Zfletcher32.c H5checksum.c
|
|
if HAVE_DEFLATE
|
|
plugins_to_install += lib__nch5deflate.la
|
|
lib__nch5deflate_la_SOURCES = H5Zdeflate.c
|
|
endif
|
|
|
|
# Need our version of szip if libsz available and we are not using HDF5
|
|
if HAVE_SZ
|
|
plugins_to_install += lib__nch5szip.la
|
|
lib__nch5szip_la_SOURCES = H5Zszip.c H5Zszip.h
|
|
endif
|
|
|
|
endif # ENABLE_NCZARR_FILTERS
|
|
|
|
if ENABLE_PLUGINS
|
|
|
|
# The NCZarr codec libraries (they need libnetcdf)
|
|
lib__nczstdfilters_la_SOURCES = NCZstdfilters.c
|
|
lib__nczstdfilters_la_LIBADD = $(LIBADD) $(top_builddir)/liblib/libnetcdf.la
|
|
lib__nczhdf5filters_la_SOURCES = NCZhdf5filters.c
|
|
lib__nczhdf5filters_la_LIBADD = $(LIBADD) $(top_builddir)/liblib/libnetcdf.la
|
|
|
|
plugins_to_install += lib__nczhdf5filters.la
|
|
plugins_to_install += lib__nczstdfilters.la
|
|
|
|
if HAVE_BLOSC
|
|
lib__nch5blosc_la_SOURCES = H5Zblosc.c H5Zblosc.h
|
|
plugins_to_install += lib__nch5blosc.la
|
|
endif
|
|
|
|
if HAVE_ZSTD
|
|
lib__nch5zstd_la_SOURCES = H5Zzstd.c H5Zzstd.h
|
|
plugins_to_install += lib__nch5zstd.la
|
|
endif
|
|
|
|
endif #ENABLE_PLUGINS
|
|
|
|
# The noop filter is to allow testing of multifilters and filter order
|
|
# Need two distinct instances
|
|
lib__nch5noop_la_SOURCES = H5Znoop.c H5Zutil.c h5noop.h
|
|
lib__nch5noop1_la_SOURCES = H5Znoop1.c H5Zutil.c h5noop.h
|
|
lib__nch5noop_la_LDFLAGS = $(AM_LDFLAGS) ${RPATH}
|
|
lib__nch5noop1_la_LDFLAGS = $(AM_LDFLAGS) ${RPATH}
|
|
|
|
# The misc filter is to allow testing of filter arguments
|
|
lib__nch5misc_la_SOURCES = H5Zmisc.c H5Zutil.c h5misc.h
|
|
lib__nch5misc_la_LDFLAGS = $(AM_LDFLAGS) ${RPATH}
|
|
lib__nczmisc_la_SOURCES = NCZmisc.c
|
|
lib__nczmisc_la_LDFLAGS = $(AM_LDFLAGS) ${RPATH}
|
|
|
|
# Provide a filter to test missing filter
|
|
lib__nch5unknown_la_SOURCES = H5Zunknown.c
|
|
lib__nch5unknown_la_LDFLAGS = $(AM_LDFLAGS) ${RPATH}
|
|
|
|
check_LTLIBRARIES += lib__nch5noop.la lib__nch5noop1.la lib__nch5unknown.la
|
|
check_LTLIBRARIES += lib__nch5misc.la lib__nczmisc.la
|
|
|
|
# Bzip2 is used to test more complex filters
|
|
lib__nch5bzip2_la_SOURCES = H5Zbzip2.c h5bzip2.h
|
|
BZIP2SRC = blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c bzlib.h bzlib_private.h
|
|
EXTRA_DIST += ${BZIP2SRC} BZIP2_LICENSE
|
|
if HAVE_LOCAL_BZ2
|
|
lib__nch5bzip2_la_SOURCES += ${BZIP2SRC}
|
|
endif
|
|
plugins_to_install += lib__nch5bzip2.la
|
|
|
|
endif #ENABLE_FILTER_TESTING
|
|
|
|
if ENABLE_PLUGIN_DIR
|
|
plugin_LTLIBRARIES += $(plugins_to_install)
|
|
else
|
|
check_LTLIBRARIES += $(plugins_to_install)
|
|
endif
|
|
|
|
BUILT_SOURCES = H5Znoop1.c
|
|
DISTCLEANFILES = H5Znoop1.c H5Znoop2.c ncjson.h
|
|
H5Znoop1.c: Makefile H5Znoop.c
|
|
echo '#define NOOP_INSTANCE 1' > $@
|
|
cat ${srcdir}/H5Znoop.c >> $@
|
|
|
|
# Record where bzip2 came from; may be out of date
|
|
BZIP2VER = 1.0.8
|
|
BZIP2DIR = bzip2-${BZIP2VER}
|
|
BZIP2URL = https://sourceware.org/pub/bzip2/${BZIP2DIR}.tar.gz
|
|
bzip2::
|
|
rm -fr ./${BZIP2DIR} ${BZIP2SRC} BZIP2_LICENSE
|
|
wget ${BZIP2URL}
|
|
tar -zxf ${BZIP2DIR}.tar.gz
|
|
cd ${BZIP2DIR}; cp ${BZIP2SRC} ..; cp LICENSE ../BZIP2_LICENSE ; cd ..
|
|
rm -fr ./${BZIP2DIR}
|