Skip to content

chanmini-kavinya/Parallel-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallel CNN

This project implements a Convolutional Neural Network (CNN) in C++ using multiple parallelization strategies:

  • Sequential
  • OpenMP
  • MPI
  • Hybrid (MPI + OpenMP)

The network is trained and evaluated on the MNIST dataset provided in CSV format.


Project Structure

parallel-CNN/
│
├── dataset/           # Contains mnist.zip which includes mnist_train.csv and mnist_test.csv
├── Sequential/        # Sequential C++ implementation
├── OpenMP/            # OpenMP parallelized CNN
├── MPI/               # MPI parallelized CNN
├── Hybrid/            # MPI + OpenMP hybrid CNN
└── README.md

Prerequisites

  • C++ compiler:
    • g++ with OpenMP support
    • mpic++ (for MPI and Hybrid)
  • Dataset:
    • Located in the dataset/ directory as a ZIP file

Dataset Setup

The dataset is provided as a ZIP archive: dataset/mnist.zip.

Before running any version of the code, unzip the dataset as follows:

cd dataset
unzip mnist.zip
cd ..

This will extract the following required files:

  • dataset/mnist_train.csv
  • dataset/mnist_test.csv

Compilation and Execution

1. Sequential Version

cd Sequential
g++ cnn.cpp -o cnn_seq
./cnn_seq

2. OpenMP Version

cd OpenMP
g++ -fopenmp cnn.cpp -o cnn_omp
./cnn_omp

To control the number of threads:

export OMP_NUM_THREADS=4

3. MPI Version

cd MPI
mpic++ cnn.cpp -o cnn_mpi
mpirun -np 4 ./cnn_mpi

Replace 4 with the desired number of MPI processes.


4. Hybrid Version (MPI + OpenMP)

cd Hybrid
mpic++ -fopenmp cnn.cpp -o cnn_hybrid
mpirun -np 2 ./cnn_hybrid

To control OpenMP threads per MPI process:

export OMP_NUM_THREADS=4
mpirun -np 2 ./cnn_hybrid

Output

All versions of the program will print:

  • Training time
  • Testing time
  • Accuracy
  • Confusion matrix
  • RMSE

About

A high-performance implementation of Convolutional Neural Networks (CNNs) using parallel computing techniques (MPI, OpenMP).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages