arm_fir_q15 state buffer sizing when ARM_MATH_LOOPUNROLL is enabled without ARM_MATH_DSP (Cortex-M3) and ARM_MATH_LOOPUNROLL is enabled with ARM_MATH_DSP (Cortex-M7)
Hi,
We're integrating CMSIS-DSP 5.9.0 into our code replacement library for Cortex-M targets and want to confirm the correctness of the state buffer allocation for arm_fir_q15 on Cortex-M3 and Cortex-M7 targets.
Observation:
In arm_fir_init_q15.c, the state buffer size is determined by ARM_MATH_DSP:
#if defined (ARM_MATH_DSP)
memset(pState, 0, (numTaps + blockSize) * sizeof(q15_t)); // M4/M7
#else
memset(pState, 0, (numTaps + blockSize - 1U) * sizeof(q15_t)); // M0/M3
#endif
However, ARM_MATH_LOOPUNROLL is a separate define that can be enabled independently of ARM_MATH_DSP. When ARM_MATH_LOOPUNROLL is enabled on a Cortex-M3 (where ARM_MATH_DSP is NOT defined), the processing function in arm_fir_q15.c (lines 483–638) uses:
read_q15x2_ia(&px)
__SMLALD(x0, c0, acc0) // (software-emulated via dsp/none.h)
The same functions are used by M4 and M7 targets with ARM_MATH_DSP and loop unroll enabled and M0 targets with loop unroll enabled.
Question:
Is it safe to use the smaller state buffer (numTaps + blockSize - 1) when ARM_MATH_LOOPUNROLL is active, but ARM_MATH_DSP is not? because same functionality is being called?
Our Configuration:
- Target's Cortex-M3 (ARMv7-M, no DSP extension), Cortex-M7 (DSP extension)
- ARM_MATH_LOOPUNROLL: defined
- ARM_MATH_DSP: NOT defined for M3, defined for M7
- CMSIS-DSP version: 1.14.3 and CMSIS version 5.9
What we need to confirm:
1. Should users allocate numTaps + blockSize (larger) or numTaps + blockSize - 1 (smaller) for M3 with loop unrolling enabled? 2. Should users allocate numTaps + blockSize (larger) or numTaps + blockSize - 1 (smaller) for M7 with DSP and loop unrolling enabled? 3. Or is enabling ARM_MATH_LOOPUNROLL without ARM_MATH_DSP an unsupported/untested configuration?
Any update