-
Notifications
You must be signed in to change notification settings - Fork 4
Introduce ELF CPU extractor and simulator options. #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Not sure if QEMU supports all CPUs but I think it makes sense to adapt this approach for it too. |
d491677
to
d4ad7b3
Compare
Add a python script that extracts the ARC CPU name and XLEN from an ELF file by parsing the .ARC.attributes section. The script maps CPU names to simulator options. Currently only NSIM options are supported, but the design allows for future expansion to other simulators. Signed-off-by: Luis Silva <[email protected]>
Updated arc64-elf-run to dynamically obtain NSIM options using mcpu-to-cpu-opts instead of hardcoded CPU configuration while keeping common NSIM runtime options. Replaced arc-elf32-run and arc32-elf-run with a symlink to arc64-elf-run. Signed-off-by: Luis Silva <[email protected]>
Remove hardcoded QEMU CPU selection logic and instead use "mcpu-to-cpu-opts" to dynamically determine the appropriate CPU and XLEN from the ELF file in simulator wrappers. Signed-off-by: Luis Silva <[email protected]>
d4ad7b3
to
d352f28
Compare
import elftools.elf.elffile | ||
import elftools.elf.sections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle the 3rd party dependency somehow?
Install in a venv in the makefile? Or at least print an error with instructions if its not found.
@luismgsilva thanks for this work but would be really nice to add a motivational part to the PR description. I.e. why do we need that functionality at all? What if we don't need that? |
"-p nsim_isa_code_density_option=2", | ||
"-p nsim_isa_mpy_option=2" | ||
], | ||
"hs38_linux": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very fragile approach. See, what you have here I guess is ARCv2 -mcpu
value used for building a particular elf. But what if in addition to that somebody added more options like -mmpy-option={none|plus_qmacw}
or -m{no-}ll64
, which will disable or enable use of a certain HW features by emitting certain instructions? That's more of a guess work here and it will bite you later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, there are cases where additional options (-mmpy-option, -m{no-}ll64, etc.) affect the generated code and should be reflected in the execution command.
The intention of this PR, though, is not to cover every possible configuration detail upfront, but to provide a baseline: a generic execution command per CPU which was extracted from the Jenkins dejagnu logs. This already saves developers from having to manually search CI logs when reproducing regressions.
The script can definitely be extended in the future to handle specific feature options or more complex configurations, but even in its current form it significantly reduces the manual effort of local testing.
Signed-off-by: Luis Silva <[email protected]>
Add a python script that extracts the ARC CPU name and XLEN from
an ELF file by parsing the .ARC.attributes section. The script
maps CPU names to simulator options. Currently only NSIM options
are supported, but the design allows for future expansion to
other simulators.
This PR improves the current handler so that tests can be run locally
for CPUs beyond just archs, hs5x, and hs6x.
The motivation is to make local testing practical: when debugging
regressions, it is far more convenient to have an automated way to
run a specific test (or a set of tests) for any supported CPU, rather
than digging through CI logs to extract the correct execution
command for each CPU.
This does not replace CI but complements it. CI remains the
source of truth, but with this addition developers can quickly
reproduce issues locally and validate fixes before pushing.
Without this functionality, reproducing regressions is tedious
and error-prone, which slows down debugging and development.