diff --git a/recipes/suitesparse-mongoose/all/conandata.yml b/recipes/suitesparse-mongoose/all/conandata.yml new file mode 100644 index 0000000000000..e14d8a2b78174 --- /dev/null +++ b/recipes/suitesparse-mongoose/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.3.3": + url: "https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v7.7.0.tar.gz" + sha256: "529b067f5d80981f45ddf6766627b8fc5af619822f068f342aab776e683df4f3" diff --git a/recipes/suitesparse-mongoose/all/conanfile.py b/recipes/suitesparse-mongoose/all/conanfile.py new file mode 100644 index 0000000000000..2f045095d5eb9 --- /dev/null +++ b/recipes/suitesparse-mongoose/all/conanfile.py @@ -0,0 +1,98 @@ +import os + +from conan import ConanFile +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 + +required_conan_version = ">=1.53.0" + + +class SuiteSparseMongooseConan(ConanFile): + name = "suitesparse-mongoose" + description = "Mongoose: Graph partitioning library in SuiteSparse" + license = "GPL-3.0-only" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://people.engr.tamu.edu/davis/suitesparse.html" + topics = ("graph-algorithms", "mathematics", "sparse-matrix", "graph-partitioning") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + 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) + + 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 _patch_sources(self): + # Python is only used for tests + replace_in_file(self, os.path.join(self.source_folder, "Mongoose", "CMakeLists.txt"), + "find_package ( Python COMPONENTS Interpreter )", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "Mongoose")) + cmake.build() + + def package(self): + copy(self, "License.txt", os.path.join(self.source_folder, "Mongoose", "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", "SuiteSparse_Mongoose") + self.cpp_info.set_property("cmake_target_name", "SuiteSparse::Mongoose") + if not self.options.shared: + self.cpp_info.set_property("cmake_target_aliases", ["SuiteSparse::Mongoose_static"]) + self.cpp_info.set_property("pkg_config_name", "Mongoose") + + self.cpp_info.libs = ["suitesparse_mongoose"] + self.cpp_info.includedirs.append(os.path.join("include", "suitesparse")) + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/suitesparse-mongoose/all/test_package/CMakeLists.txt b/recipes/suitesparse-mongoose/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ae0f30cfe3524 --- /dev/null +++ b/recipes/suitesparse-mongoose/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C CXX) + +find_package(SuiteSparse_Mongoose REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE SuiteSparse::Mongoose) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/suitesparse-mongoose/all/test_package/GD97_b.mtx b/recipes/suitesparse-mongoose/all/test_package/GD97_b.mtx new file mode 100644 index 0000000000000..5f8a0a76fc8cf --- /dev/null +++ b/recipes/suitesparse-mongoose/all/test_package/GD97_b.mtx @@ -0,0 +1,134 @@ +%%MatrixMarket matrix coordinate real symmetric +47 47 132 +2 1 59 +3 1 81.5 +4 1 49.8889 +5 1 79.8889 +7 1 164.3 +37 1 .01 +3 2 65.5 +4 2 39.2222 +7 2 179.167 +4 3 89.8333 +5 3 138.833 +6 3 73.8222 +10 3 60.2 +11 3 141.05 +5 4 91.5556 +6 4 80.05 +9 4 90.3167 +6 5 120.583 +8 5 428.033 +9 5 76.3167 +10 5 71.6417 +12 5 147.608 +19 5 358.254 +22 5 115.25 +24 5 65.8845 +30 5 99.1984 +33 5 93.7722 +36 5 120.531 +44 5 462.081 +45 5 158.388 +7 6 365.867 +8 6 455.811 +12 6 125.54 +13 6 304.856 +14 6 241.596 +15 6 42.5393 +29 6 12.6429 +45 6 123.319 +8 7 685.367 +11 7 149.862 +19 7 336.657 +20 7 174.18 +25 7 86.6087 +27 7 102.318 +28 7 77.5544 +29 7 4.625 +35 7 126.831 +46 7 991.274 +9 8 69.4167 +10 8 50.1762 +11 8 187.483 +12 8 138.352 +13 8 381.344 +14 8 296.278 +15 8 46.1107 +16 8 46.1107 +19 8 454.534 +20 8 160.377 +21 8 77.3671 +22 8 113.304 +24 8 48.8397 +25 8 110.661 +27 8 139.002 +28 8 84.2933 +31 8 201.018 +32 8 268.623 +34 8 217.951 +35 8 141.227 +36 8 119.128 +44 8 532.528 +13 12 261.895 +14 12 235.025 +18 12 14.75 +30 12 110.727 +15 14 82.7202 +16 14 85.6167 +17 14 32.2833 +18 14 32.7119 +21 14 64.2774 +29 14 4.7611 +34 14 214.252 +16 15 60.9107 +17 15 15.0321 +18 15 20.5095 +17 16 14.0625 +20 19 372.671 +21 19 74.5095 +23 19 73.8992 +24 19 46.8377 +25 19 91.2528 +26 19 220.074 +27 19 95.9782 +28 19 88.4937 +30 19 109.933 +31 19 180.068 +32 19 233.062 +35 19 131.191 +36 19 126.242 +44 19 565.295 +46 19 1161.05 +37 20 .01 +38 20 .2 +22 21 126.177 +23 21 124.902 +23 22 73.2749 +26 24 180.521 +26 25 196.171 +37 29 .01 +38 29 .2 +39 29 .3667 +31 30 178.286 +32 31 242.723 +33 31 111.667 +33 32 151.122 +34 32 240.569 +38 37 1 +39 37 1.5 +40 37 1.8333 +41 37 2.0833 +39 38 1 +40 38 1.375 +42 38 2.2833 +40 39 1.8333 +41 39 2.0833 +42 39 2.2833 +43 39 1.96 +41 40 2.0833 +43 40 2.4833 +42 41 2.3333 +43 42 2.5333 +45 44 187.608 +46 44 1356.59 diff --git a/recipes/suitesparse-mongoose/all/test_package/conanfile.py b/recipes/suitesparse-mongoose/all/test_package/conanfile.py new file mode 100644 index 0000000000000..79851447cced9 --- /dev/null +++ b/recipes/suitesparse-mongoose/all/test_package/conanfile.py @@ -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, "GD97_b.mtx") + self.run(f"{bin_path} {test_matrix}", env="conanrun") diff --git a/recipes/suitesparse-mongoose/all/test_package/test_package.cpp b/recipes/suitesparse-mongoose/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7323cdea6e7ef --- /dev/null +++ b/recipes/suitesparse-mongoose/all/test_package/test_package.cpp @@ -0,0 +1,73 @@ +// https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v7.7.0/Mongoose/Demo/demo.cpp + +/** + * demo.cpp + * Runs a variety of computations on several input matrices and outputs + * the results. Does not take any input. This application can be used to + * test that compilation was successful and that everything is working + * properly. + * + * Mongoose, Copyright (c) 2018, All Rights Reserved. + * Nuri Yeralan, Microsoft Research + * Scott Kolodziej, Texas A&M University + * Tim Davis, Texas A&M University + * William Hager, University of Florida. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "Mongoose.hpp" +#include +#include +#include +#include + +using namespace Mongoose; +using namespace std; + +int main(int argn, const char **argv) +{ + if (argn != 2) + { + cout << "Usage: " << argv[0] << " " << endl; + return EXIT_FAILURE; + } + + std::string demo_file = argv[1]; + + cout << "Mongoose Graph Partitioning Library, Version " << mongoose_version() << endl; + + cout << "Computing an edge cut for " << demo_file << "..." << endl; + + double trial_start = SUITESPARSE_TIME; + EdgeCut_Options *options = EdgeCut_Options::create(); + if (!options) return EXIT_FAILURE; // Return an error if we failed. + + options->matching_strategy = HEMSRdeg; + options->initial_cut_type = InitialEdgeCut_QP; + + Graph *graph = read_graph(demo_file); + if (!graph) + { + return EXIT_FAILURE; + } + + EdgeCut *result = edge_cut(graph, options); + + cout << "Cut Cost: " << setprecision(2) << result->cut_cost << endl; + if (result->imbalance < 1e-12) + { + // imbalance is zero; this is just a roundoff epsilon in the statistic + cout << "Cut Imbalance: zero (a perfect balance)" << endl; + } + else + { + cout << "Cut Imbalance: " << setprecision(2) << 100*(result->imbalance) << "%" << endl; + } + + options->~EdgeCut_Options(); + graph->~Graph(); + result->~EdgeCut(); + + return EXIT_SUCCESS; +} diff --git a/recipes/suitesparse-mongoose/config.yml b/recipes/suitesparse-mongoose/config.yml new file mode 100644 index 0000000000000..6747903d9d322 --- /dev/null +++ b/recipes/suitesparse-mongoose/config.yml @@ -0,0 +1,3 @@ +versions: + "3.3.3": + folder: all