Skip to content

CUDA < 12.4.1 bug affects use of openPMD-api in C++20 projects #1720

Open
@franzpoeschel

Description

@franzpoeschel

Describe the bug
This bug basically makes std::variant unusable in the affected CUDA versions.

To Reproduce
I've seen this issue when trying to compile the latest dev branch of PIConGPU (2981b07a7160e64d057b5653f3d26410d54a8135) against the openPMD-api (version does not really matter, I used a4d66cc).

The error affects multiple usages of std::variant, e.g.:

/nix/store/6vclfnmcqpm1k5bbh5syf89f21gip2v3-gcc-12.3.0/include/c++/12.3.0/variant(391): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with
 _First=unsigned int, _Rest=<unsigned long, unsigned long long, float, double, long double, std::complex<float>, std::complex<double>, std::complex<long double>, std::string, std::vector<cha
r, std::allocator<char>>, std::vector<short, std::allocator<short>>, std::vector<int, std::allocator<int>>, std::vector<long, std::allocator<long>>, std::vector<long long, std::allocator<lon
g long>>, std::vector<unsigned char, std::allocator<unsigned char>>, std::vector<unsigned short, std::allocator<unsigned short>>, std::vector<std::seed_seq::result_type, std::allocator<std::
seed_seq::result_type>>, std::vector<std::size_t, std::allocator<std::size_t>>, std::vector<unsigned long long, std::allocator<unsigned long long>>, std::vector<float, std::allocator<float>>
, std::vector<double, std::allocator<double>>, std::vector<long double, std::allocator<long double>>, std::vector<std::complex<float>, std::allocator<std::complex<float>>>, std::vector<std::
complex<double>, std::allocator<std::complex<double>>>, std::vector<std::complex<long double>, std::allocator<std::complex<long double>>>, std::vector<signed char, std::allocator<signed char
>>, std::vector<std::string, std::allocator<std::string>>, openpmd_array_double_7, bool>]" (declared at line 400) cannot be referenced -- it is a deleted function                            
   : _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...)                                                                                                                           
            ^                                                                                                                                                                                 
          detected during:
…
…
…
            instantiation of "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...>::_Move_ctor_base(std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> &&) [with <unna
med>=false, _Types=<char, unsigned char, signed char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::complex<f
loat>, std::complex<double>, std::complex<long double>, std::string, std::vector<char, std::allocator<char>>, std::vector<short, std::allocator<short>>, std::vector<int, std::allocator<int>>
, std::vector<long, std::allocator<long>>, std::vector<long long, std::allocator<long long>>, std::vector<unsigned char, std::allocator<unsigned char>>, std::vector<unsigned short, std::allo
cator<unsigned short>>, std::vector<std::seed_seq::result_type, std::allocator<std::seed_seq::result_type>>, std::vector<std::size_t, std::allocator<std::size_t>>, std::vector<unsigned long 
long, std::allocator<unsigned long long>>, std::vector<float, std::allocator<float>>, std::vector<double, std::allocator<double>>, std::vector<long double, std::allocator<long double>>, std:
:vector<std::complex<float>, std::allocator<std::complex<float>>>, std::vector<std::complex<double>, std::allocator<std::complex<double>>>, std::vector<std::complex<long double>, std::alloca
tor<std::complex<long double>>>, std::vector<signed char, std::allocator<signed char>>, std::vector<std::string, std::allocator<std::string>>, openpmd_array_double_7, bool>]" at line 59 of /
home/franzpoeschel/picongpu_env/env/include/openPMD/backend/Attribute.hpp

Line:

class Attribute : public auxiliary::Variant<Datatype, attribute_types>

or

/nix/store/6vclfnmcqpm1k5bbh5syf89f21gip2v3-gcc-12.3.0/include/c++/12.3.0/variant(391): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with
 _First=openPMD::UniquePtrWithLambda<void>, _Rest=<>]" (declared at line 400) cannot be referenced -- it is a deleted function                                                                
   : _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...)                                                                                                                           
            ^                                                                                                                                                                                 
          detected during:  
…
…
…
            instantiation of "std::variant<_Types...>::variant(_Tp &&) [with _Types=<std::shared_ptr<const void>, openPMD::UniquePtrWithLambda<void>>, _Tp=openPMD::UniquePtrWithLambda<void>,
 <unnamed>=void, <unnamed>=void, _Tj=openPMD::UniquePtrWithLambda<void>, <unnamed>=void]" at line 181 of /home/franzpoeschel/picongpu_env/env/include/openPMD/auxiliary/Memory.hpp

Line:

EligibleTypes m_buffer;

What should we do

I don't see an easy way out of this. Looking at the linked bug report, even trivial use of std::variant seems to be impossible. In openPMD::Attribute, std::variant is part of our public API, so we can't easily replace it with something else.

  • Option 1: Check the affected CUDA versions, add some include guard to cancel compilation with the note that the CUDA version is broken and something else should be used.
  • Option 2: Reintroduce mpark::variant? It seems to be unmaintained though

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions