1+ load ("@bazel_skylib//rules:common_settings.bzl" , "bool_flag" )
12load ("@bazel_skylib//rules:copy_file.bzl" , "copy_file" )
23load ("@rules_cc//cc:defs.bzl" , "cc_binary" , "cc_library" , "cc_test" )
4+ load ("@rules_cuda//cuda:defs.bzl" , "cuda_library" , "requires_cuda" )
35
46copy_file (
57 name = "highs-config" ,
@@ -8,12 +10,43 @@ copy_file(
810 visibility = ["//visibility:public" ],
911)
1012
13+ bool_flag (
14+ name = "cupdlp_gpu" ,
15+ build_setting_default = False ,
16+ visibility = ["//visibility:public" ],
17+ )
18+
19+ config_setting (
20+ name = "cupdlp_gpu_enabled" ,
21+ flag_values = {
22+ "@rules_cuda//cuda:enable" : "True" ,
23+ "@local_cuda//:valid_toolchain_found" : "True" ,
24+ ":cupdlp_gpu" : "True" ,
25+ },
26+ )
27+
1128cc_library (
1229 name = "config" ,
1330 srcs = ["HConfig.h" ],
1431 visibility = ["//visibility:public" ],
1532)
1633
34+ cuda_library (
35+ name = "cupdlp" ,
36+ srcs = glob ([
37+ "highs/pdlp/cupdlp/cuda/*.cu" ,
38+ ]),
39+ hdrs = glob ([
40+ "highs/pdlp/cupdlp/cuda/*.cuh" ,
41+ ]),
42+ defines = ["CUPDLP_GPU" ],
43+ target_compatible_with = requires_cuda (),
44+ deps = [
45+ "@local_cuda//:cublas" ,
46+ "@local_cuda//:cusparse" ,
47+ ],
48+ )
49+
1750cc_library (
1851 name = "highs" ,
1952 srcs = ["highs/interfaces/highs_c_api.cpp" ] + glob ([
@@ -49,6 +82,10 @@ cc_library(
4982 "-Wno-unused-but-set-variable" ,
5083 ],
5184 }),
85+ defines = select ({
86+ ":cupdlp_gpu_enabled" : ["CUPDLP_GPU" ],
87+ "//conditions:default" : ["CUPDLP_CPU" ],
88+ }),
5289 includes = [
5390 "extern" ,
5491 # "extern/filereaderlp",
@@ -66,7 +103,6 @@ cc_library(
66103 # "highs/simplex",
67104 # "highs/test_kkt",
68105 # "highs/util",
69- "bazel-bin" ,
70106 ],
71107 linkopts = select ({
72108 "@rules_cc//cc/compiler:msvc-cl" : ["-DEFAULTLIB:shell32.lib" ],
@@ -76,7 +112,10 @@ cc_library(
76112 deps = [
77113 "//:config" ,
78114 "@zlib" ,
79- ],
115+ ] + select ({
116+ ":cupdlp_gpu_enabled" : [":cupdlp" ],
117+ "//conditions:default" : [],
118+ }),
80119)
81120
82121cc_library (
0 commit comments