← Back to Home

Course Syllabus

BCS702 - Parallel Computing

Continuous Internal Evaluation (CIE) Questions

  1. Write an OpenMP program to count how many prime numbers exist between 1 and n using parallel for with dynamic scheduling. Compare the result with a serial version.
    Sample Input:
    n = 20
    Expected Output:
    Serial Count of primes = 8
    Parallel Count of primes = 8
    Execution time (serial): 0.00123 seconds
    Execution time (parallel): 0.00045 seconds
  2. Write an MPI program where process 0 sends an integer value to process 1, and process 1 multiplies it by 2 and prints the result.
    Sample Input:
    Process 0 sends integer: 5
    Expected Output:
    Process 1 received 5
    Process 1 multiplied value = 10
  3. Write an MPI program where process 0 waits to receive a message from process 1, and process 1 waits to receive from process 0 (causing deadlock). Then modify the program to avoid deadlock by letting one process send first and the other receive first.
    Case 1 (Deadlock):
    (Program hangs, no output)
    Case 2 (Fixed):
    Process 0 received message: Hello from Process 1
    Process 1 received message: Hello from Process 0
  4. Write an MPI program where process 0 reads an array of 5 integers from the user and broadcasts it to all processes using MPI_Bcast. Each process should print the array it received.
    Sample Input:
    Enter 5 integers: 1 2 3 4 5
    Expected Output (for 4 processes):
    Process 0 received array: 1 2 3 4 5
    Process 1 received array: 1 2 3 4 5
    Process 2 received array: 1 2 3 4 5
    Process 3 received array: 1 2 3 4 5
  5. Write an MPI program where process 0 has an array of numbers, scatters them to all processes, and gathers back their squared values.
    Sample Input (array at process 0 with 4 processes):
    Array: [1, 2, 3, 4]
    Expected Output:
    Process 0 got 1 → squared = 1
    Process 1 got 2 → squared = 4
    Process 2 got 3 → squared = 9
    Process 3 got 4 → squared = 16
    Gathered result at Process 0: [1, 4, 9, 16]
  6. Write an MPI program where each process has its rank as a number. Use MPI_Reduce to find the sum of all ranks at process 0, and MPI_Allreduce to share the sum with all processes.
    Sample Input (4 processes):
    Process ranks: 0, 1, 2, 3
    Expected Output:
    MPI_Reduce result at Process 0: Sum of ranks = 6
    MPI_Allreduce result at all processes: Sum of ranks = 6