From d3d3f4bb54727576f5795994e75183cfba3efa6d Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Tue, 23 Jan 2024 23:08:30 +0800 Subject: [PATCH] enable x86 suitesparse & ceres-solver (#3154) * enable x86 suitesparse * enable x86 ceres-solver --- packages/c/ceres-solver/xmake.lua | 2 +- packages/s/suitesparse/port/xmake.lua | 11 ++++++---- packages/s/suitesparse/xmake.lua | 29 ++++++++++++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/c/ceres-solver/xmake.lua b/packages/c/ceres-solver/xmake.lua index 87d62f18737..4ba0128425f 100644 --- a/packages/c/ceres-solver/xmake.lua +++ b/packages/c/ceres-solver/xmake.lua @@ -20,7 +20,7 @@ package("ceres-solver") end end) - on_install("windows|x64", "linux", "macosx", function (package) + on_install("windows|x64", "windows|x86", "linux", "macosx", function (package) local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOCUMENTATION=OFF", "-DBUILD_EXAMPLES=OFF", "-DBUILD_BENCHMARKS=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) diff --git a/packages/s/suitesparse/port/xmake.lua b/packages/s/suitesparse/port/xmake.lua index e316c6b6abf..510fa0d9388 100644 --- a/packages/s/suitesparse/port/xmake.lua +++ b/packages/s/suitesparse/port/xmake.lua @@ -5,10 +5,11 @@ set_languages("cxx14") add_rules("mode.debug", "mode.release") -- initialize options -option("with_cuda", {default = false, showmenu = true, description = "Build with CUDA support."}) -option("with_blas", {default = "mkl", showmenu = true, description = "Choose BLAS vendor.", values={"mkl", "openblas"}}) -option("complex", {default = false, showmenu = true, description = "Build with complex number support."}) -option("graphblas", {default = false, showmenu = true, description = "Build GraphBLAS module."}) +option("with_cuda", {default = false, showmenu = true, description = "Build with CUDA support."}) +option("with_blas", {default = "mkl", showmenu = true, description = "Choose BLAS vendor.", values={"mkl", "openblas"}}) +option("complex", {default = false, showmenu = true, description = "Build with complex number support."}) +option("graphblas", {default = false, showmenu = true, description = "Build GraphBLAS module."}) +option("graphblas_static", {default = false, showmenu = true, description = "Build static GraphBLAS module."}) -- set dependencies add_requires("metis") @@ -161,6 +162,7 @@ target("SPQR") target_end() if has_config("graphblas") then +if has_config("graphblas_static") then target("GraphBLAS") set_kind("static") add_files("GraphBLAS/Source/*.c", "GraphBLAS/Source/Generated/*.c") @@ -175,6 +177,7 @@ target("GraphBLAS") add_headerfiles("GraphBLAS/Include/*.h") target_end() end +end if has_config("with_cuda") then target("SuiteSparse_GPURuntime") diff --git a/packages/s/suitesparse/xmake.lua b/packages/s/suitesparse/xmake.lua index e877d8ea500..cf44578e9a6 100644 --- a/packages/s/suitesparse/xmake.lua +++ b/packages/s/suitesparse/xmake.lua @@ -16,7 +16,8 @@ package("suitesparse") add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"}) add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas", "apple"}}) add_configs("blas_static", {description = "Use static BLAS library.", default = true, type = "boolean"}) - add_configs("graphblas", {description = "Enable static GraphBLAS module.", default = false, type = "boolean"}) + add_configs("graphblas", {description = "Enable GraphBLAS module.", default = not is_arch("x86"), type = "boolean"}) + add_configs("graphblas_static", {description = "Enable static GraphBLAS module.", default = false, type = "boolean"}) add_deps("metis") if not is_plat("windows") then @@ -32,11 +33,6 @@ package("suitesparse") if package:config("openmp") then package:add("deps", "openmp") end - if package:config("cuda") then - package:add("deps", "cuda", {system = true, configs = {utils = {"cublas"}}}) - package:add("links", "GPUQREngine") - package:add("links", "SuiteSparse_GPURuntime") - end if package:config("blas") == "apple" then package:add("frameworks", "Accelerate") else @@ -46,31 +42,43 @@ package("suitesparse") local suffix = "" if package:is_plat("windows") and not package:config("shared") then suffix = "_static" + if package:config("graphblas") then + package:add("links", "graphblas" .. (package:config("graphblas_static") and "_static" or "")) + end end for _, lib in ipairs({"lagraphx", "lagraph", "graphblas", "spex", "spqr", "rbio", "ParU", "umfpack", "ldl", "klu", "klu_cholmod", "cxsparse", "cholmod", "colamd", "ccolamd", "camd", "btf", "amd", "suitesparse_mongoose", "suitesparseconfig"}) do package:add("links", lib .. suffix) end else + if package:config("cuda") then + package:add("deps", "cuda", {system = true, configs = {utils = {"cublas"}}}) + package:add("links", "GPUQREngine") + package:add("links", "SuiteSparse_GPURuntime") + end for _, lib in ipairs({"SPQR", "UMFPACK", "LDL", "KLU", "CXSparse", "CHOLMOD", "COLAMD", "CCOLAMD", "CAMD", "BTF", "AMD", "suitesparseconfig"}) do package:add("links", lib) end end end) - on_install("windows|x64", "macosx", "linux", function (package) + on_install("windows|x64", "windows|x86", "macosx", "linux", function (package) if package:version():ge("7.4.0") then local configs = {"-DSUITESPARSE_DEMOS=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON")) - table.insert(configs, "-DGRAPHBLAS_BUILD_STATIC_LIBS=" .. (package:config("graphblas") and "ON" or "OFF")) + table.insert(configs, "-DGRAPHBLAS_BUILD_STATIC_LIBS=" .. (package:config("graphblas_static") and "ON" or "OFF")) table.insert(configs, "-DSUITESPARSE_USE_OPENMP=" .. (package:config("openmp") and "ON" or "OFF")) table.insert(configs, "-DSUITESPARSE_USE_CUDA=" .. (package:config("cuda") and "ON" or "OFF")) local bla_vendor = {mkl = "Intel10_64lp", openblas = "OpenBLAS", apple = "Apple"} table.insert(configs, "-DBLA_VENDOR=" .. bla_vendor[package:config("blas")]) table.insert(configs, "-DBLA_STATIC=" .. (package:config("blas_static") and "ON" or "OFF")) if package:is_plat("windows") then - table.insert(configs, "-DSUITESPARSE_ENABLE_PROJECTS=suitesparse_config;mongoose;amd;btf;camd;ccolamd;colamd;cholmod;cxsparse;ldl;klu;umfpack;paru;rbio;spqr;graphblas;lagraph") -- remove spex since it does not support windows + if package:config("graphblas") then + table.insert(configs, "-DSUITESPARSE_ENABLE_PROJECTS=suitesparse_config;mongoose;amd;btf;camd;ccolamd;colamd;cholmod;cxsparse;ldl;klu;umfpack;paru;rbio;spqr;graphblas;lagraph") -- remove spex since it does not support windows + else + table.insert(configs, "-DSUITESPARSE_ENABLE_PROJECTS=suitesparse_config;mongoose;amd;btf;camd;ccolamd;colamd;cholmod;cxsparse;ldl;klu;umfpack;paru;rbio;spqr") + end local vs_sdkver = import("core.tool.toolchain").load("msvc"):config("vs_sdkver") if vs_sdkver then local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*") @@ -78,6 +86,8 @@ package("suitesparse") table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver) table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver) end + elseif not package:config("graphblas") then + table.insert(configs, "-DSUITESPARSE_ENABLE_PROJECTS=suitesparse_config;mongoose;amd;btf;camd;ccolamd;colamd;cholmod;cxsparse;ldl;klu;umfpack;paru;rbio;spqr;spex") end import("package.tools.cmake").install(package, configs) else @@ -86,6 +96,7 @@ package("suitesparse") configs.with_blas = package:config("blas") configs.with_cuda = package:config("cuda") configs.graphblas = package:config("graphblas") + configs.graphblas_static = package:config("graphblas_static") import("package.tools.xmake").install(package, configs) end end)