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
Annotate cms::cuda::HostAllocator::allocate() as thread safe #33246
Annotate cms::cuda::HostAllocator::allocate() as thread safe #33246
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-33246/21700
|
A new Pull Request was created by @makortel (Matti Kortelainen) for master. It involves the following packages: HeterogeneousCore/CUDAUtilities @makortel, @cmsbuild, @fwyzard can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@cmsbuild, please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-33d981/13665/summary.html Comparison SummarySummary:
|
@@ -28,7 +30,7 @@ namespace cms { | |||
using other = HostAllocator<U, FLAGS>; | |||
}; | |||
|
|||
T* allocate(std::size_t n) const __attribute__((warn_unused_result)) __attribute__((malloc)) | |||
T* allocate CMS_THREAD_SAFE(std::size_t n) const __attribute__((warn_unused_result)) __attribute__((malloc)) |
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.
is it the right place, between allocate
and (std::size_t n)
?
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.
That appears to be a legitimate place for C++ attributes, honestly I was following an example in
cmssw/DataFormats/TrackReco/interface/Track.h
Lines 74 to 76 in 8ffadd1
CovarianceMatrix& fillOuter CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillOuter(v); } | |
CovarianceMatrix& fillInner CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillInner(v); } |
On a further thought I agree the placement looks a bit weird. @gartung, could you comment how picky the static analyzer is for the placement of [[cms::thread_safe]]
attribute? Could it be placed e.g. before the function declaration? (that we seem to do with CMS_SA_ALLOW
here
CMS_SA_ALLOW tbb::task_group* group() const noexcept { return m_group; } |
)
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.
as far as I know, both
CMS_THREAD_SAFE T* allocate(std::size_t n) const __attribute__((warn_unused_result)) __attribute__((malloc))
and
T* allocate(std::size_t n) const CMS_THREAD_SAFE __attribute__((warn_unused_result)) __attribute__((malloc))
(or after the other attributes) should be fine
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.
As I recall there was some trial and error on where to place the attribute so the tokenizer would process it and attach it to the correct statement.
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.
clang-check -ast-dump -ast-dump-filter=function-name will show you the AST the tokenizer produces and you can see if the attribute is attached to the function.
Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
@cmsbuild, please test |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-33246/21850
|
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-33d981/13889/summary.html Comparison SummarySummary:
|
Seems that this way works as well, the static analyzer report is not complaining about const member function returning a pointer to non-const object. |
I noticed a bug in the summary which claims there are ESR::get warnings in the static analyzer report but there are not. I figured out the bug in the script and added a fix to |
+heterogeneous |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @silviodonato, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
This should silence 80 static analyzer warnings that @jpata reported in https://mattermost.web.cern.ch/cms-o-and-c/pl/6efrf7q4s7yi8k3oaamjhwdr3a
PR validation:
Code compiles.