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

DRAM data #9721

Merged
merged 6 commits into from
Jan 29, 2025
Merged

DRAM data #9721

merged 6 commits into from
Jan 29, 2025

Conversation

lyakh
Copy link
Collaborator

@lyakh lyakh commented Dec 11, 2024

This is an illustration of how data can be assigned to be kept in DRAM. This specific change should be done by adjusting scripts, creating those headers, not by patching headers directly. Besides additional code is needed to copy selected coefficient sets to SRAM for fast access during operation

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Looks simple.

@@ -76,6 +76,7 @@ def main():
executable = []
writable = []
readonly = []
readonly_dram = []
Copy link
Member

Choose a reason for hiding this comment

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

I assume this will all be dumped when we build the target i.e. xkB hybrid RODATA in DRAM ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood this isn't implemented yet, should be doable incrementally, yes

With this data can be assigned to a separate read-only section, which
then will be kept in DRAM without copying it to SRAM on module
instantiation.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
@lyakh lyakh force-pushed the llext-dram-data branch 2 times, most recently from fca47c0 to 2d03968 Compare January 27, 2025 11:53
@lyakh
Copy link
Collaborator Author

lyakh commented Jan 27, 2025

taking over #9765

@lyakh lyakh changed the title [DRAFT] LLEXT DRAM data DRAM data Jan 27, 2025
@lyakh lyakh marked this pull request as ready for review January 27, 2025 12:32
@@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_10_21_2500_5000_fir[480] = {
__cold_rodata static const int32_t src_int32_10_21_2500_5000_fir[480] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to make this change to SRC coefficients generator too (I can do it later).

@lyakh
Copy link
Collaborator Author

lyakh commented Jan 28, 2025

CI:

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

No real showstoppers, a couple of comments inline.

src/audio/src/src_common.c Show resolved Hide resolved
app/boards/intel_adsp_ace15_mtpm.conf Show resolved Hide resolved

if (!data->num_entries) {
data->entries = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
32 * sizeof(*entries));
Copy link
Collaborator

Choose a reason for hiding this comment

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

32? Put a magic somewhere?

zephyr/lib/fast-get.c Show resolved Hide resolved
lyakh and others added 5 commits January 29, 2025 09:09
src coefficients take a lot of space, keep them in DRAM to only copy
used sets in SRAM. Also move src_init() and src_free() to DRAM since
they aren't performance-critical.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
Implement fast_get() and fast_put() functions. The purpose of these
functions is to maintain shared SRAM copies of data stored in DRAM.

fast_get()

First checks if there is already an SRAM copy of the same DRAM chunk.

If there isn't reserve an SRAM chunk of the same size and copy the
contents there, store the both pointers, size and reference count to
in an internal data structure, and return the SRAM pointer.

If there is, return the pointer to the existing SRAM copy and
increase the reference count.

fast_put()

Look up the internal data record based on the SRAM address and
decrement reference count. Free the SRAM chunk and the data record if
reference count reaches zero,

Signed-off-by: Jyri Sarha <[email protected]>
Enable fast_get() and fast_put() on supporting ACE platforms.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
And simple module tests for fast_get and fast_put() implemented in
src/lib/fast-get/fast-get.c.

Signed-off-by: Jyri Sarha <[email protected]>
The SRC coefficients are loaded to DRAM and commit copies the
coefficients to SRAM when they are needed. The copying is done using
fast_get() and the copy is released with fast_put() when its not
needed anymore.

Signed-off-by: Jyri Sarha <[email protected]>
Copy link
Contributor

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks, looks good now.

@kv2019i kv2019i merged commit 2d0d8cb into thesofproject:main Jan 29, 2025
43 of 49 checks passed
@lyakh lyakh deleted the llext-dram-data branch January 29, 2025 12:44
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.

5 participants