Skip to content

Commit

Permalink
Merge branch 'master' into fft-functional-programming
Browse files Browse the repository at this point in the history
  • Loading branch information
alfC committed Mar 8, 2025
2 parents b3be162 + 86ecd32 commit 84c51d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
22 changes: 11 additions & 11 deletions include/boost/multi/array_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,13 +1851,13 @@ struct const_subarray : array_types<T, D, ElementPtr, Layout> {
}

template<class Archive>
auto serialize(Archive& arxiv, unsigned int version) const {
auto serialize(Archive& arxiv, unsigned int /*version*/) {
using AT = multi::archive_traits<Archive>;
if(version == 0) {
std::for_each(this->begin(), this->end(), [&](reference&& item) {arxiv & AT ::make_nvp("item", std::move(item));});
} else {
std::for_each(this->elements().begin(), this->elements().end(), [&](element& elem) {arxiv & AT ::make_nvp("elem", elem);});
}
// if(version == 0) {
// std::for_each(this->begin(), this->end(), [&](reference&& item) {arxiv & AT ::make_nvp("item", std::move(item));});
// } else {
std::for_each(this->elements().begin(), this->elements().end(), [&](element const& elem) {arxiv & AT ::make_nvp("elem", elem);});
// }
// std::for_each(this->begin(), this->end(), [&](auto&& item) {arxiv & cereal::make_nvp("item", item);});
// std::for_each(this->begin(), this->end(), [&](auto&& item) {arxiv & item ;});
}
Expand Down Expand Up @@ -2362,13 +2362,13 @@ class subarray : public const_subarray<T, D, ElementPtr, Layout> {
constexpr auto element_moved() && {return element_moved();}

template<class Archive>
auto serialize(Archive& arxiv, unsigned int version) {
auto serialize(Archive& arxiv, unsigned int /*version*/) {
using AT = multi::archive_traits<Archive>;
if(version == 0) {
std::for_each(this->begin(), this->end(), [&](typename subarray::reference item) {arxiv & AT ::make_nvp("item", item);});
} else {
// if(version == 0) {
// std::for_each(this->begin(), this->end(), [&](typename subarray::reference item) {arxiv & AT ::make_nvp("item", item);});
// } else {
std::for_each(this->elements().begin(), this->elements().end(), [&](typename subarray::element& elem) {arxiv & AT ::make_nvp("elem", elem);});
}
//}
// std::for_each(this->begin(), this->end(), [&](auto&& item) {arxiv & cereal::make_nvp("item", item);});
// std::for_each(this->begin(), this->end(), [&](auto&& item) {arxiv & item ;});
}
Expand Down
10 changes: 7 additions & 3 deletions include/boost/multi/detail/layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ struct extensions_t : boost::multi::detail::tuple_prepend_t<index_extension, typ
constexpr extensions_t(index_extension const& extension, typename layout_t<D-1>::extensions_type const& other)
: extensions_t(multi::detail::ht_tuple(extension, other.base())) {}

constexpr auto base() const& -> base_ const& {return *this;} // impl_;}
constexpr auto base() const& -> base_ const& { return *this; } // impl_;}
constexpr auto base() & -> base_ & { return *this; } // impl_;}

friend constexpr auto operator*(index_extension const& extension, extensions_t const& self) -> extensions_t<D + 1> {
// return extensions_t<D + 1>(tuple(extension, self.base()));
Expand Down Expand Up @@ -292,7 +293,8 @@ template<> struct extensions_t<0> : tuple<> {

extensions_t() = default;

constexpr auto base() const -> base_ const& {return *this;}
constexpr auto base() const& -> base_ const& { return *this; }
constexpr auto base() & -> base_ & { return *this; }

template<class Archive> static void serialize(Archive&/*ar*/, unsigned /*version*/) {/*noop*/}

Expand Down Expand Up @@ -353,7 +355,9 @@ template<> struct extensions_t<1> : tuple<multi::index_extension> {
constexpr explicit extensions_t(base_ tup) : base_{tup} {}

extensions_t() = default;
constexpr auto base() const -> base_ const& {return *this;}

constexpr auto base() const& -> base_ const& { return *this; }
constexpr auto base() & -> base_ & { return *this; }

BOOST_MULTI_HD constexpr auto operator==(extensions_t const& other) const -> bool {return base() == other.base();} // when compiling as cuda code, this needs --expt-relaxed-constexpr
BOOST_MULTI_HD constexpr auto operator!=(extensions_t const& other) const -> bool {return base() != other.base();}
Expand Down
6 changes: 5 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ else()
option(CMAKE_COMPILE_WARNING_AS_ERROR "Compile warnings as errors" ON)

find_package(Boost CONFIG)
find_package(Boost COMPONENTS serialization)

if(ENABLE_CUDA)
enable_language(CUDA)
Expand Down Expand Up @@ -339,7 +340,7 @@ else()
*.cpp
)

if((NOT Boost_FOUND) AND (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")))
if(NOT Boost_FOUND)
message(WARNING "Cannot find Boost, Multi library will have a very minimal test. If you want to test the library install Boost.Test, for example please run:\n sudo apt install libboost-test-dev\n sudo dnf install boost-devel")

add_executable(main main.cpp)
Expand Down Expand Up @@ -382,5 +383,8 @@ else()
endif()
add_test(NAME ${TEST_EXE} COMMAND $<TARGET_FILE:${TEST_EXE}>)
endforeach()

# target_link_libraries (serialization.cpp.x PRIVATE Boost::serialization)

endif()
endif()

0 comments on commit 84c51d8

Please sign in to comment.