Skip to content
Open
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
47 changes: 46 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ option(POLYSOLVE_WITH_UNICODE "Use Unicode in logging messages"
option(POLYSOLVE_WITH_CUDA "Enable cuda support" OFF)

# Polysolve options for enabling/disabling optional libraries
option(POLYSOLVE_WITH_MPI "Enable MPI support" OFF)
option(POLYSOLVE_WITH_ACCELERATE "Enable Apple Accelerate" ${POLYSOLVE_ON_APPLE_SILICON})
option(POLYSOLVE_WITH_CHOLMOD "Enable Cholmod library" ON)
option(POLYSOLVE_WITH_UMFPACK "Enable UmfPack library" ON)
Expand Down Expand Up @@ -169,6 +170,19 @@ if (POLYSOLVE_WITH_CUDA)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()

################################################################################
# MPI
################################################################################

# Check that MPI exists
if(POLYSOLVE_WITH_MPI)
find_package(MPI QUIET)
if (NOT MPI_CXX_FOUND)
message(WARNING "POLYSOLVE_WITH_MPI was requested but MPI was not found, proceeding without MPI dependent solvers.")
set(POLYSOLVE_WITH_MPI OFF)
endif()
endif()

################################################################################
# PolySolve Library
################################################################################
Expand Down Expand Up @@ -247,6 +261,21 @@ if(POLYSOLVE_WITH_CUDA)
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_CUDA)
endif()

if(POLYSOLVE_WITH_CUDA AND NOT POLYSOLVE_LARGE_INDEX)
target_compile_definitions(polysolve PUBLIC POLYSOLVE_WITH_CUDSS)
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_CUDSS)
endif()

if(POLYSOLVE_WITH_CUDA AND NOT POLYSOLVE_LARGE_INDEX)
target_compile_definitions(polysolve PUBLIC POLYSOLVE_WITH_GPU_HYBRID)
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_GPU_HYBRID)
endif()

if(POLYSOLVE_WITH_MPI AND NOT POLYSOLVE_LARGE_INDEX)
target_compile_definitions(polysolve PUBLIC POLYSOLVE_WITH_CPU_HYBRID)
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_CPU_HYBRID)
endif()

# Graph partition library Kaminpar does not support windows.
if(POLYSOLVE_WITH_CUDA AND NOT WIN32)
target_compile_definitions(polysolve PUBLIC POLYSOLVE_WITH_MAS)
Expand All @@ -257,6 +286,12 @@ endif()
# Dependencies
################################################################################

# cuDSS
if (POLYSOLVE_WITH_CUDA)
include(cudss)
target_link_libraries(polysolve_linear PRIVATE cudss)
endif()

# CCCL
if(POLYSOLVE_WITH_CUDA)
include(cccl)
Expand All @@ -275,6 +310,16 @@ endif()
# Linear
# ------

if(POLYSOLVE_WITH_MPI)
message(STATUS "MPI enabled for PolySolve.")

# Link to the linear sub-library
target_link_libraries(polysolve_linear PUBLIC MPI::MPI_CXX)

# Define POLYSOLVE_WITH_MPI for your C++ #ifdef checks
target_compile_definitions(polysolve_linear PUBLIC POLYSOLVE_WITH_MPI)
endif()

# Accelerate solver (Include before Eigen)
if(POLYSOLVE_WITH_ACCELERATE)
set(BLA_VENDOR Apple)
Expand Down Expand Up @@ -483,4 +528,4 @@ if(POLYSOLVE_WITH_TESTS)
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")

add_subdirectory(tests)
endif()
endif()
27 changes: 27 additions & 0 deletions cmake/recipes/cudss.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cuDSS solver

if(TARGET cudss)
return()
endif()

message(STATUS "Third-party: creating target 'cudss'")

set(CUDSS_URL
"https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-x86_64/libcudss-linux-x86_64-0.7.1.4_cuda13-archive.tar.xz"
CACHE STRING "cuDSS download URL")
set(CUDSS_URL_SHA256
"84b34ebe7fad40ec10f2aab2957a63b6070bd8ce16e3ada3e6bcac7317256347"
CACHE STRING "cuDSS download URL SHA256 checksum")

