-
Notifications
You must be signed in to change notification settings - Fork 615
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
Remove usages of std::call_once
.
#5599
Conversation
std::call_once has a bug in some versions of glibc. A custom implementation has been provided. Usages with static once_flag have been replaced with "magic statics". Optical flow doesn't need atomicity and the once semantics were not required at all. Other usages use the custom implementation. A stale warning about antialiasing (also guarded with call once) was removed. Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
5e81b2f
to
010a519
Compare
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
if ((has_min && is_linear_default(make_cspan(min_arg_))) || | ||
(has_interp && is_linear_default(make_cspan(interp_type_arg_)))) { | ||
static std::once_flag linear_default_warning_flag; | ||
std::call_once(linear_default_warning_flag, [&]() { | ||
DALI_WARN( | ||
"The default behavior for LINEAR interpolation type has been changed to apply an " | ||
"antialiasing filter. If you didn't mean to apply an antialiasing filter, please use " | ||
"`antialias=False`"); | ||
}); | ||
} |
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.
This warning was sitting here for 2 years now. Nobody complained during that time and the behavior is hardly a "change" any more.
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 have mixed filling about including this in this particular PR. But up to you.
std::call_once(of_initialized_, | ||
[&]() { | ||
optical_flow_.reset( | ||
new optical_flow::OpticalFlowImpl(of_params_, | ||
width, | ||
height, | ||
channels, | ||
image_type, | ||
device_id, | ||
stream)); | ||
optical_flow_->Init(of_params_); | ||
}); |
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.
This is called from within setup. No atomicity is required, setup is never called in parallel with itself.
CI MESSAGE: [17296340]: BUILD STARTED |
CI MESSAGE: [17296340]: BUILD FAILED |
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
CI MESSAGE: [17298715]: BUILD STARTED |
CI MESSAGE: [17298715]: BUILD FAILED |
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
CI MESSAGE: [17313865]: BUILD STARTED |
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
CI MESSAGE: [17317992]: BUILD STARTED |
CI MESSAGE: [17321143]: BUILD STARTED |
CI MESSAGE: [17317992]: BUILD PASSED |
Please excuse my naïve question, as I understand statics are used when the code doesn't throw, call_once where it might, right? |
I use "magic statics" when the call_once flag was also static. The compiler should take care of everything. I can double check it. |
Checked: magic statics do the trick on |
Category:
Other (e.g. Documentation, Tests, Configuration)
Workaround for a library bug.
Description:
Additional information:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78184
std::call_once
has a bug in some versions of glibc. A custom implementation has been provided.Usages with static once_flag have been replaced with "magic statics". Optical flow doesn't need atomicity and the once semantics were not required at all.
Other usages use the custom implementation.
A stale warning about antialiasing (also guarded with call once) was removed.
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A