Navigation Menu

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

Annotate cms::cuda::HostAllocator::allocate() as thread safe #33246

Merged
merged 2 commits into from Apr 6, 2021

Conversation

makortel
Copy link
Contributor

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.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-33246/21700

  • This PR adds an extra 12KB to repository

@cmsbuild
Copy link
Contributor

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.
@rovere this is something you requested to watch as well.
@silviodonato, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-33d981/13665/summary.html
COMMIT: 12c0f78
CMSSW: CMSSW_11_3_X_2021-03-21-2300/slc7_amd64_gcc900
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/33246/13665/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 5 differences found in the comparisons
  • DQMHistoTests: Total files compared: 37
  • DQMHistoTests: Total histograms compared: 2639935
  • DQMHistoTests: Total failures: 12
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 2639900
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 36 files compared)
  • DQMHistoSizes: changed ( 312.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 155 log files, 37 edm output root files, 37 DQM output files
  • TriggerResults: no differences found

@@ -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))
Copy link
Contributor

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) ?

Copy link
Contributor Author

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

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; }

)

Copy link
Contributor

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

Copy link
Member

@gartung gartung Mar 31, 2021

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.

Copy link
Member

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>
@makortel
Copy link
Contributor Author

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-33246/21850

  • This PR adds an extra 12KB to repository

@cmsbuild
Copy link
Contributor

Pull request #33246 was updated. @makortel, @fwyzard can you please check and sign again.

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-33d981/13889/summary.html
COMMIT: f20397f
CMSSW: CMSSW_11_3_X_2021-03-30-2300/slc7_amd64_gcc900
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/33246/13889/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 37
  • DQMHistoTests: Total histograms compared: 2640841
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 2640812
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: -0.004 KiB( 36 files compared)
  • DQMHistoSizes: changed ( 312.0 ): -0.004 KiB MessageLogger/Warnings
  • Checked 155 log files, 37 edm output root files, 37 DQM output files
  • TriggerResults: no differences found

@makortel
Copy link
Contributor Author

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.

@gartung
Copy link
Member

gartung commented Apr 1, 2021

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
cms-sw/cms-bot#1527

@makortel
Copy link
Contributor Author

makortel commented Apr 5, 2021

+heterogeneous

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 5, 2021

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)

@silviodonato
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit bb3c404 into cms-sw:master Apr 6, 2021
@makortel makortel deleted the threadSafeHostAllocatorAllocate branch April 6, 2021 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants