Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93437435
exchange.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 28, 18:24
Size
700 B
Mime Type
text/x-c
Expires
Sat, Nov 30, 18:24 (2 d)
Engine
blob
Format
Raw Data
Handle
22637498
Attached To
R11821 phys-743-lecture
exchange.c
View Options
#include <mpi.h>
#include <string.h>
#include <stdio.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
myrank
;
int
buf1
[
100
];
int
buf2
[
100
];
MPI_Status
status
;
MPI_Request
request
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
myrank
);
if
(
myrank
==
0
)
{
MPI_Isend
(
buf1
,
100
,
MPI_INT
,
1
,
0
,
MPI_COMM_WORLD
,
&
request
);
MPI_Recv
(
buf2
,
100
,
MPI_INT
,
1
,
0
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
}
else
if
(
myrank
==
1
)
{
MPI_Isend
(
buf1
,
100
,
MPI_INT
,
0
,
0
,
MPI_COMM_WORLD
,
&
request
);
MPI_Recv
(
buf2
,
100
,
MPI_INT
,
0
,
0
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
}
MPI_Wait
(
&
request
,
&
status
);
memcpy
(
buf1
,
buf2
,
100
*
sizeof
(
int
));
MPI_Finalize
();
return
0
;
}
Event Timeline
Log In to Comment