From 3f33d0647e621c65961094e1398f14c7e89a7dee Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Wed, 18 Dec 2024 11:07:28 -0500 Subject: [PATCH] introduced madness:is_trivially_copyable trait (can be specialized to override legally-required limitations of std::is_trivially_copyable) --- src/madness/world/type_traits.h | 7 +++++++ src/madness/world/worldgop.h | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/madness/world/type_traits.h b/src/madness/world/type_traits.h index c04fa9ea8fa..864384b8a71 100644 --- a/src/madness/world/type_traits.h +++ b/src/madness/world/type_traits.h @@ -213,6 +213,13 @@ namespace madness { template struct is_any_function_pointer::value || is_function_pointer_v>> : public std::true_type {}; template constexpr bool is_any_function_pointer_v = is_any_function_pointer::value; + /// trait for trivial (=bitwise) copyability of T, defaults to std::is_trivially_copyable but can be specialized as needed + template + struct is_trivially_copyable : std::is_trivially_copyable {}; + + template + inline constexpr bool is_trivially_copyable_v = is_trivially_copyable::value; + /// This defines stuff that is serializable by bitwise copy. /// \warning This reports true for \c T that is an aggregate type /// (struct or array) that includes pointers. diff --git a/src/madness/world/worldgop.h b/src/madness/world/worldgop.h index 20b9c90299d..77f2ecb00b9 100644 --- a/src/madness/world/worldgop.h +++ b/src/madness/world/worldgop.h @@ -730,19 +730,19 @@ namespace madness { /// Broadcasts typed contiguous data from process root while still processing AM & tasks /// Optimizations can be added for long messages - template >> + template >> inline void broadcast(T* buf, size_t nelem, ProcessID root) { broadcast((void *) buf, nelem*sizeof(T), root); } /// Broadcast of a scalar from node 0 to all other nodes - template >> + template >> void broadcast(T& t) { broadcast(&t, 1, 0); } /// Broadcast of a scalar from node root to all other nodes - template >> + template >> void broadcast(T& t, ProcessID root) { broadcast(&t, 1, root); } @@ -781,7 +781,7 @@ namespace madness { /// Optimizations can be added for long messages and to reduce the memory footprint template void reduce(T* buf, std::size_t nelem, opT op) { - static_assert(std::is_trivially_copyable_v, "T must be trivially copyable"); + static_assert(madness::is_trivially_copyable_v, "T must be trivially copyable"); ProcessID parent, child0, child1; world_.mpi.binary_tree_info(0, parent, child0, child1);