bab2min / tomotopy

Python package of Tomoto, the Topic Modeling Tool
https://bab2min.github.io/tomotopy
MIT License
548 stars 62 forks source link

C++ compilation error with v0.12.3 and AVX-512F #188

Open ankane opened 1 year ago

ankane commented 1 year ago

Hey @bab2min,

Hope things are good with you! I'm working on updating the Ruby gem from 0.12.2 to 0.12.3, but am running into a few errors when -march=native is set on Linux and Mac with AVX-512F. The full logs are here, but I've tried to capture the relevant parts below:

Error 1

/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/../Utils/EigenAddonOps.hpp:162:20: error: no matching function for call to ‘p_to_f32(const type&)’
  162 |     return p_to_f32(a);
      |            ~~~~~~~~^~~
In file included from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/LDAModel.hpp:5,
                 from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/CTModel.hpp:2,
                 from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/CTModel.cpp:1:
/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/../Utils/EigenAddonOps.hpp:42:32: note: candidate: ‘Eigen::internal::Packet8f Eigen::internal::p_to_f32(const Packet8i&)’
   42 |   EIGEN_STRONG_INLINE Packet8f p_to_f32(const Packet8i& a)
      |                                ^~~~~~~~
/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/../Utils/EigenAddonOps.hpp:42:57: note:   no known conversion for argument 1 from ‘const type’ {aka ‘const __vector(16) float’} to ‘const Packet8i&’ {aka ‘const __vector(4) long long int&’}
   42 |   EIGEN_STRONG_INLINE Packet8f p_to_f32(const Packet8i& a)
      |                                         ~~~~~~~~~~~~~~~~^
In file included from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/LDAModel.hpp:5,
                 from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/CTModel.hpp:2,
                 from /home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/CTModel.cpp:1:
/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/../Utils/EigenAddonOps.hpp:77:32: note: candidate: ‘Eigen::internal::Packet4f Eigen::internal::p_to_f32(const Packet4i&)’
   77 |   EIGEN_STRONG_INLINE Packet4f p_to_f32(const Packet4i& a)
      |                                ^~~~~~~~
/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/tomotopy/src/TopicModel/../Utils/EigenAddonOps.hpp:77:57: note:   no known conversion for argument 1 from ‘const type’ {aka ‘const __vector(16) float’} to ‘const Packet4i&’ {aka ‘const Eigen::internal::eigen_packet_wrapper<__vector(2) long long int, 0>&’}
   77 |   EIGEN_STRONG_INLINE Packet4f p_to_f32(const Packet4i& a)
      |                                         ~~~~~~~~~~~~~~~~^

Error 2

/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/eigen/Eigen/src/Core/CoreEvaluators.h:944:58: error: cannot convert ‘Eigen::internal::mapbase_evaluator<Eigen::Map<Eigen::Matrix<int, -1, 1>, 0, Eigen::Stride<0, 0> >, Eigen::Matrix<int, -1, 1> >::PointerType’ {aka ‘int*’} to ‘const type*’ {aka ‘const float*’}
  944 |     return internal::ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());

Error 3

/home/runner/work/tomoto-ruby/tomoto-ruby/vendor/eigen/Eigen/src/Core/CoreEvaluators.h:245:50: error: cannot convert ‘const int*’ to ‘const type*’ {aka ‘const float*’}
  245 |     return ploadt<PacketType, LoadMode>(m_d.data + index);
      |                                         ~~~~~~~~~^~~~~~~
      |                                                  |
      |                                                  const int*

It works great without -march=native/-mfma -mavx512f.

If you have any ideas, please let me know. If not, thanks for taking the time to read!

bab2min commented 1 year ago

Hi @ankane, Actually tomotopy doesn't support AVX512 yet. I'm not sure how it was compiled well at 0.12.2 version. I'll work to support AVX512 in the next update. Thank you for your suggestion.

ankane commented 1 year ago

That was fast. Thanks as always @bab2min!

It looks like compiling with -march=native -mno-avx512f works, so can use that for Ruby.