CastellanZhang / alphaFM

Multi-thread implementation of Factorization Machines with FTRL for binary-class classification problem.
MIT License
885 stars 275 forks source link

no member named '_Hash_node_base' in namespace 'std::__1::__detail' #34

Closed rotcx closed 3 years ago

rotcx commented 3 years ago

MacOS

g++ -O3 fm_train.cpp src/Frame/pc_frame.cpp src/Utils/utils.cpp -I . -std=c++11 -o bin/fm_train -lpthread In file included from fm_train.cpp:5: In file included from ./src/FTRL/ftrl_trainer.h:5: In file included from ./src/FTRL/ftrl_model.h:14: ./src/FTRL/../Mem/my_allocator.h:42:58: error: expected expression if(typeid(T) == typeid(__detail::_Hash_node_base)) ^ ./src/FTRL/../Mem/my_allocator.h:42:42: error: no member named '_Hash_node_base' in namespace 'std::1::detail' if(typeid(T) == typeid(__detail::_Hash_node_base))


./src/FTRL/../Mem/my_allocator.h:53:32: error: no template named '_Hash_node' in namespace 'std::__1::__detail'; did you mean '__hash_node'?
if(typeid(T) != typeid(std::__detail::_Hash_node<std::pair<const char* const, MODEL_UNIT >, false>))
^~~~~~~~~~~~~~~~~~~~~~~~~
__hash_node
/Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:95:8: note: '__hash_node' declared here
struct __hash_node
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
In file included from ./src/FTRL/ftrl_model.h:14:
./src/FTRL/../Mem/my_allocator.h:53:104: error: template argument for template type parameter must be a type
if(typeid(T) != typeid(std::__detail::_Hash_node<std::pair<const char* const, MODEL_UNIT >, false>))
^~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:94:28: note: template parameter is declared here
template <class _Tp, class _VoidPtr>
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
In file included from ./src/FTRL/ftrl_model.h:14:
./src/FTRL/../Mem/my_allocator.h:64:58: error: expected expression
if(typeid(T) == typeid(__detail::_Hash_node_base*))
^
./src/FTRL/../Mem/my_allocator.h:64:42: error: no member named '_Hash_node_base' in namespace 'std::__1::__detail'
if(typeid(T) == typeid(__detail::_Hash_node_base*))
~~~~~~~~~~^
./src/FTRL/../Mem/my_allocator.h:82:16: error: use of undeclared identifier '_Hash_impl'
return _Hash_impl::hash(key, strlen(key));
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
./src/FTRL/ftrl_model.h:44:27: error: no template named '_Hash_node' in namespace 'std::__1::__detail'; did you mean '__hash_node'?
using node_type = std::__detail::_Hash_node<std::pair<const char* const, ftrl_model_unit >, false>;
^~~~~~~~~~~~~~~~~~~~~~~~~
__hash_node
/Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:95:8: note: '__hash_node' declared here
struct __hash_node
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
./src/FTRL/ftrl_model.h:44:104: error: template argument for template type parameter must be a type
using node_type = std::__detail::_Hash_node<std::pair<const char* const, ftrl_model_unit >, false>;
^~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:94:28: note: template parameter is declared here
template <class _Tp, class _VoidPtr>
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
./src/FTRL/ftrl_model.h:45:61: error: use of undeclared identifier 'node_type'
size_t offset_this = get_value_offset_in_Hash_node((node_type*)NULL);
^
./src/FTRL/ftrl_model.h:45:71: error: expected expression
size_t offset_this = get_value_offset_in_Hash_node((node_type*)NULL);
^
./src/FTRL/ftrl_model.h:46:33: error: unknown type name 'node_type'; did you mean 'true_type'?
size_t padding = sizeof(node_type) - offset_this - class_size;
^~~~~~~~~
true_type
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:540:38: note: 'true_type' declared here
typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
In file included from ./src/FTRL/ftrl_model.h:4:
/Library/Developer/CommandLineTools/usr/include/c++/v1/unordered_map:826:5: error: static_assert failed due to requirement 'is_same<value_type, typename
allocator_type::value_type>::value' "Invalid allocator::value_type"
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/FTRL/ftrl_model.h:204:20: note: in instantiation of template class 'std::__1::unordered_map<const char *, ftrl_model_unit, my_hash, my_equal,
my_allocator<std::__1::pair<const char *, ftrl_model_unit >, float, ftrl_model_unit> >' requested here
my_hash_map muMap;
^
./src/FTRL/ftrl_trainer.h:191:18: note: in instantiation of template class 'ftrl_model' requested here
pModel = new ftrl_model(opt.factor_num, opt.init_mean, opt.init_stdev);
^
fm_train.cpp:40:21: note: in instantiation of member function 'ftrl_trainer::ftrl_trainer' requested here
ftrl_trainer trainer(opt);
^
fm_train.cpp:87:16: note: in instantiation of function template specialization 'train' requested here
return train(opt);
^
In file included from fm_train.cpp:5:
In file included from ./src/FTRL/ftrl_trainer.h:5:
In file included from ./src/FTRL/ftrl_model.h:4:
/Library/Developer/CommandLineTools/usr/include/c++/v1/unordered_map:826:5: error: static_assert failed due to requirement 'is_same<value_type, typename
allocator_type::value_type>::value' "Invalid allocator::value_type"
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/FTRL/ftrl_model.h:204:20: note: in instantiation of template class 'std::__1::unordered_map<const char *, ftrl_model_unit, my_hash, my_equal,
my_allocator<std::__1::pair<const char *, ftrl_model_unit >, double, ftrl_model_unit> >' requested here
my_hash_map muMap;
^
./src/FTRL/ftrl_trainer.h:191:18: note: in instantiation of template class 'ftrl_model' requested here
pModel = new ftrl_model(opt.factor_num, opt.init_mean, opt.init_stdev);
^
fm_train.cpp:40:21: note: in instantiation of member function 'ftrl_trainer::ftrl_trainer' requested here
ftrl_trainer trainer(opt);
^
fm_train.cpp:89:12: note: in instantiation of function template specialization 'train' requested here
return train(opt);
^
14 errors generated.
src/Frame/pc_frame.cpp:9:5: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
sem_init(&semPro, 0, 1);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/semaphore.h:55:42: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro '__deprecated'
#define __deprecated attribute((deprecated))
^
src/Frame/pc_frame.cpp:10:5: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
sem_init(&semCon, 0, 0);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/semaphore.h:55:42: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro '__deprecated'
#define __deprecated attribute((deprecated))
^
2 warnings generated.
make: *** [all] Error 1
nwnlp commented 3 years ago

