ttg 1.0.0
Template Task Graph (TTG): flowgraph-based programming model for high-performance distributed-memory algorithms
Loading...
Searching...
No Matches
madness.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// Created by Eduard Valeyev on 5/3/21.
4//
5
6#ifndef TTG_SERIALIZATION_MADNESS_H
7#define TTG_SERIALIZATION_MADNESS_H
8
9#include <type_traits>
10
11#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
12#include <madness/world/archive.h>
13#include <madness/world/buffer_archive.h>
14#include <madness/world/type_traits.h>
15#endif
16
18
19namespace ttg::detail {
20
21 /*----- if_madness_{input,output,}_archive_v -----*/
22
23#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
24 template <typename T>
25 inline constexpr bool is_madness_archive_v = madness::is_archive_v<T>;
26 template <typename T>
27 inline constexpr bool is_madness_input_archive_v = madness::is_input_archive_v<T>;
28
29 template <typename T>
30 inline constexpr bool is_madness_output_archive_v = madness::is_output_archive_v<T>;
31
32 /*----- is_archive_v for madness archives -----*/
33 template <typename T>
34 inline constexpr bool is_archive_v<T, std::enable_if_t<is_madness_archive_v<T>>> = true;
35 template <typename T>
36 inline constexpr bool is_input_archive_v<T, std::enable_if_t<is_madness_input_archive_v<T>>> = true;
37 template <typename T>
38 inline constexpr bool is_output_archive_v<T, std::enable_if_t<is_madness_output_archive_v<T>>> = true;
39
40#else // TTG_SERIALIZATION_SUPPORTS_MADNESS
41 template <typename T>
42 inline constexpr bool is_madness_archive_v = false;
43 template <typename T>
44 inline constexpr bool is_madness_input_archive_v = false;
45 template <typename T>
46 inline constexpr bool is_madness_output_archive_v = false;
47#endif // TTG_SERIALIZATION_SUPPORTS_MADNESS
48
49 /*----- is_madness_{input,output}_serializable_v -----*/
50
51 template <typename Archive, typename T, class = void>
52 struct is_madness_output_serializable : std::false_type {};
53
54#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
55 template <typename Archive, typename T>
57 Archive, T, std::enable_if_t<madness::is_output_archive_v<Archive> && madness::is_serializable_v<Archive, T>>>
58 : std::true_type {};
59#endif // TTG_SERIALIZATION_SUPPORTS_MADNESS
60
61 template <typename Archive, typename T>
62 inline static constexpr bool is_madness_output_serializable_v = is_madness_output_serializable<Archive, T>::value;
63
64 template <typename Archive, typename T, class = void>
65 struct is_madness_input_serializable : std::false_type {};
66
67#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
68 template <typename Archive, typename T>
70 Archive, T, std::enable_if_t<madness::is_input_archive_v<Archive> && madness::is_serializable_v<Archive, T>>>
71 : std::true_type {};
72#endif // TTG_SERIALIZATION_SUPPORTS_MADNESS
73
74 template <typename Archive, typename T>
75 inline static constexpr bool is_madness_input_serializable_v = is_madness_input_serializable<Archive, T>::value;
76
77 template <typename Archive, typename T>
78 inline static constexpr bool is_madness_serializable_v =
79 is_madness_input_serializable_v<Archive, T> || is_madness_output_serializable_v<Archive, T>;
80
81 template <typename T, class = void>
82 struct is_madness_buffer_serializable : std::false_type {};
83
84#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
85 template <typename T>
87 T, std::enable_if_t<is_madness_input_serializable_v<madness::archive::BufferInputArchive, T> &&
88 is_madness_output_serializable_v<madness::archive::BufferOutputArchive, T>>>
89 : std::true_type {};
90#endif
91
93 template <typename T>
95
96 template <typename T, class = void>
97 struct is_madness_user_buffer_serializable : std::false_type {};
98
99#ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
100 template <typename T>
102 T, std::enable_if_t<madness::is_user_serializable_v<madness::archive::BufferInputArchive, T> &&
103 madness::is_user_serializable_v<madness::archive::BufferOutputArchive, T>>> : std::true_type {
104 };
105#endif
106
108 template <typename T>
110
111} // namespace ttg::detail
112
113#endif // TTG_SERIALIZATION_MADNESS_H
STL namespace.
constexpr bool is_madness_output_archive_v
Definition madness.h:46
constexpr bool is_madness_archive_v
Definition madness.h:42
constexpr bool is_madness_input_archive_v
Definition madness.h:44
constexpr bool is_madness_user_buffer_serializable_v
evaluates to true if can serialize T to/from buffer using user-provided MADNESS serialization
Definition madness.h:109
constexpr bool is_madness_buffer_serializable_v
evaluates to true if can serialize T to/from buffer using MADNESS serialization
Definition madness.h:94