diff --git a/src/cmake/Setup3rdParty.cmake b/src/cmake/Setup3rdParty.cmake index 194778ed8..0bc85d1bf 100644 --- a/src/cmake/Setup3rdParty.cmake +++ b/src/cmake/Setup3rdParty.cmake @@ -150,3 +150,16 @@ if(ADIOS_DIR) message(FATAL_ERROR "ADIOS_DIR is set, but ADIOS wasn't found.") endif() endif() + +################################ +# Setup Zfp if available +################################ +# Search for Zfp. +if(ZFP_DIR) + include(cmake/thirdparty/SetupZfp.cmake) + include_directories(${ZFP_INCLUDE_DIR}) + # if we don't find Zfp, throw a fatal error + if(NOT ZFP_FOUND) + message(FATAL_ERROR "ZFP_DIR is set, but Zfp wasn't found.") + endif() +endif() diff --git a/src/cmake/thirdparty/SetupZfp.cmake b/src/cmake/thirdparty/SetupZfp.cmake new file mode 100644 index 000000000..d1b156a77 --- /dev/null +++ b/src/cmake/thirdparty/SetupZfp.cmake @@ -0,0 +1,86 @@ +############################################################################### +# Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC. +# +# Produced at the Lawrence Livermore National Laboratory +# +# LLNL-CODE-666778 +# +# All rights reserved. +# +# This file is part of Conduit. +# +# For details, see: http://software.llnl.gov/conduit/. +# +# Please also read conduit/LICENSE +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the disclaimer below. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the disclaimer (as noted below) in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the LLNS/LLNL nor the names of its contributors may +# be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################### +# +# Setup Zfp +# This file defines: +# ZFP_FOUND - If Zfp was found +# ZFP_INCLUDE_DIR - The Zfp include directories +# ZFP_LIB - Zfp library + + +# first Check for ZFP_DIR + +if(NOT ZFP_DIR) + MESSAGE(FATAL_ERROR "Zfp support needs explicit ZFP_DIR") +endif() + +find_path(ZFP_INCLUDE_DIR zfp.h + PATHS ${ZFP_DIR}/include + NO_DEFAULT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_CMAKE_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + +find_library(ZFP_LIB NAMES zfp + PATHS ${ZFP_DIR}/lib64 ${ZFP_DIR}/lib + NO_DEFAULT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_CMAKE_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set ZFP_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Zfp DEFAULT_MSG + ZFP_LIB ZFP_INCLUDE_DIR) + +mark_as_advanced(ZFP_INCLUDE_DIR + ZFP_LIB) + + +blt_register_library(NAME zfp + INCLUDES ${ZFP_INCLUDE_DIR} + LIBRARIES ${ZFP_LIB} ) diff --git a/src/libs/blueprint/CMakeLists.txt b/src/libs/blueprint/CMakeLists.txt index 85a65feb1..5149fe173 100644 --- a/src/libs/blueprint/CMakeLists.txt +++ b/src/libs/blueprint/CMakeLists.txt @@ -63,6 +63,7 @@ set(blueprint_headers conduit_blueprint_mesh_examples.hpp conduit_blueprint_mcarray.hpp conduit_blueprint_mcarray_examples.hpp + conduit_blueprint_zfparray.hpp ${CMAKE_CURRENT_BINARY_DIR}/conduit_blueprint_exports.h ) @@ -85,6 +86,7 @@ set(blueprint_sources conduit_blueprint_mesh_examples.cpp conduit_blueprint_mcarray.cpp conduit_blueprint_mcarray_examples.cpp + conduit_blueprint_zfparray.cpp ) # diff --git a/src/libs/blueprint/conduit_blueprint.cpp b/src/libs/blueprint/conduit_blueprint.cpp index d0f0de6e1..050d28289 100644 --- a/src/libs/blueprint/conduit_blueprint.cpp +++ b/src/libs/blueprint/conduit_blueprint.cpp @@ -93,6 +93,7 @@ about(Node &n) n["protocols/mesh/index"] = "enabled"; n["protocols/mcarray"] = "enabled"; + n["protocols/zfparray"] = "enabled"; } //---------------------------------------------------------------------------// diff --git a/src/libs/blueprint/conduit_blueprint.hpp b/src/libs/blueprint/conduit_blueprint.hpp index 898b08e12..e0dabe2f6 100644 --- a/src/libs/blueprint/conduit_blueprint.hpp +++ b/src/libs/blueprint/conduit_blueprint.hpp @@ -64,6 +64,7 @@ #include "conduit_blueprint_mcarray.hpp" #include "conduit_blueprint_mcarray_examples.hpp" +#include "conduit_blueprint_zfparray.hpp" //----------------------------------------------------------------------------- // -- begin conduit:: -- diff --git a/src/libs/blueprint/conduit_blueprint_zfparray.cpp b/src/libs/blueprint/conduit_blueprint_zfparray.cpp new file mode 100644 index 000000000..07eff5ee2 --- /dev/null +++ b/src/libs/blueprint/conduit_blueprint_zfparray.cpp @@ -0,0 +1,162 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see: http://software.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: conduit_blueprint_zfparray.cpp +/// +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// conduit includes +//----------------------------------------------------------------------------- +#include "conduit_blueprint_zfparray.hpp" +#include "conduit_log.hpp" + +using namespace conduit; +// Easier access to the Conduit logging functions +using namespace conduit::utils; + +//----------------------------------------------------------------------------- +// -- begin conduit:: -- +//----------------------------------------------------------------------------- +namespace conduit +{ + + +//----------------------------------------------------------------------------- +// -- begin conduit::blueprint:: -- +//----------------------------------------------------------------------------- +namespace blueprint +{ + +//----------------------------------------------------------------------------- +// -- begin conduit::blueprint::zfparray -- +//----------------------------------------------------------------------------- +namespace zfparray +{ + +//----------------------------------------------------------------------------- +bool +verify(const std::string &/*protocol*/, + const Node &/*n*/, + Node &info) +{ + // zfparray doesn't provide any nested protocols + + info.reset(); + log::validation(info, false); + return false; +} + + +//---------------------------------------------------------------------------- +bool verify(const conduit::Node &n, + Node &info) +{ + info.reset(); + bool res = true; + + const std::string proto_name = "zfparray"; + + if(!n.dtype().is_object()) + { + log::error(info,proto_name, "Node has no children"); + res = false; + } + + // ensure header + if(!n.has_child(ZFP_HEADER_FIELD_NAME)) + { + log::error(info, proto_name, "Node does not have zfparray header child"); + res = false; + } + else + { + const Node &n_header = n.fetch_child(ZFP_HEADER_FIELD_NAME); + + // compressed-array headers consist of uint8 words + if(!n_header.dtype().is_uint8()) { + log::error(info, proto_name, "ZFP header node's dtype is invalid"); + res = false; + } + } + + if(!n.has_child(ZFP_COMPRESSED_DATA_FIELD_NAME)) + { + log::error(info, proto_name, "Node does not have zfparray compressed-data child"); + res = false; + } + else + { + const Node &compressed_data = n.fetch_child(ZFP_COMPRESSED_DATA_FIELD_NAME); + + if(!compressed_data.dtype().is_unsigned_integer()) { + log::error(info, proto_name, "ZFP compressed-data node's dtype is incompatible with the compiled ZFP bitstream word size"); + res = false; + } + } + + log::validation(info, res); + + return res; +} + +//----------------------------------------------------------------------------- +} +//----------------------------------------------------------------------------- +// -- end conduit::blueprint::zfparray -- +//----------------------------------------------------------------------------- + + +} +//----------------------------------------------------------------------------- +// -- end conduit::blueprint:: -- +//----------------------------------------------------------------------------- + + +} +//----------------------------------------------------------------------------- +// -- end conduit:: -- +//----------------------------------------------------------------------------- diff --git a/src/libs/blueprint/conduit_blueprint_zfparray.hpp b/src/libs/blueprint/conduit_blueprint_zfparray.hpp new file mode 100644 index 000000000..9462e9e88 --- /dev/null +++ b/src/libs/blueprint/conduit_blueprint_zfparray.hpp @@ -0,0 +1,116 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see: http://software.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: conduit_blueprint_zfparray.hpp +/// +//----------------------------------------------------------------------------- + +#ifndef CONDUIT_BLUEPRINT_ZFPARRAY_HPP +#define CONDUIT_BLUEPRINT_ZFPARRAY_HPP + +//----------------------------------------------------------------------------- +// conduit lib includes +//----------------------------------------------------------------------------- +#include "conduit.hpp" +#include "conduit_blueprint_exports.h" + + +//----------------------------------------------------------------------------- +// -- begin conduit:: -- +//----------------------------------------------------------------------------- +namespace conduit +{ + + +//----------------------------------------------------------------------------- +// -- begin conduit::blueprint -- +//----------------------------------------------------------------------------- +namespace blueprint +{ + +//----------------------------------------------------------------------------- +// -- begin conduit::blueprint::zfparray -- +//----------------------------------------------------------------------------- +namespace zfparray +{ + +static const std::string ZFP_HEADER_FIELD_NAME = "zfp_header"; +static const std::string ZFP_COMPRESSED_DATA_FIELD_NAME = "zfp_compressed_data"; + +//----------------------------------------------------------------------------- +// blueprint protocol interface +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +bool CONDUIT_BLUEPRINT_API verify(const conduit::Node &n, + conduit::Node &info); + +//----------------------------------------------------------------------------- +bool CONDUIT_BLUEPRINT_API verify(const std::string &protocol, + const conduit::Node &n, + conduit::Node &info); + + +//----------------------------------------------------------------------------- +} +//----------------------------------------------------------------------------- +// -- end conduit::blueprint::zfparray -- +//----------------------------------------------------------------------------- + + +} +//----------------------------------------------------------------------------- +// -- end conduit::blueprint -- +//----------------------------------------------------------------------------- + + +} +//----------------------------------------------------------------------------- +// -- end conduit:: -- +//----------------------------------------------------------------------------- + + +#endif diff --git a/src/libs/relay/CMakeLists.txt b/src/libs/relay/CMakeLists.txt index 864e1ba5a..78f9965bc 100644 --- a/src/libs/relay/CMakeLists.txt +++ b/src/libs/relay/CMakeLists.txt @@ -151,6 +151,11 @@ if(ADIOS_FOUND) list(APPEND conduit_relay_sources conduit_relay_io_adios.cpp) endif() +if(ZFP_FOUND) + list(APPEND conduit_relay_headers conduit_relay_zfp.hpp) + list(APPEND conduit_relay_sources conduit_relay_zfp.cpp) +endif() + ################################ # Add fortran interface if # fortran support was selected @@ -203,6 +208,10 @@ if(ADIOS_FOUND) list(APPEND conduit_relay_deps adios_nompi) endif() +if(ZFP_FOUND) + list(APPEND conduit_relay_deps zfp) +endif() + add_compiled_library(NAME conduit_relay EXPORT conduit diff --git a/src/libs/relay/conduit_relay_zfp.cpp b/src/libs/relay/conduit_relay_zfp.cpp new file mode 100644 index 000000000..2fb2cf4d9 --- /dev/null +++ b/src/libs/relay/conduit_relay_zfp.cpp @@ -0,0 +1,183 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see: http://software.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: conduit_relay_zfp.cpp +/// +//----------------------------------------------------------------------------- + +#include "conduit_relay_zfp.hpp" +#include "zfpfactory.h" + +//----------------------------------------------------------------------------- +// -- begin conduit:: -- +//----------------------------------------------------------------------------- +namespace conduit +{ + +//----------------------------------------------------------------------------- +// -- begin conduit::relay -- +//----------------------------------------------------------------------------- +namespace relay +{ + + +//----------------------------------------------------------------------------- +// -- begin conduit::relay::io -- +//----------------------------------------------------------------------------- +namespace io +{ + +zfp::array* +unwrap_zfparray(const Node &node) +{ + Node compressed_data = node.fetch_child(ZFP_COMPRESSED_DATA_FIELD_NAME); + + // verify word size is readable with zfp + // zfp's bitstream consists of uint words + bool is_readable = true; + switch(stream_word_bits) { + case 64: + is_readable = compressed_data.dtype().is_uint64(); + break; + + case 32: + is_readable = compressed_data.dtype().is_uint32(); + break; + + case 16: + is_readable = compressed_data.dtype().is_uint16(); + break; + + case 8: + is_readable = compressed_data.dtype().is_uint8(); + break; + + default: + is_readable = false; + break; + } + + if(!is_readable) { + return NULL; + } + + zfp::array::header header; + memcpy(header.buffer, node.fetch_child(ZFP_HEADER_FIELD_NAME).data_ptr(), sizeof(header)); + + try { + return zfp::array::construct(header, static_cast(compressed_data.data_ptr()), compressed_data.allocated_bytes()); + } catch(std::exception const &) { + // could be zfp::array::header::exception, or std::bad_alloc + return NULL; + } +} + +template +void +cast_and_set_compressed_data(Node &dest, uchar* compressed_data, size_t num_data_words) +{ + void* intermediate_ptr = static_cast(compressed_data); + dest[ZFP_COMPRESSED_DATA_FIELD_NAME].set(static_cast(intermediate_ptr), num_data_words); +} + +int +wrap_zfparray(const zfp::array *arr, + Node &dest) +{ + // store header + zfp::array::header header; + try { + header = arr->get_header(); + } catch(zfp::array::header::exception const &) { + return 1; + } + dest[ZFP_HEADER_FIELD_NAME].set(static_cast(header.buffer), sizeof(header)); + + // store compressed data + size_t compressed_data_len_bits = arr->compressed_size() * CHAR_BIT; + // should already by a multiple of stream_word_bits (round for safety) + size_t num_data_words = (compressed_data_len_bits + stream_word_bits - 1) / stream_word_bits; + + // store compressed-data under same dtype as bitstream's underlying word + switch(stream_word_bits) { + case 64: + cast_and_set_compressed_data(dest, arr->compressed_data(), num_data_words); + break; + + case 32: + cast_and_set_compressed_data(dest, arr->compressed_data(), num_data_words); + break; + + case 16: + cast_and_set_compressed_data(dest, arr->compressed_data(), num_data_words); + break; + + case 8: + cast_and_set_compressed_data(dest, arr->compressed_data(), num_data_words); + break; + + default: + // error + return 2; + } + + return 0; +} + +} +//----------------------------------------------------------------------------- +// -- end conduit::relay::io -- +//----------------------------------------------------------------------------- + +} +//----------------------------------------------------------------------------- +// -- end conduit::relay -- +//----------------------------------------------------------------------------- + +} +//----------------------------------------------------------------------------- +// -- end conduit:: -- +//----------------------------------------------------------------------------- diff --git a/src/libs/relay/conduit_relay_zfp.hpp b/src/libs/relay/conduit_relay_zfp.hpp new file mode 100644 index 000000000..3e618fe19 --- /dev/null +++ b/src/libs/relay/conduit_relay_zfp.hpp @@ -0,0 +1,108 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see: http://software.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: conduit_relay_zfp.hpp +/// +//----------------------------------------------------------------------------- + +#ifndef CONDUIT_RELAY_ZFP_HPP +#define CONDUIT_RELAY_ZFP_HPP + +//----------------------------------------------------------------------------- +// external lib includes +//----------------------------------------------------------------------------- +#include "zfparray1.h" +#include "zfparray2.h" +#include "zfparray3.h" + +//----------------------------------------------------------------------------- +// conduit includes +//----------------------------------------------------------------------------- +#include "conduit_relay_io.hpp" + +//----------------------------------------------------------------------------- +// -- begin conduit:: -- +//----------------------------------------------------------------------------- +namespace conduit +{ + +//----------------------------------------------------------------------------- +// -- begin conduit::relay -- +//----------------------------------------------------------------------------- +namespace relay +{ + +//----------------------------------------------------------------------------- +// -- begin conduit::relay::io -- +//----------------------------------------------------------------------------- +namespace io +{ + +static const std::string ZFP_HEADER_FIELD_NAME = "zfp_header"; +static const std::string ZFP_COMPRESSED_DATA_FIELD_NAME = "zfp_compressed_data"; + +zfp::array* CONDUIT_RELAY_API unwrap_zfparray(const Node &node); + +int CONDUIT_RELAY_API wrap_zfparray(const zfp::array* arr, + Node &node); + +} +//----------------------------------------------------------------------------- +// -- end conduit::relay::io -- +//----------------------------------------------------------------------------- + +} +//----------------------------------------------------------------------------- +// -- end conduit::relay -- +//----------------------------------------------------------------------------- + +} +//----------------------------------------------------------------------------- +// -- end conduit:: -- +//----------------------------------------------------------------------------- + + +#endif diff --git a/src/tests/blueprint/CMakeLists.txt b/src/tests/blueprint/CMakeLists.txt index 92557255d..2794601d3 100644 --- a/src/tests/blueprint/CMakeLists.txt +++ b/src/tests/blueprint/CMakeLists.txt @@ -88,4 +88,6 @@ else() message(STATUS "Fortran disabled: Skipping conduit blueprint fortran interface tests") endif() +message(STATUS "Adding blueprint lib Zfp unit tests") +add_cpp_test(TEST t_blueprint_zfp DEPENDS_ON conduit conduit_blueprint) diff --git a/src/tests/blueprint/t_blueprint_zfp.cpp b/src/tests/blueprint/t_blueprint_zfp.cpp new file mode 100644 index 000000000..0afd06a01 --- /dev/null +++ b/src/tests/blueprint/t_blueprint_zfp.cpp @@ -0,0 +1,188 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2019, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see https://lc.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: t_blueprint_zfp.cpp +/// +//----------------------------------------------------------------------------- + +#include "conduit.hpp" +#include "conduit_blueprint.hpp" + +#include +#include "gtest/gtest.h" + +using namespace conduit; + +// some CI do not have zfp available +// these tests look at dtypes and Npde entries, so contents don't matter + +void set_zfparray_node_entries(Node& result, uint8* header, size_t n_header, uint8* compressed_data, size_t n_compressed_data) { + result[blueprint::zfparray::ZFP_HEADER_FIELD_NAME].set(header, n_header); + result[blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME].set(compressed_data, n_compressed_data); +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_zfp, zfp_verify_valid_zfparray) +{ + size_t n_header = 4; + uint8 * header = new uint8[n_header](); + + size_t n_compressed_data = 4; + uint8 * compressed_data = new uint8[n_compressed_data](); + + Node result, info; + set_zfparray_node_entries(result, header, n_header, compressed_data, n_compressed_data); + + EXPECT_TRUE(blueprint::zfparray::verify(result, info)); + + delete [] header; + delete [] compressed_data; +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_zfp, zfp_verify_invalid_zfparray_without_header) +{ + size_t n_header = 4; + uint8 * header = new uint8[n_header](); + + size_t n_compressed_data = 4; + uint8 * compressed_data = new uint8[n_compressed_data](); + + Node result, info; + set_zfparray_node_entries(result, header, n_header, compressed_data, n_compressed_data); + + EXPECT_TRUE(blueprint::zfparray::verify(result, info)); + + // remove header node + EXPECT_TRUE(result.has_child(blueprint::zfparray::ZFP_HEADER_FIELD_NAME)); + result.remove(blueprint::zfparray::ZFP_HEADER_FIELD_NAME); + + EXPECT_FALSE(blueprint::zfparray::verify(result, info)); + + delete [] header; + delete [] compressed_data; +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_zfp, zfp_verify_invalid_zfparray_without_compressed_data) +{ + size_t n_header = 4; + uint8 * header = new uint8[n_header](); + + size_t n_compressed_data = 4; + uint8 * compressed_data = new uint8[n_compressed_data](); + + Node result, info; + set_zfparray_node_entries(result, header, n_header, compressed_data, n_compressed_data); + + EXPECT_TRUE(blueprint::zfparray::verify(result, info)); + + // remove compressed-data node + EXPECT_TRUE(result.has_child(blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME)); + result.remove(blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME); + + EXPECT_FALSE(blueprint::zfparray::verify(result, info)); + + delete [] header; + delete [] compressed_data; +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_zfp, zfp_verify_invalid_zfparray_with_incorrect_header_dtype) +{ + size_t n_header = 4; + uint8 * header = new uint8[n_header](); + + size_t n_compressed_data = 4; + uint8 * compressed_data = new uint8[n_compressed_data](); + + Node result, info; + set_zfparray_node_entries(result, header, n_header, compressed_data, n_compressed_data); + + EXPECT_TRUE(blueprint::zfparray::verify(result, info)); + + // remove header node + EXPECT_TRUE(result.has_child(blueprint::zfparray::ZFP_HEADER_FIELD_NAME)); + result.remove(blueprint::zfparray::ZFP_HEADER_FIELD_NAME); + + // re-add header node as a double + double dummy = 4.4; + result[blueprint::zfparray::ZFP_HEADER_FIELD_NAME] = dummy; + + EXPECT_FALSE(blueprint::zfparray::verify(result, info)); + + delete [] header; + delete [] compressed_data; +} + +//----------------------------------------------------------------------------- +TEST(conduit_blueprint_zfp, zfp_verify_invalid_zfparray_with_incorrect_compressed_data_dtype) +{ + size_t n_header = 4; + uint8 * header = new uint8[n_header](); + + size_t n_compressed_data = 4; + uint8 * compressed_data = new uint8[n_compressed_data](); + + Node result, info; + set_zfparray_node_entries(result, header, n_header, compressed_data, n_compressed_data); + + EXPECT_TRUE(blueprint::zfparray::verify(result, info)); + + // remove compressed-data node + EXPECT_TRUE(result.has_child(blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME)); + result.remove(blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME); + + // re-add compressed-data node as a double + double dummy = 4.4; + result[blueprint::zfparray::ZFP_COMPRESSED_DATA_FIELD_NAME] = dummy; + + EXPECT_FALSE(blueprint::zfparray::verify(result, info)); + + delete [] header; + delete [] compressed_data; +} + diff --git a/src/tests/relay/CMakeLists.txt b/src/tests/relay/CMakeLists.txt index fa5ae245c..2ea8e8907 100644 --- a/src/tests/relay/CMakeLists.txt +++ b/src/tests/relay/CMakeLists.txt @@ -69,6 +69,7 @@ set(RELAY_HDF5_TESTS t_relay_io_hdf5 set(RELAY_ADIOS_TESTS t_relay_io_adios) set(RELAY_MPI_ADIOS_TESTS t_relay_mpi_io_adios) +set(RELAY_ZFP_TESTS t_relay_zfp) ################################ # Add our main tests @@ -134,6 +135,16 @@ else() endif() +if(ZFP_FOUND) + message(STATUS "ZFP enabled: Adding conduit_relay_zfp unit tests") + foreach(TEST ${RELAY_ZFP_TESTS}) + add_cpp_test(TEST ${TEST} DEPENDS_ON conduit conduit_relay) + endforeach() +else() + message(STATUS "ZFP disabled: Skipping conduit_relay_zfp tests") +endif() + + ################################ # Add optional tests ################################ diff --git a/src/tests/relay/t_relay_zfp.cpp b/src/tests/relay/t_relay_zfp.cpp new file mode 100644 index 000000000..636a9d1e5 --- /dev/null +++ b/src/tests/relay/t_relay_zfp.cpp @@ -0,0 +1,300 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC. +// +// Produced at the Lawrence Livermore National Laboratory +// +// LLNL-CODE-666778 +// +// All rights reserved. +// +// This file is part of Conduit. +// +// For details, see: http://software.llnl.gov/conduit/. +// +// Please also read conduit/LICENSE +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the LLNS/LLNL nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, +// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +//----------------------------------------------------------------------------- +/// +/// file: t_relay_zfp.cpp +/// +//----------------------------------------------------------------------------- + +#include "conduit_relay.hpp" +#include "conduit_relay_zfp.hpp" +#include "gtest/gtest.h" +#include + +using namespace conduit; +using namespace conduit::relay; + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, wrap_zfparray_and_verify_header) +{ + // initialize empty result Node + Node result; + EXPECT_FALSE(result.has_child(io::ZFP_HEADER_FIELD_NAME)); + + // create compressed-array + uint nx = 9; + uint ny = 12; + double rate = 8.0; + zfp::array2f arr(nx, ny, rate); + + // write zfparray to Node + EXPECT_EQ(0, io::wrap_zfparray(&arr, result)); + + // verify header entry was set + EXPECT_TRUE(result.has_child(io::ZFP_HEADER_FIELD_NAME)); + Node n_header = result[io::ZFP_HEADER_FIELD_NAME]; + + // assert header dtype + EXPECT_TRUE(n_header.dtype().is_uint8()); + uint8_array header_as_arr = n_header.as_uint8_array(); + + // assert header length + zfp::array::header header = arr.get_header(); + EXPECT_EQ(sizeof(header), header_as_arr.number_of_elements()); + + // assert header contents + EXPECT_TRUE(0 == std::memcmp(header.buffer, n_header.data_ptr(), sizeof(header))); +} + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, wrap_zfparray_and_verify_compressed_data) +{ + // initialize empty result Node + Node result; + EXPECT_FALSE(result.has_child(io::ZFP_COMPRESSED_DATA_FIELD_NAME)); + + // create compressed-array + uint nx = 9; + uint ny = 12; + uint ntotal = nx * ny; + float * vals = new float[ntotal]; + uint i; + for (i = 0; i < ntotal; i++) { + vals[i] = i*i; + } + + double rate = 8.0; + zfp::array2f arr(nx, ny, rate, vals); + + // write zfparray to Node + EXPECT_EQ(0, io::wrap_zfparray(&arr, result)); + + // verify compressed data entry was set + EXPECT_TRUE(result.has_child(io::ZFP_COMPRESSED_DATA_FIELD_NAME)); + Node n_data = result[io::ZFP_COMPRESSED_DATA_FIELD_NAME]; + + EXPECT_TRUE(n_data.dtype().is_unsigned_integer()); + size_t compressed_data_num_words = arr.compressed_size() * CHAR_BIT / stream_word_bits; + + // compressed-data entry written with same uint type, having width `stream_word_bits` + switch(stream_word_bits) { + case 64: + EXPECT_TRUE(n_data.dtype().is_uint64()); + { + uint64_array data_as_arr = n_data.as_uint64_array(); + EXPECT_EQ(compressed_data_num_words, data_as_arr.number_of_elements()); + } + break; + + case 32: + EXPECT_TRUE(n_data.dtype().is_uint32()); + { + uint32_array data_as_arr = n_data.as_uint32_array(); + EXPECT_EQ(compressed_data_num_words, data_as_arr.number_of_elements()); + } + break; + + case 16: + EXPECT_TRUE(n_data.dtype().is_uint16()); + { + uint16_array data_as_arr = n_data.as_uint16_array(); + EXPECT_EQ(compressed_data_num_words, data_as_arr.number_of_elements()); + } + break; + + case 8: + EXPECT_TRUE(n_data.dtype().is_uint8()); + { + uint8_array data_as_arr = n_data.as_uint8_array(); + EXPECT_EQ(compressed_data_num_words, data_as_arr.number_of_elements()); + } + break; + + default: + FAIL() << "ZFP was compiled with an unrecognizable word type"; + break; + } + + delete [] vals; + + EXPECT_TRUE(0 == std::memcmp(arr.compressed_data(), n_data.data_ptr(), arr.compressed_size())); +} + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, wrap_zfparray_with_header_exception) +{ + // create compressed-array that does not support short header + uint nx = 9; + uint ny = 12; + uint nz = 5; + double rate = 64.0; + zfp::array3d arr(nx, ny, nz, rate); + + // write zfparray to Node, but expect failure + Node result; + EXPECT_EQ(1, io::wrap_zfparray(&arr, result)); +} + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, unwrap_zfparray) +{ + // create compressed-array + uint nx = 9; + uint ny = 12; + + float vals[nx * ny]; + uint i, j; + for (j = 0; j < ny; j++) { + for (i = 0; i < nx; i++) { + vals[nx*j + i] = i * 10. + j*j; + } + } + + double rate = 32.0; + zfp::array2f original_arr(nx, ny, rate, vals); + + // write zfparray to Node + Node result; + EXPECT_EQ(0, io::wrap_zfparray(&original_arr, result)); + + // fetch zfparray object from Node + zfp::array* fetched_arr = io::unwrap_zfparray(result); + + // verify against original_arr + ASSERT_TRUE(fetched_arr != 0); + + zfp::array2f* casted_arr = dynamic_cast(fetched_arr); + ASSERT_TRUE(casted_arr != 0); + + EXPECT_EQ(nx, casted_arr->size_x()); + EXPECT_EQ(ny, casted_arr->size_y()); + EXPECT_EQ(rate, casted_arr->rate()); + + // verify compressed data + EXPECT_EQ(original_arr.compressed_size(), casted_arr->compressed_size()); + EXPECT_TRUE(0 == std::memcmp(original_arr.compressed_data(), casted_arr->compressed_data(), original_arr.compressed_size())); + + delete fetched_arr; +} + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, unwrap_zfparray_with_exception) +{ + // create compressed-array + uint nx = 9; + uint ny = 12; + + double rate = 32.0; + zfp::array2f original_arr(nx, ny, rate); + + // write zfparray to Node + Node result; + EXPECT_EQ(0, io::wrap_zfparray(&original_arr, result)); + + // corrupt the Node's data + size_t n = 10; + float * vals = new float[n]; + for (size_t i = 0; i < n; i++) { + vals[i] = 0; + } + result[io::ZFP_HEADER_FIELD_NAME].set(vals, sizeof(vals)); + + // fetch zfparray object from Node + zfp::array* fetched_arr = io::unwrap_zfparray(result); + + // verify no instance returned + ASSERT_TRUE(fetched_arr == 0); + + delete [] vals; +} + +//----------------------------------------------------------------------------- +TEST(conduit_relay_zfp, unwrap_zfparray_with_compressed_data_dtype_mismatched_with_compiled_zfp_word_size) +{ + // create compressed-array + uint nx = 9; + uint ny = 12; + uint nz = 15; + + double rate = 16.0; + zfp::array3f arr(nx, ny, nz, rate); + + // write zfparray to Node + Node result; + EXPECT_EQ(0, relay::io::wrap_zfparray(&arr, result)); + + // remove compressed-data node + EXPECT_TRUE(result.has_child(io::ZFP_COMPRESSED_DATA_FIELD_NAME)); + result.remove(io::ZFP_COMPRESSED_DATA_FIELD_NAME); + + // re-add compressed-data node as the wrong type + switch(stream_word_bits) { + case 64: + case 32: + case 16: + { + conduit::uint8 data = 3; + result[io::ZFP_COMPRESSED_DATA_FIELD_NAME] = data; + } + break; + + case 8: + { + conduit::uint64 data = 3; + result[io::ZFP_COMPRESSED_DATA_FIELD_NAME] = data; + } + break; + + default: + FAIL() << "ZFP was compiled with an unrecognizable word type"; + } + + // fetch zfparray object from Node + zfp::array* fetched_arr = io::unwrap_zfparray(result); + + // verify no instance returned + ASSERT_TRUE(fetched_arr == 0); +} +