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

apple clang 16 (at least) needs -fexperimental-library #27

Closed
andresailer opened this issue Nov 19, 2024 · 13 comments
Closed

apple clang 16 (at least) needs -fexperimental-library #27

andresailer opened this issue Nov 19, 2024 · 13 comments
Assignees

Comments

@andresailer
Copy link

As far as I can tell building against veccore on apple clang 16 on macos needs -fexperimental-library

Otherwise there is going to be a lot of

/Users/sftnight/build/workspace/lcg_nightly_pipeline/install/veccore/0.8.1-f2b7a/arm64-mac14-clang160-opt/include/VecCore/Backend/SIMD.h:17:24: error: no member named 'experimental' in namespace 'std'
   17 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |                   ~~~~~^
@amadio
Copy link
Member

amadio commented Nov 19, 2024

You need to use -std=c++20 if you want to use std::simd. Are you using it? I've only ever tested with std::simd from GCC, even with Clang. So, if you have a recipe which I can use to reproduce the issue, I can change things in VecCore before I tag the next release, which is coming quite soon.

@amadio amadio self-assigned this Nov 19, 2024
@andresailer
Copy link
Author

andresailer commented Nov 19, 2024

It is just a flag that has to be exported like an INTERFACE_COMPILE_OPTION LINK Option (?)

Yes, I am using c++20 otherwise I wouldn't reach this code

#if __cplusplus >= 202002L && defined(__has_include)
#if __has_include(<experimental/simd>)
#define VECCORE_ENABLE_STD_SIMD
#endif
#endif
#ifdef VECCORE_ENABLE_STD_SIMD
#include <experimental/simd>
namespace vecCore {
template <typename T, class Abi>
struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
using IndexType = typename std::experimental::simd_mask<T, Abi>::simd_type;

Right?

@andresailer
Copy link
Author

Here is a simple reproducer, as long as you have a mac14 clang16 machine, I guess?

cat > test.cpp << EOF
#include <experimental/simd>
template <typename T, class Abi>
struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
  using IndexType = typename std::experimental::simd_mask<T, Abi>::simd_type;
  using ScalarType = typename std::experimental::simd_mask<T, Abi>::value_type;
  static constexpr size_t Size = std::experimental::simd<T, Abi>::size();
};
int main() {
  return 0;
}
EOF

clang++ -std=c++20 test.cpp
clang++ -std=c++20 -fexperimental-library test.cpp

@amadio
Copy link
Member

amadio commented Nov 19, 2024

The reproducer above doesn't work.

test.cpp:3:8: error: explicit specialization of undeclared template struct 'TypeTraits'

I guess just #include <VecCore> should do, though.

@andresailer
Copy link
Author

andresailer commented Nov 19, 2024

Please look at the difference between with and without -fexperimental-library

bash-3.2$ clang++ -fexperimental-library -std=c++20 test2.cpp 
test2.cpp:3:8: error: explicit specialization of undeclared template struct 'TypeTraits'
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
bash-3.2$ clang++ -std=c++20 test2.cpp 
test2.cpp:3:24: error: no member named 'experimental' in namespace 'std'
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |                   ~~~~~^
test2.cpp:3:48: error: 'T' does not refer to a value
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |                                                ^
test2.cpp:2:20: note: declared here
    2 | template <typename T, class Abi>
      |                    ^
test2.cpp:3:8: error: explicit specialization of undeclared template struct 'TypeTraits'
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test2.cpp:3:55: error: expected unqualified-id
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |                                                       ^
4 errors generated.

@amadio
Copy link
Member

amadio commented Nov 19, 2024

gentoo ~ $ clang++ -std=c++20 test.cpp
test.cpp:3:8: error: explicit specialization of undeclared template struct 'TypeTraits'
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
gentoo ~ $ clang++ -std=c++20 -fexperimental-library test.cpp
test.cpp:3:8: error: explicit specialization of undeclared template struct 'TypeTraits'
    3 | struct TypeTraits<std::experimental::simd_mask<T, Abi>> {
      |        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@andresailer
Copy link
Author

clang++ --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@amadio
Copy link
Member

amadio commented Nov 19, 2024

I will try on macOS, the above is on Linux, and with clang-18, so might explain the differences.

@amadio
Copy link
Member

amadio commented Nov 19, 2024

It might be easier if you give me access to one of your build nodes, I only have an old machine with macOS 11.7 available to me at the moment, and that has clang 13 installed.

@andresailer
Copy link
Author

Continuing from our mattermost discussion, and since apple clang hopeless for now

Is it enough to add some logic so that VECCORE_ENABLE_STD_SIMD is not enabled in these cases?

 #if __cplusplus >= 202002L && defined(__has_include) 
 #if __has_include(<experimental/simd>) 
 #define VECCORE_ENABLE_STD_SIMD 
 #endif 
 #endif 

@amadio
Copy link
Member

amadio commented Nov 20, 2024

Yes, that is probably what I will do in the end.

@andresailer
Copy link
Author

Fixed in 4d2ed77

@amadio
Copy link
Member

amadio commented Nov 22, 2024

Thanks, added to the release notes!

@amadio amadio closed this as completed Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants