Skip to content

Tools: Testbench: xt-testbench - #6513

Merged
kv2019i merged 4 commits into
thesofproject:mainfrom
singalsu:testbench_surgery
May 4, 2023
Merged

Tools: Testbench: xt-testbench#6513
kv2019i merged 4 commits into
thesofproject:mainfrom
singalsu:testbench_surgery

Conversation

@singalsu

@singalsusingalsu commented Nov 1, 2022

Copy link
Copy Markdown
Collaborator

Now ready. see commit texts for description.

@btian1
btian1 self-requested a review November 2, 2022 01:34
Comment threadtools/testbench/makefile-xcc Outdated
Comment threadtools/testbench/makefile-xcc Outdated
Comment threadsrc/arch/host/CMakeLists.txt Outdated
Comment threadsrc/arch/host/include/arch/debug/backtrace.h Outdated
Comment threadsrc/platform/library/schedule/ll_schedule.c Outdated
Comment threadsrc/platform/library/schedule/ll_schedule.c Outdated
@singalsu
singalsu requested a review from fredoh9November 3, 2022 09:41
@btian1

Copy link
Copy Markdown
Contributor

one more question is: where is the entry for this testbench?

@lgirdwood

Copy link
Copy Markdown
Member

one more question is: where is the entry for this testbench?

src/tools/testbench

@singalsu
singalsuforce-pushed the testbench_surgery branch 3 times, most recently from 661b239 to ed4a9a7CompareNovember 10, 2022 15:45
@fredoh9fredoh9 changed the title [DRAFT][WIP] Static testbench build and xt-testbench[SKIP CI][DRAFT][WIP] Static testbench build and xt-testbenchNov 10, 2022
Comment threadsrc/audio/asrc/asrc.c Outdated
Comment threadsrc/arch/host/include/arch/debug/backtrace.h Outdated
Comment threadsrc/audio/module_adapter/CMakeLists.txt Outdated
Comment threadtools/testbench/include/alsa/sound/uapi/asoc.h Outdated
Comment threadtools/testbench/makefile-xcc Outdated
Comment threadtools/testbench/CMakeLists.txt Outdated
Comment threadtools/tplg_parser/tokens.c Outdated
@singalsu
singalsuforce-pushed the testbench_surgery branch 2 times, most recently from b8fdb51 to 8142001CompareFebruary 28, 2023 16:15
@singalsusingalsu changed the title [SKIP CI][DRAFT][WIP] Static testbench build and xt-testbenchTools: Testbench: Static testbench build and xt-testbenchFeb 28, 2023
Comment threadtools/test/audio/comp_run.sh Outdated
Comment threadscripts/rebuild-xt-testbench.sh Outdated
Comment threadsrc/arch/host/CMakeLists.txt Outdated
Comment threadsrc/arch/host/include/arch/debug/backtrace.h Outdated
Comment threadtools/test/audio/comp_run.sh Outdated
Comment threadtools/test/audio/comp_run.sh Outdated
Comment threadsrc/audio/module_adapter/CMakeLists.txt Outdated
@marc-hb

This comment was marked as outdated.

@singalsu

Copy link
Copy Markdown
CollaboratorAuthor

Thanks @marc-hb the file DAI may be missing some DAI operation that fuzzer expects.

@lyakhlyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do I understand it correctly, that we currently can run testbench tests on the host multi-threaded and after this PR we won't be able to do that any more? Cannot we keep both modes?

Comment threadsrc/include/sof/schedule/ll_schedule.h Outdated
Comment threadsrc/include/sof/audio/component.h Outdated
Comment threadtools/testbench/topology.c Outdated
Comment threadtools/tplg_parser/tokens.c Outdated
Comment threadsrc/arch/host/include/arch/atomic.h Outdated
@singalsu

Copy link
Copy Markdown
CollaboratorAuthor

Do I understand it correctly, that we currently can run testbench tests on the host multi-threaded and after this PR we won't be able to do that any more? Cannot we keep both modes?

Yep, this is what it does... @lgirdwood can we restore the multi-threading with your work for alsa plugin so we could have both?

My idea is that I would get the improvements for topology parser and IPC simulation to xt-testbench from the plugin work. So this would be an intermediate step. Or wait to have both somehow.

@sys-pt1s

Copy link
Copy Markdown

Can one of the admins verify this patch?

Comment threadtools/testbench/testbench.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shouldn't double be %lf?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Double is overkill for this, I'll change the equation to float. The table https://cplusplus.com/reference/cstdio/printf/ suggests that L would be used for long double, while l seems to be for integers unless I'm misunderstanding it.

@singalsusingalsu left a comment

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I've now addressed review feedback, thanks for the comments!

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Changing 0x%lx to 0x%zx seems be OK for both gcc and xcc, I'll update the patch with it.

Comment threadtools/testbench/testbench.c Outdated

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yep, I've added functions to get time and cycles. The patch now also computes MCPS with file read/write consumption excluded.

Comment threadtools/testbench/testbench.c Outdated

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Thanks, yes that works!

Comment threadtools/testbench/testbench.c Outdated

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Double is overkill for this, I'll change the equation to float. The table https://cplusplus.com/reference/cstdio/printf/ suggests that L would be used for long double, while l seems to be for integers unless I'm misunderstanding it.

@singalsu

Copy link
Copy Markdown
CollaboratorAuthor

Now run of e.g. >> process_test('volume', 32, 32, 48000, 0, 'xt-run'); gives test result for MCPS

