The Parallel Matrix Multiplication Compiler for the pPIM architecture transforms a high-level matrix multiplication program into custom ISA instructions tailored for parallel execution on a Processing-in-Memory (pPIM) architecture. The compiler processes a matrix multiplication C/C++ program and generates a sequence of optimized instructions to run efficiently across multiple processing elements (PEs). This project targets AI/ML applications that perform large matrix operations, such as in NLP and computer vision models.
-
Matrix Multiplication Compiler
The core feature of this project is to convert matrix multiplication (C = A × B) into efficient machine code for pPIM architecture. -
Parallel Execution
The compiler identifies independent rows in the matrix multiplication and generates machine code that assigns each row to a different Processing Element (PE), allowing parallel execution. -
Optimized Instruction Stream
The generated instruction stream is in 24-bit custom ISA format that targets LUT-based pPIM architecture, ensuring efficient parallel execution of matrix operations. -
Memory Mapping
The compiler generates a memory initialization file (memory_init.txt) that maps matrix elements to unique row addresses, providing efficient memory access during computation. -
Simulation and Reporting
The ISA Simulator evaluates the generated machine code, producing detailed results inreport.txt, including the final computed matrixCand simulation metrics.

Figure 1: Workflow of the Pipeline
-
Input: Matrix Multiplication Program (C/C++)
- The input matrix multiplication program is provided in C or C++ that multiplies two matrices
AandBof parameterized sizeN.
- The input matrix multiplication program is provided in C or C++ that multiplies two matrices
-
Lexical Analysis and Parsing
- The Lex (flex) and Yacc (bison) tools are used to parse the C/C++ code, identify loops (specifically parallelizable loops), and generate a Three-Address Code (TAC).
-
TAC Generation and Optimization
- The compiler identifies parallel loops and generates TAC, optimizing them for parallel execution. It then maps the instructions to multi-PE execution.
-
Instruction Generation
- The Parallel Generator converts the TAC into a custom ISA instruction format for pPIM. Each iteration of the parallel loop is assigned to a specific PE.
-
Memory Initialization
- A memory initialization file (
memory_init.txt) is created, which maps matrix elements to row addresses in pPIM, facilitating optimized memory access during simulation.
- A memory initialization file (
-
Simulation
- The ISA Simulator executes the generated ISA instructions, simulating the computation of matrix
Cacross multiple PEs and generating detailed results, including the final matrixC.
- The ISA Simulator executes the generated ISA instructions, simulating the computation of matrix
-
Final Output
- The compiler produces three main output files:
- program_parallel.isa – The final instruction stream.
- memory_init.txt – Memory initialization for matrices.
- report.txt – Simulation results and the final output matrix.
- The compiler produces three main output files:
The architecture of the framework is designed to efficiently handle matrix multiplication and simulate its execution on the pPIM architecture. The following figure demonstrates the modular structure of the framework:

Figure 2: Overall Architecture of the Proposed Framework
The architecture consists of the following modules:
- Matrix Multiplication Parser: Parses the input C/C++ matrix multiplication program.
- TAC Generator: Converts loops and operations into three-address code.
- ISA Generator: Converts TAC into pPIM-compatible instructions.
- Memory Generator: Creates memory mappings for the matrices.
- ISA Simulator: Simulates the execution of the generated instructions across multiple PEs.
-
Install Dependencies:
Install required packages:sudo apt-get update sudo apt-get install gcc flex bison python3 python3-pip pip3 install scikit-learn joblib pandas
-
Build the Project:
~/ ← Project Root
├── CMakeLists.txt # Build configuration
├── build.sh # Build and execution script
├── matrix_mul.cpp # Example matrix multiplication program
├── MatrixLoopParser.cpp # LLVM-based TAC generator
├── isa_generator.cpp # TAC to ISA converter (single PE)
├── parallel_generator.cpp # Loop unroller + multi-PE ISA generator
├── memory_generator.cpp # Memory loader (A, B, C) generator
├── isa_simulator.cpp # Simulator for MAC ops on PEs
├── program_parallel.isa # Final generated ISA instructions
├── memory_init.txt # Memory initialization for pPIM
└── report.txt # Simulation results (final matrix C)
-
Install Dependencies:
Install required packages:sudo apt-get update sudo apt-get install gcc flex bison python3 python3-pip pip3 install scikit-learn joblib pandas
-
Build the Project: Build the project and generate the required files:
chmod +x build.sh ./build.sh <matrix_size>
-
Run the Complete Pipeline: Execute the entire pipeline, which includes generating memory, ISA, and running the simulation:
chmod +x run_all.sh ./run_all.sh
- program_parallel.isa: The generated ISA instruction stream for matrix multiplication.
- memory_init.txt: The memory initialization for matrices A, B, and C in pPIM.
- report.txt: The final simulation results, including the computed matrix
C.
![]() |
![]() |
|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |









