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

Compile error: ambiguous "half" in KokkosSparse_spmv_bsrmatrix_spec on Ampere GPU architecture #2189

Open
michadavids opened this issue Apr 30, 2024 · 0 comments

Comments

@michadavids
Copy link

I am attempting to build Trilinos and Kokkos in order to run simulations on our local compute cluster.
For this purpose, I'm targeting the CUDA backend for the Ampere 80 GPU architecture.
I can compile Trilinos and Kokkos just fine as a stand-alone library, but when I try to build my simulation program against Trilinos/Kokkos the compilation fails with the following message(s):

($HOME)/projects/trilinos/trilinos-installation-15-1-1/include/KokkosSparse_spmv_bsrmatrix_spec.hpp(260): error: "half" is ambiguous
                     BsrMatrixSpMVTensorCoreDispatcher<ExecutionSpace, AMatrix, half,
                                                                                ^
($HOME)/projects/trilinos/trilinos-installation-15-1-1/include/KokkosSparse_spmv_bsrmatrix_spec.hpp(261): error: "half" is ambiguous
                                                          XVector, half, YVector, float, 16,
                                                                   ^
($HOME)/projects/trilinos/trilinos-installation-15-1-1/include/KokkosSparse_spmv_bsrmatrix_spec.hpp(281): error: "half" is ambiguous
                    ExecutionSpace, AMatrix, half, XVector, half, YVector, float,
                                             ^
($HOME)/projects/trilinos/trilinos-installation-15-1-1/include/KokkosSparse_spmv_bsrmatrix_spec.hpp(281): error: "half" is ambiguous
                    ExecutionSpace, AMatrix, half, XVector, half, YVector, float,
                                                            ^

I'm unsure if the half scalar type is something I have to define myself first, or if it should already be defined elsewhere. Scrolling up a few lines, there is the following typedef:

typedef Kokkos::Experimental::half_t Half;

However, this typedef only specifies Half and not half, so it might be a typo? Either way, by exchanging half for Half my compilation problem is resolved. Is this a correct approach to take?

For context, these are the settings used for configuring Trilinos (and Kokkos):

mkdir build
cd build
export OMPI_CXX="$HOME/projects/trilinos/trilinos-git/packages/kokkos/bin/nvcc_wrapper"
cmake ..\
    -G Ninja \
    -DCMAKE_CXX_COMPILER=mpic++ \
    -DCMAKE_C_COMPILER=mpicc \
    -DCMAKE_Fortran_COMPILER=gfortran \
    -DTrilinos_USE_GNUINSTALLDIRS=TRUE \
    -DTrilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=ON \
    -DBUILD_SHARED_LIBS:BOOL=ON \
    -DBLAS_LIBRARY_NAMES="openblas" \
    -DLAPACK_LIBRARY_NAMES="scalapack" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_CXX_EXTENSIONS=OFF \
    -DCMAKE_CXX_FLAGS_RELEASE_OVERRIDE="-std=c++17 -O3 -funroll-loops" \
    -DCMAKE_C_FLAGS_RELEASE_OVERRIDE="-O3 -funroll-loops" \
    -DCMAKE_Fortran_FLAGS_RELEASE_OVERRIDE="-O5 -funroll-all-loops -malign-double" \
    -DTrilinos_ENABLE_CXX11=ON \
    -DTPL_ENABLE_MPI=ON \
    -DTPL_ENABLE_CUDA=ON \
    -DTPL_ENABLE_gtest=OFF \
    -DTrilinos_ENABLE_Gtest=OFF \
    -DTrilinos_ENABLE_Tpetra=ON \
    -DTrilinos_ENABLE_Xpetra=ON \
    -DTrilinos_ENABLE_Belos=ON \
    -DTrilinos_ENABLE_Kokkos=ON \
    -DTrilinos_ENABLE_Ifpack2=ON \
    -DTrilinos_ENABLE_Zoltan2=ON \
    -DTrilinos_ENABLE_Teuchos=ON \
    -DTrilinos_ENABLE_MueLu=ON \
    -DTpetra_INST_SERIAL=ON \
    -DTpetra_INST_CUDA=ON \
    -DTpetra_ASSUME_GPU_AWARE_MPI=ON \
    -DKokkos_ENABLE_CUDA=ON \
    -DKokkos_ARCH_AMPERE80=ON \
    -DMueLu_ENABLE_Tutorial=OFF \
    -DTrilinos_SHOW_DEPRECATED_WARNINGS=OFF \
    -DTrilinos_HIDE_DEPRECATED_CODE=ON \
    -DCMAKE_INSTALL_PREFIX="$HOME/projects/trilinos/trilinos-installation-15-1-1"

I am using the nvcc compiler from CUDA v.12.1.1 and GCC v.12.3.0.
The Trilinos version I am compiling for is v.15.1.1, which appears to be using Kokkos v.4.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant