Loading, please wait...
🚀 Now Available on Google Play

VTU Circle

Your complete VTU student companion. Check VTU results, track SGPA & CGPA, access study resources, stay updated with VTU notifications, and connect with classmates—all in one simple and fast app.

📊 VTU Results 🎯 SGPA & CGPA 📄 Result PDF 📈 Analytics 📚 Notes 📖 Syllabus 📝 Question Papers 🛠 Study Tools 🔔 VTU Updates 🏆 Rankings 👥 Classmates 💬 Chat
Download on Google Play

BCS702 Program 5

COMMAND:

  • Create: gedit prg5.c
  • Compile: mpicc prg5.c -o prg5
  • Run: mpirun -np 2 ./prg5

PROGRAM:

#include <mpi.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    int rank, size;
    int number;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);

    if (size < 2) {
        if (rank == 0)
            printf("Please run with at least 2 processes.\n");
        MPI_Finalize();
        return 0;
    }

    if (rank == 0) {
        number = 100;
        printf("Process %d sending number %d to process 1\n", rank, number);
        MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
    } else if (rank == 1) {
        MPI_Recv(&number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
        printf("Process %d received number %d from process 0\n", rank, number);
    }

    MPI_Finalize();
    return 0;
}

OUTPUT:

Program5 ubuntu output
guest
1 Comment
999
999
08-10-2025 3:52 PM

excellent work brother

1
0
Would love your thoughts, please comment.x
()
x
Syllabus Papers
SGPA CGPA