12#ifndef ARCANE_PARALLEL_THREAD_SHAREDMEMORYMESSAGEQUEUE_H
13#define ARCANE_PARALLEL_THREAD_SHAREDMEMORYMESSAGEQUEUE_H
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
20#include "arcane/parallel/thread/ISharedMemoryMessageQueue.h"
22#include "arcane/core/ISerializer.h"
47class ARCANE_THREAD_EXPORT SharedMemoryMessageQueue
56 SharedMemoryMessageQueue()
57 : m_atomic_request_id(0)
59 ~SharedMemoryMessageQueue()
override;
63 void init(
Int32 nb_thread)
override;
66 bool is_non_blocking)
override;
81 Int32 m_nb_thread = 0;
83 std::atomic<Int64> m_atomic_request_id;
89 return m_sub_queues[rank.
value()];
91 Int64 _getNextRequestId()
93 return m_atomic_request_id.fetch_add(1);
96 SubQueue* _getSourceSubQueue(
const MP::PointToPointMessageInfo& message);
97 SubQueue* _getDestinationSubQueue(
const MP::PointToPointMessageInfo& message);
116 explicit SortFunctor(
Int32 nb_thread)
117 : m_nb_thread(nb_thread)
129 if (r1->isRecv() && !r2->isRecv())
131 if (!r1->isRecv() && r2->isRecv())
133 Int32 i1 = _getQueueIndex(r1->orig(), r1->dest());
134 Int32 i2 = _getQueueIndex(r2->orig(), r2->dest());
136 return r1->id() < r2->id();
146 return thread1.
value() + (thread2.
value() * m_nb_thread);
161 , m_request_id(request_id)
166 , m_receive_buffer_info(buf)
173 , m_request_id(request_id)
178 , m_send_buffer_info(buf)
186 MessageTag tag()
const {
return m_tag; }
187 bool isRecv()
const {
return m_is_recv; }
188 bool isDone()
const {
return m_is_done; }
189 void setDone(
bool v) { m_is_done = v; }
190 SendBufferInfo sendBufferInfo() {
return m_send_buffer_info; }
191 ReceiveBufferInfo receiveBufferInfo() {
return m_receive_buffer_info; }
192 SharedMemoryMessageQueue::SubQueue* queue() {
return m_queue; }
193 const String& queueName()
const;
194 void copyFromSender(SharedMemoryMessageRequest* sender);
195 Int64 id()
const {
return m_request_id; }
197 ISerializer* recvSerializer() {
return m_receive_buffer_info.serializer(); }
198 const ISerializer* sendSerializer() {
return m_send_buffer_info.serializer(); }
200 void setSource(MessageRank s)
212 SubQueue* m_queue =
nullptr;
213 Int64 m_request_id = -1;
214 bool m_is_recv =
false;
218 std::atomic<bool> m_is_done =
false;
220 bool m_is_destroyed =
false;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
File containing declarations concerning the message passing model.
Modifiable view of an array of type T.
Interface of a message queue with threads.
Int32 value() const
Rank value.
bool isNull() const
True if the rank is uninitialized, corresponding to the default rank.
Information for sending/receiving a point-to-point message.
Receive buffer information.
File for messages from a rank in shared memory.
Message queue between ranks shared by a SharedMemoryParallelMng.
Message within SharedMemoryMessageQueue.
SharedMemoryMessageRequest(SubQueue *queue, Int64 request_id, MessageRank orig, MessageRank dest, MessageTag tag, ReceiveBufferInfo buf)
Create a send request.
SharedMemoryMessageRequest * matchingSendRequest()
Associated request in the case it is a receive resulting from a probe.
SharedMemoryMessageRequest(SubQueue *queue, Int64 request_id, MessageRank orig, MessageRank dest, MessageTag tag, SendBufferInfo buf)
Create a receive request.
Thread-based parallelism manager.
1D data vector with value semantics (STL style).
Declarations of types and methods used by message exchange mechanisms.
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.