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 and/or k4a_set_allocator() needed for modern CPUs, OpenCV, Eigen, and many other libraries #20

Open
diablodale opened this issue Dec 21, 2023 · 3 comments

Comments

@diablodale
Copy link

In your developer transition PDF and at

k4a_result_t k4a_set_allocator(k4a_memory_allocate_cb_t allocate, k4a_memory_destroy_cb_t free)
{
k4a_result_t result = K4A_RESULT_FAILED;
LOG_WARNING("unsupported api [allocate=%d,free=%d]", allocate, free);

I read you have disabled the k4a_set_allocator() API. Unfortunately, this immediately breaks my application and makes adoption of Femto sensors difficult.
Specifically, my application needs 64-byte alignment of image data coming from the sensor.

Many modern (in the last 10 years) solutions require 64-byte alignment for AVX2 and GPU acceleration. When this hardware/library doesn't get 64-byte aligned memory, this can lead to crashes due to memory access violations. 64 is required, not optional for many scenarios.

In 2020 I escalated this issue to Microsoft microsoft#1274. To workaround the lack of memory alignment in the SDK, I analyzed the k4a SDK and wrote my own allocator that handles their 32-byte shift and results in a 64-byte aligned memory being returned. This as worked well for 3 years with zero problems.

Given that...how can I use Femto sensors and have 64-byte aligned frames to be returned to me?

I am 100% happy if you hardcode the 64-byte alignment somewhere and always return that. 👍 Microsoft's approach was always broken and this is a good opportunity for your sdk to get it right.

Alternatively, I need the k4a_set_allocator() to work as it was designed...which allows me to use my custom allocation to correct the alignment. Now having aligned memory is not only about performance, it is also about no crashes.

@zhonghong322
Copy link

Thank you for your suggestion. We will consider adding this feature in future versions, as it would require refactoring the internal memory management code in the SDK.

@diablodale
Copy link
Author

Please keep this issue open and update it when (or if) you ever do that. Only after you fix your wrapper compatibility, can I write software for and sell your sensors.

@diablodale
Copy link
Author

Checking back with you on this bug. A customer has paid for me to purchase two of your Femto sensors, I just ordered today. Is this missing code on your project list?

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