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

Modernize RPCTechnicalTrigger #25267

Merged
merged 6 commits into from Nov 20, 2018

Conversation

Dr15Jones
Copy link
Contributor

  • Improved memory management via std::unique_ptr or holding objects by value. This fixed several memory leaks. There are no remaining bare new or delete in this code.
  • Removed unnecessary member data.
  • Improved const correctness.
  • Removed unnecessary virtual destructors.
  • Changed to range based for loops.
  • Used more efficient patterns for containers.
  • Converted RPCTechnicalTrigger to a stream module.

Consolidated the setup for geometry description. If possible,
converted to a constexpr.
Have CreateObject return a std::unique_ptr.
Unregister never needed to call delete since new objects were
created each call.
-Objects are returned by std::unique_ptr
-All instances share an immutable factory
-Improved memory management via std::unique_ptr or holding objects
 by value.
-Removed unnecessary member data.
-Improved const correctness.
-Removed unnecessary virtual destructors.
-Changed to range based for loops.
-Used more efficient patterns for containers.
@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@Dr15Jones
Copy link
Contributor Author

I ran valgrind on step2 of workflow 1.0 which calls RPCTechnicalTrigger. No problem were seen.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @Dr15Jones (Chris Jones) for master.

It involves the following packages:

L1Trigger/RPCTechnicalTrigger

@nsmith-, @rekovic, @cmsbuild, @thomreis can you please review it and eventually sign? Thanks.
@Martin-Grunewald this is something you requested to watch as well.
@davidlange6, @slava77, @fabiocos you are the release manager for this.

cms-bot commands are listed here

typename std::map<Identifier, LogicCreator>::const_iterator itr;
itr = m_associations.find(id);
if( itr != m_associations.end() ) {
delete ( itr->second )() ;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not needed since the call to the function always returned a new object anyway.


private:

typename std::vector<std::string> m_logkeys;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

m_logkeys was only being used to call m_rbclogic.Unregister() which was not necessary.


typename std::vector<std::string> m_logkeys;
static RBCLogicType const& rbclogic() {
static const RBCLogicType s_rbclogic = initialise();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is thread safe.

const RBCBoardSpecs * m_rbcboardspecs;
std::unique_ptr<RBCLogicUnit> m_rbclogic;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The class now properly manages its own member data rather than having classes which inherit from it try to manage the memory.

@@ -32,8 +33,6 @@ class RBCEmulator {

RBCEmulator( const char * , const char * , int, int *);

virtual ~RBCEmulator( ); ///< Destructor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No classes inherit from this one.

isAoB = 1;
}

for ( pos = 0; pos < 6; ++pos ) {
if (this->m_block->m_sec1[pos] == sector || this->m_block->m_sec2[pos] == sector )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this->m_block is only being used as a hidden argument to the function. I made it explicit.

@@ -363,7 +272,7 @@ void RBCProcessRPCDigis::setDigiAt( int sector, int digipos )
void RBCProcessRPCDigis::setInputBit( std::bitset<15> & signals , int digipos )
{

int bitpos = m_layermap[digipos];
int bitpos = s_layermap.at(digipos);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a functional differerence. If an out of range digipos is used, this code will now throw. The old code just added a new entry.

@@ -344,7 +267,7 @@ void RBCProcessRPCSimDigis::setDigiAt( int sector, int digipos )
void RBCProcessRPCSimDigis::setInputBit( std::bitset<15> & signals , int digipos )
{

int bitpos = m_layermap[digipos];
int bitpos = s_layermap.at(digipos);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a functional difference, the code will now throw if digipos is not in the container.

bool topRight(false);
bool botLeft(false);

int indxW1 = m_WheelTtu[wheel1];
int indxW2 = m_WheelTtu[wheel2];
int indxW1 = wheelTtu[wheel1+kWheelOffset];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously a map was being used. But the keys were just {-2,-1,0,1,2}. So a std::vector with an offset can do the job better.


m_ttuboardspecs = ttuspecs;

m_ttulogic = new TTULogicUnit();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a member data from the base class.

@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 16, 2018

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/31706/console Started: 2018/11/17 01:12

@Dr15Jones
Copy link
Contributor Author

Running valgrind with memory leaks checking on, I do not see any memory leaks coming from this package with my changes.

@cmsbuild
Copy link
Contributor

-1

Tested at: f149ded

You can see the results of the tests here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-25267/31706/summary.html

I found follow errors while testing this PR

Failed tests: ClangBuild

  • Clang:

I found compilation warning while trying to compile with clang. Command used:

USER_CUDA_FLAGS='--expt-relaxed-constexpr' USER_CXXFLAGS='-Wno-register -fsyntax-only' scram build -k -j 16 COMPILER='llvm compile'

See details on the summary page.

@cmsbuild
Copy link
Contributor

Comparison not run due to Build errors/Fireworks only changes/No short matrix requested (RelVals and Igprof tests were also skipped)

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Pull request #25267 was updated. @nsmith-, @rekovic, @cmsbuild, @thomreis can you please check and sign again.

@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 17, 2018

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/31708/console Started: 2018/11/17 04:46

@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-25267/31708/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 32
  • DQMHistoTests: Total histograms compared: 3013311
  • DQMHistoTests: Total failures: 12
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3013102
  • DQMHistoTests: Total skipped: 197
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 31 files compared)
  • Checked 134 log files, 14 edm output root files, 32 DQM output files

@fabiocos
Copy link
Contributor

DQM differences look unrelated to this PR

@rekovic
Copy link
Contributor

rekovic commented Nov 20, 2018

+1

@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 will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2)

@fabiocos
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 445a255 into cms-sw:master Nov 20, 2018
@Dr15Jones Dr15Jones deleted the modernizeRPCTechnicalTrigger branch November 22, 2018 16:30
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

4 participants