LLNL / zfp

Compressed numerical arrays that support high-speed random access
http://zfp.llnl.gov
BSD 3-Clause "New" or "Revised" License
768 stars 155 forks source link

ppc32: index.hpp: error: integer constant is too large for ‘unsigned long’ type #205

Closed barracuda156 closed 1 year ago

barracuda156 commented 1 year ago

With gcc-4.2 the build errs out if tests are turned on (without tests it builds fine):

In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-1.0.0/include/zfp/array1.hpp:8,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-1.0.0/tests/testzfp.cpp:14:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-1.0.0/include/zfp/index.hpp:496: error: integer constant is too large for ‘unsigned long’ type

(Example is with v. 1.0.0, but same error with master.)

With gcc-11 build completes, though with overflow warnings:

In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/array2.hpp:8,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/tests/testviews.cpp:5:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp: In member function 'void zfp::index::hybrid4::set_block_size(size_t, size_t)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp:269:15: warning: right shift count >= width of type [-Wshift-count-overflow]
  269 |       if (ptr >> (32 + shift))
      |           ~~~~^~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp: In static member function 'static uint64 zfp::index::hybrid8<dims>::lsum(uint64)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp:500:12: warning: right shift count >= width of type [-Wshift-count-overflow]
  500 |     x += x >> 32;
      |          ~~^~~~~
[ 95%] Linking C executable ../bin/zfp
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/build/utils && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/zfpcmd.dir/link.txt --verbose=ON
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/array1.hpp:8,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/tests/testzfp.cpp:14:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp: In member function 'void zfp::index::hybrid4::set_block_size(size_t, size_t)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp:269:15: warning: right shift count >= width of type [-Wshift-count-overflow]
  269 |       if (ptr >> (32 + shift))
      |           ~~~~^~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp: In static member function 'static uint64 zfp::index::hybrid8<dims>::lsum(uint64)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_math_zfp/zfp/work/zfp-f15d00720e454cd70206a85d7013d8240ad38585/include/zfp/index.hpp:500:12: warning: right shift count >= width of type [-Wshift-count-overflow]
  500 |     x += x >> 32;
      |          ~~^~~~~
barracuda156 commented 1 year ago

However, tests fail (tbh they don’t look bad to me, perhaps threshold of precision for 32-bit should be adjusted?):

zfp_ppc32_gcc11.log

lindstro commented 1 year ago

It appears that you're compiling zfp in C89 mode but the compiler presumably uses the LLP64 data model, which zfp is not detecting correctly (testzfp reports "data model unknown"). One thing to try is to add the following to the CMake line:

-DZFP_INT64='long long' -DZFP_INT64_SUFFIX=ll -DZFP_UINT64='unsigned long long' -DZFP_UINT64_SUFFIX=ull

If instead you're compiling with GNU Make, then try the following

make DEFS="-DZFP_INT64='long long' -DZFP_INT64_SUFFIX=ll -DZFP_UINT64='unsigned long long' -DZFP_UINT64_SUFFIX=ull"
barracuda156 commented 1 year ago

@lindstro Let me try, thank you!

UPD. It worked! Thanks again.

--->  Testing zfp
Executing:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_science_zfp/zfp/work/build" && DYLD_LIBRARY_PATH=/opt/local/var/macports/build/_opt_PPCRosettaPorts_science_zfp/zfp/work/build/lib /usr/bin/make test 
Running tests...
/opt/local/bin/ctest --force-new-ctest-process 
Test project /opt/local/var/macports/build/_opt_PPCRosettaPorts_science_zfp/zfp/work/build
    Start 1: testzfp
1/2 Test #1: testzfp ..........................   Passed    1.43 sec
    Start 2: testviews
2/2 Test #2: testviews ........................   Passed    0.26 sec

100% tests passed, 0 tests failed out of 2