include(CPM)
CPMAddPackage(
NAME cudss
URL ${CUDSS_URL}
URL_HASH SHA256=${CUDSS_URL_SHA256}
DOWNLOAD_ONLY ON
)

find_package(cudss CONFIG REQUIRED
PATHS "${cudss_SOURCE_DIR}/lib/cmake/cudss"
NO_DEFAULT_PATH
)
7 changes: 6 additions & 1 deletion cmake/recipes/hypre.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ endif()

message(STATUS "Third-party: creating target 'HYPRE::HYPRE'")

set(HYPRE_ENABLE_MPI OFF CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_PRINT_ERRORS ON CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_BIGINT OFF CACHE INTERNAL "" FORCE)
set(HYPRE_ENABLE_MIXEDINT OFF CACHE BOOL "" FORCE)
Expand All @@ -22,6 +21,12 @@ else()
set(HYPRE_ENABLE_CUDA OFF CACHE INTERNAL "" FORCE)
endif()

if (POLYSOLVE_WITH_MPI)
set(HYPRE_ENABLE_MPI ON CACHE INTERNAL "" FORCE)
else()
set(HYPRE_ENABLE_MPI OFF CACHE INTERNAL "" FORCE)
endif()

# HYPRE unconditionally defines an "uninstall" target, which conflicts with other buggy libraries
# as modern cmake requires unique target name. This is a hacky workaround until upstream is fixed.
macro(add_custom_target _target_name)
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/polyfem-data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ExternalProject_Add(
SOURCE_DIR ${POLYFEM_DATA_ROOT}

GIT_REPOSITORY https://github.com/polyfem/polyfem-data
GIT_TAG 9c1bdd5bd02215e80bc1668547e5dbeb5484a527
GIT_TAG 8a2eff19a33ccfd395c9294342e2c5c2babf2626

CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
220 changes: 218 additions & 2 deletions linear-solver-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"Pardiso",
"Hypre",
"AMGCL",
"MAS"
"MAS",
"CPUHybrid",
"GPUHybrid"
],
"doc": "Settings for the linear solver."
},
Expand Down Expand Up @@ -49,7 +51,9 @@
"Eigen::BiCGSTAB",
"Eigen::GMRES",
"Eigen::MINRES",
"MAS"
"MAS",
"CPUHybrid",
"GPUHybrid"
]
},
{
Expand Down Expand Up @@ -506,5 +510,217 @@
"default": false,
"type": "bool",
"doc": "Use preconditioned residual norm for termination check."
},
{
"pointer": "/CPUHybrid",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just my personal opinion but maybe setting other than tolerance should be in advanced? I don't think user would want to tweak stuff like gmm iter.

"default": null,
"type": "object",
"optional": [
"block_dim",
"max_iter",
"relative_tolerance",
"absolute_tolerance",
"theta",
"decompose_subdomains",
"min_subdomain_size",
"max_subdomain_size",
"expand_subdomains",
"gmm_jump_threshold",
"gmm_tol",
"max_gmm_iterations",
"conditioning_threshold",
"additive_mode"
],
"doc": "Settings for the CPUHybrid solver."
},
{
"pointer": "/CPUHybrid/block_dim",
"default": 1,
"type": "int",
"doc": "Block size of the system matrix. "
},
{
"pointer": "/CPUHybrid/max_iter",
"default": 10000,
"type": "int",
"doc": "Maximum number of PCG iterations. "
},
{
"pointer": "/CPUHybrid/relative_tolerance",
"default": 1e-10,
"type": "float",
"doc": "Relative tolerance for solver convergence."
},
{
"pointer": "/CPUHybrid/absolute_tolerance",
"default": 0,
"type": "float",
"doc": "Absolute tolerance for solver convergence."
},
{
"pointer": "/CPUHybrid/theta",
"default": 0.5,
"type": "float",
"doc": "Strong threshold for AMG."
},
{
"pointer": "/CPUHybrid/decompose_subdomains",
"default": true,
"type": "bool",
"doc": "Whether to decompose the problematic subspace into independent clusters."
},
{
"pointer": "/CPUHybrid/min_subdomain_size",
"default": 3,
"type": "int",
"doc": "Minimum number of degrees of freedom or elements in a subdomain."
},
{
"pointer": "/CPUHybrid/max_subdomain_size",
"default": 1000000000,
"type": "int",
"doc": "Maximum number of degrees of freedom or elements in a subdomain."
},
{
"pointer": "/CPUHybrid/expand_subdomains",
"default": true,
"type": "bool",
"doc": "Enables one layer BFS expansion of subdomains to improve convergence."
},
{
"pointer": "/CPUHybrid/gmm_jump_threshold",
"default": 10.0,
"type": "float",
"doc": "Threshold ratio for detecting row norm jumps in GMM."
},
{
"pointer": "/CPUHybrid/gmm_tol",
"default": 1e-3,
"type": "float",
"doc": "Tolerance for the Gaussian Mixture Model. "
},
{
"pointer": "/CPUHybrid/max_gmm_iterations",
"default": 20,
"type": "int",
"doc": "Maximum number of iterations allowed for the GMM routine."
},
{
"pointer": "/CPUHybrid/conditioning_threshold",
"default": 100,
"type": "float",
"doc": "Minimal worst-case condition number to include in subspace correction. "
},
{
"pointer": "/CPUHybrid/additive_mode",
"default": false,
"type": "bool",
"doc": "Apply subspace correction additively. "
},
{
"pointer": "/GPUHybrid",
"default": null,
"type": "object",
"optional": [
"block_dim",
"max_iter",
"relative_tolerance",
"absolute_tolerance",
"theta",
"decompose_subdomains",
"min_subdomain_size",
"max_subdomain_size",
"expand_subdomains",
"gmm_jump_threshold",
"gmm_tol",
"max_gmm_iterations",
"conditioning_threshold",
"additive_mode"
],
"doc": "Settings for the GPUHybrid solver."
},
{
"pointer": "/GPUHybrid/block_dim",
"default": 1,
"type": "int",
"doc": "Block size of the system matrix. "
},
{
"pointer": "/GPUHybrid/max_iter",
"default": 10000,
"type": "int",
"doc": "Maximum number of PCG iterations. "
},
{
"pointer": "/GPUHybrid/relative_tolerance",
"default": 1e-10,
"type": "float",
"doc": "Relative tolerance for solver convergence."
},
{
"pointer": "/GPUHybrid/absolute_tolerance",
"default": 0,
"type": "float",
"doc": "Absolute tolerance for solver convergence."
},
{
"pointer": "/GPUHybrid/theta",
"default": 0.5,
"type": "float",
"doc": "Strong threshold for AMG."
},
{
"pointer": "/GPUHybrid/decompose_subdomains",
"default": true,
"type": "bool",
"doc": "Whether to decompose the problematic subspace into independent clusters."
},
{
"pointer": "/GPUHybrid/min_subdomain_size",
"default": 3,
"type": "int",
"doc": "Minimum number of degrees of freedom or elements in a subdomain."
},
{
"pointer": "/GPUHybrid/max_subdomain_size",
"default": 1000000000,
"type": "int",
"doc": "Maximum number of degrees of freedom or elements in a subdomain."
},
{
"pointer": "/GPUHybrid/expand_subdomains",
"default": true,
"type": "bool",
"doc": "Enables one layer BFS expansion of subdomains to improve convergence."
},
{
"pointer": "/GPUHybrid/gmm_jump_threshold",
"default": 10.0,
"type": "float",
"doc": "Threshold ratio for detecting row norm jumps in GMM."
},
{
"pointer": "/GPUHybrid/gmm_tol",
"default": 1e-3,
"type": "float",
"doc": "Tolerance for the Gaussian Mixture Model. "
},
{
"pointer": "/GPUHybrid/max_gmm_iterations",
"default": 20,
"type": "int",
"doc": "Maximum number of iterations allowed for the GMM routine."
},
{
"pointer": "/GPUHybrid/conditioning_threshold",
"default": 100,
"type": "float",
"doc": "Minimal worst-case condition number to include in subspace correction. "
},
{
"pointer": "/GPUHybrid/additive_mode",
"default": false,
"type": "bool",
"doc": "Apply subspace correction additively. "
}
]
Loading
Loading