Skip to content

Commit

Permalink
enable x86 suitesparse & ceres-solver (#3154)
Browse files Browse the repository at this point in the history
* enable x86 suitesparse

* enable x86 ceres-solver
  • Loading branch information
xq114 authored Jan 23, 2024
1 parent 724b6f8 commit d3d3f4b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/c/ceres-solver/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
11 changes: 7 additions & 4 deletions packages/s/suitesparse/port/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -175,6 +177,7 @@ target("GraphBLAS")
add_headerfiles("GraphBLAS/Include/*.h")
target_end()
end
end

if has_config("with_cuda") then
target("SuiteSparse_GPURuntime")
Expand Down
29 changes: 20 additions & 9 deletions packages/s/suitesparse/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -46,38 +42,52 @@ 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*")
assert(tonumber(build_ver) >= 18362, "cpuinfo requires Windows SDK to be at least 10.0.18362.0")
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
Expand All @@ -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)
Expand Down

0 comments on commit d3d3f4b

Please sign in to comment.