Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ jobs:
run: |
for n in 1 2 4; do
NANOMPI_NUM_RANKS=$n ./build/tests/bench_spmd 32 CPUHybrid | tee -a bench.txt
NANOMPI_NUM_RANKS=$n ./build/tests/bench_spmd 32 Hypre | tee -a bench.txt
done
# every run must have converged
awk '{ for (i = 1; i <= NF; i++) if ($i ~ /^relres=/) {
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ if(POLYSOLVE_WITH_HYPRE)
if(HYPRE_ENABLE_MPI)
target_compile_definitions(polysolve_linear PUBLIC HYPRE_ENABLE_MPI)
endif()
# hypre is built with CUDA whenever polysolve is (see the hypre recipe), which
# lets the Hypre solver run on the GPU when its "use_gpu" option is set.
if(POLYSOLVE_WITH_CUDA)
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_HYPRE_GPU)
endif()
endif()

# CHOLMOD solver
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ Polysolve uses a json file to provide parameters to the individual solvers. The
#### Hypre Only

- `pre_max_iter`, number of pre iterations, default `1`
- `use_gpu`, solve on the GPU (the current CUDA device, as a single rank), default `false`. Needs `POLYSOLVE_WITH_CUDA=ON`.

When built with `POLYSOLVE_WITH_MPI=ON`, Hypre splits the rows across [nano-mpi](https://github.com/danielepanozzo/nano-mpi) ranks, which are threads of the calling process, so no `mpirun` is needed. `NANOMPI_NUM_RANKS` sets the number of ranks; the default is the number of cores.

#### AMGCL Only

Expand Down
13 changes: 10 additions & 3 deletions cmake/recipes/hypre.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ endif()
# hypre is built as an ordinary MPI build. What is different is the MPI: with
# POLYSOLVE_WITH_MPI on, the nanompi recipe has already put a FindMPI shim on the
# module path, so hypre's own find_package(MPI REQUIRED) resolves to nano-mpi --
# whose ranks are threads of this process. hypre itself needs no special mode.
# whose ranks are threads of this process.
#
# Because the ranks are threads, hypre's process-wide state (its handle, error
# flag, random seed, ...) must be per thread, or the ranks race on it.
# HYPRE_ENABLE_THREAD_LOCAL does that. It means every thread that calls hypre
# runs HYPRE_Initialize() itself, which the solvers do.
if (POLYSOLVE_WITH_MPI)
include(nanompi)
set(HYPRE_ENABLE_MPI ON CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_MPI ON CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_THREAD_LOCAL ON CACHE INTERNAL "" FORCE)
else()
set(HYPRE_ENABLE_MPI OFF CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_MPI OFF CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_THREAD_LOCAL OFF CACHE INTERNAL "" FORCE)
endif()

# HYPRE unconditionally defines an "uninstall" target, which conflicts with other buggy libraries
Expand Down
11 changes: 9 additions & 2 deletions linear-solver-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@
"tolerance",
"theta",
"nodal_coarsening",
"interp_rbms"
"interp_rbms",
"use_gpu"
],
"doc": "Settings for the Hypre solver."
"doc": "Settings for the Hypre solver. On the CPU, when built with MPI, the rows are split across the nano-mpi ranks (threads of this process); NANOMPI_NUM_RANKS sets how many, and the default is the number of cores."
},
{
"pointer": "/AMGCL",
Expand Down Expand Up @@ -287,6 +288,12 @@
"type": "bool",
"doc": "Whether or not to include nodal coarsening options."
},
{
"pointer": "/Hypre/use_gpu",
"default": false,
"type": "bool",
"doc": "Solve on the GPU: the current CUDA device, as a single rank. Needs POLYSOLVE_WITH_CUDA=ON."
},
{
"pointer": "/AMGCL/solver",
"default": null,
Expand Down
7 changes: 7 additions & 0 deletions src/polysolve/linear/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ if(POLYSOLVE_WITH_CUDA)
)
endif()

if(POLYSOLVE_WITH_MPI)
list(APPEND SOURCES
mpi_utils/RankTeam.cpp
mpi_utils/RankTeam.hpp
)
endif()

if(POLYSOLVE_WITH_MPI AND NOT POLYSOLVE_LARGE_INDEX)
list(APPEND SOURCES
CPUHybridSolver.cpp
Expand Down
Loading
Loading