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

Misc ICC errors fixes. #7406

Merged
merged 2 commits into from Jan 29, 2015
Merged

Misc ICC errors fixes. #7406

merged 2 commits into from Jan 29, 2015

Conversation

ktf
Copy link
Contributor

@ktf ktf commented Jan 27, 2015

  • ICC complains because we are trying to create a std::pair<int, int> from what is actually a (int, size_t) pair. This fix will workaround the problem by forcing a downcast of size_t to int, but it would result in a real issue if secondLegNr was > 2**32. However, I assume we would have other problems in that case.
  • Like clang, ICC does not have constexpr version for std::exp / std::pow and in general anything coming from cmath. I think this is actually more an unsupported gcc extension.

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @ktf (Giulio Eulisse) for CMSSW_7_4_X.

Workaround ICC error.

It involves the following packages:

HLTrigger/Egamma

@Martin-Grunewald, @perrotta, @cmsbuild, @nclopezo, @fwyzard can you please review it and eventually sign? Thanks.
@Martin-Grunewald this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.

@cmsbuild
Copy link
Contributor

Pull request #7406 was updated. @perrotta, @cmsbuild, @nclopezo, @cvuosalo, @fwyzard, @Martin-Grunewald, @slava77 can you please check and sign again.

@@ -51,7 +51,7 @@ EcalRecHit::ESFlags ESRecHitSimAlgo::evalAmplitude(float * results, const ESData

// A from analytical formula:
constexpr float t1 = 20.;
#ifdef __clang__
#ifdef __clang__ || __INTEL_COMPILER
Copy link
Contributor

Choose a reason for hiding this comment

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

This gives a compiler warning:

/scratch/CMS2/CMSSW_7_4_X_2015-01-28-0200/src/RecoLocalCalo/EcalRecAlgos/src/ESRecHitSimAlgo.cc:54:20: warning: extra tokens at end of #ifdef directive
   #ifdef __clang__ || __INTEL_COMPILER
                    ^

@ktf
Copy link
Contributor Author

ktf commented Jan 28, 2015

@cmsbuild please test

@cmsbuild
Copy link
Contributor

Pull request #7406 was updated. @perrotta, @cmsbuild, @nclopezo, @cvuosalo, @fwyzard, @Martin-Grunewald, @slava77 can you please check and sign again.

@davidlt
Copy link
Contributor

davidlt commented Jan 28, 2015

A few comments.

  • ICC and Clang are correct with cmath functions. Recent changes in C++14 standard prohibits implementations mark random standard library functions as constexpr. IIRC, GCC will revert those back to non-constexpr. They made them as constexpr before the standard was finished.
  • I would avoid static_cast<>. This is not fixing and issue, but hiding it. matchedCands seems to store size_t, yet matched2ndLegs a pair of ints? They size_t is not a good type here? On 64-bit systems it would be long unsigned int and on 32-bit - unsigned int. Someone needs to pick correct size types and be consistent.

@fwyzard
Copy link
Contributor

fwyzard commented Jan 28, 2015

Hi David,
since you mention C++14 - do we plan on switching to -std=c++14 for CMSSW ?

.A

@ghost
Copy link

ghost commented Jan 28, 2015

@cmsbuild please test

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@ktf
Copy link
Contributor Author

ktf commented Jan 28, 2015

@davidlt

  • As of today gcc digests constexpr. When they change it or we move to c++14, we think about it. No change of behaviour in production builds due to platform ports.
  • matchedCands is std::vector<std::pair<int,int> > matchedCands; so it stores int. changing it to store size_t changes memory footprint. Again, no changes in behaviour in ports. static_cast is simply making the implicit explicit.

@davidlt
Copy link
Contributor

davidlt commented Jan 28, 2015

Regarding 2nd point. From my experience with ARMv7/UBSan/etc/you need to be very careful with types. I think, C++ 4.7/3 applies here (integral conversion):

If the destination type is signed, the value does not change 
if the source integer can be represented in the destination type. 
Otherwise the result is implementation-defined. (Note that this 
is different from signed integer arithmetic overflow, which is 
undefined) 

Now you have it easy. Later on if this becomes a problem you wont have a compiler diagnostic, you will have a difference in histogram, which will be way harder to track.

My two cents. It's HLT and RECO decision.

@fwyzard I think, this was discussed in Core Software meeting and it was OKed to have try -std=c++14 with CMSSW (maybe as separate IB?), but that's there it stopped.

@ktf
Copy link
Contributor Author

ktf commented Jan 28, 2015

Changing secondLegNr is simply moving the problem around, since std::vector<T>::size() always returns size_t which would then need to be casted. The only real solution without having 50% more memory used in that vector is to have an assert so that the size_t is within int range and do then do a static cast. There is no way that variable is going to exceed 2**31 nor become negative.

@cmsbuild
Copy link
Contributor

@slava77
Copy link
Contributor

slava77 commented Jan 28, 2015

regarding
As you say this is RECO / HLT business, if changing from int to size_t is fine with them
we should not make this change in data formats in the persisted data members (IIUC, it can trigger a difference in the actual compiled dictionary depending on the architecture).
Beyond that, in memory-lght cases size_t should be fine, do a cast otherwise.

@ktf
Copy link
Contributor Author

ktf commented Jan 28, 2015

Ok, I think we all agree that if this needs to be fixed, it can be done in a separate PR. @slava77, can you +1 this? It should be trivial.

@cmsbuild
Copy link
Contributor

@ktf
Copy link
Contributor Author

ktf commented Jan 29, 2015

Assuming @slava77 is ok with the changes, which are otherwise trivial. Merging. Complain if not.

ktf added a commit that referenced this pull request Jan 29, 2015
@ktf ktf merged commit d396872 into cms-sw:CMSSW_7_4_X Jan 29, 2015
@ktf ktf deleted the fix-intel2 branch January 29, 2015 08:03
@slava77
Copy link
Contributor

slava77 commented Jan 29, 2015

+1

for
#7406 f762ec0
postfactum
code looks ok
the set of tests in jenkins is surprisingly short

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

6 participants