Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
RequestListBase.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* RequestListBase.cc (C) 2000-2025 */
9/* */
10/* MPI request list. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/message_passing/RequestListBase.h"
15#include "arccore/base/NotImplementedException.h"
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20namespace Arcane::MessagePassing::internal
21{
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
27clear()
28{
29 m_requests.clear();
30 m_requests_done.clear();
31 m_done_request_indexes.clear();
32}
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
39{
40 // TODO: optimize this by removing multiple values at once
41 for (Integer i = 0, n = m_requests.size(); i < n; ++i) {
42 if (m_requests_done[i]) {
43 _removeRequestAtIndex(i);
44 --i;
45 --n;
46 }
47 }
48 m_done_request_indexes.clear();
49}
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
56{
57 return m_done_request_indexes.view();
58}
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
64wait(eWaitType wait_type)
65{
66 m_requests_done.fill(false);
67
68 // Delegates the actual call to the derived class which must fill
69 // the m_requests_done field (except for WaitAll)
70 _wait(wait_type);
71
72 if (wait_type == WaitAll)
73 m_requests_done.fill(true);
74
75 Integer nb_request = size();
76 m_done_request_indexes.clear();
77 m_done_request_indexes.reserve(nb_request);
78 Int32 nb_done = 0;
79 for (Integer i = 0; i < nb_request; ++i)
80 if (m_requests_done[i]) {
81 m_done_request_indexes.add(i);
82 ++nb_done;
83 }
84 return nb_done;
85}
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90} // namespace Arcane::MessagePassing::internal
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
Constant view of an array of type T.
void removeDoneRequests() override
Removes completed requests from the list.
void clear() final
Removes all requests from the list.
virtual void _wait(eWaitType wait_type)=0
Performs the wait or test.
Int32 wait(eWaitType wait_type) final
Waits for or tests the completion of one or more requests.
Int32 size() const override
Number of requests.
ConstArrayView< Int32 > doneRequestIndexes() const final
Indices in the request array of requests completed during the last call to wait().
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.