[Arc][Conversion] Lower sim.clocked_terminate to exit in LowerArcToLLVM#10089
[Arc][Conversion] Lower sim.clocked_terminate to exit in LowerArcToLLVM#10089
Conversation
106a193 to
cca53ee
Compare
|
Thank you for your contribution, @nanjo712. It would be great to finally have support for the terminate operation in arcilator. However, I'm skeptical if simply calling
One option to solve this would be to add a return value to the Please also consider our policy on AI assisted contributions: https://llvm.org/docs/AIToolPolicy.html |
7c7ade4 to
86ceb84
Compare
|
@fzi-hielscher Regarding the LLVM AI Tool Policy: I used AI tools solely for documentation translation and to assist in navigating and understanding the existing CIRCT codebase. All code, logic designs, and test cases included in this PR were manually authored and verified by me. |
86ceb84 to
5eb102f
Compare
|
To echo @fzi-hielscher, AI policy applies to PR descriptions as well. Please avoid directly pasting verbose LLM output into PR description since it's unnecessary verbose and hard to understand the real intent of the PR. (My apologies if the current description was written manually!) SI Even if the code was developed entirely without AI, verbose PR description can give the impression that the entire PR was created by LLM, which ultimately diminishes your hard work. This is from LLVM AI policy:
|
|
@uenoku |
|
No need to apologize! Thank you for sending a PR 😄 It's totally fine to use LLM or other tools for translation. |
- Implement lowering for `sim.clocked_terminate` by writing a status code (1 for success, 2 for failure) to the state at offset 8. - Increase `kStateOffset` to 16 in `AllocateState.cpp` to reserve space for the termination flag. - Use a branch to the exit block instead of calling `exit()` to allow the simulation instance to terminate without killing the host process. - Add test cases in `sim_clocked_terminate.mlir`.
5eb102f to
9e70177
Compare
|
Hi, I noticed that the CI job "Build and Test / Build and Test (clang, clang++, Debug, ON, ON) (pull_request)" is consistently failed with 'The operation was canceled.' I've checked the logs, and there are no explicit build errors; the process simply stops. Could you help check if this is due to a specific environment timeout, a resource limit? |
fzi-hielscher
left a comment
There was a problem hiding this comment.
No worries. It was indeed the PR description which made me assume AI assistance. As @uenoku said, there is nothing inherently wrong about using it, we just prefer it to be disclosed. Thanks for adding the information.
The CI is unfortunately broken at the moment and we get randomly canceled runs on all PRs. Sorry for the confusion, I don't think there is anything wrong with your code.
|
I have tried to implement it according to the suggestion. Please take a look when you have time. Thank you. |
fzi-hielscher
left a comment
There was a problem hiding this comment.
Thanks! This is already looking pretty good. A few more suggestions:
585f8e3 to
fbdfb73
Compare
fzi-hielscher
left a comment
There was a problem hiding this comment.
One last nit, otherwise LGTM. 👍
fbdfb73 to
5f4ea01
Compare
Description
This PR addresses the issue that ArcToLLVM Pass cannot correctly downgrade from sim.clocked_terminate to LLVM IR. The current implementation strategy adds 8 bytes to the reserved portion of the Model State header (8 bytes were already reserved for simulation timing; the additional 8 bytes are for alignment), with the first byte used as the terminateFlag.
Technical Changes
Reserved offset 8 in the simulation state for a termination flag by increasing kStateOffset to 16 in AllocateState.cpp.
Updated ArcToLLVM to write status codes (1 for success, 2 for failure) to this flag.
Testing
Added a new regression test: test/arcilator/sim_clocked_terminate.mlir.
Updated sim_clocked_terminate.mlir and allocate_state.mlir to verify the new memory layout and store logic.
Reference
Fixes #10087.
Assisted-by: Gemini 3 Flash (Used for English translation)