-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Make use of C++11 std::aligned_alloc where available #24844
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
Conversation
return ptr; | ||
} | ||
#elif defined HAVE_WIN32_ALIGNED_MALLOC | ||
if (isAlignedAllocationEnabled()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wornder if runtime / build time switcher for disabling aligned allocation are still relevant
return ptr; | ||
} | ||
#if defined(_MSC_VER) | ||
void* ptr = _aligned_alloc(size, CV_MALLOC_ALIGN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows does not have std::aligned_alloc as their free() method does not support freeing such blocks.
I will add comment regarding this limitation it a further commits.
|
Whoops! I assume we can not mandate such function, can we? |
OpenCV 4 requires >= C++11 Looks like there are already plans to use Lines 761 to 769 in 2791bb7
From a quick search, I did not find the minimal requirements (C++/C versions, target architectures, CUDA version/support, Python version/support, ...) for the different main OpenCV versions? I think it would be great to add these info on these pages? |
@georgthegreat Thanks a lot for the contribution. The PR was discussed on OpenCV Core team meeting. We propose not to remove the existing branches, but wrap the new standard branch with C++ version guard and put it on the first priority. It means:
|
@asmorkalov, thanks for carrying out the negotiation. I will bring the PR later on, but, first, what do you think about removing runtime checks for |
Both C11 and C++17 of Proof:
Current OpenCV implementation does not follow the rule when the
|
This is more like a food for thought, not a final state ready to be merged.
As I see, opencv uses constexpr statement and thus should mandate C++11 to be built.
C++ introduces much more compatible way for allocating aligned memory blocks.
Maybe opencv can make use of it too?