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

C++20 compilation errors #1966

Closed iarspider closed 1 year ago

iarspider commented 1 year ago

Hello,

we are testing CMSSW software with C++20, and we observe the following error coming from Alpaka:

/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-e30fb68be5dbc9ad534ab5b10ba8ea7c/bin/c++ -MMD -MF DataFormatsPortableTestObjectsCudaAsync/a/DataFormatsPortableTestObjectsCudaAsync_xr.cc.d -c -I/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/a14bf464246f95136089dfec95b1a932/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_13_2_CPP20_X_2023-06-19-1100 -DGNU_GCC -D_GNU_SOURCE -DEIGEN_DONT_PARALLELIZE -DTBB_USE_GLIBCXX_VERSION=120301 -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DTBB_PREVIEW_RESUMABLE_TASKS=1 -DTBB_PREVIEW_TASK_GROUP_EXTENSIONS=1 -DBOOST_SPIRIT_THREADSAFE -DPHOENIX_THREADSAFE -DBOOST_MATH_DISABLE_STD_FPCLASSIFY -DBOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX -DCMSSW_GIT_HASH="CMSSW_13_2_CPP20_X_2023-06-19-1100" -DPROJECT_NAME="CMSSW" -DPROJECT_VERSION="CMSSW_13_2_CPP20_X_2023-06-19-1100" -I/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/a14bf464246f95136089dfec95b1a932/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_13_2_CPP20_X_2023-06-19-1100/src -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/develop-20230215-a37f028d24c0a0c96276684ace2bf9fc/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/pcre/8.43-ee0ac3651e0571e8d71676c53f87f6bb/include -isystem/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/boost/1.80.0-5ce416e4e3d324bce139418ff776bc40/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/bz2lib/1.0.6-dfa3ff7cacf48cd32eb3d45cd63fee68/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/cuda/12.0.1-2e5f00a210425510b7cef80bca1c7aea/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/libuuid/2.34-987bc5996c3fb810503cd0c8fa963d12/include -isystem/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.28.05-e314476965ac3f15ab54162722584362/include -isystem/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/tbb/v2021.8.0-9814d2d84c34bbf56b362194ee5f6730/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/xz/5.2.5-0092caf13c3ab3a2c2c0afdfa28e0244/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/zlib/1.2.11-2ddeceaaf8d16873849934d49137d43d/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/eigen/82dd3710dac619448f50331c1d6a35da673f764a-3a9941cb71e69d858602f027f1d2c407/include/eigen3 -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/fmt/8.0.1-d380b275137f6ca5b5f3df006f3359bf/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/md5/1.0.0-98e498def849b64d1566bff1f12ce11e/include -I/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/tinyxml2/6.2.0-13db7fefb20600bc8a3335e6543da9d2/include -DCMSSW_REFLEX_DICT -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++20 -ftree-vectorize -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -Wno-error=array-bounds -Warray-bounds -fuse-ld=bfd -msse3 -felide-constructors -fmessage-length=0 -Wall -Wno-non-template-friend -Wno-long-long -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-unused-parameter -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Werror=strict-aliasing -Werror=narrowing -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-psabi -Wno-error=unused-variable -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 -DALPAKA_ACC_GPU_CUDA_ENABLED -DALPAKA_HOST_ONLY -DBOOST_DISABLE_ASSERTS -Os -Wno-unused-variable -flto -fipa-icf -flto-odr-type-merging -fno-fat-lto-objects -Wodr -fPIC DataFormatsPortableTestObjectsCudaAsync/a/DataFormatsPortableTestObjectsCudaAsync_xr.cc -o DataFormatsPortableTestObjectsCudaAsync/a/DataFormatsPortableTestObjectsCudaAsync_xr.cc.o
In file included from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/develop-20230215-a37f028d24c0a0c96276684ace2bf9fc/include/alpaka/event/EventCudaRt.hpp:15,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/develop-20230215-a37f028d24c0a0c96276684ace2bf9fc/include/alpaka/alpaka.hpp:105,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/a14bf464246f95136089dfec95b1a932/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_13_2_CPP20_X_2023-06-19-1100/src/DataFormats/Portable/interface/alpaka/PortableCollection.h:6,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/a14bf464246f95136089dfec95b1a932/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_13_2_CPP20_X_2023-06-19-1100/src/DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h:4,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/a14bf464246f95136089dfec95b1a932/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_13_2_CPP20_X_2023-06-19-1100/src/DataFormats/PortableTestObjects/src/alpaka/classes_cuda.h:4,
                 from DataFormatsPortableTestObjectsCudaAsync/a/DataFormatsPortableTestObjectsCudaAsync_xr.cc:38:
  /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/develop-20230215-a37f028d24c0a0c96276684ace2bf9fc/include/alpaka/event/EventUniformCudaHipRt.hpp:98:78: error: invalid declarator before 'const'
    98 |         ALPAKA_FN_HOST EventUniformCudaHipRt<TApi>(DevUniformCudaHipRt<TApi> const& dev, bool bBusyWait = true)
      |                                                                              ^~~~~
  /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/develop-20230215-a37f028d24c0a0c96276684ace2bf9fc/include/alpaka/event/EventUniformCudaHipRt.hpp:98:77: error: expected ')' before 'const'
    98 |         ALPAKA_FN_HOST EventUniformCudaHipRt<TApi>(DevUniformCudaHipRt<TApi> const& dev, bool bBusyWait = true)
      |                                                   ~                         ^~~~~~
      |                                                                             )
  gmake: *** [tmp/el8_amd64_gcc12/src/DataFormats/PortableTestObjects/src/alpaka/DataFormatsPortableTestObjectsCudaAsync/a/DataFormatsPortableTestObjectsCudaAsync_xr.cc.o] Error 1

As far as I understand, in C++20 one should use bare (templated) class name without template specialization in constructor and destructor names, i.e. this

template<typename T>
struct S {
    S<T>();
};

is no longer valid, and should be replaced with

template<typename T>
struct S {
    S();
};

(same applies to destructors)

j-stephan commented 1 year ago

Hi @iarspider, thanks for reaching out. If I interpret your command line correctly you are trying to compile the CUDA back-end in C++20 mode with g++-12, right?

iarspider commented 1 year ago

@j-stephan yes, exactly.

j-stephan commented 1 year ago

Thanks for reporting this. It uncovered a gap in our CI test matrix which we need to fill. Afterwards we'll look into your error.

bernhardmgruber commented 1 year ago

As far as I understand, in C++20 one should use bare (templated) class name without template specialization in constructor and destructor names, i.e. this

template<typename T>
struct S {
    S<T>();
};

is no longer valid, and should be replaced with

template<typename T>
struct S {
    S();
};

I am surprised this even worked before C++20. I always thought the constructor can only be named through the injected class name, which is S in that case.

I will post a fix.

fwyzard commented 1 year ago

It's a breaking change in c++20: https://cplusplus.github.io/CWG/issues/2237.html .