Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricchevalier19 authored Apr 13, 2023
2 parents aa2b050 + fea96bd commit 43f83b7
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CMake

on:
push:
branches: [ main ]
branches: [ develop ]
pull_request:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Documentation

on:
push:
branches: [ main ]
branches: [ develop ]
pull_request:
branches: [ main ]
branches: [ develop ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Clang Format Checker
on:
pull_request:
branches: [ main ]
branches: [ develop ]
push:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

jobs:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ifpen_devenv_2021b.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: IFPEN devenv 2021b

on:
push:
branches: [ develop ]
workflow_dispatch:

env:
Expand Down Expand Up @@ -46,7 +48,7 @@ env:
CT_OPTS: "--timeout 300 --output-on-failure"

jobs:
build :
build:
name: ${{matrix.config.name}}
runs-on: ubuntu-latest
timeout-minutes: 120
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ifpen_el7_foss-2018b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: IFPEN el7 foss/2018b

on:
push:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ifpen_el7_gimkl-2018b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: IFPEN el7 gimkl/2018b

on:
push:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ifpen_el8_foss-2018b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: IFPEN el8 foss/2018b

on:
push:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ifpen_el8_gimkl-2018b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: IFPEN el8 gimkl/2018b

on:
push:
branches: [ main ]
branches: [ develop ]
workflow_dispatch:

env:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

- \[move\]: parallel matrix-market reader
- \[hypre\]: improve AMG parameter choices, especially for GPU
- \[trilinos\]: use modern CMake Trilinos and support for GPU

**Fixed bugs:**

Expand Down
85 changes: 51 additions & 34 deletions plugins/trilinos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@ option(ALIEN_TRILINOS_UNIT_TESTS "Enable Trilinos wrapper tests" ${ALIEN_UNIT_TE

find_package(MPI REQUIRED)


# ----------------------------------------------------------------------------
find_package(Trilinos 13 REQUIRED COMPONENTS Teuchos Kokkos KokkosKernels Belos Tpetra Ifpack2)

# Echo trilinos build info just for fun
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
MESSAGE(" Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS}")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE("End of Trilinos details\n")

# Make sure to use same compilers and flags as Trilinos
#MESSAGE(" Trilinos_CXX_COMPILER_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")
string(REPLACE " " ";" Trilinos_CXX_COMPILER_FLAGS ${Trilinos_CXX_COMPILER_FLAGS})

# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------

add_library(trilinos_wrapper
Expand All @@ -46,26 +22,69 @@ add_library(trilinos_wrapper
src/trilinos_config.cpp
)

set_property(TARGET trilinos_wrapper
APPEND_STRING
PROPERTY
COMPILE_OPTIONS ${Trilinos_CXX_COMPILER_FLAGS}
)

target_link_libraries(trilinos_wrapper PUBLIC
Alien::alien_core
)

# ----------------------------------------------------------------------------
find_package(Trilinos 13 REQUIRED COMPONENTS Teuchos Kokkos KokkosKernels Belos Tpetra Ifpack2 MueLu)

if (NOT TARGET Trilinos::all_selected_libs)
# Newer versions of Trilinos should define this target.

# Echo trilinos build info just for fun
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
MESSAGE(" Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS}")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE("End of Trilinos details\n")

# Make sure to use same compilers and flags as Trilinos
#MESSAGE(" Trilinos_CXX_COMPILER_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")
string(REPLACE " " ";" Trilinos_CXX_COMPILER_FLAGS ${Trilinos_CXX_COMPILER_FLAGS})
add_library(Trilinos::all_selected_libs INTERFACE IMPORTED)
target_compile_options(Trilinos::all_selected_libs INTERFACE ${Trilinos_CXX_COMPILER_FLAGS})
target_include_directories(Trilinos::all_selected_libs INTERFACE ${Trilinos_INCLUDE_DIRS} ${TRILINOS_TPL_INCLUDE_DIRS})
target_link_libraries(Trilinos::all_selected_libs INTERFACE ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})

if (NOT TARGET Kokkos::kokkos)
add_library(Kokkos::kokkos INTERFACE IMPORTED)
else ()
# Debian and Ubuntu packaging is bugged, INTERFACE_INCLUDE_DIRECTORIES referencing a /usr/lib/include directory
get_target_property(KOKKOS_INC_DIRS Kokkos::kokkos INTERFACE_INCLUDE_DIRECTORIES)
set(NEW_KOKKOS_INC_DIRS)
foreach (INC_DIR ${KOKKOS_INC_DIRS})
MESSAGE(STATUS "INC_DIR = ${INC_DIR}")
if (EXISTS ${INC_DIR})
LIST(APPEND NEW_KOKKOS_INC_DIRS ${INC_DIR})
endif ()
endforeach ()
set_target_properties(Kokkos::kokkos PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${NEW_KOKKOS_INC_DIRS}")
endif ()
else ()
kokkos_compilation(TARGET trilinos_wrapper)
endif ()

# ----------------------------------------------------------------------------

target_link_libraries(trilinos_wrapper PRIVATE
MPI::MPI_CXX
Arccore::arccore_trace
Arccore::arccore_collections
Arccore::arccore_base
Arccore::arccore_message_passing_mpi
${Trilinos_LIBRARIES}
${Trilinos_TPL_LIBRARIES}
Trilinos::all_selected_libs Kokkos::kokkos
)


if (ALIEN_PLUGIN_TRILINOS_OMP)
message("------ COMPILING TRILINOS WRAPPER WITH *OPENMP* BACKEND ------- ")
elseif (ALIEN_PLUGIN_TRILINOS_CUDA)
Expand All @@ -91,8 +110,6 @@ target_include_directories(trilinos_wrapper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${Trilinos_INCLUDE_DIRS}
${Trilinos_TPL_INCLUDE_DIRS}
)

add_library(Alien::trilinos_wrapper ALIAS trilinos_wrapper)
Expand Down
3 changes: 3 additions & 0 deletions plugins/trilinos/examples/trilinos_example_solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ int main(int argc, char** argv)
else if (std::string(argv[2]) == "NoPC") {
prec = Alien::Trilinos::OptionTypes::NoPC;
}
else if (std::string(argv[2]) == "AMG") {
prec = Alien::Trilinos::OptionTypes::MueLu;
}
else {
std::cerr << "Unrecognized preconditioner : " << argv[2] << "\n"
<< " - preconditioner list : (Relaxation|NoPC) \n";
Expand Down
1 change: 1 addition & 0 deletions plugins/trilinos/include/alien/trilinos/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct OptionTypes

enum ePreconditioner
{
MueLu,
Relaxation,
NoPC
};
Expand Down
28 changes: 22 additions & 6 deletions plugins/trilinos/src/trilinos_linear_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@

#include "trilinos_linear_solver.h"

#include <Ifpack2_Factory.hpp>
#include <BelosBlockCGSolMgr.hpp>
#include <BelosBlockGmresSolMgr.hpp>
#include <BelosBiCGStabSolMgr.hpp>
#include <BelosSolverFactory_Tpetra.hpp>
#include <Tpetra_Operator.hpp>
#include <MueLu_CreateTpetraPreconditioner.hpp>

namespace Alien
{
// Compile TrilinosLinearSolver.
Expand All @@ -35,21 +43,29 @@ bool InternalLinearSolver::solve(const Matrix& A, const Vector& b, Vector& x)

// Create the linear problem instance.
Belos::LinearProblem<SC, MV, OP> problem(A.internal(), x.internal(), b.internal());
Teuchos::RCP<prec_type> M;

// Ifpack2 preconditioner.
// preconditioners.
switch (m_options.preconditioner()) {
case OptionTypes::MueLu: {
Teuchos::ParameterList paramList;
paramList.set("verbosity", "low");
paramList.set("max levels", 3);
paramList.set("coarse: max size", 10);
paramList.set("multigrid algorithm", "sa");
auto prec = MueLu::CreateTpetraPreconditioner(static_cast<Teuchos::RCP<OP>>(A.internal()), paramList);
problem.setLeftPrec(prec);
} break;
case OptionTypes::Relaxation: {
M = Ifpack2::Factory::create<row_matrix_type>("RELAXATION", A.internal());
auto M = Ifpack2::Factory::create<row_matrix_type>("RELAXATION", A.internal());
if (M.is_null()) {
std::cerr << "Failed to create Ifpack2 preconditioner !" << std::endl;
return -1;
}
M->initialize();
M->compute();
}
problem.setRightPrec(M);
break;

problem.setLeftPrec(M);
} break;
case OptionTypes::NoPC:
break;
default:
Expand Down
6 changes: 0 additions & 6 deletions plugins/trilinos/src/trilinos_linear_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
#include "trilinos_matrix.h"
#include "trilinos_vector.h"

#include <Ifpack2_Factory.hpp>
#include <BelosBlockCGSolMgr.hpp>
#include <BelosBlockGmresSolMgr.hpp>
#include <BelosBiCGStabSolMgr.hpp>
#include <BelosSolverFactory_Tpetra.hpp>

namespace Alien::Trilinos
{
class InternalLinearSolver : public IInternalLinearSolver<Matrix, Vector>
Expand Down

0 comments on commit 43f83b7

Please sign in to comment.