Last active
May 17, 2021 11:14
-
-
Save SomeoneSerge/cf5728c1cbb0f8f7e8db1898c7a776cf to your computer and use it in GitHub Desktop.
Eigen, SuiteSparse and sparseLM in Bazel
This file contains hidden or 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
cc_library( | |
name="doctest", | |
hdrs=["@doctest//file"], | |
visibility=["//visibility:public"], | |
strip_include_prefix = "/external/doctest/file", | |
include_prefix = "doctest", | |
) | |
cc_library( | |
name="downstream", | |
srcs=[ | |
# ... | |
], | |
hdrs=[ | |
# ... | |
], | |
deps=[ | |
"@sparselm//:splm", | |
"@eigen//:eigen", | |
"@suitesparse//:SPQR", | |
"doctest", | |
], | |
copts=[ | |
"-std=c++2a", | |
"-O3", | |
"-DDOCTEST_CONFIG_DISABLE", | |
# Enables #pragma omp | |
"-fopenmp", | |
# May disable some optimizations | |
], | |
linkopts=[ | |
# This propagates to reverse-dependencies, unlike -fopenmp | |
"-L$${MKLROOT}/lib/intel64", | |
"-llapack", | |
"-Wl,--no-as-needed", | |
"-lmkl_intel_ilp64", | |
"-lmkl_intel_thread", | |
"-lmkl_core", | |
"-liomp5", | |
"-lpthread", | |
"-lm", | |
"-ldl", | |
], | |
include_prefix="downstream", | |
) | |
cc_binary( | |
name="tests", | |
srcs=["tests.cpp"], | |
deps=[ | |
":downstream", | |
], | |
copts=[ | |
"-std=c++2a", | |
], | |
linkopts=[ | |
], | |
) |
This file contains hidden or 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
package( | |
default_visibility = ["//visibility:public"], | |
) | |
cc_library( | |
name="eigen", | |
hdrs = glob(["Eigen/**", "unsupported/Eigen/**"]), | |
includes = ["."], | |
) |
This file contains hidden or 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
cc_library( | |
name = "splm", | |
srcs = glob([ | |
"splm.c", | |
"splm_crsm.c", | |
"splm_ccsm.c", | |
"splm_hessian.c", | |
"splm_time.c", | |
"splm_stm.c", | |
"splm_misc.c", | |
"splm_umfpack.c", | |
"splm_cholmod.c", | |
"splm_csparse.c", | |
# "splm_dss.c", | |
]), | |
hdrs = glob(["splm.h", "*.h"]), | |
deps = [ | |
"@suitesparse//:CSPQR", | |
"@suitesparse//:CHOLMOD", | |
], | |
copts = [ | |
"-DHAVE_CSPARSE", | |
"-DHAVE_CHOLMOD", | |
], | |
linkopts=[ | |
], | |
visibility = ["//visibility:public"], | |
) |
This file contains hidden or 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
filegroup( | |
name = "all", | |
srcs = glob(["**"]), | |
visibility = ["//visibility:public"]) | |
cc_library( | |
name="gklib", | |
srcs=glob(["metis-5.1.0/GKlib/*.c"]), | |
hdrs=glob(["metis-5.1.0/GKlib/*.h"]), | |
includes=["metis-5.1.0/GKlib"], | |
) | |
cc_library( | |
name="metis-headers", | |
srcs=[], | |
hdrs=glob(["metis-5.1.0/include/*.h"]), | |
strip_include_prefix="metis-5.1.0/include/", | |
) | |
cc_library( | |
name="metis", | |
srcs=glob(["metis-5.1.0/libmetis/*.c"]), | |
hdrs=glob(["metis-5.1.0/libmetis/*.h"]), | |
includes=["metis-5.1.0/libmetis"], | |
deps=[ | |
":metis-headers", | |
":gklib" | |
], | |
) | |
cc_library( | |
name="SuiteSparse_config", | |
hdrs = glob([ | |
"SuiteSparse_config/*", | |
]), | |
srcs = ["SuiteSparse_config/SuiteSparse_config.c"], | |
strip_include_prefix = "SuiteSparse_config/", | |
copts=["-DDINT"], | |
) | |
cc_library( | |
name="COLAMD", | |
hdrs = glob([ | |
"COLAMD/Include/*", | |
]), | |
strip_include_prefix = "COLAMD/Include", | |
deps = [":SuiteSparse_config"], | |
srcs=glob([ | |
"COLAMD/Source/*", | |
]), | |
copts=["-fopenmp", "-DDINT"], | |
) | |
cc_library( | |
name="CSparse", | |
hdrs = glob([ | |
"CSparse/Include/*.h", | |
]), | |
strip_include_prefix = "CSparse/Include", | |
deps = [":SuiteSparse_config"], | |
srcs=glob([ | |
"CSparse/Source/*.c", | |
]), | |
copts=[ | |
"-fopenmp", | |
"-DDINT", | |
"-Wno-incompatible-pointer-types", | |
], | |
visibility = ["//visibility:public"], | |
) | |
cc_library( | |
name = "UMFPACK_internal", | |
hdrs = glob([ | |
"UMFPACK/Source/*.h", | |
"UMFPACK/Source/umf_*.c", | |
"UMFPACK/Source/umfpack_solve.c", | |
]), | |
deps=[":AMD", ":CHOLMOD"], | |
strip_include_prefix = "UMFPACK/Source", | |
) | |
cc_library( | |
name="UMFPACK", | |
hdrs = glob([ | |
"UMFPACK/Include/*.h", | |
]), | |
strip_include_prefix = "UMFPACK/Include", | |
deps = [":SuiteSparse_config", ":UMFPACK_internal"], | |
srcs=glob([ | |
"UMFPACK/Source/*.c", | |
]), | |
copts=["-fopenmp", "-DDINT"], | |
visibility = ["//visibility:public"], | |
) | |
cc_library( | |
name="CCOLAMD", | |
hdrs = glob([ | |
"CCOLAMD/Include/*", | |
]), | |
strip_include_prefix = "CCOLAMD/Include", | |
deps = [":SuiteSparse_config"], | |
srcs=glob([ | |
"CCOLAMD/Source/*", | |
]), | |
copts=["-fopenmp", "-DDINT"], | |
) | |
cc_library( | |
name = "AMD", | |
hdrs = glob([ | |
"AMD/Include/*", | |
]), | |
strip_include_prefix = "AMD/Include", | |
srcs = glob([ | |
"AMD/Source/*.c", | |
]), | |
deps = [":SuiteSparse_config"], | |
copts=["-fopenmp", "-DDINT"], | |
) | |
cc_library( | |
name="CAMD", | |
hdrs = glob([ | |
"CAMD/Include/*", | |
]), | |
strip_include_prefix = "CAMD/Include", | |
srcs=glob([ | |
"CAMD/Source/*.c", | |
]), | |
deps = [":SuiteSparse_config"], | |
copts=["-fopenmp", "-DDINT"], | |
) | |
cc_library( | |
name="CHOLMOD_TEMPLATES", | |
hdrs=glob([ | |
"CHOLMOD/Core/t_*.c", | |
"CHOLMOD/MatrixOps/t_*.c", | |
"CHOLMOD/Cholesky/t_*.c", | |
"CHOLMOD/Supernodal/t_*.c", | |
]), | |
copts=["-fopenmp", "-DDINT"],) | |
cc_library( | |
name = "CHOLMOD", | |
hdrs = glob([ | |
"CHOLMOD/Include/*", | |
# "CHOLMOD/Core/t_cholmod_change_factor.c", | |
]), | |
strip_include_prefix = "CHOLMOD/Include", | |
includes=[ | |
"CHOLMOD/Core/", | |
"CHOLMOD/MatrixOps/", | |
"CHOLMOD/Cholesky/", | |
"CHOLMOD/Partition/", | |
"CHOLMOD/Supernodal/", | |
], | |
srcs=[ | |
_ for _ in glob([ | |
"CHOLMOD/Core/*.c", | |
"CHOLMOD/Cholesky/*.c", | |
"CHOLMOD/MatrixOps/*.c", | |
"CHOLMOD/Partition/*.c", | |
"CHOLMOD/Supernodal/*.c", | |
]) | |
if not _.split("/")[-1].startswith("t_") | |
], | |
deps=[":CHOLMOD_TEMPLATES", ":SuiteSparse_config", ":AMD", ":CAMD", ":COLAMD", ":CCOLAMD", ":metis"], | |
copts=[ | |
"-fopenmp", | |
"-DDINT", | |
"-Wno-unused-but-set-variable", | |
"-Wno-unused-pragmas", | |
"-Wno-unused-variable", | |
], | |
visibility = ["//visibility:public"], | |
) | |
cc_library( | |
name="CSPQR", | |
hdrs = [ | |
"SPQR/Include/SuiteSparseQR_C.h", | |
"SPQR/Include/SuiteSparseQR_definitions.h", | |
], | |
strip_include_prefix = "SPQR/Include", | |
srcs = glob([ | |
"SPQR/Source/*.c", | |
]), | |
deps=[ | |
":CHOLMOD", | |
":COLAMD", | |
":AMD", | |
":CSparse", | |
":UMFPACK", | |
":SuiteSparse_config" | |
], | |
copts=["-DDINT"], | |
linkopts=[ | |
"-L$(PREFIX)/lib", | |
"-llapack", | |
"-Wl,--no-as-needed", | |
"-lmkl_intel_ilp64", | |
"-lmkl_intel_thread", | |
"-lmkl_core", | |
"-liomp5", | |
"-lpthread", | |
"-lm", | |
"-ldl", | |
], | |
visibility = ["//visibility:public"], | |
) | |
cc_library( | |
name = "SPQR", | |
hdrs = glob([ | |
"SPQR/Include/SuiteSparseQR.hpp", | |
"SPQR/Include/spqr.hpp", | |
]), | |
strip_include_prefix = "SPQR/Include", | |
srcs = glob([ | |
"SPQR/Source/*.cpp", | |
]), | |
deps = [":CSPQR"], | |
copts=["-DDINT"], | |
linkopts=[ | |
"-L$(PREFIX)/lib", | |
"-llapack", | |
"-Wl,--no-as-needed", | |
"-lmkl_intel_ilp64", | |
"-lmkl_intel_thread", | |
"-lmkl_core", | |
"-liomp5", | |
"-lpthread", | |
"-lm", | |
"-ldl", | |
], | |
visibility = ["//visibility:public"], | |
) |
This file contains hidden or 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
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") | |
http_archive( | |
name = "rules_foreign_cc", | |
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.1.0.zip", | |
strip_prefix = "rules_foreign_cc-0.1.0", | |
sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e", | |
) | |
load("@rules_foreign_cc//:workspace_definitions.bzl", | |
"rules_foreign_cc_dependencies") | |
rules_foreign_cc_dependencies() | |
# FIXME: not a release of Eigen, arbitrary commit from master | |
# needed because operator() supports arrays of indices only in 3.3.90+ | |
http_archive( | |
name = "eigen", | |
url = "https://github.com/SomeoneSerge/eigen/archive/b9a0ca84d86e735096f4264d75b0b06d4c18de51.zip", | |
sha256 = "80a32fbf385356ba81129c91d58c8d8e3e73aeb7af4e3683a656af6e9c0549aa", | |
build_file="@//:BUILD.eigen.bzl", | |
strip_prefix="eigen-b9a0ca84d86e735096f4264d75b0b06d4c18de51", | |
) | |
http_archive( | |
name = "suitesparse", | |
urls = ["https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v5.9.0.zip"], | |
build_file="@//:BUILD.suitesparse.bzl", | |
strip_prefix="SuiteSparse-5.9.0", | |
sha256 = "4d596ef4aa29dafcfb9b1100be40c5128fb56d37b83c45b5b02dfebf43b7f613", | |
) | |
http_archive( | |
name = "sparselm", | |
urls = ["https://users.ics.forth.gr/~lourakis/sparseLM/sparselm-1.3.tgz"], | |
strip_prefix = "sparselm-1.3", | |
build_file = "@//:BUILD.sparselm.bzl", | |
sha256 = "", | |
) | |
http_file( | |
name = "doctest", | |
downloaded_file_path = "doctest.h", | |
urls = ["https://raw.githubusercontent.com/onqtam/doctest/2.4.4/doctest/doctest.h"], | |
sha256 = "0b396d188bf140198a83c8f86fd714d8882333c1f95c408f5f5896c009664932", | |
) | |
http_archive( | |
name = "com_grail_bazel_toolchain", | |
strip_prefix = "bazel-toolchain-5f82830f9d6a1941c3eb29683c1864ccf2862454", | |
urls = ["https://github.com/grailbio/bazel-toolchain/archive/5f82830f9d6a1941c3eb29683c1864ccf2862454.tar.gz"], | |
sha256 = "", | |
) | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment