-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add ARC_MPY_OPTION to kconfig #39460
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
Add ARC_MPY_OPTION to kconfig #39460
Conversation
91627bc to
e73cfdb
Compare
|
I'd say this is a bit incomplete change as if we introduce that granular MPY option it makes sense to also handle that in options we pass to the compiler. And both: |
|
Not sure I would like setting compiler options via kconfig defines. We have TCF files that have all the relevant options, I rather see these to be leading, and maybe generate a kconfig from that instead. For now, why not simply define 'HAS_ACCL' for the relevant boards instead of introducing the MPY option? |
|
@ruuddw I think defining HAS_ACCL statically is not flexable for all arc targets. The help message for HAS_ACCL already states that it should be enabled when FPU and/or MPY > 6 but MPY is nowhere to be found. Defining MPY_OPTION has the same effect as define HAS_ACCL everywhere, but it can also provide more: We could add compiler options later so it could improve performance. |
|
For selecting the relevant compiler flags, I'd like to see a move to using the ARC Tool Configuration files (TCF), instead of introducing corresponding kconfig options for all of these. |
0c2cea2 to
5a2af85
Compare
soc/arc/snps_nsim/CMakeLists.txt
Outdated
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.
Hmm, this looks very suspicious.
We set it for EMSK and GNU toolchain
zephyr_compile_options_ifdef(CONFIG_ARC_MPY_OPTION -mmpy-option=${CONFIG_ARC_MPY_OPTION})
but we hardcode number here.
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.
I'm taking reference from tcf files here but I find the option value in tcf file is mismatch between metaware option and gnu option. For example in emsk arcem9d.tcf there's -Xmpy_option=mpyd (which is synonym of -Xmpy_option=8) and -mmpy-option=6 at the same time. That's the reason I put hardcode here. What do you think if I change kconfig value to lowest mpy_option value in tcf (at the cost of disable some MPY instructions when use metaware toolchain)?
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.
I get the confirmation from GNU team that at the moment the EM mpy value is limited to 6 as DSP exensions for EM are not supported.
caf4126 to
d840da2
Compare
soc/arc/snps_nsim/CMakeLists.txt
Outdated
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.
Even if we actually need this I'd prefer to have this logic in some Cmake function/macro in arc .cmake and call it from SoC CMakeLists.txt. We can call it arc_finalize_mpy_compile_options and put option for both GNU and MWDT toolchain in it.
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.
not sure - if we want a clean, generic solution, then I come back to my earlier suggestion: it would be better to have the option to use tcf files for all hardware specific compiler options/flags.
|
@ruuddw so then maybe we just set |
Yes, that's what I proposed as my first feedback to this PR already: "For now, why not simply define 'HAS_ACCL' for the relevant boards instead of introducing the MPY option?" |
d840da2 to
e15ef79
Compare
|
I've run twister test with jenkins and the result proves the fix. |
ruuddw
left a comment
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.
Thanks, this is much simpler and specific.
arch/arc/Kconfig
Outdated
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.
BTW, the default FPU usage is without FPU_SHARING - we assume that we use FPU only in one thread, so we don't need ARC_HAS_ACCL_REGS if we have FPU by default (at least on ARC HS).
I guess we are enabling ARC_HAS_ACCL_REGS because we assuming that ACCL_REGS would be used by MPY instructions. Probably we need to add comment here that if we don't need to enable it if our system doesn't support MPY instructions / we are 100% sure that we don't use them.
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.
Triggered by this, I checked and actually believe FPU doesn't always mean the accl registers are there. Instead, they are only available if fused multiply & add/sub is configured in the hardware.
I think this default line can simply be removed and left to SoC configuration.
ruuddw
left a comment
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.
See comments, I don't believe FPU implies by default that accumulator registers are present.
ARC_HAS_ACCL_REGS should set to y to protect ACCL and ACCH registers during irq. These registers could be used as GPRs by compilers and therefore need store/restore during irq. Signed-off-by: Yuguo Zou <[email protected]>
e0d4b12 to
4093e2a
Compare
ruuddw
left a comment
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.
Simple is often better, fixing the 'CONFIG_HAS_ACCL_REGS was not set' can be as simple as setting it for the targets that need this.
The CONFIG_ARC_HAS_ACCL_REGS is not set for most of ARC targets. When it is set, it provides saving & restoring to r58 and r59 which are acch and accl registers. The condition to set CONFIG_ARC_HAS_ACCL_REGS should be FPU and/or MPY > 6 but there's no corresponding kconfig item for MPY.
The issue mentioned in #39392 was caused by this, CONFIG_ARC_HAS_ACCL_REGS was not set but arcmwdt compiler uses accl and acch as general purpose registers which are corrupted during IRQ.
This PR add a new ARC_MPY_OPTION to kconfig to patch this problem.
Fixes #39392