Skip to content

Commit

Permalink
memory: move some code and data to DRAM
Browse files Browse the repository at this point in the history
A lot of code isn't performance-critical and can be used directly in
DRAM, without being copied into scarce SRAM. This commit selects two
functions as first candidates for that.

Moving data to DRAM is more difficult. The largest data blobs are
audio processing coefficients and they're usually used during audio
processing, i.e. when performance is critical. A good candidate for
such data relocation is the src component, which has many coefficient
sets, of which only some are used at run-time. Follow up work will
switch to keeping all src coefficients in DRAM and only copying used
ones into dynamically allocated SRAM buffers. This commit only moves
several conversion function selection arrays into DRAM. Those arrays
are small so this won't free a lot of SRAM, but at least this will
serve as the first test.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
  • Loading branch information
lyakh committed Jan 6, 2025
1 parent 0f7f6ab commit 88e65fb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SOF_DEFINE_REG_UUID(mfcc);

DECLARE_TR_CTX(mfcc_tr, SOF_UUID(mfcc_uuid), LOG_LEVEL_INFO);

const struct mfcc_func_map mfcc_fm[] = {
__cold_rodata const struct mfcc_func_map mfcc_fm[] = {
#if CONFIG_FORMAT_S16LE
{SOF_IPC_FRAME_S16_LE, mfcc_s16_default},
#endif /* CONFIG_FORMAT_S16LE */
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mixin_mixout/mixin_mixout_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static void mix_s32_gain(struct cir_buf_ptr *sink, int32_t start_sample, int32_t
}
#endif /* CONFIG_FORMAT_S32LE */

const struct mix_func_map mix_func_map[] = {
__cold_rodata const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, mix_s16, mix_s16_gain },
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mixin_mixout/mixin_mixout_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static void mix_s32_gain(struct cir_buf_ptr *sink, int32_t start_sample, int32_t

#endif /* CONFIG_FORMAT_S32LE */

const struct mix_func_map mix_func_map[] = {
__cold_rodata const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, mix_s16, mix_s16_gain },
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mixin_mixout/mixin_mixout_hifi5.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void mix_s32(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
#endif /* CONFIG_FORMAT_S32LE */

/* TODO: implement mixing functions with gain support!*/
const struct mix_func_map mix_func_map[] = {
__cold_rodata const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, mix_s16, mix_s16 },
#endif
Expand Down
8 changes: 6 additions & 2 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ static uint32_t vol_zc_get_s32(const struct audio_stream *source,

#endif /* CONFIG_FORMAT_S32LE */

/** \brief Map of formats with dedicated zc functions. */
static const struct comp_zc_func_map zc_func_map[] = {
/**
* \brief Map of formats with dedicated zc functions.
*
* This is only used during @c .prepare() so it isn't performance-critical.
*/
__cold_rodata static const struct comp_zc_func_map zc_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, vol_zc_get_s16 },
#endif /* CONFIG_FORMAT_S16LE */
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ static int ipc4_process_glb_message(struct ipc4_message_request *ipc4)
* delete module <-------> free component
*/

static int ipc4_init_module_instance(struct ipc4_message_request *ipc4)
__cold static int ipc4_init_module_instance(struct ipc4_message_request *ipc4)
{
struct ipc4_module_init_instance module_init;
struct comp_dev *dev;
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static inline char *ipc4_get_comp_new_data(void)
}
#endif

struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
__cold struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
{
struct comp_ipc_config ipc_config;
const struct comp_driver *drv;
Expand Down

0 comments on commit 88e65fb

Please sign in to comment.