Skip to content
Snippets Groups Projects
Commit 9eb19503 authored by Chao Zhan's avatar Chao Zhan
Browse files

add deadlock solution

parent 6edb7fa1
Branches
No related tags found
No related merge requests found
...@@ -301,7 +301,7 @@ The receive buffer must be able to fit the entire message: ...@@ -301,7 +301,7 @@ The receive buffer must be able to fit the entire message:
The MPI status object holds information about the received message. The MPI status object holds information about the received message.
**MPI_Status status**: **MPI_Status status** object is a structure in C with freely accessible members:
```c ```c
status.MPI_SOURCE // message source rank status.MPI_SOURCE // message source rank
...@@ -440,3 +440,34 @@ This tells us: <span class="text-rose-500 font-bold">Never rely on any implement ...@@ -440,3 +440,34 @@ This tells us: <span class="text-rose-500 font-bold">Never rely on any implement
</v-click> </v-click>
---
title: Deadlock III
---
### Another Solution to Deadlock
**Using Combined Send and Receive**:
```c
MPI_Sendrecv (
void *senddata,
int sendcount,
MPI_Datatype sendtype,
int dest,
int sendtag,
void *recvdata,
int recvcount,
MPI_Datatype recvtype,
int source,
int recvtag,
MPI_Comm comm,
MPI_Status *status
)
```
Sends one message and receives one message (in any order) **without deadlocking(unless unmatched)**
<span class="text-rose-500 font-bold">Send and receive buffers must not overlap!</span>
Don't want two buffers? -> Use **MPI_Sendrecv_replace**!
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment