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

Update Svc::BufferManager data structures to align with allocation #1349

Open
timcanham opened this issue Mar 30, 2022 · 1 comment
Open
Labels
enhancement Medium Priority need-to-reproduce F´  developers need to reproduce.

Comments

@timcanham
Copy link
Collaborator

F´ Version 3.0.0
Affected Component `Svc::BufferManager``

Feature Description

Reorganize internal data structures to honor alignment.

Rationale

The data structures tracking memory buffers in Svc::BufferManager look like this:

        struct AllocatedBuffer
        {
            Fw::Buffer buff; //!< Buffer class to give to user
            U8 *memory;      //!< pointer to memory buffer
            U32 size;        //!< size of the buffer
            bool allocated;  //!< this buffer has been allocated
        };

The issue is that if a user wants to get aligned buffers, the memory member is not aligned.

The proposal would be to reorganize the data structures so that the memory pointers retain the alignment. This could be done by placing the AllocatedBuffer structs at the end of the overall allocated buffer.

@LeStarch LeStarch added the High Priority High Priority issue that needs to be resolved. label Mar 28, 2024
@thomas-bc thomas-bc added Medium Priority need-to-reproduce F´  developers need to reproduce. and removed High Priority High Priority issue that needs to be resolved. labels Oct 9, 2024
@matt392code
Copy link
Contributor

buffer-manager-2.txt
Propsed buffer alignment issue solution:
Key improvements in this design:

  1. Alignment Guarantees
struct alignas(std::max_align_t) BufferMetadata { ... }
  • Uses maximum platform alignment
  • Ensures compatibility with hardware DMA
  • Works with SIMD operations
  1. Memory Layout
[Alignment Padding][User Buffer][Metadata]
  • User buffer starts on alignment boundary
  • Metadata stored at end to preserve alignment
  • Efficient memory usage
  1. Memory Management
  • Clean allocation/deallocation
  • No memory leaks
  • Proper tracking of buffer status
  1. Compatibility
  • Works with existing Fw::Buffer interface
  • Minimal changes to client code
  • Platform independent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Medium Priority need-to-reproduce F´  developers need to reproduce.
Projects
None yet
Development

No branches or pull requests

4 participants