Skip to content

Commit

Permalink
Fix Tpetra 64 bit global ordinate errors
Browse files Browse the repository at this point in the history
Tpetra requires long long as global ordinate type,
which does not always match with std::int64_t.
Therefore, configure stage fails with default Tpetra settings.

Changed signed_global_index_type in types.h to reflect this too.
Also added hopefully helpful CMake messages
in case the Tpetra check fails.
If it is global index related it will offer two ways
to make Tpetra usable in deal.II.
  • Loading branch information
jpthiele committed Sep 18, 2023
1 parent 4e1c906 commit 31bf623
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
40 changes: 38 additions & 2 deletions cmake/configure/configure_20_trilinos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ macro(feature_trilinos_find_external var)
add_flags(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_LINKER_FLAGS}")

if(DEAL_II_WITH_64BIT_INDICES)
set(_global_index_type "std::int64_t")
set(_global_index_type "long long")
else()
set(_global_index_type "int")
endif()
Expand Down Expand Up @@ -272,9 +272,45 @@ macro(feature_trilinos_find_external var)
else()
message(
STATUS
"Tpetra was found but is not usable! Disabling Tpetra support."
"Tpetra was found but is not usable! Disabling Tpetra support and searching for common errors."
)
set(TRILINOS_WITH_TPETRA OFF)

check_cxx_symbol_exists(HAVE_TPETRA_INT_LONG_LONG "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INT_LONG_LONG)
check_cxx_symbol_exists(HAVE_TPETRA_INT_INT "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INT_INT)

if(DEAL_II_HAVE_TPETRA_INT_INT AND DEAL_II_WITH_64BIT_INDICES)
message(
STATUS
" Tpetra is installed with 32 bit global indices but you want to build deal.II with 64. "
)
message(
STATUS
" Either rebuild Trilinos with -DTPETRA_INST_INT_INT=OFF and -DTPETRA_INST_LONG_LONG=ON "
)
message(
STATUS
" or clean and reconfigure deal.II with -DDEAL_II_WITH_64_BIT_INDICES=OFF."
)
elseif(DEAL_II_HAVE_TPETRA_INT_LONG_LONG AND NOT DEAL_II_WITH_64BIT_INDICES)
message(
STATUS
" Tpetra is installed with 64 bit global indices but you want to build deal.II with 32. "
)
message(
STATUS
" Either rebuild Trilinos with -DTPETRA_INST_INT_INT=ON and -DTPETRA_INST_LONG_LONG=OFF "
)
message(
STATUS
" or clean and reconfigure deal.II with -DDEAL_II_WITH_64_BIT_INDICES=ON."
)
else()
message(
STATUS
" No supported global index configuration of Trilions found."
)
endif()
endif()
reset_cmake_required()
endif()
Expand Down
10 changes: 7 additions & 3 deletions include/deal.II/base/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ namespace types
#ifdef DEAL_II_WITH_64BIT_INDICES
using global_dof_index = std::uint64_t;
#else
using global_dof_index = unsigned int;
using global_dof_index = unsigned int;
#endif

/**
* Signed version of global_dof_index.
* This is useful for interacting with Trilinos' Tpetra that only works well
* with a signed global ordinal type.
*/
using signed_global_dof_index = std::make_signed_t<global_dof_index>;
#ifdef DEAL_II_WITH_64BIT_INDICES
using signed_global_dof_index = long long;
#else
using signed_global_dof_index = int;
#endif

/**
* An identifier that denotes the MPI type associated with
Expand Down Expand Up @@ -115,7 +119,7 @@ namespace types
#ifdef DEAL_II_WITH_64BIT_INDICES
using global_cell_index = std::uint64_t;
#else
using global_cell_index = unsigned int;
using global_cell_index = unsigned int;
#endif

/**
Expand Down

0 comments on commit 31bf623

Please sign in to comment.