Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_cuda//cuda:defs.bzl", "cuda_library", "requires_cuda")

copy_file(
name = "highs-config",
Expand All @@ -8,12 +10,43 @@ copy_file(
visibility = ["//visibility:public"],
)

bool_flag(
name = "cupdlp_gpu",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
name = "cupdlp_gpu_enabled",
flag_values = {
"@rules_cuda//cuda:enable": "True",
"@local_cuda//:valid_toolchain_found": "True",
":cupdlp_gpu": "True",
},
)

cc_library(
name = "config",
srcs = ["HConfig.h"],
visibility = ["//visibility:public"],
)

cuda_library(
name = "cupdlp",
srcs = glob([
"highs/pdlp/cupdlp/cuda/*.cu",
]),
hdrs = glob([
"highs/pdlp/cupdlp/cuda/*.cuh",
]),
defines = ["CUPDLP_GPU"],
target_compatible_with = requires_cuda(),
deps = [
"@local_cuda//:cublas",
"@local_cuda//:cusparse",
],
)

cc_library(
name = "highs",
srcs = ["highs/interfaces/highs_c_api.cpp"] + glob([
Expand Down Expand Up @@ -49,6 +82,10 @@ cc_library(
"-Wno-unused-but-set-variable",
],
}),
defines = select({
":cupdlp_gpu_enabled": ["CUPDLP_GPU"],
"//conditions:default": ["CUPDLP_CPU"],
}),
includes = [
"extern",
# "extern/filereaderlp",
Expand All @@ -66,7 +103,6 @@ cc_library(
# "highs/simplex",
# "highs/test_kkt",
# "highs/util",
"bazel-bin",
],
linkopts = select({
"@rules_cc//cc/compiler:msvc-cl": ["-DEFAULTLIB:shell32.lib"],
Expand All @@ -76,7 +112,10 @@ cc_library(
deps = [
"//:config",
"@zlib",
],
] + select({
":cupdlp_gpu_enabled": [":cupdlp"],
"//conditions:default": [],
}),
)

cc_library(
Expand Down
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ bazel_dep(
name = "zlib",
version = "1.3.1.bcr.5",
)

bazel_dep(
name = "rules_cuda",
version = "0.2.5",
)

local_cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
local_cuda.local_toolchain(
toolkit_path = "",
)
use_repo(local_cuda, "local_cuda")
1 change: 0 additions & 1 deletion highs/HConfig.h.bazel.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#define FAST_BUILD
/* #undef ZLIB_FOUND */
#define CUPDLP_CPU
#define CMAKE_BUILD_TYPE "RELEASE"
#define HiGHSRELEASE
/* #undef HIGHSINT64 */
Expand Down
10 changes: 10 additions & 0 deletions highs/pdlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ When both work, on Linux, you should check that `/usr/local/cuda` exists.

#### Build

##### CMake

```
cmake -S . -B build -DCUPDLP_GPU=ON -DALL_TESTS=ON ..
cmake --build build --parallel
```

##### Bazel

```bash
# Will NOT build with CUDA, only CPU support
bazel build //:highs
# Will build with CUDA if a CUDA toolchain is detected
bazel build //:highs --//:cupdlp_gpu
```
Loading