From 8de441a6387f163a31e803b2453cec67e4efc76d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 27 Jun 2021 14:45:00 -0400 Subject: [PATCH 01/94] Partial Julia bindings --- CMakeLists.txt | 53 ++ src/binding/julia/Access.cpp | 12 + src/binding/julia/Attributable.cpp | 22 + src/binding/julia/Attribute.cpp | 14 + src/binding/julia/BaseRecordComponent.cpp | 22 + src/binding/julia/Container.cpp | 3 + src/binding/julia/Container.hpp | 83 +++ src/binding/julia/Dataset.cpp | 23 + src/binding/julia/Datatype.cpp | 35 + src/binding/julia/Format.cpp | 18 + src/binding/julia/Iteration.cpp | 30 + src/binding/julia/Mesh.cpp | 72 ++ src/binding/julia/MeshRecordComponent.cpp | 22 + src/binding/julia/RecordComponent.cpp | 89 +++ src/binding/julia/Series.cpp | 78 ++ src/binding/julia/UnitDimension.cpp | 16 + src/binding/julia/WriteIterations.cpp | 17 + src/binding/julia/defs.hpp | 150 ++++ src/binding/julia/openPMD.cpp | 49 ++ .../julia/openPMD.jl/.JuliaFormatter.toml | 10 + .../julia/openPMD.jl/.github/workflows/CI.yml | 77 ++ src/binding/julia/openPMD.jl/.gitignore | 1 + src/binding/julia/openPMD.jl/COPYING | 675 ++++++++++++++++++ src/binding/julia/openPMD.jl/COPYING.LESSER | 166 +++++ src/binding/julia/openPMD.jl/Project.toml | 14 + src/binding/julia/openPMD.jl/docs/.gitignore | 2 + .../julia/openPMD.jl/docs/Project.toml | 2 + src/binding/julia/openPMD.jl/docs/make.jl | 11 + .../julia/openPMD.jl/docs/src/index.md | 5 + src/binding/julia/openPMD.jl/src/Access.jl | 12 + .../julia/openPMD.jl/src/Attributable.jl | 86 +++ src/binding/julia/openPMD.jl/src/Attribute.jl | 25 + .../openPMD.jl/src/BaseRecordComponent.jl | 28 + src/binding/julia/openPMD.jl/src/Container.jl | 65 ++ src/binding/julia/openPMD.jl/src/Dataset.jl | 78 ++ src/binding/julia/openPMD.jl/src/Datatype.jl | 245 +++++++ src/binding/julia/openPMD.jl/src/Format.jl | 28 + src/binding/julia/openPMD.jl/src/Iteration.jl | 58 ++ src/binding/julia/openPMD.jl/src/Mesh.jl | 140 ++++ .../openPMD.jl/src/MeshRecordComponent.jl | 33 + .../julia/openPMD.jl/src/RecordComponent.jl | 82 +++ src/binding/julia/openPMD.jl/src/Series.jl | 159 +++++ .../julia/openPMD.jl/src/UnitDimension.jl | 18 + .../julia/openPMD.jl/src/WriteIterations.jl | 13 + src/binding/julia/openPMD.jl/src/openPMD.jl | 61 ++ src/binding/julia/openPMD.jl/src/version.jl | 34 + src/binding/julia/openPMD.jl/test/Access.jl | 11 + .../julia/openPMD.jl/test/Attributable.jl | 22 + .../julia/openPMD.jl/test/Attribute.jl | 8 + .../openPMD.jl/test/BaseRecordComponent.jl | 10 + .../julia/openPMD.jl/test/Container.jl | 33 + src/binding/julia/openPMD.jl/test/Dataset.jl | 7 + src/binding/julia/openPMD.jl/test/Datatype.jl | 83 +++ src/binding/julia/openPMD.jl/test/Format.jl | 24 + .../julia/openPMD.jl/test/Iteration.jl | 22 + src/binding/julia/openPMD.jl/test/Mesh.jl | 14 + .../openPMD.jl/test/MeshRecordComponent.jl | 14 + .../julia/openPMD.jl/test/RecordComponent.jl | 7 + src/binding/julia/openPMD.jl/test/Series.jl | 77 ++ .../julia/openPMD.jl/test/UnitDimension.jl | 15 + .../julia/openPMD.jl/test/WriteIterations.jl | 11 + src/binding/julia/openPMD.jl/test/runtests.jl | 48 ++ src/binding/julia/openPMD.jl/test/version.jl | 12 + src/binding/julia/version.cpp | 12 + 64 files changed, 3366 insertions(+) create mode 100644 src/binding/julia/Access.cpp create mode 100644 src/binding/julia/Attributable.cpp create mode 100644 src/binding/julia/Attribute.cpp create mode 100644 src/binding/julia/BaseRecordComponent.cpp create mode 100644 src/binding/julia/Container.cpp create mode 100644 src/binding/julia/Container.hpp create mode 100644 src/binding/julia/Dataset.cpp create mode 100644 src/binding/julia/Datatype.cpp create mode 100644 src/binding/julia/Format.cpp create mode 100644 src/binding/julia/Iteration.cpp create mode 100644 src/binding/julia/Mesh.cpp create mode 100644 src/binding/julia/MeshRecordComponent.cpp create mode 100644 src/binding/julia/RecordComponent.cpp create mode 100644 src/binding/julia/Series.cpp create mode 100644 src/binding/julia/UnitDimension.cpp create mode 100644 src/binding/julia/WriteIterations.cpp create mode 100644 src/binding/julia/defs.hpp create mode 100644 src/binding/julia/openPMD.cpp create mode 100644 src/binding/julia/openPMD.jl/.JuliaFormatter.toml create mode 100644 src/binding/julia/openPMD.jl/.github/workflows/CI.yml create mode 100644 src/binding/julia/openPMD.jl/.gitignore create mode 100644 src/binding/julia/openPMD.jl/COPYING create mode 100644 src/binding/julia/openPMD.jl/COPYING.LESSER create mode 100644 src/binding/julia/openPMD.jl/Project.toml create mode 100644 src/binding/julia/openPMD.jl/docs/.gitignore create mode 100644 src/binding/julia/openPMD.jl/docs/Project.toml create mode 100644 src/binding/julia/openPMD.jl/docs/make.jl create mode 100644 src/binding/julia/openPMD.jl/docs/src/index.md create mode 100644 src/binding/julia/openPMD.jl/src/Access.jl create mode 100644 src/binding/julia/openPMD.jl/src/Attributable.jl create mode 100644 src/binding/julia/openPMD.jl/src/Attribute.jl create mode 100644 src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/src/Container.jl create mode 100644 src/binding/julia/openPMD.jl/src/Dataset.jl create mode 100644 src/binding/julia/openPMD.jl/src/Datatype.jl create mode 100644 src/binding/julia/openPMD.jl/src/Format.jl create mode 100644 src/binding/julia/openPMD.jl/src/Iteration.jl create mode 100644 src/binding/julia/openPMD.jl/src/Mesh.jl create mode 100644 src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/src/RecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/src/Series.jl create mode 100644 src/binding/julia/openPMD.jl/src/UnitDimension.jl create mode 100644 src/binding/julia/openPMD.jl/src/WriteIterations.jl create mode 100644 src/binding/julia/openPMD.jl/src/openPMD.jl create mode 100644 src/binding/julia/openPMD.jl/src/version.jl create mode 100644 src/binding/julia/openPMD.jl/test/Access.jl create mode 100644 src/binding/julia/openPMD.jl/test/Attributable.jl create mode 100644 src/binding/julia/openPMD.jl/test/Attribute.jl create mode 100644 src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/test/Container.jl create mode 100644 src/binding/julia/openPMD.jl/test/Dataset.jl create mode 100644 src/binding/julia/openPMD.jl/test/Datatype.jl create mode 100644 src/binding/julia/openPMD.jl/test/Format.jl create mode 100644 src/binding/julia/openPMD.jl/test/Iteration.jl create mode 100644 src/binding/julia/openPMD.jl/test/Mesh.jl create mode 100644 src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/test/RecordComponent.jl create mode 100644 src/binding/julia/openPMD.jl/test/Series.jl create mode 100644 src/binding/julia/openPMD.jl/test/UnitDimension.jl create mode 100644 src/binding/julia/openPMD.jl/test/WriteIterations.jl create mode 100644 src/binding/julia/openPMD.jl/test/runtests.jl create mode 100644 src/binding/julia/openPMD.jl/test/version.jl create mode 100644 src/binding/julia/version.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ae1dc79983..def77ef0ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ openpmd_option(MPI "Parallel, Multi-Node I/O for clusters" AUTO) openpmd_option(HDF5 "HDF5 backend (.h5 files)" AUTO) openpmd_option(ADIOS1 "ADIOS1 backend (.bp files)" AUTO) openpmd_option(ADIOS2 "ADIOS2 backend (.bp files)" AUTO) +openpmd_option(JULIA "Enable Julia bindings" AUTO) openpmd_option(PYTHON "Enable Python bindings" AUTO) option(openPMD_INSTALL "Add installation targets" ON) @@ -283,6 +284,34 @@ endif() # TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON +# External library: libcxxwrap-julia +if(openPMD_USE_JULIA STREQUAL AUTO) + find_package(JlCxx 0.8.3) + if(JlCxx_FOUND) + set(openPMD_HAVE_JlCxx TRUE) + else() + set(openPMD_HAVE_JlCxx FALSE) + endif() + if(JULIA_FOUND) + set(openPMD_HAVE_JULIA TRUE) + else() + set(openPMD_HAVE_JULIA FALSE) + endif() +elseif(openPMD_USE_JULIA) + find_package(JlCxx 0.8.3 REQUIRED) + set(openPMD_HAVE_JULIA TRUE) + set(openPMD_HAVE_JlCxx TRUE) +else() + set(openPMD_HAVE_JULIA FALSE) + set(openPMD_HAVE_JlCxx FALSE) +endif() +if(openPMD_HAVE_JlCxx) + get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) + get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") + message(STATUS "Found JlCxx version ${JlCxx_VERSION} at ${JlCxx_location}") +endif() + # external library: pybind11 (optional) set(_PY_DEV_MODULE Development.Module) if(CMAKE_VERSION VERSION_LESS 3.18.0) @@ -574,6 +603,30 @@ else() target_compile_definitions(openPMD PRIVATE openPMD_USE_VERIFY=0) endif() +# Julia bindings +if(openPMD_HAVE_JlCxx) + add_library(openPMD_jl SHARED + src/binding/julia/Access.cpp + src/binding/julia/Attributable.cpp + src/binding/julia/Attribute.cpp + src/binding/julia/BaseRecordComponent.cpp + src/binding/julia/Container.cpp + src/binding/julia/Dataset.cpp + src/binding/julia/Datatype.cpp + src/binding/julia/Format.cpp + src/binding/julia/Iteration.cpp + src/binding/julia/Mesh.cpp + src/binding/julia/MeshRecordComponent.cpp + src/binding/julia/RecordComponent.cpp + src/binding/julia/Series.cpp + src/binding/julia/UnitDimension.cpp + src/binding/julia/WriteIterations.cpp + src/binding/julia/openPMD.cpp + src/binding/julia/version.cpp + ) + target_link_libraries(openPMD_jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) +endif() + # python bindings if(openPMD_HAVE_PYTHON) add_library(openPMD.py MODULE diff --git a/src/binding/julia/Access.cpp b/src/binding/julia/Access.cpp new file mode 100644 index 0000000000..2940c99001 --- /dev/null +++ b/src/binding/julia/Access.cpp @@ -0,0 +1,12 @@ +// IO/Access + +#include "defs.hpp" + +void define_julia_Access(jlcxx::Module &mod) { + mod.add_bits("Access", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("READ_ONLY", Access::READ_ONLY); + mod.set_const("READ_WRITE", Access::READ_WRITE); + mod.set_const("CREATE", Access::CREATE); +} diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp new file mode 100644 index 0000000000..ec5d398c71 --- /dev/null +++ b/src/binding/julia/Attributable.cpp @@ -0,0 +1,22 @@ +// Attributable + +#include "defs.hpp" + +void define_julia_Attributable(jlcxx::Module &mod) { + auto type = mod.add_type("Attributable"); + +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("set_attribute1_" NAME "!", &Attributable::setAttribute); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE + + type.method("get_attribute1", &Attributable::getAttribute); + type.method("delete_attribute!", &Attributable::deleteAttribute); + type.method("attributes", &Attributable::attributes); + type.method("num_attributes1", &Attributable::numAttributes); + type.method("contains_attribute", &Attributable::containsAttribute); + type.method("comment", &Attributable::comment); + type.method("set_comment!", &Attributable::setComment); + type.method("series_flush", static_cast( + &Attributable::seriesFlush)); +} diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp new file mode 100644 index 0000000000..b9f0e82e94 --- /dev/null +++ b/src/binding/julia/Attribute.cpp @@ -0,0 +1,14 @@ +// Attribute + +#include "defs.hpp" + +void define_julia_Attribute(jlcxx::Module &mod) { + auto type = mod.add_type("Attribute"); + + type.method("dtype1", [](const Attribute &attr) { return attr.dtype; }); + +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("get1_" NAME, &Attribute::get); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp new file mode 100644 index 0000000000..ade27dbc8c --- /dev/null +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -0,0 +1,22 @@ +// BaseRecordComponent + +#include "defs.hpp" + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { + typedef Attributable type; +}; +} // namespace jlcxx + +void define_julia_BaseRecordComponent(jlcxx::Module &mod) { + + auto type = mod.add_type( + "BaseRecordComponent", jlcxx::julia_base_type()); + + type.method("unit_SI", &BaseRecordComponent::unitSI); + type.method("reset_datatype1!", &BaseRecordComponent::resetDatatype); + type.method("get_datatype1", &BaseRecordComponent::getDatatype); + type.method("is_constant", &BaseRecordComponent::constant); + // TODO: availableChunks +} diff --git a/src/binding/julia/Container.cpp b/src/binding/julia/Container.cpp new file mode 100644 index 0000000000..ab2fc2cb18 --- /dev/null +++ b/src/binding/julia/Container.cpp @@ -0,0 +1,3 @@ +#include "Container.hpp" + +std::unique_ptr julia_Container_type; diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp new file mode 100644 index 0000000000..f5af677dcc --- /dev/null +++ b/src/binding/julia/Container.hpp @@ -0,0 +1,83 @@ +#ifndef CONTAINER_HPP +#define CONTAINER_HPP + +// Container + +#include "defs.hpp" + +#include +#include + +// Define supertype relationships +namespace jlcxx { +template struct SuperType> { + typedef Attributable type; +}; +} // namespace jlcxx + +// TODO: use std::optional instead of std::unique_ptr +typedef jlcxx::TypeWrapper< + jlcxx::Parametric, jlcxx::TypeVar<2>>> + julia_Container_type_t; +extern std::unique_ptr julia_Container_type; + +template +void define_julia_Container(jlcxx::Module &mod) { + if (!julia_Container_type) + julia_Container_type = std::make_unique( + mod.add_type, jlcxx::TypeVar<2>>>( + "Container", jlcxx::julia_base_type())); + + julia_Container_type->apply>([](auto type) { + using ContainerT = typename decltype(type)::type; + using key_type = typename ContainerT::key_type; + using mapped_type = typename ContainerT::mapped_type; + using size_type = typename ContainerT::size_type; + static_assert(std::is_same_v); + static_assert(std::is_same_v); + + type.template constructor(); + + type.method("empty1", &ContainerT::empty); + type.method("length1", &ContainerT::size); + type.method("empty1!", &ContainerT::clear); + type.method("getindex1", + static_cast( + &ContainerT::at)); + type.method("get1!", + [](ContainerT &cont, const key_type &key) -> mapped_type & { + return cont[key]; + }); + type.method("setindex1!", + [](ContainerT &cont, const mapped_type &value, + const key_type &key) { return cont[key] = value; }); + type.method("count1", &ContainerT::count); + type.method("contains1", &ContainerT::contains); + type.method("delete1!", + static_cast( + &ContainerT::erase)); + type.method("keys1", [](const ContainerT &cont) { + std::vector res; + res.reserve(cont.size()); + for (auto iter = cont.begin(); iter != cont.end(); ++iter) + res.push_back(iter->first); + return res; + }); + // type.method("values1", [](const ContainerT &cont) { + // std::vector res; + // res.reserve(cont.size()); + // for (auto iter = cont.begin(); iter != cont.end(); ++iter) + // res.push_back(&iter->second); + // return res; + // }); + // type.method("collect1", [](const ContainerT &cont) { + // std::vector> res; + // res.reserve(cont.size()); + // for (auto iter = cont.begin(); iter != cont.end(); ++iter) + // res.emplace_back(iter->first, &iter->second); + // return res; + // }); + }); +} + +#endif // #ifndef CONTAINER_HPP diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp new file mode 100644 index 0000000000..1e0638d243 --- /dev/null +++ b/src/binding/julia/Dataset.cpp @@ -0,0 +1,23 @@ +// Dataset + +#include "defs.hpp" + +void define_julia_Dataset(jlcxx::Module &mod) { + auto type = mod.add_type("Dataset"); + + type.constructor(); + type.constructor(); + type.constructor(); + + type.method("extend!", &Dataset::extend); + type.method("set_chunk_size!", &Dataset::setChunkSize); + type.method("set_compression!", &Dataset::setCompression); + type.method("set_custom_transform!", &Dataset::setCustomTransform); + type.method("extent1", [](const Dataset &d) { return d.extent; }); + type.method("dtype1", [](const Dataset &d) { return d.dtype; }); + type.method("rank1", [](const Dataset &d) { return d.rank; }); + type.method("chunk_size1", [](const Dataset &d) { return d.chunkSize; }); + type.method("compression", [](const Dataset &d) { return d.compression; }); + type.method("transform", [](const Dataset &d) { return d.transform; }); + type.method("options", [](const Dataset &d) { return d.options; }); +} diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp new file mode 100644 index 0000000000..8f46f80c2c --- /dev/null +++ b/src/binding/julia/Datatype.cpp @@ -0,0 +1,35 @@ +// Datatype + +#include "defs.hpp" + +void define_julia_Datatype(jlcxx::Module &mod) { + mod.add_bits("Datatype", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + +#define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE + mod.set_const("DATATYPE", Datatype::DATATYPE); + mod.set_const("UNDEFINED", Datatype::UNDEFINED); + + mod.set_const("openPMD_datatypes", openPMD_Datatypes); + // mod.method("determine_datatype", determineDatatype); + mod.method("to_bytes1", toBytes); + mod.method("to_bits1", toBits); + mod.method("is_vector1", isVector); + mod.method("is_floating_point1", (bool (*)(Datatype))isFloatingPoint); + mod.method("is_complex_floating_point1", + static_cast(isComplexFloatingPoint)); + mod.method("is_integer1", (std::tuple(*)(Datatype))isInteger); + // isSameFloatingPoint + // isSameComplexFloatingPoint + // isSameInteger + mod.method("is_same1", isSame); + mod.method("basic_datatype1", basicDatatype); + mod.method("to_vector_type1", toVectorType); + mod.method("datatype_to_string1", datatypeToString); + mod.method("string_to_datatype1", stringToDatatype); + mod.method("warn_wrong_datatype1", warnWrongDtype); + // mod.method("==", operator==); + // mod.method("!=", operator!=); +} diff --git a/src/binding/julia/Format.cpp b/src/binding/julia/Format.cpp new file mode 100644 index 0000000000..dec3d96eec --- /dev/null +++ b/src/binding/julia/Format.cpp @@ -0,0 +1,18 @@ +// IO/Format + +#include "defs.hpp" + +void define_julia_Format(jlcxx::Module &mod) { + mod.add_bits("Format", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("HDF5", Format::HDF5); + mod.set_const("ADIOS1", Format::ADIOS1); + mod.set_const("ADIOS2", Format::ADIOS2); + mod.set_const("ADIOS2_SST", Format::ADIOS2_SST); + mod.set_const("ADIOS2_SSC", Format::ADIOS2_SSC); + mod.set_const("JSON", Format::JSON); + mod.set_const("DUMMY", Format::DUMMY); + mod.method("determine_format", determineFormat); + mod.method("suffix", suffix); +} diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp new file mode 100644 index 0000000000..6ff8c1de3f --- /dev/null +++ b/src/binding/julia/Iteration.cpp @@ -0,0 +1,30 @@ +// Iteration + +#include "defs.hpp" + +#include + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { typedef Attributable type; }; +} // namespace jlcxx + +void define_julia_Iteration(jlcxx::Module &mod) { + auto type = mod.add_type("Iteration", + jlcxx::julia_base_type()); + + type.method("time1", &Iteration::time); + type.method("set_time!", &Iteration::setTime); + type.method("dt", &Iteration::dt); + type.method("set_dt!", &Iteration::setDt); + type.method("time_unit_SI", &Iteration::timeUnitSI); + type.method("set_time_unit_SI!", &Iteration::setTimeUnitSI); + type.method("close1", + static_cast(&Iteration::close)); + type.method("open", &Iteration::open); + type.method("closed", &Iteration::closed); + type.method("closed_by_writer", &Iteration::closedByWriter); + type.method("meshes", + [](Iteration &iter) -> Container & { return iter.meshes; }); + // TODO: particles +} diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp new file mode 100644 index 0000000000..7a562cf602 --- /dev/null +++ b/src/binding/julia/Mesh.cpp @@ -0,0 +1,72 @@ +// Mesh + +#include "defs.hpp" + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { + typedef Container type; +}; +} // namespace jlcxx + +void define_julia_Mesh(jlcxx::Module &mod) { + + // Mesh::Geometry + mod.add_bits("Geometry", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("cartesian", Mesh::Geometry::cartesian); + mod.set_const("theta_mode", Mesh::Geometry::thetaMode); + mod.set_const("cylindrical", Mesh::Geometry::cylindrical); + mod.set_const("spherical", Mesh::Geometry::spherical); + mod.set_const("other", Mesh::Geometry::other); + + // Mesh::DataOrder + mod.add_bits("DataOrder", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("C", Mesh::DataOrder::C); + mod.set_const("F", Mesh::DataOrder::F); + + // Mesh + auto type = mod.add_type( + "Mesh", + // We don't wrap BaseRecord for simplicity. We thus need to declare + // Container as our supertype. + jlcxx::julia_base_type>()); + + // These two functions come from our superclass + // BaseRecord. We declare them as if they were our own. + type.method("unit_dimension", &Mesh::unitDimension); + type.method("isscalar", &Mesh::scalar); + + type.method("geometry", &Mesh::geometry); + type.method("set_geometry!", static_cast( + &Mesh::setGeometry)); + type.method("geometry_parameters", &Mesh::geometryParameters); + type.method("set_geometry_parameters!", &Mesh::setGeometryParameters); + type.method("data_order", &Mesh::dataOrder); + type.method("set_data_order!", &Mesh::setDataOrder); + type.method("axis_labels", &Mesh::axisLabels); + type.method("set_axis_labels1!", &Mesh::setAxisLabels); + type.method("grid_spacing", &Mesh::gridSpacing); + type.method("set_grid_spacing1!", &Mesh::setGridSpacing); + type.method("grid_global_offset", &Mesh::gridGlobalOffset); + type.method("set_grid_global_offset1!", &Mesh::setGridGlobalOffset); + type.method("grid_unit_SI", &Mesh::gridUnitSI); + type.method("set_grid_unit_SI!", &Mesh::setGridUnitSI); + type.method("set_unit_dimension1!", [](Mesh &mesh, + const array7 &unitDimension) { + return mesh.setUnitDimension(std::map{ + {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, + {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, + {UnitDimension::T, unitDimension[uint8_t(UnitDimension::T)]}, + {UnitDimension::I, unitDimension[uint8_t(UnitDimension::I)]}, + {UnitDimension::theta, unitDimension[uint8_t(UnitDimension::theta)]}, + {UnitDimension::N, unitDimension[uint8_t(UnitDimension::N)]}, + {UnitDimension::J, unitDimension[uint8_t(UnitDimension::J)]}, + }); + }); + type.method("time_offset", &Mesh::timeOffset); + type.method("set_time_offset!", &Mesh::setTimeOffset); +} diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp new file mode 100644 index 0000000000..7a80e48225 --- /dev/null +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -0,0 +1,22 @@ +// MeshRecordComponent + +#include "defs.hpp" + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { + typedef RecordComponent type; +}; +} // namespace jlcxx + +void define_julia_MeshRecordComponent(jlcxx::Module &mod) { + auto type = mod.add_type( + "MeshRecordComponent", jlcxx::julia_base_type()); + + type.method("position1", &MeshRecordComponent::position); + type.method("set_position1!", &MeshRecordComponent::setPosition); +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("make_constant1_" NAME, &MeshRecordComponent::makeConstant); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp new file mode 100644 index 0000000000..c3974e3ddc --- /dev/null +++ b/src/binding/julia/RecordComponent.cpp @@ -0,0 +1,89 @@ +// RecordComponent + +#include "defs.hpp" + +#include +#include +#include +#include + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { + typedef BaseRecordComponent type; +}; +} // namespace jlcxx + +namespace { +template std::shared_ptr capture_vector(std::vector vec) { + if constexpr (std::is_same_v) { + // Copy the vector, because std::vector is special + T *dataptr = new T[vec.size()]; + std::shared_ptr ptr(dataptr, std::default_delete()); + std::copy(vec.begin(), vec.end(), dataptr); + return ptr; + } else { + // Capture the vector + T *dataptr = vec.data(); + std::shared_ptr ptr(dataptr, [vec = std::move(vec)](T *p) { + /* We moved the vector into the anonymous function, and thus it will be + * destructed when the anonymous function is destructed. There is no need + * to call a destructor manually. */ + }); + return ptr; + } +} +} // namespace + +void define_julia_RecordComponent(jlcxx::Module &mod) { + + // RecordComponent::Allocation + mod.add_bits("Allocation", + jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("USER", RecordComponent::Allocation::USER); + mod.set_const("API", RecordComponent::Allocation::API); + mod.set_const("AUTO", RecordComponent::Allocation::AUTO); + + auto type = mod.add_type( + "RecordComponent", jlcxx::julia_base_type()); + + type.method("set_unit_SI!", &RecordComponent::setUnitSI); + type.method("reset_dataset!", &RecordComponent::resetDataset); + type.method("get_dimensionality1", &RecordComponent::getDimensionality); + type.method("get_extent1", &RecordComponent::getExtent); +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("make_constant1_" NAME, &RecordComponent::makeConstant); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE + type.method( + "make_empty1", + static_cast( + &RecordComponent::makeEmpty)); + type.method("empty1", &RecordComponent::empty); +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method( \ + "load_chunk1_" NAME, \ + static_cast (RecordComponent::*)(Offset, Extent)>( \ + &RecordComponent::loadChunk)); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("store_chunk1_" NAME, \ + static_cast, \ + Offset, Extent)>( \ + &RecordComponent::storeChunk)); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ + std::vector data, \ + Offset offset, Extent extent) { \ + std::shared_ptr ptr(capture_vector(std::move(data))); \ + comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ + }); \ + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE + type.method("SCALAR1", []() { return RecordComponent::SCALAR; }); +} diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp new file mode 100644 index 0000000000..57a803c980 --- /dev/null +++ b/src/binding/julia/Series.cpp @@ -0,0 +1,78 @@ +// Series + +#include "defs.hpp" + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { typedef Attributable type; }; +template <> struct SuperType { typedef SeriesImpl type; }; +} // namespace jlcxx + +void define_julia_Series(jlcxx::Module &mod) { + + // SeriesImpl + { + auto type = mod.add_type( + "SeriesImpl", jlcxx::julia_base_type()); + + type.method("openPMD_version", &SeriesImpl::openPMD); + type.method("set_openPMD_version!", &SeriesImpl::setOpenPMD); + type.method("openPMD_extension", &SeriesImpl::openPMDextension); + type.method("set_openPMD_extension!", &SeriesImpl::setOpenPMDextension); + type.method("base_path", &SeriesImpl::basePath); + type.method("set_base_path!", &SeriesImpl::setBasePath); + type.method("meshes_path", &SeriesImpl::meshesPath); + type.method("set_meshes_path!", &SeriesImpl::setMeshesPath); + type.method("particles_path", &SeriesImpl::particlesPath); + type.method("set_particles_path!", &SeriesImpl::setParticlesPath); + type.method("author", &SeriesImpl::author); + type.method("set_author!", &SeriesImpl::setAuthor); + type.method("software", &SeriesImpl::software); + type.method("set_software!", + static_cast( + &SeriesImpl::setSoftware)); + type.method("set_software!", + (SeriesImpl & (SeriesImpl::*)(std::string const &))( + &SeriesImpl::setSoftware)); + type.method("software_version", &SeriesImpl::softwareVersion); + // type.method("set_software_version!", &SeriesImpl::setSoftwareVersion); + type.method("date", &SeriesImpl::date); + type.method("set_date!", &SeriesImpl::setDate); + type.method("software_dependencies", &SeriesImpl::softwareDependencies); + type.method("set_software_dependencies!", + &SeriesImpl::setSoftwareDependencies); + type.method("machine", &SeriesImpl::machine); + type.method("set_machine!", &SeriesImpl::setMachine); + // TODO: type.method("iteration_encoding", &SeriesImpl::iterationEncoding); + // TODO: type.method("set_iteration_encoding!", + // &SeriesImpl::setIterationEncoding); + type.method("iteration_format", &SeriesImpl::iterationFormat); + type.method("set_iteration_format!", &SeriesImpl::setIterationFormat); + type.method("name", &SeriesImpl::name); + type.method("set_name!", &SeriesImpl::setName); + type.method("backend", &SeriesImpl::backend); + type.method("flush1", &SeriesImpl::flush); + } + + // Series + + { + auto type = + mod.add_type("Series", jlcxx::julia_base_type()); + + type.constructor<>(); +#if openPMD_HAVE_MPI + type.constructor(); + type.constructor(); +#endif + type.constructor(); + type.constructor(); + + type.method("isvalid1", [](const Series &s) { return bool(s); }); + // TODO: iterations + // TODO: readIterations + type.method("write_iterations", &Series::writeIterations); + } +} diff --git a/src/binding/julia/UnitDimension.cpp b/src/binding/julia/UnitDimension.cpp new file mode 100644 index 0000000000..2225bcdddb --- /dev/null +++ b/src/binding/julia/UnitDimension.cpp @@ -0,0 +1,16 @@ +// IO/UnitDimension + +#include "defs.hpp" + +void define_julia_UnitDimension(jlcxx::Module &mod) { + mod.add_bits("UnitDimension", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("L", UnitDimension::L); + mod.set_const("M", UnitDimension::M); + mod.set_const("T", UnitDimension::T); + mod.set_const("I", UnitDimension::I); + mod.set_const("θ", UnitDimension::theta); + mod.set_const("N", UnitDimension::N); + mod.set_const("J", UnitDimension::J); +} diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp new file mode 100644 index 0000000000..8961c8fbee --- /dev/null +++ b/src/binding/julia/WriteIterations.cpp @@ -0,0 +1,17 @@ +// WriteIterations + +#include "defs.hpp" + +#include + +void define_julia_WriteIterations(jlcxx::Module &mod) { + using iterations_t = Container; + using key_type = typename iterations_t::key_type; + using mapped_type = typename iterations_t::mapped_type; + + auto type = mod.add_type("WriteIterations"); + type.method("get1!", + [](WriteIterations &w, const key_type &k) -> Iteration & { + return w[k]; + }); +} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp new file mode 100644 index 0000000000..75cebc0536 --- /dev/null +++ b/src/binding/julia/defs.hpp @@ -0,0 +1,150 @@ +#ifndef DEFS_HPP +#define DEFS_HPP + +#include "openPMD/openPMD.hpp" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace openPMD; + +template using array7 = std::array; + +// Generate code fo all openPMD types. Use is e.g. as follows: +// #define USE_TYPE(NAME, ENUM, TYPE) \ +// type.method("get_" NAME, &Attribute::get); +// FORALL_OPENPMD_TYPES +// #undef USE_TYPE +// +// We disable `long double` since Julia does not support this type +#define FORALL_OPENPMD_TYPES \ + USE_TYPE("CHAR", Datatype::CHAR, char) \ + USE_TYPE("UCHAR", Datatype::UCHAR, unsigned char) \ + USE_TYPE("SHORT", Datatype::SHORT, short) \ + USE_TYPE("INT", Datatype::INT, int) \ + USE_TYPE("LONG", Datatype::LONG, long) \ + USE_TYPE("LONGLONG", Datatype::LONGLONG, long long) \ + USE_TYPE("USHORT", Datatype::USHORT, unsigned short) \ + USE_TYPE("UINT", Datatype::UINT, unsigned int) \ + USE_TYPE("ULONG", Datatype::ULONG, unsigned long) \ + USE_TYPE("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ + USE_TYPE("FLOAT", Datatype::FLOAT, float) \ + USE_TYPE("DOUBLE", Datatype::DOUBLE, double) \ + /* USE_TYPE("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ + USE_TYPE("CFLOAT", Datatype::CFLOAT, std::complex) \ + USE_TYPE("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* USE_TYPE("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ + USE_TYPE("STRING", Datatype::STRING, std::string) \ + USE_TYPE("VEC_CHAR", Datatype::VEC_CHAR, std::vector) \ + USE_TYPE("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ + USE_TYPE("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ + USE_TYPE("VEC_INT", Datatype::VEC_INT, std::vector) \ + USE_TYPE("VEC_LONG", Datatype::VEC_LONG, std::vector) \ + USE_TYPE("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ + USE_TYPE("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ + USE_TYPE("VEC_UINT", Datatype::VEC_UINT, std::vector) \ + USE_TYPE("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ + USE_TYPE("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, \ + std::vector) \ + USE_TYPE("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ + USE_TYPE("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ + /* USE_TYPE("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) */ \ + USE_TYPE("VEC_CFLOAT", Datatype::VEC_CFLOAT, \ + std::vector>) \ + USE_TYPE("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, \ + std::vector>) \ + /* USE_TYPE("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ + * std::vector>) */ \ + USE_TYPE("VEC_STRING", Datatype::VEC_STRING, std::vector) \ + USE_TYPE("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + USE_TYPE("BOOL", Datatype::BOOL, bool) + +namespace { +template +std::vector> map_to_vector_pair(const std::map &m) { + std::vector> vp; + vp.reserve(m.size()); + for (const auto &p : m) + vp.push_back(p); + return vp; +} + +template +std::vector> map_to_vector_tuple(const std::map &m) { + std::vector> vp; + vp.reserve(m.size()); + for (const auto &p : m) + vp.emplace_back(p.first, p.second); + return vp; +} + +template +void add_array_type(jlcxx::Module &mod, const std::string &name) { + mod.add_type>(name) + .template constructor<>() + .template constructor &>() + .method("size1", &std::array::size) + .method("getindex1", + [](const std::array &a, std::size_t n) { return a[n]; }); + jlcxx::stl::apply_stl>(mod); +} + +template +void map_array_type(jlcxx::Module &mod, const std::string &name) { + mod.map_type>(name); + mod.method("size1", [](const std::array &a) { return a.size(); }); + mod.method("getindex1", + [](const std::array &a, std::size_t n) { return a[n]; }); + jlcxx::stl::apply_stl>(mod); +} + +template +void add_pair_type(jlcxx::Module &mod, const std::string &name) { + mod.add_type>(name) + .template constructor<>() + .template constructor &>() + .method("first", [](const std::pair &p) { return p.first; }) + .method("second", [](const std::pair &p) { return p.second; }); + jlcxx::stl::apply_stl>(mod); +} + +} // namespace + +namespace jlcxx { +template <> struct IsMirroredType> : std::false_type {}; +} // namespace jlcxx + +// We use one function per header file +void define_julia_Access(jlcxx::Module &mod); +void define_julia_Attributable(jlcxx::Module &mod); +void define_julia_Attribute(jlcxx::Module &mod); +void define_julia_BaseRecordComponent(jlcxx::Module &mod); +template +void define_julia_Container(jlcxx::Module &mod); +void define_julia_Dataset(jlcxx::Module &mod); +void define_julia_Datatype(jlcxx::Module &mod); +void define_julia_Format(jlcxx::Module &mod); +void define_julia_Iteration(jlcxx::Module &mod); +void define_julia_Mesh(jlcxx::Module &mod); +void define_julia_MeshRecordComponent(jlcxx::Module &mod); +void define_julia_RecordComponent(jlcxx::Module &mod); +void define_julia_Series(jlcxx::Module &mod); +void define_julia_UnitDimension(jlcxx::Module &mod); +void define_julia_WriteIterations(jlcxx::Module &mod); +void define_julia_version(jlcxx::Module &mod); + +#endif // #ifndef DEFS_HPP diff --git a/src/binding/julia/openPMD.cpp b/src/binding/julia/openPMD.cpp new file mode 100644 index 0000000000..4cbd208553 --- /dev/null +++ b/src/binding/julia/openPMD.cpp @@ -0,0 +1,49 @@ +#include "defs.hpp" + +#include "Container.hpp" + +#include + +//////////////////////////////////////////////////////////////////////////////// + +JLCXX_MODULE define_julia_module(jlcxx::Module &mod) { + add_array_type(mod, "array_double_7"); + add_pair_type(mod, "pair_string_bool"); + + // The order of these calls matters. Julia types need to be defined before + // they are used. + + // Stand-alone classes + define_julia_Access(mod); + define_julia_Datatype(mod); + define_julia_Format(mod); + define_julia_UnitDimension(mod); + // All classes below need at least Datatype + + define_julia_Attribute(mod); + define_julia_Attributable(mod); + define_julia_Dataset(mod); + + define_julia_BaseRecordComponent(mod); // needs: Attributable + define_julia_RecordComponent(mod); // needs: BaseRecordComponent + define_julia_MeshRecordComponent(mod); // needs: RecordComponent + + define_julia_Container( + mod); // needs: Attributable, MeshRecordComponent + + define_julia_Mesh(mod); // needs: Container + + define_julia_Container(mod); // needs: Attributable + + define_julia_Iteration(mod); // needs: Attributable, Container + + define_julia_Container(mod); // needs: Attributable + + define_julia_WriteIterations(mod); // needs: Iteration + + // The main class + define_julia_Series(mod); + + // Handle metadata + define_julia_version(mod); +} diff --git a/src/binding/julia/openPMD.jl/.JuliaFormatter.toml b/src/binding/julia/openPMD.jl/.JuliaFormatter.toml new file mode 100644 index 0000000000..3347951293 --- /dev/null +++ b/src/binding/julia/openPMD.jl/.JuliaFormatter.toml @@ -0,0 +1,10 @@ +style = "yas" +indent = 4 +margin = 132 +always_for_in = true +whitespace_ops_in_indices = true +whitespace_typedefs = false +remove_extra_newlines = true +import_to_using = true +pipe_to_function_call = true +short_to_long_function_def = true diff --git a/src/binding/julia/openPMD.jl/.github/workflows/CI.yml b/src/binding/julia/openPMD.jl/.github/workflows/CI.yml new file mode 100644 index 0000000000..154f1df431 --- /dev/null +++ b/src/binding/julia/openPMD.jl/.github/workflows/CI.yml @@ -0,0 +1,77 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Julia ${{matrix.version}} - ${{matrix.os}} - ${{matrix.arch}} - ${{github.event_name}} + runs-on: ${{matrix.os}} + strategy: + matrix: + # arch: [x64, x86] + # os: [ubuntu-latest, windows-latest, macOS-latest] + # version: ["1.4", "1.5", "1.6", "nightly"] + include: + - arch: "x64" + os: "ubuntu-latest" + version: "1.6" + - arch: "x64" + os: "windows-latest" + version: "1.6" + - arch: "x64" + os: "macOS-latest" + version: "1.6" + - arch: "x86" + os: "ubuntu-latest" + version: "1.6" + - arch: "x64" + os: "ubuntu-latest" + version: "nightly" + - arch: "x64" + os: "ubuntu-latest" + version: "1.5" + - arch: "x64" + os: "ubuntu-latest" + version: "1.4" + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{matrix.version}} + arch: ${{matrix.arch}} + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{runner.os}}-test-${{env.cache-name}}-${{hashFiles('**/Project.toml')}} + restore-keys: | + ${{runner.os}}-test-${{env.cache-name}}- + ${{runner.os}}-test- + ${{runner.os}}- + - uses: julia-actions/julia-buildpkg@v1 + env: + PYTHON: + - uses: julia-actions/julia-runtest@v1 + continue-on-error: ${{matrix.version == 'nightly'}} + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - run: | + julia --project=docs -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' + - run: julia --project=docs docs/make.jl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/src/binding/julia/openPMD.jl/.gitignore b/src/binding/julia/openPMD.jl/.gitignore new file mode 100644 index 0000000000..ba39cc531e --- /dev/null +++ b/src/binding/julia/openPMD.jl/.gitignore @@ -0,0 +1 @@ +Manifest.toml diff --git a/src/binding/julia/openPMD.jl/COPYING b/src/binding/julia/openPMD.jl/COPYING new file mode 100644 index 0000000000..10926e87f1 --- /dev/null +++ b/src/binding/julia/openPMD.jl/COPYING @@ -0,0 +1,675 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/src/binding/julia/openPMD.jl/COPYING.LESSER b/src/binding/julia/openPMD.jl/COPYING.LESSER new file mode 100644 index 0000000000..341c30bda4 --- /dev/null +++ b/src/binding/julia/openPMD.jl/COPYING.LESSER @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + diff --git a/src/binding/julia/openPMD.jl/Project.toml b/src/binding/julia/openPMD.jl/Project.toml new file mode 100644 index 0000000000..154d4bd30d --- /dev/null +++ b/src/binding/julia/openPMD.jl/Project.toml @@ -0,0 +1,14 @@ +name = "openPMD" +uuid = "e4c73209-6c8c-4213-807b-38d671e094ab" +authors = ["Erik Schnetter "] +version = "0.1.0" + +[deps] +CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +CxxWrap = "0.11.2" +StaticArrays = "1.2.4" +julia = "1.4" diff --git a/src/binding/julia/openPMD.jl/docs/.gitignore b/src/binding/julia/openPMD.jl/docs/.gitignore new file mode 100644 index 0000000000..a303fff203 --- /dev/null +++ b/src/binding/julia/openPMD.jl/docs/.gitignore @@ -0,0 +1,2 @@ +build/ +site/ diff --git a/src/binding/julia/openPMD.jl/docs/Project.toml b/src/binding/julia/openPMD.jl/docs/Project.toml new file mode 100644 index 0000000000..dfa65cd107 --- /dev/null +++ b/src/binding/julia/openPMD.jl/docs/Project.toml @@ -0,0 +1,2 @@ +[deps] +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" diff --git a/src/binding/julia/openPMD.jl/docs/make.jl b/src/binding/julia/openPMD.jl/docs/make.jl new file mode 100644 index 0000000000..4d3b2f7620 --- /dev/null +++ b/src/binding/julia/openPMD.jl/docs/make.jl @@ -0,0 +1,11 @@ +# Generate documentation with this command: +# (cd docs && julia --color=yes make.jl) + +push!(LOAD_PATH, "..") + +using Documenter +using openPMD + +makedocs(; sitename="openPMD", format=Documenter.HTML(), modules=[openPMD]) + +deploydocs(; repo="github.com/eschnett/openPMD.jl.git", devbranch="main", push_preview=true) diff --git a/src/binding/julia/openPMD.jl/docs/src/index.md b/src/binding/julia/openPMD.jl/docs/src/index.md new file mode 100644 index 0000000000..a3593e19c6 --- /dev/null +++ b/src/binding/julia/openPMD.jl/docs/src/index.md @@ -0,0 +1,5 @@ +# openPMD.jl + +```@autodocs +Modules = [openPMD] +``` diff --git a/src/binding/julia/openPMD.jl/src/Access.jl b/src/binding/julia/openPMD.jl/src/Access.jl new file mode 100644 index 0000000000..44b2ddbfa2 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Access.jl @@ -0,0 +1,12 @@ +# Access + +@doc """ + @enum Access begin + READ_ONLY + READ_WRITE + CREATE + end +""" Access +export Access, READ_ONLY, READ_WRITE, CREATE + +Base.hash(acc::Access, u::UInt) = hash(hash(convert(UInt, acc), u), UInt(0x0bec3b3e)) diff --git a/src/binding/julia/openPMD.jl/src/Attributable.jl b/src/binding/julia/openPMD.jl/src/Attributable.jl new file mode 100644 index 0000000000..d180011e40 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Attributable.jl @@ -0,0 +1,86 @@ +# Attributable + +@doc """ + abstract type Attributable end +""" Attributable +export Attributable + +# We cannot use `setindex!` and `getindex` for `Attributable` types +# because the concrete types might implement their own `setindex!` and +# `getindex`, which would make attributes inaccessible. +# +# @doc """ +# setindex!(attr::Attributeable, key::AbstractString, value::OpenPMDType) +# attr[key] = value +# """ Base.setindex! +# for (otype, jtype) in julia_types +# @eval begin +# Base.setindex!(attr::Attributable, value::$jtype, key::AbstractString) = set_attribute1!(attr, key, value) +# end +# end +# +# @doc """ +# getindex(attr::Attributable, key::AbstractString)::OpenPMDType +# attr[key]::Attribute +# """ Base.getindex +# Base.getindex(attr::Attributable, key::AbstractString) = get_attribute1(attr, key)[] +# +# @doc """ +# delete!(attr:Attributable, key::AbstractString) +# """ Base.delete! +# Base.delete!(attr::Attributable, key::AbstractString) = (delete_attribute1(attr, key); attr) + +@doc """ + set_attribute!(attr::Attributeable, key::AbstractString, value::OpenPMDType) +""" set_attribute! +export set_attribute! +for (otype, jtype) in julia_types + @eval begin + @cxxdereference function set_attribute!(attr::Attributable, key::AbstractString, value::$jtype) + $(Symbol("set_attribute1_", type_symbols[otype], "!"))(attr, key, wrap_vector(value)) + return attr + end + end +end + +@doc """ + get_attribute(attr::Attributable, key::AbstractString)::OpenPMDType +""" get_attribute +export get_attribute +@cxxdereference get_attribute(attr::Attributable, key::AbstractString) = get_attribute1(attr, key)[] + +@doc """ + delete_attribute!(attr:Attributable, key::AbstractString) +""" delete_attribute! +export delete_attribute! + +@doc """ + attributes(attr:Attributable)::AbstractVector{<:AbstractString} +""" attributes +export attributes + +@doc """ + num_attributes(attr:Attributable)::Int +""" num_attributes +export num_attributes +@cxxdereference num_attributes(attr::Attributable) = Int(num_attributes1(attr)) + +@doc """ + contains_attribute(attr:Attributable, key::AbstractString)::Bool +""" contains_attribute +export contains_attribute + +@doc """ + comment(attr::Attributable)::AbstractString +""" comment +export comment + +@doc """ + set_comment!(attr::Attributable, comment::AbstractString)::Attributable +""" set_comment! +export set_comment! + +@doc """ + series_flush(attr::Attributable) +""" series_flush +export series_flush diff --git a/src/binding/julia/openPMD.jl/src/Attribute.jl b/src/binding/julia/openPMD.jl/src/Attribute.jl new file mode 100644 index 0000000000..c81be68bf0 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Attribute.jl @@ -0,0 +1,25 @@ +# Attribute + +# We hide the `Attribute` class from the public; it shouldn't be necessary for Julia code. + +@doc """ + mutable struct Attribute + ... + end +""" Attribute +# export Attribute + +@cxxdereference dtype(attr::Attribute) = julia_type(dtype1(attr)) + +for (otype, jtype) in julia_types + @eval begin + @cxxdereference Base.getindex(attr::Attribute, ::Type{$jtype}) = $(Symbol("get1_", type_symbols[otype]))(attr) + end +end + +@doc """ + getindex(attr::Attribute) + attr[] +""" Base.getindex + +@cxxdereference Base.getindex(attr::Attribute) = getindex(attr, dtype(attr)) diff --git a/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl b/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl new file mode 100644 index 0000000000..b0c8f7a5f1 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl @@ -0,0 +1,28 @@ +# BaseRecordComponent + +@doc """ + abstract type BaseRecordComponent <: Attributable end +""" BaseRecordComponent +export BaseRecordComponent + +@doc """ + unit_SI(comp::BaseRecordComponent)::CxxDouble +""" unit_SI +export unit_SI + +@doc """ + reset_datatype!(comp::BaseRecordComponent, T::Type) +""" reset_datatype! +export reset_datatype! +@cxxdereference reset_datatype!(comp::BaseRecordComponent, T::Type) = reset_datatype1!(comp, openpmd_type(T)) + +@doc """ + get_datatype(comp::BaseRecordComponent)::Type +""" get_datatype +export get_datatype +@cxxdereference get_datatype(comp::BaseRecordComponent) = julia_type(get_datatype1(comp)) + +@doc """ + is_constant(comp::BaseRecordComponent)::Bool +""" is_constant +export is_constant diff --git a/src/binding/julia/openPMD.jl/src/Container.jl b/src/binding/julia/openPMD.jl/src/Container.jl new file mode 100644 index 0000000000..1dce0580f2 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Container.jl @@ -0,0 +1,65 @@ +# Container + +@doc """ + abstract type Container{T,K} <: Attributable end +""" Container +export Container + +Base.eltype(::Type{Container{T,K}}) where {T,K} = T +Base.keytype(::Type{Container{T,K}}) where {T,K} = K + +@doc """ + isempty(cont::Container) +""" Base.isempty +@cxxdereference Base.isempty(cont::Container) = empty1(cont) + +@doc """ + length(cont::Container) +""" Base.length +@cxxdereference Base.length(cont::Container) = Int(length1(cont)) + +@doc """ + empty!(cont::Container) +""" Base.empty! +@cxxdereference Base.empty!(cont::Container) = (empty1!(cont); cont) + +@doc """ + getindex(cont::Container, key) + cont[key] +""" Base.getindex +@cxxdereference Base.getindex(cont::Container, key) = getindex1(cont, key) + +@doc """ + get!(cont::Container, key) +""" Base.get! +@cxxdereference Base.get!(cont::Container, key) = get1!(cont, key) + +@doc """ + setindex!(cont::Container, value, key) + cont[key] = value +""" Base.setindex! +@cxxdereference Base.setindex!(cont::Container, value, key) = setindex1!(cont, value, key) + +@doc """ + count(cont::Container) +""" Base.count +@cxxdereference Base.count(cont::Container, key) = Int(count1(cont, key)) + +@doc """ + in(key, cont::Container) + key in cont +""" Base.in +@cxxdereference Base.in(key, cont::Container) = contains1(cont, key) + +@doc """ + delete!(cont::Container, key) +""" Base.delete! +@cxxdereference Base.delete!(cont::Container, key) = (delete1!(cont, key); cont) + +@doc """ + keys(cont::Container)::AbstractVector +""" Base.keys +@cxxdereference Base.keys(cont::Container) = keys1(cont) + +# @cxxdereference Base.values(cont::Container) = values1(cont) +# @cxxdereference Base.collect(cont::Container) = collect1(cont) diff --git a/src/binding/julia/openPMD.jl/src/Dataset.jl b/src/binding/julia/openPMD.jl/src/Dataset.jl new file mode 100644 index 0000000000..aba7cebdb5 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Dataset.jl @@ -0,0 +1,78 @@ +# Dataset + +""" + const Extent = Union{NTuple{D,Int},SVector{D,Int}} +""" +const Extent{D} = Union{NTuple{D,Int},SVector{D,Int}} +export Extent + +""" + const Offset = Union{NTuple{D,Int},SVector{D,Int}} +""" +const Offset{D} = Union{NTuple{D,Int},SVector{D,Int}} +export Offset + +@doc """ + mutable struct Dataset + .... + end + Dataset(::Type{<:OpenPMDType}, extent::Extent, options::AbstractString="{}") + Dataset(extent::Extent) +""" Dataset +export Dataset + +@doc """ + extend!(dset::Dataset, newextent::Extent) +""" extend! +export extend! + +@doc """ + set_chunk_size!(dset::Dataset, chunk_size::Extent) +""" set_chunk_size! +export set_chunk_size! + +@doc """ + set_compression!(dset::Dataset, compression::AbstractString, level::Int) +""" set_compression! +export set_compression! + +@doc """ + set_custom_transform!(dset::Dataset, transform::AbstractString) +""" set_custom_transform! +export set_custom_transform! + +""" + size(dset::Dataset) +""" +@cxxdereference Base.size(dset::Dataset) = Tuple(extent1(dset)) + +""" + eltype(dset::Dataset) +""" +@cxxdereference Base.eltype(dset::Dataset) = julia_type(dtype1(dset)) + +""" + ndims(dset::Dataset) +""" +@cxxdereference Base.ndims(dset::Dataset) = Int(rank1(dset)) + +""" + chunk_size(dset::Dataset) +""" +@cxxdereference chunk_size(dset::Dataset) = Tuple(chunk_size1(dset)) +export chunk_size + +@doc """ + compression(dset::Dataset)::AbstractString +""" compression +export compression + +@doc """ + transform(dset::Dataset)::AbstractString +""" transform +export transform + +@doc """ + options(dset::Dataset)::AbstractString +""" options +export options diff --git a/src/binding/julia/openPMD.jl/src/Datatype.jl b/src/binding/julia/openPMD.jl/src/Datatype.jl new file mode 100644 index 0000000000..bfb046d116 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Datatype.jl @@ -0,0 +1,245 @@ +# Datatype + +@doc """ + @enum Datatype begin + CHAR => CxxChar + UCHAR => CxxUChar + SHORT => CxxShort + INT => CxxInt + LONG => CxxLong, + LONGLONG => CxxLongLong + USHORT => CxxUShort + UINT => CxxUInt + ULONG => CxxULong, + ULONGLONG => CxxULongLong + FLOAT => CxxFloat + DOUBLE => CxxDouble, + CFLOAT => Complex{CxxFloat} + CDOUBLE => Complex{CxxDouble} + STRING => String, + VEC_CHAR => Vector{CxxChar} + VEC_UCHAR => Vector{CxxUChar} + VEC_SHORT => Vector{CxxShort}, + VEC_INT => Vector{CxxInt} + VEC_LONG => Vector{CxxLong} + VEC_LONGLONG => Vector{CxxLongLong}, + VEC_USHORT => Vector{CxxUShort} + VEC_UINT => Vector{CxxUInt} + VEC_ULONG => Vector{CxxULong}, + VEC_ULONGLONG => Vector{CxxULongLong} + VEC_FLOAT => Vector{CxxFloat}, + VEC_DOUBLE => Vector{CxxDouble} + VEC_CFLOAT => Vector{Complex{CxxFloat}}, + VEC_CDOUBLE => Vector{Complex{CxxDouble}} + VEC_STRING => Vector{String} + BOOL => CxxBool, + ARR_DBL_7 => SVector{7,CxxDouble}) + end +""" Datatype +export Datatype, CHAR, UCHAR, SHORT, INT, LONG, LONGLONG, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, CFLOAT, CDOUBLE, STRING, + VEC_CHAR, VEC_UCHAR, VEC_SHORT, VEC_INT, VEC_LONG, VEC_LONGLONG, VEC_USHORT, VEC_UINT, VEC_ULONG, VEC_ULONGLONG, VEC_FLOAT, + VEC_DOUBLE, VEC_CFLOAT, VEC_CDOUBLE, VEC_STRING, ARR_DBL_7, BOOL + +# CxxWrap promises these types, but doesn't define them +const CxxDouble = Cdouble +const CxxFloat = Cfloat +const CxxInt = Cint +const CxxShort = Cshort +const CxxUInt = Cuint +const CxxUShort = Cushort +export CxxDouble, CxxFloat, CxxInt, CxxShort, CxxUInt, CxxUShort + +Base.hash(b::CxxBool, u::UInt) = hash(hash(Bool(b), u), UInt(0x4c87662d)) + +# We cannot use this definition for equality. It leads to `LONG` == +# `LONGLONG` on some systems. + +# Base.:(==)(d::Datatype, e::Datatype) = is_same1(d, e) +# function Base.hash(d::Datatype, h::UInt) +# isvec = is_vector1(d) +# isint, issig = is_integer1(d) +# isfp = is_floating_point1(d) +# iscfp = is_complex_floating_point1(d) +# bits = to_bits1(d) +# return hash(0x6b224312, hash(isvec, hash(isint, hash(issig, hash(isfp, hash(iscfp, hash(bits, h))))))) +# end + +Base.hash(d::Datatype, u::UInt) = hash(hash(convert(UInt, d), u), UInt(0x6b224312)) + +# Convert between Julia types and OpenPMD type ids + +const type_symbols = Dict{Datatype,Symbol}(CHAR => :CHAR, UCHAR => :UCHAR, SHORT => :SHORT, INT => :INT, LONG => :LONG, + LONGLONG => :LONGLONG, USHORT => :USHORT, UINT => :UINT, ULONG => :ULONG, + ULONGLONG => :ULONGLONG, FLOAT => :FLOAT, DOUBLE => :DOUBLE, CFLOAT => :CFLOAT, + CDOUBLE => :CDOUBLE, STRING => :STRING, VEC_CHAR => :VEC_CHAR, VEC_UCHAR => :VEC_UCHAR, + VEC_SHORT => :VEC_SHORT, VEC_INT => :VEC_INT, VEC_LONG => :VEC_LONG, + VEC_LONGLONG => :VEC_LONGLONG, VEC_USHORT => :VEC_USHORT, VEC_UINT => :VEC_UINT, + VEC_ULONG => :VEC_ULONG, VEC_ULONGLONG => :VEC_ULONGLONG, VEC_FLOAT => :VEC_FLOAT, + VEC_DOUBLE => :VEC_DOUBLE, VEC_CFLOAT => :VEC_CFLOAT, VEC_CDOUBLE => :VEC_CDOUBLE, + VEC_STRING => :VEC_STRING, ARR_DBL_7 => :ARR_DBL_7, BOOL => :BOOL) +const julia_types = Dict{Datatype,Type}(CHAR => CxxChar, UCHAR => CxxUChar, SHORT => CxxShort, INT => CxxInt, LONG => CxxLong, + LONGLONG => CxxLongLong, USHORT => CxxUShort, UINT => CxxUInt, ULONG => CxxULong, + ULONGLONG => CxxULongLong, FLOAT => CxxFloat, DOUBLE => CxxDouble, + CFLOAT => Complex{CxxFloat}, CDOUBLE => Complex{CxxDouble}, STRING => String, + VEC_CHAR => Vector{CxxChar}, VEC_UCHAR => Vector{CxxUChar}, VEC_SHORT => Vector{CxxShort}, + VEC_INT => Vector{CxxInt}, VEC_LONG => Vector{CxxLong}, VEC_LONGLONG => Vector{CxxLongLong}, + VEC_USHORT => Vector{CxxUShort}, VEC_UINT => Vector{CxxUInt}, VEC_ULONG => Vector{CxxULong}, + VEC_ULONGLONG => Vector{CxxULongLong}, VEC_FLOAT => Vector{CxxFloat}, + VEC_DOUBLE => Vector{CxxDouble}, VEC_CFLOAT => Vector{Complex{CxxFloat}}, + VEC_CDOUBLE => Vector{Complex{CxxDouble}}, VEC_STRING => Vector{String}, + ARR_DBL_7 => SVector{7,CxxDouble}, BOOL => CxxBool) +function julia_type(d::Datatype) + T = get(julia_types, d, nothing) + T ≡ nothing && error("unknown Datatype $d") + return T +end + +openpmd_type(::Type{CxxChar}) = CHAR +openpmd_type(::Type{CxxUChar}) = UCHAR +openpmd_type(::Type{CxxShort}) = SHORT +openpmd_type(::Type{CxxInt}) = INT +openpmd_type(::Type{CxxLong}) = LONG +openpmd_type(::Type{CxxLongLong}) = LONGLONG +openpmd_type(::Type{CxxUShort}) = USHORT +openpmd_type(::Type{CxxUInt}) = UINT +openpmd_type(::Type{CxxULong}) = ULONG +openpmd_type(::Type{CxxULongLong}) = ULONGLONG +openpmd_type(::Type{CxxFloat}) = FLOAT +openpmd_type(::Type{CxxDouble}) = DOUBLE +openpmd_type(::Type{Complex{CxxFloat}}) = CFLOAT +openpmd_type(::Type{Complex{CxxDouble}}) = CDOUBLE +openpmd_type(::Type{String}) = STRING +openpmd_type(::Type{Vector{CxxChar}}) = VEC_CHAR +openpmd_type(::Type{Vector{CxxUChar}}) = VEC_UCHAR +openpmd_type(::Type{Vector{CxxShort}}) = VEC_SHORT +openpmd_type(::Type{Vector{CxxInt}}) = VEC_INT +openpmd_type(::Type{Vector{CxxLong}}) = VEC_LONG +openpmd_type(::Type{Vector{CxxLongLong}}) = VEC_LONGLONG +openpmd_type(::Type{Vector{CxxUShort}}) = VEC_USHORT +openpmd_type(::Type{Vector{CxxUInt}}) = VEC_UINT +openpmd_type(::Type{Vector{CxxULong}}) = VEC_ULONG +openpmd_type(::Type{Vector{CxxULongLong}}) = VEC_ULONGLONG +openpmd_type(::Type{Vector{CxxFloat}}) = VEC_FLOAT +openpmd_type(::Type{Vector{CxxDouble}}) = VEC_DOUBLE +openpmd_type(::Type{Vector{Complex{CxxFloat}}}) = VEC_CFLOAT +openpmd_type(::Type{Vector{Complex{CxxDouble}}}) = VEC_CDOUBLE +openpmd_type(::Type{Vector{String}}) = VEC_STRING +openpmd_type(::Type{SVector{7,CxxDouble}}) = ARR_DBL_7 +openpmd_type(::Type{CxxBool}) = BOOL + +""" + openPMD_datatypes::AbstractVector{Datatype} +""" +openPMD_datatypes +export openPMD_datatypes + +""" + OpenPMDType = Union{...} +""" +const OpenPMDType = Union{CxxChar,CxxUChar,CxxShort,CxxInt,CxxLong,CxxLongLong,CxxUShort,CxxUInt,CxxULong,CxxULongLong,CxxFloat, + CxxDouble,Complex{CxxFloat},Complex{CxxDouble},String,Vector{CxxChar},Vector{CxxUChar},Vector{CxxShort}, + Vector{CxxInt},Vector{CxxLong},Vector{CxxLongLong},Vector{CxxUShort},Vector{CxxUInt},Vector{CxxULong}, + Vector{CxxULongLong},Vector{CxxFloat},Vector{CxxDouble},Vector{Complex{CxxFloat}}, + Vector{Complex{CxxDouble}},Vector{String},SVector{7,CxxDouble},CxxBool} +export OpenPMDType + +""" + determine_datatype(::Type)::Datatype +""" +determine_datatype(T::Type) = openpmd_type(T) +export determine_datatype + +""" + to_bytes(::Type)::Int +""" +to_bytes(T::Type) = Int(to_bytes1(openpmd_type(T))) +export to_bytes + +""" + to_bits(::Type)::Int +""" +to_bits(T::Type) = Int(to_bits1(openpmd_type(T))) +export to_bits + +""" + is_vector(::Type)::Bool +""" +is_vector(T::Type) = is_vector1(openpmd_type(T)) +export is_vector + +""" + is_floating_point(::Type)::Bool +""" +is_floating_point(T::Type) = is_floating_point1(openpmd_type(T)) +export is_floating_point + +""" + is_complex_floating_point(::Type)::Bool +""" +is_complex_floating_point(T::Type) = is_complex_floating_point1(openpmd_type(T)) +export is_complex_floating_point + +""" + is_integer(::Type)::Tuple{Bool,Bool} + +Whether the type is an integer (first tuple element), and if so, +whether it is signed (second tuple element). +""" +is_integer(T::Type) = Tuple{Bool,Bool}(is_integer1(openpmd_type(T))) +export is_integer + +""" + is_same(::Type, ::Type)::Bool +""" +is_same(T1::Type, T2::Type) = is_same1(openpmd_type(T1), openpmd_type(T2)) +export is_same + +# """ +# is_same_floating_point(::Type, ::Type)::Bool +# """ +# is_same_floating_point(T1::Type, T2::Type) = is_same_floating_point(openpmd_type(T1), openpmd_type(T2)) +# export is_same_floating_point +# +# """ +# is_same_complex_floating_point(::Type, ::Type)::Bool +# """ +# is_same_complex_floating_point(T!::Type, T2::Type) = is_same_complex_floating_point(openpmd_type(T1), openpmd_type(T2)) +# export is_same_complex_floating_point +# +# """ +# is_same_integer(::Type, ::Type)::Bool +# """ +# is_same_integer(T1::Type, T2::Type) = is_same_integer(openpmd_type(T1), openpmd_type(T2)) +# export is_same_integer + +""" + basic_datatype(::Type)::Type +""" +basic_datatype(T::Type) = julia_type(basic_datatype1(openpmd_type(T))) +export basic_datatype + +""" + to_vector_type(::Type)::Type +""" +to_vector_type(T::Type) = julia_type(to_vector_type1(openpmd_type(T))) +export to_vector_type + +""" + datatype_to_string(::Type)::AbstractString +""" +datatype_to_string(T::Type) = datatype_to_string1(openpmd_type(T)) +export datatype_to_string + +""" + string_to_datatype(str::AbstractString)::Type +""" +string_to_datatype(str::AbstractString) = julia_type(string_to_datatype1(str)) +export string_to_datatype + +""" + warn_wrong_dtype(key::AbstractString, ::Type{Store}, ::Type{Request}) where {Store,Request} +""" +function warn_wrong_dtype1(key::AbstractString, ::Type{Store}, ::Type{Request}) where {Store,Request} + return warn_wrong_dtype(key, openpmd_type(Store), openpmd_type(Request)) +end +export warn_wrong_dtype diff --git a/src/binding/julia/openPMD.jl/src/Format.jl b/src/binding/julia/openPMD.jl/src/Format.jl new file mode 100644 index 0000000000..e5151137e0 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Format.jl @@ -0,0 +1,28 @@ +# Format + +@doc """ + @enum Format begin + HDF5 + ADIOS1 + ADIOS2 + ADIOS2_SST + ADIOS2_SSC + JSON + DUMMY + end +""" Format +export Format, HDF5, ADIOS1, ADIOS2, ADIOS2_SST, ADIOS2_SSC, JSON, DUMMY + +Base.hash(fmt::Format, u::UInt) = hash(hash(convert(UInt, fmt), u), UInt(0x2d9a9364)) + +""" + determine_format(filename::AbstractString)::Format +""" +function determine_format end +export determine_format + +""" + suffix(format::Format)::AbstractString +""" +function suffix end +export suffix diff --git a/src/binding/julia/openPMD.jl/src/Iteration.jl b/src/binding/julia/openPMD.jl/src/Iteration.jl new file mode 100644 index 0000000000..4c45f01a7a --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Iteration.jl @@ -0,0 +1,58 @@ +# Iteration + +@doc """ + mutable struct Iteration <: Attributable + ... + end +""" Iteration +export Iteration + +@doc """ + time(iter::Iteration)::CxxDouble +""" Base.time +@cxxdereference Base.time(iter) = time1(iter) + +@doc """ + set_time!(iter::Iteration, time::CxxDouble) +""" set_time! +export set_time! + +@doc """ + dt(iter::Iteration)::CxxDouble +""" dt +export dt + +@doc """ + set_dt!(iter::Iteration, dt::CxxDouble) +""" set_dt! +export set_dt! + +@doc """ + time_unit_SI(iter::Iteration)::CxxDouble +""" time_unit_SI +export time_unit_SI + +@doc """ + set_time_unit_SI!(iter::Iteration, time_unit_SI::CxxDouble) +""" set_time_unit_SI! +export set_time_unit_SI! + +@doc """ + close(iter::Iteration; flush::Bool=true) +""" Base.close +@cxxdereference Base.close(iter::Iteration; flush::Bool=true) = close1(iter, flush) + +@doc """ + closed(iter::Iteration)::Bool +""" closed +export closed + +@doc """ + closed_by_writer(iter::Iteration)::Bool +""" closed_by_writer +export closed_by_writer + +@doc """ + meshes(iter::Iteration)::Container{Mesh} +""" meshes +export meshes diff --git a/src/binding/julia/openPMD.jl/src/Mesh.jl b/src/binding/julia/openPMD.jl/src/Mesh.jl new file mode 100644 index 0000000000..4c5e9ff481 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Mesh.jl @@ -0,0 +1,140 @@ +# Mesh + +@doc """ + @enum Geometry begin + cartesian + theta_mode + cylindrical + spherical + other + end +""" Geometry +export Geometry, cartesian, theta_mode, cylindrical, spherical, other + +@doc """ + @enum DataOrder begin + C + F + end +""" DataOrder +export DataOrder, C, F + +@doc """ + mutable struct Mesh <: Container{MeshRecordComponent} + ... + end +""" Mesh +export Mesh + +@doc """ + unit_dimension(mesh::Mesh)::SVector{7,Double} +""" unit_dimension +export unit_dimension + +@doc """ + isscalar(mesh::Mesh)::Bool +""" isscalar +export isscalar + +@doc """ + geometry(mesh::Mesh)::Geometry +""" geometry +export geometry + +@doc """ + set_geometry!(mesh::Mesh, geom::Geometry) +""" set_geometry! +export set_geometry! + +@doc """ + geometry_parameters(mesh::Mesh)::AbstractString +""" geometry_parameters +export geometry_parameters + +@doc """ + set_geometry_parameters!(mesh::Mesh, params::AbstractString) +""" set_geometry_parameters! +export set_geometry_parameters! + +@doc """ + data_order(mesh::Mesh) +""" data_order +export data_order + +@doc """ + set_data_order!(mesh::Mesh, order::DataOrder) +""" set_data_order! +export set_data_order! + +@doc """ + axis_labels(mesh::Mesh)::AbstractVector{<:AbstractString} +""" axis_labels +export axis_labels + +@doc """ + set_axis_labels!(mesh::Mesh, labels::AbstractVector{<:AbstractString}) +""" set_axis_labels! +export set_axis_labels! +@cxxdereference function set_axis_labels!(mesh::Mesh, labels::AbstractVector{<:AbstractString}) + return set_axis_labels1!(mesh, wrap_vector(labels)) +end + +@doc """ + grid_spacing(mesh::Mesh)::AbstractVector{CxxDouble} +""" grid_spacing +export grid_spacing + +@doc """ + set_grid_spacing!(mesh::Mesh, spacing::AbstractVector{CxxDouble}) +""" set_grid_spacing! +export set_grid_spacing! +@cxxdereference set_grid_spacing!(mesh::Mesh, spacing::AbstractVector{CxxDouble}) = set_grid_spacing1!(mesh, wrap_vector(spacing)) + +@doc """ + grid_global_offset(mesh::Mesh)::AbstractVector{CxxDouble} +""" grid_global_offset +export grid_global_offset + +@doc """ + set_grid_global_offset!(mesh::Mesh, offset::AbstractVector{CxxDouble}) +""" set_grid_global_offset! +export set_grid_global_offset! +@cxxdereference function set_grid_global_offset!(mesh::Mesh, offset::AbstractVector{CxxDouble}) + return set_grid_global_offset1!(mesh, wrap_vector(offset)) +end + +@doc """ + grid_unit_SI(mesh::Mesh)::CxxDouble +""" grid_unit_SI +export grid_unit_SI + +@doc """ + set_grid_unit_SI!(mesh::Mesh, unit::CxxDouble) +""" set_grid_unit_SI! +export set_grid_unit_SI! + +@doc """ + set_unit_dimension!(mesh::Mesh, unit_dim::Dict{UnitDimension,<:AbstractFloat}) +""" set_unit_dimension! +export set_unit_dimension! +@cxxdereference function set_unit_dimension!(mesh::Mesh, unit_dim::Dict{UnitDimension,<:AbstractFloat}) + return set_unit_dimension1!(mesh, + SVector{7,Float64}(get(unit_dim, L, 0.0), get(unit_dim, M, 0.0), get(unit_dim, T, 0.0), + get(unit_dim, I, 0.0), get(unit_dim, θ, 0.0), get(unit_dim, N, 0.0), + get(unit_dim, J, 0.0))) +end + +@doc """ + time_offset(mesh::Mesh)::CxxDouble +""" time_offset +export time_offset + +@doc """ + set_time_offset!(mesh::Mesh, unit::CxxDouble) +""" set_time_offset! +export set_time_offset! + +""" + const SCALAR::AbstractString +""" +const SCALAR = SCALAR1() diff --git a/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl b/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl new file mode 100644 index 0000000000..73c3d2a6eb --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl @@ -0,0 +1,33 @@ +# MeshRecordComponent + +@doc """ + mutable struct MeshRecordComponent <: RecordComponent + ... + end +""" MeshRecordComponent +export MeshRecordComponent + +@doc """ + position(comp::MeshRecordComponent)::AbstractVector{CxxDouble} +""" Base.position +@cxxdereference Base.position(comp::MeshRecordComponent) = position1(comp) + +@doc """ + set_position!(comp::MeshRecordComponent, newpos::AbstractVector{CxxDouble}) +""" set_position! +export set_position! +@cxxdereference function set_position!(comp::MeshRecordComponent, newpos::AbstractVector{CxxDouble}) + return set_position1!(comp, wrap_vector(newpos)) +end + +@doc """ + make_constant(comp::MeshRecordComponent, value::OpenMPType) +""" make_constant +export make_constant +for (otype, jtype) in julia_types + @eval begin + @cxxdereference function make_constant(comp::MeshRecordComponent, value::$jtype) + return $(Symbol("make_constant1_", type_symbols[otype]))(comp, value) + end + end +end diff --git a/src/binding/julia/openPMD.jl/src/RecordComponent.jl b/src/binding/julia/openPMD.jl/src/RecordComponent.jl new file mode 100644 index 0000000000..075c6ac753 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/RecordComponent.jl @@ -0,0 +1,82 @@ +# RecordComponent + +@doc """ + @enum Allocation begin + USER + API + AUTO + end +""" Allocation +export Allocation, USER, API, AUTO + +@doc """ + abstract type RecordComponent <: BaseRecordComponent end +""" RecordComponent +export RecordComponent + +@doc """ + set_unit_SI!(comp::RecordComponent, unit::CxxDouble) +""" set_unit_SI! +export set_unit_SI! + +@doc """ + reset_dataset!(comp::RecordComponent, dset::Dataset) +""" reset_dataset! +export reset_dataset! + +@doc """ + ndims(comp::RecordComponent) +""" Base.ndims +@cxxdereference Base.ndims(comp::RecordComponent) = Int(get_dimensionality(comp)) + +@doc """ + size(comp::RecordComponent) +""" Base.size +@cxxdereference Base.size(comp::RecordComponent) = Tuple(get_extent1(comp)) + +@doc """ + make_constant(comp::RecordComponent, value::OpenMPType) +""" make_constant +export make_constant +for (otype, jtype) in julia_types + @eval begin + @cxxdereference function make_constant(comp::RecordComponent, value::$jtype) + return $(Symbol("make_constant1_", type_symbols[otype]))(comp, value) + end + end +end + +@doc """ + make_empty(T::Type, comp::RecordComponent, ndims::Int) +""" make_empty +export make_empty +@cxxdereference make_empty(T::Type, comp::RecordComponent, ndims::Int) = make_empty1(comp, openpmd_type(T), ndims) + +@doc """ + isempty(comp::RecordComponent) +""" Base.isempty +@cxxdereference Base.isempty(comp::RecordComponent) = empty1(comp) + +# TODO: load_chunk + +@doc """ + store_chunk(comp::RecordComponent, data::AbstractArray, offset, extent) +""" store_chunk +export store_chunk +# Object lifetime management for store_chunk: Ideally, we would ensure +# that the Julia object stays alive until openPMD has written the +# dataset. To simplify things, we currently create a temporary buffer +# that is managed by a C++ std::shared_ptr. Note that `wrap_vector` +# copies the data, which also needs to be avoided. +for (otype, jtype) in julia_types + @eval begin + @cxxdereference function store_chunk(comp::RecordComponent, data::AbstractArray{$jtype}, offset::AbstractVector, + extent::AbstractVector) + @assert ndims(offset) == ndims(extent) == ndims(comp) + @assert all(extent .>= 0) + @assert length(data) == product(extent) + return $(Symbol("store_chunk_copy1_", type_symbols[otype]))(comp, wrap_vector(reshape(value, :)), wrap_vector(offset), + wrap_vector(extent)) + end + end +end diff --git a/src/binding/julia/openPMD.jl/src/Series.jl b/src/binding/julia/openPMD.jl/src/Series.jl new file mode 100644 index 0000000000..0d582e8cbe --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/Series.jl @@ -0,0 +1,159 @@ +# Series + +@doc """ + mutable struct Series <: Attributable + ... + end + Series() + Series(filepath::AbstractString, access::Access, comm::MPI_Comm, options::AbstractString="{}") + Series(filepath::AbstractString, access::Access, options::AbstractString="{}") +""" Series +export Series + +@doc """ + openPMD_version(series::Series)::AbstractString +""" openPMD_version +export openPMD_version + +@doc """ + set_openPMD_version!(series::Series, version::AbstractString) +""" set_openPMD_version! +export set_openPMD_version! + +@doc """ + openPMD_extension(series::Series)::AbstractString +""" openPMD_extension +export openPMD_extension + +@doc """ + set_openPMD_extension!(series::Series, extension::AbstractString) +""" set_openPMD_extension! +export set_openPMD_extension! + +@doc """ + base_path(series::Series)::AbstractString +""" base_path +export base_path + +@doc """ + set_base_path!(series::Series, path::AbstractString) +""" set_base_path! +export set_base_path! + +@doc """ + meshes_path(series::Series)::AbstractString +""" meshes_path +export meshes_path + +@doc """ + set_meshes_path!(series::Series, path::AbstractString) +""" set_meshes_path! +export set_meshes_path! + +@doc """ + particles_path(series::Series)::AbstractString +""" particles_path +export particles_path + +@doc """ + set_particles_path!(series::Series, path::AbstractString) +""" set_particles_path! +export set_particles_path! + +@doc """ + author(series::Series)::AbstractString +""" author +export author + +@doc """ + set_author!(series::Series, author::AbstractString) +""" set_author! +export set_author! + +@doc """ + software(series::Series)::AbstractString +""" software +export software + +@doc """ + set_software!(series::Series, software::AbstractString, version::AbstractString="unspecified") +""" set_software! +export set_software! + +@doc """ + software_version(series::Series)::AbstractString +""" software_version +export software_version + +@doc """ + date(series::Series)::AbstractString +""" date +export date + +@doc """ + set_date!(series::Series, date::AbstractString) +""" set_date! +export set_date! + +@doc """ + software_dependencies(series::Series)::AbstractString +""" software_dependencies +export software_dependencies + +@doc """ + set_software_dependencies!(series::Series, dependencies::AbstractString) +""" set_software_dependencies! +export set_software_dependencies! + +@doc """ + machine(series::Series)::AbstractString +""" machine +export machine + +@doc """ + set_machine!(series::Series, machine::AbstractString) +""" set_machine! +export set_machine! + +# TODO: type.method("iteration_encoding", &SeriesImpl::iterationEncoding); +# TODO: type.method("set_iteration_encoding!", &SeriesImpl::setIterationEncoding); + +@doc """ + iteration_format(series::Series)::AbstractString +""" iteration_format +export iteration_format + +@doc """ + set_iteration_format!(series::Series, format::AbstractString) +""" set_iteration_format! +export set_iteration_format! + +@doc """ + name(series::Series)::AbstractString +""" name +export name + +@doc """ + set_name!(series::Series, name::AbstractString) +""" set_name! +export set_name! + +@doc """ + backend(series::Series)::AbstractString +""" backend +export backend + +@doc """ + flush(series::Series)::AbstractString +""" Base.flush +@cxxdereference Base.flush(series::SeriesImpl) = flush1(series) + +@doc """ + isvalid(series::Series) +""" Base.isvalid +@cxxdereference Base.isvalid(series::Series) = isvalid1(series) + +@doc """ + write_iterations(series::Series) +""" write_iterations +export write_iterations diff --git a/src/binding/julia/openPMD.jl/src/UnitDimension.jl b/src/binding/julia/openPMD.jl/src/UnitDimension.jl new file mode 100644 index 0000000000..b85cca2a3f --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/UnitDimension.jl @@ -0,0 +1,18 @@ +# UnitDimension + +@doc """ + @enum UnitDimension begin + L # length + M # mass + T # time + I # electric current + θ # thermodynamic temperature + N # amount of substance + J # luminous intensity + end +""" UnitDimension +export UnitDimension, L, M, T, I, θ, N, J + +Base.convert(::Type{I}, d::UnitDimension) where {I<:Integer} = convert(I, reinterpret(UInt8, d)) + +Base.hash(d::UnitDimension, u::UInt) = hash(hash(convert(UInt, d), u), UInt(0xe2ff8533)) diff --git a/src/binding/julia/openPMD.jl/src/WriteIterations.jl b/src/binding/julia/openPMD.jl/src/WriteIterations.jl new file mode 100644 index 0000000000..f3801af0c2 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/WriteIterations.jl @@ -0,0 +1,13 @@ +# WriteIterations + +@doc """ + mutable struct WriteIterations + ... + end +""" WriteIterations +export WriteIterations + +@doc """ + get!(iters::WriteIterations, key) +""" Base.get! +@cxxdereference Base.get!(iters::WriteIterations, key) = get1!(iters, key) diff --git a/src/binding/julia/openPMD.jl/src/openPMD.jl b/src/binding/julia/openPMD.jl/src/openPMD.jl new file mode 100644 index 0000000000..40290d1011 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/openPMD.jl @@ -0,0 +1,61 @@ +module openPMD + +using CxxWrap +using StaticArrays + +@wrapmodule "/Users/eschnett/src/openPMD-api/build/lib/libopenPMD_jl.dylib" + +__init__() = @initcxx + +################################################################################ + +# TODO: +# +# - do we need to worry about `jlcxx::StrictlyTypedNumber`? +# +# - do we really need all the `@cxxdereference` macros? yes we do. +# maybe we need it only for explicitly declared functions and not +# for wrapped functions? +# +# - remove all the `Bool(...)` wrappers; they are not needed +# +# - put enum values into a namespace + +################################################################################ + +# Convert Julia vectors to `StdVector`, leave all other types alone +wrap_vector(xs::AbstractVector) = StdVector(xs) +wrap_vector(x) = x + +################################################################################ + +# The order in which these files are included matters. The order here +# should mirror the order in the file `openPMD.cpp` that implements +# the respective types, constants, and functions. + +include("Access.jl") +include("Datatype.jl") +include("Format.jl") +include("UnitDimension.jl") + +include("Attribute.jl") +include("Attributable.jl") +include("Dataset.jl") + +include("Container.jl") + +include("BaseRecordComponent.jl") +include("RecordComponent.jl") +include("MeshRecordComponent.jl") + +include("Mesh.jl") + +include("Iteration.jl") + +include("WriteIterations.jl") + +include("Series.jl") + +include("version.jl") + +end diff --git a/src/binding/julia/openPMD.jl/src/version.jl b/src/binding/julia/openPMD.jl/src/version.jl new file mode 100644 index 0000000000..393c4beaa2 --- /dev/null +++ b/src/binding/julia/openPMD.jl/src/version.jl @@ -0,0 +1,34 @@ +# version + +@doc """ + get_version()::AbstractString +""" get_version +export get_version + +@doc """ + get_standard()::AbstractString +""" get_standard +export get_standard + +@doc """ + get_standard_minimum()::AbstractString +""" get_standard_minimum +export get_standard_minimum + +@doc """ + get_variants()::Dict{String,Bool} +""" get_variants +export get_variants +function get_variants() + variants1 = get_variants1() + variants = Dict{String,Bool}() + for var1 in variants1 + variants[first(var1)] = second(var1) + end + return variants +end + +@doc """ + get_file_extensions()::AbstractVector{<:AbstractString} +""" get_file_extensions +export get_file_extensions diff --git a/src/binding/julia/openPMD.jl/test/Access.jl b/src/binding/julia/openPMD.jl/test/Access.jl new file mode 100644 index 0000000000..64dcd21a28 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Access.jl @@ -0,0 +1,11 @@ +@testset "Access" begin + @test Access isa Type + @test READ_ONLY isa Access + @test READ_WRITE isa Access + @test CREATE isa Access + + @test READ_ONLY == READ_ONLY + @test READ_ONLY ≠ READ_WRITE + @test hash(READ_ONLY) isa UInt + @test hash(READ_ONLY) ≠ hash(convert(UInt, READ_ONLY)) +end diff --git a/src/binding/julia/openPMD.jl/test/Attributable.jl b/src/binding/julia/openPMD.jl/test/Attributable.jl new file mode 100644 index 0000000000..298a60fe6a --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Attributable.jl @@ -0,0 +1,22 @@ +@testset "Attributable" begin + @test Attributable isa Type + @test isabstracttype(Attributable) + + obj = series + @test obj isa Attributable + set_attribute!(obj, "hello", 42) + set_attribute!(obj, "world", [float(π)]) + @test get_attribute(obj, "hello") === 42 + @test get_attribute(obj, "world") == [float(π)] + delete_attribute!(obj, "hello") + @test !contains_attribute(obj, "hello") + @test contains_attribute(obj, "world") + @test "world" ∈ attributes(obj) + @test num_attributes(obj) ≥ 1 + + set_comment!(obj, "abc αβγ") + @test comment(obj) == "abc αβγ" + + # Don't flush or close anything until the end of the test + # series_flush(obj) +end diff --git a/src/binding/julia/openPMD.jl/test/Attribute.jl b/src/binding/julia/openPMD.jl/test/Attribute.jl new file mode 100644 index 0000000000..0177b8e18d --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Attribute.jl @@ -0,0 +1,8 @@ +# @testset "Attribute" begin +# @test Attribute isa Type +# +# #TODO attr = Attribute() +# #TODO @test dtype(attr) <: OpenPMDType +# #TODO @test attr[] isa OpenPMDType +# #TODO @test typeof(attr[]) === dtype(attr) +# end diff --git a/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl b/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl new file mode 100644 index 0000000000..692ae02b66 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl @@ -0,0 +1,10 @@ +@testset "BaseRecordComponent" begin + @test BaseRecordComponent isa Type + @test isabstracttype(BaseRecordComponent) + + #TODO comp = ??? + #TODO comp::BaseRecordComponent + #TODO @test unit_SI(comp) isa CxxDouble + + @warn "TODO" +end diff --git a/src/binding/julia/openPMD.jl/test/Container.jl b/src/binding/julia/openPMD.jl/test/Container.jl new file mode 100644 index 0000000000..14a48552fb --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Container.jl @@ -0,0 +1,33 @@ +@testset "Container{$contT}" begin + T = contT + K = contK + @test Container{T,K} isa Type + @test isabstracttype(Container{T,K}) + + @test cont isa CxxRef{<:Container{T,K}} + + @test isempty(cont) isa Bool + @test (length(cont) == 0) == isempty(cont) + + empty!(cont) + @test isempty(cont) + @test length(cont) == 0 + + newval = get!(cont, "bubble") + @test length(cont) == 1 + @test cont["bubble"] == newval + + cont["bobble"] = newval + @test length(cont) == 2 + + @test count(cont, "bubble") == 1 + @test "bubble" ∈ cont + + delete!(cont, "bobble") + @test length(cont) == 1 + + @test keys(cont) == ["bubble"] + + # @cxxdereference Base.values(cont::Container) = values1(cont) + # @cxxdereference Base.collect(cont::Container) = collect1(cont) +end diff --git a/src/binding/julia/openPMD.jl/test/Dataset.jl b/src/binding/julia/openPMD.jl/test/Dataset.jl new file mode 100644 index 0000000000..c3b0fa4f52 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Dataset.jl @@ -0,0 +1,7 @@ +@testset "Dataset" begin + @test Extent isa Type + @test Offset isa Type + @test Dataset isa Type + + @warn "TODO" +end diff --git a/src/binding/julia/openPMD.jl/test/Datatype.jl b/src/binding/julia/openPMD.jl/test/Datatype.jl new file mode 100644 index 0000000000..902514dcff --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Datatype.jl @@ -0,0 +1,83 @@ +@testset "Datatype" begin + @test Datatype isa Type + + otypes = [CHAR, UCHAR, SHORT, INT, LONG, LONGLONG, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, CFLOAT, CDOUBLE, STRING, + VEC_CHAR, VEC_UCHAR, VEC_SHORT, VEC_INT, VEC_LONG, VEC_LONGLONG, VEC_USHORT, VEC_UINT, VEC_ULONG, VEC_ULONGLONG, + VEC_FLOAT, VEC_DOUBLE, VEC_CFLOAT, VEC_CDOUBLE, VEC_STRING, BOOL, ARR_DBL_7] + otype_equiv = Dict(otype => otype for otype in otypes) + if sizeof(CxxLong) == sizeof(CxxLongLong) + otype_equiv[LONG] = LONGLONG + otype_equiv[ULONG] = ULONGLONG + otype_equiv[VEC_LONG] = VEC_LONGLONG + otype_equiv[VEC_ULONG] = VEC_ULONGLONG + end + for otype in otypes + @test otype isa Datatype + jtype = openPMD.julia_type(otype) + @test jtype <: OpenPMDType + otype′ = determine_datatype(jtype) + @test otype_equiv[otype′] ≡ otype_equiv[otype] + end + + jtypes = [CxxChar, CxxUChar, CxxShort, CxxInt, CxxLong, CxxLongLong, CxxUShort, CxxUInt, CxxULong, CxxULongLong, CxxFloat, + CxxDouble, Complex{CxxFloat}, Complex{CxxDouble}, String, Vector{CxxChar}, Vector{CxxUChar}, Vector{CxxShort}, + Vector{CxxInt}, Vector{CxxLong}, Vector{CxxLongLong}, Vector{CxxUShort}, Vector{CxxUInt}, Vector{CxxULong}, + Vector{CxxULongLong}, Vector{CxxFloat}, Vector{CxxDouble}, Vector{Complex{CxxFloat}}, Vector{Complex{CxxDouble}}, + Vector{String}, SVector{7,CxxDouble}, CxxBool] + jtype_equiv = Dict(jt => jt for jt in jtypes) + if sizeof(CxxLong) == sizeof(CxxLongLong) + jtype_equiv[CxxLong] = CxxLongLong + jtype_equiv[CxxULong] = CxxULongLong + jtype_equiv[Vector{CxxLong}] = Vector{CxxLongLong} + jtype_equiv[Vector{CxxULong}] = Vector{CxxULongLong} + end + for jtype in jtypes + @test jtype <: OpenPMDType + otype = determine_datatype(jtype) + @test otype isa Datatype + jtype′ = openPMD.julia_type(otype) + @test jtype′ ≡ jtype + end + + @test CHAR == CHAR + @test CHAR ≠ UCHAR + @test hash(CHAR) isa UInt + @test hash(CHAR) ≠ hash(convert(UInt8, CHAR)) + + for jtype in jtypes + if jtype <: Vector + # pass + elseif jtype <: String + # pass + else + @test to_bytes(jtype) == sizeof(eltype(jtype)) + @test to_bits(jtype) == 8 * sizeof(eltype(jtype)) + end + @test is_vector(jtype) == (jtype <: Vector) + ejtype = jtype <: Vector ? eltype(jtype) : jtype + @test is_floating_point(jtype) == (ejtype <: AbstractFloat) + @test is_complex_floating_point(jtype) == (ejtype <: Complex) + @test is_integer(jtype)[1] == (ejtype <: Integer && ejtype ∉ (CxxBool, CxxChar, CxxUChar)) + if is_integer(jtype)[1] + @test is_integer(jtype)[2] == (ejtype <: Signed) + end + for jtype′ in jtypes + @test is_same(jtype′, jtype) == (jtype_equiv[jtype′] === jtype_equiv[jtype]) + end + if jtype <: AbstractVector + @test basic_datatype(jtype) === eltype(jtype) + # @test to_vector_type(jtype) === jtype + else + @test basic_datatype(jtype) === jtype + if jtype === CxxBool + # skip; `CxxBool` is not accepted + # @test to_vector_type(jtype) === Vector{jtype} + else + @test to_vector_type(jtype) === Vector{jtype} + end + end + str = datatype_to_string(jtype) + @test str isa AbstractString + @test string_to_datatype(str) === jtype + end +end diff --git a/src/binding/julia/openPMD.jl/test/Format.jl b/src/binding/julia/openPMD.jl/test/Format.jl new file mode 100644 index 0000000000..3318bd0639 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Format.jl @@ -0,0 +1,24 @@ +@testset "Format" begin + @test Format isa Type + @test HDF5 isa Format + @test ADIOS1 isa Format + @test ADIOS2 isa Format + @test ADIOS2_SST isa Format + @test ADIOS2_SSC isa Format + @test JSON isa Format + @test DUMMY isa Format + + @test HDF5 == HDF5 + @test HDF5 ≠ ADIOS1 + @test hash(HDF5) isa UInt + @test hash(HDF5) ≠ hash(convert(UInt, HDF5)) + + for format in [HDF5, ADIOS1, ADIOS2, ADIOS2_SST, ADIOS2_SSC, JSON] + suf = suffix(format) + @test suf isa AbstractString + @test !isempty(suf) + # Not all formats can be recognized by suffix + want_format = format == ADIOS1 ? ADIOS2 : format + @test determine_format("hello.$suf") == want_format + end +end diff --git a/src/binding/julia/openPMD.jl/test/Iteration.jl b/src/binding/julia/openPMD.jl/test/Iteration.jl new file mode 100644 index 0000000000..d4849b1645 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Iteration.jl @@ -0,0 +1,22 @@ +@testset "Iteration" begin + @test Iteration isa Type + + @test iter isa CxxRef{Iteration} + + t = 0.11 + set_time!(iter, t) + @test time(iter) === t + + dt_ = 0.01 + set_dt!(iter, dt_) + @test dt(iter) === dt_ + + tu = 1.1 + set_time_unit_SI!(iter, tu) + @test time_unit_SI(iter) === tu + + @test !closed(iter) + @test !closed_by_writer(iter) + + @test meshes(iter) isa CxxRef{Container{Mesh,StdString}} +end diff --git a/src/binding/julia/openPMD.jl/test/Mesh.jl b/src/binding/julia/openPMD.jl/test/Mesh.jl new file mode 100644 index 0000000000..031f3e976d --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Mesh.jl @@ -0,0 +1,14 @@ +@testset "Mesh" begin + @test Geometry isa Type + @test cartesian isa Geometry + @test theta_mode isa Geometry + @test cylindrical isa Geometry + @test spherical isa Geometry + @test other isa Geometry + + @test DataOrder isa Type + @test C isa DataOrder + @test F isa DataOrder + + @test Mesh isa Type +end diff --git a/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl b/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl new file mode 100644 index 0000000000..5f3150aa26 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl @@ -0,0 +1,14 @@ +@testset "MeshRecordComponent" begin + @test MeshRecordComponent isa Type + + comp::CxxRef{MeshRecordComponent} + pos = [1.0, 2.0, 3.0] + set_position!(comp, pos) + @test position(comp) == pos + make_constant(comp, 3) + @test is_constant(comp) + make_constant(comp, float(π)) + @test is_constant(comp) + make_constant(comp, 1.0im) + @test is_constant(comp) +end diff --git a/src/binding/julia/openPMD.jl/test/RecordComponent.jl b/src/binding/julia/openPMD.jl/test/RecordComponent.jl new file mode 100644 index 0000000000..03ee044555 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/RecordComponent.jl @@ -0,0 +1,7 @@ +@testset "RecordComponent" begin + @test RecordComponent isa Type + @test isabstracttype(RecordComponent) + + data = Int[10i+j for i in 1:2, j in 1:3] + store_chunk(comp, (0,0), size(data)) +end diff --git a/src/binding/julia/openPMD.jl/test/Series.jl b/src/binding/julia/openPMD.jl/test/Series.jl new file mode 100644 index 0000000000..d0a9e631e7 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/Series.jl @@ -0,0 +1,77 @@ +@testset "Series" begin + @test Series isa Type + + @test series isa Series + + ver = openPMD_version(series) + set_openPMD_version!(series, ver) + @test ver == openPMD_version(series) + + ext = openPMD_extension(series) + set_openPMD_extension!(series, ext) + @test ext == openPMD_extension(series) + + bpath = base_path(series) + # Not allowed in openPMD ≤ 1.1.0 + # set_base_path!(series, bpath) + @test bpath == base_path(series) + + # Error if accessed when not present + if contains_attribute(series, "meshesPath") + mpath = meshes_path(series) + set_meshes_path!(series, mpath) + @test mpath == meshes_path(series) + end + + if contains_attribute(series, "particlesPath") + ppath = particles_path(series) + set_particles_path!(series, ppath) + @test ppath == particles_path(series) + end + + auth = author(series) + set_author!(series, auth) + @test auth == author(series) + + sw = software(series) + sv = software_version(series) + set_software!(series, sw, sv) + @test sw == software(series) + @test sv == software_version(series) + + dat = date(series) + set_date!(series, dat) + @test dat == date(series) + + if contains_attribute(series, "softwareDependencies") + deps = software_dependencies(series) + set_software_dependencies!(series, deps) + @test deps == software_dependencies(series) + end + + if contains_attribute(series, "machine") + mach = machine(series) + set_machine!(series, mach) + @test mach == machine(series) + end + + iterfmt = iteration_format(series) + # Cannot be set after a file has been written + # set_iteration_format!(series, iterfmt) + @test iterfmt == iteration_format(series) + + if contains_attribute(series, "name") + name = name(series) + set_name!(series, name) + @test name == name(series) + end + + bend = backend(series) + @test bend == "JSON" + + # flush(series) + + @test isvalid(series) + + @test write_iterations(series) isa WriteIterations +end diff --git a/src/binding/julia/openPMD.jl/test/UnitDimension.jl b/src/binding/julia/openPMD.jl/test/UnitDimension.jl new file mode 100644 index 0000000000..d546e77244 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/UnitDimension.jl @@ -0,0 +1,15 @@ +@testset "UnitDimension" begin + @test UnitDimension isa Type + @test L isa UnitDimension + @test M isa UnitDimension + @test T isa UnitDimension + @test I isa UnitDimension + @test θ isa UnitDimension + @test N isa UnitDimension + @test J isa UnitDimension + + @test L == L + @test L ≠ M + @test hash(L) isa UInt + @test hash(L) ≠ hash(convert(UInt, L)) +end diff --git a/src/binding/julia/openPMD.jl/test/WriteIterations.jl b/src/binding/julia/openPMD.jl/test/WriteIterations.jl new file mode 100644 index 0000000000..fbadbcb24a --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/WriteIterations.jl @@ -0,0 +1,11 @@ +@testset "WriteIterations" begin + @test WriteIterations isa Type + + @test iters isa WriteIterations + + # We cannot test getting a new iteration; doing so closes the current iteration + # newiter = get!(iters, 12) + # @test newiter isa Iteration + iter′ = get!(iters, 0) + @test iter′ isa CxxRef{Iteration} +end diff --git a/src/binding/julia/openPMD.jl/test/runtests.jl b/src/binding/julia/openPMD.jl/test/runtests.jl new file mode 100644 index 0000000000..1eeca6653b --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/runtests.jl @@ -0,0 +1,48 @@ +using Base.Filesystem +using CxxWrap +using StaticArrays +using Test +using openPMD + +include("Access.jl") +include("Datatype.jl") +include("Format.jl") +include("UnitDimension.jl") + +#TODO const dirname = Filesystem.mktempdir(; cleanup=true) +const dirname = Filesystem.mktempdir(; cleanup=false) +const filename = joinpath(dirname, "hello.json") + +const series = Series(filename, CREATE) +set_name!(series, "hello") +set_author!(series, "Erik Schnetter ") +const iters = write_iterations(series) +const iter = get!(iters, 0) +const mesh = get!(meshes(iter), "my_first_mesh") +const comp = get!(mesh, "my_first_record") + +include("Attribute.jl") +include("Attributable.jl") +include("Dataset.jl") + +include("BaseRecordComponent.jl") +include("RecordComponent.jl") +include("MeshRecordComponent.jl") + +cont = mesh +contT = MeshRecordComponent +contK = StdString +include("Container.jl") +include("Mesh.jl") + +include("Iteration.jl") + +include("WriteIterations.jl") + +include("Series.jl") + +include("version.jl") + +series_flush(series) + +close(iter) diff --git a/src/binding/julia/openPMD.jl/test/version.jl b/src/binding/julia/openPMD.jl/test/version.jl new file mode 100644 index 0000000000..b78dca5473 --- /dev/null +++ b/src/binding/julia/openPMD.jl/test/version.jl @@ -0,0 +1,12 @@ +@testset "version" begin + @test get_version() isa AbstractString + @test get_standard() isa AbstractString + @test get_standard_minimum() isa AbstractString + vars = get_variants() + @test vars isa Dict{String,Bool} + @test "json" ∈ keys(vars) + @test vars["json"] + exts = get_file_extensions() + @test exts isa AbstractVector{<:AbstractString} + @test "json" ∈ exts +end diff --git a/src/binding/julia/version.cpp b/src/binding/julia/version.cpp new file mode 100644 index 0000000000..3b7a967f30 --- /dev/null +++ b/src/binding/julia/version.cpp @@ -0,0 +1,12 @@ +// version + +#include "defs.hpp" + +void define_julia_version(jlcxx::Module &mod) { + mod.method("get_version", getVersion); + mod.method("get_standard", getStandard); + mod.method("get_standard_minimum", getStandardMinimum); + mod.method("get_variants1", + []() { return map_to_vector_pair(getVariants()); }); + mod.method("get_file_extensions", getFileExtensions); +} From b657d95b66f0a4b04b49a47bd324795bb10d047e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 27 Jun 2021 19:34:26 -0400 Subject: [PATCH 02/94] Julia: Wrap store_chunk --- CMakeLists.txt | 3 ++ src/binding/julia/Dataset.cpp | 4 +- src/binding/julia/RecordComponent.cpp | 51 ++----------------- .../julia/RecordComponent_load_chunk.cpp | 14 +++++ .../julia/RecordComponent_make_constant.cpp | 11 ++++ .../julia/RecordComponent_store_chunk.cpp | 23 +++++++++ src/binding/julia/defs.hpp | 27 ++++++++++ src/binding/julia/openPMD.jl/src/Dataset.jl | 30 ++++++++--- .../openPMD.jl/src/MeshRecordComponent.jl | 5 +- .../julia/openPMD.jl/src/RecordComponent.jl | 15 +++--- src/binding/julia/openPMD.jl/src/openPMD.jl | 2 + src/binding/julia/openPMD.jl/test/Dataset.jl | 8 ++- .../julia/openPMD.jl/test/RecordComponent.jl | 6 ++- src/binding/julia/openPMD.jl/test/runtests.jl | 5 ++ 14 files changed, 136 insertions(+), 68 deletions(-) create mode 100644 src/binding/julia/RecordComponent_load_chunk.cpp create mode 100644 src/binding/julia/RecordComponent_make_constant.cpp create mode 100644 src/binding/julia/RecordComponent_store_chunk.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index def77ef0ab..a703c78022 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -618,6 +618,9 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/Mesh.cpp src/binding/julia/MeshRecordComponent.cpp src/binding/julia/RecordComponent.cpp + src/binding/julia/RecordComponent_load_chunk.cpp + src/binding/julia/RecordComponent_make_constant.cpp + src/binding/julia/RecordComponent_store_chunk.cpp src/binding/julia/Series.cpp src/binding/julia/UnitDimension.cpp src/binding/julia/WriteIterations.cpp diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index 1e0638d243..75bd8bf3f6 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -9,8 +9,8 @@ void define_julia_Dataset(jlcxx::Module &mod) { type.constructor(); type.constructor(); - type.method("extend!", &Dataset::extend); - type.method("set_chunk_size!", &Dataset::setChunkSize); + type.method("extend1!", &Dataset::extend); + type.method("set_chunk_size1!", &Dataset::setChunkSize); type.method("set_compression!", &Dataset::setCompression); type.method("set_custom_transform!", &Dataset::setCustomTransform); type.method("extent1", [](const Dataset &d) { return d.extent; }); diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index c3974e3ddc..4553b4476f 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -14,27 +14,6 @@ template <> struct SuperType { }; } // namespace jlcxx -namespace { -template std::shared_ptr capture_vector(std::vector vec) { - if constexpr (std::is_same_v) { - // Copy the vector, because std::vector is special - T *dataptr = new T[vec.size()]; - std::shared_ptr ptr(dataptr, std::default_delete()); - std::copy(vec.begin(), vec.end(), dataptr); - return ptr; - } else { - // Capture the vector - T *dataptr = vec.data(); - std::shared_ptr ptr(dataptr, [vec = std::move(vec)](T *p) { - /* We moved the vector into the anonymous function, and thus it will be - * destructed when the anonymous function is destructed. There is no need - * to call a destructor manually. */ - }); - return ptr; - } -} -} // namespace - void define_julia_RecordComponent(jlcxx::Module &mod) { // RecordComponent::Allocation @@ -53,37 +32,13 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { type.method("reset_dataset!", &RecordComponent::resetDataset); type.method("get_dimensionality1", &RecordComponent::getDimensionality); type.method("get_extent1", &RecordComponent::getExtent); -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("make_constant1_" NAME, &RecordComponent::makeConstant); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE + define_julia_RecordComponent_make_constant(mod, type); type.method( "make_empty1", static_cast( &RecordComponent::makeEmpty)); type.method("empty1", &RecordComponent::empty); -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "load_chunk1_" NAME, \ - static_cast (RecordComponent::*)(Offset, Extent)>( \ - &RecordComponent::loadChunk)); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk1_" NAME, \ - static_cast, \ - Offset, Extent)>( \ - &RecordComponent::storeChunk)); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ - std::vector data, \ - Offset offset, Extent extent) { \ - std::shared_ptr ptr(capture_vector(std::move(data))); \ - comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ - }); \ - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE + define_julia_RecordComponent_load_chunk(mod, type); + define_julia_RecordComponent_store_chunk(mod, type); type.method("SCALAR1", []() { return RecordComponent::SCALAR; }); } diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp new file mode 100644 index 0000000000..1f9c6c425c --- /dev/null +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -0,0 +1,14 @@ +// RecordComponent_load_chunk + +#include "defs.hpp" + +void define_julia_RecordComponent_load_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method( \ + "load_chunk1_" NAME, \ + static_cast (RecordComponent::*)(Offset, Extent)>( \ + &RecordComponent::loadChunk)); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp new file mode 100644 index 0000000000..1a5db48d4c --- /dev/null +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -0,0 +1,11 @@ +// RecordComponent_make_constant + +#include "defs.hpp" + +void define_julia_RecordComponent_make_constant( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("make_constant1_" NAME, &RecordComponent::makeConstant); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp new file mode 100644 index 0000000000..99e654571a --- /dev/null +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -0,0 +1,23 @@ +// RecordComponent_store_chunk + +#include "defs.hpp" + +void define_julia_RecordComponent_store_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("store_chunk1_" NAME, \ + static_cast, \ + Offset, Extent)>( \ + &RecordComponent::storeChunk)); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ + std::vector data, \ + Offset offset, Extent extent) { \ + std::shared_ptr ptr(capture_vector(std::move(data))); \ + comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ + }); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 75cebc0536..6050295525 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -10,9 +10,11 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -92,6 +94,25 @@ std::vector> map_to_vector_tuple(const std::map &m) { return vp; } +template std::shared_ptr capture_vector(std::vector vec) { + if constexpr (std::is_same_v) { + // Copy the vector, because std::vector is special + T *dataptr = new T[vec.size()]; + std::shared_ptr ptr(dataptr, std::default_delete()); + std::copy(vec.begin(), vec.end(), dataptr); + return ptr; + } else { + // Capture the vector + T *dataptr = vec.data(); + std::shared_ptr ptr(dataptr, [vec = std::move(vec)](T *p) { + /* We moved the vector into the anonymous function, and thus it will be + * destructed when the anonymous function is destructed. There is no need + * to call a destructor manually. */ + }); + return ptr; + } +} + template void add_array_type(jlcxx::Module &mod, const std::string &name) { mod.add_type>(name) @@ -142,6 +163,12 @@ void define_julia_Iteration(jlcxx::Module &mod); void define_julia_Mesh(jlcxx::Module &mod); void define_julia_MeshRecordComponent(jlcxx::Module &mod); void define_julia_RecordComponent(jlcxx::Module &mod); +void define_julia_RecordComponent_load_chunk(jlcxx::Module &mod, + jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_make_constant(jlcxx::Module &mod, + jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_store_chunk(jlcxx::Module &mod, + jlcxx::TypeWrapper &type); void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); void define_julia_WriteIterations(jlcxx::Module &mod); diff --git a/src/binding/julia/openPMD.jl/src/Dataset.jl b/src/binding/julia/openPMD.jl/src/Dataset.jl index aba7cebdb5..9dce4ca549 100644 --- a/src/binding/julia/openPMD.jl/src/Dataset.jl +++ b/src/binding/julia/openPMD.jl/src/Dataset.jl @@ -1,17 +1,25 @@ # Dataset """ - const Extent = Union{NTuple{D,Int},SVector{D,Int}} + const Extent = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} """ -const Extent{D} = Union{NTuple{D,Int},SVector{D,Int}} +const Extent{D} = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} export Extent +# TODO: Don't call `reverse`, use something more efficient +wrap_extent(extent::Vector{UInt64}) = StdVector(reverse(extent)) +wrap_extent(extent::Vector) = wrap_extent(Vector{UInt64}(extent)) +wrap_extent(extent::SVector) = wrap_extent(UInt64[extent...]) +wrap_extent(extent::Tuple) = wrap_extent(UInt64[extent...]) + """ - const Offset = Union{NTuple{D,Int},SVector{D,Int}} + const Offset = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} """ -const Offset{D} = Union{NTuple{D,Int},SVector{D,Int}} +const Offset{D} = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} export Offset +wrap_offset(offset) = wrap_extent(offset) + @doc """ mutable struct Dataset .... @@ -21,15 +29,25 @@ export Offset """ Dataset export Dataset +for (otype, jtype) in julia_types + @eval begin + @cxxdereference function Dataset(::Type{$jtype}, extent::Extent, options::AbstractString="{}") + return Dataset($otype, wrap_extent(extent), options) + end + end +end + @doc """ extend!(dset::Dataset, newextent::Extent) """ extend! export extend! +@cxxdereference extentd!(dset::Dataset, newextent::Extent) = extend1!(dset, wrap_extent(newextent)) @doc """ set_chunk_size!(dset::Dataset, chunk_size::Extent) """ set_chunk_size! export set_chunk_size! +@cxxdereference set_chunk_size!(dset::Dataset, chunk_size::Extent) = set_chunk_size1!(dset, wrap_extent(chunk_size)) @doc """ set_compression!(dset::Dataset, compression::AbstractString, level::Int) @@ -44,7 +62,7 @@ export set_custom_transform! """ size(dset::Dataset) """ -@cxxdereference Base.size(dset::Dataset) = Tuple(extent1(dset)) +@cxxdereference Base.size(dset::Dataset) = reverse(Tuple(extent1(dset))) """ eltype(dset::Dataset) @@ -59,7 +77,7 @@ export set_custom_transform! """ chunk_size(dset::Dataset) """ -@cxxdereference chunk_size(dset::Dataset) = Tuple(chunk_size1(dset)) +@cxxdereference chunk_size(dset::Dataset) = reverse(Tuple(chunk_size1(dset))) export chunk_size @doc """ diff --git a/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl b/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl index 73c3d2a6eb..5934a3c504 100644 --- a/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl +++ b/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl @@ -13,12 +13,15 @@ export MeshRecordComponent @cxxdereference Base.position(comp::MeshRecordComponent) = position1(comp) @doc """ - set_position!(comp::MeshRecordComponent, newpos::AbstractVector{CxxDouble}) + set_position!(comp::MeshRecordComponent, newpos::Union{NTuple{D,CxxDouble}, AbstractVector{CxxDouble}}) """ set_position! export set_position! @cxxdereference function set_position!(comp::MeshRecordComponent, newpos::AbstractVector{CxxDouble}) return set_position1!(comp, wrap_vector(newpos)) end +@cxxdereference function set_position!(comp::MeshRecordComponent, newpos::NTuple{D,CxxDouble} where {D}) + return set_position!(comp, CxxDouble[newpos...]) +end @doc """ make_constant(comp::MeshRecordComponent, value::OpenMPType) diff --git a/src/binding/julia/openPMD.jl/src/RecordComponent.jl b/src/binding/julia/openPMD.jl/src/RecordComponent.jl index 075c6ac753..80a203387d 100644 --- a/src/binding/julia/openPMD.jl/src/RecordComponent.jl +++ b/src/binding/julia/openPMD.jl/src/RecordComponent.jl @@ -27,7 +27,7 @@ export reset_dataset! @doc """ ndims(comp::RecordComponent) """ Base.ndims -@cxxdereference Base.ndims(comp::RecordComponent) = Int(get_dimensionality(comp)) +@cxxdereference Base.ndims(comp::RecordComponent) = Int(get_dimensionality1(comp)) @doc """ size(comp::RecordComponent) @@ -60,7 +60,7 @@ export make_empty # TODO: load_chunk @doc """ - store_chunk(comp::RecordComponent, data::AbstractArray, offset, extent) + store_chunk(comp::RecordComponent, data::AbstractArray, offset::Offset, extent::Extent) """ store_chunk export store_chunk # Object lifetime management for store_chunk: Ideally, we would ensure @@ -70,13 +70,12 @@ export store_chunk # copies the data, which also needs to be avoided. for (otype, jtype) in julia_types @eval begin - @cxxdereference function store_chunk(comp::RecordComponent, data::AbstractArray{$jtype}, offset::AbstractVector, - extent::AbstractVector) - @assert ndims(offset) == ndims(extent) == ndims(comp) + @cxxdereference function store_chunk(comp::RecordComponent, data::AbstractArray{$jtype}, offset::Offset, extent::Extent) + # @assert length(offset) == length(extent) == ndims(comp) @assert all(extent .>= 0) - @assert length(data) == product(extent) - return $(Symbol("store_chunk_copy1_", type_symbols[otype]))(comp, wrap_vector(reshape(value, :)), wrap_vector(offset), - wrap_vector(extent)) + @assert length(data) == prod(extent) + return $(Symbol("store_chunk_copy1_", type_symbols[otype]))(comp, wrap_vector(reshape(data, :)), wrap_offset(offset), + wrap_extent(extent)) end end end diff --git a/src/binding/julia/openPMD.jl/src/openPMD.jl b/src/binding/julia/openPMD.jl/src/openPMD.jl index 40290d1011..dfb24dc373 100644 --- a/src/binding/julia/openPMD.jl/src/openPMD.jl +++ b/src/binding/julia/openPMD.jl/src/openPMD.jl @@ -20,6 +20,8 @@ __init__() = @initcxx # - remove all the `Bool(...)` wrappers; they are not needed # # - put enum values into a namespace +# +# - do we really need different names to call templated functions? probably not, at least not for constructors. ################################################################################ diff --git a/src/binding/julia/openPMD.jl/test/Dataset.jl b/src/binding/julia/openPMD.jl/test/Dataset.jl index c3b0fa4f52..2cc023ba9f 100644 --- a/src/binding/julia/openPMD.jl/test/Dataset.jl +++ b/src/binding/julia/openPMD.jl/test/Dataset.jl @@ -3,5 +3,11 @@ @test Offset isa Type @test Dataset isa Type - @warn "TODO" + @test dset isa Dataset + + @test size(dset) == ext + @test eltype(dset) == dsetT + @test ndims(dset) == length(ext) + + # TODO: test chunk_size, compression, transform, options end diff --git a/src/binding/julia/openPMD.jl/test/RecordComponent.jl b/src/binding/julia/openPMD.jl/test/RecordComponent.jl index 03ee044555..8dffe6f104 100644 --- a/src/binding/julia/openPMD.jl/test/RecordComponent.jl +++ b/src/binding/julia/openPMD.jl/test/RecordComponent.jl @@ -2,6 +2,8 @@ @test RecordComponent isa Type @test isabstracttype(RecordComponent) - data = Int[10i+j for i in 1:2, j in 1:3] - store_chunk(comp, (0,0), size(data)) + data = Int[10i + j for i in 1:2, j in 1:3] + @test size(data) == ext + @test eltype(data) == dsetT + store_chunk(comp, data, (0, 0), size(data)) end diff --git a/src/binding/julia/openPMD.jl/test/runtests.jl b/src/binding/julia/openPMD.jl/test/runtests.jl index 1eeca6653b..f2cb14eaaf 100644 --- a/src/binding/julia/openPMD.jl/test/runtests.jl +++ b/src/binding/julia/openPMD.jl/test/runtests.jl @@ -20,6 +20,11 @@ const iters = write_iterations(series) const iter = get!(iters, 0) const mesh = get!(meshes(iter), "my_first_mesh") const comp = get!(mesh, "my_first_record") +set_position!(comp, (0.0, 0.0)) +const dsetT = Int +const ext = (2, 3) +const dset = Dataset(dsetT, ext) +reset_dataset!(comp, dset) include("Attribute.jl") include("Attributable.jl") From 2de8c93ffc0ed54044cfa85b1003402275bef3e8 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 11:16:47 -0400 Subject: [PATCH 03/94] Move Julia package to a separate repository --- .../julia/openPMD.jl/.JuliaFormatter.toml | 10 - .../julia/openPMD.jl/.github/workflows/CI.yml | 77 -- src/binding/julia/openPMD.jl/.gitignore | 1 - src/binding/julia/openPMD.jl/COPYING | 675 ------------------ src/binding/julia/openPMD.jl/COPYING.LESSER | 166 ----- src/binding/julia/openPMD.jl/Project.toml | 14 - src/binding/julia/openPMD.jl/docs/.gitignore | 2 - .../julia/openPMD.jl/docs/Project.toml | 2 - src/binding/julia/openPMD.jl/docs/make.jl | 11 - .../julia/openPMD.jl/docs/src/index.md | 5 - src/binding/julia/openPMD.jl/src/Access.jl | 12 - .../julia/openPMD.jl/src/Attributable.jl | 86 --- src/binding/julia/openPMD.jl/src/Attribute.jl | 25 - .../openPMD.jl/src/BaseRecordComponent.jl | 28 - src/binding/julia/openPMD.jl/src/Container.jl | 65 -- src/binding/julia/openPMD.jl/src/Dataset.jl | 96 --- src/binding/julia/openPMD.jl/src/Datatype.jl | 245 ------- src/binding/julia/openPMD.jl/src/Format.jl | 28 - src/binding/julia/openPMD.jl/src/Iteration.jl | 58 -- src/binding/julia/openPMD.jl/src/Mesh.jl | 140 ---- .../openPMD.jl/src/MeshRecordComponent.jl | 36 - .../julia/openPMD.jl/src/RecordComponent.jl | 81 --- src/binding/julia/openPMD.jl/src/Series.jl | 159 ----- .../julia/openPMD.jl/src/UnitDimension.jl | 18 - .../julia/openPMD.jl/src/WriteIterations.jl | 13 - src/binding/julia/openPMD.jl/src/openPMD.jl | 63 -- src/binding/julia/openPMD.jl/src/version.jl | 34 - src/binding/julia/openPMD.jl/test/Access.jl | 11 - .../julia/openPMD.jl/test/Attributable.jl | 22 - .../julia/openPMD.jl/test/Attribute.jl | 8 - .../openPMD.jl/test/BaseRecordComponent.jl | 10 - .../julia/openPMD.jl/test/Container.jl | 33 - src/binding/julia/openPMD.jl/test/Dataset.jl | 13 - src/binding/julia/openPMD.jl/test/Datatype.jl | 83 --- src/binding/julia/openPMD.jl/test/Format.jl | 24 - .../julia/openPMD.jl/test/Iteration.jl | 22 - src/binding/julia/openPMD.jl/test/Mesh.jl | 14 - .../openPMD.jl/test/MeshRecordComponent.jl | 14 - .../julia/openPMD.jl/test/RecordComponent.jl | 9 - src/binding/julia/openPMD.jl/test/Series.jl | 77 -- .../julia/openPMD.jl/test/UnitDimension.jl | 15 - .../julia/openPMD.jl/test/WriteIterations.jl | 11 - src/binding/julia/openPMD.jl/test/runtests.jl | 53 -- src/binding/julia/openPMD.jl/test/version.jl | 12 - 44 files changed, 2581 deletions(-) delete mode 100644 src/binding/julia/openPMD.jl/.JuliaFormatter.toml delete mode 100644 src/binding/julia/openPMD.jl/.github/workflows/CI.yml delete mode 100644 src/binding/julia/openPMD.jl/.gitignore delete mode 100644 src/binding/julia/openPMD.jl/COPYING delete mode 100644 src/binding/julia/openPMD.jl/COPYING.LESSER delete mode 100644 src/binding/julia/openPMD.jl/Project.toml delete mode 100644 src/binding/julia/openPMD.jl/docs/.gitignore delete mode 100644 src/binding/julia/openPMD.jl/docs/Project.toml delete mode 100644 src/binding/julia/openPMD.jl/docs/make.jl delete mode 100644 src/binding/julia/openPMD.jl/docs/src/index.md delete mode 100644 src/binding/julia/openPMD.jl/src/Access.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Attributable.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Attribute.jl delete mode 100644 src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Container.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Dataset.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Datatype.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Format.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Iteration.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Mesh.jl delete mode 100644 src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/src/RecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/src/Series.jl delete mode 100644 src/binding/julia/openPMD.jl/src/UnitDimension.jl delete mode 100644 src/binding/julia/openPMD.jl/src/WriteIterations.jl delete mode 100644 src/binding/julia/openPMD.jl/src/openPMD.jl delete mode 100644 src/binding/julia/openPMD.jl/src/version.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Access.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Attributable.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Attribute.jl delete mode 100644 src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Container.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Dataset.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Datatype.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Format.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Iteration.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Mesh.jl delete mode 100644 src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/test/RecordComponent.jl delete mode 100644 src/binding/julia/openPMD.jl/test/Series.jl delete mode 100644 src/binding/julia/openPMD.jl/test/UnitDimension.jl delete mode 100644 src/binding/julia/openPMD.jl/test/WriteIterations.jl delete mode 100644 src/binding/julia/openPMD.jl/test/runtests.jl delete mode 100644 src/binding/julia/openPMD.jl/test/version.jl diff --git a/src/binding/julia/openPMD.jl/.JuliaFormatter.toml b/src/binding/julia/openPMD.jl/.JuliaFormatter.toml deleted file mode 100644 index 3347951293..0000000000 --- a/src/binding/julia/openPMD.jl/.JuliaFormatter.toml +++ /dev/null @@ -1,10 +0,0 @@ -style = "yas" -indent = 4 -margin = 132 -always_for_in = true -whitespace_ops_in_indices = true -whitespace_typedefs = false -remove_extra_newlines = true -import_to_using = true -pipe_to_function_call = true -short_to_long_function_def = true diff --git a/src/binding/julia/openPMD.jl/.github/workflows/CI.yml b/src/binding/julia/openPMD.jl/.github/workflows/CI.yml deleted file mode 100644 index 154f1df431..0000000000 --- a/src/binding/julia/openPMD.jl/.github/workflows/CI.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: CI -on: - - push - - pull_request -jobs: - test: - name: Julia ${{matrix.version}} - ${{matrix.os}} - ${{matrix.arch}} - ${{github.event_name}} - runs-on: ${{matrix.os}} - strategy: - matrix: - # arch: [x64, x86] - # os: [ubuntu-latest, windows-latest, macOS-latest] - # version: ["1.4", "1.5", "1.6", "nightly"] - include: - - arch: "x64" - os: "ubuntu-latest" - version: "1.6" - - arch: "x64" - os: "windows-latest" - version: "1.6" - - arch: "x64" - os: "macOS-latest" - version: "1.6" - - arch: "x86" - os: "ubuntu-latest" - version: "1.6" - - arch: "x64" - os: "ubuntu-latest" - version: "nightly" - - arch: "x64" - os: "ubuntu-latest" - version: "1.5" - - arch: "x64" - os: "ubuntu-latest" - version: "1.4" - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{matrix.version}} - arch: ${{matrix.arch}} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{runner.os}}-test-${{env.cache-name}}-${{hashFiles('**/Project.toml')}} - restore-keys: | - ${{runner.os}}-test-${{env.cache-name}}- - ${{runner.os}}-test- - ${{runner.os}}- - - uses: julia-actions/julia-buildpkg@v1 - env: - PYTHON: - - uses: julia-actions/julia-runtest@v1 - continue-on-error: ${{matrix.version == 'nightly'}} - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 - with: - file: lcov.info - docs: - name: Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - run: | - julia --project=docs -e ' - using Pkg - Pkg.develop(PackageSpec(path=pwd())) - Pkg.instantiate()' - - run: julia --project=docs docs/make.jl - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/src/binding/julia/openPMD.jl/.gitignore b/src/binding/julia/openPMD.jl/.gitignore deleted file mode 100644 index ba39cc531e..0000000000 --- a/src/binding/julia/openPMD.jl/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Manifest.toml diff --git a/src/binding/julia/openPMD.jl/COPYING b/src/binding/julia/openPMD.jl/COPYING deleted file mode 100644 index 10926e87f1..0000000000 --- a/src/binding/julia/openPMD.jl/COPYING +++ /dev/null @@ -1,675 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/src/binding/julia/openPMD.jl/COPYING.LESSER b/src/binding/julia/openPMD.jl/COPYING.LESSER deleted file mode 100644 index 341c30bda4..0000000000 --- a/src/binding/julia/openPMD.jl/COPYING.LESSER +++ /dev/null @@ -1,166 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. - diff --git a/src/binding/julia/openPMD.jl/Project.toml b/src/binding/julia/openPMD.jl/Project.toml deleted file mode 100644 index 154d4bd30d..0000000000 --- a/src/binding/julia/openPMD.jl/Project.toml +++ /dev/null @@ -1,14 +0,0 @@ -name = "openPMD" -uuid = "e4c73209-6c8c-4213-807b-38d671e094ab" -authors = ["Erik Schnetter "] -version = "0.1.0" - -[deps] -CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -CxxWrap = "0.11.2" -StaticArrays = "1.2.4" -julia = "1.4" diff --git a/src/binding/julia/openPMD.jl/docs/.gitignore b/src/binding/julia/openPMD.jl/docs/.gitignore deleted file mode 100644 index a303fff203..0000000000 --- a/src/binding/julia/openPMD.jl/docs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -site/ diff --git a/src/binding/julia/openPMD.jl/docs/Project.toml b/src/binding/julia/openPMD.jl/docs/Project.toml deleted file mode 100644 index dfa65cd107..0000000000 --- a/src/binding/julia/openPMD.jl/docs/Project.toml +++ /dev/null @@ -1,2 +0,0 @@ -[deps] -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" diff --git a/src/binding/julia/openPMD.jl/docs/make.jl b/src/binding/julia/openPMD.jl/docs/make.jl deleted file mode 100644 index 4d3b2f7620..0000000000 --- a/src/binding/julia/openPMD.jl/docs/make.jl +++ /dev/null @@ -1,11 +0,0 @@ -# Generate documentation with this command: -# (cd docs && julia --color=yes make.jl) - -push!(LOAD_PATH, "..") - -using Documenter -using openPMD - -makedocs(; sitename="openPMD", format=Documenter.HTML(), modules=[openPMD]) - -deploydocs(; repo="github.com/eschnett/openPMD.jl.git", devbranch="main", push_preview=true) diff --git a/src/binding/julia/openPMD.jl/docs/src/index.md b/src/binding/julia/openPMD.jl/docs/src/index.md deleted file mode 100644 index a3593e19c6..0000000000 --- a/src/binding/julia/openPMD.jl/docs/src/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# openPMD.jl - -```@autodocs -Modules = [openPMD] -``` diff --git a/src/binding/julia/openPMD.jl/src/Access.jl b/src/binding/julia/openPMD.jl/src/Access.jl deleted file mode 100644 index 44b2ddbfa2..0000000000 --- a/src/binding/julia/openPMD.jl/src/Access.jl +++ /dev/null @@ -1,12 +0,0 @@ -# Access - -@doc """ - @enum Access begin - READ_ONLY - READ_WRITE - CREATE - end -""" Access -export Access, READ_ONLY, READ_WRITE, CREATE - -Base.hash(acc::Access, u::UInt) = hash(hash(convert(UInt, acc), u), UInt(0x0bec3b3e)) diff --git a/src/binding/julia/openPMD.jl/src/Attributable.jl b/src/binding/julia/openPMD.jl/src/Attributable.jl deleted file mode 100644 index d180011e40..0000000000 --- a/src/binding/julia/openPMD.jl/src/Attributable.jl +++ /dev/null @@ -1,86 +0,0 @@ -# Attributable - -@doc """ - abstract type Attributable end -""" Attributable -export Attributable - -# We cannot use `setindex!` and `getindex` for `Attributable` types -# because the concrete types might implement their own `setindex!` and -# `getindex`, which would make attributes inaccessible. -# -# @doc """ -# setindex!(attr::Attributeable, key::AbstractString, value::OpenPMDType) -# attr[key] = value -# """ Base.setindex! -# for (otype, jtype) in julia_types -# @eval begin -# Base.setindex!(attr::Attributable, value::$jtype, key::AbstractString) = set_attribute1!(attr, key, value) -# end -# end -# -# @doc """ -# getindex(attr::Attributable, key::AbstractString)::OpenPMDType -# attr[key]::Attribute -# """ Base.getindex -# Base.getindex(attr::Attributable, key::AbstractString) = get_attribute1(attr, key)[] -# -# @doc """ -# delete!(attr:Attributable, key::AbstractString) -# """ Base.delete! -# Base.delete!(attr::Attributable, key::AbstractString) = (delete_attribute1(attr, key); attr) - -@doc """ - set_attribute!(attr::Attributeable, key::AbstractString, value::OpenPMDType) -""" set_attribute! -export set_attribute! -for (otype, jtype) in julia_types - @eval begin - @cxxdereference function set_attribute!(attr::Attributable, key::AbstractString, value::$jtype) - $(Symbol("set_attribute1_", type_symbols[otype], "!"))(attr, key, wrap_vector(value)) - return attr - end - end -end - -@doc """ - get_attribute(attr::Attributable, key::AbstractString)::OpenPMDType -""" get_attribute -export get_attribute -@cxxdereference get_attribute(attr::Attributable, key::AbstractString) = get_attribute1(attr, key)[] - -@doc """ - delete_attribute!(attr:Attributable, key::AbstractString) -""" delete_attribute! -export delete_attribute! - -@doc """ - attributes(attr:Attributable)::AbstractVector{<:AbstractString} -""" attributes -export attributes - -@doc """ - num_attributes(attr:Attributable)::Int -""" num_attributes -export num_attributes -@cxxdereference num_attributes(attr::Attributable) = Int(num_attributes1(attr)) - -@doc """ - contains_attribute(attr:Attributable, key::AbstractString)::Bool -""" contains_attribute -export contains_attribute - -@doc """ - comment(attr::Attributable)::AbstractString -""" comment -export comment - -@doc """ - set_comment!(attr::Attributable, comment::AbstractString)::Attributable -""" set_comment! -export set_comment! - -@doc """ - series_flush(attr::Attributable) -""" series_flush -export series_flush diff --git a/src/binding/julia/openPMD.jl/src/Attribute.jl b/src/binding/julia/openPMD.jl/src/Attribute.jl deleted file mode 100644 index c81be68bf0..0000000000 --- a/src/binding/julia/openPMD.jl/src/Attribute.jl +++ /dev/null @@ -1,25 +0,0 @@ -# Attribute - -# We hide the `Attribute` class from the public; it shouldn't be necessary for Julia code. - -@doc """ - mutable struct Attribute - ... - end -""" Attribute -# export Attribute - -@cxxdereference dtype(attr::Attribute) = julia_type(dtype1(attr)) - -for (otype, jtype) in julia_types - @eval begin - @cxxdereference Base.getindex(attr::Attribute, ::Type{$jtype}) = $(Symbol("get1_", type_symbols[otype]))(attr) - end -end - -@doc """ - getindex(attr::Attribute) - attr[] -""" Base.getindex - -@cxxdereference Base.getindex(attr::Attribute) = getindex(attr, dtype(attr)) diff --git a/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl b/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl deleted file mode 100644 index b0c8f7a5f1..0000000000 --- a/src/binding/julia/openPMD.jl/src/BaseRecordComponent.jl +++ /dev/null @@ -1,28 +0,0 @@ -# BaseRecordComponent - -@doc """ - abstract type BaseRecordComponent <: Attributable end -""" BaseRecordComponent -export BaseRecordComponent - -@doc """ - unit_SI(comp::BaseRecordComponent)::CxxDouble -""" unit_SI -export unit_SI - -@doc """ - reset_datatype!(comp::BaseRecordComponent, T::Type) -""" reset_datatype! -export reset_datatype! -@cxxdereference reset_datatype!(comp::BaseRecordComponent, T::Type) = reset_datatype1!(comp, openpmd_type(T)) - -@doc """ - get_datatype(comp::BaseRecordComponent)::Type -""" get_datatype -export get_datatype -@cxxdereference get_datatype(comp::BaseRecordComponent) = julia_type(get_datatype1(comp)) - -@doc """ - is_constant(comp::BaseRecordComponent)::Bool -""" is_constant -export is_constant diff --git a/src/binding/julia/openPMD.jl/src/Container.jl b/src/binding/julia/openPMD.jl/src/Container.jl deleted file mode 100644 index 1dce0580f2..0000000000 --- a/src/binding/julia/openPMD.jl/src/Container.jl +++ /dev/null @@ -1,65 +0,0 @@ -# Container - -@doc """ - abstract type Container{T,K} <: Attributable end -""" Container -export Container - -Base.eltype(::Type{Container{T,K}}) where {T,K} = T -Base.keytype(::Type{Container{T,K}}) where {T,K} = K - -@doc """ - isempty(cont::Container) -""" Base.isempty -@cxxdereference Base.isempty(cont::Container) = empty1(cont) - -@doc """ - length(cont::Container) -""" Base.length -@cxxdereference Base.length(cont::Container) = Int(length1(cont)) - -@doc """ - empty!(cont::Container) -""" Base.empty! -@cxxdereference Base.empty!(cont::Container) = (empty1!(cont); cont) - -@doc """ - getindex(cont::Container, key) - cont[key] -""" Base.getindex -@cxxdereference Base.getindex(cont::Container, key) = getindex1(cont, key) - -@doc """ - get!(cont::Container, key) -""" Base.get! -@cxxdereference Base.get!(cont::Container, key) = get1!(cont, key) - -@doc """ - setindex!(cont::Container, value, key) - cont[key] = value -""" Base.setindex! -@cxxdereference Base.setindex!(cont::Container, value, key) = setindex1!(cont, value, key) - -@doc """ - count(cont::Container) -""" Base.count -@cxxdereference Base.count(cont::Container, key) = Int(count1(cont, key)) - -@doc """ - in(key, cont::Container) - key in cont -""" Base.in -@cxxdereference Base.in(key, cont::Container) = contains1(cont, key) - -@doc """ - delete!(cont::Container, key) -""" Base.delete! -@cxxdereference Base.delete!(cont::Container, key) = (delete1!(cont, key); cont) - -@doc """ - keys(cont::Container)::AbstractVector -""" Base.keys -@cxxdereference Base.keys(cont::Container) = keys1(cont) - -# @cxxdereference Base.values(cont::Container) = values1(cont) -# @cxxdereference Base.collect(cont::Container) = collect1(cont) diff --git a/src/binding/julia/openPMD.jl/src/Dataset.jl b/src/binding/julia/openPMD.jl/src/Dataset.jl deleted file mode 100644 index 9dce4ca549..0000000000 --- a/src/binding/julia/openPMD.jl/src/Dataset.jl +++ /dev/null @@ -1,96 +0,0 @@ -# Dataset - -""" - const Extent = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} -""" -const Extent{D} = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} -export Extent - -# TODO: Don't call `reverse`, use something more efficient -wrap_extent(extent::Vector{UInt64}) = StdVector(reverse(extent)) -wrap_extent(extent::Vector) = wrap_extent(Vector{UInt64}(extent)) -wrap_extent(extent::SVector) = wrap_extent(UInt64[extent...]) -wrap_extent(extent::Tuple) = wrap_extent(UInt64[extent...]) - -""" - const Offset = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} -""" -const Offset{D} = Union{NTuple{D,Int},SVector{D,Int},Vector{D}} -export Offset - -wrap_offset(offset) = wrap_extent(offset) - -@doc """ - mutable struct Dataset - .... - end - Dataset(::Type{<:OpenPMDType}, extent::Extent, options::AbstractString="{}") - Dataset(extent::Extent) -""" Dataset -export Dataset - -for (otype, jtype) in julia_types - @eval begin - @cxxdereference function Dataset(::Type{$jtype}, extent::Extent, options::AbstractString="{}") - return Dataset($otype, wrap_extent(extent), options) - end - end -end - -@doc """ - extend!(dset::Dataset, newextent::Extent) -""" extend! -export extend! -@cxxdereference extentd!(dset::Dataset, newextent::Extent) = extend1!(dset, wrap_extent(newextent)) - -@doc """ - set_chunk_size!(dset::Dataset, chunk_size::Extent) -""" set_chunk_size! -export set_chunk_size! -@cxxdereference set_chunk_size!(dset::Dataset, chunk_size::Extent) = set_chunk_size1!(dset, wrap_extent(chunk_size)) - -@doc """ - set_compression!(dset::Dataset, compression::AbstractString, level::Int) -""" set_compression! -export set_compression! - -@doc """ - set_custom_transform!(dset::Dataset, transform::AbstractString) -""" set_custom_transform! -export set_custom_transform! - -""" - size(dset::Dataset) -""" -@cxxdereference Base.size(dset::Dataset) = reverse(Tuple(extent1(dset))) - -""" - eltype(dset::Dataset) -""" -@cxxdereference Base.eltype(dset::Dataset) = julia_type(dtype1(dset)) - -""" - ndims(dset::Dataset) -""" -@cxxdereference Base.ndims(dset::Dataset) = Int(rank1(dset)) - -""" - chunk_size(dset::Dataset) -""" -@cxxdereference chunk_size(dset::Dataset) = reverse(Tuple(chunk_size1(dset))) -export chunk_size - -@doc """ - compression(dset::Dataset)::AbstractString -""" compression -export compression - -@doc """ - transform(dset::Dataset)::AbstractString -""" transform -export transform - -@doc """ - options(dset::Dataset)::AbstractString -""" options -export options diff --git a/src/binding/julia/openPMD.jl/src/Datatype.jl b/src/binding/julia/openPMD.jl/src/Datatype.jl deleted file mode 100644 index bfb046d116..0000000000 --- a/src/binding/julia/openPMD.jl/src/Datatype.jl +++ /dev/null @@ -1,245 +0,0 @@ -# Datatype - -@doc """ - @enum Datatype begin - CHAR => CxxChar - UCHAR => CxxUChar - SHORT => CxxShort - INT => CxxInt - LONG => CxxLong, - LONGLONG => CxxLongLong - USHORT => CxxUShort - UINT => CxxUInt - ULONG => CxxULong, - ULONGLONG => CxxULongLong - FLOAT => CxxFloat - DOUBLE => CxxDouble, - CFLOAT => Complex{CxxFloat} - CDOUBLE => Complex{CxxDouble} - STRING => String, - VEC_CHAR => Vector{CxxChar} - VEC_UCHAR => Vector{CxxUChar} - VEC_SHORT => Vector{CxxShort}, - VEC_INT => Vector{CxxInt} - VEC_LONG => Vector{CxxLong} - VEC_LONGLONG => Vector{CxxLongLong}, - VEC_USHORT => Vector{CxxUShort} - VEC_UINT => Vector{CxxUInt} - VEC_ULONG => Vector{CxxULong}, - VEC_ULONGLONG => Vector{CxxULongLong} - VEC_FLOAT => Vector{CxxFloat}, - VEC_DOUBLE => Vector{CxxDouble} - VEC_CFLOAT => Vector{Complex{CxxFloat}}, - VEC_CDOUBLE => Vector{Complex{CxxDouble}} - VEC_STRING => Vector{String} - BOOL => CxxBool, - ARR_DBL_7 => SVector{7,CxxDouble}) - end -""" Datatype -export Datatype, CHAR, UCHAR, SHORT, INT, LONG, LONGLONG, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, CFLOAT, CDOUBLE, STRING, - VEC_CHAR, VEC_UCHAR, VEC_SHORT, VEC_INT, VEC_LONG, VEC_LONGLONG, VEC_USHORT, VEC_UINT, VEC_ULONG, VEC_ULONGLONG, VEC_FLOAT, - VEC_DOUBLE, VEC_CFLOAT, VEC_CDOUBLE, VEC_STRING, ARR_DBL_7, BOOL - -# CxxWrap promises these types, but doesn't define them -const CxxDouble = Cdouble -const CxxFloat = Cfloat -const CxxInt = Cint -const CxxShort = Cshort -const CxxUInt = Cuint -const CxxUShort = Cushort -export CxxDouble, CxxFloat, CxxInt, CxxShort, CxxUInt, CxxUShort - -Base.hash(b::CxxBool, u::UInt) = hash(hash(Bool(b), u), UInt(0x4c87662d)) - -# We cannot use this definition for equality. It leads to `LONG` == -# `LONGLONG` on some systems. - -# Base.:(==)(d::Datatype, e::Datatype) = is_same1(d, e) -# function Base.hash(d::Datatype, h::UInt) -# isvec = is_vector1(d) -# isint, issig = is_integer1(d) -# isfp = is_floating_point1(d) -# iscfp = is_complex_floating_point1(d) -# bits = to_bits1(d) -# return hash(0x6b224312, hash(isvec, hash(isint, hash(issig, hash(isfp, hash(iscfp, hash(bits, h))))))) -# end - -Base.hash(d::Datatype, u::UInt) = hash(hash(convert(UInt, d), u), UInt(0x6b224312)) - -# Convert between Julia types and OpenPMD type ids - -const type_symbols = Dict{Datatype,Symbol}(CHAR => :CHAR, UCHAR => :UCHAR, SHORT => :SHORT, INT => :INT, LONG => :LONG, - LONGLONG => :LONGLONG, USHORT => :USHORT, UINT => :UINT, ULONG => :ULONG, - ULONGLONG => :ULONGLONG, FLOAT => :FLOAT, DOUBLE => :DOUBLE, CFLOAT => :CFLOAT, - CDOUBLE => :CDOUBLE, STRING => :STRING, VEC_CHAR => :VEC_CHAR, VEC_UCHAR => :VEC_UCHAR, - VEC_SHORT => :VEC_SHORT, VEC_INT => :VEC_INT, VEC_LONG => :VEC_LONG, - VEC_LONGLONG => :VEC_LONGLONG, VEC_USHORT => :VEC_USHORT, VEC_UINT => :VEC_UINT, - VEC_ULONG => :VEC_ULONG, VEC_ULONGLONG => :VEC_ULONGLONG, VEC_FLOAT => :VEC_FLOAT, - VEC_DOUBLE => :VEC_DOUBLE, VEC_CFLOAT => :VEC_CFLOAT, VEC_CDOUBLE => :VEC_CDOUBLE, - VEC_STRING => :VEC_STRING, ARR_DBL_7 => :ARR_DBL_7, BOOL => :BOOL) -const julia_types = Dict{Datatype,Type}(CHAR => CxxChar, UCHAR => CxxUChar, SHORT => CxxShort, INT => CxxInt, LONG => CxxLong, - LONGLONG => CxxLongLong, USHORT => CxxUShort, UINT => CxxUInt, ULONG => CxxULong, - ULONGLONG => CxxULongLong, FLOAT => CxxFloat, DOUBLE => CxxDouble, - CFLOAT => Complex{CxxFloat}, CDOUBLE => Complex{CxxDouble}, STRING => String, - VEC_CHAR => Vector{CxxChar}, VEC_UCHAR => Vector{CxxUChar}, VEC_SHORT => Vector{CxxShort}, - VEC_INT => Vector{CxxInt}, VEC_LONG => Vector{CxxLong}, VEC_LONGLONG => Vector{CxxLongLong}, - VEC_USHORT => Vector{CxxUShort}, VEC_UINT => Vector{CxxUInt}, VEC_ULONG => Vector{CxxULong}, - VEC_ULONGLONG => Vector{CxxULongLong}, VEC_FLOAT => Vector{CxxFloat}, - VEC_DOUBLE => Vector{CxxDouble}, VEC_CFLOAT => Vector{Complex{CxxFloat}}, - VEC_CDOUBLE => Vector{Complex{CxxDouble}}, VEC_STRING => Vector{String}, - ARR_DBL_7 => SVector{7,CxxDouble}, BOOL => CxxBool) -function julia_type(d::Datatype) - T = get(julia_types, d, nothing) - T ≡ nothing && error("unknown Datatype $d") - return T -end - -openpmd_type(::Type{CxxChar}) = CHAR -openpmd_type(::Type{CxxUChar}) = UCHAR -openpmd_type(::Type{CxxShort}) = SHORT -openpmd_type(::Type{CxxInt}) = INT -openpmd_type(::Type{CxxLong}) = LONG -openpmd_type(::Type{CxxLongLong}) = LONGLONG -openpmd_type(::Type{CxxUShort}) = USHORT -openpmd_type(::Type{CxxUInt}) = UINT -openpmd_type(::Type{CxxULong}) = ULONG -openpmd_type(::Type{CxxULongLong}) = ULONGLONG -openpmd_type(::Type{CxxFloat}) = FLOAT -openpmd_type(::Type{CxxDouble}) = DOUBLE -openpmd_type(::Type{Complex{CxxFloat}}) = CFLOAT -openpmd_type(::Type{Complex{CxxDouble}}) = CDOUBLE -openpmd_type(::Type{String}) = STRING -openpmd_type(::Type{Vector{CxxChar}}) = VEC_CHAR -openpmd_type(::Type{Vector{CxxUChar}}) = VEC_UCHAR -openpmd_type(::Type{Vector{CxxShort}}) = VEC_SHORT -openpmd_type(::Type{Vector{CxxInt}}) = VEC_INT -openpmd_type(::Type{Vector{CxxLong}}) = VEC_LONG -openpmd_type(::Type{Vector{CxxLongLong}}) = VEC_LONGLONG -openpmd_type(::Type{Vector{CxxUShort}}) = VEC_USHORT -openpmd_type(::Type{Vector{CxxUInt}}) = VEC_UINT -openpmd_type(::Type{Vector{CxxULong}}) = VEC_ULONG -openpmd_type(::Type{Vector{CxxULongLong}}) = VEC_ULONGLONG -openpmd_type(::Type{Vector{CxxFloat}}) = VEC_FLOAT -openpmd_type(::Type{Vector{CxxDouble}}) = VEC_DOUBLE -openpmd_type(::Type{Vector{Complex{CxxFloat}}}) = VEC_CFLOAT -openpmd_type(::Type{Vector{Complex{CxxDouble}}}) = VEC_CDOUBLE -openpmd_type(::Type{Vector{String}}) = VEC_STRING -openpmd_type(::Type{SVector{7,CxxDouble}}) = ARR_DBL_7 -openpmd_type(::Type{CxxBool}) = BOOL - -""" - openPMD_datatypes::AbstractVector{Datatype} -""" -openPMD_datatypes -export openPMD_datatypes - -""" - OpenPMDType = Union{...} -""" -const OpenPMDType = Union{CxxChar,CxxUChar,CxxShort,CxxInt,CxxLong,CxxLongLong,CxxUShort,CxxUInt,CxxULong,CxxULongLong,CxxFloat, - CxxDouble,Complex{CxxFloat},Complex{CxxDouble},String,Vector{CxxChar},Vector{CxxUChar},Vector{CxxShort}, - Vector{CxxInt},Vector{CxxLong},Vector{CxxLongLong},Vector{CxxUShort},Vector{CxxUInt},Vector{CxxULong}, - Vector{CxxULongLong},Vector{CxxFloat},Vector{CxxDouble},Vector{Complex{CxxFloat}}, - Vector{Complex{CxxDouble}},Vector{String},SVector{7,CxxDouble},CxxBool} -export OpenPMDType - -""" - determine_datatype(::Type)::Datatype -""" -determine_datatype(T::Type) = openpmd_type(T) -export determine_datatype - -""" - to_bytes(::Type)::Int -""" -to_bytes(T::Type) = Int(to_bytes1(openpmd_type(T))) -export to_bytes - -""" - to_bits(::Type)::Int -""" -to_bits(T::Type) = Int(to_bits1(openpmd_type(T))) -export to_bits - -""" - is_vector(::Type)::Bool -""" -is_vector(T::Type) = is_vector1(openpmd_type(T)) -export is_vector - -""" - is_floating_point(::Type)::Bool -""" -is_floating_point(T::Type) = is_floating_point1(openpmd_type(T)) -export is_floating_point - -""" - is_complex_floating_point(::Type)::Bool -""" -is_complex_floating_point(T::Type) = is_complex_floating_point1(openpmd_type(T)) -export is_complex_floating_point - -""" - is_integer(::Type)::Tuple{Bool,Bool} - -Whether the type is an integer (first tuple element), and if so, -whether it is signed (second tuple element). -""" -is_integer(T::Type) = Tuple{Bool,Bool}(is_integer1(openpmd_type(T))) -export is_integer - -""" - is_same(::Type, ::Type)::Bool -""" -is_same(T1::Type, T2::Type) = is_same1(openpmd_type(T1), openpmd_type(T2)) -export is_same - -# """ -# is_same_floating_point(::Type, ::Type)::Bool -# """ -# is_same_floating_point(T1::Type, T2::Type) = is_same_floating_point(openpmd_type(T1), openpmd_type(T2)) -# export is_same_floating_point -# -# """ -# is_same_complex_floating_point(::Type, ::Type)::Bool -# """ -# is_same_complex_floating_point(T!::Type, T2::Type) = is_same_complex_floating_point(openpmd_type(T1), openpmd_type(T2)) -# export is_same_complex_floating_point -# -# """ -# is_same_integer(::Type, ::Type)::Bool -# """ -# is_same_integer(T1::Type, T2::Type) = is_same_integer(openpmd_type(T1), openpmd_type(T2)) -# export is_same_integer - -""" - basic_datatype(::Type)::Type -""" -basic_datatype(T::Type) = julia_type(basic_datatype1(openpmd_type(T))) -export basic_datatype - -""" - to_vector_type(::Type)::Type -""" -to_vector_type(T::Type) = julia_type(to_vector_type1(openpmd_type(T))) -export to_vector_type - -""" - datatype_to_string(::Type)::AbstractString -""" -datatype_to_string(T::Type) = datatype_to_string1(openpmd_type(T)) -export datatype_to_string - -""" - string_to_datatype(str::AbstractString)::Type -""" -string_to_datatype(str::AbstractString) = julia_type(string_to_datatype1(str)) -export string_to_datatype - -""" - warn_wrong_dtype(key::AbstractString, ::Type{Store}, ::Type{Request}) where {Store,Request} -""" -function warn_wrong_dtype1(key::AbstractString, ::Type{Store}, ::Type{Request}) where {Store,Request} - return warn_wrong_dtype(key, openpmd_type(Store), openpmd_type(Request)) -end -export warn_wrong_dtype diff --git a/src/binding/julia/openPMD.jl/src/Format.jl b/src/binding/julia/openPMD.jl/src/Format.jl deleted file mode 100644 index e5151137e0..0000000000 --- a/src/binding/julia/openPMD.jl/src/Format.jl +++ /dev/null @@ -1,28 +0,0 @@ -# Format - -@doc """ - @enum Format begin - HDF5 - ADIOS1 - ADIOS2 - ADIOS2_SST - ADIOS2_SSC - JSON - DUMMY - end -""" Format -export Format, HDF5, ADIOS1, ADIOS2, ADIOS2_SST, ADIOS2_SSC, JSON, DUMMY - -Base.hash(fmt::Format, u::UInt) = hash(hash(convert(UInt, fmt), u), UInt(0x2d9a9364)) - -""" - determine_format(filename::AbstractString)::Format -""" -function determine_format end -export determine_format - -""" - suffix(format::Format)::AbstractString -""" -function suffix end -export suffix diff --git a/src/binding/julia/openPMD.jl/src/Iteration.jl b/src/binding/julia/openPMD.jl/src/Iteration.jl deleted file mode 100644 index 4c45f01a7a..0000000000 --- a/src/binding/julia/openPMD.jl/src/Iteration.jl +++ /dev/null @@ -1,58 +0,0 @@ -# Iteration - -@doc """ - mutable struct Iteration <: Attributable - ... - end -""" Iteration -export Iteration - -@doc """ - time(iter::Iteration)::CxxDouble -""" Base.time -@cxxdereference Base.time(iter) = time1(iter) - -@doc """ - set_time!(iter::Iteration, time::CxxDouble) -""" set_time! -export set_time! - -@doc """ - dt(iter::Iteration)::CxxDouble -""" dt -export dt - -@doc """ - set_dt!(iter::Iteration, dt::CxxDouble) -""" set_dt! -export set_dt! - -@doc """ - time_unit_SI(iter::Iteration)::CxxDouble -""" time_unit_SI -export time_unit_SI - -@doc """ - set_time_unit_SI!(iter::Iteration, time_unit_SI::CxxDouble) -""" set_time_unit_SI! -export set_time_unit_SI! - -@doc """ - close(iter::Iteration; flush::Bool=true) -""" Base.close -@cxxdereference Base.close(iter::Iteration; flush::Bool=true) = close1(iter, flush) - -@doc """ - closed(iter::Iteration)::Bool -""" closed -export closed - -@doc """ - closed_by_writer(iter::Iteration)::Bool -""" closed_by_writer -export closed_by_writer - -@doc """ - meshes(iter::Iteration)::Container{Mesh} -""" meshes -export meshes diff --git a/src/binding/julia/openPMD.jl/src/Mesh.jl b/src/binding/julia/openPMD.jl/src/Mesh.jl deleted file mode 100644 index 4c5e9ff481..0000000000 --- a/src/binding/julia/openPMD.jl/src/Mesh.jl +++ /dev/null @@ -1,140 +0,0 @@ -# Mesh - -@doc """ - @enum Geometry begin - cartesian - theta_mode - cylindrical - spherical - other - end -""" Geometry -export Geometry, cartesian, theta_mode, cylindrical, spherical, other - -@doc """ - @enum DataOrder begin - C - F - end -""" DataOrder -export DataOrder, C, F - -@doc """ - mutable struct Mesh <: Container{MeshRecordComponent} - ... - end -""" Mesh -export Mesh - -@doc """ - unit_dimension(mesh::Mesh)::SVector{7,Double} -""" unit_dimension -export unit_dimension - -@doc """ - isscalar(mesh::Mesh)::Bool -""" isscalar -export isscalar - -@doc """ - geometry(mesh::Mesh)::Geometry -""" geometry -export geometry - -@doc """ - set_geometry!(mesh::Mesh, geom::Geometry) -""" set_geometry! -export set_geometry! - -@doc """ - geometry_parameters(mesh::Mesh)::AbstractString -""" geometry_parameters -export geometry_parameters - -@doc """ - set_geometry_parameters!(mesh::Mesh, params::AbstractString) -""" set_geometry_parameters! -export set_geometry_parameters! - -@doc """ - data_order(mesh::Mesh) -""" data_order -export data_order - -@doc """ - set_data_order!(mesh::Mesh, order::DataOrder) -""" set_data_order! -export set_data_order! - -@doc """ - axis_labels(mesh::Mesh)::AbstractVector{<:AbstractString} -""" axis_labels -export axis_labels - -@doc """ - set_axis_labels!(mesh::Mesh, labels::AbstractVector{<:AbstractString}) -""" set_axis_labels! -export set_axis_labels! -@cxxdereference function set_axis_labels!(mesh::Mesh, labels::AbstractVector{<:AbstractString}) - return set_axis_labels1!(mesh, wrap_vector(labels)) -end - -@doc """ - grid_spacing(mesh::Mesh)::AbstractVector{CxxDouble} -""" grid_spacing -export grid_spacing - -@doc """ - set_grid_spacing!(mesh::Mesh, spacing::AbstractVector{CxxDouble}) -""" set_grid_spacing! -export set_grid_spacing! -@cxxdereference set_grid_spacing!(mesh::Mesh, spacing::AbstractVector{CxxDouble}) = set_grid_spacing1!(mesh, wrap_vector(spacing)) - -@doc """ - grid_global_offset(mesh::Mesh)::AbstractVector{CxxDouble} -""" grid_global_offset -export grid_global_offset - -@doc """ - set_grid_global_offset!(mesh::Mesh, offset::AbstractVector{CxxDouble}) -""" set_grid_global_offset! -export set_grid_global_offset! -@cxxdereference function set_grid_global_offset!(mesh::Mesh, offset::AbstractVector{CxxDouble}) - return set_grid_global_offset1!(mesh, wrap_vector(offset)) -end - -@doc """ - grid_unit_SI(mesh::Mesh)::CxxDouble -""" grid_unit_SI -export grid_unit_SI - -@doc """ - set_grid_unit_SI!(mesh::Mesh, unit::CxxDouble) -""" set_grid_unit_SI! -export set_grid_unit_SI! - -@doc """ - set_unit_dimension!(mesh::Mesh, unit_dim::Dict{UnitDimension,<:AbstractFloat}) -""" set_unit_dimension! -export set_unit_dimension! -@cxxdereference function set_unit_dimension!(mesh::Mesh, unit_dim::Dict{UnitDimension,<:AbstractFloat}) - return set_unit_dimension1!(mesh, - SVector{7,Float64}(get(unit_dim, L, 0.0), get(unit_dim, M, 0.0), get(unit_dim, T, 0.0), - get(unit_dim, I, 0.0), get(unit_dim, θ, 0.0), get(unit_dim, N, 0.0), - get(unit_dim, J, 0.0))) -end - -@doc """ - time_offset(mesh::Mesh)::CxxDouble -""" time_offset -export time_offset - -@doc """ - set_time_offset!(mesh::Mesh, unit::CxxDouble) -""" set_time_offset! -export set_time_offset! - -""" - const SCALAR::AbstractString -""" -const SCALAR = SCALAR1() diff --git a/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl b/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl deleted file mode 100644 index 5934a3c504..0000000000 --- a/src/binding/julia/openPMD.jl/src/MeshRecordComponent.jl +++ /dev/null @@ -1,36 +0,0 @@ -# MeshRecordComponent - -@doc """ - mutable struct MeshRecordComponent <: RecordComponent - ... - end -""" MeshRecordComponent -export MeshRecordComponent - -@doc """ - position(comp::MeshRecordComponent)::AbstractVector{CxxDouble} -""" Base.position -@cxxdereference Base.position(comp::MeshRecordComponent) = position1(comp) - -@doc """ - set_position!(comp::MeshRecordComponent, newpos::Union{NTuple{D,CxxDouble}, AbstractVector{CxxDouble}}) -""" set_position! -export set_position! -@cxxdereference function set_position!(comp::MeshRecordComponent, newpos::AbstractVector{CxxDouble}) - return set_position1!(comp, wrap_vector(newpos)) -end -@cxxdereference function set_position!(comp::MeshRecordComponent, newpos::NTuple{D,CxxDouble} where {D}) - return set_position!(comp, CxxDouble[newpos...]) -end - -@doc """ - make_constant(comp::MeshRecordComponent, value::OpenMPType) -""" make_constant -export make_constant -for (otype, jtype) in julia_types - @eval begin - @cxxdereference function make_constant(comp::MeshRecordComponent, value::$jtype) - return $(Symbol("make_constant1_", type_symbols[otype]))(comp, value) - end - end -end diff --git a/src/binding/julia/openPMD.jl/src/RecordComponent.jl b/src/binding/julia/openPMD.jl/src/RecordComponent.jl deleted file mode 100644 index 80a203387d..0000000000 --- a/src/binding/julia/openPMD.jl/src/RecordComponent.jl +++ /dev/null @@ -1,81 +0,0 @@ -# RecordComponent - -@doc """ - @enum Allocation begin - USER - API - AUTO - end -""" Allocation -export Allocation, USER, API, AUTO - -@doc """ - abstract type RecordComponent <: BaseRecordComponent end -""" RecordComponent -export RecordComponent - -@doc """ - set_unit_SI!(comp::RecordComponent, unit::CxxDouble) -""" set_unit_SI! -export set_unit_SI! - -@doc """ - reset_dataset!(comp::RecordComponent, dset::Dataset) -""" reset_dataset! -export reset_dataset! - -@doc """ - ndims(comp::RecordComponent) -""" Base.ndims -@cxxdereference Base.ndims(comp::RecordComponent) = Int(get_dimensionality1(comp)) - -@doc """ - size(comp::RecordComponent) -""" Base.size -@cxxdereference Base.size(comp::RecordComponent) = Tuple(get_extent1(comp)) - -@doc """ - make_constant(comp::RecordComponent, value::OpenMPType) -""" make_constant -export make_constant -for (otype, jtype) in julia_types - @eval begin - @cxxdereference function make_constant(comp::RecordComponent, value::$jtype) - return $(Symbol("make_constant1_", type_symbols[otype]))(comp, value) - end - end -end - -@doc """ - make_empty(T::Type, comp::RecordComponent, ndims::Int) -""" make_empty -export make_empty -@cxxdereference make_empty(T::Type, comp::RecordComponent, ndims::Int) = make_empty1(comp, openpmd_type(T), ndims) - -@doc """ - isempty(comp::RecordComponent) -""" Base.isempty -@cxxdereference Base.isempty(comp::RecordComponent) = empty1(comp) - -# TODO: load_chunk - -@doc """ - store_chunk(comp::RecordComponent, data::AbstractArray, offset::Offset, extent::Extent) -""" store_chunk -export store_chunk -# Object lifetime management for store_chunk: Ideally, we would ensure -# that the Julia object stays alive until openPMD has written the -# dataset. To simplify things, we currently create a temporary buffer -# that is managed by a C++ std::shared_ptr. Note that `wrap_vector` -# copies the data, which also needs to be avoided. -for (otype, jtype) in julia_types - @eval begin - @cxxdereference function store_chunk(comp::RecordComponent, data::AbstractArray{$jtype}, offset::Offset, extent::Extent) - # @assert length(offset) == length(extent) == ndims(comp) - @assert all(extent .>= 0) - @assert length(data) == prod(extent) - return $(Symbol("store_chunk_copy1_", type_symbols[otype]))(comp, wrap_vector(reshape(data, :)), wrap_offset(offset), - wrap_extent(extent)) - end - end -end diff --git a/src/binding/julia/openPMD.jl/src/Series.jl b/src/binding/julia/openPMD.jl/src/Series.jl deleted file mode 100644 index 0d582e8cbe..0000000000 --- a/src/binding/julia/openPMD.jl/src/Series.jl +++ /dev/null @@ -1,159 +0,0 @@ -# Series - -@doc """ - mutable struct Series <: Attributable - ... - end - Series() - Series(filepath::AbstractString, access::Access, comm::MPI_Comm, options::AbstractString="{}") - Series(filepath::AbstractString, access::Access, options::AbstractString="{}") -""" Series -export Series - -@doc """ - openPMD_version(series::Series)::AbstractString -""" openPMD_version -export openPMD_version - -@doc """ - set_openPMD_version!(series::Series, version::AbstractString) -""" set_openPMD_version! -export set_openPMD_version! - -@doc """ - openPMD_extension(series::Series)::AbstractString -""" openPMD_extension -export openPMD_extension - -@doc """ - set_openPMD_extension!(series::Series, extension::AbstractString) -""" set_openPMD_extension! -export set_openPMD_extension! - -@doc """ - base_path(series::Series)::AbstractString -""" base_path -export base_path - -@doc """ - set_base_path!(series::Series, path::AbstractString) -""" set_base_path! -export set_base_path! - -@doc """ - meshes_path(series::Series)::AbstractString -""" meshes_path -export meshes_path - -@doc """ - set_meshes_path!(series::Series, path::AbstractString) -""" set_meshes_path! -export set_meshes_path! - -@doc """ - particles_path(series::Series)::AbstractString -""" particles_path -export particles_path - -@doc """ - set_particles_path!(series::Series, path::AbstractString) -""" set_particles_path! -export set_particles_path! - -@doc """ - author(series::Series)::AbstractString -""" author -export author - -@doc """ - set_author!(series::Series, author::AbstractString) -""" set_author! -export set_author! - -@doc """ - software(series::Series)::AbstractString -""" software -export software - -@doc """ - set_software!(series::Series, software::AbstractString, version::AbstractString="unspecified") -""" set_software! -export set_software! - -@doc """ - software_version(series::Series)::AbstractString -""" software_version -export software_version - -@doc """ - date(series::Series)::AbstractString -""" date -export date - -@doc """ - set_date!(series::Series, date::AbstractString) -""" set_date! -export set_date! - -@doc """ - software_dependencies(series::Series)::AbstractString -""" software_dependencies -export software_dependencies - -@doc """ - set_software_dependencies!(series::Series, dependencies::AbstractString) -""" set_software_dependencies! -export set_software_dependencies! - -@doc """ - machine(series::Series)::AbstractString -""" machine -export machine - -@doc """ - set_machine!(series::Series, machine::AbstractString) -""" set_machine! -export set_machine! - -# TODO: type.method("iteration_encoding", &SeriesImpl::iterationEncoding); -# TODO: type.method("set_iteration_encoding!", &SeriesImpl::setIterationEncoding); - -@doc """ - iteration_format(series::Series)::AbstractString -""" iteration_format -export iteration_format - -@doc """ - set_iteration_format!(series::Series, format::AbstractString) -""" set_iteration_format! -export set_iteration_format! - -@doc """ - name(series::Series)::AbstractString -""" name -export name - -@doc """ - set_name!(series::Series, name::AbstractString) -""" set_name! -export set_name! - -@doc """ - backend(series::Series)::AbstractString -""" backend -export backend - -@doc """ - flush(series::Series)::AbstractString -""" Base.flush -@cxxdereference Base.flush(series::SeriesImpl) = flush1(series) - -@doc """ - isvalid(series::Series) -""" Base.isvalid -@cxxdereference Base.isvalid(series::Series) = isvalid1(series) - -@doc """ - write_iterations(series::Series) -""" write_iterations -export write_iterations diff --git a/src/binding/julia/openPMD.jl/src/UnitDimension.jl b/src/binding/julia/openPMD.jl/src/UnitDimension.jl deleted file mode 100644 index b85cca2a3f..0000000000 --- a/src/binding/julia/openPMD.jl/src/UnitDimension.jl +++ /dev/null @@ -1,18 +0,0 @@ -# UnitDimension - -@doc """ - @enum UnitDimension begin - L # length - M # mass - T # time - I # electric current - θ # thermodynamic temperature - N # amount of substance - J # luminous intensity - end -""" UnitDimension -export UnitDimension, L, M, T, I, θ, N, J - -Base.convert(::Type{I}, d::UnitDimension) where {I<:Integer} = convert(I, reinterpret(UInt8, d)) - -Base.hash(d::UnitDimension, u::UInt) = hash(hash(convert(UInt, d), u), UInt(0xe2ff8533)) diff --git a/src/binding/julia/openPMD.jl/src/WriteIterations.jl b/src/binding/julia/openPMD.jl/src/WriteIterations.jl deleted file mode 100644 index f3801af0c2..0000000000 --- a/src/binding/julia/openPMD.jl/src/WriteIterations.jl +++ /dev/null @@ -1,13 +0,0 @@ -# WriteIterations - -@doc """ - mutable struct WriteIterations - ... - end -""" WriteIterations -export WriteIterations - -@doc """ - get!(iters::WriteIterations, key) -""" Base.get! -@cxxdereference Base.get!(iters::WriteIterations, key) = get1!(iters, key) diff --git a/src/binding/julia/openPMD.jl/src/openPMD.jl b/src/binding/julia/openPMD.jl/src/openPMD.jl deleted file mode 100644 index dfb24dc373..0000000000 --- a/src/binding/julia/openPMD.jl/src/openPMD.jl +++ /dev/null @@ -1,63 +0,0 @@ -module openPMD - -using CxxWrap -using StaticArrays - -@wrapmodule "/Users/eschnett/src/openPMD-api/build/lib/libopenPMD_jl.dylib" - -__init__() = @initcxx - -################################################################################ - -# TODO: -# -# - do we need to worry about `jlcxx::StrictlyTypedNumber`? -# -# - do we really need all the `@cxxdereference` macros? yes we do. -# maybe we need it only for explicitly declared functions and not -# for wrapped functions? -# -# - remove all the `Bool(...)` wrappers; they are not needed -# -# - put enum values into a namespace -# -# - do we really need different names to call templated functions? probably not, at least not for constructors. - -################################################################################ - -# Convert Julia vectors to `StdVector`, leave all other types alone -wrap_vector(xs::AbstractVector) = StdVector(xs) -wrap_vector(x) = x - -################################################################################ - -# The order in which these files are included matters. The order here -# should mirror the order in the file `openPMD.cpp` that implements -# the respective types, constants, and functions. - -include("Access.jl") -include("Datatype.jl") -include("Format.jl") -include("UnitDimension.jl") - -include("Attribute.jl") -include("Attributable.jl") -include("Dataset.jl") - -include("Container.jl") - -include("BaseRecordComponent.jl") -include("RecordComponent.jl") -include("MeshRecordComponent.jl") - -include("Mesh.jl") - -include("Iteration.jl") - -include("WriteIterations.jl") - -include("Series.jl") - -include("version.jl") - -end diff --git a/src/binding/julia/openPMD.jl/src/version.jl b/src/binding/julia/openPMD.jl/src/version.jl deleted file mode 100644 index 393c4beaa2..0000000000 --- a/src/binding/julia/openPMD.jl/src/version.jl +++ /dev/null @@ -1,34 +0,0 @@ -# version - -@doc """ - get_version()::AbstractString -""" get_version -export get_version - -@doc """ - get_standard()::AbstractString -""" get_standard -export get_standard - -@doc """ - get_standard_minimum()::AbstractString -""" get_standard_minimum -export get_standard_minimum - -@doc """ - get_variants()::Dict{String,Bool} -""" get_variants -export get_variants -function get_variants() - variants1 = get_variants1() - variants = Dict{String,Bool}() - for var1 in variants1 - variants[first(var1)] = second(var1) - end - return variants -end - -@doc """ - get_file_extensions()::AbstractVector{<:AbstractString} -""" get_file_extensions -export get_file_extensions diff --git a/src/binding/julia/openPMD.jl/test/Access.jl b/src/binding/julia/openPMD.jl/test/Access.jl deleted file mode 100644 index 64dcd21a28..0000000000 --- a/src/binding/julia/openPMD.jl/test/Access.jl +++ /dev/null @@ -1,11 +0,0 @@ -@testset "Access" begin - @test Access isa Type - @test READ_ONLY isa Access - @test READ_WRITE isa Access - @test CREATE isa Access - - @test READ_ONLY == READ_ONLY - @test READ_ONLY ≠ READ_WRITE - @test hash(READ_ONLY) isa UInt - @test hash(READ_ONLY) ≠ hash(convert(UInt, READ_ONLY)) -end diff --git a/src/binding/julia/openPMD.jl/test/Attributable.jl b/src/binding/julia/openPMD.jl/test/Attributable.jl deleted file mode 100644 index 298a60fe6a..0000000000 --- a/src/binding/julia/openPMD.jl/test/Attributable.jl +++ /dev/null @@ -1,22 +0,0 @@ -@testset "Attributable" begin - @test Attributable isa Type - @test isabstracttype(Attributable) - - obj = series - @test obj isa Attributable - set_attribute!(obj, "hello", 42) - set_attribute!(obj, "world", [float(π)]) - @test get_attribute(obj, "hello") === 42 - @test get_attribute(obj, "world") == [float(π)] - delete_attribute!(obj, "hello") - @test !contains_attribute(obj, "hello") - @test contains_attribute(obj, "world") - @test "world" ∈ attributes(obj) - @test num_attributes(obj) ≥ 1 - - set_comment!(obj, "abc αβγ") - @test comment(obj) == "abc αβγ" - - # Don't flush or close anything until the end of the test - # series_flush(obj) -end diff --git a/src/binding/julia/openPMD.jl/test/Attribute.jl b/src/binding/julia/openPMD.jl/test/Attribute.jl deleted file mode 100644 index 0177b8e18d..0000000000 --- a/src/binding/julia/openPMD.jl/test/Attribute.jl +++ /dev/null @@ -1,8 +0,0 @@ -# @testset "Attribute" begin -# @test Attribute isa Type -# -# #TODO attr = Attribute() -# #TODO @test dtype(attr) <: OpenPMDType -# #TODO @test attr[] isa OpenPMDType -# #TODO @test typeof(attr[]) === dtype(attr) -# end diff --git a/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl b/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl deleted file mode 100644 index 692ae02b66..0000000000 --- a/src/binding/julia/openPMD.jl/test/BaseRecordComponent.jl +++ /dev/null @@ -1,10 +0,0 @@ -@testset "BaseRecordComponent" begin - @test BaseRecordComponent isa Type - @test isabstracttype(BaseRecordComponent) - - #TODO comp = ??? - #TODO comp::BaseRecordComponent - #TODO @test unit_SI(comp) isa CxxDouble - - @warn "TODO" -end diff --git a/src/binding/julia/openPMD.jl/test/Container.jl b/src/binding/julia/openPMD.jl/test/Container.jl deleted file mode 100644 index 14a48552fb..0000000000 --- a/src/binding/julia/openPMD.jl/test/Container.jl +++ /dev/null @@ -1,33 +0,0 @@ -@testset "Container{$contT}" begin - T = contT - K = contK - @test Container{T,K} isa Type - @test isabstracttype(Container{T,K}) - - @test cont isa CxxRef{<:Container{T,K}} - - @test isempty(cont) isa Bool - @test (length(cont) == 0) == isempty(cont) - - empty!(cont) - @test isempty(cont) - @test length(cont) == 0 - - newval = get!(cont, "bubble") - @test length(cont) == 1 - @test cont["bubble"] == newval - - cont["bobble"] = newval - @test length(cont) == 2 - - @test count(cont, "bubble") == 1 - @test "bubble" ∈ cont - - delete!(cont, "bobble") - @test length(cont) == 1 - - @test keys(cont) == ["bubble"] - - # @cxxdereference Base.values(cont::Container) = values1(cont) - # @cxxdereference Base.collect(cont::Container) = collect1(cont) -end diff --git a/src/binding/julia/openPMD.jl/test/Dataset.jl b/src/binding/julia/openPMD.jl/test/Dataset.jl deleted file mode 100644 index 2cc023ba9f..0000000000 --- a/src/binding/julia/openPMD.jl/test/Dataset.jl +++ /dev/null @@ -1,13 +0,0 @@ -@testset "Dataset" begin - @test Extent isa Type - @test Offset isa Type - @test Dataset isa Type - - @test dset isa Dataset - - @test size(dset) == ext - @test eltype(dset) == dsetT - @test ndims(dset) == length(ext) - - # TODO: test chunk_size, compression, transform, options -end diff --git a/src/binding/julia/openPMD.jl/test/Datatype.jl b/src/binding/julia/openPMD.jl/test/Datatype.jl deleted file mode 100644 index 902514dcff..0000000000 --- a/src/binding/julia/openPMD.jl/test/Datatype.jl +++ /dev/null @@ -1,83 +0,0 @@ -@testset "Datatype" begin - @test Datatype isa Type - - otypes = [CHAR, UCHAR, SHORT, INT, LONG, LONGLONG, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, CFLOAT, CDOUBLE, STRING, - VEC_CHAR, VEC_UCHAR, VEC_SHORT, VEC_INT, VEC_LONG, VEC_LONGLONG, VEC_USHORT, VEC_UINT, VEC_ULONG, VEC_ULONGLONG, - VEC_FLOAT, VEC_DOUBLE, VEC_CFLOAT, VEC_CDOUBLE, VEC_STRING, BOOL, ARR_DBL_7] - otype_equiv = Dict(otype => otype for otype in otypes) - if sizeof(CxxLong) == sizeof(CxxLongLong) - otype_equiv[LONG] = LONGLONG - otype_equiv[ULONG] = ULONGLONG - otype_equiv[VEC_LONG] = VEC_LONGLONG - otype_equiv[VEC_ULONG] = VEC_ULONGLONG - end - for otype in otypes - @test otype isa Datatype - jtype = openPMD.julia_type(otype) - @test jtype <: OpenPMDType - otype′ = determine_datatype(jtype) - @test otype_equiv[otype′] ≡ otype_equiv[otype] - end - - jtypes = [CxxChar, CxxUChar, CxxShort, CxxInt, CxxLong, CxxLongLong, CxxUShort, CxxUInt, CxxULong, CxxULongLong, CxxFloat, - CxxDouble, Complex{CxxFloat}, Complex{CxxDouble}, String, Vector{CxxChar}, Vector{CxxUChar}, Vector{CxxShort}, - Vector{CxxInt}, Vector{CxxLong}, Vector{CxxLongLong}, Vector{CxxUShort}, Vector{CxxUInt}, Vector{CxxULong}, - Vector{CxxULongLong}, Vector{CxxFloat}, Vector{CxxDouble}, Vector{Complex{CxxFloat}}, Vector{Complex{CxxDouble}}, - Vector{String}, SVector{7,CxxDouble}, CxxBool] - jtype_equiv = Dict(jt => jt for jt in jtypes) - if sizeof(CxxLong) == sizeof(CxxLongLong) - jtype_equiv[CxxLong] = CxxLongLong - jtype_equiv[CxxULong] = CxxULongLong - jtype_equiv[Vector{CxxLong}] = Vector{CxxLongLong} - jtype_equiv[Vector{CxxULong}] = Vector{CxxULongLong} - end - for jtype in jtypes - @test jtype <: OpenPMDType - otype = determine_datatype(jtype) - @test otype isa Datatype - jtype′ = openPMD.julia_type(otype) - @test jtype′ ≡ jtype - end - - @test CHAR == CHAR - @test CHAR ≠ UCHAR - @test hash(CHAR) isa UInt - @test hash(CHAR) ≠ hash(convert(UInt8, CHAR)) - - for jtype in jtypes - if jtype <: Vector - # pass - elseif jtype <: String - # pass - else - @test to_bytes(jtype) == sizeof(eltype(jtype)) - @test to_bits(jtype) == 8 * sizeof(eltype(jtype)) - end - @test is_vector(jtype) == (jtype <: Vector) - ejtype = jtype <: Vector ? eltype(jtype) : jtype - @test is_floating_point(jtype) == (ejtype <: AbstractFloat) - @test is_complex_floating_point(jtype) == (ejtype <: Complex) - @test is_integer(jtype)[1] == (ejtype <: Integer && ejtype ∉ (CxxBool, CxxChar, CxxUChar)) - if is_integer(jtype)[1] - @test is_integer(jtype)[2] == (ejtype <: Signed) - end - for jtype′ in jtypes - @test is_same(jtype′, jtype) == (jtype_equiv[jtype′] === jtype_equiv[jtype]) - end - if jtype <: AbstractVector - @test basic_datatype(jtype) === eltype(jtype) - # @test to_vector_type(jtype) === jtype - else - @test basic_datatype(jtype) === jtype - if jtype === CxxBool - # skip; `CxxBool` is not accepted - # @test to_vector_type(jtype) === Vector{jtype} - else - @test to_vector_type(jtype) === Vector{jtype} - end - end - str = datatype_to_string(jtype) - @test str isa AbstractString - @test string_to_datatype(str) === jtype - end -end diff --git a/src/binding/julia/openPMD.jl/test/Format.jl b/src/binding/julia/openPMD.jl/test/Format.jl deleted file mode 100644 index 3318bd0639..0000000000 --- a/src/binding/julia/openPMD.jl/test/Format.jl +++ /dev/null @@ -1,24 +0,0 @@ -@testset "Format" begin - @test Format isa Type - @test HDF5 isa Format - @test ADIOS1 isa Format - @test ADIOS2 isa Format - @test ADIOS2_SST isa Format - @test ADIOS2_SSC isa Format - @test JSON isa Format - @test DUMMY isa Format - - @test HDF5 == HDF5 - @test HDF5 ≠ ADIOS1 - @test hash(HDF5) isa UInt - @test hash(HDF5) ≠ hash(convert(UInt, HDF5)) - - for format in [HDF5, ADIOS1, ADIOS2, ADIOS2_SST, ADIOS2_SSC, JSON] - suf = suffix(format) - @test suf isa AbstractString - @test !isempty(suf) - # Not all formats can be recognized by suffix - want_format = format == ADIOS1 ? ADIOS2 : format - @test determine_format("hello.$suf") == want_format - end -end diff --git a/src/binding/julia/openPMD.jl/test/Iteration.jl b/src/binding/julia/openPMD.jl/test/Iteration.jl deleted file mode 100644 index d4849b1645..0000000000 --- a/src/binding/julia/openPMD.jl/test/Iteration.jl +++ /dev/null @@ -1,22 +0,0 @@ -@testset "Iteration" begin - @test Iteration isa Type - - @test iter isa CxxRef{Iteration} - - t = 0.11 - set_time!(iter, t) - @test time(iter) === t - - dt_ = 0.01 - set_dt!(iter, dt_) - @test dt(iter) === dt_ - - tu = 1.1 - set_time_unit_SI!(iter, tu) - @test time_unit_SI(iter) === tu - - @test !closed(iter) - @test !closed_by_writer(iter) - - @test meshes(iter) isa CxxRef{Container{Mesh,StdString}} -end diff --git a/src/binding/julia/openPMD.jl/test/Mesh.jl b/src/binding/julia/openPMD.jl/test/Mesh.jl deleted file mode 100644 index 031f3e976d..0000000000 --- a/src/binding/julia/openPMD.jl/test/Mesh.jl +++ /dev/null @@ -1,14 +0,0 @@ -@testset "Mesh" begin - @test Geometry isa Type - @test cartesian isa Geometry - @test theta_mode isa Geometry - @test cylindrical isa Geometry - @test spherical isa Geometry - @test other isa Geometry - - @test DataOrder isa Type - @test C isa DataOrder - @test F isa DataOrder - - @test Mesh isa Type -end diff --git a/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl b/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl deleted file mode 100644 index 5f3150aa26..0000000000 --- a/src/binding/julia/openPMD.jl/test/MeshRecordComponent.jl +++ /dev/null @@ -1,14 +0,0 @@ -@testset "MeshRecordComponent" begin - @test MeshRecordComponent isa Type - - comp::CxxRef{MeshRecordComponent} - pos = [1.0, 2.0, 3.0] - set_position!(comp, pos) - @test position(comp) == pos - make_constant(comp, 3) - @test is_constant(comp) - make_constant(comp, float(π)) - @test is_constant(comp) - make_constant(comp, 1.0im) - @test is_constant(comp) -end diff --git a/src/binding/julia/openPMD.jl/test/RecordComponent.jl b/src/binding/julia/openPMD.jl/test/RecordComponent.jl deleted file mode 100644 index 8dffe6f104..0000000000 --- a/src/binding/julia/openPMD.jl/test/RecordComponent.jl +++ /dev/null @@ -1,9 +0,0 @@ -@testset "RecordComponent" begin - @test RecordComponent isa Type - @test isabstracttype(RecordComponent) - - data = Int[10i + j for i in 1:2, j in 1:3] - @test size(data) == ext - @test eltype(data) == dsetT - store_chunk(comp, data, (0, 0), size(data)) -end diff --git a/src/binding/julia/openPMD.jl/test/Series.jl b/src/binding/julia/openPMD.jl/test/Series.jl deleted file mode 100644 index d0a9e631e7..0000000000 --- a/src/binding/julia/openPMD.jl/test/Series.jl +++ /dev/null @@ -1,77 +0,0 @@ -@testset "Series" begin - @test Series isa Type - - @test series isa Series - - ver = openPMD_version(series) - set_openPMD_version!(series, ver) - @test ver == openPMD_version(series) - - ext = openPMD_extension(series) - set_openPMD_extension!(series, ext) - @test ext == openPMD_extension(series) - - bpath = base_path(series) - # Not allowed in openPMD ≤ 1.1.0 - # set_base_path!(series, bpath) - @test bpath == base_path(series) - - # Error if accessed when not present - if contains_attribute(series, "meshesPath") - mpath = meshes_path(series) - set_meshes_path!(series, mpath) - @test mpath == meshes_path(series) - end - - if contains_attribute(series, "particlesPath") - ppath = particles_path(series) - set_particles_path!(series, ppath) - @test ppath == particles_path(series) - end - - auth = author(series) - set_author!(series, auth) - @test auth == author(series) - - sw = software(series) - sv = software_version(series) - set_software!(series, sw, sv) - @test sw == software(series) - @test sv == software_version(series) - - dat = date(series) - set_date!(series, dat) - @test dat == date(series) - - if contains_attribute(series, "softwareDependencies") - deps = software_dependencies(series) - set_software_dependencies!(series, deps) - @test deps == software_dependencies(series) - end - - if contains_attribute(series, "machine") - mach = machine(series) - set_machine!(series, mach) - @test mach == machine(series) - end - - iterfmt = iteration_format(series) - # Cannot be set after a file has been written - # set_iteration_format!(series, iterfmt) - @test iterfmt == iteration_format(series) - - if contains_attribute(series, "name") - name = name(series) - set_name!(series, name) - @test name == name(series) - end - - bend = backend(series) - @test bend == "JSON" - - # flush(series) - - @test isvalid(series) - - @test write_iterations(series) isa WriteIterations -end diff --git a/src/binding/julia/openPMD.jl/test/UnitDimension.jl b/src/binding/julia/openPMD.jl/test/UnitDimension.jl deleted file mode 100644 index d546e77244..0000000000 --- a/src/binding/julia/openPMD.jl/test/UnitDimension.jl +++ /dev/null @@ -1,15 +0,0 @@ -@testset "UnitDimension" begin - @test UnitDimension isa Type - @test L isa UnitDimension - @test M isa UnitDimension - @test T isa UnitDimension - @test I isa UnitDimension - @test θ isa UnitDimension - @test N isa UnitDimension - @test J isa UnitDimension - - @test L == L - @test L ≠ M - @test hash(L) isa UInt - @test hash(L) ≠ hash(convert(UInt, L)) -end diff --git a/src/binding/julia/openPMD.jl/test/WriteIterations.jl b/src/binding/julia/openPMD.jl/test/WriteIterations.jl deleted file mode 100644 index fbadbcb24a..0000000000 --- a/src/binding/julia/openPMD.jl/test/WriteIterations.jl +++ /dev/null @@ -1,11 +0,0 @@ -@testset "WriteIterations" begin - @test WriteIterations isa Type - - @test iters isa WriteIterations - - # We cannot test getting a new iteration; doing so closes the current iteration - # newiter = get!(iters, 12) - # @test newiter isa Iteration - iter′ = get!(iters, 0) - @test iter′ isa CxxRef{Iteration} -end diff --git a/src/binding/julia/openPMD.jl/test/runtests.jl b/src/binding/julia/openPMD.jl/test/runtests.jl deleted file mode 100644 index f2cb14eaaf..0000000000 --- a/src/binding/julia/openPMD.jl/test/runtests.jl +++ /dev/null @@ -1,53 +0,0 @@ -using Base.Filesystem -using CxxWrap -using StaticArrays -using Test -using openPMD - -include("Access.jl") -include("Datatype.jl") -include("Format.jl") -include("UnitDimension.jl") - -#TODO const dirname = Filesystem.mktempdir(; cleanup=true) -const dirname = Filesystem.mktempdir(; cleanup=false) -const filename = joinpath(dirname, "hello.json") - -const series = Series(filename, CREATE) -set_name!(series, "hello") -set_author!(series, "Erik Schnetter ") -const iters = write_iterations(series) -const iter = get!(iters, 0) -const mesh = get!(meshes(iter), "my_first_mesh") -const comp = get!(mesh, "my_first_record") -set_position!(comp, (0.0, 0.0)) -const dsetT = Int -const ext = (2, 3) -const dset = Dataset(dsetT, ext) -reset_dataset!(comp, dset) - -include("Attribute.jl") -include("Attributable.jl") -include("Dataset.jl") - -include("BaseRecordComponent.jl") -include("RecordComponent.jl") -include("MeshRecordComponent.jl") - -cont = mesh -contT = MeshRecordComponent -contK = StdString -include("Container.jl") -include("Mesh.jl") - -include("Iteration.jl") - -include("WriteIterations.jl") - -include("Series.jl") - -include("version.jl") - -series_flush(series) - -close(iter) diff --git a/src/binding/julia/openPMD.jl/test/version.jl b/src/binding/julia/openPMD.jl/test/version.jl deleted file mode 100644 index b78dca5473..0000000000 --- a/src/binding/julia/openPMD.jl/test/version.jl +++ /dev/null @@ -1,12 +0,0 @@ -@testset "version" begin - @test get_version() isa AbstractString - @test get_standard() isa AbstractString - @test get_standard_minimum() isa AbstractString - vars = get_variants() - @test vars isa Dict{String,Bool} - @test "json" ∈ keys(vars) - @test vars["json"] - exts = get_file_extensions() - @test exts isa AbstractVector{<:AbstractString} - @test "json" ∈ exts -end From eee0d3582c39c272b2874be787e7452cd522cb62 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 11:17:38 -0400 Subject: [PATCH 04/94] Require C++17 for Julia wrappers --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a703c78022..904f181bf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,6 +627,7 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/openPMD.cpp src/binding/julia/version.cpp ) + target_compile_features(openPMD_jl PUBLIC cxx_std_17) target_link_libraries(openPMD_jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) endif() From 4d71540210458c380c57d094807038d9ff2412f5 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 15:51:15 -0400 Subject: [PATCH 05/94] Julia: Only require C++14 --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 904f181bf7..b0be076a38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,7 +627,16 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/openPMD.cpp src/binding/julia/version.cpp ) - target_compile_features(openPMD_jl PUBLIC cxx_std_17) + # target_compile_features(openPMD_jl PUBLIC cxx_std_17) + # On macOS, not all C++17 features are enabled by `cxx_std_17`: + # Older platforms (<10.14) do not have `std::variant`. We thus + # select C++14 so that openPMD's header files enable respective + # work-arounds. + target_compile_features(openPMD_jl PUBLIC cxx_std_14) + set_target_properties(openPMD_jl PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON + ) target_link_libraries(openPMD_jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) endif() From 0e6ec91cf958e09000726f4047ed792f2d041faa Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 15:57:42 -0400 Subject: [PATCH 06/94] Julia: Switch back to C++17 --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0be076a38..ae6e480788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,12 +627,12 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/openPMD.cpp src/binding/julia/version.cpp ) - # target_compile_features(openPMD_jl PUBLIC cxx_std_17) - # On macOS, not all C++17 features are enabled by `cxx_std_17`: - # Older platforms (<10.14) do not have `std::variant`. We thus - # select C++14 so that openPMD's header files enable respective - # work-arounds. - target_compile_features(openPMD_jl PUBLIC cxx_std_14) + target_compile_features(openPMD_jl PUBLIC cxx_std_17) + # # On macOS, not all C++17 features are enabled by `cxx_std_17`: + # # Older platforms (<10.14) do not have `std::variant`. We thus + # # select C++14 so that openPMD's header files enable respective + # # work-arounds. + # target_compile_features(openPMD_jl PUBLIC cxx_std_14) set_target_properties(openPMD_jl PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON From 48d6024eca467c53fac40d49c9239e2fc9eb1931 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 16:20:50 -0400 Subject: [PATCH 07/94] Disable std::variant on Apple with clang --- CMakeLists.txt | 5 ----- include/openPMD/auxiliary/VariantSrc.hpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae6e480788..cd5f527d72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,11 +628,6 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/version.cpp ) target_compile_features(openPMD_jl PUBLIC cxx_std_17) - # # On macOS, not all C++17 features are enabled by `cxx_std_17`: - # # Older platforms (<10.14) do not have `std::variant`. We thus - # # select C++14 so that openPMD's header files enable respective - # # work-arounds. - # target_compile_features(openPMD_jl PUBLIC cxx_std_14) set_target_properties(openPMD_jl PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON diff --git a/include/openPMD/auxiliary/VariantSrc.hpp b/include/openPMD/auxiliary/VariantSrc.hpp index b6e8de49b0..f162a2af08 100644 --- a/include/openPMD/auxiliary/VariantSrc.hpp +++ b/include/openPMD/auxiliary/VariantSrc.hpp @@ -20,7 +20,7 @@ */ #pragma once -#if __cplusplus >= 201703L +#if __cplusplus >= 201703L && !(defined __APPLE__ && defined __clang__) # include // IWYU pragma: export namespace variantSrc = std; #else From 28658451037b4ea1343269d021e7f551ebae5569 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 17:27:55 -0400 Subject: [PATCH 08/94] cmake: Only look for C++ MPI --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd5f527d72..756532caa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,14 +129,14 @@ option(openPMD_BUILD_EXAMPLES "Build the examples" ${BUILD_EXAMPLES}) # # external library: MPI (optional) if(openPMD_USE_MPI STREQUAL AUTO) - find_package(MPI) + find_package(MPI COMPONENTS CXX) if(MPI_FOUND) set(openPMD_HAVE_MPI TRUE) else() set(openPMD_HAVE_MPI FALSE) endif() elseif(openPMD_USE_MPI) - find_package(MPI REQUIRED) + find_package(MPI COMPONENTS CXX REQUIRED) set(openPMD_HAVE_MPI TRUE) else() set(openPMD_HAVE_MPI FALSE) From 9c81660c198b9e681b045e6d80d7fab49d046539 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Jun 2021 23:16:22 -0400 Subject: [PATCH 09/94] Install Julia bindings --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 756532caa2..428072d86a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -961,6 +961,10 @@ if(openPMD_INSTALL) endforeach() endif() + if(openPMD_HAVE_JlCxx) + list(APPEND openPMD_INSTALL_TARGET_NAMES openPMD_jl) + endif() + install(TARGETS ${openPMD_INSTALL_TARGET_NAMES} EXPORT openPMDTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} From d33895e81f414d541bd0e21ae116c53bc12e9a06 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 3 Jul 2021 19:57:36 -0400 Subject: [PATCH 10/94] Rename to WriteIterations::getindex --- src/binding/julia/WriteIterations.cpp | 2 +- src/binding/julia/defs.hpp | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp index 8961c8fbee..e91aeb3344 100644 --- a/src/binding/julia/WriteIterations.cpp +++ b/src/binding/julia/WriteIterations.cpp @@ -10,7 +10,7 @@ void define_julia_WriteIterations(jlcxx::Module &mod) { using mapped_type = typename iterations_t::mapped_type; auto type = mod.add_type("WriteIterations"); - type.method("get1!", + type.method("getindex1!", [](WriteIterations &w, const key_type &k) -> Iteration & { return w[k]; }); diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 6050295525..2cbe31bbf9 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -104,11 +104,12 @@ template std::shared_ptr capture_vector(std::vector vec) { } else { // Capture the vector T *dataptr = vec.data(); - std::shared_ptr ptr(dataptr, [vec = std::move(vec)](T *p) { - /* We moved the vector into the anonymous function, and thus it will be - * destructed when the anonymous function is destructed. There is no need - * to call a destructor manually. */ - }); + auto deleter = [vec = std::move(vec)](T *) { + // We moved the vector into the anonymous function, and thus it will be + // destructed when the anonymous function is destructed. There is no need + // to call a destructor manually. + }; + std::shared_ptr ptr(dataptr, std::move(deleter)); return ptr; } } @@ -163,12 +164,12 @@ void define_julia_Iteration(jlcxx::Module &mod); void define_julia_Mesh(jlcxx::Module &mod); void define_julia_MeshRecordComponent(jlcxx::Module &mod); void define_julia_RecordComponent(jlcxx::Module &mod); -void define_julia_RecordComponent_load_chunk(jlcxx::Module &mod, - jlcxx::TypeWrapper &type); -void define_julia_RecordComponent_make_constant(jlcxx::Module &mod, - jlcxx::TypeWrapper &type); -void define_julia_RecordComponent_store_chunk(jlcxx::Module &mod, - jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_load_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_make_constant( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_store_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); void define_julia_WriteIterations(jlcxx::Module &mod); From 492912dc1e096b0fee9cfb75eee251f883cee5a3 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 3 Jul 2021 21:43:42 -0400 Subject: [PATCH 11/94] Rename to MeshRecordComponent1 --- src/binding/julia/MeshRecordComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 7a80e48225..cfc44816c7 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -11,7 +11,7 @@ template <> struct SuperType { void define_julia_MeshRecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( - "MeshRecordComponent", jlcxx::julia_base_type()); + "MeshRecordComponent1", jlcxx::julia_base_type()); type.method("position1", &MeshRecordComponent::position); type.method("set_position1!", &MeshRecordComponent::setPosition); From 5ab016c1eefeac0a27c0229f61181cf4807f2d96 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 4 Jul 2021 19:13:52 -0400 Subject: [PATCH 12/94] Simplify function names --- src/binding/julia/Attributable.cpp | 2 +- src/binding/julia/Container.hpp | 6 +++--- src/binding/julia/MeshRecordComponent.cpp | 2 +- src/binding/julia/RecordComponent_store_chunk.cpp | 13 ++++++------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index ec5d398c71..958eb5174c 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -6,7 +6,7 @@ void define_julia_Attributable(jlcxx::Module &mod) { auto type = mod.add_type("Attributable"); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("set_attribute1_" NAME "!", &Attributable::setAttribute); + type.method("set_attribute1!", &Attributable::setAttribute); { FORALL_OPENPMD_TYPES } #undef USE_TYPE diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index f5af677dcc..f084b56db1 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -41,10 +41,10 @@ void define_julia_Container(jlcxx::Module &mod) { type.method("empty1", &ContainerT::empty); type.method("length1", &ContainerT::size); type.method("empty1!", &ContainerT::clear); + // type.method("getindex1", + // static_cast( + // &ContainerT::at)); type.method("getindex1", - static_cast( - &ContainerT::at)); - type.method("get1!", [](ContainerT &cont, const key_type &key) -> mapped_type & { return cont[key]; }); diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index cfc44816c7..36daa2f9bb 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -16,7 +16,7 @@ void define_julia_MeshRecordComponent(jlcxx::Module &mod) { type.method("position1", &MeshRecordComponent::position); type.method("set_position1!", &MeshRecordComponent::setPosition); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("make_constant1_" NAME, &MeshRecordComponent::makeConstant); + type.method("make_constant1", &MeshRecordComponent::makeConstant); { FORALL_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 99e654571a..b4b140b92e 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -5,16 +5,15 @@ void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk1_" NAME, \ - static_cast, \ - Offset, Extent)>( \ - &RecordComponent::storeChunk)); + type.method("store_chunk1", static_cast, Offset, Extent)>( \ + &RecordComponent::storeChunk)); { FORALL_OPENPMD_TYPES } #undef USE_TYPE #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ - std::vector data, \ - Offset offset, Extent extent) { \ + type.method("store_chunk_copy1", [](RecordComponent &comp, \ + std::vector data, Offset offset, \ + Extent extent) { \ std::shared_ptr ptr(capture_vector(std::move(data))); \ comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ }); From 34f11ab771b2aa989d93e9a69a25ab0499bd3f86 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 4 Jul 2021 20:07:56 -0400 Subject: [PATCH 13/94] Use separate function names for templates --- src/binding/julia/Attributable.cpp | 2 +- src/binding/julia/MeshRecordComponent.cpp | 2 +- src/binding/julia/RecordComponent_store_chunk.cpp | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 958eb5174c..ec5d398c71 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -6,7 +6,7 @@ void define_julia_Attributable(jlcxx::Module &mod) { auto type = mod.add_type("Attributable"); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("set_attribute1!", &Attributable::setAttribute); + type.method("set_attribute1_" NAME "!", &Attributable::setAttribute); { FORALL_OPENPMD_TYPES } #undef USE_TYPE diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 36daa2f9bb..cfc44816c7 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -16,7 +16,7 @@ void define_julia_MeshRecordComponent(jlcxx::Module &mod) { type.method("position1", &MeshRecordComponent::position); type.method("set_position1!", &MeshRecordComponent::setPosition); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("make_constant1", &MeshRecordComponent::makeConstant); + type.method("make_constant1_" NAME, &MeshRecordComponent::makeConstant); { FORALL_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index b4b140b92e..99e654571a 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -5,15 +5,16 @@ void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk1", static_cast, Offset, Extent)>( \ - &RecordComponent::storeChunk)); + type.method("store_chunk1_" NAME, \ + static_cast, \ + Offset, Extent)>( \ + &RecordComponent::storeChunk)); { FORALL_OPENPMD_TYPES } #undef USE_TYPE #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk_copy1", [](RecordComponent &comp, \ - std::vector data, Offset offset, \ - Extent extent) { \ + type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ + std::vector data, \ + Offset offset, Extent extent) { \ std::shared_ptr ptr(capture_vector(std::move(data))); \ comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ }); From d679474fd845dcd0ed27b2b0f156765ff0b183a5 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 11:35:57 -0400 Subject: [PATCH 14/94] New API for loadChunk --- CMakeLists.txt | 1 + src/binding/julia/ReadIterations.cpp | 15 +++++++++++++++ .../julia/RecordComponent_load_chunk.cpp | 18 ++++++++++++++++++ src/binding/julia/Series.cpp | 9 ++++++--- src/binding/julia/defs.hpp | 13 +++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/binding/julia/ReadIterations.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 428072d86a..68f61d2ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -617,6 +617,7 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/Iteration.cpp src/binding/julia/Mesh.cpp src/binding/julia/MeshRecordComponent.cpp + src/binding/julia/ReadIterations.cpp src/binding/julia/RecordComponent.cpp src/binding/julia/RecordComponent_load_chunk.cpp src/binding/julia/RecordComponent_make_constant.cpp diff --git a/src/binding/julia/ReadIterations.cpp b/src/binding/julia/ReadIterations.cpp new file mode 100644 index 0000000000..90f30cc44c --- /dev/null +++ b/src/binding/julia/ReadIterations.cpp @@ -0,0 +1,15 @@ +// ReadIterations + +#include "defs.hpp" + +#include + +void define_julia_ReadIterations(jlcxx::Module &mod) { + using iterations_t = Container; + using key_type = typename iterations_t::key_type; + using mapped_type = typename iterations_t::mapped_type; + + auto type = mod.add_type("ReadIterations"); + // TODO: SeriesIterator + // TODO: begin, end +} diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index 1f9c6c425c..a65d83f972 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -4,6 +4,15 @@ void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("load_chunk1_" NAME, [](RecordComponent &comp, \ + std::vector &buffer, \ + Offset offset, Extent extent) { \ + std::shared_ptr ptr(capture_vector_as_buffer(buffer)); \ + comp.loadChunk(std::move(ptr), std::move(offset), std::move(extent)); \ + }); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE #define USE_TYPE(NAME, ENUM, TYPE) \ type.method( \ "load_chunk1_" NAME, \ @@ -11,4 +20,13 @@ void define_julia_RecordComponent_load_chunk( &RecordComponent::loadChunk)); { FORALL_OPENPMD_TYPES } #undef USE_TYPE +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("copy_chunk1_" NAME, \ + [](const std::shared_ptr &ptr, std::vector &data) { \ + const TYPE *dataptr = ptr.get(); \ + std::size_t datasize = data.size(); \ + std::copy(dataptr, dataptr + datasize, data.begin()); \ + }); + { FORALL_OPENPMD_TYPES } +#undef USE_TYPE } diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 57a803c980..848d328d2a 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -70,9 +70,12 @@ void define_julia_Series(jlcxx::Module &mod) { type.constructor(); type.constructor(); - type.method("isvalid1", [](const Series &s) { return bool(s); }); - // TODO: iterations - // TODO: readIterations + type.method("isvalid1", [](const Series &series) { return bool(series); }); + type.method("iterations", + [](Series &series) -> Container & { + return series.iterations; + }); + type.method("read_iterations", &Series::readIterations); type.method("write_iterations", &Series::writeIterations); } } diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 2cbe31bbf9..18eff460e6 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -94,6 +94,18 @@ std::vector> map_to_vector_tuple(const std::map &m) { return vp; } +template +std::shared_ptr capture_vector_as_buffer(std::vector &vec) { + if constexpr (std::is_same_v) { + // We cannot handle std::vector because it is special + std::abort(); + } else { + auto deleter = [](T *) { /* do not delete anything */ }; + std::shared_ptr ptr(vec.data(), std::move(deleter)); + return ptr; + } +} + template std::shared_ptr capture_vector(std::vector vec) { if constexpr (std::is_same_v) { // Copy the vector, because std::vector is special @@ -172,6 +184,7 @@ void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); +void define_julia_ReadIterations(jlcxx::Module &mod); void define_julia_WriteIterations(jlcxx::Module &mod); void define_julia_version(jlcxx::Module &mod); From 828222b61f4b37b823252b569ea67798d808b1ae Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 12:49:07 -0400 Subject: [PATCH 15/94] Split files to reduce build time --- CMakeLists.txt | 3 ++ .../julia/RecordComponent_copy_chunk.cpp | 16 ++++++++++ .../julia/RecordComponent_load_chunk.cpp | 20 +------------ .../RecordComponent_load_chunk_buffer.cpp | 16 ++++++++++ .../julia/RecordComponent_make_constant.cpp | 2 +- .../julia/RecordComponent_store_chunk.cpp | 11 +------ .../RecordComponent_store_chunk_copy.cpp | 16 ++++++++++ src/binding/julia/defs.hpp | 29 +++++++++++++++++++ 8 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 src/binding/julia/RecordComponent_copy_chunk.cpp create mode 100644 src/binding/julia/RecordComponent_load_chunk_buffer.cpp create mode 100644 src/binding/julia/RecordComponent_store_chunk_copy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 68f61d2ed4..19e739e7e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -619,9 +619,12 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/MeshRecordComponent.cpp src/binding/julia/ReadIterations.cpp src/binding/julia/RecordComponent.cpp + src/binding/julia/RecordComponent_copy_chunk.cpp src/binding/julia/RecordComponent_load_chunk.cpp + src/binding/julia/RecordComponent_load_chunk_buffer.cpp src/binding/julia/RecordComponent_make_constant.cpp src/binding/julia/RecordComponent_store_chunk.cpp + src/binding/julia/RecordComponent_store_chunk_copy.cpp src/binding/julia/Series.cpp src/binding/julia/UnitDimension.cpp src/binding/julia/WriteIterations.cpp diff --git a/src/binding/julia/RecordComponent_copy_chunk.cpp b/src/binding/julia/RecordComponent_copy_chunk.cpp new file mode 100644 index 0000000000..54d81d5615 --- /dev/null +++ b/src/binding/julia/RecordComponent_copy_chunk.cpp @@ -0,0 +1,16 @@ +// RecordComponent_copy_chunk + +#include "defs.hpp" + +void define_julia_RecordComponent_copy_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("copy_chunk1_" NAME, \ + [](const std::shared_ptr &ptr, std::vector &data) { \ + const TYPE *dataptr = ptr.get(); \ + std::size_t datasize = data.size(); \ + std::copy(dataptr, dataptr + datasize, data.begin()); \ + }); + { FORALL_SCALAR_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index a65d83f972..cae9b0ae49 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -4,29 +4,11 @@ void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("load_chunk1_" NAME, [](RecordComponent &comp, \ - std::vector &buffer, \ - Offset offset, Extent extent) { \ - std::shared_ptr ptr(capture_vector_as_buffer(buffer)); \ - comp.loadChunk(std::move(ptr), std::move(offset), std::move(extent)); \ - }); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE #define USE_TYPE(NAME, ENUM, TYPE) \ type.method( \ "load_chunk1_" NAME, \ static_cast (RecordComponent::*)(Offset, Extent)>( \ &RecordComponent::loadChunk)); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("copy_chunk1_" NAME, \ - [](const std::shared_ptr &ptr, std::vector &data) { \ - const TYPE *dataptr = ptr.get(); \ - std::size_t datasize = data.size(); \ - std::copy(dataptr, dataptr + datasize, data.begin()); \ - }); - { FORALL_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_load_chunk_buffer.cpp b/src/binding/julia/RecordComponent_load_chunk_buffer.cpp new file mode 100644 index 0000000000..ba6d0e7bde --- /dev/null +++ b/src/binding/julia/RecordComponent_load_chunk_buffer.cpp @@ -0,0 +1,16 @@ +// RecordComponent_load_chunk_buffer + +#include "defs.hpp" + +void define_julia_RecordComponent_load_chunk_buffer( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("load_chunk1_" NAME, [](RecordComponent &comp, \ + std::vector &buffer, \ + Offset offset, Extent extent) { \ + std::shared_ptr ptr(capture_vector_as_buffer(buffer)); \ + comp.loadChunk(std::move(ptr), std::move(offset), std::move(extent)); \ + }); + { FORALL_SCALAR_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 1a5db48d4c..94ba4155fd 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -6,6 +6,6 @@ void define_julia_RecordComponent_make_constant( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("make_constant1_" NAME, &RecordComponent::makeConstant); - { FORALL_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 99e654571a..13102dbb63 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -9,15 +9,6 @@ void define_julia_RecordComponent_store_chunk( static_cast, \ Offset, Extent)>( \ &RecordComponent::storeChunk)); - { FORALL_OPENPMD_TYPES } -#undef USE_TYPE -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ - std::vector data, \ - Offset offset, Extent extent) { \ - std::shared_ptr ptr(capture_vector(std::move(data))); \ - comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ - }); - { FORALL_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk_copy.cpp b/src/binding/julia/RecordComponent_store_chunk_copy.cpp new file mode 100644 index 0000000000..3a2fd22f18 --- /dev/null +++ b/src/binding/julia/RecordComponent_store_chunk_copy.cpp @@ -0,0 +1,16 @@ +// RecordComponent_store_chunk_copy + +#include "defs.hpp" + +void define_julia_RecordComponent_store_chunk_copy( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ + std::vector data, \ + Offset offset, Extent extent) { \ + std::shared_ptr ptr(capture_vector(std::move(data))); \ + comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ + }); + { FORALL_SCALAR_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 18eff460e6..2dca5d14de 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -31,6 +31,7 @@ template using array7 = std::array; // #undef USE_TYPE // // We disable `long double` since Julia does not support this type +// We disable `long double` since Julia does not support this type #define FORALL_OPENPMD_TYPES \ USE_TYPE("CHAR", Datatype::CHAR, char) \ USE_TYPE("UCHAR", Datatype::UCHAR, unsigned char) \ @@ -75,6 +76,28 @@ template using array7 = std::array; USE_TYPE("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ USE_TYPE("BOOL", Datatype::BOOL, bool) +#define FORALL_SCALAR_OPENPMD_TYPES \ + USE_TYPE("CHAR", Datatype::CHAR, char) \ + USE_TYPE("UCHAR", Datatype::UCHAR, unsigned char) \ + USE_TYPE("SHORT", Datatype::SHORT, short) \ + USE_TYPE("INT", Datatype::INT, int) \ + USE_TYPE("LONG", Datatype::LONG, long) \ + USE_TYPE("LONGLONG", Datatype::LONGLONG, long long) \ + USE_TYPE("USHORT", Datatype::USHORT, unsigned short) \ + USE_TYPE("UINT", Datatype::UINT, unsigned int) \ + USE_TYPE("ULONG", Datatype::ULONG, unsigned long) \ + USE_TYPE("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ + USE_TYPE("FLOAT", Datatype::FLOAT, float) \ + USE_TYPE("DOUBLE", Datatype::DOUBLE, double) \ + /* USE_TYPE("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ + USE_TYPE("CFLOAT", Datatype::CFLOAT, std::complex) \ + USE_TYPE("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* USE_TYPE("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ + USE_TYPE("STRING", Datatype::STRING, std::string) \ + USE_TYPE("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + USE_TYPE("BOOL", Datatype::BOOL, bool) + namespace { template std::vector> map_to_vector_pair(const std::map &m) { @@ -176,12 +199,18 @@ void define_julia_Iteration(jlcxx::Module &mod); void define_julia_Mesh(jlcxx::Module &mod); void define_julia_MeshRecordComponent(jlcxx::Module &mod); void define_julia_RecordComponent(jlcxx::Module &mod); +void define_julia_RecordComponent_copy_chunk( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_load_chunk_buffer( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_make_constant( jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_store_chunk_copy( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); void define_julia_ReadIterations(jlcxx::Module &mod); From bc3d5f92b0f176a789bed39c173357332d29e7ba Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 14:34:06 -0400 Subject: [PATCH 16/94] Disable ReadIterations --- src/binding/julia/ReadIterations.cpp | 6 +----- src/binding/julia/Series.cpp | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/binding/julia/ReadIterations.cpp b/src/binding/julia/ReadIterations.cpp index 90f30cc44c..2b99e4fe5f 100644 --- a/src/binding/julia/ReadIterations.cpp +++ b/src/binding/julia/ReadIterations.cpp @@ -5,11 +5,7 @@ #include void define_julia_ReadIterations(jlcxx::Module &mod) { - using iterations_t = Container; - using key_type = typename iterations_t::key_type; - using mapped_type = typename iterations_t::mapped_type; - - auto type = mod.add_type("ReadIterations"); + // TODO auto type = mod.add_type("ReadIterations"); // TODO: SeriesIterator // TODO: begin, end } diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 848d328d2a..ae67c934d6 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -75,7 +75,7 @@ void define_julia_Series(jlcxx::Module &mod) { [](Series &series) -> Container & { return series.iterations; }); - type.method("read_iterations", &Series::readIterations); + //TODO type.method("read_iterations", &Series::readIterations); type.method("write_iterations", &Series::writeIterations); } } From 2492182a0f1ed0b3d68cf799c1890a249b788700 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 15:00:59 -0400 Subject: [PATCH 17/94] Define chunk function wrappers --- src/binding/julia/RecordComponent.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index 4553b4476f..2ddd12f1ea 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -38,7 +38,10 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { static_cast( &RecordComponent::makeEmpty)); type.method("empty1", &RecordComponent::empty); + define_julia_RecordComponent_copy_chunk(mod, type); define_julia_RecordComponent_load_chunk(mod, type); + define_julia_RecordComponent_load_chunk_buffer(mod, type); define_julia_RecordComponent_store_chunk(mod, type); + define_julia_RecordComponent_store_chunk_copy(mod, type); type.method("SCALAR1", []() { return RecordComponent::SCALAR; }); } From 8d444e807310fa739ca026793b378d272c21527a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 17:21:25 -0400 Subject: [PATCH 18/94] Add functions to create shared_ptrs --- CMakeLists.txt | 2 ++ src/binding/julia/RecordComponent.cpp | 1 + src/binding/julia/RecordComponent_load_chunk.cpp | 8 ++++---- .../julia/RecordComponent_load_chunk_alloc.cpp | 14 ++++++++++++++ src/binding/julia/defs.hpp | 8 ++++++++ src/binding/julia/openPMD.cpp | 2 ++ src/binding/julia/shared_ptr.cpp | 11 +++++++++++ 7 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/binding/julia/RecordComponent_load_chunk_alloc.cpp create mode 100644 src/binding/julia/shared_ptr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cc114a686..aad3194c26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -639,6 +639,7 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/RecordComponent.cpp src/binding/julia/RecordComponent_copy_chunk.cpp src/binding/julia/RecordComponent_load_chunk.cpp + src/binding/julia/RecordComponent_load_chunk_alloc.cpp src/binding/julia/RecordComponent_load_chunk_buffer.cpp src/binding/julia/RecordComponent_make_constant.cpp src/binding/julia/RecordComponent_store_chunk.cpp @@ -647,6 +648,7 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/UnitDimension.cpp src/binding/julia/WriteIterations.cpp src/binding/julia/openPMD.cpp + src/binding/julia/shared_ptr.cpp src/binding/julia/version.cpp ) target_compile_features(openPMD_jl PUBLIC cxx_std_17) diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index 2ddd12f1ea..3597dfb147 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -40,6 +40,7 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { type.method("empty1", &RecordComponent::empty); define_julia_RecordComponent_copy_chunk(mod, type); define_julia_RecordComponent_load_chunk(mod, type); + define_julia_RecordComponent_load_chunk_alloc(mod, type); define_julia_RecordComponent_load_chunk_buffer(mod, type); define_julia_RecordComponent_store_chunk(mod, type); define_julia_RecordComponent_store_chunk_copy(mod, type); diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index cae9b0ae49..473e5ae349 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -5,10 +5,10 @@ void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "load_chunk1_" NAME, \ - static_cast (RecordComponent::*)(Offset, Extent)>( \ - &RecordComponent::loadChunk)); + type.method("load_chunk1_" NAME, \ + static_cast, \ + Offset, Extent)>( \ + &RecordComponent::loadChunk)); { FORALL_SCALAR_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_load_chunk_alloc.cpp b/src/binding/julia/RecordComponent_load_chunk_alloc.cpp new file mode 100644 index 0000000000..8a5d178bb9 --- /dev/null +++ b/src/binding/julia/RecordComponent_load_chunk_alloc.cpp @@ -0,0 +1,14 @@ +// RecordComponent_load_chunk_alloc + +#include "defs.hpp" + +void define_julia_RecordComponent_load_chunk_alloc( + jlcxx::Module &mod, jlcxx::TypeWrapper &type) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + type.method( \ + "load_chunk_alloc1_" NAME, \ + static_cast (RecordComponent::*)(Offset, Extent)>( \ + &RecordComponent::loadChunk)); + { FORALL_SCALAR_OPENPMD_TYPES } +#undef USE_TYPE +} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 2dca5d14de..2f3c368494 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -117,6 +117,11 @@ std::vector> map_to_vector_tuple(const std::map &m) { return vp; } +template std::shared_ptr create_aliasing_shared_ptr(T *ptr) { + auto null_deleter = [](T *) {}; + return std::shared_ptr(ptr, null_deleter); +} + template std::shared_ptr capture_vector_as_buffer(std::vector &vec) { if constexpr (std::is_same_v) { @@ -203,6 +208,8 @@ void define_julia_RecordComponent_copy_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); +void define_julia_RecordComponent_load_chunk_alloc( + jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_load_chunk_buffer( jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_make_constant( @@ -215,6 +222,7 @@ void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); void define_julia_ReadIterations(jlcxx::Module &mod); void define_julia_WriteIterations(jlcxx::Module &mod); +void define_julia_shared_ptr(jlcxx::Module &mod); void define_julia_version(jlcxx::Module &mod); #endif // #ifndef DEFS_HPP diff --git a/src/binding/julia/openPMD.cpp b/src/binding/julia/openPMD.cpp index 4cbd208553..91fc3096ef 100644 --- a/src/binding/julia/openPMD.cpp +++ b/src/binding/julia/openPMD.cpp @@ -10,6 +10,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module &mod) { add_array_type(mod, "array_double_7"); add_pair_type(mod, "pair_string_bool"); + define_julia_shared_ptr(mod); + // The order of these calls matters. Julia types need to be defined before // they are used. diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp new file mode 100644 index 0000000000..5ab9607fa3 --- /dev/null +++ b/src/binding/julia/shared_ptr.cpp @@ -0,0 +1,11 @@ +// shared_ptr + +#include "defs.hpp" + +void define_julia_shared_ptr(jlcxx::Module &mod) { +#define USE_TYPE(NAME, ENUM, TYPE) \ + mod.method("create_aliasing_shared_ptr_" NAME, \ + &create_aliasing_shared_ptr); + { FORALL_SCALAR_OPENPMD_TYPES } +#undef USE_TYPE +} From 29cd7ffdd6257e81add7d98c20e0f5ad6c01bcae Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 19:19:33 -0400 Subject: [PATCH 19/94] Use `cxx_` prefix instead of `1` suffix --- src/binding/julia/Access.cpp | 6 +- src/binding/julia/Attributable.cpp | 22 +++---- src/binding/julia/Attribute.cpp | 6 +- src/binding/julia/BaseRecordComponent.cpp | 6 +- src/binding/julia/Container.hpp | 24 ++++---- src/binding/julia/Dataset.cpp | 12 ++-- src/binding/julia/Datatype.cpp | 24 ++++---- src/binding/julia/Format.cpp | 14 ++--- src/binding/julia/Iteration.cpp | 24 ++++---- src/binding/julia/Mesh.cpp | 14 ++--- src/binding/julia/MeshRecordComponent.cpp | 9 +-- src/binding/julia/RecordComponent.cpp | 18 +++--- src/binding/julia/Series.cpp | 71 ++++++++++++----------- src/binding/julia/UnitDimension.cpp | 14 ++--- src/binding/julia/version.cpp | 2 +- 15 files changed, 134 insertions(+), 132 deletions(-) diff --git a/src/binding/julia/Access.cpp b/src/binding/julia/Access.cpp index 2940c99001..efd12c183b 100644 --- a/src/binding/julia/Access.cpp +++ b/src/binding/julia/Access.cpp @@ -6,7 +6,7 @@ void define_julia_Access(jlcxx::Module &mod) { mod.add_bits("Access", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("READ_ONLY", Access::READ_ONLY); - mod.set_const("READ_WRITE", Access::READ_WRITE); - mod.set_const("CREATE", Access::CREATE); + mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY); + mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE); + mod.set_const("ACCESS_CREATE", Access::CREATE); } diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index ec5d398c71..97c81c7e01 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -3,20 +3,20 @@ #include "defs.hpp" void define_julia_Attributable(jlcxx::Module &mod) { - auto type = mod.add_type("Attributable"); + auto type = mod.add_type("CXX_Attributable"); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("set_attribute1_" NAME "!", &Attributable::setAttribute); + type.method("cxx_set_attribute_" NAME "!", &Attributable::setAttribute); { FORALL_OPENPMD_TYPES } #undef USE_TYPE - type.method("get_attribute1", &Attributable::getAttribute); - type.method("delete_attribute!", &Attributable::deleteAttribute); - type.method("attributes", &Attributable::attributes); - type.method("num_attributes1", &Attributable::numAttributes); - type.method("contains_attribute", &Attributable::containsAttribute); - type.method("comment", &Attributable::comment); - type.method("set_comment!", &Attributable::setComment); - type.method("series_flush", static_cast( - &Attributable::seriesFlush)); + type.method("cxx_get_attribute", &Attributable::getAttribute); + type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); + type.method("cxx_attributes", &Attributable::attributes); + type.method("cxx_num_attributes", &Attributable::numAttributes); + type.method("cxx_contains_attribute", &Attributable::containsAttribute); + type.method("cxx_comment", &Attributable::comment); + type.method("cxx_set_comment!", &Attributable::setComment); + type.method("cxx_series_flush", static_cast( + &Attributable::seriesFlush)); } diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index b9f0e82e94..13be0c9b4a 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -3,12 +3,12 @@ #include "defs.hpp" void define_julia_Attribute(jlcxx::Module &mod) { - auto type = mod.add_type("Attribute"); + auto type = mod.add_type("CXX_Attribute"); - type.method("dtype1", [](const Attribute &attr) { return attr.dtype; }); + type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("get1_" NAME, &Attribute::get); + type.method("cxx_get_" NAME, &Attribute::get); { FORALL_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index ade27dbc8c..6a1a802c01 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -12,11 +12,11 @@ template <> struct SuperType { void define_julia_BaseRecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( - "BaseRecordComponent", jlcxx::julia_base_type()); + "CXX_BaseRecordComponent", jlcxx::julia_base_type()); type.method("unit_SI", &BaseRecordComponent::unitSI); - type.method("reset_datatype1!", &BaseRecordComponent::resetDatatype); - type.method("get_datatype1", &BaseRecordComponent::getDatatype); + type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); + type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); type.method("is_constant", &BaseRecordComponent::constant); // TODO: availableChunks } diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index f084b56db1..8403b0b55f 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -38,39 +38,39 @@ void define_julia_Container(jlcxx::Module &mod) { type.template constructor(); - type.method("empty1", &ContainerT::empty); - type.method("length1", &ContainerT::size); - type.method("empty1!", &ContainerT::clear); - // type.method("getindex1", + type.method("cxx_empty", &ContainerT::empty); + type.method("cxx_length", &ContainerT::size); + type.method("cxx_empty!", &ContainerT::clear); + // type.method("cxx_getindex", // static_cast( // &ContainerT::at)); - type.method("getindex1", + type.method("cxx_getindex", [](ContainerT &cont, const key_type &key) -> mapped_type & { return cont[key]; }); - type.method("setindex1!", + type.method("cxx_setindex!", [](ContainerT &cont, const mapped_type &value, const key_type &key) { return cont[key] = value; }); - type.method("count1", &ContainerT::count); - type.method("contains1", &ContainerT::contains); - type.method("delete1!", + type.method("cxx_count", &ContainerT::count); + type.method("cxx_contains", &ContainerT::contains); + type.method("cxx_delete!", static_cast( &ContainerT::erase)); - type.method("keys1", [](const ContainerT &cont) { + type.method("cxx_keys", [](const ContainerT &cont) { std::vector res; res.reserve(cont.size()); for (auto iter = cont.begin(); iter != cont.end(); ++iter) res.push_back(iter->first); return res; }); - // type.method("values1", [](const ContainerT &cont) { + // type.method("cxx_values", [](const ContainerT &cont) { // std::vector res; // res.reserve(cont.size()); // for (auto iter = cont.begin(); iter != cont.end(); ++iter) // res.push_back(&iter->second); // return res; // }); - // type.method("collect1", [](const ContainerT &cont) { + // type.method("cxx_collect", [](const ContainerT &cont) { // std::vector> res; // res.reserve(cont.size()); // for (auto iter = cont.begin(); iter != cont.end(); ++iter) diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index 75bd8bf3f6..f4c968ab19 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -9,14 +9,14 @@ void define_julia_Dataset(jlcxx::Module &mod) { type.constructor(); type.constructor(); - type.method("extend1!", &Dataset::extend); - type.method("set_chunk_size1!", &Dataset::setChunkSize); + type.method("cxx_extend!", &Dataset::extend); + type.method("cxx_set_chunk_size!", &Dataset::setChunkSize); type.method("set_compression!", &Dataset::setCompression); type.method("set_custom_transform!", &Dataset::setCustomTransform); - type.method("extent1", [](const Dataset &d) { return d.extent; }); - type.method("dtype1", [](const Dataset &d) { return d.dtype; }); - type.method("rank1", [](const Dataset &d) { return d.rank; }); - type.method("chunk_size1", [](const Dataset &d) { return d.chunkSize; }); + type.method("cxx_extent", [](const Dataset &d) { return d.extent; }); + type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; }); + type.method("cxx_rank", [](const Dataset &d) { return d.rank; }); + type.method("cxx_chunk_size", [](const Dataset &d) { return d.chunkSize; }); type.method("compression", [](const Dataset &d) { return d.compression; }); type.method("transform", [](const Dataset &d) { return d.transform; }); type.method("options", [](const Dataset &d) { return d.options; }); diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 8f46f80c2c..a9cc4a1a05 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -14,22 +14,22 @@ void define_julia_Datatype(jlcxx::Module &mod) { mod.set_const("openPMD_datatypes", openPMD_Datatypes); // mod.method("determine_datatype", determineDatatype); - mod.method("to_bytes1", toBytes); - mod.method("to_bits1", toBits); - mod.method("is_vector1", isVector); - mod.method("is_floating_point1", (bool (*)(Datatype))isFloatingPoint); - mod.method("is_complex_floating_point1", + mod.method("cxx_to_bytes", toBytes); + mod.method("cxx_to_bits", toBits); + mod.method("cxx_is_vector", isVector); + mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint); + mod.method("cxx_is_complex_floating_point", static_cast(isComplexFloatingPoint)); - mod.method("is_integer1", (std::tuple(*)(Datatype))isInteger); + mod.method("cxx_is_integer", (std::tuple(*)(Datatype))isInteger); // isSameFloatingPoint // isSameComplexFloatingPoint // isSameInteger - mod.method("is_same1", isSame); - mod.method("basic_datatype1", basicDatatype); - mod.method("to_vector_type1", toVectorType); - mod.method("datatype_to_string1", datatypeToString); - mod.method("string_to_datatype1", stringToDatatype); - mod.method("warn_wrong_datatype1", warnWrongDtype); + mod.method("cxx_is_same", isSame); + mod.method("cxx_basic_datatype", basicDatatype); + mod.method("cxx_to_vector_type", toVectorType); + mod.method("cxx_datatype_to_string", datatypeToString); + mod.method("cxx_string_to_datatype", stringToDatatype); + mod.method("cxx_warn_wrong_datatype", warnWrongDtype); // mod.method("==", operator==); // mod.method("!=", operator!=); } diff --git a/src/binding/julia/Format.cpp b/src/binding/julia/Format.cpp index dec3d96eec..5c974e5683 100644 --- a/src/binding/julia/Format.cpp +++ b/src/binding/julia/Format.cpp @@ -6,13 +6,13 @@ void define_julia_Format(jlcxx::Module &mod) { mod.add_bits("Format", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("HDF5", Format::HDF5); - mod.set_const("ADIOS1", Format::ADIOS1); - mod.set_const("ADIOS2", Format::ADIOS2); - mod.set_const("ADIOS2_SST", Format::ADIOS2_SST); - mod.set_const("ADIOS2_SSC", Format::ADIOS2_SSC); - mod.set_const("JSON", Format::JSON); - mod.set_const("DUMMY", Format::DUMMY); + mod.set_const("FORMAT_HDF5", Format::HDF5); + mod.set_const("FORMAT_ADIOS1", Format::ADIOS1); + mod.set_const("FORMAT_ADIOS2", Format::ADIOS2); + mod.set_const("FORMAT_ADIOS2_SST", Format::ADIOS2_SST); + mod.set_const("FORMAT_ADIOS2_SSC", Format::ADIOS2_SSC); + mod.set_const("FORMAT_JSON", Format::JSON); + mod.set_const("FORMAT_DUMMY", Format::DUMMY); mod.method("determine_format", determineFormat); mod.method("suffix", suffix); } diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index 6ff8c1de3f..1dae10240a 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -10,21 +10,21 @@ template <> struct SuperType { typedef Attributable type; }; } // namespace jlcxx void define_julia_Iteration(jlcxx::Module &mod) { - auto type = mod.add_type("Iteration", + auto type = mod.add_type("CXX_Iteration", jlcxx::julia_base_type()); - type.method("time1", &Iteration::time); - type.method("set_time!", &Iteration::setTime); - type.method("dt", &Iteration::dt); - type.method("set_dt!", &Iteration::setDt); - type.method("time_unit_SI", &Iteration::timeUnitSI); - type.method("set_time_unit_SI!", &Iteration::setTimeUnitSI); - type.method("close1", + type.method("cxx_time", &Iteration::time); + type.method("cxx_set_time!", &Iteration::setTime); + type.method("cxx_dt", &Iteration::dt); + type.method("cxx_set_dt!", &Iteration::setDt); + type.method("cxx_time_unit_SI", &Iteration::timeUnitSI); + type.method("cxx_set_time_unit_SI!", &Iteration::setTimeUnitSI); + type.method("cxx_close", static_cast(&Iteration::close)); - type.method("open", &Iteration::open); - type.method("closed", &Iteration::closed); - type.method("closed_by_writer", &Iteration::closedByWriter); - type.method("meshes", + type.method("cxx_open", &Iteration::open); + type.method("cxx_closed", &Iteration::closed); + type.method("cxx_closed_by_writer", &Iteration::closedByWriter); + type.method("cxx_meshes", [](Iteration &iter) -> Container & { return iter.meshes; }); // TODO: particles } diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 7a562cf602..74c86b0a99 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -15,18 +15,18 @@ void define_julia_Mesh(jlcxx::Module &mod) { mod.add_bits("Geometry", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("cartesian", Mesh::Geometry::cartesian); - mod.set_const("theta_mode", Mesh::Geometry::thetaMode); - mod.set_const("cylindrical", Mesh::Geometry::cylindrical); - mod.set_const("spherical", Mesh::Geometry::spherical); - mod.set_const("other", Mesh::Geometry::other); + mod.set_const("GEOMETRY_cartesian", Mesh::Geometry::cartesian); + mod.set_const("GEOMETRY_theta_mode", Mesh::Geometry::thetaMode); + mod.set_const("GEOMETRY_cylindrical", Mesh::Geometry::cylindrical); + mod.set_const("GEOMETRY_spherical", Mesh::Geometry::spherical); + mod.set_const("GEOMETRY_other", Mesh::Geometry::other); // Mesh::DataOrder mod.add_bits("DataOrder", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("C", Mesh::DataOrder::C); - mod.set_const("F", Mesh::DataOrder::F); + mod.set_const("DATAORDER_C", Mesh::DataOrder::C); + mod.set_const("DATAORDER_F", Mesh::DataOrder::F); // Mesh auto type = mod.add_type( diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index cfc44816c7..43c05a0e70 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -11,12 +11,13 @@ template <> struct SuperType { void define_julia_MeshRecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( - "MeshRecordComponent1", jlcxx::julia_base_type()); + "CXX_MeshRecordComponent", jlcxx::julia_base_type()); - type.method("position1", &MeshRecordComponent::position); - type.method("set_position1!", &MeshRecordComponent::setPosition); + type.method("cxx_position", &MeshRecordComponent::position); + type.method("cxx_set_position!", &MeshRecordComponent::setPosition); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("make_constant1_" NAME, &MeshRecordComponent::makeConstant); + type.method("cxx_make_constant_" NAME, \ + &MeshRecordComponent::makeConstant); { FORALL_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index 3597dfb147..7e5215e830 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -21,28 +21,28 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("USER", RecordComponent::Allocation::USER); - mod.set_const("API", RecordComponent::Allocation::API); - mod.set_const("AUTO", RecordComponent::Allocation::AUTO); + mod.set_const("ALLOCATION_USER", RecordComponent::Allocation::USER); + mod.set_const("ALLOCATION_API", RecordComponent::Allocation::API); + mod.set_const("ALLOCATION_AUTO", RecordComponent::Allocation::AUTO); auto type = mod.add_type( - "RecordComponent", jlcxx::julia_base_type()); + "CXX_RecordComponent", jlcxx::julia_base_type()); type.method("set_unit_SI!", &RecordComponent::setUnitSI); type.method("reset_dataset!", &RecordComponent::resetDataset); - type.method("get_dimensionality1", &RecordComponent::getDimensionality); - type.method("get_extent1", &RecordComponent::getExtent); + type.method("cxx_get_dimensionality", &RecordComponent::getDimensionality); + type.method("cxx_get_extent", &RecordComponent::getExtent); define_julia_RecordComponent_make_constant(mod, type); type.method( - "make_empty1", + "cxx_make_empty", static_cast( &RecordComponent::makeEmpty)); - type.method("empty1", &RecordComponent::empty); + type.method("cxx_isempty", &RecordComponent::empty); define_julia_RecordComponent_copy_chunk(mod, type); define_julia_RecordComponent_load_chunk(mod, type); define_julia_RecordComponent_load_chunk_alloc(mod, type); define_julia_RecordComponent_load_chunk_buffer(mod, type); define_julia_RecordComponent_store_chunk(mod, type); define_julia_RecordComponent_store_chunk_copy(mod, type); - type.method("SCALAR1", []() { return RecordComponent::SCALAR; }); + type.method("cxx_SCALAR", []() { return RecordComponent::SCALAR; }); } diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index ae67c934d6..95b8939298 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -13,53 +13,53 @@ void define_julia_Series(jlcxx::Module &mod) { // SeriesImpl { auto type = mod.add_type( - "SeriesImpl", jlcxx::julia_base_type()); + "CXX_SeriesImpl", jlcxx::julia_base_type()); - type.method("openPMD_version", &SeriesImpl::openPMD); - type.method("set_openPMD_version!", &SeriesImpl::setOpenPMD); - type.method("openPMD_extension", &SeriesImpl::openPMDextension); - type.method("set_openPMD_extension!", &SeriesImpl::setOpenPMDextension); - type.method("base_path", &SeriesImpl::basePath); - type.method("set_base_path!", &SeriesImpl::setBasePath); - type.method("meshes_path", &SeriesImpl::meshesPath); - type.method("set_meshes_path!", &SeriesImpl::setMeshesPath); - type.method("particles_path", &SeriesImpl::particlesPath); - type.method("set_particles_path!", &SeriesImpl::setParticlesPath); - type.method("author", &SeriesImpl::author); - type.method("set_author!", &SeriesImpl::setAuthor); - type.method("software", &SeriesImpl::software); - type.method("set_software!", + type.method("cxx_openPMD_version", &SeriesImpl::openPMD); + type.method("cxx_set_openPMD_version!", &SeriesImpl::setOpenPMD); + type.method("cxx_openPMD_extension", &SeriesImpl::openPMDextension); + type.method("cxx_set_openPMD_extension!", &SeriesImpl::setOpenPMDextension); + type.method("cxx_base_path", &SeriesImpl::basePath); + type.method("cxx_set_base_path!", &SeriesImpl::setBasePath); + type.method("cxx_meshes_path", &SeriesImpl::meshesPath); + type.method("cxx_set_meshes_path!", &SeriesImpl::setMeshesPath); + type.method("cxx_particles_path", &SeriesImpl::particlesPath); + type.method("cxx_set_particles_path!", &SeriesImpl::setParticlesPath); + type.method("cxx_author", &SeriesImpl::author); + type.method("cxx_set_author!", &SeriesImpl::setAuthor); + type.method("cxx_software", &SeriesImpl::software); + type.method("cxx_set_software!", static_cast( &SeriesImpl::setSoftware)); - type.method("set_software!", + type.method("cxx_set_software!", (SeriesImpl & (SeriesImpl::*)(std::string const &))( &SeriesImpl::setSoftware)); - type.method("software_version", &SeriesImpl::softwareVersion); + type.method("cxx_software_version", &SeriesImpl::softwareVersion); // type.method("set_software_version!", &SeriesImpl::setSoftwareVersion); - type.method("date", &SeriesImpl::date); - type.method("set_date!", &SeriesImpl::setDate); - type.method("software_dependencies", &SeriesImpl::softwareDependencies); - type.method("set_software_dependencies!", + type.method("cxx_date", &SeriesImpl::date); + type.method("cxx_set_date!", &SeriesImpl::setDate); + type.method("cxx_software_dependencies", &SeriesImpl::softwareDependencies); + type.method("cxx_set_software_dependencies!", &SeriesImpl::setSoftwareDependencies); - type.method("machine", &SeriesImpl::machine); - type.method("set_machine!", &SeriesImpl::setMachine); + type.method("cxx_machine", &SeriesImpl::machine); + type.method("cxx_set_machine!", &SeriesImpl::setMachine); // TODO: type.method("iteration_encoding", &SeriesImpl::iterationEncoding); // TODO: type.method("set_iteration_encoding!", // &SeriesImpl::setIterationEncoding); - type.method("iteration_format", &SeriesImpl::iterationFormat); - type.method("set_iteration_format!", &SeriesImpl::setIterationFormat); - type.method("name", &SeriesImpl::name); - type.method("set_name!", &SeriesImpl::setName); - type.method("backend", &SeriesImpl::backend); - type.method("flush1", &SeriesImpl::flush); + type.method("cxx_iteration_format", &SeriesImpl::iterationFormat); + type.method("cxx_set_iteration_format!", &SeriesImpl::setIterationFormat); + type.method("cxx_name", &SeriesImpl::name); + type.method("cxx_set_name!", &SeriesImpl::setName); + type.method("cxx_backend", &SeriesImpl::backend); + type.method("cxx_flush", &SeriesImpl::flush); } // Series { - auto type = - mod.add_type("Series", jlcxx::julia_base_type()); + auto type = mod.add_type("CXX_Series", + jlcxx::julia_base_type()); type.constructor<>(); #if openPMD_HAVE_MPI @@ -70,12 +70,13 @@ void define_julia_Series(jlcxx::Module &mod) { type.constructor(); type.constructor(); - type.method("isvalid1", [](const Series &series) { return bool(series); }); - type.method("iterations", + type.method("cxx_isvalid", + [](const Series &series) { return bool(series); }); + type.method("cxx_iterations", [](Series &series) -> Container & { return series.iterations; }); - //TODO type.method("read_iterations", &Series::readIterations); - type.method("write_iterations", &Series::writeIterations); + // TODO type.method("read_iterations", &Series::readIterations); + type.method("cxx_write_iterations", &Series::writeIterations); } } diff --git a/src/binding/julia/UnitDimension.cpp b/src/binding/julia/UnitDimension.cpp index 2225bcdddb..a2725fc45d 100644 --- a/src/binding/julia/UnitDimension.cpp +++ b/src/binding/julia/UnitDimension.cpp @@ -6,11 +6,11 @@ void define_julia_UnitDimension(jlcxx::Module &mod) { mod.add_bits("UnitDimension", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - mod.set_const("L", UnitDimension::L); - mod.set_const("M", UnitDimension::M); - mod.set_const("T", UnitDimension::T); - mod.set_const("I", UnitDimension::I); - mod.set_const("θ", UnitDimension::theta); - mod.set_const("N", UnitDimension::N); - mod.set_const("J", UnitDimension::J); + mod.set_const("UNITDIMENSION_L", UnitDimension::L); + mod.set_const("UNITDIMENSION_M", UnitDimension::M); + mod.set_const("UNITDIMENSION_T", UnitDimension::T); + mod.set_const("UNITDIMENSION_I", UnitDimension::I); + mod.set_const("UNITDIMENSION_θ", UnitDimension::theta); + mod.set_const("UNITDIMENSION_N", UnitDimension::N); + mod.set_const("UNITDIMENSION_J", UnitDimension::J); } diff --git a/src/binding/julia/version.cpp b/src/binding/julia/version.cpp index 3b7a967f30..12129188bc 100644 --- a/src/binding/julia/version.cpp +++ b/src/binding/julia/version.cpp @@ -6,7 +6,7 @@ void define_julia_version(jlcxx::Module &mod) { mod.method("get_version", getVersion); mod.method("get_standard", getStandard); mod.method("get_standard_minimum", getStandardMinimum); - mod.method("get_variants1", + mod.method("cxx_get_variants", []() { return map_to_vector_pair(getVariants()); }); mod.method("get_file_extensions", getFileExtensions); } From d4d0db74012d54d6a5db59d73b1b8d330726814b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 20:26:50 -0400 Subject: [PATCH 20/94] Rename Container to CXX_Container; remove unused code --- CMakeLists.txt | 4 ---- src/binding/julia/Container.hpp | 2 +- src/binding/julia/RecordComponent.cpp | 4 ---- src/binding/julia/RecordComponent_copy_chunk.cpp | 16 ---------------- .../julia/RecordComponent_load_chunk_alloc.cpp | 14 -------------- .../julia/RecordComponent_load_chunk_buffer.cpp | 16 ---------------- .../julia/RecordComponent_store_chunk_copy.cpp | 16 ---------------- src/binding/julia/defs.hpp | 8 -------- 8 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 src/binding/julia/RecordComponent_copy_chunk.cpp delete mode 100644 src/binding/julia/RecordComponent_load_chunk_alloc.cpp delete mode 100644 src/binding/julia/RecordComponent_load_chunk_buffer.cpp delete mode 100644 src/binding/julia/RecordComponent_store_chunk_copy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index aad3194c26..ae158963c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -637,13 +637,9 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/MeshRecordComponent.cpp src/binding/julia/ReadIterations.cpp src/binding/julia/RecordComponent.cpp - src/binding/julia/RecordComponent_copy_chunk.cpp src/binding/julia/RecordComponent_load_chunk.cpp - src/binding/julia/RecordComponent_load_chunk_alloc.cpp - src/binding/julia/RecordComponent_load_chunk_buffer.cpp src/binding/julia/RecordComponent_make_constant.cpp src/binding/julia/RecordComponent_store_chunk.cpp - src/binding/julia/RecordComponent_store_chunk_copy.cpp src/binding/julia/Series.cpp src/binding/julia/UnitDimension.cpp src/binding/julia/WriteIterations.cpp diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index 8403b0b55f..1330a151de 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -26,7 +26,7 @@ void define_julia_Container(jlcxx::Module &mod) { if (!julia_Container_type) julia_Container_type = std::make_unique( mod.add_type, jlcxx::TypeVar<2>>>( - "Container", jlcxx::julia_base_type())); + "CXX_Container", jlcxx::julia_base_type())); julia_Container_type->apply>([](auto type) { using ContainerT = typename decltype(type)::type; diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index 7e5215e830..62c2783a14 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -38,11 +38,7 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { static_cast( &RecordComponent::makeEmpty)); type.method("cxx_isempty", &RecordComponent::empty); - define_julia_RecordComponent_copy_chunk(mod, type); define_julia_RecordComponent_load_chunk(mod, type); - define_julia_RecordComponent_load_chunk_alloc(mod, type); - define_julia_RecordComponent_load_chunk_buffer(mod, type); define_julia_RecordComponent_store_chunk(mod, type); - define_julia_RecordComponent_store_chunk_copy(mod, type); type.method("cxx_SCALAR", []() { return RecordComponent::SCALAR; }); } diff --git a/src/binding/julia/RecordComponent_copy_chunk.cpp b/src/binding/julia/RecordComponent_copy_chunk.cpp deleted file mode 100644 index 54d81d5615..0000000000 --- a/src/binding/julia/RecordComponent_copy_chunk.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RecordComponent_copy_chunk - -#include "defs.hpp" - -void define_julia_RecordComponent_copy_chunk( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("copy_chunk1_" NAME, \ - [](const std::shared_ptr &ptr, std::vector &data) { \ - const TYPE *dataptr = ptr.get(); \ - std::size_t datasize = data.size(); \ - std::copy(dataptr, dataptr + datasize, data.begin()); \ - }); - { FORALL_SCALAR_OPENPMD_TYPES } -#undef USE_TYPE -} diff --git a/src/binding/julia/RecordComponent_load_chunk_alloc.cpp b/src/binding/julia/RecordComponent_load_chunk_alloc.cpp deleted file mode 100644 index 8a5d178bb9..0000000000 --- a/src/binding/julia/RecordComponent_load_chunk_alloc.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RecordComponent_load_chunk_alloc - -#include "defs.hpp" - -void define_julia_RecordComponent_load_chunk_alloc( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "load_chunk_alloc1_" NAME, \ - static_cast (RecordComponent::*)(Offset, Extent)>( \ - &RecordComponent::loadChunk)); - { FORALL_SCALAR_OPENPMD_TYPES } -#undef USE_TYPE -} diff --git a/src/binding/julia/RecordComponent_load_chunk_buffer.cpp b/src/binding/julia/RecordComponent_load_chunk_buffer.cpp deleted file mode 100644 index ba6d0e7bde..0000000000 --- a/src/binding/julia/RecordComponent_load_chunk_buffer.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RecordComponent_load_chunk_buffer - -#include "defs.hpp" - -void define_julia_RecordComponent_load_chunk_buffer( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("load_chunk1_" NAME, [](RecordComponent &comp, \ - std::vector &buffer, \ - Offset offset, Extent extent) { \ - std::shared_ptr ptr(capture_vector_as_buffer(buffer)); \ - comp.loadChunk(std::move(ptr), std::move(offset), std::move(extent)); \ - }); - { FORALL_SCALAR_OPENPMD_TYPES } -#undef USE_TYPE -} diff --git a/src/binding/julia/RecordComponent_store_chunk_copy.cpp b/src/binding/julia/RecordComponent_store_chunk_copy.cpp deleted file mode 100644 index 3a2fd22f18..0000000000 --- a/src/binding/julia/RecordComponent_store_chunk_copy.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RecordComponent_store_chunk_copy - -#include "defs.hpp" - -void define_julia_RecordComponent_store_chunk_copy( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk_copy1_" NAME, [](RecordComponent &comp, \ - std::vector data, \ - Offset offset, Extent extent) { \ - std::shared_ptr ptr(capture_vector(std::move(data))); \ - comp.storeChunk(std::move(ptr), std::move(offset), std::move(extent)); \ - }); - { FORALL_SCALAR_OPENPMD_TYPES } -#undef USE_TYPE -} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 2f3c368494..8ea9f5a251 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -204,20 +204,12 @@ void define_julia_Iteration(jlcxx::Module &mod); void define_julia_Mesh(jlcxx::Module &mod); void define_julia_MeshRecordComponent(jlcxx::Module &mod); void define_julia_RecordComponent(jlcxx::Module &mod); -void define_julia_RecordComponent_copy_chunk( - jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); -void define_julia_RecordComponent_load_chunk_alloc( - jlcxx::Module &mod, jlcxx::TypeWrapper &type); -void define_julia_RecordComponent_load_chunk_buffer( - jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_make_constant( jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type); -void define_julia_RecordComponent_store_chunk_copy( - jlcxx::Module &mod, jlcxx::TypeWrapper &type); void define_julia_Series(jlcxx::Module &mod); void define_julia_UnitDimension(jlcxx::Module &mod); void define_julia_ReadIterations(jlcxx::Module &mod); From b41d41e5b184c78e27c0d42ff9f335a55de3cffb Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 7 Jul 2021 22:02:29 -0400 Subject: [PATCH 21/94] Correct wrapping names --- src/binding/julia/BaseRecordComponent.cpp | 4 +- src/binding/julia/Mesh.cpp | 67 ++++++++++--------- src/binding/julia/RecordComponent.cpp | 4 +- .../julia/RecordComponent_load_chunk.cpp | 2 +- .../julia/RecordComponent_make_constant.cpp | 2 +- .../julia/RecordComponent_store_chunk.cpp | 2 +- 6 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index 6a1a802c01..267cbb13c1 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -14,9 +14,9 @@ void define_julia_BaseRecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( "CXX_BaseRecordComponent", jlcxx::julia_base_type()); - type.method("unit_SI", &BaseRecordComponent::unitSI); + type.method("cxx_unit_SI", &BaseRecordComponent::unitSI); type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); - type.method("is_constant", &BaseRecordComponent::constant); + type.method("cxx_isconstant", &BaseRecordComponent::constant); // TODO: availableChunks } diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 74c86b0a99..99ecbbd376 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -30,43 +30,46 @@ void define_julia_Mesh(jlcxx::Module &mod) { // Mesh auto type = mod.add_type( - "Mesh", + "CXX_Mesh", // We don't wrap BaseRecord for simplicity. We thus need to declare // Container as our supertype. jlcxx::julia_base_type>()); // These two functions come from our superclass // BaseRecord. We declare them as if they were our own. - type.method("unit_dimension", &Mesh::unitDimension); - type.method("isscalar", &Mesh::scalar); + type.method("cxx_unit_dimension", &Mesh::unitDimension); + type.method("cxx_isscalar", &Mesh::scalar); - type.method("geometry", &Mesh::geometry); - type.method("set_geometry!", static_cast( - &Mesh::setGeometry)); - type.method("geometry_parameters", &Mesh::geometryParameters); - type.method("set_geometry_parameters!", &Mesh::setGeometryParameters); - type.method("data_order", &Mesh::dataOrder); - type.method("set_data_order!", &Mesh::setDataOrder); - type.method("axis_labels", &Mesh::axisLabels); - type.method("set_axis_labels1!", &Mesh::setAxisLabels); - type.method("grid_spacing", &Mesh::gridSpacing); - type.method("set_grid_spacing1!", &Mesh::setGridSpacing); - type.method("grid_global_offset", &Mesh::gridGlobalOffset); - type.method("set_grid_global_offset1!", &Mesh::setGridGlobalOffset); - type.method("grid_unit_SI", &Mesh::gridUnitSI); - type.method("set_grid_unit_SI!", &Mesh::setGridUnitSI); - type.method("set_unit_dimension1!", [](Mesh &mesh, - const array7 &unitDimension) { - return mesh.setUnitDimension(std::map{ - {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, - {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, - {UnitDimension::T, unitDimension[uint8_t(UnitDimension::T)]}, - {UnitDimension::I, unitDimension[uint8_t(UnitDimension::I)]}, - {UnitDimension::theta, unitDimension[uint8_t(UnitDimension::theta)]}, - {UnitDimension::N, unitDimension[uint8_t(UnitDimension::N)]}, - {UnitDimension::J, unitDimension[uint8_t(UnitDimension::J)]}, - }); - }); - type.method("time_offset", &Mesh::timeOffset); - type.method("set_time_offset!", &Mesh::setTimeOffset); + type.method("cxx_geometry", &Mesh::geometry); + type.method( + "cxx_set_geometry!", + static_cast(&Mesh::setGeometry)); + type.method("cxx_geometry_parameters", &Mesh::geometryParameters); + type.method("cxx_set_geometry_parameters!", &Mesh::setGeometryParameters); + type.method("cxx_data_order", &Mesh::dataOrder); + type.method("cxx_set_data_order!", &Mesh::setDataOrder); + type.method("cxx_axis_labels", &Mesh::axisLabels); + type.method("cxx_set_axis_labels!", &Mesh::setAxisLabels); + type.method("cxx_grid_spacing", &Mesh::gridSpacing); + type.method("cxx_set_grid_spacing!", &Mesh::setGridSpacing); + type.method("cxx_grid_global_offset", &Mesh::gridGlobalOffset); + type.method("cxx_set_grid_global_offset!", &Mesh::setGridGlobalOffset); + type.method("cxx_grid_unit_SI", &Mesh::gridUnitSI); + type.method("cxx_set_grid_unit_SI!", &Mesh::setGridUnitSI); + type.method( + "cxx_set_unit_dimension!", + [](Mesh &mesh, const array7 &unitDimension) { + return mesh.setUnitDimension(std::map{ + {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, + {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, + {UnitDimension::T, unitDimension[uint8_t(UnitDimension::T)]}, + {UnitDimension::I, unitDimension[uint8_t(UnitDimension::I)]}, + {UnitDimension::theta, + unitDimension[uint8_t(UnitDimension::theta)]}, + {UnitDimension::N, unitDimension[uint8_t(UnitDimension::N)]}, + {UnitDimension::J, unitDimension[uint8_t(UnitDimension::J)]}, + }); + }); + type.method("cxx_time_offset", &Mesh::timeOffset); + type.method("cxx_set_time_offset!", &Mesh::setTimeOffset); } diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index 62c2783a14..b3be78ca99 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -28,8 +28,8 @@ void define_julia_RecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( "CXX_RecordComponent", jlcxx::julia_base_type()); - type.method("set_unit_SI!", &RecordComponent::setUnitSI); - type.method("reset_dataset!", &RecordComponent::resetDataset); + type.method("cxx_set_unit_SI!", &RecordComponent::setUnitSI); + type.method("cxx_reset_dataset!", &RecordComponent::resetDataset); type.method("cxx_get_dimensionality", &RecordComponent::getDimensionality); type.method("cxx_get_extent", &RecordComponent::getExtent); define_julia_RecordComponent_make_constant(mod, type); diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index 473e5ae349..a28aee2d92 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -5,7 +5,7 @@ void define_julia_RecordComponent_load_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("load_chunk1_" NAME, \ + type.method("cxx_load_chunk_" NAME, \ static_cast, \ Offset, Extent)>( \ &RecordComponent::loadChunk)); diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 94ba4155fd..7856005ebd 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -5,7 +5,7 @@ void define_julia_RecordComponent_make_constant( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("make_constant1_" NAME, &RecordComponent::makeConstant); + type.method("cxx_make_constant_" NAME, &RecordComponent::makeConstant); { FORALL_SCALAR_OPENPMD_TYPES } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 13102dbb63..602ec9a2d8 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -5,7 +5,7 @@ void define_julia_RecordComponent_store_chunk( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("store_chunk1_" NAME, \ + type.method("cxx_store_chunk_" NAME, \ static_cast, \ Offset, Extent)>( \ &RecordComponent::storeChunk)); From b1801e1f42cd95659c9b985fc34aa1ea2ea59b33 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 8 Jul 2021 09:37:32 -0400 Subject: [PATCH 22/94] Wrap availableChunks --- CMakeLists.txt | 1 + src/binding/julia/BaseRecordComponent.cpp | 3 +-- src/binding/julia/ChunkInfo.cpp | 23 +++++++++++++++++++++++ src/binding/julia/defs.hpp | 1 + src/binding/julia/openPMD.cpp | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/binding/julia/ChunkInfo.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ae158963c4..51591556fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,6 +628,7 @@ if(openPMD_HAVE_JlCxx) src/binding/julia/Attributable.cpp src/binding/julia/Attribute.cpp src/binding/julia/BaseRecordComponent.cpp + src/binding/julia/ChunkInfo.cpp src/binding/julia/Container.cpp src/binding/julia/Dataset.cpp src/binding/julia/Datatype.cpp diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index 267cbb13c1..93cb99ad10 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -10,7 +10,6 @@ template <> struct SuperType { } // namespace jlcxx void define_julia_BaseRecordComponent(jlcxx::Module &mod) { - auto type = mod.add_type( "CXX_BaseRecordComponent", jlcxx::julia_base_type()); @@ -18,5 +17,5 @@ void define_julia_BaseRecordComponent(jlcxx::Module &mod) { type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); type.method("cxx_isconstant", &BaseRecordComponent::constant); - // TODO: availableChunks + type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks); } diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp new file mode 100644 index 0000000000..393ae42705 --- /dev/null +++ b/src/binding/julia/ChunkInfo.cpp @@ -0,0 +1,23 @@ +// ChunkInfo + +#include "defs.hpp" + +// Define supertype relationships +namespace jlcxx { +template <> struct SuperType { typedef ChunkInfo type; }; +} // namespace jlcxx + +void define_julia_ChunkInfo(jlcxx::Module &mod) { + auto chunkInfo = mod.add_type("CXX_ChunkInfo"); + chunkInfo.constructor<>(); + chunkInfo.constructor(); + chunkInfo.method("cxx_offset", + [](const ChunkInfo &chunkInfo) { return chunkInfo.offset; }); + chunkInfo.method("cxx_extent", + [](const ChunkInfo &chunkInfo) { return chunkInfo.extent; }); + + auto writtenChunkInfo = mod.add_type( + "CXX_WrittenChunkInfo", jlcxx::julia_base_type()); + writtenChunkInfo.constructor<>(); + writtenChunkInfo.constructor(); +} diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 8ea9f5a251..5c6cb7ebf8 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -195,6 +195,7 @@ void define_julia_Access(jlcxx::Module &mod); void define_julia_Attributable(jlcxx::Module &mod); void define_julia_Attribute(jlcxx::Module &mod); void define_julia_BaseRecordComponent(jlcxx::Module &mod); +void define_julia_ChunkInfo(jlcxx::Module &mod); template void define_julia_Container(jlcxx::Module &mod); void define_julia_Dataset(jlcxx::Module &mod); diff --git a/src/binding/julia/openPMD.cpp b/src/binding/julia/openPMD.cpp index 91fc3096ef..8a24490328 100644 --- a/src/binding/julia/openPMD.cpp +++ b/src/binding/julia/openPMD.cpp @@ -17,6 +17,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module &mod) { // Stand-alone classes define_julia_Access(mod); + define_julia_ChunkInfo(mod); define_julia_Datatype(mod); define_julia_Format(mod); define_julia_UnitDimension(mod); From 91b07e7ff4ef5b4b5cefb198865af6cbeb81274c Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 8 Jul 2021 10:10:33 -0400 Subject: [PATCH 23/94] Correct error in wrapping WrittenChunkInfo --- src/binding/julia/ChunkInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp index 393ae42705..eb9ecd1d46 100644 --- a/src/binding/julia/ChunkInfo.cpp +++ b/src/binding/julia/ChunkInfo.cpp @@ -16,7 +16,7 @@ void define_julia_ChunkInfo(jlcxx::Module &mod) { chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo) { return chunkInfo.extent; }); - auto writtenChunkInfo = mod.add_type( + auto writtenChunkInfo = mod.add_type( "CXX_WrittenChunkInfo", jlcxx::julia_base_type()); writtenChunkInfo.constructor<>(); writtenChunkInfo.constructor(); From 58391348d6efd8ce529dcc1548019904a63bcdd4 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 8 Jul 2021 15:47:15 -0400 Subject: [PATCH 24/94] Correct template parameter type --- include/openPMD/Datatype.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openPMD/Datatype.hpp b/include/openPMD/Datatype.hpp index c949a60f53..50db0e15c4 100644 --- a/include/openPMD/Datatype.hpp +++ b/include/openPMD/Datatype.hpp @@ -629,7 +629,7 @@ namespace detail { Datatype m_dt = BasicDatatypeHelper{}.m_dt; }; - template + template struct BasicDatatypeHelper> { Datatype m_dt = BasicDatatypeHelper{}.m_dt; }; From 1f6559bd7891fa1bbd0313c84137289dc8cc6757 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 30 Jul 2021 09:59:18 -0400 Subject: [PATCH 25/94] Julia: Rename SeriesImpl -> SeriesInterface --- src/binding/julia/Series.cpp | 88 +++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 95b8939298..26644d8480 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -4,62 +4,68 @@ // Define supertype relationships namespace jlcxx { -template <> struct SuperType { typedef Attributable type; }; -template <> struct SuperType { typedef SeriesImpl type; }; +template <> struct SuperType { typedef Attributable type; }; +template <> struct SuperType { typedef SeriesInterface type; }; } // namespace jlcxx void define_julia_Series(jlcxx::Module &mod) { - // SeriesImpl + // SeriesInterface { - auto type = mod.add_type( - "CXX_SeriesImpl", jlcxx::julia_base_type()); + auto type = mod.add_type( + "CXX_SeriesInterface", jlcxx::julia_base_type()); - type.method("cxx_openPMD_version", &SeriesImpl::openPMD); - type.method("cxx_set_openPMD_version!", &SeriesImpl::setOpenPMD); - type.method("cxx_openPMD_extension", &SeriesImpl::openPMDextension); - type.method("cxx_set_openPMD_extension!", &SeriesImpl::setOpenPMDextension); - type.method("cxx_base_path", &SeriesImpl::basePath); - type.method("cxx_set_base_path!", &SeriesImpl::setBasePath); - type.method("cxx_meshes_path", &SeriesImpl::meshesPath); - type.method("cxx_set_meshes_path!", &SeriesImpl::setMeshesPath); - type.method("cxx_particles_path", &SeriesImpl::particlesPath); - type.method("cxx_set_particles_path!", &SeriesImpl::setParticlesPath); - type.method("cxx_author", &SeriesImpl::author); - type.method("cxx_set_author!", &SeriesImpl::setAuthor); - type.method("cxx_software", &SeriesImpl::software); + type.method("cxx_openPMD_version", &SeriesInterface::openPMD); + type.method("cxx_set_openPMD_version!", &SeriesInterface::setOpenPMD); + type.method("cxx_openPMD_extension", &SeriesInterface::openPMDextension); + type.method("cxx_set_openPMD_extension!", + &SeriesInterface::setOpenPMDextension); + type.method("cxx_base_path", &SeriesInterface::basePath); + type.method("cxx_set_base_path!", &SeriesInterface::setBasePath); + type.method("cxx_meshes_path", &SeriesInterface::meshesPath); + type.method("cxx_set_meshes_path!", &SeriesInterface::setMeshesPath); + type.method("cxx_particles_path", &SeriesInterface::particlesPath); + type.method("cxx_set_particles_path!", &SeriesInterface::setParticlesPath); + type.method("cxx_author", &SeriesInterface::author); + type.method("cxx_set_author!", &SeriesInterface::setAuthor); + type.method("cxx_software", &SeriesInterface::software); + type.method( + "cxx_set_software!", + static_cast( + &SeriesInterface::setSoftware)); type.method("cxx_set_software!", - static_cast( - &SeriesImpl::setSoftware)); - type.method("cxx_set_software!", - (SeriesImpl & (SeriesImpl::*)(std::string const &))( - &SeriesImpl::setSoftware)); - type.method("cxx_software_version", &SeriesImpl::softwareVersion); - // type.method("set_software_version!", &SeriesImpl::setSoftwareVersion); - type.method("cxx_date", &SeriesImpl::date); - type.method("cxx_set_date!", &SeriesImpl::setDate); - type.method("cxx_software_dependencies", &SeriesImpl::softwareDependencies); + (SeriesInterface & (SeriesInterface::*)(std::string const &))( + &SeriesInterface::setSoftware)); + type.method("cxx_software_version", &SeriesInterface::softwareVersion); + // type.method("set_software_version!", + // &SeriesInterface::setSoftwareVersion); + type.method("cxx_date", &SeriesInterface::date); + type.method("cxx_set_date!", &SeriesInterface::setDate); + type.method("cxx_software_dependencies", + &SeriesInterface::softwareDependencies); type.method("cxx_set_software_dependencies!", - &SeriesImpl::setSoftwareDependencies); - type.method("cxx_machine", &SeriesImpl::machine); - type.method("cxx_set_machine!", &SeriesImpl::setMachine); - // TODO: type.method("iteration_encoding", &SeriesImpl::iterationEncoding); + &SeriesInterface::setSoftwareDependencies); + type.method("cxx_machine", &SeriesInterface::machine); + type.method("cxx_set_machine!", &SeriesInterface::setMachine); + // TODO: type.method("iteration_encoding", + // &SeriesInterface::iterationEncoding); // TODO: type.method("set_iteration_encoding!", - // &SeriesImpl::setIterationEncoding); - type.method("cxx_iteration_format", &SeriesImpl::iterationFormat); - type.method("cxx_set_iteration_format!", &SeriesImpl::setIterationFormat); - type.method("cxx_name", &SeriesImpl::name); - type.method("cxx_set_name!", &SeriesImpl::setName); - type.method("cxx_backend", &SeriesImpl::backend); - type.method("cxx_flush", &SeriesImpl::flush); + // &SeriesInterface::setIterationEncoding); + type.method("cxx_iteration_format", &SeriesInterface::iterationFormat); + type.method("cxx_set_iteration_format!", + &SeriesInterface::setIterationFormat); + type.method("cxx_name", &SeriesInterface::name); + type.method("cxx_set_name!", &SeriesInterface::setName); + type.method("cxx_backend", &SeriesInterface::backend); + type.method("cxx_flush", &SeriesInterface::flush); } // Series { auto type = mod.add_type("CXX_Series", - jlcxx::julia_base_type()); + jlcxx::julia_base_type()); type.constructor<>(); #if openPMD_HAVE_MPI From e315fe8562c2558e1b0e14c2823fbc5eed19c1c2 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 20 Aug 2021 16:11:36 -0400 Subject: [PATCH 26/94] Disable Julia bindings by default --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa9cf81c73..e65a17c045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ openpmd_option(MPI "Parallel, Multi-Node I/O for clusters" AUTO) openpmd_option(HDF5 "HDF5 backend (.h5 files)" AUTO) openpmd_option(ADIOS1 "ADIOS1 backend (.bp files)" AUTO) openpmd_option(ADIOS2 "ADIOS2 backend (.bp files)" AUTO) -openpmd_option(JULIA "Enable Julia bindings" AUTO) +openpmd_option(JULIA "Enable Julia bindings" OFF) openpmd_option(PYTHON "Enable Python bindings" AUTO) option(openPMD_INSTALL "Add installation targets" ON) From 895e06069df7a4309d5a647684aa1ef0c5742b53 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 20 Aug 2021 16:20:10 -0400 Subject: [PATCH 27/94] Clean up macro FORALL_OPENPMD_TYPES --- src/binding/julia/Attributable.cpp | 2 +- src/binding/julia/Attribute.cpp | 2 +- src/binding/julia/Datatype.cpp | 2 +- src/binding/julia/MeshRecordComponent.cpp | 2 +- .../julia/RecordComponent_load_chunk.cpp | 2 +- .../julia/RecordComponent_make_constant.cpp | 2 +- .../julia/RecordComponent_store_chunk.cpp | 2 +- src/binding/julia/defs.hpp | 135 +++++++++--------- src/binding/julia/shared_ptr.cpp | 2 +- 9 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 97c81c7e01..b976396c54 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -7,7 +7,7 @@ void define_julia_Attributable(jlcxx::Module &mod) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_set_attribute_" NAME "!", &Attributable::setAttribute); - { FORALL_OPENPMD_TYPES } + { FORALL_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE type.method("cxx_get_attribute", &Attributable::getAttribute); diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index 13be0c9b4a..9b1d6f631d 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -9,6 +9,6 @@ void define_julia_Attribute(jlcxx::Module &mod) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_get_" NAME, &Attribute::get); - { FORALL_OPENPMD_TYPES } + { FORALL_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index a9cc4a1a05..51620d86a7 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -7,7 +7,7 @@ void define_julia_Datatype(jlcxx::Module &mod) { jlcxx::stl::apply_stl(mod); #define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); - { FORALL_OPENPMD_TYPES } + { FORALL_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE mod.set_const("DATATYPE", Datatype::DATATYPE); mod.set_const("UNDEFINED", Datatype::UNDEFINED); diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 43c05a0e70..62dc86186f 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -18,6 +18,6 @@ void define_julia_MeshRecordComponent(jlcxx::Module &mod) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_make_constant_" NAME, \ &MeshRecordComponent::makeConstant); - { FORALL_OPENPMD_TYPES } + { FORALL_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index a28aee2d92..0a469c7787 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -9,6 +9,6 @@ void define_julia_RecordComponent_load_chunk( static_cast, \ Offset, Extent)>( \ &RecordComponent::loadChunk)); - { FORALL_SCALAR_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 7856005ebd..bafb2f4f5e 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -6,6 +6,6 @@ void define_julia_RecordComponent_make_constant( jlcxx::Module &mod, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_make_constant_" NAME, &RecordComponent::makeConstant); - { FORALL_SCALAR_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 602ec9a2d8..7988105022 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -9,6 +9,6 @@ void define_julia_RecordComponent_store_chunk( static_cast, \ Offset, Extent)>( \ &RecordComponent::storeChunk)); - { FORALL_SCALAR_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 5c6cb7ebf8..e26e37d7ec 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -24,79 +24,80 @@ using namespace openPMD; template using array7 = std::array; -// Generate code fo all openPMD types. Use is e.g. as follows: -// #define USE_TYPE(NAME, ENUM, TYPE) \ -// type.method("get_" NAME, &Attribute::get); -// FORALL_OPENPMD_TYPES -// #undef USE_TYPE -// +/* + * Generate code fo all openPMD types. Use is e.g. as follows: + * #define USE_TYPE(NAME, ENUM, TYPE) \ + * type.method("get_" NAME, &Attribute::get); + * FORALL_OPENPMD_TYPES(USE_TYPE) + * #undef USE_TYPE + */ + // We disable `long double` since Julia does not support this type // We disable `long double` since Julia does not support this type -#define FORALL_OPENPMD_TYPES \ - USE_TYPE("CHAR", Datatype::CHAR, char) \ - USE_TYPE("UCHAR", Datatype::UCHAR, unsigned char) \ - USE_TYPE("SHORT", Datatype::SHORT, short) \ - USE_TYPE("INT", Datatype::INT, int) \ - USE_TYPE("LONG", Datatype::LONG, long) \ - USE_TYPE("LONGLONG", Datatype::LONGLONG, long long) \ - USE_TYPE("USHORT", Datatype::USHORT, unsigned short) \ - USE_TYPE("UINT", Datatype::UINT, unsigned int) \ - USE_TYPE("ULONG", Datatype::ULONG, unsigned long) \ - USE_TYPE("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - USE_TYPE("FLOAT", Datatype::FLOAT, float) \ - USE_TYPE("DOUBLE", Datatype::DOUBLE, double) \ - /* USE_TYPE("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - USE_TYPE("CFLOAT", Datatype::CFLOAT, std::complex) \ - USE_TYPE("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* USE_TYPE("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) \ + MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - USE_TYPE("STRING", Datatype::STRING, std::string) \ - USE_TYPE("VEC_CHAR", Datatype::VEC_CHAR, std::vector) \ - USE_TYPE("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ - USE_TYPE("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ - USE_TYPE("VEC_INT", Datatype::VEC_INT, std::vector) \ - USE_TYPE("VEC_LONG", Datatype::VEC_LONG, std::vector) \ - USE_TYPE("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ - USE_TYPE("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ - USE_TYPE("VEC_UINT", Datatype::VEC_UINT, std::vector) \ - USE_TYPE("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ - USE_TYPE("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, \ - std::vector) \ - USE_TYPE("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ - USE_TYPE("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ - /* USE_TYPE("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) \ + MACRO("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ + MACRO("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ + MACRO("VEC_INT", Datatype::VEC_INT, std::vector) \ + MACRO("VEC_LONG", Datatype::VEC_LONG, std::vector) \ + MACRO("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ + MACRO("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ + MACRO("VEC_UINT", Datatype::VEC_UINT, std::vector) \ + MACRO("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ + MACRO("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, \ + std::vector) \ + MACRO("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ + MACRO("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ + /* MACRO("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) */ \ - USE_TYPE("VEC_CFLOAT", Datatype::VEC_CFLOAT, \ - std::vector>) \ - USE_TYPE("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, \ - std::vector>) \ - /* USE_TYPE("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ + MACRO("VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>) \ + MACRO("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, \ + std::vector>) \ + /* MACRO("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ * std::vector>) */ \ - USE_TYPE("VEC_STRING", Datatype::VEC_STRING, std::vector) \ - USE_TYPE("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ - USE_TYPE("BOOL", Datatype::BOOL, bool) - -#define FORALL_SCALAR_OPENPMD_TYPES \ - USE_TYPE("CHAR", Datatype::CHAR, char) \ - USE_TYPE("UCHAR", Datatype::UCHAR, unsigned char) \ - USE_TYPE("SHORT", Datatype::SHORT, short) \ - USE_TYPE("INT", Datatype::INT, int) \ - USE_TYPE("LONG", Datatype::LONG, long) \ - USE_TYPE("LONGLONG", Datatype::LONGLONG, long long) \ - USE_TYPE("USHORT", Datatype::USHORT, unsigned short) \ - USE_TYPE("UINT", Datatype::UINT, unsigned int) \ - USE_TYPE("ULONG", Datatype::ULONG, unsigned long) \ - USE_TYPE("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - USE_TYPE("FLOAT", Datatype::FLOAT, float) \ - USE_TYPE("DOUBLE", Datatype::DOUBLE, double) \ - /* USE_TYPE("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - USE_TYPE("CFLOAT", Datatype::CFLOAT, std::complex) \ - USE_TYPE("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* USE_TYPE("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + MACRO("BOOL", Datatype::BOOL, bool) + +#define FORALL_SCALAR_OPENPMD_TYPES(MACRO) \ + MACRO("CHAR", Datatype::CHAR, char) \ + MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ + MACRO("SHORT", Datatype::SHORT, short) \ + MACRO("INT", Datatype::INT, int) \ + MACRO("LONG", Datatype::LONG, long) \ + MACRO("LONGLONG", Datatype::LONGLONG, long long) \ + MACRO("USHORT", Datatype::USHORT, unsigned short) \ + MACRO("UINT", Datatype::UINT, unsigned int) \ + MACRO("ULONG", Datatype::ULONG, unsigned long) \ + MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ + MACRO("FLOAT", Datatype::FLOAT, float) \ + MACRO("DOUBLE", Datatype::DOUBLE, double) \ + /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ + MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ + MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - USE_TYPE("STRING", Datatype::STRING, std::string) \ - USE_TYPE("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ - USE_TYPE("BOOL", Datatype::BOOL, bool) + MACRO("STRING", Datatype::STRING, std::string) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + MACRO("BOOL", Datatype::BOOL, bool) namespace { template diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp index 5ab9607fa3..d326c6f410 100644 --- a/src/binding/julia/shared_ptr.cpp +++ b/src/binding/julia/shared_ptr.cpp @@ -6,6 +6,6 @@ void define_julia_shared_ptr(jlcxx::Module &mod) { #define USE_TYPE(NAME, ENUM, TYPE) \ mod.method("create_aliasing_shared_ptr_" NAME, \ &create_aliasing_shared_ptr); - { FORALL_SCALAR_OPENPMD_TYPES } + { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE } From 1fe64f1754d9a212d8140f310e7ea3dd741f9240 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 20 Aug 2021 16:22:01 -0400 Subject: [PATCH 28/94] Avoid compiler warnings --- src/binding/julia/ChunkInfo.cpp | 10 ++++++---- src/binding/julia/ReadIterations.cpp | 2 +- src/binding/julia/RecordComponent_load_chunk.cpp | 2 +- src/binding/julia/RecordComponent_make_constant.cpp | 2 +- src/binding/julia/WriteIterations.cpp | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp index eb9ecd1d46..33bd4f89fc 100644 --- a/src/binding/julia/ChunkInfo.cpp +++ b/src/binding/julia/ChunkInfo.cpp @@ -11,10 +11,12 @@ void define_julia_ChunkInfo(jlcxx::Module &mod) { auto chunkInfo = mod.add_type("CXX_ChunkInfo"); chunkInfo.constructor<>(); chunkInfo.constructor(); - chunkInfo.method("cxx_offset", - [](const ChunkInfo &chunkInfo) { return chunkInfo.offset; }); - chunkInfo.method("cxx_extent", - [](const ChunkInfo &chunkInfo) { return chunkInfo.extent; }); + chunkInfo.method("cxx_offset", [](const ChunkInfo &chunkInfo_) { + return chunkInfo_.offset; + }); + chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo_) { + return chunkInfo_.extent; + }); auto writtenChunkInfo = mod.add_type( "CXX_WrittenChunkInfo", jlcxx::julia_base_type()); diff --git a/src/binding/julia/ReadIterations.cpp b/src/binding/julia/ReadIterations.cpp index 2b99e4fe5f..cdd53b805c 100644 --- a/src/binding/julia/ReadIterations.cpp +++ b/src/binding/julia/ReadIterations.cpp @@ -4,7 +4,7 @@ #include -void define_julia_ReadIterations(jlcxx::Module &mod) { +void define_julia_ReadIterations(jlcxx::Module & /*mod*/) { // TODO auto type = mod.add_type("ReadIterations"); // TODO: SeriesIterator // TODO: begin, end diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index 0a469c7787..c726597688 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -3,7 +3,7 @@ #include "defs.hpp" void define_julia_RecordComponent_load_chunk( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_load_chunk_" NAME, \ static_cast, \ diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index bafb2f4f5e..a8cec440fb 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -3,7 +3,7 @@ #include "defs.hpp" void define_julia_RecordComponent_make_constant( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_make_constant_" NAME, &RecordComponent::makeConstant); { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp index e91aeb3344..2805d1065c 100644 --- a/src/binding/julia/WriteIterations.cpp +++ b/src/binding/julia/WriteIterations.cpp @@ -7,7 +7,7 @@ void define_julia_WriteIterations(jlcxx::Module &mod) { using iterations_t = Container; using key_type = typename iterations_t::key_type; - using mapped_type = typename iterations_t::mapped_type; + // using mapped_type = typename iterations_t::mapped_type; auto type = mod.add_type("WriteIterations"); type.method("getindex1!", From 46a7b004f494bc036ecfef52e6b00f04fd4e232e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 20 Aug 2021 17:02:34 -0400 Subject: [PATCH 29/94] Experiment with templates for iterating over types --- src/binding/julia/defs.hpp | 67 +++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index e26e37d7ec..fadb50300b 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,6 @@ template using array7 = std::array; * #undef USE_TYPE */ -// We disable `long double` since Julia does not support this type // We disable `long double` since Julia does not support this type #define FORALL_OPENPMD_TYPES(MACRO) \ MACRO("CHAR", Datatype::CHAR, char) \ @@ -99,6 +99,71 @@ template using array7 = std::array; MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ MACRO("BOOL", Datatype::BOOL, bool) +// This C++ version is a bit more tedious to use than the macro version above +template +void forall_openPMD_types(const F &f, Args &&...args) { + f("CHAR", Datatype::CHAR, char{}, std::forward(args)...); + f("UCHAR", Datatype::UCHAR, (unsigned char){}, std::forward(args)...); + f("SHORT", Datatype::SHORT, short{}, std::forward(args)...); + f("INT", Datatype::INT, int{}, std::forward(args)...); + f("LONG", Datatype::LONG, long{}, std::forward(args)...); + f("LONGLONG", Datatype::LONGLONG, (long long){}, std::forward(args)...); + f("USHORT", Datatype::USHORT, (unsigned short){}, + std::forward(args)...); + f("UINT", Datatype::UINT, (unsigned int){}, std::forward(args)...); + f("ULONG", Datatype::ULONG, (unsigned long){}, std::forward(args)...); + f("ULONGLONG", Datatype::ULONGLONG, (unsigned long long){}, + std::forward(args)...); + f("FLOAT", Datatype::FLOAT, float{}, std::forward(args)...); + f("DOUBLE", Datatype::DOUBLE, double{}, std::forward(args)...); + // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, (long double){}, + // std::forward(args)...); + f("CFLOAT", Datatype::CFLOAT, std::complex{}, + std::forward(args)...); + f("CDOUBLE", Datatype::CDOUBLE, std::complex{}, + std::forward(args)...); + // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex{}, + // std::forward(args)...); + f("STRING", Datatype::STRING, std::string{}, std::forward(args)...); + f("VEC_CHAR", Datatype::VEC_CHAR, std::vector{}, + std::forward(args)...); + f("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector{}, + std::forward(args)...); + f("VEC_SHORT", Datatype::VEC_SHORT, std::vector{}, + std::forward(args)...); + f("VEC_INT", Datatype::VEC_INT, std::vector{}, + std::forward(args)...); + f("VEC_LONG", Datatype::VEC_LONG, std::vector{}, + std::forward(args)...); + f("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector{}, + std::forward(args)...); + f("VEC_USHORT", Datatype::VEC_USHORT, std::vector{}, + std::forward(args)...); + f("VEC_UINT", Datatype::VEC_UINT, std::vector{}, + std::forward(args)...); + f("VEC_ULONG", Datatype::VEC_ULONG, std::vector{}, + std::forward(args)...); + f("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, std::vector{}, + std::forward(args)...); + f("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector{}, + std::forward(args)...); + f("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector{}, + std::forward(args)...); + // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector{}, + // std::forward(args)...); + f("VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>{}, + std::forward(args)...); + f("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, std::vector>{}, + std::forward(args)...); + // f("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, + // std::vector>{}, std::forward(args)...); + f("VEC_STRING", Datatype::VEC_STRING, std::vector{}, + std::forward(args)...); + f("ARR_DBL_7", Datatype::ARR_DBL_7, array7{}, + std::forward(args)...); + f("BOOL", Datatype::BOOL, bool{}, std::forward(args)...); +} + namespace { template std::vector> map_to_vector_pair(const std::map &m) { From bcf29ccc5c92f532536997231c177597411f2f17 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 16:48:46 -0400 Subject: [PATCH 30/94] Simplify cmake statements for Julia --- CMakeLists.txt | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e65a17c045..40f2cc8631 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ openpmd_option(MPI "Parallel, Multi-Node I/O for clusters" AUTO) openpmd_option(HDF5 "HDF5 backend (.h5 files)" AUTO) openpmd_option(ADIOS1 "ADIOS1 backend (.bp files)" AUTO) openpmd_option(ADIOS2 "ADIOS2 backend (.bp files)" AUTO) -openpmd_option(JULIA "Enable Julia bindings" OFF) +openpmd_option(Julia "Enable Julia bindings" OFF) openpmd_option(PYTHON "Enable Python bindings" AUTO) option(openPMD_INSTALL "Add installation targets" ON) @@ -335,27 +335,20 @@ endif() # TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON # External library: libcxxwrap-julia -if(openPMD_USE_JULIA STREQUAL AUTO) +if(openPMD_USE_Julia STREQUAL AUTO) find_package(JlCxx 0.8.3) - if(JlCxx_FOUND) - set(openPMD_HAVE_JlCxx TRUE) + if(Julia_FOUND) + set(openPMD_HAVE_Julia TRUE) else() - set(openPMD_HAVE_JlCxx FALSE) + set(openPMD_HAVE_Julia FALSE) endif() - if(JULIA_FOUND) - set(openPMD_HAVE_JULIA TRUE) - else() - set(openPMD_HAVE_JULIA FALSE) - endif() -elseif(openPMD_USE_JULIA) +elseif(openPMD_USE_Julia) find_package(JlCxx 0.8.3 REQUIRED) - set(openPMD_HAVE_JULIA TRUE) - set(openPMD_HAVE_JlCxx TRUE) + set(openPMD_HAVE_Julia TRUE) else() - set(openPMD_HAVE_JULIA FALSE) - set(openPMD_HAVE_JlCxx FALSE) + set(openPMD_HAVE_Julia FALSE) endif() -if(openPMD_HAVE_JlCxx) +if(openPMD_HAVE_Julia) get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") @@ -660,7 +653,7 @@ else() endif() # Julia bindings -if(openPMD_HAVE_JlCxx) +if(openPMD_HAVE_Julia) add_library(openPMD_jl SHARED src/binding/julia/Access.cpp src/binding/julia/Attributable.cpp @@ -1023,7 +1016,7 @@ if(openPMD_INSTALL) endforeach() endif() - if(openPMD_HAVE_JlCxx) + if(openPMD_HAVE_Julia) list(APPEND openPMD_INSTALL_TARGET_NAMES openPMD_jl) endif() From a9955b362ee99d22debd64b27f060d667deb16fd Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 16:49:07 -0400 Subject: [PATCH 31/94] Correct Julia bindings for MPI_Comm --- src/binding/julia/Series.cpp | 12 +++++++++--- src/binding/julia/defs.hpp | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 26644d8480..d30ae2a186 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -69,9 +69,15 @@ void define_julia_Series(jlcxx::Module &mod) { type.constructor<>(); #if openPMD_HAVE_MPI - type.constructor(); - type.constructor(); + type.method("cxx_Series", [](const std::string &filepath, Access at, + sized_uint_t comm, + const std::string &options) { + return Series(filepath, at, *(const MPI_Comm *)&comm, options); + }); + type.method("cxx_Series", [](const std::string &filepath, Access at, + sized_uint_t comm) { + return Series(filepath, at, *(const MPI_Comm *)&comm); + }); #endif type.constructor(); type.constructor(); diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index fadb50300b..dd6be30232 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,13 @@ using namespace openPMD; +template struct sized_uint; +template <> struct sized_uint<1> { using type = std::uint8_t; }; +template <> struct sized_uint<2> { using type = std::uint16_t; }; +template <> struct sized_uint<4> { using type = std::uint32_t; }; +template <> struct sized_uint<8> { using type = std::uint64_t; }; +template using sized_uint_t = typename sized_uint::type; + template using array7 = std::array; /* From b0c1fd027b3a777a4e1ab3f6bc2b68a2a212911f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 18:09:12 -0400 Subject: [PATCH 32/94] Rename Julia library to openPMD.jl --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40f2cc8631..d8993fe74f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -654,7 +654,7 @@ endif() # Julia bindings if(openPMD_HAVE_Julia) - add_library(openPMD_jl SHARED + add_library(openPMD.jl SHARED src/binding/julia/Access.cpp src/binding/julia/Attributable.cpp src/binding/julia/Attribute.cpp @@ -679,12 +679,12 @@ if(openPMD_HAVE_Julia) src/binding/julia/shared_ptr.cpp src/binding/julia/version.cpp ) - target_compile_features(openPMD_jl PUBLIC cxx_std_17) - set_target_properties(openPMD_jl PROPERTIES + target_compile_features(openPMD.jl PUBLIC cxx_std_17) + set_target_properties(openPMD.jl PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON ) - target_link_libraries(openPMD_jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) + target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) endif() # python bindings @@ -1017,7 +1017,7 @@ if(openPMD_INSTALL) endif() if(openPMD_HAVE_Julia) - list(APPEND openPMD_INSTALL_TARGET_NAMES openPMD_jl) + list(APPEND openPMD_INSTALL_TARGET_NAMES openPMD.jl) endif() install(TARGETS ${openPMD_INSTALL_TARGET_NAMES} From 5c192e31e4fdd66d3eb85881a7bf700ddc34207d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 18:46:30 -0400 Subject: [PATCH 33/94] Remove Julia wrapper for "DATATYPE" --- src/binding/julia/Datatype.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 51620d86a7..f9585a31a5 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -9,7 +9,6 @@ void define_julia_Datatype(jlcxx::Module &mod) { #define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); { FORALL_OPENPMD_TYPES(USE_TYPE) } #undef USE_TYPE - mod.set_const("DATATYPE", Datatype::DATATYPE); mod.set_const("UNDEFINED", Datatype::UNDEFINED); mod.set_const("openPMD_datatypes", openPMD_Datatypes); From 5c4d14f4627fcc6ed296cb644658ec5a616ea509 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 19:15:48 -0400 Subject: [PATCH 34/94] Remove "AUTO" logic for Julia --- CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce0f7d09b8..b53acb6e87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -348,14 +348,7 @@ endif() # TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON # External library: libcxxwrap-julia -if(openPMD_USE_Julia STREQUAL AUTO) - find_package(JlCxx 0.8.3) - if(Julia_FOUND) - set(openPMD_HAVE_Julia TRUE) - else() - set(openPMD_HAVE_Julia FALSE) - endif() -elseif(openPMD_USE_Julia) +if(openPMD_USE_Julia) find_package(JlCxx 0.8.3 REQUIRED) set(openPMD_HAVE_Julia TRUE) else() From 7c663d893ac64e72f29d2729e597ee98b2af0d0e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 19:32:24 -0400 Subject: [PATCH 35/94] CI: Build Julia bindings on macOS --- .github/workflows/macos.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7901503f63..7d1de89df3 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -21,6 +21,19 @@ jobs: brew install hdf5-mpi || true brew install python || true set -e + # Install Julia + wget https://julialang-s3.julialang.org/bin/mac/x64/1.6/julia-1.6.2-mac64.dmg + sudo hdiutil attach julia-1.6.2-mac64.dmg + sudo cp -fr /Volumes/Julia-1.6.2/Julia-1.6.app /Applications + sudo hdiutil detach /Volumes/Julia-1.6.2 + rm julia-1.6.2-mac64.dmg + # Install libcxxwrap-julia + wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz + tar xzf v0.8.3.tar.gz + cd libcxxwrap-julia-0.8.3 + cmake -S . -B build + cmake --build build --parallel 2 + cmake --install build --parallel 2 - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, MACOSX_DEPLOYMENT_TARGET: 10.9} # C++11 & 14 support in macOS 10.9+ @@ -30,10 +43,11 @@ jobs: share/openPMD/download_samples.sh build chmod u-w build/samples/git-sample/*.h5 cmake -S . -B build \ - -DopenPMD_USE_PYTHON=ON \ - -DopenPMD_USE_MPI=ON \ - -DopenPMD_USE_HDF5=ON \ -DopenPMD_USE_ADIOS2=ON \ + -DopenPMD_USE_HDF5=ON \ + -DopenPMD_USE_Julia=ON \ + -DopenPMD_USE_MPI=ON \ + -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure From d42b4d6094c09e2f1bb405e8fc0df4974939abc4 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 19:36:35 -0400 Subject: [PATCH 36/94] CI: Install Julia via homebrew --- .github/workflows/macos.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7d1de89df3..cfbb1c4b78 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -19,21 +19,25 @@ jobs: brew update brew install adios2 || true brew install hdf5-mpi || true + brew install julia || true brew install python || true set -e - # Install Julia - wget https://julialang-s3.julialang.org/bin/mac/x64/1.6/julia-1.6.2-mac64.dmg - sudo hdiutil attach julia-1.6.2-mac64.dmg - sudo cp -fr /Volumes/Julia-1.6.2/Julia-1.6.app /Applications - sudo hdiutil detach /Volumes/Julia-1.6.2 - rm julia-1.6.2-mac64.dmg + # # Install Julia + # wget https://julialang-s3.julialang.org/bin/mac/x64/1.6/julia-1.6.2-mac64.dmg + # sudo hdiutil attach julia-1.6.2-mac64.dmg + # sudo cp -fr /Volumes/Julia-1.6.2/Julia-1.6.app /Applications + # sudo hdiutil detach /Volumes/Julia-1.6.2 + # rm julia-1.6.2-mac64.dmg # Install libcxxwrap-julia wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz tar xzf v0.8.3.tar.gz + rm -rf v0.8.3.tar.gz cd libcxxwrap-julia-0.8.3 cmake -S . -B build cmake --build build --parallel 2 cmake --install build --parallel 2 + cd .. + rm -rf libcxxwrap-julia-0.8.3 - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, MACOSX_DEPLOYMENT_TARGET: 10.9} # C++11 & 14 support in macOS 10.9+ From cbb0da4e2011e999522f190583ba06c60ae6c497 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 20:31:25 -0400 Subject: [PATCH 37/94] CI: Correct cmake options for installing libcxxwrap-julia --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cfbb1c4b78..12e4a1e1e3 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -35,7 +35,7 @@ jobs: cd libcxxwrap-julia-0.8.3 cmake -S . -B build cmake --build build --parallel 2 - cmake --install build --parallel 2 + cmake --install build cd .. rm -rf libcxxwrap-julia-0.8.3 - name: Build From a288938e01af6d8add8a2704baee8b52feb062c1 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 20:55:48 -0400 Subject: [PATCH 38/94] CI: Require macOS 10.12+ for Julia bindings --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 12e4a1e1e3..42119e4011 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -39,7 +39,7 @@ jobs: cd .. rm -rf libcxxwrap-julia-0.8.3 - name: Build - env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, MACOSX_DEPLOYMENT_TARGET: 10.9} + env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, MACOSX_DEPLOYMENT_TARGET: 10.12} # C++11 & 14 support in macOS 10.9+ # C++17 support in macOS 10.13+/10.14+ # https://cibuildwheel.readthedocs.io/en/stable/cpp_standards/#macos-and-deployment-target-versions From dd9aff693de6d98b0075b8182547131cd3ea7601 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 17 Sep 2021 21:39:49 -0400 Subject: [PATCH 39/94] CI: Build Julia bindings on gcc9_py38_pd_nompi_h5_ad1_ad2_libcpp --- .github/workflows/linux.yml | 19 +++++++++++++++++-- .github/workflows/macos.yml | 6 ------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 06383feabb..8a9646f606 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -216,15 +216,30 @@ jobs: sudo apt-get update sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev libadios-dev python3 python3-numpy python3-mpi4py python3-pandas # TODO ADIOS1 (.pc file broken?) ADIOS2 + # Install Julia + wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.2-linux-x86_64.tar.gz + tar -xz -C /usr/local -f julia-1.6.2-linux-x86_64.tar.gz + rm julia-1.6.2-linux-x86_64.tar.gz + # Install libcxxwrap-julia + wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz + tar xzf v0.8.3.tar.gz + rm -rf v0.8.3.tar.gz + cd libcxxwrap-julia-0.8.3 + cmake -S . -B build -DJulia_EXECUTABLE=/usr/local/julia-1.6.2/bin/julia + cmake --build build --parallel 2 + cmake --install build + cd .. + rm -rf libcxxwrap-julia-0.8.3 - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig} run: | share/openPMD/download_samples.sh build chmod u-w build/samples/git-sample/*.h5 cmake -S . -B build \ - -DopenPMD_USE_PYTHON=ON \ - -DopenPMD_USE_MPI=ON \ -DopenPMD_USE_HDF5=ON \ + -DopenPMD_USE_Julia=ON \ + -DopenPMD_USE_MPI=ON \ + -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 42119e4011..587c3ccbae 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -22,12 +22,6 @@ jobs: brew install julia || true brew install python || true set -e - # # Install Julia - # wget https://julialang-s3.julialang.org/bin/mac/x64/1.6/julia-1.6.2-mac64.dmg - # sudo hdiutil attach julia-1.6.2-mac64.dmg - # sudo cp -fr /Volumes/Julia-1.6.2/Julia-1.6.app /Applications - # sudo hdiutil detach /Volumes/Julia-1.6.2 - # rm julia-1.6.2-mac64.dmg # Install libcxxwrap-julia wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz tar xzf v0.8.3.tar.gz From 19af703c8851e76f7014264cd737f17f360d18fe Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 13 Oct 2021 12:16:17 -0400 Subject: [PATCH 40/94] Add `close` function to Series object --- include/openPMD/Series.hpp | 8 ++++++++ src/Series.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/include/openPMD/Series.hpp b/include/openPMD/Series.hpp index cf34a3074d..39b70bdd1d 100644 --- a/include/openPMD/Series.hpp +++ b/include/openPMD/Series.hpp @@ -517,6 +517,14 @@ class Series : public SeriesInterface */ operator bool() const; + /** + * @brief Close the Series object, and put it into the unusable state. + * + * Closes the Series object, flushing all state, and puts it into + * the default-constructed state. + */ + void close(); + /** * @brief Entry point to the reading end of the streaming API. * diff --git a/src/Series.cpp b/src/Series.cpp index c95662bff2..a5b6ca9543 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -1568,6 +1568,11 @@ Series::operator bool() const return m_series.operator bool(); } +void Series::close() +{ + m_series = nullptr; +} + ReadIterations Series::readIterations() { return { *this }; From f32b68bb748f0cb6a35dc85898c2e1b8e7c2073b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 13 Oct 2021 12:17:43 -0400 Subject: [PATCH 41/94] [julia] Wrap Series::closeee --- src/binding/julia/Series.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index d30ae2a186..147719e41e 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -84,6 +84,7 @@ void define_julia_Series(jlcxx::Module &mod) { type.method("cxx_isvalid", [](const Series &series) { return bool(series); }); + type.method("cxx_close", &Series::close); type.method("cxx_iterations", [](Series &series) -> Container & { return series.iterations; From 3d23f12061650dccf4cb0e5e42f902f56945c71e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 16 Dec 2021 20:20:58 -0500 Subject: [PATCH 42/94] Julia interface: Clean up handling std::array --- src/binding/julia/Mesh.cpp | 2 +- src/binding/julia/Series.cpp | 8 ++++ src/binding/julia/defs.hpp | 91 +++++++++++++++++++----------------- 3 files changed, 58 insertions(+), 43 deletions(-) diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 99ecbbd376..d1c5f0dbbf 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -58,7 +58,7 @@ void define_julia_Mesh(jlcxx::Module &mod) { type.method("cxx_set_grid_unit_SI!", &Mesh::setGridUnitSI); type.method( "cxx_set_unit_dimension!", - [](Mesh &mesh, const array7 &unitDimension) { + [](Mesh &mesh, const array_double_7 &unitDimension) { return mesh.setUnitDimension(std::map{ {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 147719e41e..c26b57b857 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -2,6 +2,14 @@ #include "defs.hpp" +#if openPMD_HAVE_MPI +#include + +namespace jlcxx { +template <> struct IsMirroredType : std::false_type {}; +} // namespace jlcxx +#endif + // Define supertype relationships namespace jlcxx { template <> struct SuperType { typedef Attributable type; }; diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index dd6be30232..a5530c347d 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -31,7 +31,7 @@ template <> struct sized_uint<4> { using type = std::uint32_t; }; template <> struct sized_uint<8> { using type = std::uint64_t; }; template using sized_uint_t = typename sized_uint::type; -template using array7 = std::array; +using array_double_7 = std::array; /* * Generate code fo all openPMD types. Use is e.g. as follows: @@ -82,7 +82,7 @@ template using array7 = std::array; /* MACRO("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ * std::vector>) */ \ MACRO("VEC_STRING", Datatype::VEC_STRING, std::vector) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ MACRO("BOOL", Datatype::BOOL, bool) #define FORALL_SCALAR_OPENPMD_TYPES(MACRO) \ @@ -104,72 +104,79 @@ template using array7 = std::array; /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ MACRO("STRING", Datatype::STRING, std::string) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array7) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ MACRO("BOOL", Datatype::BOOL, bool) // This C++ version is a bit more tedious to use than the macro version above +template T typeval() { return T{}; } template void forall_openPMD_types(const F &f, Args &&...args) { - f("CHAR", Datatype::CHAR, char{}, std::forward(args)...); - f("UCHAR", Datatype::UCHAR, (unsigned char){}, std::forward(args)...); - f("SHORT", Datatype::SHORT, short{}, std::forward(args)...); - f("INT", Datatype::INT, int{}, std::forward(args)...); - f("LONG", Datatype::LONG, long{}, std::forward(args)...); - f("LONGLONG", Datatype::LONGLONG, (long long){}, std::forward(args)...); - f("USHORT", Datatype::USHORT, (unsigned short){}, + f("CHAR", Datatype::CHAR, typeval(), std::forward(args)...); + f("UCHAR", Datatype::UCHAR, typeval(), std::forward(args)...); - f("UINT", Datatype::UINT, (unsigned int){}, std::forward(args)...); - f("ULONG", Datatype::ULONG, (unsigned long){}, std::forward(args)...); - f("ULONGLONG", Datatype::ULONGLONG, (unsigned long long){}, + f("SHORT", Datatype::SHORT, typeval(), std::forward(args)...); + f("INT", Datatype::INT, typeval(), std::forward(args)...); + f("LONG", Datatype::LONG, typeval(), std::forward(args)...); + f("LONGLONG", Datatype::LONGLONG, typeval(), std::forward(args)...); - f("FLOAT", Datatype::FLOAT, float{}, std::forward(args)...); - f("DOUBLE", Datatype::DOUBLE, double{}, std::forward(args)...); - // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, (long double){}, - // std::forward(args)...); - f("CFLOAT", Datatype::CFLOAT, std::complex{}, + f("USHORT", Datatype::USHORT, typeval(), + std::forward(args)...); + f("UINT", Datatype::UINT, typeval(), + std::forward(args)...); + f("ULONG", Datatype::ULONG, typeval(), std::forward(args)...); - f("CDOUBLE", Datatype::CDOUBLE, std::complex{}, + f("ULONGLONG", Datatype::ULONGLONG, typeval(), std::forward(args)...); - // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex{}, + f("FLOAT", Datatype::FLOAT, typeval(), std::forward(args)...); + f("DOUBLE", Datatype::DOUBLE, typeval(), std::forward(args)...); + // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, typeval(), // std::forward(args)...); - f("STRING", Datatype::STRING, std::string{}, std::forward(args)...); - f("VEC_CHAR", Datatype::VEC_CHAR, std::vector{}, + f("CFLOAT", Datatype::CFLOAT, typeval>(), std::forward(args)...); - f("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector{}, + f("CDOUBLE", Datatype::CDOUBLE, typeval>(), std::forward(args)...); - f("VEC_SHORT", Datatype::VEC_SHORT, std::vector{}, + // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, typeval>(), std::forward(args)...); + f("STRING", Datatype::STRING, typeval(), std::forward(args)...); - f("VEC_INT", Datatype::VEC_INT, std::vector{}, + f("VEC_CHAR", Datatype::VEC_CHAR, typeval>(), std::forward(args)...); - f("VEC_LONG", Datatype::VEC_LONG, std::vector{}, + f("VEC_UCHAR", Datatype::VEC_UCHAR, typeval>(), std::forward(args)...); - f("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector{}, + f("VEC_SHORT", Datatype::VEC_SHORT, typeval>(), std::forward(args)...); - f("VEC_USHORT", Datatype::VEC_USHORT, std::vector{}, + f("VEC_INT", Datatype::VEC_INT, typeval>(), std::forward(args)...); - f("VEC_UINT", Datatype::VEC_UINT, std::vector{}, + f("VEC_LONG", Datatype::VEC_LONG, typeval>(), std::forward(args)...); - f("VEC_ULONG", Datatype::VEC_ULONG, std::vector{}, + f("VEC_LONGLONG", Datatype::VEC_LONGLONG, typeval>(), std::forward(args)...); - f("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, std::vector{}, + f("VEC_USHORT", Datatype::VEC_USHORT, typeval>(), std::forward(args)...); - f("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector{}, + f("VEC_UINT", Datatype::VEC_UINT, typeval>(), std::forward(args)...); - f("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector{}, + f("VEC_ULONG", Datatype::VEC_ULONG, typeval>(), std::forward(args)...); - // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector{}, - // std::forward(args)...); - f("VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>{}, + f("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, + typeval>(), std::forward(args)...); + f("VEC_FLOAT", Datatype::VEC_FLOAT, typeval>(), std::forward(args)...); - f("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, std::vector>{}, + f("VEC_DOUBLE", Datatype::VEC_DOUBLE, typeval>(), std::forward(args)...); + // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, typeval>(), std::forward(args)...); + f("VEC_CFLOAT", Datatype::VEC_CFLOAT, + typeval>>(), std::forward(args)...); + f("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, + typeval>>(), std::forward(args)...); // f("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, - // std::vector>{}, std::forward(args)...); - f("VEC_STRING", Datatype::VEC_STRING, std::vector{}, + // typeval>>(), + // std::forward(args)...); + f("VEC_STRING", Datatype::VEC_STRING, typeval>(), std::forward(args)...); - f("ARR_DBL_7", Datatype::ARR_DBL_7, array7{}, + f("ARR_DBL_7", Datatype::ARR_DBL_7, typeval(), std::forward(args)...); - f("BOOL", Datatype::BOOL, bool{}, std::forward(args)...); + f("BOOL", Datatype::BOOL, typeval(), std::forward(args)...); } namespace { @@ -261,7 +268,7 @@ void add_pair_type(jlcxx::Module &mod, const std::string &name) { } // namespace namespace jlcxx { -template <> struct IsMirroredType> : std::false_type {}; +template <> struct IsMirroredType : std::false_type {}; } // namespace jlcxx // We use one function per header file From 7daa8337ad778131d04f6dbfd900f813fdf2ee1d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 30 Dec 2021 22:16:46 -0500 Subject: [PATCH 43/94] Resolve merge errors --- include/openPMD/Series.hpp | 1 - src/Series.cpp | 5 ----- 2 files changed, 6 deletions(-) diff --git a/include/openPMD/Series.hpp b/include/openPMD/Series.hpp index 7416a1ce08..1bac1f360c 100644 --- a/include/openPMD/Series.hpp +++ b/include/openPMD/Series.hpp @@ -54,7 +54,6 @@ namespace openPMD { class ReadIterations; class Series; -class Series; namespace internal { diff --git a/src/Series.cpp b/src/Series.cpp index 3337d1c83a..519710aa3f 100644 --- a/src/Series.cpp +++ b/src/Series.cpp @@ -1654,11 +1654,6 @@ Series::operator bool() const return m_series.operator bool(); } -void Series::close() -{ - m_series = nullptr; -} - ReadIterations Series::readIterations() { // Use private constructor instead of copy constructor to avoid From 218b67e18d0c67ade7872915cbe5260341f0531f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 30 Dec 2021 22:16:54 -0500 Subject: [PATCH 44/94] Update Julia interface --- src/binding/julia/Dataset.cpp | 15 ++-- src/binding/julia/Series.cpp | 142 +++++++++++++++------------------- 2 files changed, 73 insertions(+), 84 deletions(-) diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index f4c968ab19..77eb393dfb 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -10,14 +10,17 @@ void define_julia_Dataset(jlcxx::Module &mod) { type.constructor(); type.method("cxx_extend!", &Dataset::extend); - type.method("cxx_set_chunk_size!", &Dataset::setChunkSize); - type.method("set_compression!", &Dataset::setCompression); - type.method("set_custom_transform!", &Dataset::setCustomTransform); + // TODO type.method("cxx_set_chunk_size!", &Dataset::setChunkSize); + // TODO type.method("set_compression!", &Dataset::setCompression); + // TODO type.method("set_custom_transform!", &Dataset::setCustomTransform); type.method("cxx_extent", [](const Dataset &d) { return d.extent; }); type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; }); type.method("cxx_rank", [](const Dataset &d) { return d.rank; }); - type.method("cxx_chunk_size", [](const Dataset &d) { return d.chunkSize; }); - type.method("compression", [](const Dataset &d) { return d.compression; }); - type.method("transform", [](const Dataset &d) { return d.transform; }); + // TODO type.method("cxx_chunk_size", [](const Dataset &d) { return + // d.chunkSize; }); + // TODO type.method("compression", [](const Dataset &d) { return + // d.compression; }); + // TODO type.method("transform", [](const Dataset &d) { return d.transform; + // }); type.method("options", [](const Dataset &d) { return d.options; }); } diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index c26b57b857..f97662bf79 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -12,92 +12,78 @@ template <> struct IsMirroredType : std::false_type {}; // Define supertype relationships namespace jlcxx { -template <> struct SuperType { typedef Attributable type; }; -template <> struct SuperType { typedef SeriesInterface type; }; +template <> struct SuperType { typedef Attributable type; }; } // namespace jlcxx void define_julia_Series(jlcxx::Module &mod) { - // SeriesInterface - { - auto type = mod.add_type( - "CXX_SeriesInterface", jlcxx::julia_base_type()); - - type.method("cxx_openPMD_version", &SeriesInterface::openPMD); - type.method("cxx_set_openPMD_version!", &SeriesInterface::setOpenPMD); - type.method("cxx_openPMD_extension", &SeriesInterface::openPMDextension); - type.method("cxx_set_openPMD_extension!", - &SeriesInterface::setOpenPMDextension); - type.method("cxx_base_path", &SeriesInterface::basePath); - type.method("cxx_set_base_path!", &SeriesInterface::setBasePath); - type.method("cxx_meshes_path", &SeriesInterface::meshesPath); - type.method("cxx_set_meshes_path!", &SeriesInterface::setMeshesPath); - type.method("cxx_particles_path", &SeriesInterface::particlesPath); - type.method("cxx_set_particles_path!", &SeriesInterface::setParticlesPath); - type.method("cxx_author", &SeriesInterface::author); - type.method("cxx_set_author!", &SeriesInterface::setAuthor); - type.method("cxx_software", &SeriesInterface::software); - type.method( - "cxx_set_software!", - static_cast( - &SeriesInterface::setSoftware)); - type.method("cxx_set_software!", - (SeriesInterface & (SeriesInterface::*)(std::string const &))( - &SeriesInterface::setSoftware)); - type.method("cxx_software_version", &SeriesInterface::softwareVersion); - // type.method("set_software_version!", - // &SeriesInterface::setSoftwareVersion); - type.method("cxx_date", &SeriesInterface::date); - type.method("cxx_set_date!", &SeriesInterface::setDate); - type.method("cxx_software_dependencies", - &SeriesInterface::softwareDependencies); - type.method("cxx_set_software_dependencies!", - &SeriesInterface::setSoftwareDependencies); - type.method("cxx_machine", &SeriesInterface::machine); - type.method("cxx_set_machine!", &SeriesInterface::setMachine); - // TODO: type.method("iteration_encoding", - // &SeriesInterface::iterationEncoding); - // TODO: type.method("set_iteration_encoding!", - // &SeriesInterface::setIterationEncoding); - type.method("cxx_iteration_format", &SeriesInterface::iterationFormat); - type.method("cxx_set_iteration_format!", - &SeriesInterface::setIterationFormat); - type.method("cxx_name", &SeriesInterface::name); - type.method("cxx_set_name!", &SeriesInterface::setName); - type.method("cxx_backend", &SeriesInterface::backend); - type.method("cxx_flush", &SeriesInterface::flush); - } - // Series - { - auto type = mod.add_type("CXX_Series", - jlcxx::julia_base_type()); + auto type = mod.add_type("CXX_Series", + jlcxx::julia_base_type()); - type.constructor<>(); + type.constructor<>(); #if openPMD_HAVE_MPI - type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t comm, - const std::string &options) { - return Series(filepath, at, *(const MPI_Comm *)&comm, options); - }); - type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t comm) { - return Series(filepath, at, *(const MPI_Comm *)&comm); - }); + type.method("cxx_Series", [](const std::string &filepath, Access at, + sized_uint_t comm, + const std::string &options) { + return Series(filepath, at, *(const MPI_Comm *)&comm, options); + }); + type.method("cxx_Series", [](const std::string &filepath, Access at, + sized_uint_t comm) { + return Series(filepath, at, *(const MPI_Comm *)&comm); + }); #endif - type.constructor(); - type.constructor(); + type.constructor(); + type.constructor(); + + type.method("cxx_isvalid", [](const Series &series) { return bool(series); }); + + type.method("cxx_openPMD_version", &Series::openPMD); + type.method("cxx_set_openPMD_version!", &Series::setOpenPMD); + type.method("cxx_openPMD_extension", &Series::openPMDextension); + type.method("cxx_set_openPMD_extension!", &Series::setOpenPMDextension); + type.method("cxx_base_path", &Series::basePath); + type.method("cxx_set_base_path!", &Series::setBasePath); + type.method("cxx_meshes_path", &Series::meshesPath); + type.method("cxx_set_meshes_path!", &Series::setMeshesPath); + type.method("cxx_particles_path", &Series::particlesPath); + type.method("cxx_set_particles_path!", &Series::setParticlesPath); + type.method("cxx_author", &Series::author); + type.method("cxx_set_author!", &Series::setAuthor); + type.method("cxx_software", &Series::software); + type.method("cxx_set_software!", + static_cast( + &Series::setSoftware)); + type.method("cxx_set_software!", (Series & (Series::*)(std::string const &))( + &Series::setSoftware)); + type.method("cxx_software_version", &Series::softwareVersion); + // type.method("set_software_version!", + // &Series::setSoftwareVersion); + type.method("cxx_date", &Series::date); + type.method("cxx_set_date!", &Series::setDate); + type.method("cxx_software_dependencies", &Series::softwareDependencies); + type.method("cxx_set_software_dependencies!", + &Series::setSoftwareDependencies); + type.method("cxx_machine", &Series::machine); + type.method("cxx_set_machine!", &Series::setMachine); + // TODO: type.method("iteration_encoding", + // &Series::iterationEncoding); + // TODO: type.method("set_iteration_encoding!", + // &Series::setIterationEncoding); + type.method("cxx_iteration_format", &Series::iterationFormat); + type.method("cxx_set_iteration_format!", &Series::setIterationFormat); + type.method("cxx_name", &Series::name); + type.method("cxx_set_name!", &Series::setName); + type.method("cxx_backend", &Series::backend); + type.method("cxx_flush", &Series::flush); - type.method("cxx_isvalid", - [](const Series &series) { return bool(series); }); - type.method("cxx_close", &Series::close); - type.method("cxx_iterations", - [](Series &series) -> Container & { - return series.iterations; - }); - // TODO type.method("read_iterations", &Series::readIterations); - type.method("cxx_write_iterations", &Series::writeIterations); - } + // TODO type.method("cxx_close", &Series::close); + type.method("cxx_iterations", + [](Series &series) -> Container & { + return series.iterations; + }); + // TODO type.method("read_iterations", &Series::readIterations); + type.method("cxx_write_iterations", &Series::writeIterations); } From 1e9e69ca01b402217207671ea5798faf279dd05d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 30 Dec 2021 22:25:53 -0500 Subject: [PATCH 45/94] CI: Update to Julia 1.6.5; correct yaml syntax --- .github/workflows/linux.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c1fef3ff1c..187278eec5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -226,17 +226,17 @@ jobs: run: | sudo apt-get update sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev libadios-dev python3 python3-numpy python3-mpi4py python3-pandas -# TODO ADIOS1 (.pc file broken?) ADIOS2 + # TODO ADIOS1 (.pc file broken?) ADIOS2 # Install Julia - wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.2-linux-x86_64.tar.gz - tar -xz -C /usr/local -f julia-1.6.2-linux-x86_64.tar.gz - rm julia-1.6.2-linux-x86_64.tar.gz + wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.5-linux-x86_64.tar.gz + tar -xz -C /usr/local -f julia-1.6.5-linux-x86_64.tar.gz + rm julia-1.6.5-linux-x86_64.tar.gz # Install libcxxwrap-julia wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz tar xzf v0.8.3.tar.gz rm -rf v0.8.3.tar.gz cd libcxxwrap-julia-0.8.3 - cmake -S . -B build -DJulia_EXECUTABLE=/usr/local/julia-1.6.2/bin/julia + cmake -S . -B build -DJulia_EXECUTABLE=/usr/local/julia-1.6.5/bin/julia cmake --build build --parallel 2 cmake --install build cd .. From de3d45143c8d371666dbd08053205917d04db4bd Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 13:22:33 -0500 Subject: [PATCH 46/94] CI: Use newer version of libcxxwrap-julia --- .github/workflows/macos.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 8ac75fa1d3..6716c5f5a3 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -28,15 +28,20 @@ jobs: brew install python || true set -e # Install libcxxwrap-julia - wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz - tar xzf v0.8.3.tar.gz - rm -rf v0.8.3.tar.gz - cd libcxxwrap-julia-0.8.3 + # wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz + # tar xzf v0.8.3.tar.gz + # rm -rf v0.8.3.tar.gz + # cd libcxxwrap-julia-0.8.3 + wget https://github.com/JuliaInterop/libcxxwrap-julia.git/tarball/37743e11cda7363a17840fe2353ff78a7e964a2c + tar xzf 37743e11cda7363a17840fe2353ff78a7e964a2c + rm -rf 37743e11cda7363a17840fe2353ff78a7e964a2c + cd JuliaInterop-libcxxwrap-julia-37743e1 cmake -S . -B build cmake --build build --parallel 2 cmake --install build cd .. - rm -rf libcxxwrap-julia-0.8.3 + # rm -rf libcxxwrap-julia-0.8.3 + rm -rf JuliaInterop-libcxxwrap-julia-37743e1 - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, MACOSX_DEPLOYMENT_TARGET: 10.12} # C++11 & 14 support in macOS 10.9+ From 896daebb171c9d2637144c4fa9acbb91b632f805 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 14:25:31 -0500 Subject: [PATCH 47/94] CI: Correct Julia/libcxxwrap download commands --- .github/workflows/linux.yml | 8 ++++---- .github/workflows/macos.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 187278eec5..eed4f24b0b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -229,7 +229,7 @@ jobs: # TODO ADIOS1 (.pc file broken?) ADIOS2 # Install Julia wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.5-linux-x86_64.tar.gz - tar -xz -C /usr/local -f julia-1.6.5-linux-x86_64.tar.gz + sudo tar -xz -C /usr/local -f julia-1.6.5-linux-x86_64.tar.gz rm julia-1.6.5-linux-x86_64.tar.gz # Install libcxxwrap-julia wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz @@ -238,7 +238,7 @@ jobs: cd libcxxwrap-julia-0.8.3 cmake -S . -B build -DJulia_EXECUTABLE=/usr/local/julia-1.6.5/bin/julia cmake --build build --parallel 2 - cmake --install build + sudo cmake --install build cd .. rm -rf libcxxwrap-julia-0.8.3 - name: Build @@ -246,9 +246,9 @@ jobs: run: | share/openPMD/download_samples.sh build chmod u-w build/samples/git-sample/*.h5 - cmake -S . -B build \ + cmake -S . -B build \ -DopenPMD_USE_HDF5=ON \ - -DopenPMD_USE_Julia=ON \ + -DopenPMD_USE_Julia=ON \ -DopenPMD_USE_MPI=ON \ -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6716c5f5a3..190e23cfd1 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -32,7 +32,7 @@ jobs: # tar xzf v0.8.3.tar.gz # rm -rf v0.8.3.tar.gz # cd libcxxwrap-julia-0.8.3 - wget https://github.com/JuliaInterop/libcxxwrap-julia.git/tarball/37743e11cda7363a17840fe2353ff78a7e964a2c + wget https://github.com/JuliaInterop/libcxxwrap-julia/tarball/37743e11cda7363a17840fe2353ff78a7e964a2c tar xzf 37743e11cda7363a17840fe2353ff78a7e964a2c rm -rf 37743e11cda7363a17840fe2353ff78a7e964a2c cd JuliaInterop-libcxxwrap-julia-37743e1 From 1228708ab9e55c172d4eba9fc01f9ef49a585628 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 14:51:39 -0500 Subject: [PATCH 48/94] Avoid unused-parameter warning --- src/binding/julia/RecordComponent_store_chunk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 7988105022..64ba48a7f1 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -3,7 +3,7 @@ #include "defs.hpp" void define_julia_RecordComponent_store_chunk( - jlcxx::Module &mod, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { #define USE_TYPE(NAME, ENUM, TYPE) \ type.method("cxx_store_chunk_" NAME, \ static_cast, \ From d146f5f4a0dff5d7cbd68b7db63aa5ba5442772d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 16:51:47 -0500 Subject: [PATCH 49/94] Avoid compiler warnings --- src/binding/julia/Series.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index f97662bf79..84a1456cb7 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -27,11 +27,12 @@ void define_julia_Series(jlcxx::Module &mod) { type.method("cxx_Series", [](const std::string &filepath, Access at, sized_uint_t comm, const std::string &options) { - return Series(filepath, at, *(const MPI_Comm *)&comm, options); + return Series(filepath, at, *(const MPI_Comm *)(const void *)&comm, + options); }); type.method("cxx_Series", [](const std::string &filepath, Access at, sized_uint_t comm) { - return Series(filepath, at, *(const MPI_Comm *)&comm); + return Series(filepath, at, *(const MPI_Comm *)(const void *)&comm); }); #endif type.constructor(); @@ -53,11 +54,13 @@ void define_julia_Series(jlcxx::Module &mod) { type.method("cxx_set_author!", &Series::setAuthor); type.method("cxx_software", &Series::software); type.method("cxx_set_software!", - static_cast( + static_cast( &Series::setSoftware)); - type.method("cxx_set_software!", (Series & (Series::*)(std::string const &))( - &Series::setSoftware)); + type.method("cxx_set_software!", + [](Series &series, const std::string &newName) -> Series & { + return series.setSoftware(newName); + }); type.method("cxx_software_version", &Series::softwareVersion); // type.method("set_software_version!", // &Series::setSoftwareVersion); From d7eefb96c78c359c2fdce7373436f335010f3caf Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 17:04:31 -0500 Subject: [PATCH 50/94] Add missing include header --- src/binding/python/Series.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/binding/python/Series.cpp b/src/binding/python/Series.cpp index b8bb2e8298..e2a24cdb75 100644 --- a/src/binding/python/Series.cpp +++ b/src/binding/python/Series.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "openPMD/config.hpp" #include "openPMD/Series.hpp" From d3c042b658dd9cda5a493844dcbfd667052cc45a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 31 Dec 2021 23:40:39 -0500 Subject: [PATCH 51/94] Correct pointer casts --- src/binding/julia/Series.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 84a1456cb7..73be8991e3 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -27,12 +27,11 @@ void define_julia_Series(jlcxx::Module &mod) { type.method("cxx_Series", [](const std::string &filepath, Access at, sized_uint_t comm, const std::string &options) { - return Series(filepath, at, *(const MPI_Comm *)(const void *)&comm, - options); + return Series(filepath, at, reinterpret_cast(comm), options); }); type.method("cxx_Series", [](const std::string &filepath, Access at, sized_uint_t comm) { - return Series(filepath, at, *(const MPI_Comm *)(const void *)&comm); + return Series(filepath, at, reinterpret_cast(comm)); }); #endif type.constructor(); From 3c9f215a35fbd9ef276640ec6e6220dd42f23d14 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 1 Jan 2022 19:48:17 -0500 Subject: [PATCH 52/94] Remove outdated function from Julia bindings --- src/binding/julia/Dataset.cpp | 9 --------- src/binding/julia/Iteration.cpp | 1 - 2 files changed, 10 deletions(-) diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index 77eb393dfb..019cfc6143 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -10,17 +10,8 @@ void define_julia_Dataset(jlcxx::Module &mod) { type.constructor(); type.method("cxx_extend!", &Dataset::extend); - // TODO type.method("cxx_set_chunk_size!", &Dataset::setChunkSize); - // TODO type.method("set_compression!", &Dataset::setCompression); - // TODO type.method("set_custom_transform!", &Dataset::setCustomTransform); type.method("cxx_extent", [](const Dataset &d) { return d.extent; }); type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; }); type.method("cxx_rank", [](const Dataset &d) { return d.rank; }); - // TODO type.method("cxx_chunk_size", [](const Dataset &d) { return - // d.chunkSize; }); - // TODO type.method("compression", [](const Dataset &d) { return - // d.compression; }); - // TODO type.method("transform", [](const Dataset &d) { return d.transform; - // }); type.method("options", [](const Dataset &d) { return d.options; }); } diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index 1dae10240a..654c850654 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -23,7 +23,6 @@ void define_julia_Iteration(jlcxx::Module &mod) { static_cast(&Iteration::close)); type.method("cxx_open", &Iteration::open); type.method("cxx_closed", &Iteration::closed); - type.method("cxx_closed_by_writer", &Iteration::closedByWriter); type.method("cxx_meshes", [](Iteration &iter) -> Container & { return iter.meshes; }); // TODO: particles From 32f4fe62bd92cad93c920a93a589211a95bd1543 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 1 Jan 2022 19:48:39 -0500 Subject: [PATCH 53/94] [Julia] Use memcpy to handle MPI_Comm --- src/binding/julia/Series.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 73be8991e3..3ec2d363de 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -2,6 +2,8 @@ #include "defs.hpp" +#include + #if openPMD_HAVE_MPI #include @@ -25,13 +27,19 @@ void define_julia_Series(jlcxx::Module &mod) { type.constructor<>(); #if openPMD_HAVE_MPI type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t comm, + sized_uint_t ucomm, const std::string &options) { - return Series(filepath, at, reinterpret_cast(comm), options); + MPI_Comm comm; + static_assert(sizeof ucomm == sizeof comm, ""); + memcpy(&comm, &ucomm, sizeof comm); + return Series(filepath, at, comm, options); }); type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t comm) { - return Series(filepath, at, reinterpret_cast(comm)); + sized_uint_t ucomm) { + MPI_Comm comm; + static_assert(sizeof ucomm == sizeof comm, ""); + memcpy(&comm, &ucomm, sizeof comm); + return Series(filepath, at, comm); }); #endif type.constructor(); @@ -81,7 +89,6 @@ void define_julia_Series(jlcxx::Module &mod) { type.method("cxx_backend", &Series::backend); type.method("cxx_flush", &Series::flush); - // TODO type.method("cxx_close", &Series::close); type.method("cxx_iterations", [](Series &series) -> Container & { return series.iterations; From 9edac3b316a4e7c8215ad4d529577c573879c054 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 24 Jan 2022 18:10:13 -0800 Subject: [PATCH 54/94] CI: Simply with cmake-easyinstall --- .github/workflows/linux.yml | 16 ++++++---------- .github/workflows/macos.yml | 18 ++++-------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index db840eeebb..8fd7339feb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -230,7 +230,7 @@ jobs: cmake --build build --parallel 2 ctest --test-dir build --output-on-failure - gcc9_py38_pd_nompi_h5_ad1_ad2_libcpp: + gcc9_py38_pd_nompi_h5_ad1_ad2_libcpp_julia: runs-on: ubuntu-20.04 if: github.event.pull_request.draft == false steps: @@ -244,16 +244,12 @@ jobs: wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.5-linux-x86_64.tar.gz sudo tar -xz -C /usr/local -f julia-1.6.5-linux-x86_64.tar.gz rm julia-1.6.5-linux-x86_64.tar.gz + # Install cmake-easyinstall + sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY + sudo chmod a+x /usr/local/bin/cmake-easyinstall + export CEI_SUDO="sudo" # Install libcxxwrap-julia - wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz - tar xzf v0.8.3.tar.gz - rm -rf v0.8.3.tar.gz - cd libcxxwrap-julia-0.8.3 - cmake -S . -B build -DJulia_EXECUTABLE=/usr/local/julia-1.6.5/bin/julia - cmake --build build --parallel 2 - sudo cmake --install build - cd .. - rm -rf libcxxwrap-julia-0.8.3 + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.0 -DJulia_EXECUTABLE=/usr/local/julia-1.6.5/bin/julia - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig} run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index af96856e93..2df5f27171 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -27,21 +27,11 @@ jobs: brew install julia || true brew install python || true set -e + # Install cmake-easyinstall + sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY + sudo chmod a+x /usr/local/bin/cmake-easyinstall # Install libcxxwrap-julia - # wget https://github.com/JuliaInterop/libcxxwrap-julia/archive/refs/tags/v0.8.3.tar.gz - # tar xzf v0.8.3.tar.gz - # rm -rf v0.8.3.tar.gz - # cd libcxxwrap-julia-0.8.3 - wget https://github.com/JuliaInterop/libcxxwrap-julia/tarball/37743e11cda7363a17840fe2353ff78a7e964a2c - tar xzf 37743e11cda7363a17840fe2353ff78a7e964a2c - rm -rf 37743e11cda7363a17840fe2353ff78a7e964a2c - cd JuliaInterop-libcxxwrap-julia-37743e1 - cmake -S . -B build - cmake --build build --parallel 2 - cmake --install build - cd .. - # rm -rf libcxxwrap-julia-0.8.3 - rm -rf JuliaInterop-libcxxwrap-julia-37743e1 + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.0 - name: Build env: {CXXFLAGS: -Werror -Wno-deprecated-declarations -DTOML11_DISABLE_STD_FILESYSTEM, MACOSX_DEPLOYMENT_TARGET: 10.13} # C++11 & 14 support in macOS 10.9+ From 3f1a23dc30b7b1e6d7964dff11ee952ab0ca9f52 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Mar 2022 16:38:51 +0000 Subject: [PATCH 55/94] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/binding/julia/Access.cpp | 13 +- src/binding/julia/Attributable.cpp | 31 +- src/binding/julia/Attribute.cpp | 13 +- src/binding/julia/BaseRecordComponent.cpp | 26 +- src/binding/julia/ChunkInfo.cpp | 38 +- src/binding/julia/Container.hpp | 120 +++-- src/binding/julia/Dataset.cpp | 21 +- src/binding/julia/Datatype.cpp | 55 +- src/binding/julia/Format.cpp | 25 +- src/binding/julia/Iteration.cpp | 44 +- src/binding/julia/Mesh.cpp | 120 +++-- src/binding/julia/MeshRecordComponent.cpp | 28 +- src/binding/julia/ReadIterations.cpp | 9 +- src/binding/julia/RecordComponent.cpp | 64 +-- .../julia/RecordComponent_load_chunk.cpp | 16 +- .../julia/RecordComponent_make_constant.cpp | 10 +- .../julia/RecordComponent_store_chunk.cpp | 16 +- src/binding/julia/Series.cpp | 167 +++--- src/binding/julia/UnitDimension.cpp | 21 +- src/binding/julia/WriteIterations.cpp | 19 +- src/binding/julia/defs.hpp | 501 +++++++++++------- src/binding/julia/openPMD.cpp | 62 +-- src/binding/julia/shared_ptr.cpp | 12 +- src/binding/julia/version.cpp | 15 +- src/binding/python/Series.cpp | 2 +- 25 files changed, 825 insertions(+), 623 deletions(-) diff --git a/src/binding/julia/Access.cpp b/src/binding/julia/Access.cpp index efd12c183b..9c76401cab 100644 --- a/src/binding/julia/Access.cpp +++ b/src/binding/julia/Access.cpp @@ -2,11 +2,12 @@ #include "defs.hpp" -void define_julia_Access(jlcxx::Module &mod) { - mod.add_bits("Access", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); +void define_julia_Access(jlcxx::Module &mod) +{ + mod.add_bits("Access", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); - mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY); - mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE); - mod.set_const("ACCESS_CREATE", Access::CREATE); + mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY); + mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE); + mod.set_const("ACCESS_CREATE", Access::CREATE); } diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index b976396c54..76c11dc17f 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -2,21 +2,26 @@ #include "defs.hpp" -void define_julia_Attributable(jlcxx::Module &mod) { - auto type = mod.add_type("CXX_Attributable"); +void define_julia_Attributable(jlcxx::Module &mod) +{ + auto type = mod.add_type("CXX_Attributable"); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_set_attribute_" NAME "!", &Attributable::setAttribute); - { FORALL_OPENPMD_TYPES(USE_TYPE) } + type.method( \ + "cxx_set_attribute_" NAME "!", &Attributable::setAttribute); + { + FORALL_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE - type.method("cxx_get_attribute", &Attributable::getAttribute); - type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); - type.method("cxx_attributes", &Attributable::attributes); - type.method("cxx_num_attributes", &Attributable::numAttributes); - type.method("cxx_contains_attribute", &Attributable::containsAttribute); - type.method("cxx_comment", &Attributable::comment); - type.method("cxx_set_comment!", &Attributable::setComment); - type.method("cxx_series_flush", static_cast( - &Attributable::seriesFlush)); + type.method("cxx_get_attribute", &Attributable::getAttribute); + type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); + type.method("cxx_attributes", &Attributable::attributes); + type.method("cxx_num_attributes", &Attributable::numAttributes); + type.method("cxx_contains_attribute", &Attributable::containsAttribute); + type.method("cxx_comment", &Attributable::comment); + type.method("cxx_set_comment!", &Attributable::setComment); + type.method( + "cxx_series_flush", + static_cast(&Attributable::seriesFlush)); } diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index 9b1d6f631d..6d55e4ae49 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -2,13 +2,16 @@ #include "defs.hpp" -void define_julia_Attribute(jlcxx::Module &mod) { - auto type = mod.add_type("CXX_Attribute"); +void define_julia_Attribute(jlcxx::Module &mod) +{ + auto type = mod.add_type("CXX_Attribute"); - type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); + type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_get_" NAME, &Attribute::get); - { FORALL_OPENPMD_TYPES(USE_TYPE) } + type.method("cxx_get_" NAME, &Attribute::get); + { + FORALL_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index 93cb99ad10..05c7a41b09 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -3,19 +3,23 @@ #include "defs.hpp" // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { - typedef Attributable type; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef Attributable type; }; } // namespace jlcxx -void define_julia_BaseRecordComponent(jlcxx::Module &mod) { - auto type = mod.add_type( - "CXX_BaseRecordComponent", jlcxx::julia_base_type()); +void define_julia_BaseRecordComponent(jlcxx::Module &mod) +{ + auto type = mod.add_type( + "CXX_BaseRecordComponent", jlcxx::julia_base_type()); - type.method("cxx_unit_SI", &BaseRecordComponent::unitSI); - type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); - type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); - type.method("cxx_isconstant", &BaseRecordComponent::constant); - type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks); + type.method("cxx_unit_SI", &BaseRecordComponent::unitSI); + type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype); + type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype); + type.method("cxx_isconstant", &BaseRecordComponent::constant); + type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks); } diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp index 33bd4f89fc..86fe6f13f9 100644 --- a/src/binding/julia/ChunkInfo.cpp +++ b/src/binding/julia/ChunkInfo.cpp @@ -3,23 +3,29 @@ #include "defs.hpp" // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { typedef ChunkInfo type; }; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef ChunkInfo type; +}; } // namespace jlcxx -void define_julia_ChunkInfo(jlcxx::Module &mod) { - auto chunkInfo = mod.add_type("CXX_ChunkInfo"); - chunkInfo.constructor<>(); - chunkInfo.constructor(); - chunkInfo.method("cxx_offset", [](const ChunkInfo &chunkInfo_) { - return chunkInfo_.offset; - }); - chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo_) { - return chunkInfo_.extent; - }); +void define_julia_ChunkInfo(jlcxx::Module &mod) +{ + auto chunkInfo = mod.add_type("CXX_ChunkInfo"); + chunkInfo.constructor<>(); + chunkInfo.constructor(); + chunkInfo.method("cxx_offset", [](const ChunkInfo &chunkInfo_) { + return chunkInfo_.offset; + }); + chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo_) { + return chunkInfo_.extent; + }); - auto writtenChunkInfo = mod.add_type( - "CXX_WrittenChunkInfo", jlcxx::julia_base_type()); - writtenChunkInfo.constructor<>(); - writtenChunkInfo.constructor(); + auto writtenChunkInfo = mod.add_type( + "CXX_WrittenChunkInfo", jlcxx::julia_base_type()); + writtenChunkInfo.constructor<>(); + writtenChunkInfo.constructor(); } diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index 1330a151de..0db492542d 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -9,9 +9,12 @@ #include // Define supertype relationships -namespace jlcxx { -template struct SuperType> { - typedef Attributable type; +namespace jlcxx +{ +template +struct SuperType> +{ + typedef Attributable type; }; } // namespace jlcxx @@ -22,62 +25,69 @@ typedef jlcxx::TypeWrapper< extern std::unique_ptr julia_Container_type; template -void define_julia_Container(jlcxx::Module &mod) { - if (!julia_Container_type) - julia_Container_type = std::make_unique( - mod.add_type, jlcxx::TypeVar<2>>>( - "CXX_Container", jlcxx::julia_base_type())); +void define_julia_Container(jlcxx::Module &mod) +{ + if (!julia_Container_type) + julia_Container_type = std::make_unique( + mod.add_type< + jlcxx::Parametric, jlcxx::TypeVar<2>>>( + "CXX_Container", jlcxx::julia_base_type())); - julia_Container_type->apply>([](auto type) { - using ContainerT = typename decltype(type)::type; - using key_type = typename ContainerT::key_type; - using mapped_type = typename ContainerT::mapped_type; - using size_type = typename ContainerT::size_type; - static_assert(std::is_same_v); - static_assert(std::is_same_v); + julia_Container_type->apply>([](auto type) { + using ContainerT = typename decltype(type)::type; + using key_type = typename ContainerT::key_type; + using mapped_type = typename ContainerT::mapped_type; + using size_type = typename ContainerT::size_type; + static_assert(std::is_same_v); + static_assert(std::is_same_v); - type.template constructor(); + type.template constructor(); - type.method("cxx_empty", &ContainerT::empty); - type.method("cxx_length", &ContainerT::size); - type.method("cxx_empty!", &ContainerT::clear); - // type.method("cxx_getindex", - // static_cast( - // &ContainerT::at)); - type.method("cxx_getindex", - [](ContainerT &cont, const key_type &key) -> mapped_type & { - return cont[key]; - }); - type.method("cxx_setindex!", - [](ContainerT &cont, const mapped_type &value, - const key_type &key) { return cont[key] = value; }); - type.method("cxx_count", &ContainerT::count); - type.method("cxx_contains", &ContainerT::contains); - type.method("cxx_delete!", - static_cast( - &ContainerT::erase)); - type.method("cxx_keys", [](const ContainerT &cont) { - std::vector res; - res.reserve(cont.size()); - for (auto iter = cont.begin(); iter != cont.end(); ++iter) - res.push_back(iter->first); - return res; + type.method("cxx_empty", &ContainerT::empty); + type.method("cxx_length", &ContainerT::size); + type.method("cxx_empty!", &ContainerT::clear); + // type.method("cxx_getindex", + // static_cast( + // &ContainerT::at)); + type.method( + "cxx_getindex", + [](ContainerT &cont, const key_type &key) -> mapped_type & { + return cont[key]; + }); + type.method( + "cxx_setindex!", + [](ContainerT &cont, + const mapped_type &value, + const key_type &key) { return cont[key] = value; }); + type.method("cxx_count", &ContainerT::count); + type.method("cxx_contains", &ContainerT::contains); + type.method( + "cxx_delete!", + static_cast( + &ContainerT::erase)); + type.method("cxx_keys", [](const ContainerT &cont) { + std::vector res; + res.reserve(cont.size()); + for (auto iter = cont.begin(); iter != cont.end(); ++iter) + res.push_back(iter->first); + return res; + }); + // type.method("cxx_values", [](const ContainerT &cont) { + // std::vector res; + // res.reserve(cont.size()); + // for (auto iter = cont.begin(); iter != cont.end(); ++iter) + // res.push_back(&iter->second); + // return res; + // }); + // type.method("cxx_collect", [](const ContainerT &cont) { + // std::vector> res; + // res.reserve(cont.size()); + // for (auto iter = cont.begin(); iter != cont.end(); ++iter) + // res.emplace_back(iter->first, &iter->second); + // return res; + // }); }); - // type.method("cxx_values", [](const ContainerT &cont) { - // std::vector res; - // res.reserve(cont.size()); - // for (auto iter = cont.begin(); iter != cont.end(); ++iter) - // res.push_back(&iter->second); - // return res; - // }); - // type.method("cxx_collect", [](const ContainerT &cont) { - // std::vector> res; - // res.reserve(cont.size()); - // for (auto iter = cont.begin(); iter != cont.end(); ++iter) - // res.emplace_back(iter->first, &iter->second); - // return res; - // }); - }); } #endif // #ifndef CONTAINER_HPP diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index 019cfc6143..8ac8da2854 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -2,16 +2,17 @@ #include "defs.hpp" -void define_julia_Dataset(jlcxx::Module &mod) { - auto type = mod.add_type("Dataset"); +void define_julia_Dataset(jlcxx::Module &mod) +{ + auto type = mod.add_type("Dataset"); - type.constructor(); - type.constructor(); - type.constructor(); + type.constructor(); + type.constructor(); + type.constructor(); - type.method("cxx_extend!", &Dataset::extend); - type.method("cxx_extent", [](const Dataset &d) { return d.extent; }); - type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; }); - type.method("cxx_rank", [](const Dataset &d) { return d.rank; }); - type.method("options", [](const Dataset &d) { return d.options; }); + type.method("cxx_extend!", &Dataset::extend); + type.method("cxx_extent", [](const Dataset &d) { return d.extent; }); + type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; }); + type.method("cxx_rank", [](const Dataset &d) { return d.rank; }); + type.method("options", [](const Dataset &d) { return d.options; }); } diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index f9585a31a5..55001f39db 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -2,33 +2,38 @@ #include "defs.hpp" -void define_julia_Datatype(jlcxx::Module &mod) { - mod.add_bits("Datatype", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); +void define_julia_Datatype(jlcxx::Module &mod) +{ + mod.add_bits("Datatype", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); #define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); - { FORALL_OPENPMD_TYPES(USE_TYPE) } + { + FORALL_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE - mod.set_const("UNDEFINED", Datatype::UNDEFINED); + mod.set_const("UNDEFINED", Datatype::UNDEFINED); - mod.set_const("openPMD_datatypes", openPMD_Datatypes); - // mod.method("determine_datatype", determineDatatype); - mod.method("cxx_to_bytes", toBytes); - mod.method("cxx_to_bits", toBits); - mod.method("cxx_is_vector", isVector); - mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint); - mod.method("cxx_is_complex_floating_point", - static_cast(isComplexFloatingPoint)); - mod.method("cxx_is_integer", (std::tuple(*)(Datatype))isInteger); - // isSameFloatingPoint - // isSameComplexFloatingPoint - // isSameInteger - mod.method("cxx_is_same", isSame); - mod.method("cxx_basic_datatype", basicDatatype); - mod.method("cxx_to_vector_type", toVectorType); - mod.method("cxx_datatype_to_string", datatypeToString); - mod.method("cxx_string_to_datatype", stringToDatatype); - mod.method("cxx_warn_wrong_datatype", warnWrongDtype); - // mod.method("==", operator==); - // mod.method("!=", operator!=); + mod.set_const("openPMD_datatypes", openPMD_Datatypes); + // mod.method("determine_datatype", determineDatatype); + mod.method("cxx_to_bytes", toBytes); + mod.method("cxx_to_bits", toBits); + mod.method("cxx_is_vector", isVector); + mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint); + mod.method( + "cxx_is_complex_floating_point", + static_cast(isComplexFloatingPoint)); + mod.method( + "cxx_is_integer", (std::tuple(*)(Datatype))isInteger); + // isSameFloatingPoint + // isSameComplexFloatingPoint + // isSameInteger + mod.method("cxx_is_same", isSame); + mod.method("cxx_basic_datatype", basicDatatype); + mod.method("cxx_to_vector_type", toVectorType); + mod.method("cxx_datatype_to_string", datatypeToString); + mod.method("cxx_string_to_datatype", stringToDatatype); + mod.method("cxx_warn_wrong_datatype", warnWrongDtype); + // mod.method("==", operator==); + // mod.method("!=", operator!=); } diff --git a/src/binding/julia/Format.cpp b/src/binding/julia/Format.cpp index 5c974e5683..7052a957f4 100644 --- a/src/binding/julia/Format.cpp +++ b/src/binding/julia/Format.cpp @@ -2,17 +2,18 @@ #include "defs.hpp" -void define_julia_Format(jlcxx::Module &mod) { - mod.add_bits("Format", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); +void define_julia_Format(jlcxx::Module &mod) +{ + mod.add_bits("Format", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); - mod.set_const("FORMAT_HDF5", Format::HDF5); - mod.set_const("FORMAT_ADIOS1", Format::ADIOS1); - mod.set_const("FORMAT_ADIOS2", Format::ADIOS2); - mod.set_const("FORMAT_ADIOS2_SST", Format::ADIOS2_SST); - mod.set_const("FORMAT_ADIOS2_SSC", Format::ADIOS2_SSC); - mod.set_const("FORMAT_JSON", Format::JSON); - mod.set_const("FORMAT_DUMMY", Format::DUMMY); - mod.method("determine_format", determineFormat); - mod.method("suffix", suffix); + mod.set_const("FORMAT_HDF5", Format::HDF5); + mod.set_const("FORMAT_ADIOS1", Format::ADIOS1); + mod.set_const("FORMAT_ADIOS2", Format::ADIOS2); + mod.set_const("FORMAT_ADIOS2_SST", Format::ADIOS2_SST); + mod.set_const("FORMAT_ADIOS2_SSC", Format::ADIOS2_SSC); + mod.set_const("FORMAT_JSON", Format::JSON); + mod.set_const("FORMAT_DUMMY", Format::DUMMY); + mod.method("determine_format", determineFormat); + mod.method("suffix", suffix); } diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index 654c850654..b39b878690 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -5,25 +5,33 @@ #include // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { typedef Attributable type; }; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef Attributable type; +}; } // namespace jlcxx -void define_julia_Iteration(jlcxx::Module &mod) { - auto type = mod.add_type("CXX_Iteration", - jlcxx::julia_base_type()); +void define_julia_Iteration(jlcxx::Module &mod) +{ + auto type = mod.add_type( + "CXX_Iteration", jlcxx::julia_base_type()); - type.method("cxx_time", &Iteration::time); - type.method("cxx_set_time!", &Iteration::setTime); - type.method("cxx_dt", &Iteration::dt); - type.method("cxx_set_dt!", &Iteration::setDt); - type.method("cxx_time_unit_SI", &Iteration::timeUnitSI); - type.method("cxx_set_time_unit_SI!", &Iteration::setTimeUnitSI); - type.method("cxx_close", - static_cast(&Iteration::close)); - type.method("cxx_open", &Iteration::open); - type.method("cxx_closed", &Iteration::closed); - type.method("cxx_meshes", - [](Iteration &iter) -> Container & { return iter.meshes; }); - // TODO: particles + type.method("cxx_time", &Iteration::time); + type.method("cxx_set_time!", &Iteration::setTime); + type.method("cxx_dt", &Iteration::dt); + type.method("cxx_set_dt!", &Iteration::setDt); + type.method("cxx_time_unit_SI", &Iteration::timeUnitSI); + type.method("cxx_set_time_unit_SI!", &Iteration::setTimeUnitSI); + type.method( + "cxx_close", + static_cast(&Iteration::close)); + type.method("cxx_open", &Iteration::open); + type.method("cxx_closed", &Iteration::closed); + type.method("cxx_meshes", [](Iteration &iter) -> Container & { + return iter.meshes; + }); + // TODO: particles } diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index d1c5f0dbbf..3ed65ef378 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -3,73 +3,77 @@ #include "defs.hpp" // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { - typedef Container type; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef Container type; }; } // namespace jlcxx -void define_julia_Mesh(jlcxx::Module &mod) { +void define_julia_Mesh(jlcxx::Module &mod) +{ - // Mesh::Geometry - mod.add_bits("Geometry", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); + // Mesh::Geometry + mod.add_bits("Geometry", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); - mod.set_const("GEOMETRY_cartesian", Mesh::Geometry::cartesian); - mod.set_const("GEOMETRY_theta_mode", Mesh::Geometry::thetaMode); - mod.set_const("GEOMETRY_cylindrical", Mesh::Geometry::cylindrical); - mod.set_const("GEOMETRY_spherical", Mesh::Geometry::spherical); - mod.set_const("GEOMETRY_other", Mesh::Geometry::other); + mod.set_const("GEOMETRY_cartesian", Mesh::Geometry::cartesian); + mod.set_const("GEOMETRY_theta_mode", Mesh::Geometry::thetaMode); + mod.set_const("GEOMETRY_cylindrical", Mesh::Geometry::cylindrical); + mod.set_const("GEOMETRY_spherical", Mesh::Geometry::spherical); + mod.set_const("GEOMETRY_other", Mesh::Geometry::other); - // Mesh::DataOrder - mod.add_bits("DataOrder", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); + // Mesh::DataOrder + mod.add_bits("DataOrder", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); - mod.set_const("DATAORDER_C", Mesh::DataOrder::C); - mod.set_const("DATAORDER_F", Mesh::DataOrder::F); + mod.set_const("DATAORDER_C", Mesh::DataOrder::C); + mod.set_const("DATAORDER_F", Mesh::DataOrder::F); - // Mesh - auto type = mod.add_type( - "CXX_Mesh", - // We don't wrap BaseRecord for simplicity. We thus need to declare - // Container as our supertype. - jlcxx::julia_base_type>()); + // Mesh + auto type = mod.add_type( + "CXX_Mesh", + // We don't wrap BaseRecord for simplicity. We thus need to declare + // Container as our supertype. + jlcxx::julia_base_type>()); - // These two functions come from our superclass - // BaseRecord. We declare them as if they were our own. - type.method("cxx_unit_dimension", &Mesh::unitDimension); - type.method("cxx_isscalar", &Mesh::scalar); + // These two functions come from our superclass + // BaseRecord. We declare them as if they were our own. + type.method("cxx_unit_dimension", &Mesh::unitDimension); + type.method("cxx_isscalar", &Mesh::scalar); - type.method("cxx_geometry", &Mesh::geometry); - type.method( - "cxx_set_geometry!", - static_cast(&Mesh::setGeometry)); - type.method("cxx_geometry_parameters", &Mesh::geometryParameters); - type.method("cxx_set_geometry_parameters!", &Mesh::setGeometryParameters); - type.method("cxx_data_order", &Mesh::dataOrder); - type.method("cxx_set_data_order!", &Mesh::setDataOrder); - type.method("cxx_axis_labels", &Mesh::axisLabels); - type.method("cxx_set_axis_labels!", &Mesh::setAxisLabels); - type.method("cxx_grid_spacing", &Mesh::gridSpacing); - type.method("cxx_set_grid_spacing!", &Mesh::setGridSpacing); - type.method("cxx_grid_global_offset", &Mesh::gridGlobalOffset); - type.method("cxx_set_grid_global_offset!", &Mesh::setGridGlobalOffset); - type.method("cxx_grid_unit_SI", &Mesh::gridUnitSI); - type.method("cxx_set_grid_unit_SI!", &Mesh::setGridUnitSI); - type.method( - "cxx_set_unit_dimension!", - [](Mesh &mesh, const array_double_7 &unitDimension) { - return mesh.setUnitDimension(std::map{ - {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, - {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, - {UnitDimension::T, unitDimension[uint8_t(UnitDimension::T)]}, - {UnitDimension::I, unitDimension[uint8_t(UnitDimension::I)]}, - {UnitDimension::theta, - unitDimension[uint8_t(UnitDimension::theta)]}, - {UnitDimension::N, unitDimension[uint8_t(UnitDimension::N)]}, - {UnitDimension::J, unitDimension[uint8_t(UnitDimension::J)]}, + type.method("cxx_geometry", &Mesh::geometry); + type.method( + "cxx_set_geometry!", + static_cast(&Mesh::setGeometry)); + type.method("cxx_geometry_parameters", &Mesh::geometryParameters); + type.method("cxx_set_geometry_parameters!", &Mesh::setGeometryParameters); + type.method("cxx_data_order", &Mesh::dataOrder); + type.method("cxx_set_data_order!", &Mesh::setDataOrder); + type.method("cxx_axis_labels", &Mesh::axisLabels); + type.method("cxx_set_axis_labels!", &Mesh::setAxisLabels); + type.method("cxx_grid_spacing", &Mesh::gridSpacing); + type.method("cxx_set_grid_spacing!", &Mesh::setGridSpacing); + type.method("cxx_grid_global_offset", &Mesh::gridGlobalOffset); + type.method("cxx_set_grid_global_offset!", &Mesh::setGridGlobalOffset); + type.method("cxx_grid_unit_SI", &Mesh::gridUnitSI); + type.method("cxx_set_grid_unit_SI!", &Mesh::setGridUnitSI); + type.method( + "cxx_set_unit_dimension!", + [](Mesh &mesh, const array_double_7 &unitDimension) { + return mesh.setUnitDimension(std::map{ + {UnitDimension::L, unitDimension[uint8_t(UnitDimension::L)]}, + {UnitDimension::M, unitDimension[uint8_t(UnitDimension::M)]}, + {UnitDimension::T, unitDimension[uint8_t(UnitDimension::T)]}, + {UnitDimension::I, unitDimension[uint8_t(UnitDimension::I)]}, + {UnitDimension::theta, + unitDimension[uint8_t(UnitDimension::theta)]}, + {UnitDimension::N, unitDimension[uint8_t(UnitDimension::N)]}, + {UnitDimension::J, unitDimension[uint8_t(UnitDimension::J)]}, + }); }); - }); - type.method("cxx_time_offset", &Mesh::timeOffset); - type.method("cxx_set_time_offset!", &Mesh::setTimeOffset); + type.method("cxx_time_offset", &Mesh::timeOffset); + type.method("cxx_set_time_offset!", &Mesh::setTimeOffset); } diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 62dc86186f..67e253e07e 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -3,21 +3,27 @@ #include "defs.hpp" // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { - typedef RecordComponent type; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef RecordComponent type; }; } // namespace jlcxx -void define_julia_MeshRecordComponent(jlcxx::Module &mod) { - auto type = mod.add_type( - "CXX_MeshRecordComponent", jlcxx::julia_base_type()); +void define_julia_MeshRecordComponent(jlcxx::Module &mod) +{ + auto type = mod.add_type( + "CXX_MeshRecordComponent", jlcxx::julia_base_type()); - type.method("cxx_position", &MeshRecordComponent::position); - type.method("cxx_set_position!", &MeshRecordComponent::setPosition); + type.method("cxx_position", &MeshRecordComponent::position); + type.method("cxx_set_position!", &MeshRecordComponent::setPosition); #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_make_constant_" NAME, \ - &MeshRecordComponent::makeConstant); - { FORALL_OPENPMD_TYPES(USE_TYPE) } + type.method( \ + "cxx_make_constant_" NAME, &MeshRecordComponent::makeConstant); + { + FORALL_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/ReadIterations.cpp b/src/binding/julia/ReadIterations.cpp index cdd53b805c..3bab96bedb 100644 --- a/src/binding/julia/ReadIterations.cpp +++ b/src/binding/julia/ReadIterations.cpp @@ -4,8 +4,9 @@ #include -void define_julia_ReadIterations(jlcxx::Module & /*mod*/) { - // TODO auto type = mod.add_type("ReadIterations"); - // TODO: SeriesIterator - // TODO: begin, end +void define_julia_ReadIterations(jlcxx::Module & /*mod*/) +{ + // TODO auto type = mod.add_type("ReadIterations"); + // TODO: SeriesIterator + // TODO: begin, end } diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index b3be78ca99..acd3ec1a10 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -8,37 +8,41 @@ #include // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { - typedef BaseRecordComponent type; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef BaseRecordComponent type; }; } // namespace jlcxx -void define_julia_RecordComponent(jlcxx::Module &mod) { - - // RecordComponent::Allocation - mod.add_bits("Allocation", - jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); - - mod.set_const("ALLOCATION_USER", RecordComponent::Allocation::USER); - mod.set_const("ALLOCATION_API", RecordComponent::Allocation::API); - mod.set_const("ALLOCATION_AUTO", RecordComponent::Allocation::AUTO); - - auto type = mod.add_type( - "CXX_RecordComponent", jlcxx::julia_base_type()); - - type.method("cxx_set_unit_SI!", &RecordComponent::setUnitSI); - type.method("cxx_reset_dataset!", &RecordComponent::resetDataset); - type.method("cxx_get_dimensionality", &RecordComponent::getDimensionality); - type.method("cxx_get_extent", &RecordComponent::getExtent); - define_julia_RecordComponent_make_constant(mod, type); - type.method( - "cxx_make_empty", - static_cast( - &RecordComponent::makeEmpty)); - type.method("cxx_isempty", &RecordComponent::empty); - define_julia_RecordComponent_load_chunk(mod, type); - define_julia_RecordComponent_store_chunk(mod, type); - type.method("cxx_SCALAR", []() { return RecordComponent::SCALAR; }); +void define_julia_RecordComponent(jlcxx::Module &mod) +{ + + // RecordComponent::Allocation + mod.add_bits( + "Allocation", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); + + mod.set_const("ALLOCATION_USER", RecordComponent::Allocation::USER); + mod.set_const("ALLOCATION_API", RecordComponent::Allocation::API); + mod.set_const("ALLOCATION_AUTO", RecordComponent::Allocation::AUTO); + + auto type = mod.add_type( + "CXX_RecordComponent", jlcxx::julia_base_type()); + + type.method("cxx_set_unit_SI!", &RecordComponent::setUnitSI); + type.method("cxx_reset_dataset!", &RecordComponent::resetDataset); + type.method("cxx_get_dimensionality", &RecordComponent::getDimensionality); + type.method("cxx_get_extent", &RecordComponent::getExtent); + define_julia_RecordComponent_make_constant(mod, type); + type.method( + "cxx_make_empty", + static_cast( + &RecordComponent::makeEmpty)); + type.method("cxx_isempty", &RecordComponent::empty); + define_julia_RecordComponent_load_chunk(mod, type); + define_julia_RecordComponent_store_chunk(mod, type); + type.method("cxx_SCALAR", []() { return RecordComponent::SCALAR; }); } diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index c726597688..f1f0900071 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -3,12 +3,16 @@ #include "defs.hpp" void define_julia_RecordComponent_load_chunk( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_load_chunk_" NAME, \ - static_cast, \ - Offset, Extent)>( \ - &RecordComponent::loadChunk)); - { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } + type.method( \ + "cxx_load_chunk_" NAME, \ + static_cast, Offset, Extent)>( \ + &RecordComponent::loadChunk)); + { + FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index a8cec440fb..41e9a81670 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -3,9 +3,13 @@ #include "defs.hpp" void define_julia_RecordComponent_make_constant( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_make_constant_" NAME, &RecordComponent::makeConstant); - { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } + type.method( \ + "cxx_make_constant_" NAME, &RecordComponent::makeConstant); + { + FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 64ba48a7f1..761b139c2b 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -3,12 +3,16 @@ #include "defs.hpp" void define_julia_RecordComponent_store_chunk( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ #define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_store_chunk_" NAME, \ - static_cast, \ - Offset, Extent)>( \ - &RecordComponent::storeChunk)); - { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } + type.method( \ + "cxx_store_chunk_" NAME, \ + static_cast, Offset, Extent)>( \ + &RecordComponent::storeChunk)); + { + FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 3ec2d363de..4a112db055 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -7,92 +7,111 @@ #if openPMD_HAVE_MPI #include -namespace jlcxx { -template <> struct IsMirroredType : std::false_type {}; +namespace jlcxx +{ +template <> +struct IsMirroredType : std::false_type +{}; } // namespace jlcxx #endif // Define supertype relationships -namespace jlcxx { -template <> struct SuperType { typedef Attributable type; }; +namespace jlcxx +{ +template <> +struct SuperType +{ + typedef Attributable type; +}; } // namespace jlcxx -void define_julia_Series(jlcxx::Module &mod) { +void define_julia_Series(jlcxx::Module &mod) +{ - // Series + // Series - auto type = mod.add_type("CXX_Series", - jlcxx::julia_base_type()); + auto type = mod.add_type( + "CXX_Series", jlcxx::julia_base_type()); - type.constructor<>(); + type.constructor<>(); #if openPMD_HAVE_MPI - type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t ucomm, - const std::string &options) { - MPI_Comm comm; - static_assert(sizeof ucomm == sizeof comm, ""); - memcpy(&comm, &ucomm, sizeof comm); - return Series(filepath, at, comm, options); - }); - type.method("cxx_Series", [](const std::string &filepath, Access at, - sized_uint_t ucomm) { - MPI_Comm comm; - static_assert(sizeof ucomm == sizeof comm, ""); - memcpy(&comm, &ucomm, sizeof comm); - return Series(filepath, at, comm); - }); + type.method( + "cxx_Series", + [](const std::string &filepath, + Access at, + sized_uint_t ucomm, + const std::string &options) { + MPI_Comm comm; + static_assert(sizeof ucomm == sizeof comm, ""); + memcpy(&comm, &ucomm, sizeof comm); + return Series(filepath, at, comm, options); + }); + type.method( + "cxx_Series", + [](const std::string &filepath, + Access at, + sized_uint_t ucomm) { + MPI_Comm comm; + static_assert(sizeof ucomm == sizeof comm, ""); + memcpy(&comm, &ucomm, sizeof comm); + return Series(filepath, at, comm); + }); #endif - type.constructor(); - type.constructor(); + type.constructor(); + type.constructor(); - type.method("cxx_isvalid", [](const Series &series) { return bool(series); }); + type.method( + "cxx_isvalid", [](const Series &series) { return bool(series); }); - type.method("cxx_openPMD_version", &Series::openPMD); - type.method("cxx_set_openPMD_version!", &Series::setOpenPMD); - type.method("cxx_openPMD_extension", &Series::openPMDextension); - type.method("cxx_set_openPMD_extension!", &Series::setOpenPMDextension); - type.method("cxx_base_path", &Series::basePath); - type.method("cxx_set_base_path!", &Series::setBasePath); - type.method("cxx_meshes_path", &Series::meshesPath); - type.method("cxx_set_meshes_path!", &Series::setMeshesPath); - type.method("cxx_particles_path", &Series::particlesPath); - type.method("cxx_set_particles_path!", &Series::setParticlesPath); - type.method("cxx_author", &Series::author); - type.method("cxx_set_author!", &Series::setAuthor); - type.method("cxx_software", &Series::software); - type.method("cxx_set_software!", - static_cast( - &Series::setSoftware)); - type.method("cxx_set_software!", - [](Series &series, const std::string &newName) -> Series & { - return series.setSoftware(newName); - }); - type.method("cxx_software_version", &Series::softwareVersion); - // type.method("set_software_version!", - // &Series::setSoftwareVersion); - type.method("cxx_date", &Series::date); - type.method("cxx_set_date!", &Series::setDate); - type.method("cxx_software_dependencies", &Series::softwareDependencies); - type.method("cxx_set_software_dependencies!", - &Series::setSoftwareDependencies); - type.method("cxx_machine", &Series::machine); - type.method("cxx_set_machine!", &Series::setMachine); - // TODO: type.method("iteration_encoding", - // &Series::iterationEncoding); - // TODO: type.method("set_iteration_encoding!", - // &Series::setIterationEncoding); - type.method("cxx_iteration_format", &Series::iterationFormat); - type.method("cxx_set_iteration_format!", &Series::setIterationFormat); - type.method("cxx_name", &Series::name); - type.method("cxx_set_name!", &Series::setName); - type.method("cxx_backend", &Series::backend); - type.method("cxx_flush", &Series::flush); + type.method("cxx_openPMD_version", &Series::openPMD); + type.method("cxx_set_openPMD_version!", &Series::setOpenPMD); + type.method("cxx_openPMD_extension", &Series::openPMDextension); + type.method("cxx_set_openPMD_extension!", &Series::setOpenPMDextension); + type.method("cxx_base_path", &Series::basePath); + type.method("cxx_set_base_path!", &Series::setBasePath); + type.method("cxx_meshes_path", &Series::meshesPath); + type.method("cxx_set_meshes_path!", &Series::setMeshesPath); + type.method("cxx_particles_path", &Series::particlesPath); + type.method("cxx_set_particles_path!", &Series::setParticlesPath); + type.method("cxx_author", &Series::author); + type.method("cxx_set_author!", &Series::setAuthor); + type.method("cxx_software", &Series::software); + type.method( + "cxx_set_software!", + static_cast( + &Series::setSoftware)); + type.method( + "cxx_set_software!", + [](Series &series, const std::string &newName) -> Series & { + return series.setSoftware(newName); + }); + type.method("cxx_software_version", &Series::softwareVersion); + // type.method("set_software_version!", + // &Series::setSoftwareVersion); + type.method("cxx_date", &Series::date); + type.method("cxx_set_date!", &Series::setDate); + type.method("cxx_software_dependencies", &Series::softwareDependencies); + type.method( + "cxx_set_software_dependencies!", &Series::setSoftwareDependencies); + type.method("cxx_machine", &Series::machine); + type.method("cxx_set_machine!", &Series::setMachine); + // TODO: type.method("iteration_encoding", + // &Series::iterationEncoding); + // TODO: type.method("set_iteration_encoding!", + // &Series::setIterationEncoding); + type.method("cxx_iteration_format", &Series::iterationFormat); + type.method("cxx_set_iteration_format!", &Series::setIterationFormat); + type.method("cxx_name", &Series::name); + type.method("cxx_set_name!", &Series::setName); + type.method("cxx_backend", &Series::backend); + type.method("cxx_flush", &Series::flush); - type.method("cxx_iterations", - [](Series &series) -> Container & { - return series.iterations; - }); - // TODO type.method("read_iterations", &Series::readIterations); - type.method("cxx_write_iterations", &Series::writeIterations); + type.method( + "cxx_iterations", + [](Series &series) -> Container & { + return series.iterations; + }); + // TODO type.method("read_iterations", &Series::readIterations); + type.method("cxx_write_iterations", &Series::writeIterations); } diff --git a/src/binding/julia/UnitDimension.cpp b/src/binding/julia/UnitDimension.cpp index a2725fc45d..eaea8b4db2 100644 --- a/src/binding/julia/UnitDimension.cpp +++ b/src/binding/julia/UnitDimension.cpp @@ -2,15 +2,16 @@ #include "defs.hpp" -void define_julia_UnitDimension(jlcxx::Module &mod) { - mod.add_bits("UnitDimension", jlcxx::julia_type("CppEnum")); - jlcxx::stl::apply_stl(mod); +void define_julia_UnitDimension(jlcxx::Module &mod) +{ + mod.add_bits("UnitDimension", jlcxx::julia_type("CppEnum")); + jlcxx::stl::apply_stl(mod); - mod.set_const("UNITDIMENSION_L", UnitDimension::L); - mod.set_const("UNITDIMENSION_M", UnitDimension::M); - mod.set_const("UNITDIMENSION_T", UnitDimension::T); - mod.set_const("UNITDIMENSION_I", UnitDimension::I); - mod.set_const("UNITDIMENSION_θ", UnitDimension::theta); - mod.set_const("UNITDIMENSION_N", UnitDimension::N); - mod.set_const("UNITDIMENSION_J", UnitDimension::J); + mod.set_const("UNITDIMENSION_L", UnitDimension::L); + mod.set_const("UNITDIMENSION_M", UnitDimension::M); + mod.set_const("UNITDIMENSION_T", UnitDimension::T); + mod.set_const("UNITDIMENSION_I", UnitDimension::I); + mod.set_const("UNITDIMENSION_θ", UnitDimension::theta); + mod.set_const("UNITDIMENSION_N", UnitDimension::N); + mod.set_const("UNITDIMENSION_J", UnitDimension::J); } diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp index 2805d1065c..dd4a039ed8 100644 --- a/src/binding/julia/WriteIterations.cpp +++ b/src/binding/julia/WriteIterations.cpp @@ -4,14 +4,15 @@ #include -void define_julia_WriteIterations(jlcxx::Module &mod) { - using iterations_t = Container; - using key_type = typename iterations_t::key_type; - // using mapped_type = typename iterations_t::mapped_type; +void define_julia_WriteIterations(jlcxx::Module &mod) +{ + using iterations_t = Container; + using key_type = typename iterations_t::key_type; + // using mapped_type = typename iterations_t::mapped_type; - auto type = mod.add_type("WriteIterations"); - type.method("getindex1!", - [](WriteIterations &w, const key_type &k) -> Iteration & { - return w[k]; - }); + auto type = mod.add_type("WriteIterations"); + type.method( + "getindex1!", [](WriteIterations &w, const key_type &k) -> Iteration & { + return w[k]; + }); } diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index a5530c347d..5be29cc08a 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -24,12 +24,30 @@ using namespace openPMD; -template struct sized_uint; -template <> struct sized_uint<1> { using type = std::uint8_t; }; -template <> struct sized_uint<2> { using type = std::uint16_t; }; -template <> struct sized_uint<4> { using type = std::uint32_t; }; -template <> struct sized_uint<8> { using type = std::uint64_t; }; -template using sized_uint_t = typename sized_uint::type; +template +struct sized_uint; +template <> +struct sized_uint<1> +{ + using type = std::uint8_t; +}; +template <> +struct sized_uint<2> +{ + using type = std::uint16_t; +}; +template <> +struct sized_uint<4> +{ + using type = std::uint32_t; +}; +template <> +struct sized_uint<8> +{ + using type = std::uint64_t; +}; +template +using sized_uint_t = typename sized_uint::type; using array_double_7 = std::array; @@ -43,232 +61,317 @@ using array_double_7 = std::array; // We disable `long double` since Julia does not support this type #define FORALL_OPENPMD_TYPES(MACRO) \ - MACRO("CHAR", Datatype::CHAR, char) \ - MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ - MACRO("SHORT", Datatype::SHORT, short) \ - MACRO("INT", Datatype::INT, int) \ - MACRO("LONG", Datatype::LONG, long) \ - MACRO("LONGLONG", Datatype::LONGLONG, long long) \ - MACRO("USHORT", Datatype::USHORT, unsigned short) \ - MACRO("UINT", Datatype::UINT, unsigned int) \ - MACRO("ULONG", Datatype::ULONG, unsigned long) \ - MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - MACRO("FLOAT", Datatype::FLOAT, float) \ - MACRO("DOUBLE", Datatype::DOUBLE, double) \ - /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ - MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - MACRO("STRING", Datatype::STRING, std::string) \ - MACRO("VEC_CHAR", Datatype::VEC_CHAR, std::vector) \ - MACRO("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ - MACRO("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ - MACRO("VEC_INT", Datatype::VEC_INT, std::vector) \ - MACRO("VEC_LONG", Datatype::VEC_LONG, std::vector) \ - MACRO("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ - MACRO("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ - MACRO("VEC_UINT", Datatype::VEC_UINT, std::vector) \ - MACRO("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ - MACRO("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, \ + MACRO("CHAR", Datatype::CHAR, char) \ + MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ + MACRO("SHORT", Datatype::SHORT, short) \ + MACRO("INT", Datatype::INT, int) \ + MACRO("LONG", Datatype::LONG, long) \ + MACRO("LONGLONG", Datatype::LONGLONG, long long) \ + MACRO("USHORT", Datatype::USHORT, unsigned short) \ + MACRO("UINT", Datatype::UINT, unsigned int) \ + MACRO("ULONG", Datatype::ULONG, unsigned long) \ + MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ + MACRO("FLOAT", Datatype::FLOAT, float) \ + MACRO("DOUBLE", Datatype::DOUBLE, double) \ + /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ + MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ + MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ + MACRO("STRING", Datatype::STRING, std::string) \ + MACRO("VEC_CHAR", Datatype::VEC_CHAR, std::vector) \ + MACRO("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ + MACRO("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ + MACRO("VEC_INT", Datatype::VEC_INT, std::vector) \ + MACRO("VEC_LONG", Datatype::VEC_LONG, std::vector) \ + MACRO("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ + MACRO("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ + MACRO("VEC_UINT", Datatype::VEC_UINT, std::vector) \ + MACRO("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ + MACRO( \ + "VEC_ULONGLONG", \ + Datatype::VEC_ULONGLONG, \ std::vector) \ - MACRO("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ - MACRO("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ - /* MACRO("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) */ \ - MACRO("VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>) \ - MACRO("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, \ + MACRO("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ + MACRO("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ + /* MACRO("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) */ \ + MACRO( \ + "VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>) \ + MACRO( \ + "VEC_CDOUBLE", \ + Datatype::VEC_CDOUBLE, \ std::vector>) \ - /* MACRO("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ - * std::vector>) */ \ - MACRO("VEC_STRING", Datatype::VEC_STRING, std::vector) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ - MACRO("BOOL", Datatype::BOOL, bool) + /* MACRO("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ + * std::vector>) */ \ + MACRO("VEC_STRING", Datatype::VEC_STRING, std::vector) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ + MACRO("BOOL", Datatype::BOOL, bool) #define FORALL_SCALAR_OPENPMD_TYPES(MACRO) \ - MACRO("CHAR", Datatype::CHAR, char) \ - MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ - MACRO("SHORT", Datatype::SHORT, short) \ - MACRO("INT", Datatype::INT, int) \ - MACRO("LONG", Datatype::LONG, long) \ - MACRO("LONGLONG", Datatype::LONGLONG, long long) \ - MACRO("USHORT", Datatype::USHORT, unsigned short) \ - MACRO("UINT", Datatype::UINT, unsigned int) \ - MACRO("ULONG", Datatype::ULONG, unsigned long) \ - MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - MACRO("FLOAT", Datatype::FLOAT, float) \ - MACRO("DOUBLE", Datatype::DOUBLE, double) \ - /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ - MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - MACRO("STRING", Datatype::STRING, std::string) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ - MACRO("BOOL", Datatype::BOOL, bool) + MACRO("CHAR", Datatype::CHAR, char) \ + MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ + MACRO("SHORT", Datatype::SHORT, short) \ + MACRO("INT", Datatype::INT, int) \ + MACRO("LONG", Datatype::LONG, long) \ + MACRO("LONGLONG", Datatype::LONGLONG, long long) \ + MACRO("USHORT", Datatype::USHORT, unsigned short) \ + MACRO("UINT", Datatype::UINT, unsigned int) \ + MACRO("ULONG", Datatype::ULONG, unsigned long) \ + MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ + MACRO("FLOAT", Datatype::FLOAT, float) \ + MACRO("DOUBLE", Datatype::DOUBLE, double) \ + /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ + MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ + MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ + /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ + MACRO("STRING", Datatype::STRING, std::string) \ + MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ + MACRO("BOOL", Datatype::BOOL, bool) // This C++ version is a bit more tedious to use than the macro version above -template T typeval() { return T{}; } +template +T typeval() +{ + return T{}; +} template -void forall_openPMD_types(const F &f, Args &&...args) { - f("CHAR", Datatype::CHAR, typeval(), std::forward(args)...); - f("UCHAR", Datatype::UCHAR, typeval(), - std::forward(args)...); - f("SHORT", Datatype::SHORT, typeval(), std::forward(args)...); - f("INT", Datatype::INT, typeval(), std::forward(args)...); - f("LONG", Datatype::LONG, typeval(), std::forward(args)...); - f("LONGLONG", Datatype::LONGLONG, typeval(), - std::forward(args)...); - f("USHORT", Datatype::USHORT, typeval(), - std::forward(args)...); - f("UINT", Datatype::UINT, typeval(), - std::forward(args)...); - f("ULONG", Datatype::ULONG, typeval(), - std::forward(args)...); - f("ULONGLONG", Datatype::ULONGLONG, typeval(), - std::forward(args)...); - f("FLOAT", Datatype::FLOAT, typeval(), std::forward(args)...); - f("DOUBLE", Datatype::DOUBLE, typeval(), std::forward(args)...); - // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, typeval(), - // std::forward(args)...); - f("CFLOAT", Datatype::CFLOAT, typeval>(), - std::forward(args)...); - f("CDOUBLE", Datatype::CDOUBLE, typeval>(), - std::forward(args)...); - // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, typeval>(), std::forward(args)...); - f("STRING", Datatype::STRING, typeval(), - std::forward(args)...); - f("VEC_CHAR", Datatype::VEC_CHAR, typeval>(), - std::forward(args)...); - f("VEC_UCHAR", Datatype::VEC_UCHAR, typeval>(), - std::forward(args)...); - f("VEC_SHORT", Datatype::VEC_SHORT, typeval>(), - std::forward(args)...); - f("VEC_INT", Datatype::VEC_INT, typeval>(), - std::forward(args)...); - f("VEC_LONG", Datatype::VEC_LONG, typeval>(), - std::forward(args)...); - f("VEC_LONGLONG", Datatype::VEC_LONGLONG, typeval>(), - std::forward(args)...); - f("VEC_USHORT", Datatype::VEC_USHORT, typeval>(), - std::forward(args)...); - f("VEC_UINT", Datatype::VEC_UINT, typeval>(), - std::forward(args)...); - f("VEC_ULONG", Datatype::VEC_ULONG, typeval>(), - std::forward(args)...); - f("VEC_ULONGLONG", Datatype::VEC_ULONGLONG, - typeval>(), std::forward(args)...); - f("VEC_FLOAT", Datatype::VEC_FLOAT, typeval>(), - std::forward(args)...); - f("VEC_DOUBLE", Datatype::VEC_DOUBLE, typeval>(), - std::forward(args)...); - // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, typeval>(), std::forward(args)...); - f("VEC_CFLOAT", Datatype::VEC_CFLOAT, - typeval>>(), std::forward(args)...); - f("VEC_CDOUBLE", Datatype::VEC_CDOUBLE, - typeval>>(), std::forward(args)...); - // f("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, - // typeval>>(), - // std::forward(args)...); - f("VEC_STRING", Datatype::VEC_STRING, typeval>(), - std::forward(args)...); - f("ARR_DBL_7", Datatype::ARR_DBL_7, typeval(), - std::forward(args)...); - f("BOOL", Datatype::BOOL, typeval(), std::forward(args)...); +void forall_openPMD_types(const F &f, Args &&...args) +{ + f("CHAR", Datatype::CHAR, typeval(), std::forward(args)...); + f("UCHAR", + Datatype::UCHAR, + typeval(), + std::forward(args)...); + f("SHORT", Datatype::SHORT, typeval(), std::forward(args)...); + f("INT", Datatype::INT, typeval(), std::forward(args)...); + f("LONG", Datatype::LONG, typeval(), std::forward(args)...); + f("LONGLONG", + Datatype::LONGLONG, + typeval(), + std::forward(args)...); + f("USHORT", + Datatype::USHORT, + typeval(), + std::forward(args)...); + f("UINT", + Datatype::UINT, + typeval(), + std::forward(args)...); + f("ULONG", + Datatype::ULONG, + typeval(), + std::forward(args)...); + f("ULONGLONG", + Datatype::ULONGLONG, + typeval(), + std::forward(args)...); + f("FLOAT", Datatype::FLOAT, typeval(), std::forward(args)...); + f("DOUBLE", + Datatype::DOUBLE, + typeval(), + std::forward(args)...); + // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, typeval(), + // std::forward(args)...); + f("CFLOAT", + Datatype::CFLOAT, + typeval>(), + std::forward(args)...); + f("CDOUBLE", + Datatype::CDOUBLE, + typeval>(), + std::forward(args)...); + // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, typeval>(), std::forward(args)...); + f("STRING", + Datatype::STRING, + typeval(), + std::forward(args)...); + f("VEC_CHAR", + Datatype::VEC_CHAR, + typeval>(), + std::forward(args)...); + f("VEC_UCHAR", + Datatype::VEC_UCHAR, + typeval>(), + std::forward(args)...); + f("VEC_SHORT", + Datatype::VEC_SHORT, + typeval>(), + std::forward(args)...); + f("VEC_INT", + Datatype::VEC_INT, + typeval>(), + std::forward(args)...); + f("VEC_LONG", + Datatype::VEC_LONG, + typeval>(), + std::forward(args)...); + f("VEC_LONGLONG", + Datatype::VEC_LONGLONG, + typeval>(), + std::forward(args)...); + f("VEC_USHORT", + Datatype::VEC_USHORT, + typeval>(), + std::forward(args)...); + f("VEC_UINT", + Datatype::VEC_UINT, + typeval>(), + std::forward(args)...); + f("VEC_ULONG", + Datatype::VEC_ULONG, + typeval>(), + std::forward(args)...); + f("VEC_ULONGLONG", + Datatype::VEC_ULONGLONG, + typeval>(), + std::forward(args)...); + f("VEC_FLOAT", + Datatype::VEC_FLOAT, + typeval>(), + std::forward(args)...); + f("VEC_DOUBLE", + Datatype::VEC_DOUBLE, + typeval>(), + std::forward(args)...); + // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, typeval>(), std::forward(args)...); + f("VEC_CFLOAT", + Datatype::VEC_CFLOAT, + typeval>>(), + std::forward(args)...); + f("VEC_CDOUBLE", + Datatype::VEC_CDOUBLE, + typeval>>(), + std::forward(args)...); + // f("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, + // typeval>>(), + // std::forward(args)...); + f("VEC_STRING", + Datatype::VEC_STRING, + typeval>(), + std::forward(args)...); + f("ARR_DBL_7", + Datatype::ARR_DBL_7, + typeval(), + std::forward(args)...); + f("BOOL", Datatype::BOOL, typeval(), std::forward(args)...); } -namespace { +namespace +{ template -std::vector> map_to_vector_pair(const std::map &m) { - std::vector> vp; - vp.reserve(m.size()); - for (const auto &p : m) - vp.push_back(p); - return vp; +std::vector> map_to_vector_pair(const std::map &m) +{ + std::vector> vp; + vp.reserve(m.size()); + for (const auto &p : m) + vp.push_back(p); + return vp; } template -std::vector> map_to_vector_tuple(const std::map &m) { - std::vector> vp; - vp.reserve(m.size()); - for (const auto &p : m) - vp.emplace_back(p.first, p.second); - return vp; +std::vector> map_to_vector_tuple(const std::map &m) +{ + std::vector> vp; + vp.reserve(m.size()); + for (const auto &p : m) + vp.emplace_back(p.first, p.second); + return vp; } -template std::shared_ptr create_aliasing_shared_ptr(T *ptr) { - auto null_deleter = [](T *) {}; - return std::shared_ptr(ptr, null_deleter); +template +std::shared_ptr create_aliasing_shared_ptr(T *ptr) +{ + auto null_deleter = [](T *) {}; + return std::shared_ptr(ptr, null_deleter); } template -std::shared_ptr capture_vector_as_buffer(std::vector &vec) { - if constexpr (std::is_same_v) { - // We cannot handle std::vector because it is special - std::abort(); - } else { - auto deleter = [](T *) { /* do not delete anything */ }; - std::shared_ptr ptr(vec.data(), std::move(deleter)); - return ptr; - } +std::shared_ptr capture_vector_as_buffer(std::vector &vec) +{ + if constexpr (std::is_same_v) + { + // We cannot handle std::vector because it is special + std::abort(); + } + else + { + auto deleter = [](T *) { /* do not delete anything */ }; + std::shared_ptr ptr(vec.data(), std::move(deleter)); + return ptr; + } } -template std::shared_ptr capture_vector(std::vector vec) { - if constexpr (std::is_same_v) { - // Copy the vector, because std::vector is special - T *dataptr = new T[vec.size()]; - std::shared_ptr ptr(dataptr, std::default_delete()); - std::copy(vec.begin(), vec.end(), dataptr); - return ptr; - } else { - // Capture the vector - T *dataptr = vec.data(); - auto deleter = [vec = std::move(vec)](T *) { - // We moved the vector into the anonymous function, and thus it will be - // destructed when the anonymous function is destructed. There is no need - // to call a destructor manually. - }; - std::shared_ptr ptr(dataptr, std::move(deleter)); - return ptr; - } +template +std::shared_ptr capture_vector(std::vector vec) +{ + if constexpr (std::is_same_v) + { + // Copy the vector, because std::vector is special + T *dataptr = new T[vec.size()]; + std::shared_ptr ptr(dataptr, std::default_delete()); + std::copy(vec.begin(), vec.end(), dataptr); + return ptr; + } + else + { + // Capture the vector + T *dataptr = vec.data(); + auto deleter = [vec = std::move(vec)](T *) { + // We moved the vector into the anonymous function, and thus it will + // be destructed when the anonymous function is destructed. There is + // no need to call a destructor manually. + }; + std::shared_ptr ptr(dataptr, std::move(deleter)); + return ptr; + } } template -void add_array_type(jlcxx::Module &mod, const std::string &name) { - mod.add_type>(name) - .template constructor<>() - .template constructor &>() - .method("size1", &std::array::size) - .method("getindex1", - [](const std::array &a, std::size_t n) { return a[n]; }); - jlcxx::stl::apply_stl>(mod); +void add_array_type(jlcxx::Module &mod, const std::string &name) +{ + mod.add_type>(name) + .template constructor<>() + .template constructor &>() + .method("size1", &std::array::size) + .method("getindex1", [](const std::array &a, std::size_t n) { + return a[n]; + }); + jlcxx::stl::apply_stl>(mod); } template -void map_array_type(jlcxx::Module &mod, const std::string &name) { - mod.map_type>(name); - mod.method("size1", [](const std::array &a) { return a.size(); }); - mod.method("getindex1", - [](const std::array &a, std::size_t n) { return a[n]; }); - jlcxx::stl::apply_stl>(mod); +void map_array_type(jlcxx::Module &mod, const std::string &name) +{ + mod.map_type>(name); + mod.method("size1", [](const std::array &a) { return a.size(); }); + mod.method("getindex1", [](const std::array &a, std::size_t n) { + return a[n]; + }); + jlcxx::stl::apply_stl>(mod); } template -void add_pair_type(jlcxx::Module &mod, const std::string &name) { - mod.add_type>(name) - .template constructor<>() - .template constructor &>() - .method("first", [](const std::pair &p) { return p.first; }) - .method("second", [](const std::pair &p) { return p.second; }); - jlcxx::stl::apply_stl>(mod); +void add_pair_type(jlcxx::Module &mod, const std::string &name) +{ + mod.add_type>(name) + .template constructor<>() + .template constructor &>() + .method("first", [](const std::pair &p) { return p.first; }) + .method("second", [](const std::pair &p) { return p.second; }); + jlcxx::stl::apply_stl>(mod); } } // namespace -namespace jlcxx { -template <> struct IsMirroredType : std::false_type {}; +namespace jlcxx +{ +template <> +struct IsMirroredType : std::false_type +{}; } // namespace jlcxx // We use one function per header file diff --git a/src/binding/julia/openPMD.cpp b/src/binding/julia/openPMD.cpp index 8a24490328..0e96b8a1d4 100644 --- a/src/binding/julia/openPMD.cpp +++ b/src/binding/julia/openPMD.cpp @@ -6,47 +6,49 @@ //////////////////////////////////////////////////////////////////////////////// -JLCXX_MODULE define_julia_module(jlcxx::Module &mod) { - add_array_type(mod, "array_double_7"); - add_pair_type(mod, "pair_string_bool"); +JLCXX_MODULE define_julia_module(jlcxx::Module &mod) +{ + add_array_type(mod, "array_double_7"); + add_pair_type(mod, "pair_string_bool"); - define_julia_shared_ptr(mod); + define_julia_shared_ptr(mod); - // The order of these calls matters. Julia types need to be defined before - // they are used. + // The order of these calls matters. Julia types need to be defined before + // they are used. - // Stand-alone classes - define_julia_Access(mod); - define_julia_ChunkInfo(mod); - define_julia_Datatype(mod); - define_julia_Format(mod); - define_julia_UnitDimension(mod); - // All classes below need at least Datatype + // Stand-alone classes + define_julia_Access(mod); + define_julia_ChunkInfo(mod); + define_julia_Datatype(mod); + define_julia_Format(mod); + define_julia_UnitDimension(mod); + // All classes below need at least Datatype - define_julia_Attribute(mod); - define_julia_Attributable(mod); - define_julia_Dataset(mod); + define_julia_Attribute(mod); + define_julia_Attributable(mod); + define_julia_Dataset(mod); - define_julia_BaseRecordComponent(mod); // needs: Attributable - define_julia_RecordComponent(mod); // needs: BaseRecordComponent - define_julia_MeshRecordComponent(mod); // needs: RecordComponent + define_julia_BaseRecordComponent(mod); // needs: Attributable + define_julia_RecordComponent(mod); // needs: BaseRecordComponent + define_julia_MeshRecordComponent(mod); // needs: RecordComponent - define_julia_Container( - mod); // needs: Attributable, MeshRecordComponent + define_julia_Container( + mod); // needs: Attributable, MeshRecordComponent - define_julia_Mesh(mod); // needs: Container + define_julia_Mesh(mod); // needs: Container - define_julia_Container(mod); // needs: Attributable + define_julia_Container(mod); // needs: Attributable - define_julia_Iteration(mod); // needs: Attributable, Container + define_julia_Iteration(mod); // needs: Attributable, Container - define_julia_Container(mod); // needs: Attributable + define_julia_Container( + mod); // needs: Attributable - define_julia_WriteIterations(mod); // needs: Iteration + define_julia_WriteIterations(mod); // needs: Iteration - // The main class - define_julia_Series(mod); + // The main class + define_julia_Series(mod); - // Handle metadata - define_julia_version(mod); + // Handle metadata + define_julia_version(mod); } diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp index d326c6f410..b735f7ccb5 100644 --- a/src/binding/julia/shared_ptr.cpp +++ b/src/binding/julia/shared_ptr.cpp @@ -2,10 +2,14 @@ #include "defs.hpp" -void define_julia_shared_ptr(jlcxx::Module &mod) { +void define_julia_shared_ptr(jlcxx::Module &mod) +{ #define USE_TYPE(NAME, ENUM, TYPE) \ - mod.method("create_aliasing_shared_ptr_" NAME, \ - &create_aliasing_shared_ptr); - { FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) } + mod.method( \ + "create_aliasing_shared_ptr_" NAME, \ + &create_aliasing_shared_ptr); + { + FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + } #undef USE_TYPE } diff --git a/src/binding/julia/version.cpp b/src/binding/julia/version.cpp index 12129188bc..f3446e73fd 100644 --- a/src/binding/julia/version.cpp +++ b/src/binding/julia/version.cpp @@ -2,11 +2,12 @@ #include "defs.hpp" -void define_julia_version(jlcxx::Module &mod) { - mod.method("get_version", getVersion); - mod.method("get_standard", getStandard); - mod.method("get_standard_minimum", getStandardMinimum); - mod.method("cxx_get_variants", - []() { return map_to_vector_pair(getVariants()); }); - mod.method("get_file_extensions", getFileExtensions); +void define_julia_version(jlcxx::Module &mod) +{ + mod.method("get_version", getVersion); + mod.method("get_standard", getStandard); + mod.method("get_standard_minimum", getStandardMinimum); + mod.method( + "cxx_get_variants", []() { return map_to_vector_pair(getVariants()); }); + mod.method("get_file_extensions", getFileExtensions); } diff --git a/src/binding/python/Series.cpp b/src/binding/python/Series.cpp index aea4526d0a..484c7d25b6 100644 --- a/src/binding/python/Series.cpp +++ b/src/binding/python/Series.cpp @@ -19,9 +19,9 @@ * If not, see . */ +#include #include #include -#include #include "openPMD/Series.hpp" #include "openPMD/config.hpp" From 84bce33ffe0f730ac13562a6f0ff142222efff95 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 8 Mar 2022 12:51:17 -0500 Subject: [PATCH 56/94] Set CMAKE_OSX_DEPLOYMENT_TARGET to 10.14 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1868217997..9114fdff92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ # cmake_minimum_required(VERSION 3.15.0) +# macOS 10.14 is required for certain C++17 features. +# (This variable needs to be set before calling `project`.) +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version") + project(openPMD VERSION 0.15.0) # LANGUAGES CXX # the openPMD "markup"/"schema" standard version From 46d19afcd745f2774d8ce968a7415c6213b007b3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:14:12 +0000 Subject: [PATCH 57/94] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/binding/julia/Attributable.cpp | 4 +--- src/binding/julia/Datatype.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 76c11dc17f..bc5e61649d 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -9,9 +9,7 @@ void define_julia_Attributable(jlcxx::Module &mod) #define USE_TYPE(NAME, ENUM, TYPE) \ type.method( \ "cxx_set_attribute_" NAME "!", &Attributable::setAttribute); - { - FORALL_OPENPMD_TYPES(USE_TYPE) - } + {FORALL_OPENPMD_TYPES(USE_TYPE)} #undef USE_TYPE type.method("cxx_get_attribute", &Attributable::getAttribute); diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 55001f39db..638ba99769 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -8,9 +8,7 @@ void define_julia_Datatype(jlcxx::Module &mod) jlcxx::stl::apply_stl(mod); #define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); - { - FORALL_OPENPMD_TYPES(USE_TYPE) - } + {FORALL_OPENPMD_TYPES(USE_TYPE)} #undef USE_TYPE mod.set_const("UNDEFINED", Datatype::UNDEFINED); From 479b3d734c81b732a12754de1f9a599064b671c1 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 11 Nov 2022 17:55:14 -0500 Subject: [PATCH 58/94] Julia: Update ADIOS2 format enum constants --- src/binding/julia/Format.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/binding/julia/Format.cpp b/src/binding/julia/Format.cpp index 7052a957f4..5af8f58053 100644 --- a/src/binding/julia/Format.cpp +++ b/src/binding/julia/Format.cpp @@ -9,7 +9,8 @@ void define_julia_Format(jlcxx::Module &mod) mod.set_const("FORMAT_HDF5", Format::HDF5); mod.set_const("FORMAT_ADIOS1", Format::ADIOS1); - mod.set_const("FORMAT_ADIOS2", Format::ADIOS2); + mod.set_const("FORMAT_ADIOS2_BP4", Format::ADIOS2_BP4); + mod.set_const("FORMAT_ADIOS2_BP5", Format::ADIOS2_BP5); mod.set_const("FORMAT_ADIOS2_SST", Format::ADIOS2_SST); mod.set_const("FORMAT_ADIOS2_SSC", Format::ADIOS2_SSC); mod.set_const("FORMAT_JSON", Format::JSON); From 20cdbe774e9dd5b739f3aede0c7fc69a7dbaf431 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 11 Nov 2022 18:46:10 -0500 Subject: [PATCH 59/94] Julia: Wrap call to seriesFlush in lambda to resolve overload --- src/binding/julia/Attributable.cpp | 3 +-- src/binding/julia/Datatype.cpp | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index bc5e61649d..26aaabd54e 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -20,6 +20,5 @@ void define_julia_Attributable(jlcxx::Module &mod) type.method("cxx_comment", &Attributable::comment); type.method("cxx_set_comment!", &Attributable::setComment); type.method( - "cxx_series_flush", - static_cast(&Attributable::seriesFlush)); + "cxx_series_flush", [](Attributable &attr) { attr.seriesFlush(); }); } diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 638ba99769..addda0776c 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -17,7 +17,9 @@ void define_julia_Datatype(jlcxx::Module &mod) mod.method("cxx_to_bytes", toBytes); mod.method("cxx_to_bits", toBits); mod.method("cxx_is_vector", isVector); - mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint); + mod.method( + "cxx_is_floating_point", + static_cast(isFloatingPoint)); mod.method( "cxx_is_complex_floating_point", static_cast(isComplexFloatingPoint)); From e31818f13105e7117639f53f448f63c818524998 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 09:53:13 -0400 Subject: [PATCH 60/94] Simplify CMakeLists.txt --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efbf3aa6de..6dedf3faa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -709,11 +709,7 @@ if(openPMD_HAVE_Julia) src/binding/julia/shared_ptr.cpp src/binding/julia/version.cpp ) - target_compile_features(openPMD.jl PUBLIC cxx_std_17) - set_target_properties(openPMD.jl PROPERTIES - CXX_EXTENSIONS OFF - CXX_STANDARD_REQUIRED ON - ) + openpmd_cxx_required(openPMD.jl) target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) endif() From 61fe000b080e83374cfe8322682c67054e9d214d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 14:38:00 +0000 Subject: [PATCH 61/94] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/binding/julia/Series.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 4a112db055..2c4ee53a33 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -78,8 +78,8 @@ void define_julia_Series(jlcxx::Module &mod) type.method("cxx_software", &Series::software); type.method( "cxx_set_software!", - static_cast( + static_cast( &Series::setSoftware)); type.method( "cxx_set_software!", From c11fcd0c22876e74a48e475782bbd17d26decdeb Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 10:45:36 -0400 Subject: [PATCH 62/94] CI: Correct yaml syntax --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0d7ed1ff67..d43f8937c4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -240,7 +240,7 @@ jobs: run: | sudo apt-get update sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev python3 python3-numpy python3-mpi4py python3-pandas -# TODO ADIOS2 + # TODO ADIOS2 # Install Julia wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz sudo tar -xz -C /usr/local -f julia-1.6.7-linux-x86_64.tar.gz @@ -250,7 +250,7 @@ jobs: sudo chmod a+x /usr/local/bin/cmake-easyinstall export CEI_SUDO="sudo" # Install libcxxwrap-julia - cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.0 -DJulia_EXECUTABLE=/usr/local/julia-1.6.7/bin/julia + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.7 -DJulia_EXECUTABLE=/usr/local/julia-1.6.7/bin/julia - name: Build env: {CXXFLAGS: -Werror, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig} run: | From e6029937a3f3dcce4c7b79a42bcb0fac99a3cb1d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 11:12:21 -0400 Subject: [PATCH 63/94] CI: Require newer macOS when installing dependencies --- .github/workflows/macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 46257ca561..880369c47a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -18,6 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install + env: {MACOSX_DEPLOYMENT_TARGET: 10.15} run: | rm -rf /usr/local/bin/2to3 set +e From e3642175d56f4038c2070b035b3245723371cc2a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 11:13:09 -0400 Subject: [PATCH 64/94] CI: Require newer libcxxwrap on macOS --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 880369c47a..4651830949 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -33,7 +33,7 @@ jobs: sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY sudo chmod a+x /usr/local/bin/cmake-easyinstall # Install libcxxwrap-julia - cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.0 + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.7 - name: Build env: {CXXFLAGS: -Werror, MACOSX_DEPLOYMENT_TARGET: 10.15} # 10.14+ due to std::visit From 742418716cd5a03942acd387cc1d2215a9e93924 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 11:57:58 -0400 Subject: [PATCH 65/94] CI: Require macOS 10.15 for Julia bindings --- .github/workflows/macos.yml | 3 +-- CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 4651830949..6ad36300da 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,13 +12,12 @@ jobs: # appleclang10_py37_h5_ad2_libcpp # appleclang11_nopy_nompi_h5_ad2 - appleclang14_py_mpi_h5_ad2: + appleclang14_py_mpi_h5_ad2_julia: runs-on: macos-latest if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 - name: Install - env: {MACOSX_DEPLOYMENT_TARGET: 10.15} run: | rm -rf /usr/local/bin/2to3 set +e diff --git a/CMakeLists.txt b/CMakeLists.txt index 7290858221..e20cb1b531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,9 @@ # cmake_minimum_required(VERSION 3.15.0) -# macOS 10.14 is required for certain C++17 features. +# macOS 10.15 is required for certain C++17 features. # (This variable needs to be set before calling `project`.) -set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version") +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") project(openPMD VERSION 0.16.0) # LANGUAGES CXX From 4be71b1a09c9a51d1ce0fa2f9821b5dd6366f178 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 12:42:40 -0400 Subject: [PATCH 66/94] CI: Install `dot` executable when building documentation --- .readthedocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.readthedocs.yml b/.readthedocs.yml index 2fc118e82d..d72547f396 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -14,4 +14,5 @@ build: tools: python: "3.11" apt_packages: + - graphviz - librsvg2-bin From 655febb3248dbb47e6cab34ff12f9102e732be6b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 13:05:08 -0400 Subject: [PATCH 67/94] Document install with Julia --- NEWS.rst | 3 +++ README.md | 6 ++++++ docs/source/install/install.rst | 14 +++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 86ea34fff4..ce40950146 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -13,6 +13,9 @@ Please transition to ADIOS2. For reading legacy ADIOS1 BP3 files, either use an older version of openPMD-api or the BP3 backend in ADIOS2. Note that ADIOS2 does not support compression in BP3 files. +Julia 1.7 to 1.9 are supported. The development version of Julia +(future 1.10) is supported as well. Julia 1.6 is too old. + 0.15.0 ------ diff --git a/README.md b/README.md index 1cf6bdba78..8735c83b61 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,12 @@ while those can be built either with or without: * MPI 2.1+, e.g. OpenMPI 1.6.5+ or MPICH2 Optional language bindings: +* Julia: + * Most Julia users will not build `openPMD_api` from source. The + Julia package `openPMD.jl` will automatically download a suitable + `openPMD_api` binary. + * Julia 1.7 - 1.10 + * [libcxxwrap_julia](https://github.com/JuliaInterop/libcxxwrap-julia) 0.8.3 - 0.9.7 * Python: * Python 3.7 - 3.11 * pybind11 2.10.1+ diff --git a/docs/source/install/install.rst b/docs/source/install/install.rst index 48b9f6c3e9..03ea04de54 100644 --- a/docs/source/install/install.rst +++ b/docs/source/install/install.rst @@ -123,6 +123,18 @@ Additional CMake options can be passed via individual environment variables, whi .. image:: cmake.svg +Using the Julia Package +----------------------- + +A package for openPMD-api is available via the Julia Package Registry: + +.. code-block:: julia + + # We need Julia 1.7 or newer + using("Pkg") + Pkg.add("openPMD") + + From Source with CMake ---------------------- @@ -147,7 +159,7 @@ Linux & OSX # -DCMAKE_INSTALL_PREFIX=$HOME/somepath # for options append: # -DopenPMD_USE_...=... - # e.g. for python support add: + # e.g. for Python support add: # -DopenPMD_USE_PYTHON=ON -DPython_EXECUTABLE=$(which python3) cmake ../openPMD-api From 13ea8b4ecca968a5355825d639b3e9182d14b484 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 19 May 2023 14:05:30 -0400 Subject: [PATCH 68/94] CI: Rename workflow --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6ad36300da..b247cbc63d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,7 +12,7 @@ jobs: # appleclang10_py37_h5_ad2_libcpp # appleclang11_nopy_nompi_h5_ad2 - appleclang14_py_mpi_h5_ad2_julia: + appleclang14_py_mpi_h5_ad2: runs-on: macos-latest if: github.event.pull_request.draft == false steps: From 130c167eaef59c3c02751e07afb13bfa5e2ea181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Jun 2023 14:25:03 +0200 Subject: [PATCH 69/94] Replace FORALL_OPENPMD_TYPES -> forallJuliaTypes Same for forallScalarJuliaTypes --- src/binding/julia/Attributable.cpp | 21 +- src/binding/julia/Attribute.cpp | 21 +- src/binding/julia/Datatype.cpp | 18 +- src/binding/julia/MeshRecordComponent.cpp | 22 +- .../julia/RecordComponent_load_chunk.cpp | 27 +- .../julia/RecordComponent_make_constant.cpp | 22 +- .../julia/RecordComponent_store_chunk.cpp | 27 +- src/binding/julia/defs.hpp | 293 ++++++------------ src/binding/julia/shared_ptr.cpp | 24 +- 9 files changed, 217 insertions(+), 258 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 26aaabd54e..afaa51c9c4 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -2,15 +2,26 @@ #include "defs.hpp" +namespace +{ +struct UseType +{ + template + static void call(jlcxx::TypeWrapper type) + { + type.method( + "cxx_set_attribute_" + datatypeToString(determineDatatype()) + + "!", + &Attributable::setAttribute); + } +}; +} // namespace + void define_julia_Attributable(jlcxx::Module &mod) { auto type = mod.add_type("CXX_Attributable"); -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "cxx_set_attribute_" NAME "!", &Attributable::setAttribute); - {FORALL_OPENPMD_TYPES(USE_TYPE)} -#undef USE_TYPE + forallJuliaTypes(type); type.method("cxx_get_attribute", &Attributable::getAttribute); type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index 6d55e4ae49..9042bce0d1 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -2,16 +2,25 @@ #include "defs.hpp" +namespace +{ +struct UseType +{ + template + static void call(jlcxx::TypeWrapper type) + { + type.method( + "cxx_get_" + datatypeToString(determineDatatype()), + &Attribute::get); + } +}; +} // namespace + void define_julia_Attribute(jlcxx::Module &mod) { auto type = mod.add_type("CXX_Attribute"); type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method("cxx_get_" NAME, &Attribute::get); - { - FORALL_OPENPMD_TYPES(USE_TYPE) - } -#undef USE_TYPE + forallJuliaTypes(type); } diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index addda0776c..caef3cc1bb 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -2,14 +2,26 @@ #include "defs.hpp" +namespace +{ +struct UseType +{ + template + static void call(jlcxx::Module &mod) + { + Datatype const dt = determineDatatype(); + mod.set_const(datatypeToString(dt), dt); + } +}; +} // namespace + void define_julia_Datatype(jlcxx::Module &mod) { mod.add_bits("Datatype", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); -#define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM); - {FORALL_OPENPMD_TYPES(USE_TYPE)} -#undef USE_TYPE + forallJuliaTypes(mod); + mod.set_const("UNDEFINED", Datatype::UNDEFINED); mod.set_const("openPMD_datatypes", openPMD_Datatypes); diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 67e253e07e..baa58433e0 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -12,6 +12,20 @@ struct SuperType }; } // namespace jlcxx +namespace +{ +struct UseType +{ + template + static void call(jlcxx::TypeWrapper type) + { + type.method( + "cxx_make_constant_" + datatypeToString(determineDatatype()), + &MeshRecordComponent::makeConstant); + } +}; +} // namespace + void define_julia_MeshRecordComponent(jlcxx::Module &mod) { auto type = mod.add_type( @@ -19,11 +33,5 @@ void define_julia_MeshRecordComponent(jlcxx::Module &mod) type.method("cxx_position", &MeshRecordComponent::position); type.method("cxx_set_position!", &MeshRecordComponent::setPosition); -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "cxx_make_constant_" NAME, &MeshRecordComponent::makeConstant); - { - FORALL_OPENPMD_TYPES(USE_TYPE) - } -#undef USE_TYPE + forallJuliaTypes(type); } diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index f1f0900071..de6d97024e 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -2,17 +2,24 @@ #include "defs.hpp" -void define_julia_RecordComponent_load_chunk( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +namespace { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "cxx_load_chunk_" NAME, \ - static_cast, Offset, Extent)>( \ - &RecordComponent::loadChunk)); +struct UseType +{ + template + static void call(jlcxx::TypeWrapper &type) { - FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + type.method( + "cxx_load_" + datatypeToString(determineDatatype()), + static_cast, Offset, Extent)>( + &RecordComponent::loadChunk)); } -#undef USE_TYPE +}; +} // namespace + +void define_julia_RecordComponent_load_chunk( + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ + forallScalarJuliaTypes(type); } diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 41e9a81670..e739d59c65 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -2,14 +2,22 @@ #include "defs.hpp" -void define_julia_RecordComponent_make_constant( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +namespace { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "cxx_make_constant_" NAME, &RecordComponent::makeConstant); +struct UseType +{ + template + static void call(jlcxx::TypeWrapper &type) { - FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + type.method( + "cxx_make_constant_" + datatypeToString(determineDatatype()), + &RecordComponent::makeConstant); } -#undef USE_TYPE +}; +} // namespace + +void define_julia_RecordComponent_make_constant( + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ + forallScalarJuliaTypes(type); } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 761b139c2b..7a6977160e 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -2,17 +2,24 @@ #include "defs.hpp" -void define_julia_RecordComponent_store_chunk( - jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +namespace { -#define USE_TYPE(NAME, ENUM, TYPE) \ - type.method( \ - "cxx_store_chunk_" NAME, \ - static_cast, Offset, Extent)>( \ - &RecordComponent::storeChunk)); +struct UseType +{ + template + static void call(jlcxx::TypeWrapper &type) { - FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + type.method( + "cxx_store_chunk_" + datatypeToString(determineDatatype()), + static_cast, Offset, Extent)>( + &RecordComponent::storeChunk)); } -#undef USE_TYPE +}; +} // namespace + +void define_julia_RecordComponent_store_chunk( + jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) +{ + forallScalarJuliaTypes(type); } diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 5be29cc08a..261c6d0494 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -51,213 +52,99 @@ using sized_uint_t = typename sized_uint::type; using array_double_7 = std::array; -/* - * Generate code fo all openPMD types. Use is e.g. as follows: - * #define USE_TYPE(NAME, ENUM, TYPE) \ - * type.method("get_" NAME, &Attribute::get); - * FORALL_OPENPMD_TYPES(USE_TYPE) - * #undef USE_TYPE +/** + * Generalizes the repeated application of a function template for all + * scalar openPMD datatypes. + * + * Will call the function template found at Action::template call(), + * instantiating T with every scalar openPMD datatype as found + * in the Datatype enum. + * + * @tparam Action The struct containing the function template. + * @tparam Args The function template's argument types. + * @param args The function template's arguments. */ - -// We disable `long double` since Julia does not support this type -#define FORALL_OPENPMD_TYPES(MACRO) \ - MACRO("CHAR", Datatype::CHAR, char) \ - MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ - MACRO("SHORT", Datatype::SHORT, short) \ - MACRO("INT", Datatype::INT, int) \ - MACRO("LONG", Datatype::LONG, long) \ - MACRO("LONGLONG", Datatype::LONGLONG, long long) \ - MACRO("USHORT", Datatype::USHORT, unsigned short) \ - MACRO("UINT", Datatype::UINT, unsigned int) \ - MACRO("ULONG", Datatype::ULONG, unsigned long) \ - MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - MACRO("FLOAT", Datatype::FLOAT, float) \ - MACRO("DOUBLE", Datatype::DOUBLE, double) \ - /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ - MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - MACRO("STRING", Datatype::STRING, std::string) \ - MACRO("VEC_CHAR", Datatype::VEC_CHAR, std::vector) \ - MACRO("VEC_UCHAR", Datatype::VEC_UCHAR, std::vector) \ - MACRO("VEC_SHORT", Datatype::VEC_SHORT, std::vector) \ - MACRO("VEC_INT", Datatype::VEC_INT, std::vector) \ - MACRO("VEC_LONG", Datatype::VEC_LONG, std::vector) \ - MACRO("VEC_LONGLONG", Datatype::VEC_LONGLONG, std::vector) \ - MACRO("VEC_USHORT", Datatype::VEC_USHORT, std::vector) \ - MACRO("VEC_UINT", Datatype::VEC_UINT, std::vector) \ - MACRO("VEC_ULONG", Datatype::VEC_ULONG, std::vector) \ - MACRO( \ - "VEC_ULONGLONG", \ - Datatype::VEC_ULONGLONG, \ - std::vector) \ - MACRO("VEC_FLOAT", Datatype::VEC_FLOAT, std::vector) \ - MACRO("VEC_DOUBLE", Datatype::VEC_DOUBLE, std::vector) \ - /* MACRO("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, std::vector) */ \ - MACRO( \ - "VEC_CFLOAT", Datatype::VEC_CFLOAT, std::vector>) \ - MACRO( \ - "VEC_CDOUBLE", \ - Datatype::VEC_CDOUBLE, \ - std::vector>) \ - /* MACRO("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, \ - * std::vector>) */ \ - MACRO("VEC_STRING", Datatype::VEC_STRING, std::vector) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ - MACRO("BOOL", Datatype::BOOL, bool) - -#define FORALL_SCALAR_OPENPMD_TYPES(MACRO) \ - MACRO("CHAR", Datatype::CHAR, char) \ - MACRO("UCHAR", Datatype::UCHAR, unsigned char) \ - MACRO("SHORT", Datatype::SHORT, short) \ - MACRO("INT", Datatype::INT, int) \ - MACRO("LONG", Datatype::LONG, long) \ - MACRO("LONGLONG", Datatype::LONGLONG, long long) \ - MACRO("USHORT", Datatype::USHORT, unsigned short) \ - MACRO("UINT", Datatype::UINT, unsigned int) \ - MACRO("ULONG", Datatype::ULONG, unsigned long) \ - MACRO("ULONGLONG", Datatype::ULONGLONG, unsigned long long) \ - MACRO("FLOAT", Datatype::FLOAT, float) \ - MACRO("DOUBLE", Datatype::DOUBLE, double) \ - /* MACRO("LONG_DOUBLE", Datatype::LONG_DOUBLE, long double) */ \ - MACRO("CFLOAT", Datatype::CFLOAT, std::complex) \ - MACRO("CDOUBLE", Datatype::CDOUBLE, std::complex) \ - /* MACRO("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, std::complex) */ \ - MACRO("STRING", Datatype::STRING, std::string) \ - MACRO("ARR_DBL_7", Datatype::ARR_DBL_7, array_double_7) \ - MACRO("BOOL", Datatype::BOOL, bool) - -// This C++ version is a bit more tedious to use than the macro version above -template -T typeval() +template +void forallScalarJuliaTypes(Args &&...args) { - return T{}; + // Do NOT call std::forward(args)... here + // Move semantics must be avoided due to repeated application + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + // We disable `long double` since Julia does not support this type + // Action::template call(args...); + Action::template call>(args...); + Action::template call>(args...); + // Action::template call>(args...); + Action::template call(args...); + Action::template call(args...); } -template -void forall_openPMD_types(const F &f, Args &&...args) +/** + * Generalizes the repeated application of a function template for all + * openPMD datatypes. + * + * Will call the function template found at Action::template call(), + * instantiating T with every scalar datatype as found in the Datatype enum. + * + * @tparam Action The struct containing the function template. + * @tparam Args The function template's argument types. + * @param args The function template's arguments. + */ +template +void forallJuliaTypes(Args &&...args) { - f("CHAR", Datatype::CHAR, typeval(), std::forward(args)...); - f("UCHAR", - Datatype::UCHAR, - typeval(), - std::forward(args)...); - f("SHORT", Datatype::SHORT, typeval(), std::forward(args)...); - f("INT", Datatype::INT, typeval(), std::forward(args)...); - f("LONG", Datatype::LONG, typeval(), std::forward(args)...); - f("LONGLONG", - Datatype::LONGLONG, - typeval(), - std::forward(args)...); - f("USHORT", - Datatype::USHORT, - typeval(), - std::forward(args)...); - f("UINT", - Datatype::UINT, - typeval(), - std::forward(args)...); - f("ULONG", - Datatype::ULONG, - typeval(), - std::forward(args)...); - f("ULONGLONG", - Datatype::ULONGLONG, - typeval(), - std::forward(args)...); - f("FLOAT", Datatype::FLOAT, typeval(), std::forward(args)...); - f("DOUBLE", - Datatype::DOUBLE, - typeval(), - std::forward(args)...); - // f("LONG_DOUBLE", Datatype::LONG_DOUBLE, typeval(), - // std::forward(args)...); - f("CFLOAT", - Datatype::CFLOAT, - typeval>(), - std::forward(args)...); - f("CDOUBLE", - Datatype::CDOUBLE, - typeval>(), - std::forward(args)...); - // f("CLONG_DOUBLE", Datatype::CLONG_DOUBLE, typeval>(), std::forward(args)...); - f("STRING", - Datatype::STRING, - typeval(), - std::forward(args)...); - f("VEC_CHAR", - Datatype::VEC_CHAR, - typeval>(), - std::forward(args)...); - f("VEC_UCHAR", - Datatype::VEC_UCHAR, - typeval>(), - std::forward(args)...); - f("VEC_SHORT", - Datatype::VEC_SHORT, - typeval>(), - std::forward(args)...); - f("VEC_INT", - Datatype::VEC_INT, - typeval>(), - std::forward(args)...); - f("VEC_LONG", - Datatype::VEC_LONG, - typeval>(), - std::forward(args)...); - f("VEC_LONGLONG", - Datatype::VEC_LONGLONG, - typeval>(), - std::forward(args)...); - f("VEC_USHORT", - Datatype::VEC_USHORT, - typeval>(), - std::forward(args)...); - f("VEC_UINT", - Datatype::VEC_UINT, - typeval>(), - std::forward(args)...); - f("VEC_ULONG", - Datatype::VEC_ULONG, - typeval>(), - std::forward(args)...); - f("VEC_ULONGLONG", - Datatype::VEC_ULONGLONG, - typeval>(), - std::forward(args)...); - f("VEC_FLOAT", - Datatype::VEC_FLOAT, - typeval>(), - std::forward(args)...); - f("VEC_DOUBLE", - Datatype::VEC_DOUBLE, - typeval>(), - std::forward(args)...); - // f("VEC_LONG_DOUBLE", Datatype::VEC_LONG_DOUBLE, typeval>(), std::forward(args)...); - f("VEC_CFLOAT", - Datatype::VEC_CFLOAT, - typeval>>(), - std::forward(args)...); - f("VEC_CDOUBLE", - Datatype::VEC_CDOUBLE, - typeval>>(), - std::forward(args)...); - // f("VEC_CLONG_DOUBLE", Datatype::VEC_CLONG_DOUBLE, - // typeval>>(), - // std::forward(args)...); - f("VEC_STRING", - Datatype::VEC_STRING, - typeval>(), - std::forward(args)...); - f("ARR_DBL_7", - Datatype::ARR_DBL_7, - typeval(), - std::forward(args)...); - f("BOOL", Datatype::BOOL, typeval(), std::forward(args)...); + // Do NOT call std::forward(args)... here + // Move semantics must be avoided due to repeated application + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + Action::template call(args...); + // We disable `long double` since Julia does not support this type + // Action::template call(args...); + Action::template call>(args...); + Action::template call>(args...); + // Action::template call>(args...); + Action::template call(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call>(args...); + // Action::template call>(args...); + Action::template call>>(args...); + Action::template call>>(args...); + // Action::template call>>(args...); + Action::template call>(args...); + Action::template call>(args...); + Action::template call(args...); } namespace diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp index b735f7ccb5..bfed4e3678 100644 --- a/src/binding/julia/shared_ptr.cpp +++ b/src/binding/julia/shared_ptr.cpp @@ -1,15 +1,25 @@ // shared_ptr #include "defs.hpp" +#include "openPMD/Datatype.hpp" +#include -void define_julia_shared_ptr(jlcxx::Module &mod) +namespace +{ +struct UseType { -#define USE_TYPE(NAME, ENUM, TYPE) \ - mod.method( \ - "create_aliasing_shared_ptr_" NAME, \ - &create_aliasing_shared_ptr); + template + static void call(jlcxx::Module &mod) { - FORALL_SCALAR_OPENPMD_TYPES(USE_TYPE) + mod.method( + "create_aliasing_shared_ptr_" + + datatypeToString(determineDatatype()), + &create_aliasing_shared_ptr); } -#undef USE_TYPE +}; +} // namespace + +void define_julia_shared_ptr(jlcxx::Module &mod) +{ + forallScalarJuliaTypes(mod); } From 769adbcfb43d48332204bbda14a5610e845a3a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Jun 2023 14:54:21 +0200 Subject: [PATCH 70/94] Replace typedef -> using --- src/binding/julia/BaseRecordComponent.cpp | 2 +- src/binding/julia/ChunkInfo.cpp | 2 +- src/binding/julia/Container.hpp | 7 +++---- src/binding/julia/Iteration.cpp | 2 +- src/binding/julia/Mesh.cpp | 2 +- src/binding/julia/MeshRecordComponent.cpp | 2 +- src/binding/julia/RecordComponent.cpp | 2 +- src/binding/julia/Series.cpp | 6 +++--- src/binding/julia/WriteIterations.cpp | 3 +-- 9 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index 05c7a41b09..f436275057 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -8,7 +8,7 @@ namespace jlcxx template <> struct SuperType { - typedef Attributable type; + using type = Attributable; }; } // namespace jlcxx diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp index 86fe6f13f9..c019266ab4 100644 --- a/src/binding/julia/ChunkInfo.cpp +++ b/src/binding/julia/ChunkInfo.cpp @@ -8,7 +8,7 @@ namespace jlcxx template <> struct SuperType { - typedef ChunkInfo type; + using type = ChunkInfo; }; } // namespace jlcxx diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index 0db492542d..44f31fe41e 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -14,14 +14,13 @@ namespace jlcxx template struct SuperType> { - typedef Attributable type; + using type = Attributable; }; } // namespace jlcxx +using julia_Container_type_t = + jlcxx::TypeWrapper, jlcxx::TypeVar<2>>>; // TODO: use std::optional instead of std::unique_ptr -typedef jlcxx::TypeWrapper< - jlcxx::Parametric, jlcxx::TypeVar<2>>> - julia_Container_type_t; extern std::unique_ptr julia_Container_type; template diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index b39b878690..53390f6362 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -10,7 +10,7 @@ namespace jlcxx template <> struct SuperType { - typedef Attributable type; + using type = Attributable; }; } // namespace jlcxx diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 3ed65ef378..9be4758397 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -8,7 +8,7 @@ namespace jlcxx template <> struct SuperType { - typedef Container type; + using type = Container; }; } // namespace jlcxx diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index baa58433e0..7c67c3dae0 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -8,7 +8,7 @@ namespace jlcxx template <> struct SuperType { - typedef RecordComponent type; + using type = RecordComponent; }; } // namespace jlcxx diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index acd3ec1a10..1b391ab6bd 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -13,7 +13,7 @@ namespace jlcxx template <> struct SuperType { - typedef BaseRecordComponent type; + using type = BaseRecordComponent; }; } // namespace jlcxx diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 2c4ee53a33..08203d3493 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -21,7 +21,7 @@ namespace jlcxx template <> struct SuperType { - typedef Attributable type; + using type = Attributable; }; } // namespace jlcxx @@ -42,7 +42,7 @@ void define_julia_Series(jlcxx::Module &mod) sized_uint_t ucomm, const std::string &options) { MPI_Comm comm; - static_assert(sizeof ucomm == sizeof comm, ""); + static_assert(sizeof ucomm == sizeof comm); memcpy(&comm, &ucomm, sizeof comm); return Series(filepath, at, comm, options); }); @@ -52,7 +52,7 @@ void define_julia_Series(jlcxx::Module &mod) Access at, sized_uint_t ucomm) { MPI_Comm comm; - static_assert(sizeof ucomm == sizeof comm, ""); + static_assert(sizeof ucomm == sizeof comm); memcpy(&comm, &ucomm, sizeof comm); return Series(filepath, at, comm); }); diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp index dd4a039ed8..6587b28fe1 100644 --- a/src/binding/julia/WriteIterations.cpp +++ b/src/binding/julia/WriteIterations.cpp @@ -6,8 +6,7 @@ void define_julia_WriteIterations(jlcxx::Module &mod) { - using iterations_t = Container; - using key_type = typename iterations_t::key_type; + using key_type = Series::IterationIndex_t; // using mapped_type = typename iterations_t::mapped_type; auto type = mod.add_type("WriteIterations"); From b381ad846669e88e952a081508dde68371db507b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Jun 2023 16:03:24 +0200 Subject: [PATCH 71/94] Use overload_cast --- src/binding/julia/Container.hpp | 5 +-- src/binding/julia/Iteration.cpp | 4 +- src/binding/julia/Mesh.cpp | 3 +- .../julia/RecordComponent_load_chunk.cpp | 3 +- .../julia/RecordComponent_store_chunk.cpp | 3 +- src/binding/julia/Series.cpp | 3 +- src/binding/julia/defs.hpp | 42 +++++++++++++++++++ 7 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index 44f31fe41e..940127a987 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -36,7 +36,6 @@ void define_julia_Container(jlcxx::Module &mod) using ContainerT = typename decltype(type)::type; using key_type = typename ContainerT::key_type; using mapped_type = typename ContainerT::mapped_type; - using size_type = typename ContainerT::size_type; static_assert(std::is_same_v); static_assert(std::is_same_v); @@ -62,9 +61,7 @@ void define_julia_Container(jlcxx::Module &mod) type.method("cxx_count", &ContainerT::count); type.method("cxx_contains", &ContainerT::contains); type.method( - "cxx_delete!", - static_cast( - &ContainerT::erase)); + "cxx_delete!", overload_cast(&ContainerT::erase)); type.method("cxx_keys", [](const ContainerT &cont) { std::vector res; res.reserve(cont.size()); diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index 53390f6362..2e79fa0cdb 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -25,9 +25,7 @@ void define_julia_Iteration(jlcxx::Module &mod) type.method("cxx_set_dt!", &Iteration::setDt); type.method("cxx_time_unit_SI", &Iteration::timeUnitSI); type.method("cxx_set_time_unit_SI!", &Iteration::setTimeUnitSI); - type.method( - "cxx_close", - static_cast(&Iteration::close)); + type.method("cxx_close", overload_cast(&Iteration::close)); type.method("cxx_open", &Iteration::open); type.method("cxx_closed", &Iteration::closed); type.method("cxx_meshes", [](Iteration &iter) -> Container & { diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 9be4758397..5bcfe42f9c 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -46,8 +46,7 @@ void define_julia_Mesh(jlcxx::Module &mod) type.method("cxx_geometry", &Mesh::geometry); type.method( - "cxx_set_geometry!", - static_cast(&Mesh::setGeometry)); + "cxx_set_geometry!", overload_cast(&Mesh::setGeometry)); type.method("cxx_geometry_parameters", &Mesh::geometryParameters); type.method("cxx_set_geometry_parameters!", &Mesh::setGeometryParameters); type.method("cxx_data_order", &Mesh::dataOrder); diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index de6d97024e..99d763d56f 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -11,8 +11,7 @@ struct UseType { type.method( "cxx_load_" + datatypeToString(determineDatatype()), - static_cast, Offset, Extent)>( + overload_cast, Offset, Extent>( &RecordComponent::loadChunk)); } }; diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 7a6977160e..803400d6c8 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -11,8 +11,7 @@ struct UseType { type.method( "cxx_store_chunk_" + datatypeToString(determineDatatype()), - static_cast, Offset, Extent)>( + overload_cast, Offset, Extent>( &RecordComponent::storeChunk)); } }; diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 08203d3493..5605a900ea 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -78,8 +78,7 @@ void define_julia_Series(jlcxx::Module &mod) type.method("cxx_software", &Series::software); type.method( "cxx_set_software!", - static_cast( + overload_cast( &Series::setSoftware)); type.method( "cxx_set_software!", diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 261c6d0494..cd88dc2d5f 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -52,6 +52,48 @@ using sized_uint_t = typename sized_uint::type; using array_double_7 = std::array; +// From pybind11, see +// share/openPMD/thirdParty/pybind11/include/pybind11/detail/common.h +// in the source tree +struct non_const_tag +{}; +struct const_tag +{}; + +namespace detail +{ +template +struct overload_cast_impl +{ + template + constexpr auto operator()(Return (*pf)(Args...)) const noexcept + -> decltype(pf) + { + return pf; + } + + template + constexpr auto + operator()(Return (Class::*pmf)(Args...), non_const_tag = {}) const noexcept + -> decltype(pmf) + { + return pmf; + } + + template + constexpr auto + operator()(Return (Class::*pmf)(Args...) const, const_tag) const noexcept + -> decltype(pmf) + { + return pmf; + } +}; +} // namespace detail + +template +static constexpr ::detail::overload_cast_impl overload_cast{}; +constexpr const_tag const const_; + /** * Generalizes the repeated application of a function template for all * scalar openPMD datatypes. From c6f63a1c3b7a571eb848b67f193584268a53b410 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 1 Aug 2023 13:58:15 -0400 Subject: [PATCH 72/94] Rename USE_Julia to USE_JULIA --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e20cb1b531..34d9128eb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,7 @@ endfunction() openpmd_option(MPI "Parallel, Multi-Node I/O for clusters" AUTO) openpmd_option(HDF5 "HDF5 backend (.h5 files)" AUTO) openpmd_option(ADIOS2 "ADIOS2 backend (.bp files)" AUTO) -openpmd_option(Julia "Enable Julia bindings" OFF) +openpmd_option(JULIA "Enable Julia bindings" OFF) openpmd_option(PYTHON "Enable Python bindings" AUTO) option(openPMD_INSTALL "Add installation targets" ON) @@ -394,13 +394,13 @@ endif() # TODO: Check if ADIOS2 is parallel when openPMD_HAVE_MPI is ON # External library: libcxxwrap-julia -if(openPMD_USE_Julia) +if(openPMD_USE_JULIA) find_package(JlCxx 0.8.3 REQUIRED) - set(openPMD_HAVE_Julia TRUE) + set(openPMD_HAVE_JULIA TRUE) else() - set(openPMD_HAVE_Julia FALSE) + set(openPMD_HAVE_JULIA FALSE) endif() -if(openPMD_HAVE_Julia) +if(openPMD_HAVE_JULIA) get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") @@ -613,7 +613,7 @@ else() endif() # Julia bindings -if(openPMD_HAVE_Julia) +if(openPMD_HAVE_JULIA) add_library(openPMD.jl SHARED src/binding/julia/Access.cpp src/binding/julia/Attributable.cpp @@ -1103,7 +1103,7 @@ if(openPMD_INSTALL) endforeach() endif() - if(openPMD_HAVE_Julia) + if(openPMD_HAVE_JULIA) list(APPEND openPMD_INSTALL_TARGET_NAMES openPMD.jl) endif() From f7e4424627e1e1f8ff571b2abb2262bfa35fa514 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 1 Aug 2023 13:58:39 -0400 Subject: [PATCH 73/94] Add copyright comments to Julia bindings --- src/binding/julia/Access.cpp | 6 +++++- src/binding/julia/Attributable.cpp | 6 +++++- src/binding/julia/Attribute.cpp | 6 +++++- src/binding/julia/BaseRecordComponent.cpp | 6 +++++- src/binding/julia/ChunkInfo.cpp | 6 +++++- src/binding/julia/Container.cpp | 6 ++++++ src/binding/julia/Container.hpp | 6 ++++++ src/binding/julia/Dataset.cpp | 6 +++++- src/binding/julia/Datatype.cpp | 6 +++++- src/binding/julia/Format.cpp | 6 +++++- src/binding/julia/Iteration.cpp | 6 +++++- src/binding/julia/Mesh.cpp | 6 +++++- src/binding/julia/MeshRecordComponent.cpp | 6 +++++- src/binding/julia/ReadIterations.cpp | 6 +++++- src/binding/julia/RecordComponent.cpp | 6 +++++- src/binding/julia/RecordComponent_load_chunk.cpp | 6 +++++- src/binding/julia/RecordComponent_make_constant.cpp | 6 +++++- src/binding/julia/RecordComponent_store_chunk.cpp | 6 +++++- src/binding/julia/Series.cpp | 11 +++++++---- src/binding/julia/UnitDimension.cpp | 6 +++++- src/binding/julia/WriteIterations.cpp | 6 +++++- src/binding/julia/defs.hpp | 6 ++++++ src/binding/julia/openPMD.cpp | 6 ++++++ src/binding/julia/shared_ptr.cpp | 6 +++++- src/binding/julia/version.cpp | 6 +++++- 25 files changed, 131 insertions(+), 24 deletions(-) diff --git a/src/binding/julia/Access.cpp b/src/binding/julia/Access.cpp index 9c76401cab..b317401e8d 100644 --- a/src/binding/julia/Access.cpp +++ b/src/binding/julia/Access.cpp @@ -1,4 +1,8 @@ -// IO/Access +/* Bindings for IO/Access + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 26aaabd54e..5ae68f764d 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -1,4 +1,8 @@ -// Attributable +/* Bindings for Attributable + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index 6d55e4ae49..cacda12faf 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -1,4 +1,8 @@ -// Attribute +/* Bindings for Attribute + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/BaseRecordComponent.cpp b/src/binding/julia/BaseRecordComponent.cpp index 05c7a41b09..e2ddda708e 100644 --- a/src/binding/julia/BaseRecordComponent.cpp +++ b/src/binding/julia/BaseRecordComponent.cpp @@ -1,4 +1,8 @@ -// BaseRecordComponent +/* Bindings for BaseRecordComponent + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/ChunkInfo.cpp b/src/binding/julia/ChunkInfo.cpp index 86fe6f13f9..322fb996b0 100644 --- a/src/binding/julia/ChunkInfo.cpp +++ b/src/binding/julia/ChunkInfo.cpp @@ -1,4 +1,8 @@ -// ChunkInfo +/* Bindings for ChunkInfo + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Container.cpp b/src/binding/julia/Container.cpp index ab2fc2cb18..66e8729319 100644 --- a/src/binding/julia/Container.cpp +++ b/src/binding/julia/Container.cpp @@ -1,3 +1,9 @@ +/* Bindings for Container + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ + #include "Container.hpp" std::unique_ptr julia_Container_type; diff --git a/src/binding/julia/Container.hpp b/src/binding/julia/Container.hpp index 0db492542d..ba973bafc0 100644 --- a/src/binding/julia/Container.hpp +++ b/src/binding/julia/Container.hpp @@ -1,3 +1,9 @@ +/* Bindings for Container + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ + #ifndef CONTAINER_HPP #define CONTAINER_HPP diff --git a/src/binding/julia/Dataset.cpp b/src/binding/julia/Dataset.cpp index 8ac8da2854..14fbbd20b6 100644 --- a/src/binding/julia/Dataset.cpp +++ b/src/binding/julia/Dataset.cpp @@ -1,4 +1,8 @@ -// Dataset +/* Bindings for Datset + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index addda0776c..ce3fe6212f 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -1,4 +1,8 @@ -// Datatype +/* Bindings for Datatype + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Format.cpp b/src/binding/julia/Format.cpp index 98337cbd7e..083cc52ff7 100644 --- a/src/binding/julia/Format.cpp +++ b/src/binding/julia/Format.cpp @@ -1,4 +1,8 @@ -// IO/Format +/* Bindings for IO/Format + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Iteration.cpp b/src/binding/julia/Iteration.cpp index b39b878690..952931d41d 100644 --- a/src/binding/julia/Iteration.cpp +++ b/src/binding/julia/Iteration.cpp @@ -1,4 +1,8 @@ -// Iteration +/* Bindings for Iteration + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Mesh.cpp b/src/binding/julia/Mesh.cpp index 3ed65ef378..f196b761e4 100644 --- a/src/binding/julia/Mesh.cpp +++ b/src/binding/julia/Mesh.cpp @@ -1,4 +1,8 @@ -// Mesh +/* Bindings for Mesh + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 67e253e07e..5b000760d6 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -1,4 +1,8 @@ -// MeshRecordComponent +/* Bindings for MeshRecordComponent + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/ReadIterations.cpp b/src/binding/julia/ReadIterations.cpp index 3bab96bedb..637b0654ac 100644 --- a/src/binding/julia/ReadIterations.cpp +++ b/src/binding/julia/ReadIterations.cpp @@ -1,4 +1,8 @@ -// ReadIterations +/* Bindings for ReadIterations + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/RecordComponent.cpp b/src/binding/julia/RecordComponent.cpp index acd3ec1a10..a938e1515f 100644 --- a/src/binding/julia/RecordComponent.cpp +++ b/src/binding/julia/RecordComponent.cpp @@ -1,4 +1,8 @@ -// RecordComponent +/* Bindings for RecordComponent + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index f1f0900071..12d0c8876e 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -1,4 +1,8 @@ -// RecordComponent_load_chunk +/* Bindings for RecordComponent::load_chunk + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 41e9a81670..68f5384cef 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -1,4 +1,8 @@ -// RecordComponent_make_constant +/* Bindings for RecordComponent::make_constant + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 761b139c2b..2fc3ecf544 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -1,4 +1,8 @@ -// RecordComponent_store_chunk +/* Bindings for RecordComponent::store_chunk + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index 2c4ee53a33..cbf236b263 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -1,4 +1,8 @@ -// Series +/* Bindings for Series + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" @@ -27,7 +31,6 @@ struct SuperType void define_julia_Series(jlcxx::Module &mod) { - // Series auto type = mod.add_type( @@ -78,8 +81,8 @@ void define_julia_Series(jlcxx::Module &mod) type.method("cxx_software", &Series::software); type.method( "cxx_set_software!", - static_cast( + static_cast( &Series::setSoftware)); type.method( "cxx_set_software!", diff --git a/src/binding/julia/UnitDimension.cpp b/src/binding/julia/UnitDimension.cpp index eaea8b4db2..57fd1e7c44 100644 --- a/src/binding/julia/UnitDimension.cpp +++ b/src/binding/julia/UnitDimension.cpp @@ -1,4 +1,8 @@ -// IO/UnitDimension +/* Bindings for IO/UnitDimension + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/WriteIterations.cpp b/src/binding/julia/WriteIterations.cpp index dd4a039ed8..d4f31c51a2 100644 --- a/src/binding/julia/WriteIterations.cpp +++ b/src/binding/julia/WriteIterations.cpp @@ -1,4 +1,8 @@ -// WriteIterations +/* Bindings for WriteIterations + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index 5be29cc08a..97bac41ec2 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -1,3 +1,9 @@ +/* General definitions + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ + #ifndef DEFS_HPP #define DEFS_HPP diff --git a/src/binding/julia/openPMD.cpp b/src/binding/julia/openPMD.cpp index 0e96b8a1d4..d90e432847 100644 --- a/src/binding/julia/openPMD.cpp +++ b/src/binding/julia/openPMD.cpp @@ -1,3 +1,9 @@ +/* Main file for Julia bindings + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ + #include "defs.hpp" #include "Container.hpp" diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp index b735f7ccb5..69c8808fbc 100644 --- a/src/binding/julia/shared_ptr.cpp +++ b/src/binding/julia/shared_ptr.cpp @@ -1,4 +1,8 @@ -// shared_ptr +/* Bindings for std::shared_ptr + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" diff --git a/src/binding/julia/version.cpp b/src/binding/julia/version.cpp index f3446e73fd..3ac339e40d 100644 --- a/src/binding/julia/version.cpp +++ b/src/binding/julia/version.cpp @@ -1,4 +1,8 @@ -// version +/* Bindings for version + * + * File authors: Erik Schnetter + * License: LGPL-3.0-or-later + */ #include "defs.hpp" From 21cecd42cf85958629b6f15e6e398107ebaed573 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 1 Aug 2023 13:58:57 -0400 Subject: [PATCH 74/94] CI: Update USE_JULIA config option --- .github/workflows/linux.yml | 2 +- .github/workflows/macos.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d43f8937c4..876a68bfbc 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -257,7 +257,7 @@ jobs: share/openPMD/download_samples.sh build cmake -S . -B build \ -DopenPMD_USE_HDF5=ON \ - -DopenPMD_USE_Julia=ON \ + -DopenPMD_USE_JULIA=ON \ -DopenPMD_USE_MPI=ON \ -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b247cbc63d..d3ff711d67 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -43,7 +43,7 @@ jobs: cmake -S . -B build \ -DopenPMD_USE_ADIOS2=ON \ -DopenPMD_USE_HDF5=ON \ - -DopenPMD_USE_Julia=ON \ + -DopenPMD_USE_JULIA=ON \ -DopenPMD_USE_MPI=ON \ -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON From 8dc4076a36dbef36d16dec7f0b2dda40eafbed28 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:01:01 +0000 Subject: [PATCH 75/94] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/binding/julia/Series.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/binding/julia/Series.cpp b/src/binding/julia/Series.cpp index cbf236b263..b6fe058523 100644 --- a/src/binding/julia/Series.cpp +++ b/src/binding/julia/Series.cpp @@ -81,8 +81,8 @@ void define_julia_Series(jlcxx::Module &mod) type.method("cxx_software", &Series::software); type.method( "cxx_set_software!", - static_cast( + static_cast( &Series::setSoftware)); type.method( "cxx_set_software!", From 8fb74b98f7327fb5b864d5e3437bc33c23d6a344 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 2 Aug 2023 14:13:25 -0400 Subject: [PATCH 76/94] Add minimal Julia example --- src/binding/julia/tests/minimal_example.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/binding/julia/tests/minimal_example.jl diff --git a/src/binding/julia/tests/minimal_example.jl b/src/binding/julia/tests/minimal_example.jl new file mode 100644 index 0000000000..0734a80ad9 --- /dev/null +++ b/src/binding/julia/tests/minimal_example.jl @@ -0,0 +1,11 @@ +module openPMD +using CxxWrap +@wrapmodule("build/libopenPMD.jl") +__init__() = @initcxx +end + +Base.getindex(cont::openPMD.CXX_Container, index::Integer) = openPMD.cxx_getindex(cont, index) + +series = openPMD.CXX_Series("sample.json", openPMD.ACCESS_CREATE) +openPMD.cxx_iterations(series)[100] +openPMD.cxx_flush(series, "{}") From ddf4fbc57be3424904d8d81dd048389d7eee1414 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 2 Aug 2023 14:13:36 -0400 Subject: [PATCH 77/94] CI: Run Julia self-tests --- .github/workflows/linux.yml | 1 + .github/workflows/macos.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 876a68bfbc..367d94585b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,6 +263,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure + /usr/local/julia-1.6.7/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: runs-on: ubuntu-20.04 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d3ff711d67..7379138b5a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -49,6 +49,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 3 ctest --test-dir build --verbose + julia src/binding/julia/tests/minimal_example.jl appleclang13_py: runs-on: macos-11 From 2ee34a0e0d7140be22723a47c7b12aff0bce0cd0 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 2 Aug 2023 15:23:30 -0400 Subject: [PATCH 78/94] CI: Install CxxWrap for Julia tests --- .github/workflows/linux.yml | 1 + .github/workflows/macos.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 367d94585b..b3ce539740 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,6 +263,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure + /usr/local/julia-1.6.7/bin/julia --eval 'using Pkg; Pkg.install("CxxWrap")' /usr/local/julia-1.6.7/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7379138b5a..00b8cce6bb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -49,6 +49,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 3 ctest --test-dir build --verbose + julia --eval 'using Pkg; Pkg.install("CxxWrap")' julia src/binding/julia/tests/minimal_example.jl appleclang13_py: From a17a10d04cac5f873bec4634cd416b87e0774434 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 2 Aug 2023 16:09:04 -0400 Subject: [PATCH 79/94] CI: Install CxxWrap for Julia tests --- .github/workflows/linux.yml | 2 +- .github/workflows/macos.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b3ce539740..b4b6ca1aef 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,7 +263,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure - /usr/local/julia-1.6.7/bin/julia --eval 'using Pkg; Pkg.install("CxxWrap")' + /usr/local/julia-1.6.7/bin/julia --eval 'using Pkg; Pkg.add("CxxWrap")' /usr/local/julia-1.6.7/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 00b8cce6bb..6a868d1df9 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -49,7 +49,7 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 3 ctest --test-dir build --verbose - julia --eval 'using Pkg; Pkg.install("CxxWrap")' + julia --eval 'using Pkg; Pkg.add("CxxWrap")' julia src/binding/julia/tests/minimal_example.jl appleclang13_py: From 5229a573c56b3432725256d243fdc8ff1406910d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 3 Aug 2023 10:34:08 -0400 Subject: [PATCH 80/94] CI: Switch to Julia 1.7 --- .github/workflows/linux.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b4b6ca1aef..f323d2d51d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -242,15 +242,16 @@ jobs: sudo apt-get install g++ libopenmpi-dev libhdf5-openmpi-dev python3 python3-numpy python3-mpi4py python3-pandas # TODO ADIOS2 # Install Julia - wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz - sudo tar -xz -C /usr/local -f julia-1.6.7-linux-x86_64.tar.gz - rm julia-1.6.7-linux-x86_64.tar.gz + # 1.6.7 + wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz + sudo tar -xz -C /usr/local -f julia-1.7.3-linux-x86_64.tar.gz + rm julia-1.7.3-linux-x86_64.tar.gz # Install cmake-easyinstall sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY sudo chmod a+x /usr/local/bin/cmake-easyinstall export CEI_SUDO="sudo" # Install libcxxwrap-julia - cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.7 -DJulia_EXECUTABLE=/usr/local/julia-1.6.7/bin/julia + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.7 -DJulia_EXECUTABLE=/usr/local/julia-1.7.3/bin/julia - name: Build env: {CXXFLAGS: -Werror, PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig} run: | @@ -263,8 +264,8 @@ jobs: -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure - /usr/local/julia-1.6.7/bin/julia --eval 'using Pkg; Pkg.add("CxxWrap")' - /usr/local/julia-1.6.7/bin/julia src/binding/julia/tests/minimal_example.jl + /usr/local/julia-1.7.3/bin/julia --eval 'using Pkg; Pkg.add("CxxWrap")' + /usr/local/julia-1.7.3/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: runs-on: ubuntu-20.04 From 3b1b37cb22c89ff7309e9fc7a6515d52d67b0da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 10 Aug 2023 16:56:30 +0200 Subject: [PATCH 81/94] Set openPMD.jl library target properties --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc57659d85..694812d3c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -640,6 +640,18 @@ if(openPMD_HAVE_JULIA) ) openpmd_cxx_required(openPMD.jl) target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) + + set_target_properties(openPMD.jl PROPERTIES + COMPILE_PDB_NAME openPMD.jl + ARCHIVE_OUTPUT_DIRECTORY ${openPMD_ARCHIVE_OUTPUT_DIRECTORY} + LIBRARY_OUTPUT_DIRECTORY ${openPMD_LIBRARY_OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY ${openPMD_RUNTIME_OUTPUT_DIRECTORY} + PDB_OUTPUT_DIRECTORY ${openPMD_PDB_OUTPUT_DIRECTORY} + COMPILE_PDB_OUTPUT_DIRECTORY ${openPMD_COMPILE_PDB_OUTPUT_DIRECTORY} + + POSITION_INDEPENDENT_CODE ON + WINDOWS_EXPORT_ALL_SYMBOLS ON + ) endif() # python bindings From 19184646d32b8bf1bcf0ad118da9a51fe271501a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 10 Aug 2023 17:39:59 +0200 Subject: [PATCH 82/94] Add low-level Julia test --- CMakeLists.txt | 8 ++++++++ test/julia/lowlevel_test.jl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/julia/lowlevel_test.jl diff --git a/CMakeLists.txt b/CMakeLists.txt index 694812d3c2..fac3331b87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -652,6 +652,14 @@ if(openPMD_HAVE_JULIA) POSITION_INDEPENDENT_CODE ON WINDOWS_EXPORT_ALL_SYMBOLS ON ) + + add_test(NAME CLI.julia_lowlevel + COMMAND julia + ${openPMD_SOURCE_DIR}/test/julia/lowlevel_test.jl + ${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl.so + WORKING_DIRECTORY + ${openPMD_RUNTIME_OUTPUT_DIRECTORY} + ) endif() # python bindings diff --git a/test/julia/lowlevel_test.jl b/test/julia/lowlevel_test.jl new file mode 100644 index 0000000000..7d4e5922e1 --- /dev/null +++ b/test/julia/lowlevel_test.jl @@ -0,0 +1,35 @@ +import Base + +# pass as first argument the path to libopenPMD.jl.so + +module openPMD +using CxxWrap +@wrapmodule(ARGS[1]) + +function __init__() + @initcxx +end +end + +s = openPMD.CXX_Series( + "../samples/lowlevel_julia_test.json", openPMD.ACCESS_CREATE) + +function Base.getindex( + cont::Cont, + index, +) where +{ + A, + B, + Cont<:openPMD.CXX_Container{A,B} +} + return openPMD.cxx_getindex(cont, index) +end + +iteration = openPMD.cxx_iterations(s)[100] +mesh = openPMD.cxx_meshes(iteration) +# empty brackets to dereference CxxRef +# automatic dereferencing works only for Int types since CxxRwap.jl defines +# Base.getindex(x::CxxBaseRef, i::Int) = Base.getindex(x[], i) +mesh[]["E"][]["x"] +openPMD.cxx_flush(s, "{}") From c6fe8742f426d8aa4b9751bd78c4a9becafc83b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 11 Aug 2023 11:00:30 +0200 Subject: [PATCH 83/94] Install CxxWrap Julia package and fix CI run --- .github/workflows/linux.yml | 4 ++-- src/binding/julia/tests/minimal_example.jl | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 src/binding/julia/tests/minimal_example.jl diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ed82bea1b3..b9fa7b4f0b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,9 +263,9 @@ jobs: -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 + # Install the Julia side of CxxWrap + julia --eval 'using Pkg; Pkg.add("CxxWrap")' ctest --test-dir build --output-on-failure - /usr/local/julia-1.7.3/bin/julia --eval 'using Pkg; Pkg.add("CxxWrap")' - /usr/local/julia-1.7.3/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: runs-on: ubuntu-20.04 diff --git a/src/binding/julia/tests/minimal_example.jl b/src/binding/julia/tests/minimal_example.jl deleted file mode 100644 index 0734a80ad9..0000000000 --- a/src/binding/julia/tests/minimal_example.jl +++ /dev/null @@ -1,11 +0,0 @@ -module openPMD -using CxxWrap -@wrapmodule("build/libopenPMD.jl") -__init__() = @initcxx -end - -Base.getindex(cont::openPMD.CXX_Container, index::Integer) = openPMD.cxx_getindex(cont, index) - -series = openPMD.CXX_Series("sample.json", openPMD.ACCESS_CREATE) -openPMD.cxx_iterations(series)[100] -openPMD.cxx_flush(series, "{}") From d548c9036970aebff02d6e400ea8aa4675192eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 11 Aug 2023 11:00:30 +0200 Subject: [PATCH 84/94] Install CxxWrap Julia package and fix CI run --- .github/workflows/linux.yml | 4 ++-- .github/workflows/macos.yml | 4 ++-- src/binding/julia/tests/minimal_example.jl | 11 ----------- 3 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 src/binding/julia/tests/minimal_example.jl diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ed82bea1b3..b9fa7b4f0b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,9 +263,9 @@ jobs: -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 2 + # Install the Julia side of CxxWrap + julia --eval 'using Pkg; Pkg.add("CxxWrap")' ctest --test-dir build --output-on-failure - /usr/local/julia-1.7.3/bin/julia --eval 'using Pkg; Pkg.add("CxxWrap")' - /usr/local/julia-1.7.3/bin/julia src/binding/julia/tests/minimal_example.jl musllinux_py10: runs-on: ubuntu-20.04 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 1cf37b3377..7f4962760a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -49,9 +49,9 @@ jobs: -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_INVASIVE_TESTS=ON cmake --build build --parallel 3 - ctest --test-dir build --verbose + # Install the Julia side of CxxWrap julia --eval 'using Pkg; Pkg.add("CxxWrap")' - julia src/binding/julia/tests/minimal_example.jl + ctest --test-dir build --verbose appleclang13_py: runs-on: macos-11 diff --git a/src/binding/julia/tests/minimal_example.jl b/src/binding/julia/tests/minimal_example.jl deleted file mode 100644 index 0734a80ad9..0000000000 --- a/src/binding/julia/tests/minimal_example.jl +++ /dev/null @@ -1,11 +0,0 @@ -module openPMD -using CxxWrap -@wrapmodule("build/libopenPMD.jl") -__init__() = @initcxx -end - -Base.getindex(cont::openPMD.CXX_Container, index::Integer) = openPMD.cxx_getindex(cont, index) - -series = openPMD.CXX_Series("sample.json", openPMD.ACCESS_CREATE) -openPMD.cxx_iterations(series)[100] -openPMD.cxx_flush(series, "{}") From d427b1917ab8f40b14b2f21ac015e21ec018097a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 18 Aug 2023 14:44:33 +0200 Subject: [PATCH 85/94] Update RPATH setting to generalized method --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac3331b87..6a5e4258aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,6 @@ endif() if(openPMD_HAVE_JULIA) get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION) get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") message(STATUS "Found JlCxx version ${JlCxx_VERSION} at ${JlCxx_location}") endif() @@ -1133,6 +1132,9 @@ if(openPMD_INSTALL) if(openPMD_HAVE_PYTHON) list(APPEND openPMD_INSTALL_RPATH_TARGET_NAMES openPMD.py) endif() + if(openPMD_HAVE_JULIA) + list(APPEND openPMD_INSTALL_RPATH_TARGET_NAMES openPMD.jl) + endif() if(NOT DEFINED CMAKE_INSTALL_RPATH) if(APPLE) set_target_properties(${openPMD_INSTALL_RPATH_TARGET_NAMES} PROPERTIES From d59773adf3cd9a27fe148c535d94e25aa5709a5a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 5 Sep 2023 18:18:40 -0400 Subject: [PATCH 86/94] Don't export openPMD_datatypes to Julia --- src/binding/julia/Datatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 47dcc21442..555caba892 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -28,7 +28,7 @@ void define_julia_Datatype(jlcxx::Module &mod) mod.set_const("UNDEFINED", Datatype::UNDEFINED); - mod.set_const("openPMD_datatypes", openPMD_Datatypes); + // mod.method("openPMD_datatypes", []() { return openPMD_datatypes; }); // mod.method("determine_datatype", determineDatatype); mod.method("cxx_to_bytes", toBytes); mod.method("cxx_to_bits", toBits); From 54a5052787543700a255a608ef290f89a9c41017 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 5 Sep 2023 18:35:20 -0400 Subject: [PATCH 87/94] Don't export openPMD_datatypes to Julia --- src/binding/julia/Datatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index 555caba892..c477f362a1 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -28,7 +28,7 @@ void define_julia_Datatype(jlcxx::Module &mod) mod.set_const("UNDEFINED", Datatype::UNDEFINED); - // mod.method("openPMD_datatypes", []() { return openPMD_datatypes; }); + // mod.method("openpmd_datatypes", openPMD_datatypes); // mod.method("determine_datatype", determineDatatype); mod.method("cxx_to_bytes", toBytes); mod.method("cxx_to_bits", toBits); From fa2efa555f97cb7e9a8a9a93c165bbcdc82f956d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 5 Sep 2023 19:36:48 -0400 Subject: [PATCH 88/94] Configure Julia include and library directories --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c8952ca3c..5a3baea13b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,7 +645,9 @@ if(openPMD_HAVE_JULIA) src/binding/julia/version.cpp ) openpmd_cxx_required(openPMD.jl) - target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl) + target_include_directories(openPMD.jl PRIVATE ${Julia_INCLUDE_DIRS}) + target_link_directories(openPMD.jl PRIVATE ${Julia_LIBRARY_DIR}) + target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl ${Julia_LIBRARY}) set_target_properties(openPMD.jl PROPERTIES COMPILE_PDB_NAME openPMD.jl From 5d5612d3158429080b5e9887183f5a6c3120636c Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 5 Sep 2023 19:45:12 -0400 Subject: [PATCH 89/94] Configure Julia include and library directories --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a3baea13b..a28a17fbf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,9 +645,9 @@ if(openPMD_HAVE_JULIA) src/binding/julia/version.cpp ) openpmd_cxx_required(openPMD.jl) - target_include_directories(openPMD.jl PRIVATE ${Julia_INCLUDE_DIRS}) - target_link_directories(openPMD.jl PRIVATE ${Julia_LIBRARY_DIR}) - target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl ${Julia_LIBRARY}) + target_include_directories(openPMD.jl PRIVATE JlCxx::cxxwrap_julia) + target_link_directories(openPMD.jl PRIVATE JlCxx::cxxwrap_julia) + target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia_stl JlCxx::cxxwrap_julia) set_target_properties(openPMD.jl PROPERTIES COMPILE_PDB_NAME openPMD.jl From 9eaec53880c365729d37840a4f788e6a57272385 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 6 Sep 2023 09:39:33 -0400 Subject: [PATCH 90/94] Don't configure Julia include and library directories --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a28a17fbf1..f756a2ade4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,8 +645,6 @@ if(openPMD_HAVE_JULIA) src/binding/julia/version.cpp ) openpmd_cxx_required(openPMD.jl) - target_include_directories(openPMD.jl PRIVATE JlCxx::cxxwrap_julia) - target_link_directories(openPMD.jl PRIVATE JlCxx::cxxwrap_julia) target_link_libraries(openPMD.jl PRIVATE openPMD JlCxx::cxxwrap_julia_stl JlCxx::cxxwrap_julia) set_target_properties(openPMD.jl PROPERTIES From cac948869a45b1b5ebeebccc930a805a7ab337a7 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 7 Sep 2023 11:29:00 -0400 Subject: [PATCH 91/94] Julia: Correct `set_const` definitions for `Datatype` enum --- src/binding/julia/Attributable.cpp | 6 +- src/binding/julia/Attribute.cpp | 6 +- src/binding/julia/Datatype.cpp | 11 +- src/binding/julia/MeshRecordComponent.cpp | 6 +- .../julia/RecordComponent_load_chunk.cpp | 8 +- .../julia/RecordComponent_make_constant.cpp | 6 +- .../julia/RecordComponent_store_chunk.cpp | 6 +- src/binding/julia/defs.hpp | 128 +++++++++--------- src/binding/julia/shared_ptr.cpp | 6 +- 9 files changed, 93 insertions(+), 90 deletions(-) diff --git a/src/binding/julia/Attributable.cpp b/src/binding/julia/Attributable.cpp index 3762f20880..50a3609ac5 100644 --- a/src/binding/julia/Attributable.cpp +++ b/src/binding/julia/Attributable.cpp @@ -8,10 +8,10 @@ namespace { -struct UseType +struct method_set_attribute { template - static void call(jlcxx::TypeWrapper type) + void call(jlcxx::TypeWrapper type) const { type.method( "cxx_set_attribute_" + datatypeToString(determineDatatype()) + @@ -25,7 +25,7 @@ void define_julia_Attributable(jlcxx::Module &mod) { auto type = mod.add_type("CXX_Attributable"); - forallJuliaTypes(type); + forallJuliaTypes(method_set_attribute(), type); type.method("cxx_get_attribute", &Attributable::getAttribute); type.method("cxx_delete_attribute!", &Attributable::deleteAttribute); diff --git a/src/binding/julia/Attribute.cpp b/src/binding/julia/Attribute.cpp index 6e13b6efe2..9c15771bbc 100644 --- a/src/binding/julia/Attribute.cpp +++ b/src/binding/julia/Attribute.cpp @@ -8,10 +8,10 @@ namespace { -struct UseType +struct method_get { template - static void call(jlcxx::TypeWrapper type) + void call(jlcxx::TypeWrapper type) const { type.method( "cxx_get_" + datatypeToString(determineDatatype()), @@ -26,5 +26,5 @@ void define_julia_Attribute(jlcxx::Module &mod) type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; }); - forallJuliaTypes(type); + forallJuliaTypes(method_get(), type); } diff --git a/src/binding/julia/Datatype.cpp b/src/binding/julia/Datatype.cpp index c477f362a1..27bd420e4d 100644 --- a/src/binding/julia/Datatype.cpp +++ b/src/binding/julia/Datatype.cpp @@ -8,13 +8,15 @@ namespace { -struct UseType +struct set_const_Datatype { template - static void call(jlcxx::Module &mod) + void call(jlcxx::Module &mod) const { Datatype const dt = determineDatatype(); - mod.set_const(datatypeToString(dt), dt); + // The second argument to `set_const` must be a value and not a + // reference + mod.set_const(datatypeToString(dt), Datatype(dt)); } }; } // namespace @@ -24,8 +26,7 @@ void define_julia_Datatype(jlcxx::Module &mod) mod.add_bits("Datatype", jlcxx::julia_type("CppEnum")); jlcxx::stl::apply_stl(mod); - forallJuliaTypes(mod); - + forallJuliaTypes(set_const_Datatype(), mod); mod.set_const("UNDEFINED", Datatype::UNDEFINED); // mod.method("openpmd_datatypes", openPMD_datatypes); diff --git a/src/binding/julia/MeshRecordComponent.cpp b/src/binding/julia/MeshRecordComponent.cpp index 965af8e269..e23260caf4 100644 --- a/src/binding/julia/MeshRecordComponent.cpp +++ b/src/binding/julia/MeshRecordComponent.cpp @@ -18,10 +18,10 @@ struct SuperType namespace { -struct UseType +struct method_make_constant { template - static void call(jlcxx::TypeWrapper type) + void call(jlcxx::TypeWrapper type) const { type.method( "cxx_make_constant_" + datatypeToString(determineDatatype()), @@ -37,5 +37,5 @@ void define_julia_MeshRecordComponent(jlcxx::Module &mod) type.method("cxx_position", &MeshRecordComponent::position); type.method("cxx_set_position!", &MeshRecordComponent::setPosition); - forallJuliaTypes(type); + forallJuliaTypes(method_make_constant(), type); } diff --git a/src/binding/julia/RecordComponent_load_chunk.cpp b/src/binding/julia/RecordComponent_load_chunk.cpp index 2c057740c6..116eda00a2 100644 --- a/src/binding/julia/RecordComponent_load_chunk.cpp +++ b/src/binding/julia/RecordComponent_load_chunk.cpp @@ -8,13 +8,13 @@ namespace { -struct UseType +struct method_load_chunk { template - static void call(jlcxx::TypeWrapper &type) + void call(jlcxx::TypeWrapper &type) const { type.method( - "cxx_load_" + datatypeToString(determineDatatype()), + "cxx_load_chunk_" + datatypeToString(determineDatatype()), overload_cast, Offset, Extent>( &RecordComponent::loadChunk)); } @@ -24,5 +24,5 @@ struct UseType void define_julia_RecordComponent_load_chunk( jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { - forallScalarJuliaTypes(type); + forallScalarJuliaTypes(method_load_chunk(), type); } diff --git a/src/binding/julia/RecordComponent_make_constant.cpp b/src/binding/julia/RecordComponent_make_constant.cpp index 89b9f7f371..622f3097cf 100644 --- a/src/binding/julia/RecordComponent_make_constant.cpp +++ b/src/binding/julia/RecordComponent_make_constant.cpp @@ -8,10 +8,10 @@ namespace { -struct UseType +struct method_make_constant { template - static void call(jlcxx::TypeWrapper &type) + void call(jlcxx::TypeWrapper &type) const { type.method( "cxx_make_constant_" + datatypeToString(determineDatatype()), @@ -23,5 +23,5 @@ struct UseType void define_julia_RecordComponent_make_constant( jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { - forallScalarJuliaTypes(type); + forallScalarJuliaTypes(method_make_constant(), type); } diff --git a/src/binding/julia/RecordComponent_store_chunk.cpp b/src/binding/julia/RecordComponent_store_chunk.cpp index 3f46b71499..355c42045a 100644 --- a/src/binding/julia/RecordComponent_store_chunk.cpp +++ b/src/binding/julia/RecordComponent_store_chunk.cpp @@ -8,10 +8,10 @@ namespace { -struct UseType +struct method_store_chunk { template - static void call(jlcxx::TypeWrapper &type) + void call(jlcxx::TypeWrapper &type) const { type.method( "cxx_store_chunk_" + datatypeToString(determineDatatype()), @@ -24,5 +24,5 @@ struct UseType void define_julia_RecordComponent_store_chunk( jlcxx::Module & /*mod*/, jlcxx::TypeWrapper &type) { - forallScalarJuliaTypes(type); + forallScalarJuliaTypes(method_store_chunk(), type); } diff --git a/src/binding/julia/defs.hpp b/src/binding/julia/defs.hpp index f4d7d0a3c0..995224d062 100644 --- a/src/binding/julia/defs.hpp +++ b/src/binding/julia/defs.hpp @@ -110,33 +110,34 @@ constexpr const_tag const const_; * * @tparam Action The struct containing the function template. * @tparam Args The function template's argument types. + * @param action The function template's arguments. * @param args The function template's arguments. */ template -void forallScalarJuliaTypes(Args &&...args) +void forallScalarJuliaTypes(const Action &action, Args &...args) { - // Do NOT call std::forward(args)... here - // Move semantics must be avoided due to repeated application - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); + // Do NOT call `std::forward(args)...` here. + // We must avoid move semantics because we apply repeatedly. + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); // We disable `long double` since Julia does not support this type - // Action::template call(args...); - Action::template call>(args...); - Action::template call>(args...); - // Action::template call>(args...); - Action::template call(args...); - Action::template call(args...); + // action. call(args...); + action.template call>(args...); + action.template call>(args...); + // action. call>(args...); + action.template call(args...); + action.template call(args...); } /** * Generalizes the repeated application of a function template for all @@ -147,52 +148,53 @@ void forallScalarJuliaTypes(Args &&...args) * * @tparam Action The struct containing the function template. * @tparam Args The function template's argument types. + * @param action The function template's arguments. * @param args The function template's arguments. */ template -void forallJuliaTypes(Args &&...args) +void forallJuliaTypes(const Action &action, Args &...args) { - // Do NOT call std::forward(args)... here - // Move semantics must be avoided due to repeated application - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); - Action::template call(args...); + // Do NOT call `std::forward(args)...` here. + // We must avoid move semantics because we apply repeatedly. + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); + action.template call(args...); // We disable `long double` since Julia does not support this type - // Action::template call(args...); - Action::template call>(args...); - Action::template call>(args...); - // Action::template call>(args...); - Action::template call(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call>(args...); - // Action::template call>(args...); - Action::template call>>(args...); - Action::template call>>(args...); - // Action::template call>>(args...); - Action::template call>(args...); - Action::template call>(args...); - Action::template call(args...); + // action.template call (args...); + action.template call>(args...); + action.template call>(args...); + // action.template call >(args...); + action.template call(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call>(args...); + // action.template call >(args...); + action.template call>>(args...); + action.template call>>(args...); + // action.template call >>(args...); + action.template call>(args...); + action.template call>(args...); + action.template call(args...); } namespace diff --git a/src/binding/julia/shared_ptr.cpp b/src/binding/julia/shared_ptr.cpp index d0fffd69f9..a2a2d240af 100644 --- a/src/binding/julia/shared_ptr.cpp +++ b/src/binding/julia/shared_ptr.cpp @@ -10,10 +10,10 @@ namespace { -struct UseType +struct method_create_aliasing_shared_ptr { template - static void call(jlcxx::Module &mod) + void call(jlcxx::Module &mod) const { mod.method( "create_aliasing_shared_ptr_" + @@ -25,5 +25,5 @@ struct UseType void define_julia_shared_ptr(jlcxx::Module &mod) { - forallScalarJuliaTypes(mod); + forallScalarJuliaTypes(method_create_aliasing_shared_ptr(), mod); } From 5213e2e27e02f2c4880d950347b26fecc0e88659 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 8 Sep 2023 19:09:30 -0400 Subject: [PATCH 92/94] CI: Correct shared library suffix for Apple --- CMakeLists.txt | 2 +- test/julia/lowlevel_test.jl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f756a2ade4..c1091d0cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -662,7 +662,7 @@ if(openPMD_HAVE_JULIA) add_test(NAME CLI.julia_lowlevel COMMAND julia ${openPMD_SOURCE_DIR}/test/julia/lowlevel_test.jl - ${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl.so + ${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl WORKING_DIRECTORY ${openPMD_RUNTIME_OUTPUT_DIRECTORY} ) diff --git a/test/julia/lowlevel_test.jl b/test/julia/lowlevel_test.jl index 7d4e5922e1..126bd7e990 100644 --- a/test/julia/lowlevel_test.jl +++ b/test/julia/lowlevel_test.jl @@ -1,10 +1,12 @@ import Base -# pass as first argument the path to libopenPMD.jl.so +# pass as first argument the path to libopenPMD.jl.so but without the ".so" suffix module openPMD using CxxWrap -@wrapmodule(ARGS[1]) +dlext = Sys.isapple() ? ".dylib" : ".so" +libname = "$(ARGS[f1])$dlext" +@wrapmodule libname function __init__() @initcxx From 805756ff9b12b47d93dfb6c57e4aa199db9de395 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 8 Sep 2023 20:01:55 -0400 Subject: [PATCH 93/94] Julia: Correct low-level test --- test/julia/lowlevel_test.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/julia/lowlevel_test.jl b/test/julia/lowlevel_test.jl index 126bd7e990..65348a0d39 100644 --- a/test/julia/lowlevel_test.jl +++ b/test/julia/lowlevel_test.jl @@ -4,8 +4,8 @@ import Base module openPMD using CxxWrap -dlext = Sys.isapple() ? ".dylib" : ".so" -libname = "$(ARGS[f1])$dlext" +dlext = Sys.isapple() ? "dylib" : "so" +libname = "$(ARGS[1]).$dlext" @wrapmodule libname function __init__() From a0b015ead2ec85e7a55805c5df5d20367afb51bd Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 8 Sep 2023 20:45:55 -0400 Subject: [PATCH 94/94] CI: Install libcxxwrap-julia @v0.11.0 --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7f4962760a..da537d26f7 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -32,7 +32,7 @@ jobs: sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY sudo chmod a+x /usr/local/bin/cmake-easyinstall # Install libcxxwrap-julia - cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.9.7 + cmake-easyinstall git+https://github.com/JuliaInterop/libcxxwrap-julia.git@v0.11.0 - name: Build env: {CXXFLAGS: -Werror, MACOSX_DEPLOYMENT_TARGET: 11.0} # 10.14+ due to std::visit