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) {
- MPI_Status mpi_status;
- int number_of_data;
- char message[6];
- MPI_Recv( message, 6, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &mpi_status);
- printf("process 2 recv: %s", message);
- //get info
- MPI_Get_count(&mpi_status, MPI_CHAR, &number_of_data);
- printf("\nNumber of data: %d, source: %d, tag: %d", number_of_data, mpi_status.MPI_SOURCE, mpi_status.MPI_TAG );
- }
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement