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

Memory alignment issues (DSP-80) #46

Open
Barabas5532 opened this issue Apr 23, 2022 · 1 comment
Open

Memory alignment issues (DSP-80) #46

Barabas5532 opened this issue Apr 23, 2022 · 1 comment

Comments

@Barabas5532
Copy link
Contributor

There are some places in this library where the user must align memory passed to functions correctly. These are not documented anywhere I can find.

E.G. The dsps_fft4r_fc32_ansi_ function casts the float *data parameter to the following struct:

typedef union fc32_u
{
    struct
    {
        float re;
        float im;
    };
    uint64_t data;
}fc32_t;

The uint64_t member of this union requires 8 bytes alignment. Actually, this member is unused, so it would be best to remove it, and make the default 4 byte alignment work. Why doesn't this library use the C99 complex type feature?

I've also noticed that 16 byte alignment was added to a lot of the example apps with the support for ESP32S3 chip in 108493c. Is this alignment only required for implementations using assembly code for that chip?

#define memalign(align_, size_) malloc(size_)

The tests disable alignment on esp-idf version <4.3.0 by defining memalign as malloc and ignoring the alignment parameter. Would this not cause issues when loading memory from an unaligned address?

@igrr
Copy link
Member

igrr commented Apr 23, 2022

The tests disable alignment on esp-idf version <4.3.0 by defining memalign as malloc and ignoring the alignment parameter.

I think the reason is that older versions of IDF didn't have memalign implemented. And the 16 byte alignment is necessary for esp32-s3, which is supported only since IDF 4.4.

Good point about documenting the alignment requirements, we'll update the docs!

@tom-borcin tom-borcin changed the title Memory alignment issues Memory alignment issues Apr 3, 2023
@github-actions github-actions bot changed the title Memory alignment issues Memory alignment issues (DSP-80) Apr 3, 2023
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