Input sample (frame) count: 326400 (163200)
Output sample (frame) count: 326400 (163200)
Total execution cycles: 18810961
File component cycles: 11272232
Pipeline cycles: 7538729
Pipeline MCPS: 2.22

Comment threadtools/testbench/testbench.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

long long for consistency?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Thanks, yes changed now!

@singalsu
singalsu requested a review from marc-hbApril 17, 2023 08:21

@marc-hbmarc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Caught one $TPLGFN typo, otherwise shell script changes LGTM

Comment threadtools/test/audio/comp_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typo

Suggested change
echo"Error: topology $TPLGFN does not exist."
echo"Error: topology $TPLG does not exist."

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Fixed, the previous print was without path. Better this way.

Comment threadtools/test/audio/comp_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

indent

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Same, I have no idea what's wrong with this indent. My emacs bash mode indents this way.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mix of tabs and spaces again?

Comment threadtools/test/audio/comp_run.sh Outdated
Comment threadscripts/rebuild-testbench.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

indent

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Sorry, I have no idea what's wrong with indent. Help?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Spaces on one line and tabs on the next feels fishy, even for shell scripts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's unfortunate that we have some files with tabs and other files with spaces in the same project but I agree 100% with @paulstelian97 : let's please not cross the line where we have a mix of tabs and spaces in the same file!

So @singalsu please find the shortcut in your editor that lets you quickly switch between tabs and spaces like the rest of us :-)

PS: I can't resist sorry: this sort of time-consuming discussion is exactly why tabs suck. Off-topic.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

The file is already without my patch a mix of tabs and spaces. I can convert them all to spaces then.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

M-x untabify is now done.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked and there are only 5 tabs right now. Feel free to convert them to spaces or to leave them alone, as long as you don't add any it's fine by me.

Comment threadtools/testbench/testbench.c Outdated

@paulstelian97paulstelian97 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Modulo that one comment this looks good (and I can live with that one too).

Comment threadtools/testbench/common_test.c Outdated

@btian1btian1Apr 26, 2023

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.

it may be a int32 usage, no need int64.
https://elixir.bootlin.com/zephyr/v1.7.0-rc2/source/drivers/timer/xtensa_sys_timer.c#L41

int32 should be enough, max should be set to: 400,000?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I'd keep this as 64 bits. With 400 MHz 32 bit counter overflows at 10.7s. Other Xtensas can be over 1 GHz clocked and we can support also other processor simulators too in the future.

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.

cycle should be a wrap data, once it go to max, then will go back to zero, so there is another issue with the code,
please refer below:

if (cycles1 > cycles0)
diff = cycles1 - cycles0;
else
diff = UINT32_MAX - cycles0 + cycles1;

it is not a always increase data.

@marc-hbmarc-hbApr 27, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

so there is another issue with the code,

What was the first issue?

cycle should be a wrap data, once it go to max, then will go back to zero,

Yes and that's OK because unsigned integers (unlike signed integers) are guaranteed to wrap around by the C standard

importnumpyasnpnp.uint32(5) -np.uint32(0xffffffff)
6

https://www.acepace.net/integerQuiz/

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.

int32 should be ok, since it is delta between one module. no way to exceed int32

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yes, it's true a single file copy should not consume over 32 bit worth of cycles but having this 64 bits avoid type casts. The overhead from this is small and it makes this more future proof, so I'd keep it as is. Unless you or others really want me to change this to smaller size.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand this code will only ever run on a GHz 64bits CPU so I don't see what difference 32 bits would make.

Mixing signed and unsigned is fraught with peril and signed overflow is undefined so unsigned is clearly better here.

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great @singalsu !

singalsu added 4 commits May 4, 2023 15:21
This patch avoids the build errors. Most of the issues are
from different types for formatted printing in gcc vs. xt-xcc.
The "__attribute__ ((fallthrough));" is not supported in xt-xcc.
The xtensa C library does not have clock_gettime() so it is
only left out from build. The cycles count and MCPS is printed
instead.
The include of dlfcn.h is not needed since the testbench no
more has dynamic libraries.
Structs within structs need to be initialized to zero in xt-xcc
with multiple brackets.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds to rebuild-testbench option -x <platform> that
can be used to build testbench for xt-run execution. The enhanced
script reuses native testbench build but with CC, LD, LDFLAGS,
etc. defines to use the xt-xcc compiler for build.
Currently TGL (HiFi3) is the only supported platform. More will
be added later.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds to process_test() sixth argument to run the tests
with xt-run environment with argument set to 'xt-run' or
'xt-run --turbo'.
The set and print of LD_LIBRARY_PATH is no more needed with static
testbench version.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
No script changes, just unify shell script style to be
with indents with spaces instead of both tabs and spaces.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsuforce-pushed the testbench_surgery branch from 8651092 to acdc21fCompareMay 4, 2023 12:37
@singalsu

Copy link
Copy Markdown
CollaboratorAuthor

I just rebased this PR and added a commit with only tabs to spaces changes to comp_run.sh.

@kv2019i

Copy link
Copy Markdown
Collaborator

Style checkpatch warning relates to long string literals -> this is ok

One unrelated fail in https://sof-ci.01.org/sofpr/PR6513/build6991/devicetest/index.html

Proceeding with merge.

@kv2019i
kv2019i merged commit 43b08c6 into thesofproject:mainMay 4, 2023
@singalsu
singalsu deleted the testbench_surgery branch May 9, 2023 12:58
Sign up for freeto 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.

8 participants

@singalsu@btian1@lgirdwood@marc-hb@kv2019i@sys-pt1s@lyakh@paulstelian97