upgrade your gcc like: brew install gcc@8

rotcx commented 3 years ago

upgrade your gcc like: brew install gcc@8

gcc version is 9 currently

gcc -v Using built-in specs. COLLECT_GCC=gcc-9 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_3/libexec/gcc/x86_64-apple-darwin18/9.2.0/lto-wrapper Target: x86_64-apple-darwin18 Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.2.0_3 --libdir=/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk Thread model: posix gcc version 9.2.0 (Homebrew GCC 9.2.0_3)

rotcx commented 3 years ago

upgrade your gcc like: brew install gcc@8

g++ -v
Using built-in specs. COLLECT_GCC=g++-9 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_3/libexec/gcc/x86_64-apple-darwin18/9.2.0/lto-wrapper Target: x86_64-apple-darwin18 Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.2.0_3 --libdir=/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk Thread model: posix gcc version 9.2.0 (Homebrew GCC 9.2.0_3)

rotcx commented 3 years ago

upgrade your gcc like: brew install gcc@8

if I used gcc to complie

/usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h:192:21: error: static assertion failed: unordered container must have the same value_type as its allocator 192 | static_assert(is_same<typename _Alloc::value_type, _Value>{}, | ^~~~~~~~~~

gcc -O3 fm_train.cpp src/Frame/pc_frame.cpp src/Utils/utils.cpp -I . -std=c++11 -o bin/fm_train -lpthread In file included from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/unordered_map:46, from src/FTRL/ftrl_model.h:4, from src/FTRL/ftrl_trainer.h:5, from fm_train.cpp:5: /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h: In instantiation of 'class std::_Hashtable<const char, std::pair<const char const, ftrl_model_unit >, my_allocator<std::pair<const char, ftrl_model_unit >, float, ftrl_model_unit>, std::detail::_Select1st, my_equal, my_hash, std::__detail::_Mod_range_hashing, std::detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >': /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/unordered_map.h:105:18: required from 'class std::unordered_map<const char, ftrl_model_unit, my_hash, my_equal, my_allocator<std::pair<const char, ftrl_model_unit >, float, ftrl_model_unit> >' src/FTRL/ftrl_model.h:204:20: required from 'class ftrl_model' src/FTRL/ftrl_trainer.h:191:14: required from 'ftrl_trainer::ftrl_trainer(const trainer_option&) [with T = float]' fm_train.cpp:40:21: required from 'int train(const trainer_option&) [with T = float]' fm_train.cpp:87:32: required from here /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h:192:21: error: static assertion failed: unordered container must have the same value_type as its allocator 192 | static_assert(is_same<typename _Alloc::value_type, _Value>{}, | ^~~~~~~~~~ /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h:275:21: error: static assertion failed: Cache the hash code or qualify your functors involved in hash code and bucket index computation with noexcept 275 | static_assert(noexcept(declval<const hash_code_base_access&>() | ^~~~~~~~~~~~~~ 276 | ._M_bucket_index((const node_type)nullptr, | ~~~~~~~~~ 277 | (std::size_t)0)), | ~~~~ /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h: In instantiation of 'class std::_Hashtable<const char, std::pair<const char const, ftrl_model_unit >, my_allocator<std::pair<const char, ftrl_model_unit >, double, ftrl_model_unit>, std::detail::_Select1st, my_equal, my_hash, std::__detail::_Mod_range_hashing, std::detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >': /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/unordered_map.h:105:18: required from 'class std::unordered_map<const char, ftrl_model_unit, my_hash, my_equal, my_allocator<std::pair<const char, ftrl_model_unit >, double, ftrl_model_unit> >' src/FTRL/ftrl_model.h:204:20: required from 'class ftrl_model' src/FTRL/ftrl_trainer.h:191:14: required from 'ftrl_trainer::ftrl_trainer(const trainer_option&) [with T = double]' fm_train.cpp:40:21: required from 'int train(const trainer_option&) [with T = double]' fm_train.cpp:89:29: required from here /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h:192:21: error: static assertion failed: unordered container must have the same value_type as its allocator 192 | static_assert(is_same<typename _Alloc::value_type, _Value>{}, | ^~~~~~~~~~ /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/hashtable.h:275:21: error: static assertion failed: Cache the hash code or qualify your functors involved in hash code and bucket index computation with noexcept 275 | static_assert(noexcept(declval<const hash_code_base_access&>() | ^~~~~~~~~~~~~~ 276 | ._M_bucket_index((const node_type)nullptr, | ~~~~~~~~~ 277 | (std::size_t)0)), | ~~~~ src/Frame/pc_frame.cpp: In member function 'bool pc_frame::init(pc_task&, int, int, int)': src/Frame/pc_frame.cpp:9:27: warning: 'int sem_init(sem_t, int, unsigned int)' is deprecated [-Wdeprecated-declarations] 9 | sem_init(&semPro, 0, 1); | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/semaphore.h:29, from src/Frame/pc_frame.h:11, from src/Frame/pc_frame.cpp:1: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:5: note: declared here 55 | int sem_init(sem_t , int, unsigned int) deprecated; | ^~~~ src/Frame/pc_frame.cpp:9:27: warning: 'int sem_init(sem_t, int, unsigned int)' is deprecated [-Wdeprecated-declarations] 9 | sem_init(&semPro, 0, 1); | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/semaphore.h:29, from src/Frame/pc_frame.h:11, from src/Frame/pc_frame.cpp:1: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:5: note: declared here 55 | int sem_init(sem_t , int, unsigned int) deprecated; | ^~~~ src/Frame/pc_frame.cpp:10:27: warning: 'int sem_init(sem_t, int, unsigned int)' is deprecated [-Wdeprecated-declarations] 10 | sem_init(&semCon, 0, 0); | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/semaphore.h:29, from src/Frame/pc_frame.h:11, from src/Frame/pc_frame.cpp:1: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:5: note: declared here 55 | int sem_init(sem_t , int, unsigned int) deprecated; | ^~~~ src/Frame/pc_frame.cpp:10:27: warning: 'int sem_init(sem_t, int, unsigned int)' is deprecated [-Wdeprecated-declarations] 10 | sem_init(&semCon, 0, 0); | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/semaphore.h:29, from src/Frame/pc_frame.h:11, from src/Frame/pc_frame.cpp:1: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:5: note: declared here 55 | int sem_init(sem_t , int, unsigned int) deprecated; | ^~~~