Fix AVX512 build with older compilers
authormstembera <MissingEmail@email>
Mon, 10 Aug 2020 19:52:46 +0000 (12:52 -0700)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Tue, 11 Aug 2020 06:17:03 +0000 (08:17 +0200)
avoids an intrinsic that is missing in gcc < 10.

For this target, might trigger another gcc bug on windows that
requires up-to-date gcc 8, 9, or 10, or usage of clang.

Fixes https://github.com/official-stockfish/Stockfish/issues/2975

closes https://github.com/official-stockfish/Stockfish/pull/2976

No functional change

src/Makefile
src/nnue/layers/affine_transform.h

index fd2618a47b276de1cfbf902af607e41e49db1b14..e34fbf615e1924f23ff26c8fdd39a3b456d1ab05 100644 (file)
@@ -416,7 +416,7 @@ endif
 ifeq ($(avx512),yes)
        CXXFLAGS += -DUSE_AVX512
        ifeq ($(comp),$(filter $(comp),gcc clang mingw))
-               CXXFLAGS += -mavx512bw
+               CXXFLAGS += -mavx512f -mavx512bw
        endif
 endif
 
index 985ee71a4193e571f9ecdddfc144ca4c2c571aea..8d2acd1852eabfa9dce873b803040742a2da75f9 100644 (file)
@@ -126,8 +126,7 @@ namespace Eval::NNUE::Layers {
             const auto iv256  = reinterpret_cast<const __m256i*>(&input_vector[kNumChunks]);
             const auto row256 = reinterpret_cast<const __m256i*>(&row[kNumChunks]);
             __m256i product256 = _mm256_maddubs_epi16(_mm256_loadA_si256(&iv256[0]), _mm256_load_si256(&row256[0]));
-            product256 = _mm256_madd_epi16(product256, _mm256_set1_epi16(1));
-            sum = _mm512_add_epi32(sum, _mm512_zextsi256_si512(product256));
+            sum = _mm512_add_epi32(sum, _mm512_cvtepi16_epi32(product256));
         }
         output[i] = _mm512_reduce_add_epi32(sum) + biases_[i];