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

adding fast and parallel-friendly kdtree implementation #18288

Merged
merged 7 commits into from May 11, 2017

Conversation

felicepantaleo
Copy link
Contributor

This PR adds a fast/parallel-friendly kd-tree implementation in CommonTools.
The plan is to replace the existing PF KDtree (based on lists) with this one which is based on vectors and SoA in HGCal wfs, making it friendly for accelerators.
Searching and building produces exactly the same results, searching with 3D point cloud of about 100k points makes it ~3x faster than the existing implementation.

@rovere @malgeri @VinInn @makortel

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 10, 2017

A new Pull Request was created by @felicepantaleo (Felice Pantaleo) for master.

It involves the following packages:

CommonTools/RecoAlgos

@perrotta, @cmsbuild, @slava77, @davidlange6 can you please review it and eventually sign? Thanks.
@rappoccio, @jdolen, @makortel, @abbiendi, @jhgoh, @ahinzmann, @gkasieczka this is something you requested to watch as well.
@Muzaffar, @davidlange6, @smuzaffar you are the release manager for this.

cms-bot commands are listed here

@slava77
Copy link
Contributor

slava77 commented Apr 10, 2017

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 10, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/19056/console Started: 2017/04/10 17:21

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-18288/19056/summary.html

Comparison Summary:

  • You potentially added 43 lines to the logs
  • Reco comparison results: 1643 differences found in the comparisons
  • DQMHistoTests: Total files compared: 23
  • DQMHistoTests: Total histograms compared: 1917175
  • DQMHistoTests: Total failures: 23404
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 1893598
  • DQMHistoTests: Total skipped: 173
  • DQMHistoTests: Total Missing objects: 0
  • Checked 94 log files, 14 edm output root files, 23 DQM output files

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-18288/19056/summary.html

Comparison Summary:

  • You potentially added 43 lines to the logs
  • Reco comparison results: 1643 differences found in the comparisons
  • DQMHistoTests: Total files compared: 23
  • DQMHistoTests: Total histograms compared: 1917175
  • DQMHistoTests: Total failures: 23404
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 1893598
  • DQMHistoTests: Total skipped: 173
  • DQMHistoTests: Total Missing objects: 0
  • Checked 94 log files, 14 edm output root files, 23 DQM output files

Copy link
Contributor

@perrotta perrotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the huge indentation (it is better avoiding computer tabs for it) and the unnecessary and illogical insertion of empty lines and instructions broken in two or more lines, make the review of this code rather painful.
Could you please adjust it, and make it better readable?

v |= v >> 8;
v |= v >> 16;
return MultiplyDeBruijnBitPosition[(unsigned int)(v * 0x07C4ACDDU) >> 27];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please improve readability by removing the many empty lines (when not needed to separate methods or logical parts inside the code)

return MultiplyDeBruijnBitPosition[(unsigned int)(v * 0x07C4ACDDU) >> 27];

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove till L28

{
theNumberOfPoints = 0;
theDepth = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


void push_back(const FKDPoint<TYPE, numberOfDimensions>& point)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty lines here and below the instruction


void push_back(FKDPoint<TYPE, numberOfDimensions> && point)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty lines here and below the instruction

if (length == 1)
return 0;
unsigned int index = 1 << (ilog2(length));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove one line

for (unsigned int i = 0; i < numberOfDimensions; ++i)
theDimensions[i][position] = point[i];
theIds[position] = point.getId();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

for (unsigned int i = 0; i < numberOfDimensions; ++i)
theDimensions[i][position] = point[i];
theIds[position] = point.getId();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

theSize = 0;
theFront = 0;
theTail = 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here one empty line could help, instead...

theFront = 0;
theTail = 0;
theCapacity = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comments about empty lines and indentations also hold for this file (not marked all them)

@VinInn
Copy link
Contributor

VinInn commented Apr 21, 2017

Dear @perrotta , I do not disagree on the specific, still we cannot change coding style at each coordinator change.
Is there a (still valid) cms coding rule about spacing and tabbing?

@perrotta
Copy link
Contributor

Ciao @VinInn
Honestly, I don't know if there there are specific official rules about spacing and tabbing in CMSSW. I only found this piece of code extremely difficult to read and follow on, mostly because of the huge indentations (that force in a few cases to break the same instruction into separate lines) and the wide usage of scattered empty lines. For a possible example of a much better readable code I could cite your own 18408 (just the first example I got at hand)

@slava77
Copy link
Contributor

slava77 commented Apr 21, 2017 via email

}


void build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The total duplication of the build() function just to change the source of the points vector is unnecessary. This function only needs to exist once.

@cmsbuild
Copy link
Contributor

cmsbuild commented May 8, 2017

Pull request #18288 was updated. @perrotta, @cmsbuild, @slava77, @davidlange6 can you please check and sign again.

@felicepantaleo
Copy link
Contributor Author

@perrotta could you point me to unit tests of some other data structure so that I can imitate?

@cmsbuild
Copy link
Contributor

cmsbuild commented May 8, 2017

Pull request #18288 was updated. @perrotta, @cmsbuild, @slava77, @davidlange6 can you please check and sign again.

@perrotta
Copy link
Contributor

perrotta commented May 9, 2017

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented May 9, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/19667/console Started: 2017/05/09 11:43

@cmsbuild
Copy link
Contributor

cmsbuild commented May 9, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented May 9, 2017

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented May 9, 2017

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-18288/19667/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 1669 differences found in the comparisons
  • DQMHistoTests: Total files compared: 24
  • DQMHistoTests: Total histograms compared: 1831050
  • DQMHistoTests: Total failures: 25574
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 1805295
  • DQMHistoTests: Total skipped: 180
  • DQMHistoTests: Total Missing objects: 0
  • Checked 98 log files, 14 edm output root files, 24 DQM output files

@perrotta
Copy link
Contributor

+1
New code made available in CommonTools/RecoAlgos, not accessed by any module in CMSSW by now.
Visual inspection looks ok, and the unit test provided (thank you Felice) ends succesfully.
Full debug and complete check of fuctionality will necessarily only be dealt with once this code will be actually used in future applications.

@cmsbuild
Copy link
Contributor

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 requires discussion in the ORP meeting before it's merged. @davidlange6, @smuzaffar

@davidlange6
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 23b3aeb into cms-sw:master May 11, 2017
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

8 participants