|
28 | 28 | "\n", |
29 | 29 | "examples_dir = Path(\"../../examples\")\n", |
30 | 30 | "\n", |
31 | | - "display(Markdown(f\"\"\"\n", |
| 31 | + "display(\n", |
| 32 | + " Markdown(\n", |
| 33 | + " f\"\"\"\n", |
32 | 34 | "```yaml\n", |
33 | 35 | "{open(examples_dir / \"misc\" / \"component_annotated.yaml\").read()}\n", |
34 | 36 | "```\n", |
35 | | - "\"\"\"))" |
| 37 | + "\"\"\"\n", |
| 38 | + " )\n", |
| 39 | + ")" |
36 | 40 | ] |
37 | 41 | }, |
38 | 42 | { |
|
53 | 57 | "\n", |
54 | 58 | "# Create the component from the yaml file\n", |
55 | 59 | "import accelforge as af\n", |
| 60 | + "\n", |
56 | 61 | "global_buffer = af.arch.Memory.from_yaml(\n", |
57 | 62 | " examples_dir / \"misc\" / \"component_annotated.yaml\"\n", |
58 | 63 | ")\n", |
|
68 | 73 | "for action in global_buffer.actions:\n", |
69 | 74 | " energy = action.energy\n", |
70 | 75 | " latency = action.latency\n", |
71 | | - " print(f'Action {action.name} energy {energy:.2e} J, latency {latency:.2e}s')" |
| 76 | + " print(f\"Action {action.name} energy {energy:.2e} J, latency {latency:.2e}s\")" |
72 | 77 | ] |
73 | 78 | }, |
74 | 79 | { |
|
127 | 132 | "source": [ |
128 | 133 | "# < DOC_INCLUDE_MARKER > hwcomponents\n", |
129 | 134 | "component_model = global_buffer.component_model\n", |
130 | | - "print(help(component_model)) # Get documentation for the model" |
| 135 | + "print(help(component_model)) # Get documentation for the model" |
131 | 136 | ] |
132 | 137 | }, |
133 | 138 | { |
|
155 | 160 | "component_model: SmartBufferSRAM = global_buffer.component_model\n", |
156 | 161 | "\n", |
157 | 162 | "# Inspect the area of each of its subcomponents\n", |
158 | | - "print(f'Area: {component_model.area:.2e} m^2')\n", |
159 | | - "print(f'\\tSRAM area: {component_model.sram.area:.2e} m^2')\n", |
160 | | - "print(f'\\tAdder area: {component_model.adder.area:.2e} m^2')\n", |
161 | | - "print(f'\\tAddress register area: {component_model.address_reg.area:.2e} m^2')\n", |
162 | | - "print(f'\\tDelta reg area: {component_model.delta_reg.area:.2e} m^2')" |
| 163 | + "print(f\"Area: {component_model.area:.2e} m^2\")\n", |
| 164 | + "print(f\"\\tSRAM area: {component_model.sram.area:.2e} m^2\")\n", |
| 165 | + "print(f\"\\tAdder area: {component_model.adder.area:.2e} m^2\")\n", |
| 166 | + "print(f\"\\tAddress register area: {component_model.address_reg.area:.2e} m^2\")\n", |
| 167 | + "print(f\"\\tDelta reg area: {component_model.delta_reg.area:.2e} m^2\")" |
163 | 168 | ] |
164 | 169 | }, |
165 | 170 | { |
|
176 | 181 | "metadata": {}, |
177 | 182 | "outputs": [], |
178 | 183 | "source": [ |
179 | | - "display(Markdown(f\"\"\"\n", |
| 184 | + "display(\n", |
| 185 | + " Markdown(\n", |
| 186 | + " f\"\"\"\n", |
180 | 187 | "```yaml\n", |
181 | 188 | "{open(examples_dir / \"arches\" / \"eyeriss.yaml\").read()}\n", |
182 | 189 | "```\n", |
183 | | - "\"\"\"))" |
| 190 | + "\"\"\"\n", |
| 191 | + " )\n", |
| 192 | + ")" |
184 | 193 | ] |
185 | 194 | }, |
186 | 195 | { |
|
207 | 216 | "spec = spec.calculate_component_area_energy_latency_leak()\n", |
208 | 217 | "\n", |
209 | 218 | "# Print out the total area and leakage power of the entire design\n", |
210 | | - "print(f'Total area of the design: {spec.arch.total_area:.2e} m^2')\n", |
211 | | - "print(f'Area breakdown per component:')\n", |
| 219 | + "print(f\"Total area of the design: {spec.arch.total_area:.2e} m^2\")\n", |
| 220 | + "print(f\"Area breakdown per component:\")\n", |
212 | 221 | "for component, area in spec.arch.per_component_total_area.items():\n", |
213 | | - " print(f'\\t{component}: {area:.2e} m^2')\n", |
214 | | - "print(f'Total leakage power of the design: {spec.arch.total_leak_power:.2e} W')\n", |
| 222 | + " print(f\"\\t{component}: {area:.2e} m^2\")\n", |
| 223 | + "print(f\"Total leakage power of the design: {spec.arch.total_leak_power:.2e} W\")\n", |
215 | 224 | "for component, leak_power in spec.arch.per_component_total_leak_power.items():\n", |
216 | | - " print(f'\\t{component}: {leak_power:.2e} W')" |
| 225 | + " print(f\"\\t{component}: {leak_power:.2e} W\")" |
217 | 226 | ] |
218 | 227 | }, |
219 | 228 | { |
|
231 | 240 | "outputs": [], |
232 | 241 | "source": [ |
233 | 242 | "mac = spec.arch.find(\"MAC\")\n", |
234 | | - "print(f'MAC area: {mac.area:.2e} m^2')\n", |
235 | | - "print(f'Total area of all MACs in the architecture: {mac.total_area:.2e} m^2')\n", |
236 | | - "print(f'MAC leak power: {mac.leak_power:.2e} W')\n", |
237 | | - "print(f'Total leak power of all MACs in the architecture: {mac.total_leak_power:.2e} W')\n", |
| 243 | + "print(f\"MAC area: {mac.area:.2e} m^2\")\n", |
| 244 | + "print(f\"Total area of all MACs in the architecture: {mac.total_area:.2e} m^2\")\n", |
| 245 | + "print(f\"MAC leak power: {mac.leak_power:.2e} W\")\n", |
| 246 | + "print(f\"Total leak power of all MACs in the architecture: {mac.total_leak_power:.2e} W\")\n", |
238 | 247 | "for action in mac.actions:\n", |
239 | | - " print(f'{action.name} energy: {action.energy:.2e} J, latency {action.latency:.2e}s')" |
| 248 | + " print(f\"{action.name} energy: {action.energy:.2e} J, latency {action.latency:.2e}s\")" |
240 | 249 | ] |
241 | 250 | }, |
242 | 251 | { |
|
268 | 277 | "# to make these!\n", |
269 | 278 | "import hwcomponents as hwc\n", |
270 | 279 | "\n", |
| 280 | + "\n", |
271 | 281 | "class MyMac(hwc.ComponentModel):\n", |
272 | 282 | " component_name: str = \"intmac\"\n", |
273 | 283 | " priority: float = 0.5\n", |
274 | 284 | "\n", |
275 | 285 | " def __init__(self):\n", |
276 | | - " super().__init__(\n", |
277 | | - " area=5e-8,\n", |
278 | | - " leak_power=1e-12 # Very low leakage power\n", |
279 | | - " )\n", |
| 286 | + " super().__init__(area=5e-8, leak_power=1e-12) # Very low leakage power\n", |
280 | 287 | "\n", |
281 | 288 | " @hwc.action\n", |
282 | 289 | " def compute(self) -> float:\n", |
283 | | - " self.logger.info(f'*** Getting compute energy ***')\n", |
| 290 | + " self.logger.info(f\"*** Getting compute energy ***\")\n", |
284 | 291 | " # 1pJ, 1ns\n", |
285 | 292 | " return 1e-12, 1e-9\n", |
286 | 293 | "\n", |
| 294 | + "\n", |
287 | 295 | "# Initialize the spec and make the MAC use our custom model\n", |
288 | 296 | "spec = af.Spec.from_yaml(examples_dir / \"arches\" / \"eyeriss.yaml\")\n", |
289 | 297 | "mac = spec.arch.find(\"MAC\")\n", |
290 | 298 | "mac.component_model = MyMac()\n", |
291 | 299 | "\n", |
292 | 300 | "# Calculate the energy and area of the MAC and print out the results\n", |
293 | 301 | "mac = mac.calculate_area_energy_latency_leak()\n", |
294 | | - "print(f'MAC area: {mac.area:.2e} m^2')\n", |
295 | | - "print(f'MAC leak power: {mac.leak_power:.2e} W')\n", |
| 302 | + "print(f\"MAC area: {mac.area:.2e} m^2\")\n", |
| 303 | + "print(f\"MAC leak power: {mac.leak_power:.2e} W\")\n", |
296 | 304 | "for action in mac.actions:\n", |
297 | | - " print(f'{action.name} energy: {action.energy:.2e} J, latency {action.latency:.2e}s')\n", |
| 305 | + " print(f\"{action.name} energy: {action.energy:.2e} J, latency {action.latency:.2e}s\")\n", |
298 | 306 | "\n", |
299 | 307 | "# The energy and area log contain logs from the ComponentModel component.\n", |
300 | 308 | "print(f\"Log messages: \")\n", |
|
327 | 335 | "for model in hwc.get_models()[:5]:\n", |
328 | 336 | " print(f\"{model} supports {model.component_name}\")\n", |
329 | 337 | " for action in model.get_action_names():\n", |
330 | | - " print(f'\\t{action}')\n", |
| 338 | + " print(f\"\\t{action}\")\n", |
331 | 339 | "\n", |
332 | 340 | "\n", |
333 | 341 | "from hwcomponents_adc import ADC\n", |
| 342 | + "\n", |
334 | 343 | "help(ADC)" |
335 | 344 | ] |
336 | 345 | } |
|
0 commit comments