|
| 1 | +--- |
| 2 | +title: Run and CLI |
| 3 | +description: Command reference for CIMFlow compiler commands and native cim-compiler tools |
| 4 | +--- |
| 5 | + |
| 6 | +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; |
| 7 | +import { Callout } from 'fumadocs-ui/components/callout'; |
| 8 | +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; |
| 9 | +import { Terminal, Cpu } from 'lucide-react'; |
| 10 | + |
| 11 | +The compiler can be invoked through `cimflow compile` for standard workflows or the `cim-compiler` native binary for advanced use. |
| 12 | + |
| 13 | +## Which Command to Use |
| 14 | + |
| 15 | +<div className="not-prose grid gap-3 grid-cols-1 sm:grid-cols-2 my-6"> |
| 16 | + <div className="rounded-lg border border-fd-border p-4 bg-fd-card shadow-sm"> |
| 17 | + <div className="flex items-center gap-2 mb-2"> |
| 18 | + <Terminal className="size-5 text-fd-primary" /> |
| 19 | + <div className="font-semibold text-fd-primary">cimflow compile</div> |
| 20 | + </div> |
| 21 | + <div className="text-sm text-fd-muted-foreground">Standard CIMFlow workflow with automatic config resolution</div> |
| 22 | + </div> |
| 23 | + <div className="rounded-lg border border-fd-border p-4 bg-fd-card shadow-sm"> |
| 24 | + <div className="flex items-center gap-2 mb-2"> |
| 25 | + <Cpu className="size-5 text-fd-primary" /> |
| 26 | + <div className="font-semibold text-fd-primary">cim-compiler</div> |
| 27 | + </div> |
| 28 | + <div className="text-sm text-fd-muted-foreground">Native binary for advanced options, visualization, and developer tools</div> |
| 29 | + </div> |
| 30 | +</div> |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## CIMFlow Compile Command |
| 35 | + |
| 36 | +The `cimflow compile` command provides CG-level and OP-level compilation with automatic config resolution. |
| 37 | + |
| 38 | +<Tabs items={['CG-Level', 'OP-Level']}> |
| 39 | +<Tab value="CG-Level"> |
| 40 | + |
| 41 | +```bash |
| 42 | +cimflow compile cg \ |
| 43 | + -m model.onnx \ |
| 44 | + -o output/cg \ |
| 45 | + -t 8 -k 16 -b 16 -c 64 \ |
| 46 | + --batch-size 8 --strategy dp |
| 47 | +``` |
| 48 | + |
| 49 | +<Accordions> |
| 50 | +<Accordion title="Options"> |
| 51 | + |
| 52 | +| Option | Description | |
| 53 | +| --- | --- | |
| 54 | +| `-m, --model-path` | Path to the ONNX model (required) | |
| 55 | +| `-o, --output-dir` | Output directory (required) | |
| 56 | +| `-t, --mg-size` | Macro group size (default: 8) | |
| 57 | +| `-k, --mg-num` | Number of macro groups (default: 16) | |
| 58 | +| `-b, --bandwidth` | NoC bandwidth in flits (default: 16) | |
| 59 | +| `-c, --core-num` | Number of cores (default: 64) | |
| 60 | +| `--batch-size` | Batch size (default: 8) | |
| 61 | +| `--strategy` | Partition strategy (default: `dp`) | |
| 62 | +| `--visualize` | Enable visualization of partition results | |
| 63 | +| `-l, --log-level` | Log level (`TRACE`, `DEBUG`, `VERBOSE`, `INFO`, `WARNING`, `ERROR`) | |
| 64 | +| `--compiler-bin` | Path to `cim-compiler` binary (default: `cim-compiler`) | |
| 65 | +| `--paths-cfg` | Path to `tool_paths.json` (see [Framework Configuration](/docs/Framework/configuration)) | |
| 66 | + |
| 67 | +</Accordion> |
| 68 | +</Accordions> |
| 69 | + |
| 70 | +</Tab> |
| 71 | +<Tab value="OP-Level"> |
| 72 | + |
| 73 | +```bash |
| 74 | +cimflow compile op \ |
| 75 | + -i output/cg/instructions_*.json \ |
| 76 | + -o output/op \ |
| 77 | + -cf config.json |
| 78 | +``` |
| 79 | + |
| 80 | +<Accordions> |
| 81 | +<Accordion title="Options"> |
| 82 | + |
| 83 | +| Option | Description | |
| 84 | +| --- | --- | |
| 85 | +| `-i, --instruction-file` | CG instruction file (required) | |
| 86 | +| `-o, --output-dir` | Output directory (required) | |
| 87 | +| `-cf, --config` | Hardware config file (auto-resolved from T/B if omitted) | |
| 88 | +| `-cd, --config-dir` | Directory containing hardware configs (overrides `tool_paths.json`) | |
| 89 | +| `-t, --mg-size` | Macro group size (required for auto-resolution) | |
| 90 | +| `-b, --bandwidth` | NoC bandwidth (required for auto-resolution) | |
| 91 | +| `--compiler-bin` | Path to `cim-compiler` binary | |
| 92 | +| `--paths-cfg` | Path to `tool_paths.json` | |
| 93 | +| `-l, --log-level` | Log level | |
| 94 | + |
| 95 | +</Accordion> |
| 96 | +</Accordions> |
| 97 | + |
| 98 | +</Tab> |
| 99 | +</Tabs> |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Native Binary |
| 104 | + |
| 105 | +The native `cim-compiler` binary provides additional commands and options not exposed through `cimflow compile`. |
| 106 | + |
| 107 | +```bash |
| 108 | +cim-compiler [--log-level LEVEL] COMMAND [OPTIONS] |
| 109 | +``` |
| 110 | + |
| 111 | +### Global Options |
| 112 | + |
| 113 | +| Option | Description | |
| 114 | +| --- | --- | |
| 115 | +| `--log-level` | `TRACE`, `DEBUG`, `VERBOSE`, `INFO`, `WARNING`, `ERROR` | |
| 116 | +| `--version`, `-V` | Print compiler version | |
| 117 | + |
| 118 | +### Compilation Commands |
| 119 | + |
| 120 | +These commands appear when you run `cim-compiler --help`. |
| 121 | + |
| 122 | +<Accordions> |
| 123 | +<Accordion title="Network (Full CG + OP Pipeline)"> |
| 124 | + |
| 125 | +```bash |
| 126 | +cim-compiler network \ |
| 127 | + -m model.onnx \ |
| 128 | + -o output \ |
| 129 | + -c config.json \ |
| 130 | + -T 8 -K 16 -B 16 -C 64 \ |
| 131 | + --batch-size 8 --strategy dp |
| 132 | +``` |
| 133 | + |
| 134 | +Key options: |
| 135 | + |
| 136 | +- `--visualize`: Emit partition visualizations |
| 137 | +- `--keep-cg-ir`: Preserve intermediate CG JSON |
| 138 | +- `--verify`: Enable OP verify path |
| 139 | + |
| 140 | +</Accordion> |
| 141 | +<Accordion title="CG-Level (Stage 1 Only)"> |
| 142 | + |
| 143 | +```bash |
| 144 | +cim-compiler cg-level \ |
| 145 | + -m model.onnx \ |
| 146 | + -o output/cg \ |
| 147 | + -T 8 -K 16 -B 16 -C 64 \ |
| 148 | + --batch-size 8 --strategy dp |
| 149 | +``` |
| 150 | + |
| 151 | +Output: `instructions_<...>.json` (CG instruction plan) |
| 152 | + |
| 153 | +</Accordion> |
| 154 | +<Accordion title="OP-Level (Stage 2 Only)"> |
| 155 | + |
| 156 | +```bash |
| 157 | +cim-compiler op-level \ |
| 158 | + -i output/cg/instructions_*.json \ |
| 159 | + -o output/op \ |
| 160 | + -c config.json \ |
| 161 | + --verify |
| 162 | +``` |
| 163 | + |
| 164 | +Output: `isa_<cg_file>.json` (merged per-core ISA) |
| 165 | + |
| 166 | +</Accordion> |
| 167 | +</Accordions> |
| 168 | + |
| 169 | +<Callout type="warn" title="Flag Case Difference"> |
| 170 | +The native `cim-compiler` uses uppercase flags (`-T`, `-K`, `-B`, `-C`) while `cimflow compile` uses lowercase (`-t`, `-k`, `-b`, `-c`). |
| 171 | +</Callout> |
| 172 | + |
| 173 | +### Developer Commands |
| 174 | + |
| 175 | +The following commands are not shown in `cim-compiler --help` but are available for specialized use cases: format conversion, instruction inspection, behavioral simulation, and config template generation. |
| 176 | + |
| 177 | +| Command | Purpose | |
| 178 | +| --- | --- | |
| 179 | +| `compile` | Compile CIM-DSL source to `final_code.json` | |
| 180 | +| `convert` | Convert instruction formats (`json`/`asm`) | |
| 181 | +| `show` | Display instruction file in human-readable assembly | |
| 182 | +| `simulate` | Built-in behavioral simulation (distinct from the cycle-accurate `cim-simulator`) | |
| 183 | +| `multi-core-simulate` | Multi-process behavioral simulation | |
| 184 | +| `op` | Single-operator compilation/testing workflow | |
| 185 | +| `config` | Generate compiler-format config from template | |
| 186 | +| `cfg_cimsim` | Generate simulator-format config from template | |
| 187 | + |
| 188 | +### Advanced Examples |
| 189 | + |
| 190 | +```bash |
| 191 | +# DSL source -> final_code.json |
| 192 | +cim-compiler compile -i code.cim -o output/codegen -c config.json |
| 193 | + |
| 194 | +# JSON ISA -> ASM |
| 195 | +cim-compiler convert --src-type json --dst-type asm --src-file isa.json --dst-file isa.asm |
| 196 | + |
| 197 | +# Inspect instruction stream |
| 198 | +cim-compiler show -i isa.json --type json |
| 199 | +``` |
0 commit comments