Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: 4.0.1 fails on i386 systems: call to 'countOnes' is ambiguous #3477

Closed
yurivict opened this issue Aug 20, 2021 · 6 comments · Fixed by #3606
Closed

BLD: 4.0.1 fails on i386 systems: call to 'countOnes' is ambiguous #3477

yurivict opened this issue Aug 20, 2021 · 6 comments · Fixed by #3606
Labels
bug build related to the build process
Milestone

Comments

@yurivict
Copy link

In file included from yt/utilities/lib/ewah_bool_wrap.cpp:684:
In file included from yt/utilities/lib/ewahboolarray/ewah.h:710:
yt/utilities/lib/ewahboolarray/ewah-inl.h:374:14: error: call to 'countOnes' is ambiguous
      tot += countOnes((uword)buffer[pointer]);
             ^~~~~~~~~
yt/utilities/lib/ewah_bool_wrap.cpp:4902:39: note: in instantiation of member function 'ewah::EWAHBoolArray<unsigned long>::numberOfOnes' requested here
  __pyx_v_nc = (__pyx_v_coll_refn[0]).numberOfOnes();
                                      ^
yt/utilities/lib/ewahboolarray/ewahutil.h:155:17: note: candidate function
inline uint32_t countOnes(uint32_t x) {
                ^
yt/utilities/lib/ewahboolarray/ewahutil.h:173:17: note: candidate function
inline uint32_t countOnes(uint64_t x) {
                ^
yt/utilities/lib/ewahboolarray/ewahutil.h:189:17: note: candidate function
inline uint32_t countOnes(uint16_t v) {
                ^
In file included from yt/utilities/lib/ewah_bool_wrap.cpp:684:
In file included from yt/utilities/lib/ewahboolarray/ewah.h:710:
yt/utilities/lib/ewahboolarray/ewah-inl.h:216:34: error: call to 'countOnes' is ambiguous
      answer = literalPosition + countOnes((uword)(t - 1));
                                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewah-inl.h:164:9: note: in instantiation of member function 'ewah::EWAHBoolArraySetBitForwardIterator<unsigned long>::next' requested here
        next();
        ^
yt/utilities/lib/ewahboolarray/ewah.h:176:12: note: in instantiation of member function 'ewah::EWAHBoolArraySetBitForwardIterator<unsigned long>::EWAHBoolArraySetBitForwardIterator' requested here
    return EWAHBoolArraySetBitForwardIterator<uword>(&buffer);
           ^
yt/utilities/lib/ewah_bool_wrap.cpp:6658:114: note: in instantiation of member function 'ewah::EWAHBoolArray<unsigned long>::begin' requested here
  __pyx_v_iter_set = new __pyx_t_2yt_9utilities_3lib_15ewah_bool_array_ewah_bool_iterator((__pyx_v_ewah_keys[0]).begin());
                                                                                                               ^

Log: http://beefy17.nyi.freebsd.org/data/main-i386-default/pa8720dde236b_seba8e643b1/logs/py38-yt-4.0.1.log (IPv6 URL)

OS: FreeBSD 13

@matthewturk
Copy link
Member

@yurivict thank you for this! I appreciate the bug reports. I'm not sure I can build it here without installing FreeBSD, which is probably what I ought to do.

I will note that we've also run into issues with some strangeness in how the EWAH code compiles with MSVC++, too, and I will check to see if there's any overlap in the issues.

@neutrinoceros neutrinoceros changed the title 4.0.1 fails on i386 systems: call to 'countOnes' is ambiguous BLD: 4.0.1 fails on i386 systems: call to 'countOnes' is ambiguous Oct 18, 2021
@cphyc
Copy link
Member

cphyc commented Oct 18, 2021

This issue is not specific to FreeBSD but to the i386 platform. I can reproduce it with the following steps on Linux (x86-64!):

export CONDA_FORCE_32BIT=1
export CFLAGS=-m32
conda create -n py37_32 python=3.7
conda activate py37_32
pip install cython numpy
python setup.py develop

This fails with the following traceback (abridged)

gcc -pthread -B /home/ccc/anaconda3/envs/py37_32/compiler_compat -Wl,--sysroot=/ -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -m32 -fPIC -Iyt/utilities/lib/ -Iyt/utilities/lib/ewahboolarray/ -I/home/ccc/anaconda3/envs/py37_32/include/python3.7m -I/home/ccc/anaconda3/envs/py37_32/lib/python3.7/site-packages/numpy/core/include -c yt/geometry/particle_oct_container.cpp -o build/temp.linux-x86_64-3.7/yt/geometry/particle_oct_container.o -std=c++14
cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/ccc/anaconda3/envs/py37_32/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1969,
                 from /home/ccc/anaconda3/envs/py37_32/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /home/ccc/anaconda3/envs/py37_32/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from yt/geometry/particle_oct_container.cpp:690:
/home/ccc/anaconda3/envs/py37_32/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
yt/geometry/particle_oct_container.cpp: In function ‘PyObject* __pyx_pf_2yt_8geometry_22particle_oct_container_14ParticleBitmap_78construct_octree(__pyx_obj_2yt_8geometry_22particle_oct_container_ParticleBitmap*, PyObject*, PyObject*, PyObject*, PyObject*, __pyx_obj_2yt_9utilities_3lib_14ewah_bool_wrap_BoolArrayCollection*, __pyx_obj_2yt_9utilities_3lib_14ewah_bool_wrap_BoolArrayCollection*)’:
yt/geometry/particle_oct_container.cpp:29323:39: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_uint64_t’ {aka ‘long long unsigned int’} and ‘npy_intp’ {aka ‘int’} [-Wsign-compare]
29323 |         for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_24; __pyx_t_1+=1) {
      |                             ~~~~~~~~~~^~~~~~~~~~~~
yt/geometry/particle_oct_container.cpp:29511:39: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_uint64_t’ {aka ‘long long unsigned int’} and ‘npy_intp’ {aka ‘int’} [-Wsign-compare]
29511 |         for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_24; __pyx_t_1+=1) {
      |                             ~~~~~~~~~~^~~~~~~~~~~~
yt/geometry/particle_oct_container.cpp: In function ‘void __pyx_f_2yt_8geometry_22particle_oct_container_22ParticleBitmapSelector_set_files_neighbors_refined(__pyx_obj_2yt_8geometry_22particle_oct_container_ParticleBitmapSelector*, __pyx_t_5numpy_uint64_t, __pyx_t_5numpy_uint64_t)’:
yt/geometry/particle_oct_container.cpp:34664:37: warning: comparison of integer expressions of different signedness: ‘int’ and ‘__pyx_t_5numpy_uint32_t’ {aka ‘long unsigned int’} [-Wsign-compare]
34664 |       for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      |                           ~~~~~~~~~~^~~~~~~~~~~
yt/geometry/particle_oct_container.cpp:34740:37: warning: comparison of integer expressions of different signedness: ‘int’ and ‘__pyx_t_5numpy_uint32_t’ {aka ‘long unsigned int’} [-Wsign-compare]
34740 |       for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      |                           ~~~~~~~~~~^~~~~~~~~~~
yt/geometry/particle_oct_container.cpp: In function ‘PyObject* __pyx_pf_2yt_8geometry_22particle_oct_container_29ParticleBitmapOctreeContainer_4finalize(__pyx_obj_2yt_8geometry_22particle_oct_container_ParticleBitmapOctreeContainer*)’:
yt/geometry/particle_oct_container.cpp:37368:103: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int64_t’ {aka ‘long long int’} and ‘__pyx_t_5numpy_uint64_t’ {aka ‘long long unsigned int’} [-Wsign-compare]
37368 |     if (unlikely(!((((__pyx_v_visitor->__pyx_base.global_index + 1) * __pyx_v_visitor->__pyx_base.nz) == __pyx_v_visitor->__pyx_base.index) != 0))) {
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yt/geometry/particle_oct_container.cpp:892:43: note: in definition of macro ‘unlikely’
  892 |   #define unlikely(x) __builtin_expect(!!(x), 0)
      |                                           ^
yt/geometry/particle_oct_container.cpp: In function ‘void __pyx_f_2yt_8geometry_22particle_oct_container_29ParticleBitmapOctreeContainer_recursive_add(__pyx_obj_2yt_8geometry_22particle_oct_container_ParticleBitmapOctreeContainer*, __pyx_t_2yt_8geometry_12oct_visitors_Oct*, PyArrayObject*, int, int*, int, int*)’:
yt/geometry/particle_oct_container.cpp:38721:35: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int64_t’ {aka ‘long long int’} and ‘__pyx_t_5numpy_uint64_t’ {aka ‘long long unsigned int’} [-Wsign-compare]
38721 |       __pyx_t_6 = ((__pyx_v_index == ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint64_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_indices.diminfo[0].strides)) >> ((__pyx_v_2yt_8geometry_13oct_container_ORDER_MAX - __pyx_v_level) * 3))) != 0);
      |                     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yt/geometry/particle_oct_container.cpp: In function ‘PyObject* __pyx_pf_2yt_8geometry_22particle_oct_container_29ParticleBitmapOctreeContainer_10add(__pyx_obj_2yt_8geometry_22particle_oct_container_ParticleBitmapOctreeContainer*, PyArrayObject*, __pyx_t_5numpy_uint64_t, int)’:
yt/geometry/particle_oct_container.cpp:39233:35: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int64_t’ {aka ‘long long int’} and ‘__pyx_t_5numpy_uint64_t’ {aka ‘long long unsigned int’} [-Wsign-compare]
39233 |       __pyx_t_4 = ((__pyx_v_index == ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint64_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_indices.diminfo[0].strides)) >> ((__pyx_v_2yt_8geometry_13oct_container_ORDER_MAX - __pyx_v_self->__pyx_base.__pyx_base.level_offset) * 3))) != 0);
      |                     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/ewah.h:16,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/boolarray.h: In instantiation of ‘size_t ewah::BoolArray<uword>::numberOfOnes() const [with uword = long unsigned int; size_t = unsigned int]’:
