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
avoid single letter names and code cleanup #32764
avoid single letter names and code cleanup #32764
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-32764/20922
|
A new Pull Request was created by @werdmann for master. It involves the following packages: RecoVertex/PrimaryVertexProducer @perrotta, @jpata, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-6948be/12589/summary.html Comparison SummarySummary:
|
@werdmann |
|
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.
Since you are cleaning this code, please also take what follows into account.
Moreover:
- The
evalF
method defined indouble evalF(const double beta, track_t const &tks, vertex_t const &v) const; cout
in it - Even though I can't imagine that classes with similar names will exist somewhere else in CMSSW, the include guards should better contain the whole file path name, i.e. (e.g.)
RecoVertex_PrimaryVertexProducer_DAClusterizerInZT_vect_h
RecoVertex_PrimaryVertexProducer_DAClusterizerInZ_vect_h
std::vector<double> tpca_vec; // t-coordinate at point of closest approach to the beamline | ||
std::vector<double> dz2_vec; // square of the error of z(pca) | ||
std::vector<double> dt2_vec; // square of the error of t(pca) | ||
std::vector<double> Z_sum_vec; // track contribution to the partition function, Z |
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.
lower case initials for data members
break; | ||
} | ||
insertItem(k, z, t, pk, tks); | ||
insertItem(k, zvtx, tvtx, rho, tks); | ||
return k; | ||
} | ||
|
||
void debugOut() { |
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.
Also this debugOut()
method doesn't look being used anywhere
} | ||
std::vector<double> zpca_vec; // z-coordinate at point of closest approach to the beamline | ||
std::vector<double> dz2_vec; // square of the error of z(pca) | ||
std::vector<double> Z_sum_vec; // track contribution to the partition function, Z |
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.
lower case initials for data members
double *__restrict__ zpca; | ||
double *__restrict__ dz2; | ||
double *__restrict__ tkwt; | ||
double *__restrict__ Z_sum; |
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.
lower case initials for data members
double *__restrict__ dz2; | ||
double *__restrict__ dt2; | ||
double *__restrict__ tkwt; | ||
double *__restrict__ Z_sum; |
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.
lower case initials for data members
@@ -24,7 +24,7 @@ DAClusterizerInZ_vect::DAClusterizerInZ_vect(const edm::ParameterSet& conf) { | |||
maxIterations_ = 1000; | |||
mintrkweight_ = 0.5; | |||
|
|||
// configurable debug outptut debug output | |||
// configurable debug outptut | |||
verbose_ = conf.getUntrackedParameter<bool>("verbose", 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.
verbose_
is only used at
cmssw/RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZT_vect.cc
Lines 50 to 68 in 0184912
if (verbose_) { | |
std::cout << "DAClusterizerInZT_vect: mintrkweight = " << mintrkweight_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: uniquetrkweight = " << uniquetrkweight_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: zmerge = " << zmerge_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: tmerge = " << tmerge_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: Tmin = " << minT << std::endl; | |
std::cout << "DAClusterizerInZT_vect: Tpurge = " << purgeT << std::endl; | |
std::cout << "DAClusterizerInZT_vect: Tstop = " << stopT << std::endl; | |
std::cout << "DAClusterizerInZT_vect: vertexSize = " << vertexSize_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: vertexSizeTime = " << vertexSizeTime_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: coolingFactor = " << coolingFactor_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: d0CutOff = " << d0CutOff_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: dzCutOff = " << dzCutOff_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: dtCutoff = " << dtCutOff_ << std::endl; | |
std::cout << "DAClusterizerInZT_vect: zrange = " << sel_zrange_ << std::endl; | |
std::cout << "DAClusterizerinZT_vect: convergence mode = " << convergence_mode_ << std::endl; | |
std::cout << "DAClusterizerinZT_vect: delta_highT = " << delta_highT_ << std::endl; | |
std::cout << "DAClusterizerinZT_vect: delta_lowT = " << delta_lowT_ << std::endl; | |
} |
The same functionality could be replaced, in a more thread compliant way, by using the DEBUG
/ DEBUG_LEVEL
structure which is used everywhere else in this code
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.
The very same apply to the other file DAClusterizerInZT_vect.cc
t_tkwt = 1. / (1. + local_exp(std::pow(atIP.value() / atIP.error(), 2) - | ||
std::pow(d0CutOff_, 2))); // reduce weight for high ip tracks | ||
if (edm::isNotFinite(t_tkwt) || t_tkwt < std::numeric_limits<double>::epsilon()) { | ||
std::cout << "DAClusterizerInZT_vect.fill rejected track t_tkwt " << t_tkwt << std::endl; |
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.
Remove all (multi-thread unsafe) cout
's from this fill() method: alternatively either replace them with some LogMessage's, or protect them with a DEBUG
flag
The two (longish) methods |
That is of course the better solution for the code. The if statement would be inside the loops. Can someone comment on whether this will somehow impact vectorization? |
In leading order adding a runtime if inside a loop can prevent vectorization. In sub-leading order compiler may be able to implement the if with mask and continue to vectorize, but it would have to be checked from the generated code. By quick look in this case the "whether or not to update |
Thank you @makortel! Wouldn't that work, perhaps another possibility could be to move the // auto-vectorized
if (Tc) {
for (unsigned int k = kmin; k < kmax; ++k) {
vertices.se[k] += vertices.exp[k] * (tmp_trk_tkwt * o_trk_Z_sum);
auto w = vertices.rho[k] * vertices.exp[k] * (tmp_trk_tkwt * o_trk_Z_sum * o_trk_dz2);
vertices.sw[k] += w;
vertices.swz[k] += w * tmp_trk_z;
}
else {
for (unsigned int k = kmin; k < kmax; ++k) {
vertices.se[k] += vertices.exp[k] * (tmp_trk_tkwt * o_trk_Z_sum);
auto w = vertices.rho[k] * vertices.exp[k] * (tmp_trk_tkwt * o_trk_Z_sum * o_trk_dz2);
vertices.sw[k] += w;
vertices.swz[k] += w * tmp_trk_z;
vertices.swE[k] += w * vertices.exp_arg[k] * obeta;
}
} Could this also work (even if more naif)? |
Yes, that should also work (with the price of some code duplication). |
Thank you for the feedback and apologies for the long silence. I verified that Andreas proposal incurs no measurable cpu time penalty and will implement all suggestions asap. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-32764/21130
|
please test |
@perotta you are right. in addition to what I posted yesterday it addresses your comment #32764 (comment) by moving the multiplication with that factor to a different loop where it needs to be executed only nvertex times instead of ntrack times. |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-6948be/12869/summary.html Comparison Summary@slava77 comparisons for the following workflows were not done due to missing matrix map:
Summary:
|
In DAClusterizerInZT_vect.cc the new At the contrary in DAClusterizerInZ_vect.cc all new |
This is done on purpose to avoid unnecessary arithmetic when an updated Tc is not needed. The ZT clusterizer only uses Tc for splitting, so it only needs to be done when a subsequent split() is possible.
Yes. In contrast to the ZT clusterizer, which before this PR did not distinguish between update and updateTc and simply effectively did updateTc all the time, the Z clusterizer already had two versions of update and the only change was to replace update() with update(..,false) and updateTc() with update(..., true). The complication was, that there was a place where strictly speaking updateTc should have been called, but wasn't. The last commits go back to that behaviour, although it could be considered a bug (albeit one that has only small consequences if the swE sum is not reset during the update(...,false)). |
+1
|
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 |
@werdmann : since the "technical" PR is now merged, please prepare the "fix" one based on the first IB that will contain this PR (quite likely this afternoon CMSSW_11_3_X_2021-02-15-1100) |
PR description:
This pull request is following up a request that arose in the context of PR #29626 to rename single letter variables which was deferred to later. It is done now in preparation of further development for cmssw_11_3.
May other variables were renamed as well to improve clarity and readability. No functionality changes have been introduced by this.
There were also some other cosmetic changes concerning comments and white-spaces.
Two unused/obsolete methods were removed from the structs in the header files.
A missing initialization of the variable betastop_ has been added. This only affects the results when Tmin was initialized with an illegal value, which of course should never happen.
PR validation:
The code was tested in CMSSW_11_3_0_pre2 against relvals and no difference was found to the original code.
runTheMatrix resulted in no failures.