This repository contains my implementation of the second lab assignment for the Concurrent Programming course at MIM UW. The project involved creating a simplified version of the Message Passing Interface (MPI) protocol in C.
Full assignment description can be found in assignment.md. My code is in files mimpirun.c
, mimpi.c
, mimpi_common.c
, mimpi_common.h
.
The goal of this project was to implement key functionalities of MPI for interprocess communication. It consists of:
mimpirun
: Handles the execution of parallel processes, managing their lifecycle and synchronization.mimpi
library: Provides functions for communication and coordination between processes.
The mimpirun
program:
- Accepts the number of processes (
n
), the executable path (prog
), and optional arguments. - Launches
n
parallel instances of the specified program. - Waits for all processes to finish and terminates cleanly.
The mimpi
library includes:
- Initialization and Finalization:
MIMPI_Init
: Initializes resources.MIMPI_Finalize()
: Releases resources and cleans up.
- Communication:
- Point-to-Point:
MIMPI_Send
: Sends a message to a given process.MIMPI_Recv
: Waits for a message from a given process.
- Group:
MIMPI_Barrier
: Synchronizes all processes.MIMPI_Bcast
: Broadcasts data from one process to others.MIMPI_Reduce
: Aggregates data using operations likesum
,prod
,max
,min
.
- Point-to-Point:
- Process Information:
MIMPI_World_size()
: Returns the total number of processes.MIMPI_World_rank()
: Returns the calling process's rank.
Build mimpirun
and all examples in the examples/
directory:
make
Example mimpirun
usage:
./mimpirun <number of processes> <path to the executable> <optional arguments>
Run all tests:
./test
Run all tests with Valgrind:
VALGRIND=1 ./test