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

Resolve Clang issues in DataFormats/Math #7223

Merged
merged 3 commits into from
Jan 17, 2015

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented Jan 16, 2015

This patchset resolves build errors and warnings with Clang compiler. Most of this was already available in CLANG IB (kudos to Giulio), but there was an issue where Vec4F and Vec2D were lowered to the same type. Most of this can be pulled out once Clang improves vector_size implementation.

The biggest issue is constexpr in the test. The test was disabled on Clang, but most likely will fail with GCC in future. C++ standard was updated and freedom to add constexpr to random functions in standard library were removed. Thus constexpr double a = std::cos() is not a valid code.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3788.html#2013

Build tested with GCC 4.9.1 and Clang pre-3.6 (65d8b4c) in DEVEL IB.

David Abdurachmanov added 3 commits January 16, 2015 14:45
Clang `vector_size` doesn't allow value dependent expressions in
templates. Instead use `ext_vector_type` (OpenCL vector types),
which doesn't have this limitation.

See PR16986: http://llvm.org/bugs/show_bug.cgi?id=16986

Previous version of this patch had an issue where `Vec4<float>` and
`Vec2<double>` were lowered to the same type.

From Clang AST dump:

|-TypedefDecl .. referenced Vec4F 'Vec4<float>':'float
__attribute__((ext_vector_type(16)))'
|-TypedefDecl .. referenced Vec2D 'Vec2<double>':'float
__attribute__((ext_vector_type(16)))'

Updated patch resolves it.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
It looks a bit complicated on understanding what can and cannot be
`constexpr`. For example `std::cos` (cmath) is not `constexpr`, but in GCC
is can be lowered down to `__builtin_cos`, which will be `constexpr`.
Clang is more strict and does not treat `__builtin_*` as `constexpr`.
With GCC `std::cos` with `-fno-builtin` will also yield a compiler
error.

This could cause issues in C++14 (?)

Commit 724b4eb62820414bc79c35c90825481d7c0f3c59 from C++ Standard Draft.

    An implementation shall not declare any standard library function
    signature as \tcode{constexpr} except for those where it is
    explicitly required.

I found the fellowing to cover the issue quite well:

    http://stackoverflow.com/questions/27744079/is-it-a-conforming-compiler-extension-to-treat-non-constexpr-standard-library-fu

Expect more issues with this file as GCC might revert the changes and
built-ins will not be `constexpr`:

    https://gcc.gnu.org/ml/libstdc++/2014-09/msg00004.html

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
- `eta3` removed as not used;
- `std::abs` from C++11 needs to be used, which supports `long long`,
  otherwise results might be truncated to `int`.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
@cmsbuild
Copy link
Contributor

A new Pull Request was created by @davidlt for CMSSW_7_4_X.

Resolve Clang issues in DataFormats/Math

It involves the following packages:

DataFormats/Math

@cmsbuild, @cvuosalo, @nclopezo, @slava77 can you please review it and eventually sign? Thanks.
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.

@davidlt
Copy link
Contributor Author

davidlt commented Jan 16, 2015

More details in commit messages as usual.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

typedef double __attribute__( ( vector_size( 16 ) ) ) float64x2_t;
typedef double __attribute__( ( vector_size( 32 ) ) ) float64x4_t;
typedef double __attribute__( ( vector_size( 64 ) ) ) float64x8_t;
#ifdef __clang__
Copy link
Contributor

Choose a reason for hiding this comment

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

how did we get to having to do fixes here.
I recall we switched to SSE in #6611
So, how did clang see an issue here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we have DataFormats/Math/src/ExtVec.cc, which is always compiled. That's the one trigger compilation issues. It contains a number of operators for printing things like Vec2D. One could disable those, but there is no top level header file which selects USE_EXTVECT/USE_SSEVECT. Current decision is done in DataFormats/Math/interface/SIMDVec.h, but you cannot include it into DataFormats/Math/src/ExtVec.cc as that would create cyclic dependency. Someone would need to split SIMDVec.h.

Copy link
Contributor

Choose a reason for hiding this comment

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

ExtVec.cc, makes sense now.
Thanks.

@slava77
Copy link
Contributor

slava77 commented Jan 17, 2015

+1

for #7223 60f6470
jenkins tests are clean (IIRC, extvec is not used in default; so, the more complex change in ExtVec.h is probably invisible)

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_4_X IBs unless changes (tests are also fine). This pull request will be automatically merged.

cmsbuild added a commit that referenced this pull request Jan 17, 2015
Resolve Clang issues in DataFormats/Math
@cmsbuild cmsbuild merged commit f26fbbb into cms-sw:CMSSW_7_4_X Jan 17, 2015
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

3 participants