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

The gcc-12 build is failing due to FbgemmSparseDenseInt8Avx2. : ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized] #1666

Closed
jayagami opened this issue Mar 27, 2023 · 4 comments

Comments

@jayagami
Copy link

jayagami commented Mar 27, 2023

Failed with gcc12, passed with gcc11

Error:


[  9%] Building CXX object CMakeFiles/fbgemm_avx2.dir/src/FbgemmI8DepthwisePerChannelQuantAvx2.cc.o
[  9%] Building CXX object CMakeFiles/fbgemm_avx2.dir/src/FbgemmSparseDenseAvx2.cc.o
[  9%] Building CXX object CMakeFiles/fbgemm_avx2.dir/src/FbgemmSparseDenseInt8Avx2.cc.o
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/immintrin.h:47,
                 from /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:13:
In function ‘void _mm256_maskstore_epi32(int*, __m256i, __m256i)’,
    inlined from ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = true; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::TENSOR]’ at /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:193:35:
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/avx2intrin.h:1155:32: error: ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized]                                                                                                                            1155 |   __builtin_ia32_maskstored256 ((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc: In function ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = true; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::TENSOR]’:
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:168:19: note: ‘mask_int32_v’ was declared here
  168 |           __m256i mask_int32_v;
      |                   ^~~~~~~~~~~~
In function ‘void _mm256_maskstore_epi32(int*, __m256i, __m256i)’,                                                                                                                                                                                                                inlined from ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = true; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::OUT_CHANNEL]’ at /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:193:35:                                                                                                                                         /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/avx2intrin.h:1155:32: error: ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized]                                                                                                                            1155 |   __builtin_ia32_maskstored256 ((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc: In function ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = true; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::OUT_CHANNEL]’:
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:168:19: note: ‘mask_int32_v’ was declared here
  168 |           __m256i mask_int32_v;
      |                   ^~~~~~~~~~~~
In function ‘void _mm256_maskstore_epi32(int*, __m256i, __m256i)’,
    inlined from ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = false; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::TENSOR]’ at /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:193:35:
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/avx2intrin.h:1155:32: error: ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized]                                                                                                                            1155 |   __builtin_ia32_maskstored256 ((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc: In function ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = false; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::TENSOR]’:
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:168:19: note: ‘mask_int32_v’ was declared here
  168 |           __m256i mask_int32_v;
      |                   ^~~~~~~~~~~~
In function ‘void _mm256_maskstore_epi32(int*, __m256i, __m256i)’,
    inlined from ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = false; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::OUT_CHANNEL]’ at /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:193:35:
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include/avx2intrin.h:1155:32: error: ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized]                                                                                                                            1155 |   __builtin_ia32_maskstored256 ((__v8si *)__X, (__v8si)__M, (__v8si)__Y);                                                                                                                                                                                                   |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                              /home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc: In function ‘void fbgemm::internal::SparseDenseInt8MMAvx2(int, const std::unique_ptr<fbgemm::BCSRMatrix<> >&, const uint8_t*, int, int32_t*, uint8_t*, int, fbgemm::trRequantizationParams_t&, bool, int, int) [with bool FUSE_RELU = false; fbgemm::QuantizationGranularity Q_GRAN = fbgemm::QuantizationGranularity::OUT_CHANNEL]’:
/home/git/FBGEMM/src/FbgemmSparseDenseInt8Avx2.cc:168:19: note: ‘mask_int32_v’ was declared here
  168 |           __m256i mask_int32_v;
      |                   ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/fbgemm_avx2.dir/build.make:174: CMakeFiles/fbgemm_avx2.dir/src/FbgemmSparseDenseInt8Avx2.cc.o] Error 1                                                                                                                                               make[1]: *** [CMakeFiles/Makefile2:368: CMakeFiles/fbgemm_avx2.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Env:

Linux ya 6.2.8-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Mar 22 21:14:50 UTC 2023 x86_64 GNU/Linux


Using built-in specs.
COLLECT_GCC=cpp
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.1 20230201 (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/cc1 -E -quiet -v - -mtune=generic -march=x86-64 -dumpbase -
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/include-fixed
 /usr/include
@jayagami jayagami changed the title build error while building FbgemmSparseDenseInt8Avx2 with gcc-2: ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized] gcc-12 build failling due to FbgemmSparseDenseInt8Avx2 : ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized] Mar 31, 2023
@jayagami jayagami changed the title gcc-12 build failling due to FbgemmSparseDenseInt8Avx2 : ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized] The gcc-12 build is failing due to FbgemmSparseDenseInt8Avx2. : ‘mask_int32_v’ may be used uninitialized [-Werror=maybe-uninitialized] Mar 31, 2023
@q10
Copy link
Contributor

q10 commented Apr 11, 2023

Hi @jayagami, thanks for reporting this issue!

Currently, our offiicial build instructions specify gcc 10, because it supports the lowest common denominator in terms of glibc and glibcxx versions on older Linux distributions (namely Ubuntu 20.04 and CentOS 7). Since these errors appear to be just uninitialized-variable errors, we will fix within the next few days (currently we are backlogged with other developments).

In the meantime, we recommend building inside a Conda environment, in which you can install a local version of gcc 10 (see our full build instructions here). Please let us know if you have any questions or concerns.

@q10
Copy link
Contributor

q10 commented Apr 12, 2023

This uninitialized variable issue is being addressed with #1697. However, this alone will not fix the build because there a known regression in GCC 12 (see here). To work around that, you will need to add the following to your environment prior to re-running CMake:

export CFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict"
export CXXFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict"

@jayagami
Copy link
Author

This uninitialized variable issue is being addressed with #1697. However, this alone will not fix the build because there a known regression in GCC 12 (see here). To work around that, you will need to add the following to your environment prior to re-running CMake:

export CFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict"
export CXXFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict"

Thanks, that's great to hear, it's not a serious problem, but I think it's better to report.
Maybe I should close it.

@q10
Copy link
Contributor

q10 commented Apr 20, 2023

Closing this issue, as we have added a note to the build instructions in the README, which should unblock users trying to build FBGEMM on gcc-12. Feel free to re-file a ticket if the issue is blocking your builds.

@q10 q10 closed this as completed Apr 20, 2023
markmc added a commit to markmc/FBGEMM that referenced this issue May 1, 2024
With recent gcc, fbgemm doesn't build with -Wmaybe-uninitialized and upstream
recommends building with -Wno-error=maybe-uninitialized

pytorch#1666
https://pytorch.org/FBGEMM/fbgemm-development/BuildInstructions.html

PyTorch itself uses -Wno-maybe-uninitialized but this doesn't get passed
through to fbgemm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants