[ESI][Runtime] Add cycle count and frequency to SysInfo#9423
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds cycle count and core clock frequency information to the ESI runtime's SysInfo service, enabling clients to query simulation time and clock characteristics from the accelerator.
Key changes:
- Extended the SysInfo API with
getCycleCount()andgetCoreClockFrequency()methods - Added SystemVerilog module
Cosim_CycleCountto track cycle counts in cosimulation - Updated RPC protocol (protobuf) and all backend implementations (MMIO, RpcServer, RpcClient, Cosim)
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/Dialect/ESI/runtime/cpp/include/esi/Services.h | Added virtual methods getCycleCount() and getCoreClockFrequency() to SysInfo base class |
| lib/Dialect/ESI/runtime/cpp/include/esi/Accelerator.h | Defined memory layout constants (CycleCountOffset, CoreFreqOffset) for MMIO access |
| lib/Dialect/ESI/runtime/cpp/include/esi/backends/RpcServer.h | Added GetCycleCountFunc typedef and updated setSysInfo signature |
| lib/Dialect/ESI/runtime/cpp/include/esi/backends/RpcClient.h | Added getCycleCount() and getCoreClockFrequency() methods to RPC client |
| lib/Dialect/ESI/runtime/cpp/lib/Services.cpp | Implemented MMIO-based cycle count and frequency reading with offset constants |
| lib/Dialect/ESI/runtime/cpp/lib/backends/RpcServer.cpp | Renamed GetManifest to GetSysInfo, added cycle count/frequency to RPC response |
| lib/Dialect/ESI/runtime/cpp/lib/backends/RpcClient.cpp | Implemented getCycleCount/getCoreClockFrequency using getSysInfo RPC call |
| lib/Dialect/ESI/runtime/cpp/lib/backends/Cosim.cpp | Added cycle count/frequency passthrough methods in CosimSysInfo |
| lib/Dialect/ESI/runtime/python/esiaccel/esiCppAccel.cpp | Exposed new SysInfo methods to Python bindings |
| lib/Dialect/ESI/runtime/cosim_dpi_server/dpi.h | Added DPI export and import declarations for cycle count callback |
| lib/Dialect/ESI/runtime/cosim_dpi_server/DpiEntryPoints.cpp | Implemented setSysInfo logic with cycle count callback registration |
| lib/Dialect/ESI/runtime/cosim_dpi_server/DummySvDpi.cpp | Added stub for c2svCosimserverGetCycleCount DPI export |
| lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_DpiPkg.sv | Added cosim_set_cycle_count_callback DPI import |
| lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_CycleCount.sv | New SystemVerilog module implementing cycle counter with DPI export |
| lib/Dialect/ESI/runtime/cosim_dpi_server/CMakeLists.txt | Added Cosim_CycleCount.sv to build collateral |
| lib/Dialect/ESI/runtime/cosim.proto | Renamed Manifest to SysInfo, added cycle_count and core_clock_frequency_hz fields |
| lib/Dialect/ESI/Passes/ESILowerToHW.cpp | Created __ESICycleCounter wrapper module and Cosim_CycleCount extern declaration |
| frontends/PyCDE/src/pycde/bsp/common.py | Extended MMIO header array with cycle counter (though with incorrect layout) |
| frontends/PyCDE/integration_test/test_software/esi_test.py | Added integration tests for cycle count monotonicity and clock frequency |
| test/Dialect/ESI/manifest.mlir | Added test expectations for cycle counter module generation |
| header = Array(Bits(64), 8)([ | ||
| 0, # Generally a good idea to not use address 0. | ||
| MagicNumber, # ESI magic number. | ||
| VersionNumber, # ESI version number. | ||
| manifest_loc, # Absolute address of the manifest ROM. | ||
| 0, # Reserved for future use. | ||
| cycles.out.as_bits(), # Cycle counter. | ||
| core_freq, # Core frequency, if known. | ||
| 0, | ||
| ]) |
There was a problem hiding this comment.
Nit: Is there some way to correlate this better with the metadata constants presented in Accelerator.h? While we can't share code, there could maybe be some injection of these values into an array using the same hex offsets as what is used in Accelerator.h. I think that would help debuggability and code clarity a lot.
There was a problem hiding this comment.
Since the hardware and software sides of the BSPs are so intertwined, I've been considering moving the PyCDE BSP libraries into esiaccel. Then I'd have esiaccel depend on some public version of PyCDE so we could co-locate the cosim runtime tests. It would also provide an opportunity to read the constants out of Accelerator.h from python.
WDYT?
No description provided.