talhasaruhan / SIMD-DHash

SIMD DHash implementation in C/C++
1 stars 0 forks source link

MSYS compilation errors #1

Open hafedh-trimeche opened 1 year ago

hafedh-trimeche commented 1 year ago

Hello,

Please note these errors:

gcc -shared -D__MSYS__ -Ofast -o 64/dhash.dll -static test.cpp
In file included from test.cpp:1:
DHash.h: In function 'void Resize_3(const uint8_t*, int, int, uint8_t*)':
DHash.h:86:42: error: request for member 'm256i_i32' in 'block_accumulate', which is of non-class type '__m256i'
   86 |                         block_accumulate.m256i_i32[i] = _horizontal_sum_4xi32(block_accumulate_wide[i]);
      |                                          ^~~~~~~~~
DHash.h: In function 'void Resize_2(const uint8_t*, int, int, uint8_t*)':
DHash.h:133:37: error: request for member 'm256i_i32' in 'row', which is of non-class type '__m256i'
  133 |                                 row.m256i_i32[block_i] = _horizontal_sum_8xi32(accumulate);
      |                                     ^~~~~~~~~
DHash.h: In function 'void Resize_1(const uint8_t*, int, int, uint8_t*)':
DHash.h:184:48: error: 'round' was not declared in this scope; did you mean 'std::chrono::round'?
  184 |                         accumulate = (uint32_t)round((float)accumulate * inv_num_px_per_block);
      |                                                ^~~~~
      |                                                std::chrono::round
In file included from D:/msys/mingw64/include/c++/12.2.0/chrono:39,
                 from DHash.h:6:
D:/msys/mingw64/include/c++/12.2.0/bits/chrono.h:971:7: note: 'std::chrono::round' declared here
  971 |       round(const time_point<_Clock, _Dur>& __tp)
      |       ^~~~~
DHash.h: In function 'void Resize_Naive(const uint8_t*, int, int, uint8_t*)':
DHash.h:216:48: error: 'round' was not declared in this scope; did you mean 'std::chrono::round'?
  216 |                         accumulate = (uint32_t)round((float)accumulate * inv_num_px_per_block);
      |                                                ^~~~~
      |                                                std::chrono::round
D:/msys/mingw64/include/c++/12.2.0/bits/chrono.h:971:7: note: 'std::chrono::round' declared here
  971 |       round(const time_point<_Clock, _Dur>& __tp)
      |       ^~~~~
DHash.h: In function 'void Resize_3(const uint8_t*, int, int, uint8_t*)':
DHash.h:44:82: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
   44 |         __m256 normalizing_multiplier = _mm256_broadcast_ss(&inv_num_px_per_block);
      |                                                                                  ^

Best regards.

talhasaruhan commented 1 year ago

Hi! Thank you for bringing this to my attention.

There seems to be a few things wrong here:

  1. m256i_i32 is MSVC only, I probably shouldn't have used that regardless. But it's just used to hold the horizontal sums of multiple vectors in each integer in the row vector, which is then horizontally summed. If your use case is immediate you can simply replace that part with a normal integer accumulator.
  2. round is not defined, that should be a simple fix, just add #include <cmath> at the top
  3. Warning about AVX vector return is about your build system configuration, I'd try adding the appropriate -march flag.