With Speculative Strategy Execution and AI-Guided Memory Mapping
OptiMap is a self-learning, AI-augmented compiler built for custom 24-bit Processor-in-Memory (pPIM) Instruction Set Architectures (ISAs). Unlike traditional compilers that follow static optimization rules, OptiMap employs speculative strategy generation and AI-guided cost prediction to select the most optimal code path for each workload.
It also incorporates hardware-aware memory mapping, making it highly suitable for edge AI accelerators and memory-centric compute systems where efficient row/bank alignment is critical. The system is designed to evolve over time using historical logs and machine learning, turning it into a long-term optimization tool.
- Custom pPIM ISA Compiler: Converts LLVM IR to 24-bit ISA for in-memory compute architectures.
- Speculative Strategy Execution: Explores multiple loop and memory layout variants for each matrix operation.
- AI-Guided Cost Modeling: Uses MLP-based prediction for selecting optimal execution plans.
- Memory Mapping Optimization: Translates abstract matrix access into hardware-aligned (Bank, Row, Offset) formats.
- Self-Learning System: Continuously improves performance through feedback and real-time updates.
OptiMap/
├── data/ # JSON memory store (compiler_memory.json, nss_memory.json)
├── include/ # Header files (IR, strategy, NSS, cost model, etc.)
├── logs/ # Debug logs (ISA traces)
├── src/ # Source code for each module
├── .gitignore
├── CMakeLists.txt # CMake configuration
├── matrix_mul.ll # LLVM IR input file
└── README.md
The compilation process follows an adaptive pipeline:
- Compile C++ matrix code into LLVM IR
- Parse matrix operations and extract shape dimensions
- Convert parsed data into pPIM-specific IR instructions
- Use IR as an abstraction layer between LLVM IR and ISA codegen
- Generate all valid permutations of loop orders, layouts, and tile sizes
- Filter semantically invalid strategies
- Lookup known strategies in
nss_memory.json
- Use heuristic estimator for unseen strategies
- Predict cost via MLP model if history is unavailable
- Select the most efficient strategy
- Map logical matrix access to
(Bank, Row, Offset)
- Ensure compatibility with row-parallel pPIM execution
- Encode IR into 24-bit binary ISA instructions
- Log instruction type, hex encoding, and physical address
- Log real execution cost
- Update strategy history and AI model
- Emit 24-bit instruction stream
- Save/update memory and logs
- Hardware-software co-design for AI accelerators
- Simulation and testing of pPIM or memory-centric architectures
- Compiler innovation and AI-based optimization research
- Integration into embedded AI toolchains
This project is licensed under the MIT License.
This project uses the open-source nlohmann/json C++ library for JSON parsing and management.
We thank Niels Lohmann for developing and maintaining this powerful and intuitive JSON library, which is integrated into OptiMap’s persistent memory subsystem.
xcode-select --install # Install Xcode Command Line Tools
brew install cmake # CMake build system
brew install git # Version control
brew install llvm # For LLVM-based IR parsing
From the project root directory:
cd build
cmake ..
make
./OptiMap
This will compile the project and execute the main pipeline, including LLVM IR parsing, strategy selection, and 24-bit ISA code generation.