Skip to content
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

DSP: add dsp support #5

Open
wants to merge 3 commits into
base: siyuan-embarc_mli_v2.0-base_tempo
Choose a base branch
from

Conversation

SiyuanCheng-CN
Copy link

@SiyuanCheng-CN SiyuanCheng-CN commented Aug 9, 2022

add dsp config to enable dsp registers

This commit is just a basic dsp support, DSP SHARING is not guaranteed to fully succeed.

Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, see comments.
Also, I'd like to see some test application added that tests the DSP context switching.

arch/Kconfig Outdated Show resolved Hide resolved
@@ -115,6 +115,17 @@ GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp2l);
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp1h);
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp1l);
#endif
#endif
#ifdef CONFIG_DSP
GEN_OFFSET_SYM(_callee_saved_stack_t, dsp_ctrl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to save the control registers (DSP_CTRL and DSP_FFT_CTRL)?
I guess it depends on the application, but the rounding/saturation etc. settings may be a global choice, not per task.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite familiar with DSP. But I think If two threads are running two different DSP applications, DSP_CTRL is quite likely different. And Jacco in MLI team told me that, MLI sets the dsp mode on every call, make sure that at least accumulator registers and dsp mode are saved and restored.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, if also DSP mode is used dynamically and not statically configured, then it should be saved. Maybe ask @JaccovG to review this PR as well?

include/zephyr/kernel.h Outdated Show resolved Hide resolved
soc/arc/snps_nsim/Kconfig Outdated Show resolved Hide resolved
soc/arc/snps_nsim/Kconfig Outdated Show resolved Hide resolved
@SiyuanCheng-CN SiyuanCheng-CN requested a review from ruuddw August 15, 2022 08:43
arch/arc/Kconfig Outdated Show resolved Hide resolved
arch/arc/Kconfig Outdated Show resolved Hide resolved
arch/arc/include/swap_macros.h Outdated Show resolved Hide resolved
arch/arc/core/thread.c Outdated Show resolved Hide resolved
arch/arc/include/swap_macros.h Outdated Show resolved Hide resolved
@ruuddw
Copy link
Member

ruuddw commented Aug 17, 2022

Thanks for adding a test, however it looks like the test needs some more work. It looks like copy-paste-edit of the fpu_sharing, but with lots of fpu_sharing stuff still in (description etc. refer to floating point, it says it computes pi but it doesn't?).
If the test indeed is very similar, maybe consider modifying/generalizing the FPU sharing test to also cover DSP?
If it is really different, then please clean it up further.

@SiyuanCheng-CN
Copy link
Author

Thanks for adding a test, however it looks like the test needs some more work. It looks like copy-paste-edit of the fpu_sharing, but with lots of fpu_sharing stuff still in (description etc. refer to floating point, it says it computes pi but it doesn't?). If the test indeed is very similar, maybe consider modifying/generalizing the FPU sharing test to also cover DSP? If it is really different, then please clean it up further.

Yes, it's still a draft, I need to add a test, which includes some DSP instructions to calculate something on XY memory to replace PI calculation. I'm trying to find examples from MLI, but it's not that easy to reproduce it without whole MLI library, do you have any ideas about example? The idea of register context switching from FPU_SHARING is good and also works for DSP register, I'll do more modifications and clean it up.

@SiyuanCheng-CN SiyuanCheng-CN force-pushed the siyuan-dsp_reg branch 2 times, most recently from f73e0c8 to add1953 Compare September 11, 2022 21:19
arch/arc/Kconfig Outdated Show resolved Hide resolved
arch/arc/Kconfig Outdated Show resolved Hide resolved
arch/arc/Kconfig Outdated Show resolved Hide resolved
arch/arc/core/offsets/offsets.c Outdated Show resolved Hide resolved
cmake/compiler/arcmwdt/compiler_flags.cmake Outdated Show resolved Hide resolved
kernel/include/kernel_arch_interface.h Outdated Show resolved Hide resolved
kernel/thread.c Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/complex_calculation.c Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/complex_calculation.c Outdated Show resolved Hide resolved
arch/arc/Kconfig Outdated Show resolved Hide resolved
Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments remaining to be handle before submitting upstream.

arch/arc/core/thread.c Show resolved Hide resolved
arch/arc/core/thread.c Outdated Show resolved Hide resolved
arch/arc/include/swap_macros.h Outdated Show resolved Hide resolved
soc/arc/snps_nsim/CMakeLists.txt Show resolved Hide resolved
arch/Kconfig Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/CMakeLists.txt Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/complex_calculation.c Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/complex_calculation.c Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/dsp_context.h Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/generic/src/dsp_context.h Outdated Show resolved Hide resolved
@SiyuanCheng-CN SiyuanCheng-CN force-pushed the siyuan-dsp_reg branch 3 times, most recently from 64d140b to c6d01b1 Compare September 27, 2022 14:12
@ruuddw
Copy link
Member

ruuddw commented Sep 27, 2022

Thanks for adding the 'dsp' variant for nsim, but let's call the new config nsim_em11d instead of 'dsp' - that aligns with the ARC core names (see also the EMSK and EMSDP boards). Note that when introducing a new board, also the ARC boards documentation for nSIM simulation should be updated.

@SiyuanCheng-CN
Copy link
Author

Thanks for adding the 'dsp' variant for nsim, but let's call the new config nsim_em11d instead of 'dsp' - that aligns with the ARC core names (see also the EMSK and EMSDP boards). Note that when introducing a new board, also the ARC boards documentation for nSIM simulation should be updated.

Could you please point the link of documentation that I'm going to amend.

@ruuddw
Copy link
Member

ruuddw commented Sep 27, 2022

Could you please point the link of documentation that I'm going to amend.

boards\arc\nsim\doc\index.rst

add DSP reg in context switch
add AGU reg in context switch to support XY mem
add thread option and API to dis/enable DSP switch

Signed-off-by: Siyuan Cheng <[email protected]>
Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the nSIM properties include caches, I suggested EM11D (EM9D has DSP, AGU/XY but no caches). But I believe the Zephyr configuration doesn't include the cache features (EM4_FPDA as basis, not EM6).

boards/arc/nsim/nsim_em11d.yaml Outdated Show resolved Hide resolved
boards/arc/nsim/nsim_em11d.yaml Outdated Show resolved Hide resolved
soc/arc/snps_nsim/Kconfig Outdated Show resolved Hide resolved
soc/arc/snps_nsim/Kconfig Show resolved Hide resolved
soc/arc/snps_nsim/Kconfig.defconfig.em11d Outdated Show resolved Hide resolved
tests/kernel/dsp_sharing/CMakeLists.txt Show resolved Hide resolved
Siyuan Cheng added 2 commits September 29, 2022 15:12
add nsim_em11d target specific for DSP feature

Signed-off-by: Siyuan Cheng <[email protected]>
add dsp context switch test
add complex multiplication test for ARC processor

Signed-off-by: Siyuan Cheng <[email protected]>
Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all my feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants