Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char** argv) {
- MPI_Init(&argc, &argv);
- int world_size;
- MPI_Comm_size(MPI_COMM_WORLD, &world_size);
- int rank;
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- printf("process: #%d", rank);
- //comunication
- if (rank == 0) {
- char helloMessage[] = "proc1";
- MPI_Send( helloMessage, 6, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
- //printf("process 1 send: %d", number);
- }
- else if (rank == 1) {
- char message[6];
- MPI_Recv( message, 6, MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
- printf("process 2 recv: %s", message);
- }
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement