Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP
Based on #26941
This is proposal of mechanism allowing to pass OpenCV parallel_for backend to HAL. This is just rough draft, details are up for discussion.
The proposal
Pass HAL_Context structure containing funciton pointer to
parallel_for
to those HAL functions which might require it (are not called insidecv::parallel_for
in OpenCV)HAL functions would then accept context as an argument:
Notes:
cv::parallel_for_
in C-like API and take a pointer to pass to HAL - context creation can be extracted and reused (e.g. in hal_replacement.hpp)Another approach
We can also use unified initialization mechanism:
OpenCV would call this function at some point and provide similar context structure or a set of arguments.
Possible call points:
Q: do we need
cv_hal_free
or something similar?Q: in case when we have multiple HALs, should we call init for each one?
Q: potential problem if we pass extra data (e.g. number of threads) via context - then we should re-init HAL if this data changes. Or HAL should assume extra level of indirection - it can only store pointer/reference to context, but should not copy it.