-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sources: | ||
"0.1.3": | ||
url: "https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v7.7.0.tar.gz" | ||
sha256: "529b067f5d80981f45ddf6766627b8fc5af619822f068f342aab776e683df4f3" | ||
patches: | ||
"0.1.3": | ||
- patch_file: "patches/001-fix-cmake.patch" | ||
patch_type: "portability" | ||
patch_description: "Fix a breaking typo in CMakeLists.txt" | ||
patch_source: "https://github.com/DrTimothyAldenDavis/SuiteSparse/pull/793" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import stdcpp_library | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import get, rm, rmdir, copy, replace_in_file, export_conandata_patches, apply_conandata_patches | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class SuiteSparseParuConan(ConanFile): | ||
name = "suitesparse-paru" | ||
description = "ParU: Routines for solving sparse linear system via parallel multifrontal LU factorization algorithms in SuiteSparse" | ||
license = "GPL-3.0-or-later" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://people.engr.tamu.edu/davis/suitesparse.html" | ||
topics = ("mathematics", "sparse-matrix", "linear-algebra", "linear-system-solver", "lu-factorization") | ||
|
||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
# OpenBLAS and OpenMP are provided via suitesparse-config | ||
self.requires("suitesparse-config/7.7.0", transitive_headers=True, transitive_libs=True) | ||
self.requires("suitesparse-cholmod/5.2.1", transitive_headers=True, transitive_libs=True) | ||
self.requires("suitesparse-umfpack/6.3.3", transitive_headers=True, transitive_libs=True) | ||
|
||
def build_requirements(self): | ||
self.tool_requires("cmake/[>=3.22 <4]") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
venv = VirtualBuildEnv(self) | ||
venv.generate() | ||
|
||
tc = CMakeToolchain(self) | ||
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared | ||
tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared | ||
tc.variables["SUITESPARSE_USE_OPENMP"] = True | ||
tc.variables["SUITESPARSE_USE_CUDA"] = False | ||
tc.variables["SUITESPARSE_DEMOS"] = False | ||
tc.variables["SUITESPARSE_USE_FORTRAN"] = False # Fortran sources are translated to C instead | ||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure(build_script_folder=os.path.join(self.source_folder, "ParU")) | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "License.txt", os.path.join(self.source_folder, "ParU", "Doc"), os.path.join(self.package_folder, "licenses")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
rm(self, "*.pdb", self.package_folder, recursive=True) | ||
|
||
def package_info(self): | ||
self.cpp_info.set_property("cmake_file_name", "ParU") | ||
self.cpp_info.set_property("cmake_target_name", "SuiteSparse::ParU") | ||
if not self.options.shared: | ||
self.cpp_info.set_property("cmake_target_aliases", ["SuiteSparse::ParU_static"]) | ||
self.cpp_info.set_property("pkg_config_name", "ParU") | ||
|
||
self.cpp_info.libs = ["paru"] | ||
self.cpp_info.includedirs.append(os.path.join("include", "suitesparse")) | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") | ||
|
||
if not self.options.shared and stdcpp_library(self): | ||
self.cpp_info.system_libs.append(stdcpp_library(self)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- ParU/CMakeLists.txt | ||
+++ ParU/CMakeLists.txt | ||
@@ -111,7 +111,7 @@ | ||
|
||
find_package ( UMFPACK 6.3.3 | ||
PATHS ${CMAKE_SOURCE_DIR}/../UMFPACK/build NO_DEFAULT_PATH ) | ||
- if ( NOT CAMD_FOUND ) | ||
+ if ( NOT UMFPACK_FOUND ) | ||
find_package ( UMFPACK 6.3.3 REQUIRED ) | ||
endif ( ) | ||
endif ( ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package LANGUAGES C) | ||
|
||
find_package(ParU REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE SuiteSparse::ParU) | ||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
test_matrix = os.path.join(self.source_folder, "p1_ss.mtx") | ||
self.run(f"{bin_path} < {test_matrix}", env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
%%MatrixMarket matrix coordinate real general | ||
%------------------------------------------------------------------------------- | ||
% UF Sparse Matrix Collection, Tim Davis | ||
% http://www.cise.ufl.edu/research/sparse/matrices/Grund/b1_ss | ||
% name: Grund/b1_ss | ||
% [Unsymmetric Matrix b1_ss, F. Grund, Dec 1994.] | ||
% id: 449 | ||
% date: 1997 | ||
% author: F. Grund | ||
% ed: F. Grund | ||
% fields: title A b name id date author ed kind | ||
% kind: chemical process simulation problem | ||
%------------------------------------------------------------------------------- | ||
7 7 15 | ||
5 1 -.03599942 | ||
6 1 -.0176371 | ||
7 1 -.007721779 | ||
1 2 1 | ||
2 2 -1 | ||
1 3 1 | ||
3 3 -1 | ||
1 4 1 | ||
4 4 -1 | ||
2 5 .45 | ||
5 5 1 | ||
3 6 .1 | ||
6 6 1 | ||
4 7 .45 | ||
7 7 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v7.7.0/ParU/Demo/paru_simplec.c | ||
|
||
// ========================================================================= / | ||
// ======================= paru_simplec.c ================================= / | ||
// ========================================================================== / | ||
|
||
// ParU, Copyright (c) 2022, Mohsen Aznaveh and Timothy A. Davis, | ||
// All Rights Reserved. | ||
// SPDX-License-Identifier: GNU GPL 3.0 | ||
|
||
/* | ||
* @brief a simple test to show how to use ParU with C interface | ||
* @author Aznaveh | ||
* */ | ||
|
||
#include <ParU_C.h> | ||
|
||
#include <stdint.h> | ||
#include <math.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
cholmod_common Common, *cc; | ||
cholmod_sparse *A; | ||
ParU_C_Symbolic *Sym; | ||
//~~~~~~~~~Reading the input matrix and test if the format is OK~~~~~~~~~~~~ | ||
// start CHOLMOD | ||
cc = &Common; | ||
int mtype; | ||
cholmod_l_start(cc); | ||
// A = mread (stdin) ; read in the sparse matrix A | ||
A = (cholmod_sparse *)cholmod_l_read_matrix(stdin, 1, &mtype, cc); | ||
//~~~~~~~~~~~~~~~~~~~Starting computation~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
printf("================= ParU, a simple demo, using C interface : ====\n"); | ||
ParU_C_Control Control; | ||
ParU_C_Init_Control(&Control); | ||
ParU_Ret info; | ||
info = ParU_C_Analyze(A, &Sym, &Control); | ||
printf("Input matrix is %" PRId64 "x%" PRId64 " nnz = %" PRId64 " \n", Sym->m, Sym->n, Sym->anz); | ||
ParU_C_Numeric *Num; | ||
info = ParU_C_Factorize(A, Sym, &Num, &Control); | ||
|
||
if (info != PARU_SUCCESS) | ||
{ | ||
printf("ParU: factorization was NOT successful."); | ||
if (info == PARU_OUT_OF_MEMORY) printf("\nOut of memory\n"); | ||
if (info == PARU_INVALID) printf("\nInvalid!\n"); | ||
if (info == PARU_SINGULAR) printf("\nSingular!\n"); | ||
} | ||
else | ||
{ | ||
printf("ParU: factorization was successful.\n"); | ||
} | ||
|
||
//~~~~~~~~~~~~~~~~~~~ Computing Ax = b ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
#if 1 | ||
if (info == PARU_SUCCESS) | ||
{ | ||
int64_t m = Sym->m; | ||
double *b = (double *)malloc(m * sizeof(double)); | ||
double *xx = (double *)malloc(m * sizeof(double)); | ||
for (int64_t i = 0; i < m; ++i) b[i] = i + 1; | ||
info = ParU_C_Solve_Axb(Sym, Num, b, xx, &Control); | ||
double resid, anorm, xnorm; | ||
info = | ||
ParU_C_Residual_bAx(A, xx, b, m, &resid, &anorm, &xnorm, &Control); | ||
double rresid = (anorm == 0 || xnorm == 0 ) ? 0 : (resid/(anorm*xnorm)); | ||
printf( "Relative residual is |%.2e|, anorm is %.2e, xnorm is %.2e " | ||
" and rcond is %.2e.\n", rresid, anorm, xnorm, Num->rcond); | ||
free(b); | ||
free(xx); | ||
} | ||
#endif // testing the results | ||
//~~~~~~~~~~~~~~~~~~~End computation~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
ParU_C_Freenum(&Num, &Control); | ||
ParU_C_Freesym(&Sym, &Control); | ||
|
||
cholmod_l_free_sparse(&A, cc); | ||
cholmod_l_finish(cc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.1.3": | ||
folder: all |