Skip to content

[POC] unit test on xt-run - #11614

Open
tmleman wants to merge 4 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/unit_test/ztest/xtensa_iss
Open

tmleman wants to merge 4 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/unit_test/ztest/xtensa_iss

Conversation

@tmleman

@tmleman tmleman commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@tmleman tmleman added the DNM Do Not Merge tag label Dec 3, 2026
Copilot AI balanced review requested due to automatic review settings December 3, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The moving Zephyr PR-head reference allows upstream pushes to change firmware and test dependencies for the same SOF commit, making builds non-reproducible.

1 open issue
What changed in this PR

This proof of concept extends SOF math unit tests to Cadence xt-run, exercising DSP-specific implementations without hardware while retaining native simulation.

Changes:

  • Add ISS scenarios for FFT, DFT3, and advanced math tests.
  • Provide ISS build configuration, headers, and library support.
  • Reference the Zephyr PR providing the simulator boards.
File Description
west.yml Select ISS-enabled Zephyr PR.
test/​ztest/​unit/​math/​fft_multi/​testcase.yaml Add FFT ISS scenarios.
test/​ztest/​unit/​math/​fft_multi/​prj.conf Configure diagnostics and heap metadata.
test/​ztest/​unit/​math/​fft_multi/​CMakeLists.txt Separate platform settings; add HiFi FFT source.
test/​ztest/​unit/​math/​fft_multi/​boards/​native_sim.conf Preserve sanitizer-visible native allocations.
test/​ztest/​unit/​math/​dft3/​testcase.yaml Add DFT3 ISS scenarios.
test/​ztest/​unit/​math/​dft3/​prj.conf Enable floating-point diagnostics.
test/​ztest/​unit/​math/​dft3/​CMakeLists.txt Limit POSIX settings to native builds.
test/​ztest/​unit/​math/​advanced/​functions/​testcase.yaml Add advanced math ISS scenarios.
test/​ztest/​unit/​math/​advanced/​functions/​prj.conf Enable floating-point diagnostics.
test/​ztest/​unit/​math/​advanced/​functions/​CMakeLists.txt Add ISS math-library integration.
test/​ztest/​unit/​common/​xtensa_iss/​newlib_errno.c Bridge newlib errno to Zephyr.
test/​ztest/​unit/​common/​xtensa_iss/​include/​platform/​platform.h Provide core-only platform stub.
test/​ztest/​unit/​common/​xtensa_iss/​include/​platform/​lib/​memory.h Provide core-only memory stub.
test/​ztest/​unit/​common/​xtensa_iss/​include/​math.h Declare reference math functions.

Review effort: Balanced

Comment thread west.yml
- name: zephyr
repo-path: zephyr
revision: 25851fa15cdc2dc9c395807bce97fa81c46c10ee
revision: pull/128018/head
Use the head of zephyrproject-rtos/zephyr PR 128018 as the Zephyr
revision. The PR adds the Intel ADSP core instruction-set simulator
boards intel_adsp_iss/ace20_lnl_iss, ace30_ptl_iss and ace40_nvl_iss,
and the ztest changes needed to run unit tests on them with the Cadence
xt-run simulator.

The PR is based on the current Zephyr main, so this also moves SOF from
25851fa15cdc to a newer Zephyr. The revisions of the imported modules
do not change.

A pull request reference moves with the PR. It has to be replaced with
a commit of Zephyr main once the PR is merged.

Link: zephyrproject-rtos/zephyr#128018

Assisted-by: Copilot:claude-fable-5.2
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Add a scenario that builds the DFT3 unit test with xt-clang for the
Intel ADSP instruction-set simulator boards and runs it with xt-run, on
the ACE20 (HiFi4), ACE30 (HiFi4) and ACE40 (HiFi5) core profiles. The
native_sim scenario is unchanged.

To build for a non-POSIX target, apply the POSIX platform include
directory and the CONFIG_ZEPHYR_POSIX and CONFIG_LIBRARY definitions
only to POSIX builds, and stop excluding the Xtensa architecture.

Enable CONFIG_CBPRINTF_FP_SUPPORT, the test prints its error figures as
floating point values.

The ISS scenario has no integration_platforms entry: the boards only
support xt-clang, and Twister in integration mode reports an
integration platform that the selected toolchain cannot build as an
error.

Assisted-by: Copilot:gpt-6.1-sol
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Add a scenario that builds the multi-size FFT unit test with xt-clang
for the Intel ADSP instruction-set simulator boards and runs all eleven
FFT and IFFT cases with xt-run, with the same reference vectors and
tolerances as on native_sim.

To build for the simulator:
- apply the POSIX platform include directories and definitions only to
  POSIX builds, and stop excluding the Xtensa architecture;
- add core-only platform headers for the ISS boards. They are empty:
  the core simulator has no SOF platform devices and no ACE memory map,
  the SOF heap of zephyr/lib/alloc.c uses the linker-provided bounds;
- link fft_32_hifi3.c, which provides the 32 bit FFT on HiFi targets
  and compiles to nothing elsewhere;
- move CONFIG_SOF_NATIVE_SIM_HOST_HEAP to a native_sim board
  configuration, the option does not exist for other boards.

Enable CONFIG_CBPRINTF_FP_SUPPORT for the floating point values in the
test messages.

The ISS scenario has no integration_platforms entry, for the same
reason as in the dft3 test.

Assisted-by: Copilot:gpt-6.1-sol
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Add a scenario that builds the math advanced functions suite with
xt-clang for the Intel ADSP ISS boards and runs it with xt-run. On
these targets sofm_exp_approx(), sofm_exp_fixed() and
sofm_db2lin_fixed() come from the HiFi implementation in
src/math/exp_fcn_hifi.c, which no unit test executed so far: on
native_sim the file compiles to nothing and the generic exp_fcn.c is
tested instead.

The tests calculate their reference values with libm functions. For
the ISS targets:
- link the math library of the Cadence toolchain. It is built against
  newlib and needs __errno(), which the Zephyr minimal C library does
  not have, so add a hook that returns the Zephyr errno;
- declare exp(), fabs(), fabsf(), pow() and round(). The math.h of the
  minimal C library only declares sqrt() and sqrtf(), and without a
  prototype the calls return garbage;
- scope the POSIX include directories and definitions to native_sim.

Enable CONFIG_CBPRINTF_FP_SUPPORT, the failure messages of the tests
print floating point values.

Verification:
- 8/8 cases pass on intel_adsp_iss/ace20_lnl_iss (HiFi4),
  ace30_ptl_iss (HiFi4) and ace40_nvl_iss (HiFi5), and on native_sim,
  also with ASan/LSan.
- The ISS image links the three functions from exp_fcn_hifi.c; the
  object of exp_fcn.c has no code there.
- Mutation test: adding 64 to the result of sofm_exp_fixed() in
  exp_fcn_hifi.c fails test_function_sofm_exp_fixed and
  test_function_sofm_db2lin_fixed on the ISS and does not affect
  native_sim. Reverted, no diff remains.

The ISS scenario has no integration_platforms entry: the boards only
support xt-clang, and Twister in integration mode reports an
integration platform that the selected toolchain cannot build as an
error.

Closes thesofproject#11591

Assisted-by: Copilot:claude-fable-5.2
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What output do we get in CI for tests ? i.e. if we assert or crash does it produce the full zephyr oops message ?

@intel-sofci

Copy link
Copy Markdown

PR 11614: test results

Run date: 2026-12-03 20:12 UTC

Tested commit: f47169807b5dd447d18b600774882fb1a9a1accf

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DNM Do Not Merge tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants