kokkos / kokkos-kernels

Kokkos C++ Performance Portability Programming Ecosystem: Math Kernels - Provides BLAS, Sparse BLAS and Graph Kernels
Other
304 stars 96 forks source link

Nightly build errors: gcc/7.3.0 w/c++17, OpenMP build with blas tpl enabled: KokkosBlas3_gemm_impl.hpp:552:7: sorry, unimplemented: unexpected AST of kind omp_simd #1487

Closed ndellingwood closed 1 year ago

ndellingwood commented 2 years ago

Nightly gcc/7.3.0 OpenMP builds with c++17 enabled and BLAS tpls enabled are failing to compile with error message:

07:03:35 /home/jenkins/jenkins-new/workspace/KokkosKernels_KokkosDev2_SPOTCHECK_TPLS-gcc/kokkos-kernels/src/blas/impl/KokkosBlas3_gemm_impl.hpp: In lambda function:
07:03:35 /home/jenkins/jenkins-new/workspace/KokkosKernels_KokkosDev2_SPOTCHECK_TPLS-gcc/kokkos-kernels/src/blas/impl/KokkosBlas3_gemm_impl.hpp:552:7: sorry, unimplemented: unexpected AST of kind omp_simd
07:03:35        });
07:03:35        ^
07:03:35 /home/jenkins/jenkins-new/workspace/KokkosKernels_KokkosDev2_SPOTCHECK_TPLS-gcc/kokkos-kernels/src/blas/impl/KokkosBlas3_gemm_impl.hpp:552: confused by earlier errors, bailing out
07:03:35 make[2]: *** [src/CMakeFiles/kokkoskernels.dir/impl/generated_specializations_cpp/gemm/Blas3_gemm_eti_DOUBLE_LAYOUTLEFT_EXECSPACE_OPENMP_MEMSPACE_HOSTSPACE.cpp.o] Error 1
07:03:35 make[2]: *** Waiting for unfinished jobs....

Reproducer:

source /projects/sems/modulefiles/utils/sems-archive-modules-init.sh
module load sems-archive-env sems-archive-cmake/3.17.1 sems-archive-gcc/7.3.0

$KOKKOSKERNELS_PATH/cm_generate_makefile.bash --with-devices=OpenMP --arch=SNB --compiler=g++ --cxxflags="-O3 -Wall -Wunused-parameter -Wshadow -pedantic -Werror -Wsign-compare -Wtype-limits -Wignored-qualifiers -Wempty-body -Wclobbered -Wuninitialized " --cxxstandard="17" --kokkos-path=$KOKKOS_PATH --kokkoskernels-path=$KOKKOSKERNELS_PATH --with-scalars='double,complex_double' --with-ordinals=int --with-offsets=int,size_t --with-layouts=LayoutLeft --with-tpls=blas --no-examples 

My guess is the CXX14 guard here https://github.com/kokkos/kokkos-kernels/blob/42ab7a29f33df64406ec5d7eae5c39926598ec33/src/blas/impl/KokkosBlas3_gemm_impl.hpp#L51 should guard for c++17 as well (iirc we didn't test or fully support c++17 at the time that workaround was added, the only known problematic case was guarded), so if we add an additional check for KOKKOS_ENABLE_CXX17 then things will pass. I'll test this out and if successful put in a PR if no alternative fix/workaround is suggested

ndellingwood commented 2 years ago

I identified the wrong guarded macro above that triggered the errors; this change allowed me to compile:

diff --git a/src/KokkosKernels_Macros.hpp b/src/KokkosKernels_Macros.hpp
index 1630028c..7cc56ca7 100644
--- a/src/KokkosKernels_Macros.hpp
+++ b/src/KokkosKernels_Macros.hpp
@@ -68,7 +68,8 @@
 // GCC 4.8.5 and older do not support #pragma omp simd
 // Do not enable when using GCC 7.2.0 + C++17 due to a bug in gcc
 #if (KOKKOS_COMPILER_GNU > 485) && \
-    !(KOKKOS_COMPILER_GNU == 720 && defined(KOKKOS_ENABLE_CXX17))
+    !(KOKKOS_COMPILER_GNU == 720 && defined(KOKKOS_ENABLE_CXX17)) && \
+    !(KOKKOS_COMPILER_GNU == 730 && defined(KOKKOS_ENABLE_CXX17))
 #define KOKKOSKERNELS_ENABLE_OMP_SIMD
 #endif
 // TODO: Check for a clang version that supports #pragma omp simd

Apparently the bug referring to gcc/7.2.0 is also present with gcc/7.3.0...

I'll put in a PR with the small change

ndellingwood commented 2 years ago

Confirmed the build completes with gcc/8.3.0, 9.2.0 and c++17