CIMFlow LogoCIMFlow

OP-Level

Lower CG tasks to per-core ISA with synchronization and code assembly

OP-level compilation consumes CG task JSON and emits ISA instruction streams keyed by numeric core IDs ("0", "1", ...).

OP-Level Processing Steps

Parse CG Tasks

Read per-core staged CG task entries from the input JSON

Lower to ISA

Convert each high-level operation to ISA instruction sequences

Compile Kernels

Generate ISA code for operator kernels (conv, depthwise conv) when needed

Insert Synchronization

Add TAG and WAIT instructions for inter-stage global-memory dependencies

Merge Per-Core Output

Combine per-core instruction streams into a unified ISA JSON file


Commands

cim-compiler op-level \
  -i output/cg/instructions_*.json \
  -o output/op \
  -c config.json \
  --verify
cimflow compile op \
  -i output/cg/instructions_*.json \
  -o output/op \
  -cf config.json

Verify Flag

--verify enables correctness checks for operator kernel compilation (conv, depthwise). Coverage varies across instruction paths — it does not validate every emitted instruction.


Input Format

OP-level expects CG JSON in this shape:

FieldRequiredDescription
metadataNoOptional metadata object (for example op_count)
core_<row>_<col>YesCore task entries such as core_0_0, core_0_1, ...
stagesYesStage container under each core entry
instructionsYesInstruction list under each stage

The following instruction types are supported in CG task entries.

CategoryInstructions
Memoryread, write
Computeconv, depthwise_conv, add
Communicationsend, receive, send_ring, receive_ring
Synchronizationwait_write

Lowering Rules (High-Level)

Each CG-level instruction is converted to one or more ISA instruction sequences. The table below shows the conversion pattern for each operation type.

For multi-core runs with inter-stage dependencies, OP-level inserts synchronization instructions. Producers emit TAG to mark write completion on global memory, and consumers emit WAIT to block until expected writes arrive. This prevents read-before-write races across stages.


Output Format

Output file naming depends on the compilation path:

Staged Command
isa_<cg_file_name>.json
One-Step Network
isa_instructions_<model>_...json

Unified ISA structure:

{
  "metadata": {
    "op_count": 1110836224
  },
  "0": [
    {"opcode": 45, "rd": 16, "imm": 8},
    {"opcode": 48, "rs": 0, "rt": 2, "rd": 1, "imm": 0}
  ],
  "1": [
    {"opcode": 45, "rd": 16, "imm": 8}
  ]
}

Intermediate Files

OP-level writes temporary per-core files under each_core/ before merging them into the final unified ISA JSON. These can be removed after compilation.

Last updated on