SAITPublic / PIMSimulator

Processing-In-Memory (PIM) Simulator
Other
93 stars 38 forks source link

PIMSimulator

Contents

1. Overview
2. HW Description
3. Setup
4. Programming Guide

1. Overview

PIMSimulator is a cycle accurate model that Single Instruction, Multiple Data (SIMD) execution units that uses the bank-level parallelism in PIM Block to boost performance that would have otherwise used multiple times of bandwidth from simultaneous access of all bank. The simulator include memory and have embedded within it a PIM block, which consist of programmable command registers, general purpose register files and execution units.

Based on https://github.com/umd-memsys/DRAMSim2, the simulator includes

2. HW description

PIM is a HBM stack that is pin compatible with HBM2 and have embedded within it a PIM block

2.1 Base Architecture

|--------------|          |--------------|          |--------------|
|              |    (A)   |              |   (B)    |              |
|    HOST      |----------| Controller   |----------|    Memory    |
|              |          |              |          |              |
|--------------|          |--------------|          |--------------|

HBM2

2.2 Address mapping

|<-rank->|<-row->|<-col high->|<-bg->|<-bank->|<-chan->|<-col low->|<-offset ->|
// Static Setting in system_*.ini
ADDRESS_MAPPING_SCHEME=Scheme8

2.3 PIM Block Placement

HBM2 case

|--------|  |--------|
|        |  |        |
| BANK_0 |  | BANK_2 |
|        |  |        |
|--------|  |--------|
|  PB_0  |  |  PB_1  |
|--------|  |--------|
|        |  |        |
| BANK_1 |  | BANK_3 |
|        |  |        |
|--------|  |--------|

2.3 PIM Instruction-Set Architecture

Type Command Description Result (DST) Operand (SRC0) Operand (SRC1)
Arithmetic ADD addition GRF GRF, BANK, SRF GRF, BANK, SRF
Arithmetic MUL multiplication GRF GRF, BANK GRF, BANK, SRF
Arithmetic MAC multiply-accumulate GRF_B GRF, BANK GRF, BANK, SRF
Arithmetic MAD multiply-and-add GRF GRF, BANK GRF, BANK, SRF
Data MOV load or store data from register to bank GRF, SRF GRF, BANK
Data FILL copy data from bank to register GRF, BANK GRF, BANK
Control NOP do nothing
Control JUMP jump instruction
Control EXIT exit instruction

2.4 Movement of Data

Mode Transaction PIM Instruction Operation
SB Read - Normal Memory Read
SB Write - Normal Memory Write
HAB Write - PIM Write (Host to PIM Register)
PIM - MOV read or write from bank to PIM Register
PIM - FILL write from bank to PIM Registers

3. Setup

3.1 Prerequisites

3.2 Installing

3.3 Launch a Test Run

Example

PIMKernelFixture. gemv_tree gemv mul add relu MemBandwidthFixture. hbm_read_bandwidth hbm_write_bandwidth PIMBenchFixture. gemv mul add relu


* Test Running
```bash
# Running: functionality test (GEMV)
./sim --gtest_filter=PIMKernelFixture.gemv

# Running: functionality test (MUL)
./sim --gtest_filter=PIMKernelFixture.mul

# Running: performance test (GEMV)
./sim --gtest_filter=PIMBenchFixture.gemv

# Running: performance test (ADD)
./sim --gtest_filter=PIMBenchFixture.add

If you want to functionality test for other dimensions, generate a new dimension in ./data and add generated dimension to the source of src/tests/KernelTestCases.cpp. Use the gen script in ./data to generate data of the dimension to be changed.

3.4 Configuration

Turning on/off verbose mode

Turning on/off data mode

4 Programming Guide

Highly recommend you to refer to src/tests/* (especially, src/tests/PIMKernel.cpp and src/tests/PIMBenchTestCases.cpp) To attach to host simulator, refer to src/tests/PIMKernel.cpp. You can see commands that request memory transactions to the memory controller for GEMV or Eltwise operations on PIM. It include a basic PIM procedure for GEMV operation in the PIMKernel::executeGemv(), and also for Eltwise operation (add, mul, relu) in the PIMKernel::executeEltwise()

4.1 Primitive Function

mem->addTransaction(is_read, address, tag, buffer);

Memory transaction

PIM transaction

4.2 PIM High-level Steps



* The other basic operation flow on PIM for GEMV(Matrix Vector multiplication), Element-wise operation are described in the `src/tests/PIMKernel.cpp`.

### Contact
* Shin-haeng Kang (s-h.kang@samsung.com)
* Sanghoon Cha (s.h.cha@samsung.com)
* Seungwoo Seo (sgwoo.seo@samsung.com)
* Jin-seong kim (jseong82.kim@samsung.com)