cyclops-community / ctf

Cyclops Tensor Framework: parallel arithmetic on multidimensional arrays
Other
194 stars 53 forks source link

Compile error with GCC 11 #131

Open susilehtola opened 2 years ago

susilehtola commented 2 years ago

Trying to compile the current master branch with gcc 11.2.1 in Fedora 35 leads to

mpicxx -O3 -fopenmp -Wall  -D_POSIX_C_SOURCE=200112L -D__STDC_LIMIT_MACROS -DFTN_UNDERSCORE=1 -DUSE_LAPACK   -c idx_tensor.cxx -o /home/work/aquarius.susi/src/external/ctf/obj/idx_tensor.o
In file included from /usr/include/c++/11/map:60,
                 from /usr/include/openmpi-x86_64/openmpi/ompi/mpi/cxx/mpicxx.h:42,
                 from /usr/include/openmpi-x86_64/mpi.h:2887,
                 from common.h:18,
                 from idx_tensor.cxx:3:
/usr/include/c++/11/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<CTF::Idx_Tensor*>*]’:
/usr/include/c++/11/bits/stl_tree.h:2069:47:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = CTF::Idx_Tensor*]’
/usr/include/c++/11/bits/stl_tree.h:2122:4:   required from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = CTF::Idx_Tensor*; _Key = CTF::Idx_Tensor*; _Val = CTF::Idx_Tensor*; _KeyOfValue = std::_Identity<CTF::Idx_Tensor*>; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>]’
/usr/include/c++/11/bits/stl_set.h:521:25:   required from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = CTF::Idx_Tensor*; _Compare = CTF_int::tensor_name_less; _Alloc = std::allocator<CTF::Idx_Tensor*>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<CTF::Idx_Tensor*, CTF::Idx_Tensor*, std::_Identity<CTF::Idx_Tensor*>, CTF_int::tensor_name_less, std::allocator<CTF::Idx_Tensor*> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<CTF::Idx_Tensor*>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<CTF::Idx_Tensor*>, CTF::Idx_Tensor*>::rebind<CTF::Idx_Tensor*>; typename _Alloc::value_type = CTF::Idx_Tensor*; std::set<_Key, _Compare, _Alloc>::value_type = CTF::Idx_Tensor*]’
idx_tensor.cxx:325:23:   required from here
/usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
  770 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const CTF_int::tensor_name_less&, CTF::Idx_Tensor* const&, CTF::Idx_Tensor* const&>’ evaluates to false
covitof commented 2 years ago

I have run into the same problem. I'm not entirely sure what the problem is and what it is related to, but I assumed it was an issue with newer versions of the compiler and tried 'CXXFLAGS=-std=c++14' which solved the problem for me.

susilehtola commented 2 years ago

Right. The problem is that configure does not set the C++ standard...

susilehtola commented 2 years ago

Migrating to CMake would probably make a lot of things easier..

raghavendrak commented 2 years ago

The tensor_name_less::operator() should be const (in interface/term.h and interface/term.cxx). Comparison operators should be constant, and I think they are being enforced in this compiler. Will submit a pull request to fix this.

jeffhammond commented 2 years ago

Switching to CMake when the problem requires a 1-line fix for each compiler type (and almost all of them use GCC-compatible -std= anyways) is killing a mosquito with nuclear weapons.

I will write the trivial fix in configure. CMake is going to create an endless nightmare of maintenance.

susilehtola commented 2 years ago

Switching to CMake when the problem requires a 1-line fix for each compiler type (and almost all of them use GCC-compatible -std= anyways) is killing a mosquito with nuclear weapons.

But hey, at least the bug is dead! [Also, Finland used to host world championships of mosquito swatting.]

raghavendrak commented 2 years ago

@susilehtola Was wondering if the pull request mentioned here fixed the issue for c++11?

susilehtola commented 2 years ago

@raghavendrak I tried, but the PR doesn't give a clean patch

raghavendrak commented 2 years ago

@susilehtola sorry there was an issue in my fork. Have fixed the same. Can you try it now?

susilehtola commented 2 years ago

@susilehtola sorry there was an issue in my fork. Have fixed the same. Can you try it now?

fix confirmed