diff --git a/CMakeLists.txt b/CMakeLists.txt index d652fd39..8665ffbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,8 +244,7 @@ if(SERIALBOX_TESTING_GRIDTOOLS) set(SERIALBOX_HAS_GRIDTOOLS 1) endif(SERIALBOX_TESTING_GRIDTOOLS) -# If ${REQUIRED_BOOST_COMPONENTS} is empty we still need the headers -find_package(Boost 1.54 REQUIRED) +find_package(Boost 1.54 REQUIRED) # only Boost headers set(SERIALBOX_BOOST_VERSION ${Boost_VERSION}) #---------------------------------------- ClangTools ----------------------------------------------- diff --git a/cmake/SerialboxConfig.cmake.in b/cmake/SerialboxConfig.cmake.in index 55844db9..e35740ac 100644 --- a/cmake/SerialboxConfig.cmake.in +++ b/cmake/SerialboxConfig.cmake.in @@ -33,13 +33,6 @@ set(SERIALBOX_HAS_NETCDF "@SERIALBOX_USE_NETCDF@") # SERIALBOX was compiled with logging support (requires Boost.Log) set(SERIALBOX_HAS_LOGGING "@SERIALBOX_LOGGING@") -# Set Boost configuration -set(SERIALBOX_BOOST_LIB_VERSION "@Boost_LIB_VERSION@") -STRING(REGEX REPLACE "_" "." SERIALBOX_BOOST_VERSION ${SERIALBOX_BOOST_LIB_VERSION}) -set(SERIALBOX_BOOST_LIBRARY_DIRS "@Boost_LIBRARY_DIRS@") -set(SERIALBOX_BOOST_INCLUDE_DIRS "@Boost_INCLUDE_DIRS@") -set(SERIALBOX_REQUIRED_BOOST_COMPONENTS "@REQUIRED_BOOST_COMPONENTS@") - #===---------------------------------------------------------------------------------------------=== # Helper functions used in this file #====--------------------------------------------------------------------------------------------=== @@ -154,30 +147,13 @@ if(NOT(DEFINED SERIALBOX_NO_EXTERNAL_LIBS)) message( STATUS "Serialbox: find_dependency(Threads)" ) find_dependency(Threads) - set(BOOST_LIBRARYDIR "${SERIALBOX_BOOST_LIBRARY_DIRS}") - set(BOOST_INCLUDEDIR "${SERIALBOX_BOOST_INCLUDE_DIRS}") - set(Boost_NO_SYSTEM_PATHS "ON") # Force boost to search locations specified above - - message( STATUS "Serialbox: find_dependency(Boost ${SERIALBOX_BOOST_VERSION} COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS})") - find_dependency(Boost - ${SERIALBOX_BOOST_VERSION} COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS}) + message( STATUS "Serialbox: find_dependency(Boost ${SERIALBOX_BOOST_VERSION})") + find_dependency(Boost ${SERIALBOX_BOOST_VERSION}) if(Boost_FOUND) list(APPEND SERIALBOX_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) else() # Give some diagnostic infos set(WARN_STR "Serialbox: Boost (${SERIALBOX_BOOST_VERSION}) NOT found!") - - if(DEFINED Boost_LIB_VERSION) - string(REPLACE "_" "." FOUND_BOOST_VERSION ${Boost_LIB_VERSION}) - list(APPEND WARN_STR " (Found Boost ${FOUND_BOOST_VERSION})") - endif() - - list(APPEND WARN_STR "\nRequired components:") - - foreach(component ${SERIALBOX_REQUIRED_BOOST_COMPONENTS}) - list(APPEND WARN_STR "\n - ${component}") - endforeach() - message(WARNING ${WARN_STR} "\n") endif() diff --git a/docs/sphinx/Building.rst b/docs/sphinx/Building.rst index 1b18b0ae..d9fc920e 100644 --- a/docs/sphinx/Building.rst +++ b/docs/sphinx/Building.rst @@ -12,7 +12,7 @@ Serialbox relies on `CMake `_ (>= 3.1), a cross-platform Quick start =========== -To build Serialbox you need a C++17 toolchain, `CMake `_ and a fairly recent version of `Boost `_. We use here the command-line, non-interactive CMake interface. +To build Serialbox you need a C++17 toolchain, `CMake `_ and `Boost `_ headers. We use here the command-line, non-interactive CMake interface. #. Make sure you have installed all the tools and dependencies, especially Boost and CMake. See `Dependencies`_. diff --git a/docs/sphinx/C.rst b/docs/sphinx/C.rst index 5b7e62ff..70bbca63 100644 --- a/docs/sphinx/C.rst +++ b/docs/sphinx/C.rst @@ -30,7 +30,7 @@ Consider the following minimalistic example, ``test.c``, which simply creates an serialboxSerializerDestroy(serializer); } -To compile this sample program, you have to link against ``SerialboxC`` and the dependency libraries. The dependency libraries include the Boost libraries (filesystem, system, chrono, log, date_time, log_setup, thread, regex and atomic) as well as the NetCDF and OpenSSL libraries. However, if you choose to link dynamically (i.e against ``libSerialboxC.so``), the dependencies will be resolved automatically: +To compile this sample program, you have to link against ``SerialboxC`` and the dependency libraries. The dependency libraries include the NetCDF and OpenSSL libraries. However, if you choose to link dynamically (i.e against ``libSerialboxC.so``), the dependencies will be resolved automatically: .. code-block:: console @@ -39,4 +39,3 @@ To compile this sample program, you have to link against ``SerialboxC`` and the $ export LD_LIBRARY_PATH=$SERIALBOX_INSTALL_PATH/lib; ./test In general, it is **strongly** advised to use the CMake find_package-module of Serialbox which takes care of linking against the correct libraries (see :doc:`Usage`). - diff --git a/docs/sphinx/Fortran.rst b/docs/sphinx/Fortran.rst index 6bdacb83..64101898 100644 --- a/docs/sphinx/Fortran.rst +++ b/docs/sphinx/Fortran.rst @@ -28,7 +28,6 @@ The CMake build system of Serialbox takes care of setting the correct flags for Using the Fortran Interface =========================== -To use the Fortran interface in your project, you need to link against ``libSerialboxFortran`` and the C++ standard library used to compile the code (e.g ``libstdc++`` for GNU gcc) as well as the dependency libraries (Boost and possibly NetCDF and OpenSSL). As this can be tedious, Serialbox provides a CMake find_package module (:ref:`FindSerialbox`) to handle this task. +To use the Fortran interface in your project, you need to link against ``libSerialboxFortran`` and the C++ standard library used to compile the code (e.g ``libstdc++`` for GNU gcc) as well as the dependency libraries (possibly NetCDF and OpenSSL). As this can be tedious, Serialbox provides a CMake find_package module (:ref:`FindSerialbox`) to handle this task. To use the preprocessing script ``pp_ser.py``, take a look at the CMake module :ref:`SerialboxTooling`. For a self-contained example see ``examples/fortran/perturbation``. - diff --git a/docs/sphinx/Usage.rst b/docs/sphinx/Usage.rst index 962541a1..477ef024 100644 --- a/docs/sphinx/Usage.rst +++ b/docs/sphinx/Usage.rst @@ -32,9 +32,8 @@ Example to find Serialbox headers and `shared` libraries for the C, C++ and Fort set(SERIALBOX_USE_SHARED_LIBS ON) find_package(Serialbox REQUIRED COMPONENTS C++ C Fortran) -The Serialbox module will look for the `exact` boost version used during compilation and append -the necessary libraries to the ``SERIALBOX_[LANGUAGE]_LIBRARIES`` variable. If Serialbox was -compiled with OpenSSL and/or NetCDF support, the necessary libraries will be appended as well. +If Serialbox was compiled with OpenSSL and/or NetCDF support, +the necessary libraries will be appended to the ``SERIALBOX_[LANGUAGE]_LIBRARIES``. Variables used by this module, they can change the default behaviour and need to be set before calling find_package:: @@ -61,7 +60,6 @@ Variables defined by this module:: SERIALBOX_FORTRAN_LIBRARIES - The Fortran libraries of Serialbox (libSerialboxFortran) and possibly the external libraries. SERIALBOX_PPSER - Path to the pp_ser.py script. - SERIALBOX_BOOST_VERSION - Boost version used during compilation. SERIALBOX_HAS_OPENSSL - Serialbox was compiled with OpenSSL support. SERIALBOX_HAS_NETCDF - Serialbox was compiled with NetCDF support. @@ -78,4 +76,3 @@ Function arguments:: SOURCES - Sources to preprocess OUTPUT_DIR - Output directory of the the source files. If nothing is specified ${PROJECT_BINARY_DIR}/pp is used. - diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 40578881..1848643b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,6 @@ function(serialbox_add_gridtools_example NAME) SerialboxStatic GridTools::gridtools ${CMAKE_THREAD_LIBS_INIT}) - target_compile_definitions(${NAME} PUBLIC BOOST_NO_CXX11_DECLTYPE) install(TARGETS ${NAME} DESTINATION bin) if(SERIALBOX_TESTING) serialbox_add_test(TARGET ${NAME} EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}) @@ -53,7 +52,3 @@ endif() if(SERIALBOX_ENABLE_PYTHON) add_subdirectory(python) endif() - -if(SERIALBOX_TESTING_GRIDTOOLS) - add_subdirectory(gridtools) -endif() diff --git a/examples/gridtools/CMakeLists.txt b/examples/gridtools/CMakeLists.txt deleted file mode 100644 index 700cbe7e..00000000 --- a/examples/gridtools/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -##===------------------------------------------------------------------------------*- CMake -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===------------------------------------------------------------------------------------------===## - -cmake_minimum_required(VERSION 3.12) - -add_subdirectory(simple) - diff --git a/examples/gridtools/simple/CMakeLists.txt b/examples/gridtools/simple/CMakeLists.txt deleted file mode 100644 index f8fe5cc0..00000000 --- a/examples/gridtools/simple/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -##===------------------------------------------------------------------------------*- CMake -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===------------------------------------------------------------------------------------------===## - -cmake_minimum_required(VERSION 3.12) - -serialbox_add_gridtools_example(example-01-laplacian-cpp example-01-laplacian.cpp) -serialbox_add_gridtools_example(example-02-stateless-cpp example-02-stateless.cpp) -serialbox_add_gridtools_example(example-03-slice-cpp example-03-slice.cpp) - diff --git a/examples/gridtools/simple/example-01-laplacian.cpp b/examples/gridtools/simple/example-01-laplacian.cpp deleted file mode 100644 index 6a98b035..00000000 --- a/examples/gridtools/simple/example-01-laplacian.cpp +++ /dev/null @@ -1,335 +0,0 @@ -//===--------------------------------------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information. -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// This example demonstrates how to setup a Serializer, add global meta-information, register -/// fields and savepoints and serialize/deserialize gridtools storages using the gridtools frontend -/// of Serialbox. -/// -/// In this small example we will repeatedly apply a two dimensional laplacian stencil to an input -/// field `phi`. Before and after each invocation of the laplacian stencil, we will serialize the -/// data to disk. -/// -/// This example is also available in all other languages supported by Serialbox. -// -//===------------------------------------------------------------------------------------------===// - -// -// Include gridtools headers -// -#include -#include - -// -// Include Serialbox headers -// -#include "serialbox/gridtools/serialbox.hpp" - -#include -#include -#include - -static constexpr int N = 10; -static constexpr int M = 10; -static constexpr int halo_size = 1; - -// -// Typedefs of the gridtools library -// -using storage_traits_t = gridtools::storage_traits; -using backend_t = gridtools::backend; -using halo_t = gridtools::halo; -using storage_info_t = - storage_traits_t::special_storage_info_t<0, gridtools::selector<1, 1, 0>, halo_t>; -using storage_t = storage_traits_t::data_store_t; - -// -// Laplacian stage -// -struct laplacian_stage { - using lap = gridtools::inout_accessor<0>; - using phi = gridtools::in_accessor<1, gridtools::extent<-1, 1, -1, 1>>; - - using arg_list = boost::mpl::vector; - - template - GT_FUNCTION static void Do(Evaluation& eval) { - eval(lap()) = - eval(phi(1, 0)) + eval(phi(-1, 0)) + eval(phi(0, -1)) + eval(phi(0, 1)) - 4 * eval(phi()); - } -}; - -//===------------------------------------------------------------------------------------------===// -// write() -// -// In this function we first prepare the Serializer for writing, add some global meta-information -// and register the fields `phi` and `lap`. Later, we apply the `laplacianStencil` to `phi` and -// `lap` and serialize every iteration `phi` as an input and `lap` as an output of the stencil. -// -//===------------------------------------------------------------------------------------------===// -void write() { - // - // The gridtools frontend of Serialbox is confined in serialbox::gridtools - // - namespace ser = serialbox::gridtools; - - // - // Create a Serializer for writing. Besides the open-policy, we have to specify the `directory` - // in which the Serializer is created and the `prefix` of all files. In case the directory does - // not exist, it will be created. In addition, if the directory is not empty, all fields with the - // same `prefix` will be erased (this behaviour can be inhibited using the Append mode). - // - ser::serializer serializer(ser::open_mode::Write, "./laplacian/", "field"); - - // - // Allocate the 2D arrays phi and lap and fill it with some random numbers - // - storage_info_t storage_info(N, M, 1); - - std::default_random_engine gen; - std::uniform_real_distribution dist(0.0, 1.0); - - storage_t phi( - storage_info, [&](int i, int j, int k) { return dist(gen); }, "phi"); - storage_t lap(storage_info, -1., "lap"); - - // - // Create the field meta-information of `phi` directly with the gridtools storage and register it - // within the Serializer. For the gridtools interface this can also be done implicitly in the - // write method (see below). - // - ser::field_meta_info fieldmetainfo(phi); - serializer.register_field("phi", fieldmetainfo); - - // - // Add some global meta-information to the serializer. Besides the usual `key = value` pair, - // you can also add `key = {value1, ..., valueN}` pairs. - // - serializer.add_global_meta_info("answer", 42); - serializer.add_global_meta_info("halos", std::vector{1, 1, 1, 1}); - - // - // Up to this point nothing has been written to disk. Using update_meta_data() will force a write - // of all meta-information to the corresponding JSON files. Note that the meta-data is updated - // after each call and thus a manual update of the meta-data is seldom required. If you are - // curious you can inspect the files './laplacian/MetaData-field.json' and - // './laplacian/ArchiveMetaData-field.json' - // - serializer.update_meta_data(); - - // - // We now assemble the gridtools stencil - // - using p_lap = gridtools::arg<0, storage_t>; - using p_phi = gridtools::arg<1, storage_t>; - using arg_list = boost::mpl::vector; - - // Setup grid - gridtools::halo_descriptor di{halo_size, halo_size, halo_size, N - halo_size - 1, N}; - gridtools::halo_descriptor dj{halo_size, halo_size, halo_size, M - halo_size - 1, M}; - - // Make computation - auto laplacian_stencil = gridtools::make_computation( - gridtools::make_grid(di, dj, 1), (p_lap() = lap), (p_phi() = phi), - gridtools::make_multistage(gridtools::enumtype::execute(), - gridtools::make_stage(p_lap(), p_phi()))); - - // - // Now, we apply the `laplacian_stencil` three times to phi. In each iteration we will create - // an input and output savepoint where we save the current `phi` field (input) and `lap` field - // (output). - // - for(int t = 0; t < 3; ++t) { - // - // Create a Savepoint. Savepoints can have the same name as long as they have different - // meta-information. In our case we will always store the current time step `t` as a - // meta-information, thus making it unique. - // - ser::savepoint savepoint_in("laplacian-in"); - savepoint_in.meta_info().insert("time", t); - - // - // Register the Savepoint. - // - serializer.register_savepoint(savepoint_in); - - // - // Write phi to disk at our input savepoint. This will create the file `field_phi.dat` upon - // first invocation and afterwards the data is appended. - // - serializer.write("phi", savepoint_in, phi); - - // - // Apply the laplacian_stencil to phi - // - laplacian_stencil.run(); - - // - // Create the output savepoint. This time we directly initialize the meta-information of the - // savepoint. - // - ser::savepoint savepoint_out("laplacian-out", {{"time", ser::meta_info_value(t)}}); - - // - // Write lap to disk. Note that here we implicitly register the field `lap` upon first - // invocation. Same goes for the output savepoint. - // - serializer.write("lap", savepoint_out, lap); - - // - // Finally, we swap phi with lap (usually you want to use a gridtools::data_field for this - // task!) - // - auto lap_view = make_host_view(lap); - auto phi_view = make_host_view(phi); - for(int i = 0; i < N; ++i) - for(int j = 0; j < M; ++j) - std::swap(phi_view(i, j, 0), lap_view(i, j, 0)); - } -} - -template -std::string vec_to_string(VectorType&& vec) { - std::stringstream ss; - ss << "[ "; - for(auto it = vec.begin(), end = vec.end(); it != end; ++it) - ss << *it << " "; - ss << "]"; - return ss.str(); -} - -//===------------------------------------------------------------------------------------------===// -// read() -// -// In this function we initialize the Serializer for reading with our serialized data from the -// write() method. First, we query some meta-data, like the global meta-information, the -// dimensions of field `phi` or the vector of savepoints. -// Afterwards, we apply the same three time steps of the `laplacianStencil` to `phi` to compute -// `lap`. However, this time we compare the result (i.e the content of `lap`) to the reference -// loaded from disk (`lap_reference`) which we computed in the write() method. Obviously, the -// results will match as we apply the exact same stencil but in a real world scenario you might use -// a different implementations of the stencil and this is where Serialbox has it's use case. -// -//===------------------------------------------------------------------------------------------===// -void read() { - namespace ser = serialbox::gridtools; - - // - // Create a Serializer for reading. This gives access to the previously written data. - // - ser::serializer serializer(ser::open_mode::Read, "./laplacian/", "field"); - - // - // Access the global meta-information - // - std::cout << "The answer is " << serializer.global_meta_info().as("answer") << std::endl; - - std::vector halos = serializer.global_meta_info().as>("halos"); - std::cout << "The halo boundaries are " << vec_to_string(halos) << std::endl; - - // - // Access the field meta-information - // - std::vector fieldnames = serializer.fieldnames(); - std::cout << "The registered fields are: " << vec_to_string(fieldnames) << std::endl; - - const std::vector& dims_of_phi = serializer.get_field_meta_info("phi").dims(); - std::cout << "Dimensions of phi: " << vec_to_string(dims_of_phi) << std::endl; - - // - // Access the savepoints. The savepoints are ordered in the order they were inserted. - // - const std::vector& savepoints = serializer.savepoints(); - std::cout << "Savepoints:\n"; - for(std::size_t i = 0; i < savepoints.size(); ++i) - std::cout << " " << savepoints[i] << "\n"; - - // - // Allocate the 2D arrays phi and lap and assemble the gridtools stencil - // - storage_info_t meta_data(N, M, 1); - storage_t phi(meta_data, -1., "phi"); - storage_t lap(meta_data, -1., "lap"); - storage_t lap_reference(meta_data, -1., "lap_reference"); - - using p_lap = gridtools::arg<0, storage_t>; - using p_phi = gridtools::arg<1, storage_t>; - using arg_list = boost::mpl::vector; - - // Setup grid - gridtools::halo_descriptor di = {halo_size, halo_size, halo_size, N - halo_size - 1, N}; - gridtools::halo_descriptor dj = {halo_size, halo_size, halo_size, M - halo_size - 1, M}; - - // Make computation - auto laplacian_stencil = gridtools::make_computation( - gridtools::make_grid(di, dj, 1), (p_lap() = lap), (p_phi() = phi), - gridtools::make_multistage(gridtools::enumtype::execute(), - gridtools::make_stage(p_lap(), p_phi()))); - // - // We will now perform the same iterations as in the write method but this time we will read - // phi as an input from disk, compute the laplacian and compare the result to the stored output - // of lap on disk (loaded as `lap_refrence`). - // - for(int t = 0; t < 3; ++t) { - // - // Get the current input savepoint at time t (the factor of 2 is due to the fact that we - // stored input and output in alternating order). - // - const ser::savepoint& savepoint_in = savepoints[2 * t]; - - // - // Load phi from disk. - // - serializer.read("phi", savepoint_in, phi); - - // - // Apply the laplacian_stencil to phi - // - laplacian_stencil.run(); - - // - // Load the refrence output of lap ... - // - const ser::savepoint& savepoint_out = savepoints[2 * t + 1]; - serializer.read("lap", savepoint_out, lap_reference); - - // - // ... and compare the results. - // - auto lap_view = make_host_view(lap); - auto lap_reference_view = make_host_view(lap_reference); - for(int i = 1; i < N - 1; ++i) - for(int j = 1; j < M - 1; ++j) - if(lap_view(i, j, 0) != lap_reference_view(i, j, 0)) - throw ser::exception("mismatch at (%i,%i) of lap and lap_reference: %f vs. %f\n", i, j, - lap_view(i, j, 0), lap_reference_view(i, j, 0)); - } -} - -//===------------------------------------------------------------------------------------------===// -// main() -// -// Here we call our write() and read() functions. -// -//===------------------------------------------------------------------------------------------===// -int main() { - try { - // Write some data ... - write(); - - // ... and read it. - read(); - - } catch(std::exception& e) { - std::cerr << "Errror: " << e.what() << std::endl; - return 1; - } - return 0; -} diff --git a/examples/gridtools/simple/example-02-stateless.cpp b/examples/gridtools/simple/example-02-stateless.cpp deleted file mode 100644 index 94790d4d..00000000 --- a/examples/gridtools/simple/example-02-stateless.cpp +++ /dev/null @@ -1,97 +0,0 @@ -//===--------------------------------------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information. -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// This example demonstrates how to use stateless serializations i.e serialize fields without the -/// need to register fields or savpoints. In addition, the usage of the logging infrastructure -/// is exemplified. -/// -/// This example is also available in all other languages supported by Serialbox. -// -//===------------------------------------------------------------------------------------------===// - -// -// Include gridtools headers -// -#include - -// -// Include Serialbox headers -// -#include "serialbox/gridtools/serialbox.hpp" - -#include -#include -#include - -// -// Typedefs of the gridtools library -// -using storage_traits_t = gridtools::storage_traits; -using storage_info_t = storage_traits_t::storage_info_t<0, 3>; -using storage_t = storage_traits_t::data_store_t; - -int main() { - int N = 10, M = 15, K = 20; - try { - - // - // The gridtools frontend of Serialbox is confined in serialbox::gridtools - // - namespace ser = serialbox::gridtools; - - // - // Enable logging, by default it is turned off - // - ser::logging::enable(); - - // - // Allocate 3D arrays and fill the input with some random numbers - // - storage_info_t storage_info(N, M, K); - - std::default_random_engine gen; - std::uniform_real_distribution dist(0.0, 1.0); - - storage_t field_in( - storage_info, [&](int i, int j, int k) { return dist(gen); }, "storage"); - storage_t field_out(storage_info, -1., "storage"); - - // - // Write the gridtools storage to disk. The archive will be deduced from the file extension - // (here ".dat" implies the Binary archive). The written data can know also be read in C, Python - // and Fortran. - // - ser::serializer::to_file("field.dat", field_in); - - // - // Read the written field from file (note that this method performs no consistency checks so you - // have to know what you are doing!). - // - ser::serializer::from_file("field.dat", field_out); - - // - // Verify the result - // - { - auto in = make_host_view(field_in); - auto out = make_host_view(field_out); - for(int i = 0; i < N; ++i) - for(int j = 0; j < M; ++j) - for(int k = 0; k < K; ++k) - if(in(i, j, k) != out(i, j, k)) - throw ser::exception("mismatch at (%i,%i) of in and out: %f vs. %f\n", i, j, - in(i, j, k), out(i, j, k)); - } - } catch(std::exception& e) { - std::cerr << "Errror: " << e.what() << std::endl; - return 1; - } - return 0; -} diff --git a/examples/gridtools/simple/example-03-slice.cpp b/examples/gridtools/simple/example-03-slice.cpp deleted file mode 100644 index 8445b232..00000000 --- a/examples/gridtools/simple/example-03-slice.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//===--------------------------------------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information. -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// This example demonstrates how to only load parts (slices) of a serialized field. This can -/// significantly improve performance if one is only interested in a small part of the data. -/// -/// This example is also available in all other languages supported by Serialbox. -// -//===------------------------------------------------------------------------------------------===// - -// -// Include gridtools headers -// -#include - -// -// Include Serialbox headers -// -#include "serialbox/gridtools/serialbox.hpp" - -#include -#include -#include -#include - -// -// Typedefs of the gridtools library -// -using storage_traits_t = gridtools::storage_traits; -using storage_info_t = storage_traits_t::storage_info_t<0, 3>; -using storage_t = storage_traits_t::data_store_t; - -int main() { - int N = 512, M = 512, K = 80; - try { - - // - // The gridtools frontend of Serialbox is confined in serialbox::gridtools - // - namespace ser = serialbox::gridtools; - - // - // Initialize the serializer. At the moment sliced loading is only supported by the Binary - // archive - // - ser::serializer serializer_write(ser::open_mode::Write, "./slice", "field", "Binary"); - - // - // Allocate 3D arrays and fill the input with some random numbers - // - storage_info_t storage_info(N, M, K); - - std::default_random_engine gen; - std::uniform_real_distribution dist(0.0, 1.0); - - storage_t field_in( - storage_info, [&](int i, int j, int k) { return dist(gen); }, "storage"); - storage_t field_out(storage_info, -1., "storage"); - - // - // Write the gridtools storage to disk at Savepoint `sp` - // - ser::timer t; - - auto savepoint = ser::savepoint("sp"); - serializer_write.write("field", savepoint, field_in); - - std::printf("serializer.write : %8.2f ms\n", t.stop()); - - // - // Initialize a serializer for reading. - // - ser::serializer serializer_read(ser::open_mode::Read, "./slice", "field", "Binary"); - - // - // Assume we are only interested in a certain layer of the data (k = 50), we can use the slice - // object (ser::slice) to encode this information and instruct the serializer to only load - // the desired data. Note that you still need to allocate memory for the whole field. - // The syntax for slicing follows closely the slicing syntax used in Python, the equivalent of - // `[start1:stop1:step1, ... ,startN:stopN:stepN]` is - // `slice(start1, stop1, step1) ... (startN, stopN, stepN)`. In python we used: - // `serializer_read.read_slice('field', savepoint, ser.Slice[:, :, 50], field_out)` which is - // equivalent to ... - // - t.start(); - - serializer_read.read_slice("field", savepoint, field_out, ser::slice()()(50, 51)); - - std::printf("serializer.read_slice : %8.2f ms\n", t.stop()); - - // - // Verify - // - { - auto in = make_host_view(field_in); - auto out = make_host_view(field_out); - for(int i = 0; i < N; ++i) - for(int j = 0; j < M; ++j) - if(in(i, j, 50) != out(i, j, 50)) - throw ser::exception("mismatch at (%i,%i) of in and out: %f vs. %f\n", i, j, - in(i, j, 50), out(i, j, 50)); - } - - // - // For comparison, let's load the full data. - // - t.start(); - - serializer_read.read("field", savepoint, field_out); - - std::printf("serializer.read : %8.2f ms\n", t.stop()); - - // - // Verify - // - { - auto in = make_host_view(field_in); - auto out = make_host_view(field_out); - for(int i = 0; i < N; ++i) - for(int j = 0; j < M; ++j) - if(in(i, j, 50) != out(i, j, 50)) - throw ser::exception("mismatch at (%i,%i) of in and out: %f vs. %f\n", i, j, - in(i, j, 50), out(i, j, 50)); - } - - // - // Remove directory - // - serialbox::remove_all("./slice"); - - } catch(std::exception& e) { - std::cerr << "Errror: " << e.what() << std::endl; - return 1; - } - return 0; -} diff --git a/examples/gridtools/smagorinsky/.gitignore b/examples/gridtools/smagorinsky/.gitignore deleted file mode 100644 index a007feab..00000000 --- a/examples/gridtools/smagorinsky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/* diff --git a/examples/gridtools/smagorinsky/CMakeLists.txt b/examples/gridtools/smagorinsky/CMakeLists.txt deleted file mode 100644 index 514e1696..00000000 --- a/examples/gridtools/smagorinsky/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -##===------------------------------------------------------------------------------*- CMake -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===------------------------------------------------------------------------------------------===## - -cmake_minimum_required(VERSION 3.12) - -project(SerialboxSmagorinskyExample CXX) - -# -# We use the Serialbox which was installed in install/. If this folder does not exists, or is empty, -# you have to build and install Serialbox first. To tell CMake where Serialbox is located, you have -# to define SERIALBOX_ROOT (either directly in CMake or pass it as -DSERIALBOX_ROOT=<> via -# command-line). -# -if(NOT(DEFINED SERIALBOX_ROOT)) - set(SERIALBOX_ROOT "${PROJECT_SOURCE_DIR}/../../../install") -endif() - -# -# Serialbox has a find_package-module which takes care of looking for the dependency libraries. -# Usually you want to bundle this module with your own project and therefore we copied it into -# "cmake/". We need to tell CMake about this. -# -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") - -# -# We call the find_package-module of Serialbox and gridtools and set the include directories -# -find_package(Serialbox REQUIRED HINTS - "${CMAKE_CURRENT_LIST_DIR}/../serialbox/install/cmake" - "${SERIALBOX_ROOT}/cmake" - "${SERIALBOX_DIR}/cmake" - "$ENV{SERIALBOX_ROOT}/cmake") - -find_package(GridTools REQUIRED) - -include_directories(SYSTEM ${SERIALBOX_INCLUDE_DIRS}) -include_directories(SYSTEM ${GRIDTOOLS_INCLUDE_DIRS}) - -# -# Serialbox requires C++17 -# -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - -# -# Don't use Debug symbols, gcc takes to long otherwise ;) -# -string(REPLACE "-g" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - -# -# Finally, we add the executables and link against the Serialbox libraries -# -add_executable(smagorinsky smagorinsky.cpp smagorinsky_stencil.hpp smagorinsky_repository.hpp) -target_link_libraries(smagorinsky ${SERIALBOX_CXX_LIBRARIES}) - -add_executable(smagorinsky-error smagorinsky.cpp smagorinsky_stencil.hpp smagorinsky_repository.hpp) -target_compile_definitions(smagorinsky-error PUBLIC -DERROR) -target_link_libraries(smagorinsky-error ${SERIALBOX_CXX_LIBRARIES}) - diff --git a/examples/gridtools/smagorinsky/cmake/FindGridTools.cmake b/examples/gridtools/smagorinsky/cmake/FindGridTools.cmake deleted file mode 100644 index 42c8dac5..00000000 --- a/examples/gridtools/smagorinsky/cmake/FindGridTools.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# Try to find GridTools libraries and headers. -# -# Usage of this module as follows: -# -# find_package(GridTools) -# -# Variables used by this module, they can change the default behaviour and need -# to be set before calling find_package: -# -# GRIDTOOLS_ROOT Set this variable to the root installation of -# GridTools if the module has problems finding the -# proper installation path. -# -# Variables defined by this module: -# -# GRIDTOOLS_FOUND System has GridTools libraries and headers -# GRIDTOOLS_INCLUDE_DIRS The location of GridTools headers - -find_path(GRIDTOOLS_ROOT NAMES include/gridtools.hpp) - -# Look for GridTools headers -find_path(GRIDTOOLS_INCLUDE_DIRS - NAMES gridtools.hpp - HINTS ${GRIDTOOLS_ROOT}/include - $ENV{GRIDTOOLS_ROOT}/include -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GRIDTOOLS DEFAULT_MSG GRIDTOOLS_INCLUDE_DIRS) - -if(GRIDTOOLS_FOUND) - mark_as_advanced(GRIDTOOLS_INCLUDE_DIRS) -else() - # If the package was required we abort the process - if(${GridTools_FIND_REQUIRED}) - message(FATAL_ERROR "Could NOT find GRIDTOOLS. (Try setting GRIDTOOLS_ROOT in the env)") - endif(${GridTools_FIND_REQUIRED}) -endif() - diff --git a/examples/gridtools/smagorinsky/smagorinsky.cpp b/examples/gridtools/smagorinsky/smagorinsky.cpp deleted file mode 100644 index 30f9fa20..00000000 --- a/examples/gridtools/smagorinsky/smagorinsky.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===-- smagorinsky.cpp -------------------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// This file calls the Smagorinsky horizontal-diffusion stencil with serialized data and uses the -/// fine-grained deserialization of gridtools for further preprocessing with sdb. -/// -//===------------------------------------------------------------------------------------------===// - -#include "smagorinsky_repository.hpp" -#include "smagorinsky_stencil.hpp" - -#include -#include - -namespace { -#ifdef ERROR -const char* output_dir = "./smagorinsky-stencil-error"; -#else -const char* output_dir = "./smagorinsky-stencil"; -#endif -} - -int main() { - // - // Allocate & initialize fields - // - - auto repo = smagorinsky::repository(33, 28, 80); - repo.init_fields(); - - try { - - // - // Setup serializer - // - serialbox::gridtools::serializer serializer(serialbox::gridtools::open_mode::Write, output_dir, - "stencil"); - - // - // Run & serialize smagorinsky stencil - // - - smagorinsky::run_stencil(repo, serializer, 3); - - } catch(std::exception& e) { - std::cerr << "Error: " << e.what() << std::endl; - return 1; - } - - std::cout << "Successfully ran Smagorinsky stencil!" << std::endl; - return 0; -} diff --git a/examples/gridtools/smagorinsky/smagorinsky_repository.hpp b/examples/gridtools/smagorinsky/smagorinsky_repository.hpp deleted file mode 100644 index 2047bef1..00000000 --- a/examples/gridtools/smagorinsky/smagorinsky_repository.hpp +++ /dev/null @@ -1,170 +0,0 @@ -//===-- smagorinsky_repository.hpp --------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// Allocate and initialize the gridtools storages with serialized data. -/// -//===------------------------------------------------------------------------------------------===// - -#pragma once - -#define CXX11_ENABLED -#define STRUCTURED_GRIDS -#include -#include -#include -#include - -#include -#include - -namespace smagorinsky { - -// Fine-grained serialization is only supported by the Naive Host backend at the moment. -using backend = gridtools::backend; - -/// @brief Axis of the Grid including the entire vertical domain -using axis_t = gridtools::interval, gridtools::level<1, 3>>; - -/// \brief All layers, meaning [0, k) -using full_domain_t = gridtools::interval, gridtools::level<1, -1>>; - -/// \brief Repository of the storages of the smagorinsky stencil -class repository { -public: - static constexpr int halo_size = 3; - - /// \brief Floating point type - using float_type = gridtools::float_type; - - /// \brief Horizontal halo - using halo_ijk_t = gridtools::halo<3, 3, 0>; - using halo_j_t = gridtools::halo<0, 3, 0>; - - /// \brief Layout types - /// @{ - using layout_ijk_t = gridtools::layout_map<0, 1, 2>; - using layout_j_t = gridtools::layout_map<-1, 0, -1>; - using layout_scalar_t = gridtools::layout_map<-1, -1, -1>; - /// @} - - /// \brief Meta-data types - /// @{ - using metadata_ijk_t = backend::storage_info<0, layout_ijk_t, halo_ijk_t>; - using metadata_j_t = backend::storage_info<1, layout_j_t, halo_j_t>; - using metadata_scalar_t = backend::storage_info<2, layout_scalar_t>; - /// @} - - /// \brief Storage types - /// @{ - using storage_ijk_t = backend::storage_type::type; - using storage_ijk_tmp_t = backend::temporary_storage_type::type; - using storage_j_t = backend::storage_type::type; - using storage_scalar_t = backend::storage_type::type; - - /// \brief Allocate the storages - repository(int i, int j, int k) - : isize_(i + 2 * halo_size), jsize_(j + 2 * halo_size), ksize_(k), - - metadata_scalar_(1, 1, 1), metadata_j_(1, jsize_, 1), metadata_ijk_(isize_, jsize_, ksize_), - - // Output fields - u_out_(metadata_ijk_, -1.0, "u_out"), v_out_(metadata_ijk_, -1.0, "v_out"), - - // Input fields - u_in_(metadata_ijk_, -1.0, "u_in"), v_in_(metadata_ijk_, -1.0, "v_in"), - hdmaskvel_(metadata_ijk_, -1.0, "hdmaskvel"), - - crlavo_(metadata_j_, -1.0, "crlavo"), crlavu_(metadata_j_, -1.0, "crlavu"), - crlato_(metadata_j_, -1.0, "crlato"), crlatu_(metadata_j_, -1.0, "crlatu"), - acrlat0_(metadata_j_, -1.0, "acrlat0"), - - // Scalar fields - eddlon_(metadata_scalar_, -1.0, "eddlon"), eddlat_(metadata_scalar_, -1.0, "eddlat"), - tau_smag_(metadata_scalar_, -1.0, "tau_smag"), - weight_smag_(metadata_scalar_, -1.0, "weight_smag") {} - - /// \brief Getter - /// @{ - storage_ijk_t& u_out() { return u_out_; } - storage_ijk_t& v_out() { return v_out_; } - - storage_ijk_t& u_in() { return u_in_; } - storage_ijk_t& v_in() { return v_in_; } - storage_ijk_t& hdmaskvel() { return hdmaskvel_; } - - storage_j_t& crlavo() { return crlavo_; } - storage_j_t& crlavu() { return crlavu_; } - storage_j_t& crlato() { return crlato_; } - storage_j_t& crlatu() { return crlatu_; } - storage_j_t& acrlat0() { return acrlat0_; } - - storage_scalar_t& eddlon() { return eddlon_; } - storage_scalar_t& eddlat() { return eddlat_; } - storage_scalar_t& tau_smag() { return tau_smag_; } - storage_scalar_t& weight_smag() { return weight_smag_; } - /// @} - - gridtools::uint_t isize() const { return isize_; } - gridtools::uint_t jsize() const { return jsize_; } - gridtools::uint_t ksize() const { return ksize_; } - - /// \brief Load input data - void init_fields() { - - std::cout << "Initializing storages ..." << std::endl; - - std::default_random_engine generator; - std::uniform_real_distribution distribution(0.0, 1.0); - - for(int i = 0; i < isize_; i++) - for(int j = 0; j < jsize_; j++) - for(int k = 0; k < ksize_; k++) { - u_out_(i, j, k) = distribution(generator); - v_out_(i, j, k) = distribution(generator); - u_in_(i, j, k) = distribution(generator); - v_in_(i, j, k) = distribution(generator); - hdmaskvel_(i, j, k) = distribution(generator); - } - - for(int j = 0; j < jsize_; j++) { - crlavo_(0, j, 0) = distribution(generator); - crlavu_(0, j, 0) = distribution(generator); - crlato_(0, j, 0) = distribution(generator); - crlatu_(0, j, 0) = distribution(generator); - acrlat0_(0, j, 0) = distribution(generator); - } - - eddlon_(0, 0, 0) = distribution(generator); - eddlat_(0, 0, 0) = distribution(generator); - tau_smag_(0, 0, 0) = distribution(generator); - weight_smag_(0, 0, 0) = distribution(generator); - } - -private: - gridtools::uint_t isize_, jsize_, ksize_; - - // Meta-data - metadata_scalar_t metadata_scalar_; - metadata_j_t metadata_j_; - metadata_ijk_t metadata_ijk_; - - // Output fields - storage_ijk_t u_out_, v_out_; - - // Input fields - storage_ijk_t u_in_, v_in_, hdmaskvel_; - storage_j_t crlavo_, crlavu_, crlato_, crlatu_, acrlat0_; - - // Scalar fields - storage_scalar_t eddlon_, eddlat_, tau_smag_, weight_smag_; -}; - -} // smagorinsky diff --git a/examples/gridtools/smagorinsky/smagorinsky_stencil.hpp b/examples/gridtools/smagorinsky/smagorinsky_stencil.hpp deleted file mode 100644 index e551cfcf..00000000 --- a/examples/gridtools/smagorinsky/smagorinsky_stencil.hpp +++ /dev/null @@ -1,291 +0,0 @@ -//===-- smagorinsky_stencil.hpp -----------------------------------------------------*- C++ -*-===// -// -// S E R I A L B O X -// -// This file is distributed under terms of BSD license. -// See LICENSE.txt for more information -// -//===------------------------------------------------------------------------------------------===// -// -/// \file -/// Define Smagorinsky horizontal diffusion stencil. -/// -//===------------------------------------------------------------------------------------------===// - -#pragma once - -#include "smagorinsky_repository.hpp" -#include - -namespace smagorinsky { - -using namespace gridtools; -using namespace gridtools::enumtype; -using namespace gridtools::expressions; - -constexpr static gridtools::dimension<1> i; -constexpr static gridtools::dimension<2> j; -constexpr static gridtools::dimension<3> k; - -namespace math { -using std::min; -using std::max; -using std::sqrt; -} - -//===------------------------------------------------------------------------------------------===// -// Stage 1 - TensionShearStage -//===------------------------------------------------------------------------------------------===// - -/// \brief Compute the tension and shear used for the Smagorinsky diffusion -struct tension_shear_stage { - using T_sqr_s = inout_accessor<0>; - using S_sqr_uv = inout_accessor<1>; - - using acrlat0 = in_accessor<2>; - using eddlon = in_accessor<3>; - using eddlat = in_accessor<4>; - using u_in = in_accessor<5, extent<-1, 0, 0, 1>>; - using v_in = in_accessor<6, extent<0, 1, -1, 0>>; - - using arg_list = boost::mpl::vector; - - template - GT_FUNCTION static void Do(const Evaluation& eval, full_domain_t) { - const float_type frac_1_dx = eval(acrlat0(i, j, k) * eddlon(i, j, k)); - const float_type frac_1_dy = eval(eddlat(i, j, k)) / float_type(6371.229e3); - - // Tension - const float_type T_s = eval(v_in(i, j - 1, k) - v_in(i, j, k)) * frac_1_dy - - eval(u_in(i - 1, j, k) - u_in(i, j, k)) * frac_1_dx; - eval(T_sqr_s()) = T_s * T_s; - - // Shear - const float_type S_uv = eval(u_in(i, j + 1, k) - u_in(i, j, k)) * frac_1_dy + - eval(v_in(i + 1, j, k) - v_in(i, j, k)) * frac_1_dx; - eval(S_sqr_uv()) = S_uv * S_uv; - } -}; - -//===------------------------------------------------------------------------------------------===// -// Stage 2 - SmagCoeffStage -//===------------------------------------------------------------------------------------------===// - -/// \brief Stage computing the coefficients for the Smagorinsky diffusion -struct smag_coeff_stage { - using smag_u = inout_accessor<0>; - using smag_v = inout_accessor<1>; - - using T_sqr_s = in_accessor<2, extent<0, 1, 0, 1>>; - using S_sqr_uv = in_accessor<3, extent<-1, 0, -1, 0>>; - using hdmaskvel = in_accessor<4>; - using tau_smag = in_accessor<5>; - using weight_smag = in_accessor<6>; - - using arg_list = - boost::mpl::vector; - - template - GT_FUNCTION static void Do(const Evaluation& eval, full_domain_t) { - const float_type hdweight = eval(weight_smag(i, j, k) * hdmaskvel(i, j, k)); - - // i-direction - const float_type smag_u_ = - eval(tau_smag(i, j, k)) * - math::sqrt((float_type)0.5 * (eval(T_sqr_s(i, j, k) + T_sqr_s(i + 1, j, k) + - S_sqr_uv(i, j, k) + S_sqr_uv(i, j - 1, k)))) - - hdweight; - - eval(smag_u()) = math::min((float_type)0.5, math::max((float_type)0.0, smag_u_)); - -// j-direction -#ifdef ERROR - const float_type smag_v_ = - eval(tau_smag(i, j, k)) * - math::sqrt((float_type)0.5 * (eval(T_sqr_s(i, j, k) + T_sqr_s(i, j + 1, k) + - S_sqr_uv(i, j, k) + S_sqr_uv(i - 1, j, k)))) + // <-- - hdweight; -#else - const float_type smag_v_ = - eval(tau_smag(i, j, k)) * - math::sqrt((float_type)0.5 * (eval(T_sqr_s(i, j, k) + T_sqr_s(i, j + 1, k) + - S_sqr_uv(i, j, k) + S_sqr_uv(i - 1, j, k)))) - - hdweight; -#endif - - eval(smag_v()) = math::min((float_type)0.5, math::max((float_type)0.0, smag_v_)); - } -}; - -//===------------------------------------------------------------------------------------------===// -// Stage 3 - SmagUpdateStage -//===------------------------------------------------------------------------------------------===// - -/// \brief Function computing the the Laplacian of an input array -struct laplacian { - using lap = inout_accessor<0>; - using in = in_accessor<1, extent<-1, 1, -1, 1>>; - using crlato = in_accessor<2>; - using crlatu = in_accessor<3>; - - using arg_list = boost::mpl::vector; - - template - GT_FUNCTION static void Do(const Evaluation& eval, full_domain_t) { - eval(lap()) = eval(in(i + 1, j, k)) + eval(in(i - 1, j, k)) - - (float_type)2.0 * eval(in(i, j, k)) + - eval(crlato(i, j) * (in(i, j + 1, k) - in(i, j, k))) + - eval(crlatu(i, j) * (in(i, j - 1, k) - in(i, j, k))); - } -}; - -/// \brief Stage updating the horizontal velocities using the Smagorinsy coefficients -struct smag_update_stage { - using u_out = inout_accessor<0>; - using v_out = inout_accessor<1>; - - using u_in = in_accessor<2, extent<-1, 1, -1, 1>>; - using v_in = in_accessor<3, extent<-1, 1, -1, 1>>; - using smag_u = in_accessor<4>; - using smag_v = in_accessor<5>; - using crlato = in_accessor<6>; - using crlatu = in_accessor<7>; - using crlavo = in_accessor<8>; - using crlavu = in_accessor<9>; - - using arg_list = - boost::mpl::vector; - - template - GT_FUNCTION static void Do(const Evaluation& eval, full_domain_t) { - const float_type lapu = - call::at<0, 0, 0>::with(eval, u_in(), crlato(), crlatu()); - - const float_type lapv = - call::at<0, 0, 0>::with(eval, v_in(), crlavo(), crlavu()); - - eval(u_out()) = eval(u_in(i, j, k)) + eval(smag_u(i, j, k)) * lapu; - eval(v_out()) = eval(v_in(i, j, k)) - eval(smag_v(i, j, k)) * lapv; - } -}; - -//===------------------------------------------------------------------------------------------===// -// Stencil -//===------------------------------------------------------------------------------------------===// - -/// \brief Smagorninsky stencil -template -void run_stencil(repository& repo, SerializerType& serializer, int invocation_count = 1) { - - // - // Argument list - // - - // Temporaries - using T_sqr_s = arg<0, repository::storage_ijk_tmp_t>; - using S_sqr_uv = arg<1, repository::storage_ijk_tmp_t>; - using smag_u = arg<2, repository::storage_ijk_tmp_t>; - using smag_v = arg<3, repository::storage_ijk_tmp_t>; - - // Output fields - using u_out = arg<4, repository::storage_ijk_t>; - using v_out = arg<5, repository::storage_ijk_t>; - - // Input fields - using u_in = arg<6, repository::storage_ijk_t>; - using v_in = arg<7, repository::storage_ijk_t>; - using hdmaskvel = arg<8, repository::storage_ijk_t>; - using crlavo = arg<9, repository::storage_j_t>; - using crlavu = arg<10, repository::storage_j_t>; - using crlato = arg<11, repository::storage_j_t>; - using crlatu = arg<12, repository::storage_j_t>; - using acrlat0 = arg<13, repository::storage_j_t>; - - // Scalar fields - using eddlon = arg<14, repository::storage_scalar_t>; - using eddlat = arg<15, repository::storage_scalar_t>; - using tau_smag = arg<16, repository::storage_scalar_t>; - using weight_smag = arg<17, repository::storage_scalar_t>; - - using arg_list = boost::mpl::vector< - // Temporaries - T_sqr_s, S_sqr_uv, smag_u, smag_v, - - // Output fields - u_out, v_out, - - // Input fields - u_in, v_in, hdmaskvel, crlavo, crlavu, crlato, crlatu, acrlat0, - - // Scalar fields - eddlon, eddlat, tau_smag, weight_smag>; - - // - // Domain - // - - auto domain = aggregator_type(boost::fusion::make_vector( - // Output fields - &repo.u_out(), &repo.v_out(), - - // Input fields - &repo.u_in(), &repo.v_in(), &repo.hdmaskvel(), &repo.crlavo(), &repo.crlavu(), &repo.crlato(), - &repo.crlatu(), &repo.acrlat0(), - - // Scalar fields - &repo.eddlon(), &repo.eddlat(), &repo.tau_smag(), &repo.weight_smag())); - - // - // Grid - // - - const int halo_size = 3; - - // minus, plus, begin, end, length - uint_t di[5] = {halo_size, halo_size, halo_size, repo.isize() - halo_size - 2, - repo.isize() - 2 * halo_size}; - uint_t dj[5] = {halo_size, halo_size, halo_size, repo.jsize() - halo_size - 2, - repo.jsize() - 2 * halo_size}; - - gridtools::grid grid(di, dj); - grid.value_list[0] = 0; - grid.value_list[1] = repo.ksize() - 1; - - // - // Computation - // - - auto computation = make_computation( - domain, grid, - make_multistage(execute(), - - // 1. Stage - Tension shear - make_stage(T_sqr_s(), S_sqr_uv(), acrlat0(), eddlon(), - eddlat(), u_in(), v_in()), - - // 2. Stage - Smagorinsky coefficient - make_stage(smag_u(), smag_v(), T_sqr_s(), S_sqr_uv(), - hdmaskvel(), tau_smag(), weight_smag()), - - // 3. Stage - Update output variable - make_stage(u_out(), v_out(), u_in(), v_in(), smag_u(), - smag_v(), crlato(), crlatu(), crlavo(), - crlavu()))); - - // - // Run stencil - // - - computation->ready(); - computation->steady(); - - std::cout << "Running smagorinsky stencil ... " << std::endl; - for(int i = 0; i < invocation_count; ++i) { - std::cout << "Invocation: " << i << std::endl; - computation->run(serializer, "Smagorinsky"); - } - - computation->finalize(); -} - -} // namespace smagorinsky diff --git a/src/serialbox-c/CMakeLists.txt b/src/serialbox-c/CMakeLists.txt index ba59fa95..dd2cbeb3 100644 --- a/src/serialbox-c/CMakeLists.txt +++ b/src/serialbox-c/CMakeLists.txt @@ -53,7 +53,7 @@ if(SERIALBOX_ENABLE_C) FortranWrapper.h ) - set(EXTERNAL_LIBRARIES ${Boost_LIBRARIES} ${SERIALBOX_EXTERNAL_LIBRARIES}) + set(EXTERNAL_LIBRARIES ${SERIALBOX_EXTERNAL_LIBRARIES}) add_library(SerialboxCObjects OBJECT ${SOURCES}) target_include_directories(SerialboxCObjects diff --git a/src/serialbox/core/Config.h.cmake b/src/serialbox/core/Config.h.cmake index ffa9c2e8..dc880dc7 100644 --- a/src/serialbox/core/Config.h.cmake +++ b/src/serialbox/core/Config.h.cmake @@ -34,9 +34,6 @@ /* SERIALBOX version string */ #define SERIALBOX_VERSION_STRING "${Serialbox_VERSION_MAJOR}.${Serialbox_VERSION_MINOR}.${Serialbox_VERSION_PATCH}" -/* Boost version used during compilation */ -#define SERIALBOX_BOOST_VERSION ${SERIALBOX_BOOST_VERSION} - /* Define if OpenSSL is available */ #cmakedefine SERIALBOX_HAS_OPENSSL ${SERIALBOX_HAS_OPENSSL} @@ -47,4 +44,3 @@ #cmakedefine SERIALBOX_HAS_LOGGING ${SERIALBOX_HAS_LOGGING} #endif - diff --git a/src/serialbox/core/MetainfoValueImpl.cpp b/src/serialbox/core/MetainfoValueImpl.cpp index 89c14590..942098e5 100644 --- a/src/serialbox/core/MetainfoValueImpl.cpp +++ b/src/serialbox/core/MetainfoValueImpl.cpp @@ -13,19 +13,18 @@ //===------------------------------------------------------------------------------------------===// #include "serialbox/core/MetainfoValueImpl.h" +#include "serialbox/core/Exception.h" #include "serialbox/core/Unreachable.h" #include -#include - namespace serialbox { namespace internal { /// Convert any to type T template -const T& convert(const boost::any& any) noexcept { - return *boost::any_cast(&any); +const T& convert(const std::any& any) noexcept { + return *std::any_cast(&any); } /// Construct T from string @@ -40,10 +39,10 @@ T fromString(StringType&& valueStr) { /// Convert any to primtive T template -T makePrimitiveOf(const boost::any& any, TypeID type); +T makePrimitiveOf(const std::any& any, TypeID type); template <> -bool makePrimitiveOf(const boost::any& any, TypeID type) { +bool makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return convert(any); @@ -64,7 +63,7 @@ bool makePrimitiveOf(const boost::any& any, TypeID type) { } template <> -int makePrimitiveOf(const boost::any& any, TypeID type) { +int makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return (int)convert(any); @@ -93,7 +92,7 @@ int makePrimitiveOf(const boost::any& any, TypeID type) { } template <> -std::int64_t makePrimitiveOf(const boost::any& any, TypeID type) { +std::int64_t makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return (std::int64_t)convert(any); @@ -122,7 +121,7 @@ std::int64_t makePrimitiveOf(const boost::any& any, TypeID type) { } template <> -float makePrimitiveOf(const boost::any& any, TypeID type) { +float makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return (float)convert(any); @@ -143,7 +142,7 @@ float makePrimitiveOf(const boost::any& any, TypeID type) { } template <> -double makePrimitiveOf(const boost::any& any, TypeID type) { +double makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return (double)convert(any); @@ -164,7 +163,7 @@ double makePrimitiveOf(const boost::any& any, TypeID type) { } template <> -std::string makePrimitiveOf(const boost::any& any, TypeID type) { +std::string makePrimitiveOf(const std::any& any, TypeID type) { switch(type) { case TypeID::Boolean: return (convert(any) ? "true" : "false"); @@ -186,7 +185,7 @@ std::string makePrimitiveOf(const boost::any& any, TypeID type) { /// Convert any to array of T template > -ArrayType makeArrayOf(const boost::any& any, TypeID type) { +ArrayType makeArrayOf(const std::any& any, TypeID type) { if(!TypeUtil::isArray(type)) throw Exception("cannot convert non-array [type = %s] to array [T = %s]", TypeUtil::toString(type), TypeUtil::toString(ToTypeID::value)); @@ -197,37 +196,37 @@ ArrayType makeArrayOf(const boost::any& any, TypeID type) { case TypeID::Boolean: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(bool(a)), TypeID::Boolean)); + arrayT.push_back(makePrimitiveOf(std::any(bool(a)), TypeID::Boolean)); break; } case TypeID::Int32: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(int(a)), TypeID::Int32)); + arrayT.push_back(makePrimitiveOf(std::any(int(a)), TypeID::Int32)); break; } case TypeID::Int64: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(std::int64_t(a)), TypeID::Int64)); + arrayT.push_back(makePrimitiveOf(std::any(std::int64_t(a)), TypeID::Int64)); break; } case TypeID::Float32: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(float(a)), TypeID::Float32)); + arrayT.push_back(makePrimitiveOf(std::any(float(a)), TypeID::Float32)); break; } case TypeID::Float64: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(double(a)), TypeID::Float64)); + arrayT.push_back(makePrimitiveOf(std::any(double(a)), TypeID::Float64)); break; } case TypeID::String: { const auto& array = convert>(any); for(const auto& a : array) - arrayT.push_back(makePrimitiveOf(boost::any(std::string(a)), TypeID::String)); + arrayT.push_back(makePrimitiveOf(std::any(std::string(a)), TypeID::String)); break; } default: diff --git a/src/serialbox/core/MetainfoValueImpl.h b/src/serialbox/core/MetainfoValueImpl.h index 18dceac8..2fca8d12 100644 --- a/src/serialbox/core/MetainfoValueImpl.h +++ b/src/serialbox/core/MetainfoValueImpl.h @@ -16,10 +16,8 @@ #define SERIALBOX_CORE_METAINFOVALUEIMPL_H #include "serialbox/core/Array.h" -#include "serialbox/core/Exception.h" #include "serialbox/core/Type.h" -#include -#include +#include #include namespace serialbox { @@ -59,7 +57,7 @@ class MetainfoValueImpl { static_assert(IsSupported::value, "ValueType is not supported"); type_ = ToTypeID::value; - any_ = boost::any(DecayedValueType(value)); + any_ = std::any(DecayedValueType(value)); } explicit MetainfoValueImpl(const char* value) : MetainfoValueImpl(std::string(value)) {} @@ -102,9 +100,9 @@ class MetainfoValueImpl { /// \brief Get TypeID TypeID type() const noexcept { return type_; } - /// \brief Get boost::any - boost::any& any() noexcept { return any_; } - const boost::any& any() const noexcept { return any_; } + /// \brief Get std::any + std::any& any() noexcept { return any_; } + const std::any& any() const noexcept { return any_; } /// \brief Convert to string std::string toString() const; @@ -112,12 +110,12 @@ class MetainfoValueImpl { private: template const T& convert() const noexcept { - return *boost::any_cast(&any_); + return *std::any_cast(&any_); } private: TypeID type_; ///< Type of the data - boost::any any_; ///< Type-erased value of the data + std::any any_; ///< Type-erased value of the data }; template <> diff --git a/src/serialbox/core/SerializerImpl.cpp b/src/serialbox/core/SerializerImpl.cpp index ff7a2b22..38fd8309 100644 --- a/src/serialbox/core/SerializerImpl.cpp +++ b/src/serialbox/core/SerializerImpl.cpp @@ -23,7 +23,6 @@ #include "serialbox/core/archive/ArchiveFactory.h" #include "serialbox/core/archive/BinaryArchive.h" #include "serialbox/core/hash/HashFactory.h" -#include #include #include #include @@ -473,7 +472,7 @@ bool SerializerImpl::upgradeMetaData() { LOG(info) << "Inserting global meta-info: key = " << it.key() << ", value = " << it.value(); std::string key = it.key(); - if(!boost::algorithm::starts_with(key, "__")) { + if(!(key.rfind("__", 0) == 0)) { // replace by starts_with in C++20 if(it.value().is_string()) { std::string value = it.value(); addGlobalMetainfo(key, value); @@ -583,7 +582,7 @@ bool SerializerImpl::upgradeMetaData() { // Add meta-info to savepoint for(auto it = offsetTableEntry.begin(), end = offsetTableEntry.end(); it != end; ++it) { std::string key = it.key(); - if(!boost::algorithm::starts_with(key, "__")) { + if(!(key.rfind("__", 0) == 0)) { // replace by starts_with in C++20 if(it.value().is_string()) { std::string value = it.value(); savepoint.addMetainfo(it.key(), value); diff --git a/src/serialbox/core/archive/BinaryArchive.cpp b/src/serialbox/core/archive/BinaryArchive.cpp index 4374bd62..67b53e8a 100644 --- a/src/serialbox/core/archive/BinaryArchive.cpp +++ b/src/serialbox/core/archive/BinaryArchive.cpp @@ -16,7 +16,6 @@ #include "serialbox/core/Logging.h" #include "serialbox/core/Version.h" #include "serialbox/core/hash/HashFactory.h" -#include #include namespace serialbox { @@ -452,7 +451,8 @@ void BinaryArchive::clear() { std::filesystem::directory_iterator end; for(std::filesystem::directory_iterator it(directory_); it != end; ++it) { if(std::filesystem::is_regular_file(it->path()) && - boost::algorithm::starts_with(it->path().filename().string(), prefix_ + "_") && + (it->path().filename().string().rfind(prefix_ + "_", 0) == 0) && // replace with starts_with + // in C++20 std::filesystem::path(it->path()).extension() == ".dat") { if(!std::filesystem::remove(it->path())) diff --git a/src/serialbox/core/archive/NetCDFArchive.cpp b/src/serialbox/core/archive/NetCDFArchive.cpp index 77d62173..85d76fd8 100644 --- a/src/serialbox/core/archive/NetCDFArchive.cpp +++ b/src/serialbox/core/archive/NetCDFArchive.cpp @@ -19,7 +19,6 @@ #include "serialbox/core/Unreachable.h" #include "serialbox/core/Version.h" #include "serialbox/core/archive/NetCDFArchive.h" -#include #include #include #include @@ -489,7 +488,8 @@ void NetCDFArchive::clear() { std::filesystem::directory_iterator end; for(std::filesystem::directory_iterator it(directory_); it != end; ++it) { if(std::filesystem::is_regular_file(it->path()) && - boost::algorithm::starts_with(it->path().filename().string(), prefix_ + "_") && + (it->path().filename().string().rfind(prefix_ + "_", 0) == + 0) && // replace with starts_with in c++20 std::filesystem::path(it->path()).extension() == ".nc") { if(!std::filesystem::remove(it->path())) diff --git a/test/benchmark/CMakeLists.txt b/test/benchmark/CMakeLists.txt index 7d850f16..616a5bde 100644 --- a/test/benchmark/CMakeLists.txt +++ b/test/benchmark/CMakeLists.txt @@ -15,8 +15,7 @@ set(SOURCES ) # Setup external libraries -set(EXTERNAL_LIBRARIES ${Boost_LIBRARIES} - ${GTEST_LIBRARIES} +set(EXTERNAL_LIBRARIES ${GTEST_LIBRARIES} ${SERIALBOX_OLD_LIBRARIES}) serialbox_add_unittest_executable(NAME SerialboxBenchmarkUnittest diff --git a/test/serialbox-fortran/CMakeLists.txt b/test/serialbox-fortran/CMakeLists.txt index f441beb3..4a8860b0 100644 --- a/test/serialbox-fortran/CMakeLists.txt +++ b/test/serialbox-fortran/CMakeLists.txt @@ -19,7 +19,6 @@ endif() # Setup external libraries set(EXTERNAL_LIBRARIES SerialboxFortranStatic SerialboxCStatic - ${Boost_LIBRARIES} ${SERIALBOX_EXTERNAL_LIBRARIES} ) diff --git a/test/serialbox/core/UnittestFieldMap.cpp b/test/serialbox/core/UnittestFieldMap.cpp index ef2a68f4..3e6913b9 100644 --- a/test/serialbox/core/UnittestFieldMap.cpp +++ b/test/serialbox/core/UnittestFieldMap.cpp @@ -14,7 +14,6 @@ #include "serialbox/core/FieldMap.h" #include "serialbox/core/FieldMapSerializer.h" -#include #include using namespace serialbox; @@ -295,7 +294,7 @@ TEST(FieldMapTest, toString) { std::stringstream ss; ss << map; - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "FieldMap")); + EXPECT_TRUE(ss.str().rfind("FieldMap", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("field1"), std::string::npos); EXPECT_NE(ss.str().find("key1"), std::string::npos); EXPECT_NE(ss.str().find("key2"), std::string::npos); diff --git a/test/serialbox/core/UnittestFieldMetainfoImpl.cpp b/test/serialbox/core/UnittestFieldMetainfoImpl.cpp index 6224ff1d..0d7adac1 100644 --- a/test/serialbox/core/UnittestFieldMetainfoImpl.cpp +++ b/test/serialbox/core/UnittestFieldMetainfoImpl.cpp @@ -15,7 +15,6 @@ #include "serialbox/core/FieldMetainfoImpl.h" #include "serialbox/core/FieldMetainfoImplSerializer.h" -#include #include using nlohmann::basic_json; diff --git a/test/serialbox/core/UnittestMetainfoMapImpl.cpp b/test/serialbox/core/UnittestMetainfoMapImpl.cpp index 55de024d..299e42fe 100644 --- a/test/serialbox/core/UnittestMetainfoMapImpl.cpp +++ b/test/serialbox/core/UnittestMetainfoMapImpl.cpp @@ -15,7 +15,6 @@ #include "serialbox/core/MetainfoMapImpl.h" #include "serialbox/core/MetainfoMapImplSerializer.h" -#include #include using namespace serialbox; @@ -85,7 +84,7 @@ TEST(MetainfoMapImplTest, Construction) { ASSERT_TRUE(map2.empty()); // Iterate values - std::vector anyvec; + std::vector anyvec; for(const auto& map_element : map) anyvec.push_back(map_element.second.any()); EXPECT_EQ(anyvec.size(), map.size()); diff --git a/test/serialbox/core/UnittestMetainfoValueImpl.cpp b/test/serialbox/core/UnittestMetainfoValueImpl.cpp index 589dd376..57e3e511 100644 --- a/test/serialbox/core/UnittestMetainfoValueImpl.cpp +++ b/test/serialbox/core/UnittestMetainfoValueImpl.cpp @@ -12,6 +12,7 @@ /// //===------------------------------------------------------------------------------------------===// +#include "serialbox/core/Exception.h" #include "serialbox/core/MetainfoValueImpl.h" #include #include diff --git a/test/serialbox/core/UnittestSavepointImpl.cpp b/test/serialbox/core/UnittestSavepointImpl.cpp index 51c0d682..3451ff66 100644 --- a/test/serialbox/core/UnittestSavepointImpl.cpp +++ b/test/serialbox/core/UnittestSavepointImpl.cpp @@ -14,7 +14,6 @@ #include "serialbox/core/SavepointImpl.h" #include "serialbox/core/SavepointImplSerializer.h" -#include #include #include diff --git a/test/serialbox/core/UnittestSavepointVector.cpp b/test/serialbox/core/UnittestSavepointVector.cpp index 74047750..3097b83f 100644 --- a/test/serialbox/core/UnittestSavepointVector.cpp +++ b/test/serialbox/core/UnittestSavepointVector.cpp @@ -14,7 +14,6 @@ #include "serialbox/core/SavepointVector.h" #include "serialbox/core/SavepointVectorSerializer.h" -#include #include using namespace serialbox; @@ -386,7 +385,7 @@ TEST(SavepointVectorTest, toString) { ASSERT_TRUE(s.addField(savepoint1, FieldID{"u", 0})); ss << s; - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "SavepointVector")); + EXPECT_TRUE(ss.str().rfind("SavepointVector", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("savepoint"), std::string::npos); EXPECT_NE(ss.str().find("key1"), std::string::npos); } diff --git a/test/serialbox/core/UnittestStorageView.cpp b/test/serialbox/core/UnittestStorageView.cpp index b0af7e0d..d0a3e9ef 100644 --- a/test/serialbox/core/UnittestStorageView.cpp +++ b/test/serialbox/core/UnittestStorageView.cpp @@ -16,7 +16,6 @@ #include "serialbox/core/StorageView.h" #include "serialbox/core/Type.h" #include "utility/Storage.h" -#include #include #include #include @@ -387,7 +386,7 @@ TYPED_TEST(StorageViewTest, toString) { // StorageView ss << sv_1d; - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "StorageView")); + EXPECT_TRUE(ss.str().rfind("StorageView", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("originPtr"), std::string::npos); EXPECT_NE(ss.str().find("type"), std::string::npos); EXPECT_NE(ss.str().find("dims"), std::string::npos); @@ -397,7 +396,7 @@ TYPED_TEST(StorageViewTest, toString) { // StorageViewIterator ss << sv_1d.begin(); - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "StorageViewIterator")); + EXPECT_TRUE(ss.str().rfind("StorageViewIterator", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("originPtr"), std::string::npos); EXPECT_NE(ss.str().find("index"), std::string::npos); EXPECT_NE(ss.str().find("end"), std::string::npos); diff --git a/test/serialbox/core/archive/UnittestBinaryArchive.cpp b/test/serialbox/core/archive/UnittestBinaryArchive.cpp index 78420ecc..322dfce8 100644 --- a/test/serialbox/core/archive/UnittestBinaryArchive.cpp +++ b/test/serialbox/core/archive/UnittestBinaryArchive.cpp @@ -16,7 +16,6 @@ #include "serialbox/core/archive/BinaryArchive.h" #include "utility/SerializerTestBase.h" #include "utility/Storage.h" -#include #include using namespace serialbox; @@ -174,7 +173,7 @@ TEST_F(BinaryArchiveUtilityTest, toString) { archive.write(sv, "storage", nullptr); ss << archive; - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "BinaryArchive")); + EXPECT_TRUE(ss.str().rfind("BinaryArchive", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("directory"), std::string::npos); EXPECT_NE(ss.str().find("mode"), std::string::npos); EXPECT_NE(ss.str().find("prefix"), std::string::npos); diff --git a/test/serialbox/core/archive/UnittestNetCDFArchive.cpp b/test/serialbox/core/archive/UnittestNetCDFArchive.cpp index 327eb270..9ccc070f 100644 --- a/test/serialbox/core/archive/UnittestNetCDFArchive.cpp +++ b/test/serialbox/core/archive/UnittestNetCDFArchive.cpp @@ -45,7 +45,7 @@ TEST_F(NetCDFArchiveUtilityTest, Construction) { NetCDFArchive b(OpenModeKind::Write, this->directory->path().string(), "field"); b.updateMetaData(); - EXPECT_TRUE(boost::algorithm::starts_with(b.name(), "NetCDF")); + EXPECT_TRUE(b.name().rfind("NetCDF", 0) == 0); // replace by starts_with in C++20 EXPECT_EQ(b.mode(), OpenModeKind::Write); EXPECT_EQ(b.prefix(), "field"); } @@ -177,7 +177,7 @@ TEST_F(NetCDFArchiveUtilityTest, toString) { ss << archive; - EXPECT_TRUE(boost::algorithm::starts_with(ss.str(), "NetCDFArchive")); + EXPECT_TRUE(ss.str().rfind("NetCDFArchive", 0) == 0); // replace by starts_with in C++20 EXPECT_NE(ss.str().find("directory"), std::string::npos); EXPECT_NE(ss.str().find("mode"), std::string::npos); EXPECT_NE(ss.str().find("prefix"), std::string::npos); diff --git a/test/serialbox/core/frontend/gridtools/UnittestMetainfoMap.cpp b/test/serialbox/core/frontend/gridtools/UnittestMetainfoMap.cpp index 2cf50bef..3ad5d4cd 100644 --- a/test/serialbox/core/frontend/gridtools/UnittestMetainfoMap.cpp +++ b/test/serialbox/core/frontend/gridtools/UnittestMetainfoMap.cpp @@ -80,7 +80,7 @@ TEST(GridToolsMetainfoMapTest, Construction) { ASSERT_TRUE(map1.empty()); // Iterate values - std::vector anyvec; + std::vector anyvec; for(const auto& map_element : map1) anyvec.push_back(map_element.second.any()); EXPECT_EQ(anyvec.size(), map1.size()); diff --git a/tools/cscs-scripts/env_kesch-test.sh b/tools/cscs-scripts/env_kesch-test.sh deleted file mode 100644 index 086a513f..00000000 --- a/tools/cscs-scripts/env_kesch-test.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -##===-----------------------------------------------------------*- bash -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===----------------------------------------------------------------------===## - -## Print help statement and exit. -print_help() -{ - printf "Usage: $0 [options]\n\n" - printf "Options:\n" - - # --fc-compiler - printf " %-35s %s\n" \ - "-f, --fc-compiler FORTRAN_COMPILER" \ - "Fortran compiler to use (set to " - printf " %-35s %s\n" "" "environment variable FC)." - - # --help - printf " %-35s %s\n" "-h, --help" "Print this help statement." - printf "\n" - exit 0 -} - -## Convert to lower case and remove all whitespaces -to_lower_and_trim() -{ - if [ $# -ne 1 ]; then - echo "$0: internal error." ; exit 1 - fi - - local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') - local trim_whitespaces=${to_lower// /} - echo "${trim_whitespaces}" -} - -#------------------------------ Parse options ---------------------------------- -ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n 'env_kesch' -- "$@"); - -if [ $? -ne 0 ]; then - exit 1 -fi - -eval set -- "$ENV_ARGS" - -while true; do - case "$1" in - -h|--h*) print_help; exit 0;; - -f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;; - --) shift; break ;; - *) echo "$0: internal error." ; exit 1 ;; - esac -done - -# Fortran Compiler -if [ -z ${ARG_FC_COMPILER+x} ]; then - echo "$0: error: fortran compiler is not set" - exit 1 -else - FC_COMPILER=${ARG_FC_COMPILER} -fi - -#------------------------------ Set environment -------------------------------- - -module purge -module load cmake/3.9.1 - -if [ "$FC_COMPILER" = "pgfortran" ]; then - -module unuse /apps/escha/UES/generic/modulefiles:/apps/escha/UES/PrgEnv-gnu-17.02/modulefiles:/apps/escha/UES/PrgEnv-cray-17.06/modulefiles:/apps/escha/UES/experimental/modulefiles -module use /apps/escha/UES/jenkins/RH7.4/gnu_PE17.02/easybuild/modules/all -module use /apps/escha/UES/jenkins/RH7.4/generic/easybuild/modules/all -module use /apps/escha/UES/jenkins/RH7.4/cray_PE17.06/easybuild/modules/all - - module load craype-haswell - module load craype-accel-nvidia35 - module switch mvapich2_cce/2.2rc1.0.3_cuda80 mvapich2gdr_gnu/2.2_cuda_8.0 - module load PrgEnv-pgi/17.10 - module load gcc/5.4.0-2.26 - -elif [ "$FC_COMPILER" = "ftn" ]; then -module unuse /apps/escha/UES/generic/modulefiles:/apps/escha/UES/PrgEnv-gnu-17.02/modulefiles:/apps/escha/UES/PrgEnv-cray-17.06/modulefiles:/apps/escha/UES/experimental/modulefiles -module use /apps/escha/UES/jenkins/RH7.4/gnu_PE17.02/easybuild/modules/all -module use /apps/escha/UES/jenkins/RH7.4/generic/easybuild/modules/all -module use /apps/escha/UES/jenkins/RH7.4/cray_PE17.06/easybuild/modules/all - - module load craype-haswell - module load PrgEnv-cray - module load craype-accel-nvidia35 - module load craype-network-infiniband - module switch mvapich2_cce/2.2rc1.0.3_cuda80 mvapich2gdr_gnu/2.2_cuda_8.0 - module load gcc/5.4.0-2.26 - export GCC_X86_64=$EBROOTGCCCORE -else - module load PrgEnv-gnu -fi - -export CXX=$(which g++) -export CC=$(which gcc) -export FC=$(which $FC_COMPILER) - -export Boost_NO_SYSTEM_PATHS=true -export Boost_NO_BOOST_CMAKE=true - -export BOOST_ROOT=/project/c14/install/kesch/boost/boost_1_67_0/ -export BOOST_INCLUDE={BOOST_ROOT}/include/ - diff --git a/tools/cscs-scripts/env_kesch.sh b/tools/cscs-scripts/env_kesch.sh deleted file mode 100644 index d309d229..00000000 --- a/tools/cscs-scripts/env_kesch.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -##===-----------------------------------------------------------*- bash -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===----------------------------------------------------------------------===## - -## Print help statement and exit. -print_help() -{ - printf "Usage: $0 [options]\n\n" - printf "Options:\n" - - # --fc-compiler - printf " %-35s %s\n" \ - "-f, --fc-compiler FORTRAN_COMPILER" \ - "Fortran compiler to use (set to " - printf " %-35s %s\n" "" "environment variable FC)." - - # --help - printf " %-35s %s\n" "-h, --help" "Print this help statement." - printf "\n" - exit 0 -} - -## Convert to lower case and remove all whitespaces -to_lower_and_trim() -{ - if [ $# -ne 1 ]; then - echo "$0: internal error." ; exit 1 - fi - - local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') - local trim_whitespaces=${to_lower// /} - echo "${trim_whitespaces}" -} - -#------------------------------ Parse options ---------------------------------- -ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n 'env_kesch' -- "$@"); - -if [ $? -ne 0 ]; then - exit 1 -fi - -eval set -- "$ENV_ARGS" - -while true; do - case "$1" in - -h|--h*) print_help; exit 0;; - -f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;; - --) shift; break ;; - *) echo "$0: internal error." ; exit 1 ;; - esac -done - -# Fortran Compiler -if [ -z ${ARG_FC_COMPILER+x} ]; then - echo "$0: error: fortran compiler is not set" - exit 1 -else - FC_COMPILER=${ARG_FC_COMPILER} -fi - -#------------------------------ Set environment -------------------------------- - -module purge - -module load PE/17.06 -module load craype-network-infiniband -module load craype-haswell -module load cmake/3.13.4 -module load python/3.6.2-gmvolf-17.02 - -if [ "$FC_COMPILER" = "pgfortran" ]; then - module load PrgEnv-pgi/18.5 - module load netcdf-fortran/4.4.4-pgi-18.5-gcc-5.4.0-2.26 - export NETCDF_ROOT=$EBROOTNETCDF - module load gcc/5.4.0-2.26 - -elif [ "$FC_COMPILER" = "ftn" ]; then - module unload mvapich2/2.2-gcc-5.4.0-2.26 - module load PrgEnv-CrayCCE/17.06 - module load gcc/5.4.0-2.26 - module load netCDF-Fortran/4.4.4-CrayCCE-17.06 - export NETCDF_ROOT=$EBROOTNETCDF - export GCC_X86_64=$EBROOTGCCCORE -else - module load PrgEnv-gnu/17.02 - module load netcdf-fortran/4.4.4-gmvolf-17.02 - export NETCDF_ROOT=$EBROOTNETCDF -fi - -export CXX=$(which g++) -export CC=$(which gcc) -export FC=$(which $FC_COMPILER) - -export Boost_NO_SYSTEM_PATHS=true -export Boost_NO_BOOST_CMAKE=true - -export BOOST_ROOT=/project/c14/install/kesch/boost/boost_1_67_0/ -export BOOST_INCLUDE={BOOST_ROOT}/include/ - diff --git a/tools/cscs-scripts/env_tave.sh b/tools/cscs-scripts/env_tave.sh deleted file mode 100644 index 61deb20a..00000000 --- a/tools/cscs-scripts/env_tave.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -##===-----------------------------------------------------------*- bash -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===----------------------------------------------------------------------===## - -## Print help statement and exit. -print_help() -{ - printf "Usage: $0 [options]\n\n" - printf "Options:\n" - - # --fc-compiler - printf " %-35s %s\n" \ - "-f, --fc-compiler FORTRAN_COMPILER" \ - "Fortran compiler to use (set to " - printf " %-35s %s\n" "" "environment variable FC)." - - # --help - printf " %-35s %s\n" "-h, --help" "Print this help statement." - printf "\n" - exit 0 -} - -## Convert to lower case and remove all whitespaces -to_lower_and_trim() -{ - if [ $# -ne 1 ]; then - echo "$0: internal error." ; exit 1 - fi - - local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') - local trim_whitespaces=${to_lower// /} - echo "${trim_whitespaces}" -} - -#------------------------------ Parse options ---------------------------------- -ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n 'env_kesch' -- "$@"); - -if [ $? -ne 0 ]; then - exit 1 -fi - -eval set -- "$ENV_ARGS" - -while true; do - case "$1" in - -h|--h*) print_help; exit 0;; - -f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;; - --) shift; break ;; - *) echo "$0: internal error." ; exit 1 ;; - esac -done - -# Fortran Compiler -if [ -z ${ARG_FC_COMPILER+x} ]; then - echo "$0: error: fortran compiler is not set" - exit 1 -else - FC_COMPILER=${ARG_FC_COMPILER} -fi - -#------------------------------ Set environment -------------------------------- - -module use /users/jenkins/easybuild/tave/modules/all -module load CMake/3.12.0 - -if [ "$FC_COMPILER" = "pgfortran" ]; then - module rm PrgEnv-cray - module load PrgEnv-pgi - module load gcc -elif [ "$FC_COMPILER" = "ftn" ]; then - module load gcc -elif [ "$FC_COMPILER" = "ifort" ]; then - module swap PrgEnv-cray PrgEnv-intel - module load gcc -else - module rm PrgEnv-cray - module load PrgEnv-gnu -fi - -module load cray-netcdf -export NETCDF_ROOT=${NETCDF_DIR} - -export CXX=$(which g++) -export CC=$(which gcc) -export FC=$(which $FC_COMPILER) - -export Boost_NO_SYSTEM_PATHS=true -export Boost_NO_BOOST_CMAKE=true - -export BOOST_ROOT=/project/c14/install/daint/boost/boost_1_67_0 -export BOOST_INCLUDE={BOOST_ROOT}/include/ -export LD_LIBRARY_PATH=${BOOST_ROOT}/lib:$LD_LIBRARY_PATH - diff --git a/tools/cscs-scripts/env_tsa.sh b/tools/cscs-scripts/env_tsa.sh deleted file mode 100755 index 12c97311..00000000 --- a/tools/cscs-scripts/env_tsa.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -##===-----------------------------------------------------------*- bash -*-===## -## -## S E R I A L B O X -## -## This file is distributed under terms of BSD license. -## See LICENSE.txt for more information. -## -##===----------------------------------------------------------------------===## - -## Print help statement and exit. -print_help() -{ - printf "Usage: $0 [options]\n\n" - printf "Options:\n" - - # --fc-compiler - printf " %-35s %s\n" \ - "-f, --fc-compiler FORTRAN_COMPILER" \ - "Fortran compiler to use (set to " - printf " %-35s %s\n" "" "environment variable FC)." - - # --help - printf " %-35s %s\n" "-h, --help" "Print this help statement." - printf "\n" - exit 0 -} - -## Convert to lower case and remove all whitespaces -to_lower_and_trim() -{ - if [ $# -ne 1 ]; then - echo "$0: internal error." ; exit 1 - fi - - local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') - local trim_whitespaces=${to_lower// /} - echo "${trim_whitespaces}" -} - -#------------------------------ Parse options ---------------------------------- -ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n 'env_kesch' -- "$@"); - -if [ $? -ne 0 ]; then - exit 1 -fi - -eval set -- "$ENV_ARGS" - -while true; do - case "$1" in - -h|--h*) print_help; exit 0;; - -f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;; - --) shift; break ;; - *) echo "$0: internal error." ; exit 1 ;; - esac -done - -# Fortran Compiler -if [ -z ${ARG_FC_COMPILER+x} ]; then - echo "$0: error: fortran compiler is not set" - exit 1 -else - FC_COMPILER=${ARG_FC_COMPILER} -fi - -#------------------------------ Set environment -------------------------------- - -module load slurm -module load cmake/3.14.5 - -if [ "$FC_COMPILER" = "pgfortran" ]; then - module load PrgEnv-pgi - module load gcc -elif [ "$FC_COMPILER" = "ftn" ]; then - echo "$FC_COMPILER not available on tsa" - exit 1 -elif [ "$FC_COMPILER" = "ifort" ]; then - echo "$FC_COMPILER not available on tsa" - exit 1 -else - module load PrgEnv-gnu -fi - -export CXX=$(which g++) -export CC=$(which gcc) -export FC=$(which $FC_COMPILER) - -export Boost_NO_SYSTEM_PATHS=true -export Boost_NO_BOOST_CMAKE=true - -export BOOST_ROOT=/apps/tsa/SSL/gridtools/jenkins/boost_1_77_0 - diff --git a/tools/cscs-scripts/submit.kesch.slurm b/tools/cscs-scripts/submit.kesch.slurm deleted file mode 100644 index 65d844d8..00000000 --- a/tools/cscs-scripts/submit.kesch.slurm +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -#SBATCH --job-name=serialbox-unittest -#SBATCH --nodes=1 -#SBATCH --ntasks=1 -#SBATCH --ntasks-per-node=1 -#SBATCH --ntasks-per-socket=1 -#SBATCH --output=serialbox-unittest.out -#SBATCH --partition=debug -#SBATCH --time=00:2:00 -#SBATCH --cpus-per-task=12 -#SBATCH --distribution block:block - -## Print help statement and exit. -print_help() -{ - printf "Usage: $0 [options]\n\n" - printf "Options:\n" - - # --fc-compiler - printf " %-35s %s\n" \ - "-f, --fc-compiler [gnu|cray|pgi]" \ - "Select Fortran compiler [default: gnu]." - - # --help - printf " %-35s %s\n" "-h, --help" "Print this help statement." - printf "\n" - exit 0 -} - -## Convert to lower case and remove all whitespaces -to_lower_and_trim() -{ - if [ $# -ne 1 ]; then - echo "$0: internal error." ; exit 1 - fi - - local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') - local trim_whitespaces=${to_lower// /} - echo "${trim_whitespaces}" -} - -#------------------------------ Parse options ---------------------------------- -ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n \ - 'submit.kesch.slurm' -- "$@"); - -if [ $? -ne 0 ]; then - exit 1 -fi - -eval set -- "$ENV_ARGS" - -while true; do - case "$1" in - -h|--h*) print_help; exit 0;; - -f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;; - --) shift; break ;; - *) echo "$0: internal error." ; exit 1 ;; - esac -done - -# Fortran Compiler -if [ "${ARG_FC_COMPILER}" = "cray" ]; then - printf "%-20s: %s\n" "Fortran compiler" "cray" - FC_COMPILER="ftn" -elif [ "${ARG_FC_COMPILER}" = "pgi" ]; then - printf "%-20s: %s\n" "Fortran compiler" "pgi" - FC_COMPILER="pgfortran" -else - printf "%-20s: %s\n" "Fortran compiler" "gnu" - FC_COMPILER="gfortran" -fi - -#------------------------------ Load environment ------------------------------- - -CURRENT_PATH=$(pwd) - -# Load environment -source ${CURRENT_PATH}/env_kesch.sh -f ${FC_COMPILER} - -#------------------------------ Run -------------------------------------------- - -RUN_SCRIPT=${CURRENT_PATH}/../../build_gcc_${ARG_FC_COMPILER}/run_tests.sh - -printf "%-10s: %s\n" "Host" "$HOSTNAME" -printf "%-10s: %s\n" "Device" "CPU" -echo "---------------------------------------------" - -srun -n 1 bash ${RUN_SCRIPT} - -echo "---------------------------------------------" -echo "Parallel execution finished." -