From 44ef7e7e3ef0484593e1775e130f23072e264382 Mon Sep 17 00:00:00 2001 From: conrad Date: Thu, 1 Dec 2022 18:01:07 +1000 Subject: [PATCH] remove HDF5 wrapper functions --- CMakeLists.txt | 52 ------ include/armadillo | 1 - include/armadillo_bits/config.hpp | 10 -- include/armadillo_bits/config.hpp.cmake | 10 -- include/armadillo_bits/def_hdf5.hpp | 156 ----------------- include/armadillo_bits/diskio_meat.hpp | 116 ++++++------- include/armadillo_bits/hdf5_misc.hpp | 222 ++++++++++++------------ include/armadillo_bits/include_hdf5.hpp | 3 - misc/armadillo.spec | 4 +- src/wrapper1.cpp | 193 -------------------- 10 files changed, 171 insertions(+), 596 deletions(-) delete mode 100644 include/armadillo_bits/def_hdf5.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 852f4b27..2ddf8200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,6 @@ set(ARMA_USE_WRAPPER true) set(ARMA_USE_LAPACK false) set(ARMA_USE_BLAS false) set(ARMA_USE_ATLAS false) -set(ARMA_USE_HDF5_CMAKE false) set(ARMA_USE_ARPACK false) set(ARMA_USE_EXTERN_RNG false) set(ARMA_USE_SUPERLU false) # Caveat: only SuperLU version 5.x can be used! @@ -188,12 +187,6 @@ else() option(BUILD_SHARED_LIBS "build shared library" ON) endif() -option(DETECT_HDF5 "Detect HDF5 and include HDF5 support, if found" ON) -# set(DETECT_HDF5 false) -## uncomment the above line to disable the detection of the HDF5 library; -## you can also disable HDF5 detection directly on the command line: -## cmake -D DETECT_HDF5=false . - option(OPENBLAS_PROVIDES_LAPACK "Assume that OpenBLAS provides LAPACK functions" OFF) ## Example use on the command line: ## cmake -D OPENBLAS_PROVIDES_LAPACK=true . @@ -247,7 +240,6 @@ message(STATUS "CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}" ) message(STATUS "") message(STATUS "*** Options:" ) message(STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" ) -message(STATUS "DETECT_HDF5 = ${DETECT_HDF5}" ) message(STATUS "OPENBLAS_PROVIDES_LAPACK = ${OPENBLAS_PROVIDES_LAPACK}") message(STATUS "ALLOW_FLEXIBLAS_LINUX = ${ALLOW_FLEXIBLAS_LINUX}" ) message(STATUS "ALLOW_OPENBLAS_MACOS = ${ALLOW_OPENBLAS_MACOS}" ) @@ -453,49 +445,6 @@ endif() find_package(PkgConfig) -if(DETECT_HDF5) - find_package(HDF5 QUIET COMPONENTS C) - - if(NOT HDF5_FOUND) - # On Debian systems, the HDF5 package has been split into multiple packages - # so that it is co-installable. But this may mean that the include files - # are hidden somewhere very odd that the FindHDF5.cmake script will not - # find. Thus, we'll also quickly check pkgconfig to see if there is - # information on what to use there. - if (PKG_CONFIG_FOUND) - pkg_check_modules(HDF5 hdf5) - # But using pkgconfig is a little weird because HDF5_LIBRARIES won't be - # filled with exact library paths, like the other scripts. So instead - # what we get is HDF5_LIBRARY_DIRS which is the equivalent of what we'd - # pass to -L. So we have to add those... - if (HDF5_FOUND) - link_directories("${HDF5_LIBRARY_DIRS}") - endif() - endif() - endif() - - message(STATUS "HDF5_FOUND = ${HDF5_FOUND}") - if(HDF5_FOUND) - set(ARMA_USE_HDF5_CMAKE true) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${HDF5_INCLUDE_DIRS}) - set(ARMA_LIBS ${ARMA_LIBS} ${HDF5_LIBRARIES}) - # Since we called HDF5 with no arguments, the script will find only the C - # bindings. So HDF5_INCLUDE_DIRS may now contain one or two elements; if it - # contains two, the first is what the user passed as HDF5_INCLUDE_DIR and we - # should use that as ARMA_HDF5_INCLUDE_DIR. Otherwise, the one entry in - # HDF5_INCLUDE_DIRS is the correct include directory. So, in either case we - # can use the first element in the list. Issue a status message, too, just - # for good measure. - list(GET HDF5_INCLUDE_DIRS 0 ARMA_HDF5_INCLUDE_DIR) - message(STATUS "ARMA_HDF5_INCLUDE_DIR = ${ARMA_HDF5_INCLUDE_DIR}") - message(STATUS "") - message(STATUS "*** If use of HDF5 is causing problems,") - message(STATUS "*** rerun cmake with HDF5 detection disabled:") - message(STATUS "*** cmake -D DETECT_HDF5=false .") - message(STATUS "") - endif() -endif() - include(ARMA_FindARPACK) message(STATUS "ARPACK_FOUND = ${ARPACK_FOUND}") @@ -539,7 +488,6 @@ message(STATUS "*** ARMA_USE_WRAPPER = ${ARMA_USE_WRAPPER}") message(STATUS "*** ARMA_USE_LAPACK = ${ARMA_USE_LAPACK}") message(STATUS "*** ARMA_USE_BLAS = ${ARMA_USE_BLAS}") message(STATUS "*** ARMA_USE_ATLAS = ${ARMA_USE_ATLAS}") -message(STATUS "*** ARMA_USE_HDF5_CMAKE = ${ARMA_USE_HDF5_CMAKE}") message(STATUS "*** ARMA_USE_ARPACK = ${ARMA_USE_ARPACK}") message(STATUS "*** ARMA_USE_EXTERN_RNG = ${ARMA_USE_EXTERN_RNG}") message(STATUS "*** ARMA_USE_SUPERLU = ${ARMA_USE_SUPERLU}") diff --git a/include/armadillo b/include/armadillo index 04f039eb..bb858b36 100644 --- a/include/armadillo +++ b/include/armadillo @@ -152,7 +152,6 @@ namespace arma #include "armadillo_bits/def_lapack.hpp" #include "armadillo_bits/def_arpack.hpp" #include "armadillo_bits/def_superlu.hpp" - #include "armadillo_bits/def_hdf5.hpp" #include "armadillo_bits/translate_blas.hpp" #include "armadillo_bits/translate_atlas.hpp" diff --git a/include/armadillo_bits/config.hpp b/include/armadillo_bits/config.hpp index e9c872ba..78acd88d 100644 --- a/include/armadillo_bits/config.hpp +++ b/include/armadillo_bits/config.hpp @@ -159,14 +159,6 @@ //// Comment out the above line to disable checking for nonfinite matrices #endif -// #define ARMA_USE_HDF5_CMAKE -#if defined(ARMA_USE_HDF5_CMAKE) && defined(ARMA_USE_WRAPPER) - #undef ARMA_USE_HDF5 - #define ARMA_USE_HDF5 - - // #define ARMA_HDF5_INCLUDE_DIR /usr/include/ -#endif - #if !defined(ARMA_MAT_PREALLOC) #define ARMA_MAT_PREALLOC 16 #endif @@ -268,7 +260,6 @@ #if defined(ARMA_DONT_USE_WRAPPER) #undef ARMA_USE_WRAPPER - #undef ARMA_USE_HDF5_CMAKE #endif #if defined(ARMA_DONT_USE_FORTRAN_HIDDEN_ARGS) @@ -315,7 +306,6 @@ #if defined(ARMA_DONT_USE_HDF5) #undef ARMA_USE_HDF5 - #undef ARMA_USE_HDF5_CMAKE #endif #if defined(ARMA_DONT_OPTIMISE_BAND) || defined(ARMA_DONT_OPTIMISE_SOLVE_BAND) diff --git a/include/armadillo_bits/config.hpp.cmake b/include/armadillo_bits/config.hpp.cmake index 07c85b83..b706933d 100644 --- a/include/armadillo_bits/config.hpp.cmake +++ b/include/armadillo_bits/config.hpp.cmake @@ -159,14 +159,6 @@ //// Comment out the above line to disable checking for nonfinite matrices #endif -#cmakedefine ARMA_USE_HDF5_CMAKE -#if defined(ARMA_USE_HDF5_CMAKE) && defined(ARMA_USE_WRAPPER) - #undef ARMA_USE_HDF5 - #define ARMA_USE_HDF5 - - #define ARMA_HDF5_INCLUDE_DIR ${ARMA_HDF5_INCLUDE_DIR}/ -#endif - #if !defined(ARMA_MAT_PREALLOC) #define ARMA_MAT_PREALLOC 16 #endif @@ -268,7 +260,6 @@ #if defined(ARMA_DONT_USE_WRAPPER) #undef ARMA_USE_WRAPPER - #undef ARMA_USE_HDF5_CMAKE #endif #if defined(ARMA_DONT_USE_FORTRAN_HIDDEN_ARGS) @@ -315,7 +306,6 @@ #if defined(ARMA_DONT_USE_HDF5) #undef ARMA_USE_HDF5 - #undef ARMA_USE_HDF5_CMAKE #endif #if defined(ARMA_DONT_OPTIMISE_BAND) || defined(ARMA_DONT_OPTIMISE_SOLVE_BAND) diff --git a/include/armadillo_bits/def_hdf5.hpp b/include/armadillo_bits/def_hdf5.hpp deleted file mode 100644 index cb4c3f42..00000000 --- a/include/armadillo_bits/def_hdf5.hpp +++ /dev/null @@ -1,156 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// -// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) -// Copyright 2008-2016 National ICT Australia (NICTA) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------ - - -#if defined(ARMA_USE_HDF5) - -#if !defined(ARMA_USE_HDF5_CMAKE) - - // macros needed if the wrapper run-time library is not being used - - #define arma_H5Tcopy H5Tcopy - #define arma_H5Tcreate H5Tcreate - #define arma_H5Tinsert H5Tinsert - #define arma_H5Tequal H5Tequal - #define arma_H5Tclose H5Tclose - - #define arma_H5Dopen H5Dopen - #define arma_H5Dget_type H5Dget_type - #define arma_H5Dclose H5Dclose - #define arma_H5Dwrite H5Dwrite - #define arma_H5Dget_space H5Dget_space - #define arma_H5Dread H5Dread - #define arma_H5Dcreate H5Dcreate - - #define arma_H5Sget_simple_extent_ndims H5Sget_simple_extent_ndims - #define arma_H5Sget_simple_extent_dims H5Sget_simple_extent_dims - #define arma_H5Sclose H5Sclose - #define arma_H5Screate_simple H5Screate_simple - - #define arma_H5Ovisit H5Ovisit - - #define arma_H5Eset_auto H5Eset_auto - #define arma_H5Eget_auto H5Eget_auto - - #define arma_H5Fopen H5Fopen - #define arma_H5Fcreate H5Fcreate - #define arma_H5Fclose H5Fclose - #define arma_H5Fis_hdf5 H5Fis_hdf5 - - #define arma_H5Gcreate H5Gcreate - #define arma_H5Gopen H5Gopen - #define arma_H5Gclose H5Gclose - - #define arma_H5Lexists H5Lexists - #define arma_H5Ldelete H5Ldelete - - #define arma_H5T_NATIVE_UCHAR H5T_NATIVE_UCHAR - #define arma_H5T_NATIVE_CHAR H5T_NATIVE_CHAR - #define arma_H5T_NATIVE_SHORT H5T_NATIVE_SHORT - #define arma_H5T_NATIVE_USHORT H5T_NATIVE_USHORT - #define arma_H5T_NATIVE_INT H5T_NATIVE_INT - #define arma_H5T_NATIVE_UINT H5T_NATIVE_UINT - #define arma_H5T_NATIVE_LONG H5T_NATIVE_LONG - #define arma_H5T_NATIVE_ULONG H5T_NATIVE_ULONG - #define arma_H5T_NATIVE_LLONG H5T_NATIVE_LLONG - #define arma_H5T_NATIVE_ULLONG H5T_NATIVE_ULLONG - #define arma_H5T_NATIVE_FLOAT H5T_NATIVE_FLOAT - #define arma_H5T_NATIVE_DOUBLE H5T_NATIVE_DOUBLE - -#else - -// prototypes for the wrapper functions defined in the wrapper run-time library (src/wrapper.cpp) - -extern "C" - { - // Wrapper functions for H5* functions. - hid_t arma_H5Tcopy(hid_t dtype_id); - hid_t arma_H5Tcreate(H5T_class_t cl, size_t size); - herr_t arma_H5Tinsert(hid_t dtype_id, const char* name, size_t offset, hid_t field_id); - htri_t arma_H5Tequal(hid_t dtype_id1, hid_t dtype_id2); - herr_t arma_H5Tclose(hid_t dtype_id); - - hid_t arma_H5Dopen(hid_t loc_id, const char* name, hid_t dapl_id); - hid_t arma_H5Dget_type(hid_t dataset_id); - herr_t arma_H5Dclose(hid_t dataset_id); - hid_t arma_H5Dcreate(hid_t loc_id, const char* name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); - herr_t arma_H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void* buf); - hid_t arma_H5Dget_space(hid_t dataset_id); - herr_t arma_H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void* buf); - - int arma_H5Sget_simple_extent_ndims(hid_t space_id); - int arma_H5Sget_simple_extent_dims(hid_t space_id, hsize_t* dims, hsize_t* maxdims); - herr_t arma_H5Sclose(hid_t space_id); - hid_t arma_H5Screate_simple(int rank, const hsize_t* current_dims, const hsize_t* maximum_dims); - - herr_t arma_H5Ovisit(hid_t object_id, H5_index_t index_type, H5_iter_order_t order, H5O_iterate_t op, void* op_data); - - herr_t arma_H5Eset_auto(hid_t estack_id, H5E_auto_t func, void* client_data); - herr_t arma_H5Eget_auto(hid_t estack_id, H5E_auto_t* func, void** client_data); - - hid_t arma_H5Fopen(const char* name, unsigned flags, hid_t fapl_id); - hid_t arma_H5Fcreate(const char* name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); - herr_t arma_H5Fclose(hid_t file_id); - htri_t arma_H5Fis_hdf5(const char* name); - - hid_t arma_H5Gcreate(hid_t loc_id, const char* name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); - hid_t arma_H5Gopen(hid_t loc_id, const char* name, hid_t gapl_id); - herr_t arma_H5Gclose(hid_t group_id); - - htri_t arma_H5Lexists(hid_t loc_id, const char* name, hid_t lapl_id); - herr_t arma_H5Ldelete(hid_t loc_id, const char* name, hid_t lapl_id); - - // Wrapper variables that represent the hid_t values for the H5T_NATIVE_* - // types. Note that H5T_NATIVE_UCHAR itself is a macro that resolves to about - // forty other macros, and we definitely don't want to hijack those, - // so this is the best way to go about wrapping these... - extern hid_t arma_H5T_NATIVE_UCHAR; - extern hid_t arma_H5T_NATIVE_CHAR; - extern hid_t arma_H5T_NATIVE_SHORT; - extern hid_t arma_H5T_NATIVE_USHORT; - extern hid_t arma_H5T_NATIVE_INT; - extern hid_t arma_H5T_NATIVE_UINT; - extern hid_t arma_H5T_NATIVE_LONG; - extern hid_t arma_H5T_NATIVE_ULONG; - extern hid_t arma_H5T_NATIVE_LLONG; - extern hid_t arma_H5T_NATIVE_ULLONG; - extern hid_t arma_H5T_NATIVE_FLOAT; - extern hid_t arma_H5T_NATIVE_DOUBLE; - - } - - // Lastly, we have to hijack H5open() and H5check_version(), which are called - // by some expanded macros of the other H5* functions. This means we can't - // create arma_H5open(), because we can't modify those macros. Instead, we'll - // create arma::H5open() and arma::H5check_version(), and then issue a using - // directive so that arma::H5open() and arma::H5check_version() are always - // called. - // - // There is potential danger in the use of a using directive like this, but in - // this case, I can't think of a better way to solve the problem, and I doubt - // this will cause problems in any situations that aren't truly bizarre. And - // if it does cause problems, the user can #define ARMA_DONT_USE_WRAPPER or - // #undef ARMA_USE_WRAPPER in their Armadillo configuration. - herr_t H5open(); - herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); - - using arma::H5open; - using arma::H5check_version; - -#endif - -#endif diff --git a/include/armadillo_bits/diskio_meat.hpp b/include/armadillo_bits/diskio_meat.hpp index 2dad2592..996d6d67 100644 --- a/include/armadillo_bits/diskio_meat.hpp +++ b/include/armadillo_bits/diskio_meat.hpp @@ -1204,12 +1204,12 @@ diskio::save_hdf5_binary(const Mat& x, const hdf5_name& spec, std::string& e const bool append = bool(spec.opts.flags & hdf5_opts::flag_append); const bool replace = bool(spec.opts.flags & hdf5_opts::flag_replace); - const bool use_existing_file = ((append || replace) && (arma_H5Fis_hdf5(spec.filename.c_str()) > 0)); + const bool use_existing_file = ((append || replace) && (H5Fis_hdf5(spec.filename.c_str()) > 0)); const std::string tmp_name = (use_existing_file) ? std::string() : diskio::gen_tmp_name(spec.filename); // Set up the file according to HDF5's preferences - hid_t file = (use_existing_file) ? arma_H5Fopen(spec.filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT) : arma_H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + hid_t file = (use_existing_file) ? H5Fopen(spec.filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT) : H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if(file < 0) { return false; } @@ -1218,7 +1218,7 @@ diskio::save_hdf5_binary(const Mat& x, const hdf5_name& spec, std::string& e dims[1] = x.n_rows; dims[0] = x.n_cols; - hid_t dataspace = arma_H5Screate_simple(2, dims, NULL); // treat the matrix as a 2d array dataspace + hid_t dataspace = H5Screate_simple(2, dims, NULL); // treat the matrix as a 2d array dataspace hid_t datatype = hdf5_misc::get_hdf5_type(); // If this returned something invalid, well, it's time to crash. @@ -1236,11 +1236,11 @@ diskio::save_hdf5_binary(const Mat& x, const hdf5_name& spec, std::string& e // Create another group... if(loc != 0) // Ignore the first /, if there is a leading /. { - hid_t gid = arma_H5Gcreate((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + hid_t gid = H5Gcreate((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if((gid < 0) && use_existing_file) { - gid = arma_H5Gopen((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT); + gid = H5Gopen((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT); } groups.push_back(gid); @@ -1255,14 +1255,14 @@ diskio::save_hdf5_binary(const Mat& x, const hdf5_name& spec, std::string& e if(use_existing_file && replace) { - arma_H5Ldelete(last_group, dataset_name.c_str(), H5P_DEFAULT); + H5Ldelete(last_group, dataset_name.c_str(), H5P_DEFAULT); // NOTE: H5Ldelete() in HDF5 v1.8 doesn't reclaim the deleted space; use h5repack to reclaim space: h5repack oldfile.h5 newfile.h5 // NOTE: has this behaviour changed in HDF5 1.10 ? // NOTE: https://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2017-August/010482.html // NOTE: https://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2017-August/010486.html } - hid_t dataset = arma_H5Dcreate(last_group, dataset_name.c_str(), datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + hid_t dataset = H5Dcreate(last_group, dataset_name.c_str(), datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if(dataset < 0) { @@ -1272,15 +1272,15 @@ diskio::save_hdf5_binary(const Mat& x, const hdf5_name& spec, std::string& e } else { - save_okay = (arma_H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, x.mem) >= 0); + save_okay = (H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, x.mem) >= 0); - arma_H5Dclose(dataset); + H5Dclose(dataset); } - arma_H5Tclose(datatype); - arma_H5Sclose(dataspace); - for(size_t i = 0; i < groups.size(); ++i) { arma_H5Gclose(groups[i]); } - arma_H5Fclose(file); + H5Tclose(datatype); + H5Sclose(dataspace); + for(size_t i = 0; i < groups.size(); ++i) { H5Gclose(groups[i]); } + H5Fclose(file); if((use_existing_file == false) && (save_okay == true)) { save_okay = diskio::safe_rename(tmp_name, spec.filename); } @@ -2562,7 +2562,7 @@ diskio::load_hdf5_binary(Mat& x, const hdf5_name& spec, std::string& err_msg bool load_okay = false; - hid_t fid = arma_H5Fopen(spec.filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + hid_t fid = H5Fopen(spec.filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); if(fid >= 0) { @@ -2589,22 +2589,22 @@ diskio::load_hdf5_binary(Mat& x, const hdf5_name& spec, std::string& err_msg if(dataset >= 0) { - hid_t filespace = arma_H5Dget_space(dataset); + hid_t filespace = H5Dget_space(dataset); // This must be <= 2 due to our search rules. - const int ndims = arma_H5Sget_simple_extent_ndims(filespace); + const int ndims = H5Sget_simple_extent_ndims(filespace); hsize_t dims[2]; - const herr_t query_status = arma_H5Sget_simple_extent_dims(filespace, dims, NULL); + const herr_t query_status = H5Sget_simple_extent_dims(filespace, dims, NULL); // arma_check(query_status < 0, "Mat::load(): cannot get size of HDF5 dataset"); if(query_status < 0) { err_msg = "cannot get size of HDF5 dataset"; - arma_H5Sclose(filespace); - arma_H5Dclose(dataset); - arma_H5Fclose(fid); + H5Sclose(filespace); + H5Dclose(dataset); + H5Fclose(fid); return false; } @@ -2614,14 +2614,14 @@ diskio::load_hdf5_binary(Mat& x, const hdf5_name& spec, std::string& err_msg try { x.set_size(dims[1], dims[0]); } catch(...) { err_msg = "not enough memory"; return false; } // Now we have to see what type is stored to figure out how to load it. - hid_t datatype = arma_H5Dget_type(dataset); + hid_t datatype = H5Dget_type(dataset); hid_t mat_type = hdf5_misc::get_hdf5_type(); // If these are the same type, it is simple. - if(arma_H5Tequal(datatype, mat_type) > 0) + if(H5Tequal(datatype, mat_type) > 0) { // Load directly; H5S_ALL used so that we load the entire dataset. - hid_t read_status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(x.memptr())); + hid_t read_status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(x.memptr())); if(read_status >= 0) { load_okay = true; } } @@ -2634,14 +2634,14 @@ diskio::load_hdf5_binary(Mat& x, const hdf5_name& spec, std::string& err_msg } // Now clean up. - arma_H5Tclose(datatype); - arma_H5Tclose(mat_type); - arma_H5Sclose(filespace); + H5Tclose(datatype); + H5Tclose(mat_type); + H5Sclose(filespace); } - arma_H5Dclose(dataset); + H5Dclose(dataset); - arma_H5Fclose(fid); + H5Fclose(fid); if(load_okay == false) { @@ -2680,7 +2680,7 @@ diskio::load_auto_detect(Mat& x, const std::string& name, std::string& err_m #if defined(ARMA_USE_HDF5) // We're currently using the C bindings for the HDF5 library, which don't support C++ streams - if( arma_H5Fis_hdf5(name.c_str()) ) { return load_hdf5_binary(x, name, err_msg); } + if( H5Fis_hdf5(name.c_str()) ) { return load_hdf5_binary(x, name, err_msg); } #endif std::fstream f; @@ -3844,12 +3844,12 @@ diskio::save_hdf5_binary(const Cube& x, const hdf5_name& spec, std::string& const bool append = bool(spec.opts.flags & hdf5_opts::flag_append); const bool replace = bool(spec.opts.flags & hdf5_opts::flag_replace); - const bool use_existing_file = ((append || replace) && (arma_H5Fis_hdf5(spec.filename.c_str()) > 0)); + const bool use_existing_file = ((append || replace) && (H5Fis_hdf5(spec.filename.c_str()) > 0)); const std::string tmp_name = (use_existing_file) ? std::string() : diskio::gen_tmp_name(spec.filename); // Set up the file according to HDF5's preferences - hid_t file = (use_existing_file) ? arma_H5Fopen(spec.filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT) : arma_H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + hid_t file = (use_existing_file) ? H5Fopen(spec.filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT) : H5Fcreate(tmp_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if(file < 0) { return false; } @@ -3859,7 +3859,7 @@ diskio::save_hdf5_binary(const Cube& x, const hdf5_name& spec, std::string& dims[1] = x.n_cols; dims[0] = x.n_slices; - hid_t dataspace = arma_H5Screate_simple(3, dims, NULL); // treat the cube as a 3d array dataspace + hid_t dataspace = H5Screate_simple(3, dims, NULL); // treat the cube as a 3d array dataspace hid_t datatype = hdf5_misc::get_hdf5_type(); // If this returned something invalid, well, it's time to crash. @@ -3877,11 +3877,11 @@ diskio::save_hdf5_binary(const Cube& x, const hdf5_name& spec, std::string& // Create another group... if(loc != 0) // Ignore the first /, if there is a leading /. { - hid_t gid = arma_H5Gcreate((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + hid_t gid = H5Gcreate((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if((gid < 0) && use_existing_file) { - gid = arma_H5Gopen((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT); + gid = H5Gopen((groups.size() == 0) ? file : groups[groups.size() - 1], full_name.substr(0, loc).c_str(), H5P_DEFAULT); } groups.push_back(gid); @@ -3896,14 +3896,14 @@ diskio::save_hdf5_binary(const Cube& x, const hdf5_name& spec, std::string& if(use_existing_file && replace) { - arma_H5Ldelete(last_group, dataset_name.c_str(), H5P_DEFAULT); + H5Ldelete(last_group, dataset_name.c_str(), H5P_DEFAULT); // NOTE: H5Ldelete() in HDF5 v1.8 doesn't reclaim the deleted space; use h5repack to reclaim space: h5repack oldfile.h5 newfile.h5 // NOTE: has this behaviour changed in HDF5 1.10 ? // NOTE: https://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2017-August/010482.html // NOTE: https://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2017-August/010486.html } - hid_t dataset = arma_H5Dcreate(last_group, dataset_name.c_str(), datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + hid_t dataset = H5Dcreate(last_group, dataset_name.c_str(), datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if(dataset < 0) { @@ -3913,15 +3913,15 @@ diskio::save_hdf5_binary(const Cube& x, const hdf5_name& spec, std::string& } else { - save_okay = (arma_H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, x.mem) >= 0); + save_okay = (H5Dwrite(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, x.mem) >= 0); - arma_H5Dclose(dataset); + H5Dclose(dataset); } - arma_H5Tclose(datatype); - arma_H5Sclose(dataspace); - for(size_t i = 0; i < groups.size(); ++i) { arma_H5Gclose(groups[i]); } - arma_H5Fclose(file); + H5Tclose(datatype); + H5Sclose(dataspace); + for(size_t i = 0; i < groups.size(); ++i) { H5Gclose(groups[i]); } + H5Fclose(file); if((use_existing_file == false) && (save_okay == true)) { save_okay = diskio::safe_rename(tmp_name, spec.filename); } @@ -4278,7 +4278,7 @@ diskio::load_hdf5_binary(Cube& x, const hdf5_name& spec, std::string& err_ms bool load_okay = false; - hid_t fid = arma_H5Fopen(spec.filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + hid_t fid = H5Fopen(spec.filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); if(fid >= 0) { @@ -4305,22 +4305,22 @@ diskio::load_hdf5_binary(Cube& x, const hdf5_name& spec, std::string& err_ms if(dataset >= 0) { - hid_t filespace = arma_H5Dget_space(dataset); + hid_t filespace = H5Dget_space(dataset); // This must be <= 3 due to our search rules. - const int ndims = arma_H5Sget_simple_extent_ndims(filespace); + const int ndims = H5Sget_simple_extent_ndims(filespace); hsize_t dims[3]; - const herr_t query_status = arma_H5Sget_simple_extent_dims(filespace, dims, NULL); + const herr_t query_status = H5Sget_simple_extent_dims(filespace, dims, NULL); // arma_check(query_status < 0, "Cube::load(): cannot get size of HDF5 dataset"); if(query_status < 0) { err_msg = "cannot get size of HDF5 dataset"; - arma_H5Sclose(filespace); - arma_H5Dclose(dataset); - arma_H5Fclose(fid); + H5Sclose(filespace); + H5Dclose(dataset); + H5Fclose(fid); return false; } @@ -4331,14 +4331,14 @@ diskio::load_hdf5_binary(Cube& x, const hdf5_name& spec, std::string& err_ms try { x.set_size(dims[2], dims[1], dims[0]); } catch(...) { err_msg = "not enough memory"; return false; } // Now we have to see what type is stored to figure out how to load it. - hid_t datatype = arma_H5Dget_type(dataset); + hid_t datatype = H5Dget_type(dataset); hid_t mat_type = hdf5_misc::get_hdf5_type(); // If these are the same type, it is simple. - if(arma_H5Tequal(datatype, mat_type) > 0) + if(H5Tequal(datatype, mat_type) > 0) { // Load directly; H5S_ALL used so that we load the entire dataset. - hid_t read_status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(x.memptr())); + hid_t read_status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(x.memptr())); if(read_status >= 0) { load_okay = true; } } @@ -4351,14 +4351,14 @@ diskio::load_hdf5_binary(Cube& x, const hdf5_name& spec, std::string& err_ms } // Now clean up. - arma_H5Tclose(datatype); - arma_H5Tclose(mat_type); - arma_H5Sclose(filespace); + H5Tclose(datatype); + H5Tclose(mat_type); + H5Sclose(filespace); } - arma_H5Dclose(dataset); + H5Dclose(dataset); - arma_H5Fclose(fid); + H5Fclose(fid); if(load_okay == false) { @@ -4397,7 +4397,7 @@ diskio::load_auto_detect(Cube& x, const std::string& name, std::string& err_ #if defined(ARMA_USE_HDF5) // We're currently using the C bindings for the HDF5 library, which don't support C++ streams - if( arma_H5Fis_hdf5(name.c_str()) ) { return load_hdf5_binary(x, name, err_msg); } + if( H5Fis_hdf5(name.c_str()) ) { return load_hdf5_binary(x, name, err_msg); } #endif std::fstream f; diff --git a/include/armadillo_bits/hdf5_misc.hpp b/include/armadillo_bits/hdf5_misc.hpp index a3b28288..6274ebaa 100644 --- a/include/armadillo_bits/hdf5_misc.hpp +++ b/include/armadillo_bits/hdf5_misc.hpp @@ -46,7 +46,7 @@ inline hid_t get_hdf5_type< unsigned char >() { - return arma_H5Tcopy(arma_H5T_NATIVE_UCHAR); + return H5Tcopy(H5T_NATIVE_UCHAR); } template<> @@ -54,7 +54,7 @@ inline hid_t get_hdf5_type< char >() { - return arma_H5Tcopy(arma_H5T_NATIVE_CHAR); + return H5Tcopy(H5T_NATIVE_CHAR); } template<> @@ -62,7 +62,7 @@ inline hid_t get_hdf5_type< short >() { - return arma_H5Tcopy(arma_H5T_NATIVE_SHORT); + return H5Tcopy(H5T_NATIVE_SHORT); } template<> @@ -70,7 +70,7 @@ inline hid_t get_hdf5_type< unsigned short >() { - return arma_H5Tcopy(arma_H5T_NATIVE_USHORT); + return H5Tcopy(H5T_NATIVE_USHORT); } template<> @@ -78,7 +78,7 @@ inline hid_t get_hdf5_type< int >() { - return arma_H5Tcopy(arma_H5T_NATIVE_INT); + return H5Tcopy(H5T_NATIVE_INT); } template<> @@ -86,7 +86,7 @@ inline hid_t get_hdf5_type< unsigned int >() { - return arma_H5Tcopy(arma_H5T_NATIVE_UINT); + return H5Tcopy(H5T_NATIVE_UINT); } template<> @@ -94,7 +94,7 @@ inline hid_t get_hdf5_type< long >() { - return arma_H5Tcopy(arma_H5T_NATIVE_LONG); + return H5Tcopy(H5T_NATIVE_LONG); } template<> @@ -102,7 +102,7 @@ inline hid_t get_hdf5_type< unsigned long >() { - return arma_H5Tcopy(arma_H5T_NATIVE_ULONG); + return H5Tcopy(H5T_NATIVE_ULONG); } template<> @@ -110,7 +110,7 @@ inline hid_t get_hdf5_type< long long >() { - return arma_H5Tcopy(arma_H5T_NATIVE_LLONG); + return H5Tcopy(H5T_NATIVE_LLONG); } template<> @@ -118,7 +118,7 @@ inline hid_t get_hdf5_type< unsigned long long >() { - return arma_H5Tcopy(arma_H5T_NATIVE_ULLONG); + return H5Tcopy(H5T_NATIVE_ULLONG); } template<> @@ -126,7 +126,7 @@ inline hid_t get_hdf5_type< float >() { - return arma_H5Tcopy(arma_H5T_NATIVE_FLOAT); + return H5Tcopy(H5T_NATIVE_FLOAT); } template<> @@ -134,7 +134,7 @@ inline hid_t get_hdf5_type< double >() { - return arma_H5Tcopy(arma_H5T_NATIVE_DOUBLE); + return H5Tcopy(H5T_NATIVE_DOUBLE); } @@ -154,10 +154,10 @@ inline hid_t get_hdf5_type< std::complex >() { - hid_t type = arma_H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t)); + hid_t type = H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t)); - arma_H5Tinsert(type, "real", HOFFSET(hdf5_complex_t, real), arma_H5T_NATIVE_FLOAT); - arma_H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t, imag), arma_H5T_NATIVE_FLOAT); + H5Tinsert(type, "real", HOFFSET(hdf5_complex_t, real), H5T_NATIVE_FLOAT); + H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t, imag), H5T_NATIVE_FLOAT); return type; } @@ -169,10 +169,10 @@ inline hid_t get_hdf5_type< std::complex >() { - hid_t type = arma_H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t)); + hid_t type = H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t)); - arma_H5Tinsert(type, "real", HOFFSET(hdf5_complex_t, real), arma_H5T_NATIVE_DOUBLE); - arma_H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t, imag), arma_H5T_NATIVE_DOUBLE); + H5Tinsert(type, "real", HOFFSET(hdf5_complex_t, real), H5T_NATIVE_DOUBLE); + H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t, imag), H5T_NATIVE_DOUBLE); return type; } @@ -192,76 +192,76 @@ is_supported_arma_hdf5_type(hid_t datatype) // start with most likely used types: double, complex, float, complex search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type< std::complex >(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type< std::complex >(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } // remaining supported types: u8, s8, u16, s16, u32, s32, u64, s64, ulng_t, slng_t search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } search_type = get_hdf5_type(); - is_equal = ( arma_H5Tequal(datatype, search_type) > 0 ); - arma_H5Tclose(search_type); + is_equal = ( H5Tequal(datatype, search_type) > 0 ); + H5Tclose(search_type); if(is_equal) { return true; } return false; @@ -297,13 +297,13 @@ hdf5_search_callback if(info->type == H5O_TYPE_DATASET) { // Check type of dataset to see if we could even load it. - hid_t dataset = arma_H5Dopen(loc_id, name, H5P_DEFAULT); - hid_t datatype = arma_H5Dget_type(dataset); + hid_t dataset = H5Dopen(loc_id, name, H5P_DEFAULT); + hid_t datatype = H5Dget_type(dataset); const bool is_supported = is_supported_arma_hdf5_type(datatype); - arma_H5Tclose(datatype); - arma_H5Dclose(dataset); + H5Tclose(datatype); + H5Dclose(dataset); if(is_supported == false) { @@ -340,7 +340,7 @@ hdf5_search_callback if(str == search_info->names[string_pos]) { // We found it exactly. - hid_t match_candidate = arma_H5Dopen(loc_id, name, H5P_DEFAULT); + hid_t match_candidate = H5Dopen(loc_id, name, H5P_DEFAULT); if(match_candidate < 0) { @@ -348,8 +348,8 @@ hdf5_search_callback } // Ensure that the dataset is valid and of the correct dimensionality. - hid_t filespace = arma_H5Dget_space(match_candidate); - int num_dims = arma_H5Sget_simple_extent_ndims(filespace); + hid_t filespace = H5Dget_space(match_candidate); + int num_dims = H5Sget_simple_extent_ndims(filespace); if(num_dims <= search_info->num_dims) { @@ -357,14 +357,14 @@ hdf5_search_callback // If we already have an existing match we have to close it. if(search_info->best_match != -1) { - arma_H5Dclose(search_info->best_match); + H5Dclose(search_info->best_match); } search_info->best_match_position = string_pos; search_info->best_match = match_candidate; } - arma_H5Sclose(filespace); + H5Sclose(filespace); // There is no possibility of anything better, so terminate the search. return 1; } @@ -393,7 +393,7 @@ hdf5_search_callback if(substring == search_info->names[string_pos]) { // We have found the object; it must be better than our existing match. - hid_t match_candidate = arma_H5Dopen(loc_id, name, H5P_DEFAULT); + hid_t match_candidate = H5Dopen(loc_id, name, H5P_DEFAULT); // arma_check(match_candidate < 0, "Mat::load(): cannot open an HDF5 dataset"); @@ -404,8 +404,8 @@ hdf5_search_callback // Ensure that the dataset is valid and of the correct dimensionality. - hid_t filespace = arma_H5Dget_space(match_candidate); - int num_dims = arma_H5Sget_simple_extent_ndims(filespace); + hid_t filespace = H5Dget_space(match_candidate); + int num_dims = H5Sget_simple_extent_ndims(filespace); if(num_dims <= search_info->num_dims) { @@ -413,14 +413,14 @@ hdf5_search_callback // If we already have an existing match we have to close it. if(search_info->best_match != -1) { - arma_H5Dclose(search_info->best_match); + H5Dclose(search_info->best_match); } search_info->best_match_position = string_pos; search_info->best_match = match_candidate; } - arma_H5Sclose(filespace); + H5Sclose(filespace); } } @@ -428,7 +428,7 @@ hdf5_search_callback // If they are not the same, but we have not found anything and we don't need an exact match, take this. if((search_info->exact == false) && (search_info->best_match == -1)) { - hid_t match_candidate = arma_H5Dopen(loc_id, name, H5P_DEFAULT); + hid_t match_candidate = H5Dopen(loc_id, name, H5P_DEFAULT); // arma_check(match_candidate < 0, "Mat::load(): cannot open an HDF5 dataset"); if(match_candidate < 0) @@ -436,16 +436,16 @@ hdf5_search_callback return -1; } - hid_t filespace = arma_H5Dget_space(match_candidate); - int num_dims = arma_H5Sget_simple_extent_ndims(filespace); + hid_t filespace = H5Dget_space(match_candidate); + int num_dims = H5Sget_simple_extent_ndims(filespace); if(num_dims <= search_info->num_dims) { // Valid dataset -- we'll keep it. - search_info->best_match = arma_H5Dopen(loc_id, name, H5P_DEFAULT); + search_info->best_match = H5Dopen(loc_id, name, H5P_DEFAULT); } - arma_H5Sclose(filespace); + H5Sclose(filespace); } } } @@ -475,7 +475,7 @@ search_hdf5_file hdf5_search_info search_info = { names, num_dims, exact, -1, names.size() }; // We'll use the H5Ovisit to track potential entries. - herr_t status = arma_H5Ovisit(hdf5_file, H5_INDEX_NAME, H5_ITER_NATIVE, hdf5_search_callback, void_ptr(&search_info)); + herr_t status = H5Ovisit(hdf5_file, H5_INDEX_NAME, H5_ITER_NATIVE, hdf5_search_callback, void_ptr(&search_info)); // Return the best match; it will be -1 if there was a problem. return (status < 0) ? -1 : search_info.best_match; @@ -508,13 +508,13 @@ load_and_convert_hdf5 // u8 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -523,13 +523,13 @@ load_and_convert_hdf5 // s8 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -538,13 +538,13 @@ load_and_convert_hdf5 // u16 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -553,13 +553,13 @@ load_and_convert_hdf5 // s16 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -568,13 +568,13 @@ load_and_convert_hdf5 // u32 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -583,13 +583,13 @@ load_and_convert_hdf5 // s32 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -598,13 +598,13 @@ load_and_convert_hdf5 // u64 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -613,13 +613,13 @@ load_and_convert_hdf5 // s64 search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -628,13 +628,13 @@ load_and_convert_hdf5 // ulng_t search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -643,13 +643,13 @@ load_and_convert_hdf5 // slng_t search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -658,13 +658,13 @@ load_and_convert_hdf5 // float search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -673,13 +673,13 @@ load_and_convert_hdf5 // double search_type = get_hdf5_type(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { Col v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert(dest, v.memptr(), n_elem); return status; @@ -688,8 +688,8 @@ load_and_convert_hdf5 // complex float search_type = get_hdf5_type< std::complex >(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { @@ -699,7 +699,7 @@ load_and_convert_hdf5 } Col< std::complex > v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert_cx(dest, v.memptr(), n_elem); return status; @@ -708,8 +708,8 @@ load_and_convert_hdf5 // complex double search_type = get_hdf5_type< std::complex >(); - is_equal = (arma_H5Tequal(datatype, search_type) > 0); - arma_H5Tclose(search_type); + is_equal = (H5Tequal(datatype, search_type) > 0); + H5Tclose(search_type); if(is_equal) { @@ -719,7 +719,7 @@ load_and_convert_hdf5 } Col< std::complex > v(n_elem, arma_nozeros_indicator()); - hid_t status = arma_H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); + hid_t status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, void_ptr(v.memptr())); arrayops::convert_cx(dest, v.memptr(), n_elem); return status; @@ -747,16 +747,16 @@ struct hdf5_suspend_printing_errors hdf5_suspend_printing_errors() { // Save old error handler. - arma_H5Eget_auto(H5E_DEFAULT, &old_client_func, &old_client_data); + H5Eget_auto(H5E_DEFAULT, &old_client_func, &old_client_data); // Disable annoying HDF5 error messages. - arma_H5Eset_auto(H5E_DEFAULT, NULL, NULL); + H5Eset_auto(H5E_DEFAULT, NULL, NULL); } inline ~hdf5_suspend_printing_errors() { - arma_H5Eset_auto(H5E_DEFAULT, old_client_func, old_client_data); + H5Eset_auto(H5E_DEFAULT, old_client_func, old_client_data); } #endif diff --git a/include/armadillo_bits/include_hdf5.hpp b/include/armadillo_bits/include_hdf5.hpp index 8b5b5884..9e19555a 100644 --- a/include/armadillo_bits/include_hdf5.hpp +++ b/include/armadillo_bits/include_hdf5.hpp @@ -27,7 +27,6 @@ #include #else #undef ARMA_USE_HDF5 - #undef ARMA_USE_HDF5_CMAKE #pragma message ("WARNING: use of HDF5 disabled; hdf5.h header not found") #endif #else @@ -48,7 +47,6 @@ #include ARMA_INCFILE_WRAP(ARMA_HDF5_HEADER) #else #undef ARMA_USE_HDF5 - #undef ARMA_USE_HDF5_CMAKE #pragma message ("WARNING: use of HDF5 disabled; hdf5.h header not found") #endif #else @@ -63,7 +61,6 @@ #if defined(H5_USE_16_API) || defined(H5_USE_16_API_DEFAULT) #pragma message ("WARNING: use of HDF5 disabled; incompatible configuration: H5_USE_16_API or H5_USE_16_API_DEFAULT") #undef ARMA_USE_HDF5 - #undef ARMA_USE_HDF5_CMAKE #endif #endif diff --git a/misc/armadillo.spec b/misc/armadillo.spec index dcd98f1d..7d49546c 100644 --- a/misc/armadillo.spec +++ b/misc/armadillo.spec @@ -7,7 +7,7 @@ License: ASL 2.0 URL: http://arma.sourceforge.net/ Source: http://sourceforge.net/projects/arma/files/%{name}-%{version}.tar.xz -BuildRequires: gcc-c++, cmake, lapack-devel, arpack-devel, hdf5-devel +BuildRequires: gcc-c++, cmake, lapack-devel, arpack-devel %{!?openblas_arches:%global openblas_arches x86_64 %{ix86} armv7hl %{power64} aarch64} %ifarch %{openblas_arches} BuildRequires: openblas-devel @@ -36,7 +36,7 @@ computer vision, signal processing, bioinformatics, statistics, finance, etc. %package devel Summary: Development headers and documentation for the Armadillo C++ library Requires: %{name} = %{version}-%{release} -Requires: lapack-devel, arpack-devel, hdf5-devel, libstdc++-devel +Requires: lapack-devel, arpack-devel, libstdc++-devel %ifarch %{openblas_arches} Requires: openblas-devel %endif diff --git a/src/wrapper1.cpp b/src/wrapper1.cpp index 3ad471ed..38ac2d2b 100644 --- a/src/wrapper1.cpp +++ b/src/wrapper1.cpp @@ -39,20 +39,6 @@ } #endif -#if defined(ARMA_USE_HDF5_CMAKE) - - #undef H5_USE_110_API - #define H5_USE_110_API - - #include - - #if defined(H5_USE_16_API) || defined(H5_USE_16_API_DEFAULT) - #pragma message ("WARNING: use of HDF5 disabled; incompatible configuration: H5_USE_16_API or H5_USE_16_API_DEFAULT") - #undef ARMA_USE_HDF5_CMAKE - #endif - -#endif - namespace arma { @@ -61,22 +47,6 @@ namespace arma #include "armadillo_bits/def_lapack.hpp" #include "armadillo_bits/def_arpack.hpp" #include "armadillo_bits/def_superlu.hpp" -// no need to include def_hdf5.hpp -- it only contains #defines for when ARMA_USE_HDF5_CMAKE is not defined. - - -#if defined(ARMA_USE_HDF5_CMAKE) - // Wrapper functions: arma::H5open() and arma::H5check_version() to hijack calls to H5open() and H5check_version() - herr_t H5open() - { - return ::H5open(); - } - - herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) - { - return ::H5check_version(majnum, minnum, relnum); - } -#endif - // at this stage we have prototypes for actual BLAS and LAPACK functions @@ -1592,169 +1562,6 @@ extern "C" } #endif - - - - #if defined(ARMA_USE_HDF5_CMAKE) - - hid_t arma_H5Tcopy(hid_t dtype_id) - { - return H5Tcopy(dtype_id); - } - - hid_t arma_H5Tcreate(H5T_class_t cl, size_t size) - { - return H5Tcreate(cl, size); - } - - herr_t arma_H5Tinsert(hid_t dtype_id, const char* name, size_t offset, hid_t field_id) - { - return H5Tinsert(dtype_id, name, offset, field_id); - } - - htri_t arma_H5Tequal(hid_t dtype_id1, hid_t dtype_id2) - { - return H5Tequal(dtype_id1, dtype_id2); - } - - herr_t arma_H5Tclose(hid_t dtype_id) - { - return H5Tclose(dtype_id); - } - - hid_t arma_H5Dopen(hid_t loc_id, const char* name, hid_t dapl_id) - { - return H5Dopen(loc_id, name, dapl_id); - } - - hid_t arma_H5Dget_type(hid_t dataset_id) - { - return H5Dget_type(dataset_id); - } - - hid_t arma_H5Dcreate(hid_t loc_id, const char* name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) - { - return H5Dcreate(loc_id, name, dtype_id, space_id, lcpl_id, dcpl_id, dapl_id); - } - - herr_t arma_H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void* buf) - { - return H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - } - - herr_t arma_H5Dclose(hid_t dataset_id) - { - return H5Dclose(dataset_id); - } - - hid_t arma_H5Dget_space(hid_t dataset_id) - { - return H5Dget_space(dataset_id); - } - - herr_t arma_H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void* buf) - { - return H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - } - - int arma_H5Sget_simple_extent_ndims(hid_t space_id) - { - return H5Sget_simple_extent_ndims(space_id); - } - - int arma_H5Sget_simple_extent_dims(hid_t space_id, hsize_t* dims, hsize_t* maxdims) - { - return H5Sget_simple_extent_dims(space_id, dims, maxdims); - } - - herr_t arma_H5Sclose(hid_t space_id) - { - return H5Sclose(space_id); - } - - hid_t arma_H5Screate_simple(int rank, const hsize_t* current_dims, const hsize_t* maximum_dims) - { - return H5Screate_simple(rank, current_dims, maximum_dims); - } - - herr_t arma_H5Ovisit(hid_t object_id, H5_index_t index_type, H5_iter_order_t order, H5O_iterate_t op, void* op_data) - { - return H5Ovisit(object_id, index_type, order, op, op_data); - } - - herr_t arma_H5Eset_auto(hid_t estack_id, H5E_auto_t func, void* client_data) - { - return H5Eset_auto(estack_id, func, client_data); - } - - herr_t arma_H5Eget_auto(hid_t estack_id, H5E_auto_t* func, void** client_data) - { - return H5Eget_auto(estack_id, func, client_data); - } - - hid_t arma_H5Fopen(const char* name, unsigned flags, hid_t fapl_id) - { - return H5Fopen(name, flags, fapl_id); - } - - hid_t arma_H5Fcreate(const char* name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) - { - return H5Fcreate(name, flags, fcpl_id, fapl_id); - } - - herr_t arma_H5Fclose(hid_t file_id) - { - return H5Fclose(file_id); - } - - htri_t arma_H5Fis_hdf5(const char* name) - { - return H5Fis_hdf5(name); - } - - hid_t arma_H5Gcreate(hid_t loc_id, const char* name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) - { - return H5Gcreate(loc_id, name, lcpl_id, gcpl_id, gapl_id); - } - - hid_t arma_H5Gopen(hid_t loc_id, const char* name, hid_t gapl_id) - { - return H5Gopen(loc_id, name, gapl_id); - } - - herr_t arma_H5Gclose(hid_t group_id) - { - return H5Gclose(group_id); - } - - htri_t arma_H5Lexists(hid_t loc_id, const char* name, hid_t lapl_id) - { - return H5Lexists(loc_id, name, lapl_id); - } - - herr_t arma_H5Ldelete(hid_t loc_id, const char* name, hid_t lapl_id) - { - return H5Ldelete(loc_id, name, lapl_id); - } - - - // H5T_NATIVE_* types. The rhs here expands to some macros. - hid_t arma_H5T_NATIVE_UCHAR = H5T_NATIVE_UCHAR; - hid_t arma_H5T_NATIVE_CHAR = H5T_NATIVE_CHAR; - hid_t arma_H5T_NATIVE_SHORT = H5T_NATIVE_SHORT; - hid_t arma_H5T_NATIVE_USHORT = H5T_NATIVE_USHORT; - hid_t arma_H5T_NATIVE_INT = H5T_NATIVE_INT; - hid_t arma_H5T_NATIVE_UINT = H5T_NATIVE_UINT; - hid_t arma_H5T_NATIVE_LONG = H5T_NATIVE_LONG; - hid_t arma_H5T_NATIVE_ULONG = H5T_NATIVE_ULONG; - hid_t arma_H5T_NATIVE_LLONG = H5T_NATIVE_LLONG; - hid_t arma_H5T_NATIVE_ULLONG = H5T_NATIVE_ULLONG; - hid_t arma_H5T_NATIVE_FLOAT = H5T_NATIVE_FLOAT; - hid_t arma_H5T_NATIVE_DOUBLE = H5T_NATIVE_DOUBLE; - - #endif - - } // end of extern "C"