Linear Algebra and HPC Kernels
This repository contains implementations of numerical linear algebra algorithms and high-performance computing (HPC) kernels:
- Condition Number Estimation for Symmetric Positive Definite (SPD) matrices
- Dense Matrix–Vector Multiplication
- CPU (serial)
- CPU (OpenMP)
- GPU (CUDA)
- Preconditioned Conjugate Gradient (PCG) solver for the 2-D Poisson equation using CSR (Compressed Sparse Row) storage
This implementation uses the Eigen library.
Dependency:
Eigen (header-only). Clone using
git clone https://gitlab.com/libeigen/eigen.git
Compile:
g++ -O3 -I path/to/eigen cond_number.cpp -o cond_number
Run:
./cond_number /path/to/matrix_file matrix_size
Compile (serial):
g++ -O3 Matrix_Vector.cpp -o matvec_cpu
Run:
./matvec_cpu /path/to/A_file /path/to/x_file matrix_size
Compile (OpenMP):
g++ -O3 -fopenmp Matrix_Vector_OMP.cpp -o Exec
Run:
export OMP_NUM_THREADS=#THREADS
./Exec /path/to/A_file /path/to/x_file rwo_size col_size
Compile:
nvcc -O3 Matrix_Vector.cu -o matvec_gpu
Run:
./matvec_gpu /path/to/A_file /path/to/x_file row_size col_size threadsPerBlock option
where
row_size,col_sizeare the matrix dimensionsthreadsPerBlockspecifies the CUDA block sizeoptionselects the kernel implementation (e.g., 1 or 2)
This implementation solves the 2-D Poisson equation using:
- CSR sparse matrix storage
- Jacobi preconditioning
- Residual-based convergence criteria
Compile: g++ -O3 cg_solver_pre.cpp -o cg_solver
Run:
./cg_solver /path/to/poisson_dir
This implementation solves the 2-D Poisson in CUDA equation using:
- CSR sparse matrix storage
- Jacobi preconditioning
- Residual-based convergence criteria
Compile: nvcc -O3 -arch=sm_61 --use_fast_math -Xcompiler "-O3" cg_solver_J.cu -o cg_solver_J
Run:
./cg_solver_J /path/to/poisson_dir
This implementation solves the 2-D Poisson equation using:
- CSR sparse matrix storage
- SSOR preconditioning
- Residual-based convergence criteria
Compile: g++ -O3 cg_solver_SSOR.cpp -o cg_solver_SSOR
Run:
./cg_solver_SSOR /path/to/poisson_dir
Compile: nvcc -O3 -arch=sm_61 --use_fast_math -Xcompiler "-O3" cg_solver_J.cu -o cg_solver_SSOR_GPU
Run:
./cg_solver_SSOR_GPU /path/to/poisson_dir