1313#include < utility>
1414
1515#include < mpiwcpp17/environment.h>
16- #include < mpiwcpp17/flag.hpp>
1716#include < mpiwcpp17/guard.hpp>
1817#include < mpiwcpp17/global.hpp>
1918#include < mpiwcpp17/process.hpp>
@@ -51,23 +50,23 @@ struct window_t : MPIWCPP17_INHERIT_HANDLE(MPI_Win, MPI_Win_free);
5150 * @param B The call block to be wrapped.
5251 */
5352#define MPIWCPP17_WIN_RAII (x ) window_t ((x), true )
54- #define MPIWCPP17_WIN_CALL (B ) MPIWCPP17_WIN_RAII(MPIWCPP17_GUARD_CALL(window_t , B))
53+ #define MPIWCPP17_WIN_CALL (B ) MPIWCPP17_WIN_RAII(MPIWCPP17_GUARD_CALL(MPI_Win , B))
5554
5655namespace window
5756{
5857 /* *
5958 * The invalid or empty window instance.
6059 * This can be used to verify whether a window is not in a valid state or to
6160 * denote an empty or uninitialized window.
62- * @since 3.0
61+ * @since 2.1
6362 */
6463 MPIWCPP17_INLINE const window_t null = MPI_WIN_NULL;
6564
6665 /* *
6766 * Declares window attribute namespace and corresponding functions.
6867 * Attributes are identified by keys that can be used to attach and retrieve
6968 * generic data from window instances.
70- * @since 3.0
69+ * @since 2.1
7170 */
7271 MPIWCPP17_ATTRIBUTE_DECLARE (
7372 window_t
@@ -80,66 +79,66 @@ namespace window
8079 * The window synchronization modes. These modes can be used to specify the type
8180 * of synchronization to be performed on a window when calling the corresponding
8281 * synchronization functions.
83- * @since 3.0
82+ * @since 2.1
8483 */
8584 enum mode_t : int
8685 {
8786 /* *
8887 * No special synchronization mode. This is the default synchronization mode
8988 * for all synchronization functions, no guarantees given whatsoever.
90- * @since 3.0
89+ * @since 2.1
9190 */
9291 none = 0
9392
9493 /* *
9594 * The mode for no preceding RMA operations. This mode indicates that no
9695 * RMA operations will be issued before synchronization.
97- * @since 3.0
96+ * @since 2.1
9897 */
9998 , no_precede = MPI_MODE_NOPRECEDE
10099
101100 /* *
102101 * The mode for no preceding local stores or get calls. This mode indicates
103102 * that no local stores or get calls will be issued before synchronization.
104- * @since 3.0
103+ * @since 2.1
105104 */
106105 , no_store = MPI_MODE_NOSTORE
107106
108107 /* *
109108 * The mode for no updates by any put or accumulate calls. This mode indicates
110109 * that no put or accumulate calls will be performed until the next synchronization.
111- * @since 3.0
110+ * @since 2.1
112111 */
113112 , no_put = MPI_MODE_NOPUT
114113
115114 /* *
116115 * The mode for no succeeding RMA operations. This mode indicates that no
117116 * RMA operations will be issued after synchronization.
118- * @since 3.0
117+ * @since 2.1
119118 */
120119 , no_succeed = MPI_MODE_NOSUCCEED
121120 };
122121
123122 /* *
124123 * The window lock types. These types can be used to specify the type of lock
125124 * to be acquired on a window when calling the corresponding lock functions.
126- * @since 3.0
125+ * @since 2.1
127126 */
128127 enum lock_t : int
129128 {
130129 /* *
131130 * The exclusive lock type. This lock type indicates that the calling process
132131 * will acquire an exclusive lock on the window, which prevents any other
133132 * process from performing access operations on the window.
134- * @since 3.0
133+ * @since 2.1
135134 */
136135 exclusive = MPI_LOCK_EXCLUSIVE
137136
138137 /* *
139138 * The shared lock type. This lock type indicates that the calling process
140139 * will acquire a shared lock on the window, which allows other processes
141140 * to perform access operations as long as they also acquire a shared lock.
142- * @since 3.0
141+ * @since 2.1
143142 */
144143 , shared = MPI_LOCK_SHARED
145144 };
@@ -149,28 +148,22 @@ namespace window
149148 * instance enabling RMA communication. The amount of memory allocated may differ
150149 * between processes and is determined individually by its own parameters.
151150 * @tparam T The type of the elements to store in the allocated memory region.
152- * @tparam G The flag to determine the type of allocated memory.
153151 * @param count The number of elements or bytes to allocate for each process.
154152 * @param comm Communicator allowed for RMA operations with allocated memory.
155153 * @param info The key-value information instance to attach to allocated memory.
156154 * @return The allocated memory pointer and new window instance.
157155 */
158- template <
159- typename T = void
160- , typename G = flag::window::local_t >
156+ template <typename T = void >
161157 MPIWCPP17_INLINE std::pair<T*, window_t > allocate (
162158 size_t count = 1
163159 , const communicator_t & comm = world
164160 , const info_t & info = info::null
165- , G = {}
166161 ) {
167- T *ptr;
168162 constexpr size_t size = sizeof (std::conditional_t <std::is_void_v<T>, uint8_t , T>);
169- auto w = MPIWCPP17_WIN_CALL ((
170- std::is_same_v<flag::window::shared_t , G>
171- ? MPI_Win_allocate_shared (count * size, size, info, comm, &ptr, &_)
172- : MPI_Win_allocate (count * size, size, info, comm, &ptr, &_)));
173- return std::make_pair (ptr, std::move (w));
163+ auto result = MPIWCPP17_GUARD_CALL (
164+ struct { T *ptr; window_t ::raw_t w; }
165+ , MPI_Win_allocate(count * size, size, info, comm, &_.ptr , &_.w ));
166+ return std::make_pair (result.ptr , MPIWCPP17_WIN_RAII (result.w ));
174167 }
175168
176169 /* *
@@ -190,7 +183,11 @@ namespace window
190183 , const communicator_t & comm = world
191184 , const info_t & info = info::null
192185 ) {
193- return allocate<T, flag::window::shared_t >(count, comm, info);
186+ constexpr size_t size = sizeof (std::conditional_t <std::is_void_v<T>, uint8_t , T>);
187+ auto result = MPIWCPP17_GUARD_CALL (
188+ struct { T *ptr; window_t ::raw_t w; }
189+ , MPI_Win_allocate_shared(count * size, size, info, comm, &_.ptr , &_.w ));
190+ return std::make_pair (result.ptr , MPIWCPP17_WIN_RAII (result.w ));
194191 }
195192
196193 /* *
@@ -236,7 +233,7 @@ namespace window
236233 * @param info The key-value information instance to attach to the new window.
237234 * @return The new window instance that manages a memory regions attached dynamically.
238235 */
239- MPIWCPP17_INLINE window_t create_dynamic (
236+ MPIWCPP17_INLINE window_t create (
240237 const communicator_t & comm = world
241238 , const info_t & info = info::null
242239 ) {
0 commit comments