E05 - 22cs4106R Lab WorkBook
E05 - 22cs4106R Lab WorkBook
COMPUTING
22CS4106R
S.No. Date Experiment Name Pre- In-Lab (25M) Post- Viva Total Faculty
Lab Program/ Data and Analysis & Lab Voce (50M) Signature
(10M) Procedure Results Inference (10M) (5M)
(5M) (10M) (10M)
Experiment 1
Title: Demonstrate various programs in OpenMP, Parallel global sum
Aim/Objective:
Demonstrate the versatility of OpenMP through multiple programs implementing parallel global sum
algorithms, emphasizing diverse parallelization approaches for optimal performance.
Description:
Explore OpenMP's capabilities by presenting distinct programs showcasing parallel global sum
computations, utilizing different OpenMP directives and strategies to achieve efficient parallelization.
Pre-Requisites:
Participants should have a solid understanding of C programming, familiarity with parallel computing
concepts, and access to a compiler with OpenMP support. A basic knowledge of multithreading and a
multiprocessor system for parallel execution are also recommended.
Pre-Lab:
1. Explain the purpose of the critical directive in OpenMP and provide a scenario where it is
beneficial?
2. Describe the role of the master directive in OpenMP. In what situations is it commonly
used?
3. Discuss the significance of the default clause in OpenMP. How does it affect the sharing
of variables in a parallel region?
5. Explain the concept of the reduction clause in OpenMP. How does it facilitate parallel
computation?
In-Lab:
• Program:
• Program:
Post-Lab:
1. Implement a program to demonstrate Parallel global sum using OpenMP Reduction clause
• Program:
Experiment 2
Title: Parallel Computation with OpenMP: Summation Techniques and Matrix-Vector
Multiplication
Aim/Objective:
Illustrate parallel computation techniques using OpenMP for two fundamental algorithms—
summation and matrix-vector multiplication—aiming to enhance performance through
concurrent processing.
Description:
Implement OpenMP-based programs for parallel summation and matrix-vector multiplication,
exploring various OpenMP directives and strategies to optimize computation speed and
scalability.
Pre-Requisites:
Proficiency in a language supporting OpenMP (e.g., C/C++), understanding of OpenMP
directives, familiarity with array and matrix manipulation, and a foundational grasp of parallel
programming concepts including thread management, synchronization, and parallelization
strategies.
Pre-Lab:
1. What is the primary objective of utilizing OpenMP in parallel summation techniques?
2. Briefly discuss one advantage of using OpenMP for parallel summation techniques
compared to sequential approaches.
3 In the context of matrix-vector multiplication, define the term "data parallelism" and explain
how OpenMP leverages this concept for parallel computation.
4. Explain the role of load balancing in the context of parallel matrix-vector multiplication
using OpenMP, and why it is crucial for optimizing performance.
5. Name one key OpenMP directive used in the parallelization of computations. Provide a brief
description of its purpose?
In-Lab:
1. Implement Parallel Summation using OMP - The Array Element Sum Problem, Tree
structure global sum - Parallel-tree-sum.c
• Program:
2. Implement a program to demonstrate Parallel prefix sum using OpenMP - OMP Parallel
prefix sumfinal.c
• Program:
Post-Lab:
1. Implement Parallel matrix vector multiplication using OpenMP
• Program:
Experiment 3
Title: Parallel implementation of PI, Fundamentals of MPI Programming
Aim/Objective:
To demonstrate the parallel computation of PI using the Monte Carlo method with OpenMP
for improved performance and to showcase the MPI_Bcast function for broadcasting data from
one process to all other processes in a communicator.
Description:
In this experiment, students will explore the program generates random points in a unit square
and estimates PI by calculating the ratio of points within a quarter circle to the total points.
OpenMP is utilized to parallelize the computation for efficient use of multiple threads
The program initializes a message on the root process, and then MPI_Bcast is used to broadcast
this message to all other processes in the communicator. This demonstrates the concept of one-
to-all communication.
Pre-Requisites:
• Basic understanding of the Monte Carlo method for PI estimation.
• Familiarity with OpenMP directives and parallel programming concepts.
• Understanding communication patterns in parallel computing.
Pre-Lab:
1. How does the MPI program partition the sequence of numbers in the example provided
for computing π?
2. Discuss the challenges associated with load balancing when partitioning a sequence of
numbers for parallel computation?
3. Explain the differences between the MPI_Send and MPI_Recv functions in MPI. How are
these functions employed for point-to-point communication in the context of parallelizing the
computation of π?
4. Discuss the trade-offs between parallel efficiency and communication overhead in the MPI
implementation of the π computation?
5. How does the program attempt to address load balancing, and what factors can impact the
efficiency of the load balancing strategy in the provided MPI example?
• Program:
In-Lab:
1. Implement Basic programs to demonstrate Broad cast and Reduction using mpi-reduce.c ,
mpi-bcast.c
o /* Program to demonstrate MPI_Reduce for sum reduction */
o /* Program to demonstrate MPI_BCAST for sum reduction */
• Program:
2. Write programs to Partition a sequence ofnumbers into parts and adding them using
a. Point-to-Point communications
b. MPI_Bcast
c. MPI_Scatter
Post-Lab:
1. Explain MPI_Reduce, MPI_Send, MPI_Sendrecv, MPI_Barrier, MPI_Scatter, MPI_Gather,
MPI_Allgather,MPI_Allreduce
Ans:
Experiment 4
Title: Parallel Computation and Sorting Techniques Using MPI and OpenMP
Aim/Objective:
Implement parallel computation techniques using MPI (Message Passing Interface) and
OpenMP. It focuses on distributed data processing, such as calculating averages and finding
maxima using MPI, and parallel sorting algorithms like odd-even transposition sort using
OpenMP.
Description:
This lab introduces the concepts of distributed data computation and parallel sorting using MPI
and OpenMP. In the Pre-Lab, MPI programs are developed to compute averages and maxima
by distributing and collecting data using collective communication functions like MPI_Scatter,
MPI_Gather, and MPI_Reduce. The In-Lab task involves implementing an odd-even
transposition sort, a parallel sorting algorithm, using OpenMP.
Pre-Requisites:
• Understanding of distributed systems and parallel computing concepts.
• Familiarity with MPI and OpenMP libraries.
• Basic knowledge of C/C++ programming.
• Tools: MPI (e.g., MPICH or OpenMPI) and GCC with OpenMP support.
Pre-Lab:
1. Develop an MPI program to compute the average numbers using the following functions and
compute the time required for the same.
• MPI_Scatter and MPI_Gather.
• MPI_Scatter and MPI_Reduce.
• Program:
2. Write an MPI program to find the maximum number of each group, then master finds
maximum of results.
1. Program:
In-Lab:
1. Program to implement odd-even transposition sort using OpenMP
• Program:
2. Implement a parallel bubble sort using OpenMP and compare its performance with odd-
even transposition sort.
• Program:
Experiment 5
Title: Exploring Parallel Sorting Algorithms: Implementations and Analysis with MPI,
OpenMP
Aim/Objective:
To Investigate parallel sorting algorithms through implementations and analysis using MPI,
OpenMP, aiming to compare and optimize their performance on various architectures.
Description:
Develop sorting algorithms in parallel using MPI for distributed memory systems, OpenMP
for shared-memory multi-core architectures. Conduct a comprehensive analysis to understand
the strengths and weaknesses of each parallelization approach.
Pre-Requisites:
• Understanding of sorting algorithms such as merge sort, quicksort, Shell sort, and
bitonic sort.
• Familiarity with OpenMP directives for multi-core CPU parallelism.
Pre-Lab:
1. Write a Program to implement Parallel Odd Even sort - MPI
• Program:
• Program:
• Program:
In-Lab:
1. A communicator has 3 processes (ID: 0, 1 and 2) such that process 0 sends a binary value
001 to process 1, in-turn process 1 increment the value by 1 (i.e. 010) and send the same
to process 2, in-turn process 2 increment the value by 1 (i.e. 011) and send the same to
process 0. Continue the process until the binary value becomes 111. Develop a MPI
program to implement the above scenario (Rotating Binary Addition).
• Program:
1. How does the parallel odd-even sort algorithm work in the MPI implementation?
2. How is the array distributed among MPI processes, and why is it important for efficiency?
3. Explain how point-to-point communication is utilized in the odd-even sort algorithm for
parallelism.
4. What is the significance of the odd and even phases in the parallel odd-even sort?
5. How does the parallel odd-even sort handle the synchronization of processes after each
phase?
Post-Lab:
1. Write a Program to implement Merge sort, Sample Sort using OpenMP
• Program:
2. Analyze odd-Even Merge sort and Hyper cube quick sort algorithm with an example
• Program:
Experiment 6
Title: Advanced Parallel Computing in Mathematical Algorithms: Harnessing OpenMP, and
MPI for Matrix Operations, Integration, and Sorting
Aim/Objective:
To explore the benefits of parallelizing numerical algorithms such as Gaussian Elimination,
Trapezoidal Integration, and Row Sums, focusing on enhancing computational efficiency
through parallel decomposition, load balancing, inter-process communication, and scalability
considerations.
Description:
Parallel Gaussian Elimination divides the matrix manipulation tasks among multiple
processing units. Parallel decomposition techniques distribute the workload, improving overall
performance by exploiting parallelism in matrix operations.
Pre-Requisites:
Pre-Lab:
1. How does parallelizing Gaussian Elimination enhance computational efficiency, and
what role do parallel decomposition techniques play in this context?
2. Briefly explain the concept of load balancing in the context of parallel Trapezoidal
Integration and identify one challenge associated with achieving optimal load
distribution.
5. Defining scalability in the context of parallel computing and identify two factors that
can affect the scalability of algorithms like Gaussian Elimination, Trapezoidal
Integration,and Row Sums.
• Program:
Post-Lab:
1. Write a program to implement a parallel version of Trapezoidal rule Using MPI.
• Program:
2. Given a directed graph, write a MPI program to count all possible walks (both closed and
open) of length k from every source and destination pair using DFS.
• Program:
Experiment 7
Title: Distributed Algorithms and Parallel Programming with MPI
Aim/Objective:
Implement the fundamental concepts of the Message Passing Interface (MPI), a standard for
parallel programming in distributed systems. It focuses on performing distributed computation
tasks using MPI, such as synchronization, communication, and computation among multiple
processes.
Description:
The lab explores the use of MPI to enable parallel computation and communication in
distributed systems. Key MPI functions such as MPI_Barrier() and MPI_Wtime() are
introduced, along with practical applications like tree-structured global sum, vector addition,
and topology-based communication. Distributed algorithms for clock synchronization
(Lamport’s clock and Vector clock) are simulated to reinforce concepts of time and order in
distributed systems. Additionally, advanced concepts such as non-blocking communication and
the Monte Carlo method for numerical computation are covered.
Pre-Requisites:
• Basic understanding of distributed systems.
• Familiarity with C/C++ programming.
• Knowledge of parallel processing concepts.
• MPI library installation and environment setup.
Pre-Lab:
1. Demonstrate the use of MPI_Barrier() and MPI_Wtime() with a program
• Program:
In-Lab:
1. Lamports clock Algorithm Implementation in C – simulation.
• Program:
• Program:
Post-Lab:
1.Write an MPI Program that implements Ring Topology using Non-Blocking Send/Receive
• Program:
Experiment 8
Title: Distributed Mutual Exclusion and Parallel Programming
Aim/Objective:
To implement various distributed mutual exclusion algorithms and parallel programming
techniques for efficient resource sharing and computation.
Description:
This lab explores key distributed algorithms for mutual exclusion and parallel computation.
These techniques ensure fair resource allocation and optimized execution in distributed and
parallel computing environments.
Pre-Requisites:
Familiarity with mutual exclusion algorithms, such as those used to manage access to shared
resources in a distributed environment, is also required. Proficiency in C programming is
necessary, along with knowledge of parallel programming libraries like OpenMP for shared-
memory systems and MPI for distributed-memory systems. Additionally, the lab requires a
properly configured environment with OpenMP and MPI support, such as GCC with OpenMP
enabled and MPI libraries like MPICH or OpenMPI, to execute and test the programs effectively.
Pre-Lab:
1. What is mutual exclusion, and why is it required in distributed systems?
Post-Lab:
1. Implement a Program to implement Matrix-Matrix multiplication using OpenMP
• Program:
Experiment 9
Title: Leader Election in Distributed Systems: Implementing Bully and Ring Algorithms
Using MPI/C Library
Aim/Objective:
To explore distributed computation essentials through the implementation of Bully and
Ring algorithms using MPI and C library, focusing on demonstrating inter-process
communication and fault-tolerant leader selection.
Description:
Develop and analyze parallel applications using MPI for distributed computing. Emphasize
matrix operations, dot products, and numerical calculations, showcasing the versatility of
parallel computation in solving computationally intensive tasks.
Pre-Requisites:
Proficiency in C/C++ programming, understanding of parallel programming concepts,
familiarity with MPI programming models, and knowledge of matrix operations,dot
products, and numerical algorithms.
Pre-Lab:
1. How can parallel dot product be implemented using multi-threading or parallel processing?
2. How does parallel processing or GPU acceleration impact the performance of matrix
transposition operations?
3.Write the algorithm of prefix sum and define the use of prefix sum reduce time complexity
in dynamic programming algorithms?
4. Write pseudocode for an in-place matrix transposition function, assuming the original matrix
is stored in row-major order in memory. Analyse its time and space complexity.
5. What are the advantages of using parallel computation for the dot product in terms of
performance?
In-Lab:
• Program:
Post-Lab:
1. Implement a Fault-Tolerant Ring Algorithm with Failure Detection
• Program:
2. Modify and Analyze the Bully Algorithm for Dynamic Node Changes.
• Program:
Experiment 10
Title: Exploring Parallel Computing: Data Structures, Algorithmic Patterns, and Visualization
Techniques
Aim/Objective:
Explore parallel computing by investigating data structures, algorithmic patterns, and
visualization techniques, aiming to enhance understanding and proficiency in leveraging
parallelism for computational tasks.
Description:
Develop and analyze parallel algorithms, employ advanced data structures, and utilize
visualization techniques to understand and optimize the performance of parallel computations.
Pre-Requisites:
Proficiency in a programming language (e.g., C/C++), foundational knowledge of data
structures and algorithms, and a basic understanding of parallel computing concepts.
Pre-Lab:
1. What is a parallel prefix sum in the context of linked lists, and how does it differ from the
array-based approach?
2. Explain the significance of list ranking in parallel computing and its relevance to linked
lists.
3. Briefly describe the Mandelbrot Set and how parallel computing accelerates its rendering
process.
5. How would you assess the performance of a parallel algorithm for linked lists? Can you
name one optimization technique for enhancing its efficiency?
In-Lab:
1. Write a program to demonstrate Linked list Parallel prefix sum using MPI
• Program:
3. What is the significance of implementing a concurrent linked list? Describe the key
challenges and solutions involved in ensuring concurrent access and modification of a linked
list.
4. Explain the potential concurrency issues that may arise in a linked list and how the concurrent
linked list program addresses them. What synchronization mechanisms are employed?
5. Walk through the steps involved in rendering the Mandelbrot Set in parallel. How does
parallelization enhance the efficiency of generating the Mandelbrot Set?
Post-Lab:
1. Parallel Program to implement List Ranking
• Program:
3. OpenMP and MPI implementation of Travelling Salesman Problem using Branch and Bound
algorithm.
• Program:
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>
Experiment 11
Title: Simulation and Distributed Programming: Consensus and Matching Algorithms
Aim/Objective:
To simulate the Lamport-Shostak-Pease Algorithm to achieve consensus in distributed systems
despite the presence of faulty nodes and to implement the Stable Marriage Problem using MPI,
utilizing asynchronous message passing for inter-process communication and logging events
such as pairings and rejections to a trace file.
Description:
The implementation of the Stable Marriage Problem using MPI demonstrates distributed
computing techniques, including asynchronous message passing for efficient inter-process
communication and event logging for monitoring and debugging. achieving consensus and
solving combinatorial problems using distributed programming. The Lamport-Shostak-Pease
Algorithm simulation addresses the challenge of reaching agreement in the presence of faulty
nodes, showcasing fault tolerance in distributed systems
Pre-Requisites:
Pre-Lab:
1. What is the significance of the Lamport-Shostak-Pease Algorithm in distributed
systems?
3. What is the Stable Marriage Problem, and how can it be solved using distributed
programming?
4. How does the asynchronous message passing differ from synchronous communication
in MPI?
In-Lab:
1. Implement Lamport-Shostak-Pease Algorithm in C- simulation
• Program:
2. MPI Distributed program to solve the Stable Marriage Problem. The processes should
communicate using asynchronous message passing. Log the trace of events (pairing,
breaking), as they happen, in a text file named as Log.txt.
• Program:
Post-Lab:
1. Modify the table Marriage MPI Program and include the dynamic addition.
• Program:
• Program:
Experiment 12
Title: Distributed Systems and Cloud Computing: Web Services, MPI, and HPC Workflows
Aim/Objective:
To explore and implement distributed systems using web services, Message Passing Interface
(MPI), and High-Performance Computing (HPC) workflows by creating, consuming, and
running distributed applications and jobs on multi-node and single-node systems in HPC and
cloud environments.
Description:
It emphasizes hands-on implementation, effective resource management, and performance
analysis, providing a comprehensive understanding of real-world computing environments.
Developing and deploying RESTful web services, running distributed MPI applications on
high-performance computing (HPC) systems with both multi-node and single-node
configurations, and configuring and testing cloud-based MPI clusters on AWS
Pre-Requisites:
A basic understanding of distributed systems and web services, including REST and SOAP, is
essential for this lab. Familiarity with MPI programming and parallel computing concepts is
also required to successfully implement the tasks. Additionally, knowledge of cloud platforms
such as AWS and job schedulers like Slurm is necessary. Hands-on experience with
Linux/Unix commands and shell scripting will be beneficial, along with pre-configured access
to KLU HPC and AWS accounts to facilitate the practical exercises.
Pre-Lab:
1. What are web services, and how do they facilitate communication in distributed
systems?
In-Lab:
1. Create a simple web service and write distributed application(calculator) to consume the
Web Service
• Program:
Post-Lab:
1. Run a multi-node MPI job with Slurm in AWS PCS
• Program:
• Program: