trilinos / Trilinos

Primary repository for the Trilinos Project
https://trilinos.org/
Other
1.19k stars 565 forks source link

Amesos2 KLU2 does not build with -DTeuchos_ENABLE_COMPLEX:BOOL=ON #1987

Closed hkthorn closed 6 years ago

hkthorn commented 6 years ago

@trilinos/amesos2 The Amesos2 KLU2 solver fails to build with complex arithmetic enabled. A very simple build of Amesos2 with KLU2 enabled, using this configure script:

cmake \ -DCMAKE_C_COMPILER=gcc-4 \ -DCMAKE_CXX_COMPILER=g++-4 \ -DCMAKE_Fortran_COMPILER=gfortran \ -D Trilinos_ENABLE_Amesos2:BOOL=ON \ -D Amesos2_ENABLE_KLU2:BOOL=ON \ -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=OFF \ -D Trilinos_ENABLE_Tpetra:BOOL=ON \ -D TPL_ENABLE_LAPACK:BOOL=ON \ -D TPL_ENABLE_BLAS:BOOL=ON \ -D Trilinos_ENABLE_COMPLEX:BOOL=ON \ -D Teuchos_ENABLE_COMPLEX:BOOL=ON \ -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -D CMAKE_BUILD_TYPE:STRING=DEBUG \ -D CMAKE_CXX_FLAGS="-Wall -D_GLIBCXX_DEBUG" \ -D Trilinos_ENABLE_EXAMPLES:BOOL=ON \ -D Trilinos_ENABLE_TESTS:BOOL=ON \ ../

Will result in a build error:

/Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_def.hpp: In instantiation of ‘int Amesos2::KLU2< , >::numericFactorization_impl() [with Matrix = Tpetra::CrsMatrix<std::complex, int, long long int, Kokkos::Compat::KokkosDeviceWrapperNode, false>; Vector = Tpetra::MultiVector<std::complex, int, long long int, Kokkos::Compat::KokkosDeviceWrapperNode >]’: /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_SolverCore_def.hpp:153:3: required from ‘Amesos2::Solver<Matrix, Vector>& Amesos2::SolverCore<ConcreteSolver, Matrix, Vector>::numericFactorization() [with ConcreteSolver = Amesos2::KLU2; Matrix = Tpetra::CrsMatrix<std::complex, int, long long int, Kokkos::Compat::KokkosDeviceWrapperNode, false>; Vector = Tpetra::MultiVector<std::complex, int, long long int, Kokkos::Compat::KokkosDeviceWrapperNode >]’ /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_registerLinearSolverFactory.cpp:102:1: required from here /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_def.hpp:247:45: error: no matching function for call to ‘klu_factor(int, int&, complex_type&, KLU2::klu_symbolic<std::complex, int>&, KLU2::klucommon<std::complex, int>*)’ data.symbolic, &(data.common_)) ; ^ /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_def.hpp:247:45: note: candidate is: In file included from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Include/klu2_internal.h:48:0, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Source/klu2_defaults.hpp:41, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_FunctionMap.hpp:68, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_decl.hpp:57, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2.hpp:47, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Factory.hpp:99, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_LinearSolverFactory_def.hpp:52, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_LinearSolverFactory.hpp:49, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_registerLinearSolverFactory.cpp:45: /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Include/klu2_version.h:79:20: note: template<class Entry, class Int> KLU2::klu_numeric<Entry, Int> KLU2::klu_factor(Int, Int, Entry, KLU2::klu_symbolic<Entry, Int>, KLU2::klu_common<Entry, Int>)

define KLU_factor klu_factor

                ^

/Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Source/klu2_factor.hpp:428:26: note: in expansion of macro ‘KLU_factor’ KLU_numeric<Entry, Int> KLU_factor / returns NULL if error, or a valid ^ /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Include/klu2_version.h:79:20: note: template argument deduction/substitution failed:

define KLU_factor klu_factor

                ^

/Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/KLU2/Source/klu2_factor.hpp:428:26: note: in expansion of macro ‘KLU_factor’ KLU_numeric<Entry, Int> KLU_factor / returns NULL if error, or a valid ^ In file included from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2.hpp:49:0, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Factory.hpp:99, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_LinearSolverFactory_def.hpp:52, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_LinearSolverFactory.hpp:49, from /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_Details_registerLinearSolverFactory.cpp:45: /Users/hkthorn/Trilinos/Trilinos/packages/amesos2/src/Amesos2_KLU2_def.hpp:247:45: note: cannot convert ‘sp_values’ (type ‘complextype {aka Kokkos::complex}’) to type ‘std::complex*’ data.symbolic, &(data.common_)) ; ^

ndellingwood commented 6 years ago

@hkthorn could you try adding these lines to the configure file: -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION:BOOL=ON \ -D Trilinos_ENABLE_Kokkos:BOOL=ON \

I did not guard something properly for Kokkos (optional dependency in Amesos2, not required) when dealing with the Kokkos vs std complex pointer issue for the optimized code path, will get this worked out. This adds a configuration combo I hadn't been testing, sorry I missed it!

prwolfe commented 6 years ago

@ndellingwood ,

Looking at this it is exactly the issue remaining after your fix for #1986. I will close that and track this one. I am not able to use the workaround you asked @hkthorn to use as we run both with and without explicit instantiation (currently - I would like to change that.)

Thanks!

ndellingwood commented 6 years ago

@prwolfe @hkthorn I think I have a fix for this issue, need to test with a few more configurations to make sure I'm not breaking something else then will get it pushed in.

ndellingwood commented 6 years ago

PR #2036 should resolve this issue, I'm assuming the auto-tester will pick it up to do the checkin testing...

ndellingwood commented 6 years ago

@prwolfe @hkthorn PR passed with the auto-tester and merged into develop branch. Let us know if this fixes the issue you are seeing.

prwolfe commented 6 years ago

This looks good. Thanks!

hkthorn commented 6 years ago

Looks good to me and it works!