yt/geometry/particle_oct_container.cpp:19290:45:   required from here
yt/utilities/lib/ewahboolarray/boolarray.h:347:25: error: call of overloaded ‘countOnes(const value_type&)’ is ambiguous
  347 |       count += countOnes(buffer[i]);
      |                ~~~~~~~~~^~~~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/boolarray.h:18,
                 from yt/utilities/lib/ewahboolarray/ewah.h:16,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/ewahutil.h:155:17: note: candidate: ‘uint32_t ewah::countOnes(uint32_t)’
  155 | inline uint32_t countOnes(uint32_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:173:17: note: candidate: ‘uint32_t ewah::countOnes(uint64_t)’
  173 | inline uint32_t countOnes(uint64_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:189:17: note: candidate: ‘uint32_t ewah::countOnes(uint16_t)’
  189 | inline uint32_t countOnes(uint16_t v) {
      |                 ^~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/ewah.h:710,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/ewah-inl.h: In instantiation of ‘size_t ewah::EWAHBoolArray<uword>::numberOfOnes() const [with uword = long unsigned int; size_t = unsigned int]’:
yt/geometry/particle_oct_container.cpp:24088:63:   required from here
yt/utilities/lib/ewahboolarray/ewah-inl.h:374:23: error: call of overloaded ‘countOnes(__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type)’ is ambiguous
  374 |       tot += countOnes((uword)buffer[pointer]);
      |              ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/boolarray.h:18,
                 from yt/utilities/lib/ewahboolarray/ewah.h:16,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/ewahutil.h:155:17: note: candidate: ‘uint32_t ewah::countOnes(uint32_t)’
  155 | inline uint32_t countOnes(uint32_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:173:17: note: candidate: ‘uint32_t ewah::countOnes(uint64_t)’
  173 | inline uint32_t countOnes(uint64_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:189:17: note: candidate: ‘uint32_t ewah::countOnes(uint16_t)’
  189 | inline uint32_t countOnes(uint16_t v) {
      |                 ^~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/ewah.h:710,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/ewah-inl.h: In instantiation of ‘void ewah::EWAHBoolArraySetBitForwardIterator<uword>::next() [with uword = long unsigned int]’:
yt/utilities/lib/ewahboolarray/ewah-inl.h:125:7:   required from ‘ewah::EWAHBoolArraySetBitForwardIterator<uword>& ewah::EWAHBoolArraySetBitForwardIterator<uword>::operator++() [with uword = long unsigned int]’
yt/geometry/particle_oct_container.cpp:9639:35:   required from here
yt/utilities/lib/ewahboolarray/ewah-inl.h:216:43: error: call of overloaded ‘countOnes(long unsigned int)’ is ambiguous
  216 |       answer = literalPosition + countOnes((uword)(t - 1));
      |                                  ~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from yt/utilities/lib/ewahboolarray/boolarray.h:18,
                 from yt/utilities/lib/ewahboolarray/ewah.h:16,
                 from yt/geometry/particle_oct_container.cpp:687:
yt/utilities/lib/ewahboolarray/ewahutil.h:155:17: note: candidate: ‘uint32_t ewah::countOnes(uint32_t)’
  155 | inline uint32_t countOnes(uint32_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:173:17: note: candidate: ‘uint32_t ewah::countOnes(uint64_t)’
  173 | inline uint32_t countOnes(uint64_t x) {
      |                 ^~~~~~~~~
yt/utilities/lib/ewahboolarray/ewahutil.h:189:17: note: candidate: ‘uint32_t ewah::countOnes(uint16_t)’
  189 | inline uint32_t countOnes(uint16_t v) {
      |                 ^~~~~~~~~
While building 'yt.geometry.particle_oct_container' following error was raised:
 command 'gcc' failed with exit status 1
error: command 'gcc' failed with exit status 1

OS: Arch Linux
System: x86-64
GCC: 11.1 (also tested with GCC 5.5.0)

@cphyc
Copy link
Member

cphyc commented Oct 18, 2021

Seems to be fixed with this patch

diff --git a/yt/utilities/lib/ewahboolarray/boolarray.h b/yt/utilities/lib/ewahboolarray/boolarray.h
index 822d576b4..e67f91bae 100644
--- a/yt/utilities/lib/ewahboolarray/boolarray.h
+++ b/yt/utilities/lib/ewahboolarray/boolarray.h
@@ -17,6 +17,13 @@
 
 #include "ewahutil.h"
 
+
+#if ((ULONG_MAX) == (UINT_MAX))
+#define UWORD uint32_t
+#else
+#define UWORD uint64_t
+#endif
+
 namespace ewah {
 /**
  * A dynamic bitset implementation. (without compression).
@@ -344,7 +351,7 @@ public:
   size_t numberOfOnes() const {
     size_t count = 0;
     for (size_t i = 0; i < buffer.size(); ++i) {
-      count += countOnes(buffer[i]);
+      count += countOnes((UWORD)buffer[i]);
     }
     return count;
   }
diff --git a/yt/utilities/lib/ewahboolarray/ewah-inl.h b/yt/utilities/lib/ewahboolarray/ewah-inl.h
index 6176c5e15..5b6e0f281 100644
--- a/yt/utilities/lib/ewahboolarray/ewah-inl.h
+++ b/yt/utilities/lib/ewahboolarray/ewah-inl.h
@@ -3,6 +3,12 @@
 
 #include "ewah.h"
 
+#if ((ULONG_MAX) == (UINT_MAX))
+#define UWORD uint32_t
+#else
+#define UWORD uint64_t
+#endif
+
 namespace ewah {
 
 /**
@@ -213,7 +219,7 @@ public:
         return;
     } else {
       uword t = static_cast<uword>(word & (~word + 1));
-      answer = literalPosition + countOnes((uword)(t - 1));
+      answer = literalPosition + countOnes((UWORD)(t - 1));
       word ^= t;
     }
     hasNext = moveToNext();
@@ -371,7 +377,7 @@ template <class uword> size_t EWAHBoolArray<uword>::numberOfOnes() const {
     }
     ++pointer;
     for (size_t k = 0; k < rlw.getNumberOfLiteralWords(); ++k) {
-      tot += countOnes((uword)buffer[pointer]);
+      tot += countOnes((UWORD)buffer[pointer]);
       ++pointer;
     }
   }

Can anyone confirm?

@neutrinoceros
Copy link
Member

@cphyc I assume the answer-store being included in your patch is a mistake ?

@neutrinoceros neutrinoceros added this to the 4.0.2 milestone Oct 18, 2021
@neutrinoceros
Copy link
Member

I'm adding this to the 4.0.2 milestone to make sure this is discussed before the bug fix release

@cphyc
Copy link
Member

cphyc commented Oct 19, 2021

@cphyc I assume the answer-store being included in your patch is a mistake ?

Correct. I'm amending my patch to remove the answer-store update.

@neutrinoceros neutrinoceros added the build related to the build process label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build related to the build process
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants