alpaka-group / alpaka

Abstraction Library for Parallel Kernel Acceleration :llama:
https://alpaka.readthedocs.io
Mozilla Public License 2.0
356 stars 74 forks source link

fix cray clang compiler errors #2392

Closed psychocoderHPC closed 1 month ago

psychocoderHPC commented 2 months ago
SimeonEhrig commented 2 months ago

Adding the Cray Compiler Compiler ID here in the CMake should solve the problem:

https://github.com/alpaka-group/alpaka/blob/5c5a690f48aeedc6b8651e5b5f486767c12f2be8/cmake/alpakaCommon.cmake#L202

I removed this line from my CMake, the Filter.hpp does not compile.

$ cmake --build -j -t kernelSpecialization
Building CXX object example/kernelSpecialization/CMakeFiles/kernelSpecialization.dir/src/kernelSpecialization.cpp.o
In file included from /home/simeon/projects/alpaka/example/kernelSpecialization/src/kernelSpecialization.cpp:5:
In file included from /home/simeon/projects/alpaka/include/alpaka/alpaka.hpp:26:
/home/simeon/projects/alpaka/include/alpaka/acc/TagAccIsEnabled.hpp:34:66: error: template template argument has different template parameters than its corresponding template template parameter
   34 |     using EnabledAccTags = alpaka::meta::Filter<AccTags, alpaka::AccIsEnabled>;
      |                                                                  ^
/home/simeon/projects/alpaka/include/alpaka/acc/TagAccIsEnabled.hpp:23:5: note: too many template parameters in template template argument
   23 |     template<typename TTag, typename = void>
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simeon/projects/alpaka/include/alpaka/meta/Filter.hpp:42:30: note: previous template template parameter is here
   42 |     template<typename TList, template<typename> class TPred>
      |                              ^~~~~~~~~~~~~~~~~~
In file included from /home/simeon/projects/alpaka/example/kernelSpecialization/src/kernelSpecialization.cpp:6:
/home/simeon/projects/alpaka/include/alpaka/example/ExecuteForEachAccTag.hpp:25:97: error: no member named 'EnabledAccTags' in namespace 'alpaka'
   25 |         return std::apply([=](auto const&... tags) { return (callable(tags) || ...); }, alpaka::EnabledAccTags{});
      |                                                                                         ~~~~~~~~^
/home/simeon/projects/alpaka/example/kernelSpecialization/src/kernelSpecialization.cpp:109:12: error: cannot initialize return object of type 'int' with an rvalue of type 'void'
  109 |     return alpaka::executeForEachAccTag([=](auto const& tag) { return example(tag); });
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
gmake[3]: *** [example/kernelSpecialization/CMakeFiles/kernelSpecialization.dir/build.make:76: example/kernelSpecialization/CMakeFiles/kernelSpecialization.dir/src/kernelSpecialization.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:2248: example/kernelSpecialization/CMakeFiles/kernelSpecialization.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:2255: example/kernelSpecialization/CMakeFiles/kernelSpecialization.dir/rule] Error 2
gmake: *** [Makefile:673: kernelSpecialization] Error 2

If I apply your changes, it compiles.

psychocoderHPC commented 2 months ago

@SimeonEhrig I removed the cmake workaround. The advantage is that stand alone header does not need additional flags and CMS does not need to handle this case in there build suite too.

fwyzard commented 1 month ago

I have no idea what these changes are about :-p

SimeonEhrig commented 1 month ago

I have no idea what these changes are about :-p

Up to Clang 19, the compiler does not support relaxed template template args by default, which is a C++17 feature: https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150 Therefore all Clang based compilers needs to set the compiler flag -frelaxed-template-template-arg to enable the feature. I forgot to add the Cray Clang compiler ID to the CMake. Therefore the compiler cannot compile the code.

René's code change simply avoids to use the feature. Therefore the flag does not need to be set anymore.

fwyzard commented 1 month ago

Thanks for the explanation. I let you approve the PR :-)