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

Should the API allocate the 4 integers in the structure? #18

Open
henkmuller opened this issue Mar 1, 2017 · 1 comment
Open

Should the API allocate the 4 integers in the structure? #18

henkmuller opened this issue Mar 1, 2017 · 1 comment

Comments

@henkmuller
Copy link
Contributor

(this is related to lib_dsp - it may have been fixed in lib_src)

The current data structure contains pointers to a 3-word and 1-word array::

typedef struct dsp_ds3_ctrl_t
{
int *in_data; // Pointer to input data (3 samples)
int *out_data; // Pointer to output data (1 sample)
...

rather than the two arrays itself::

typedef struct dsp_ds3_ctrl_t
{
int in_data[3]; // Pointer to input data (3 samples)
int out_data[1]; // Pointer to output data (1 sample)
...

The latter saves code space (no need to initialise the pointers), it saves memory space (4 words rather than 6), and best of all, you cannot forget to initialise them.

The former case optimises for a case where you move something along a buffer; something that only works if the buffer is on the same core as yourself, and not wrapped around.

Is there any good reason not to pre-allocate the arrays?

@ed-xmos
Copy link
Collaborator

ed-xmos commented Mar 1, 2017 via email

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

No branches or pull requests

2 participants