Skip to content

Commit 6fce2a5

Browse files
authored
Merge pull request #2591 from ERGO-Code/hipo-dev
BLAS order, default, printing out of blas libraries from HiGHS, docs update
2 parents dc5729c + 58f2871 commit 6fce2a5

File tree

4 files changed

+69
-29
lines changed

4 files changed

+69
-29
lines changed

cmake/FindHipoDeps.cmake

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# BLAS
2-
set(USE_CMAKE_FIND_BLAS ON)
3-
42
set(BLAS_ROOT "" CACHE STRING "Root directory of BLAS or OpenBLAS")
5-
if (NOT (BLAS_ROOT STREQUAL ""))
3+
if (NOT BLAS_ROOT STREQUAL "")
64
message(STATUS "BLAS_ROOT is " ${BLAS_ROOT})
75
endif()
86

7+
set(USE_CMAKE_FIND_BLAS ON)
8+
99
# Optionally set the vendor:
1010
# set(BLA_VENDOR libblastrampoline)
1111

@@ -100,12 +100,39 @@ if (NOT USE_CMAKE_FIND_BLAS)
100100
endif()
101101
endif()
102102
else()
103-
find_package(BLAS REQUIRED)
104-
if (BLAS_FOUND)
105-
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
106-
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
103+
104+
if (NOT BLA_VENDOR)
105+
if (APPLE)
106+
set (BLA_VENDOR Apple)
107+
elseif(LINUX)
108+
set (BLA_VENDOR OpenBLAS)
109+
elseif(WIN32)
110+
set (BLA_VENDOR OpenBLAS)
111+
endif()
112+
113+
find_package(BLAS QUIET)
114+
if (BLAS_FOUND)
115+
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
116+
if (BLAS_INCLUDE_DIRS)
117+
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
118+
endif()
119+
else()
120+
unset(BLA_VENDOR)
121+
endif()
107122
else()
108-
message(FATAL_ERROR "No BLAS library found!")
123+
message(STATUS "Specified BLA_VENDOR: ${BLA_VENDOR}")
124+
endif()
125+
126+
if (NOT BLAS_FOUND)
127+
find_package(BLAS REQUIRED)
128+
if (BLAS_FOUND)
129+
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
130+
if (BLAS_INCLUDE_DIRS)
131+
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
132+
endif()
133+
else()
134+
message(FATAL_ERROR "No BLAS library found!")
135+
endif()
109136
endif()
110137
endif()
111138

docs/src/installation.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Install HiGHS
22

3-
## Compile from source
3+
## Compile from source
44

55
HiGHS uses CMake as build system, and requires at least version
66
3.15. Details about building from source using CMake can be found in `HiGHS/cmake/README.md`.
@@ -11,62 +11,64 @@ HiGHS does not have any external dependencies, however, the new interior point s
1111

1212
#### BLAS
1313

14-
On Linux, libblas and libopenblas are supported. We recomment libopenblas for its better performance. Install with
14+
On Linux, libblas and libopenblas are supported. We recomment libopenblas for its better performance, and it is found by default if available on the system. Install with
1515

1616
```
1717
sudo apt update
1818
sudo apt install libopenblas-dev
1919
```
2020

21-
On MacOS no BLAS installation is required because HiPO uses [Apple Accelerate](https://developer.apple.com/accelerate/).
21+
On MacOS no BLAS installation is required because HiPO uses [Apple Accelerate](https://developer.apple.com/accelerate/) by default.
2222

23-
On Windows, OpenBLAS is required. It could be installed via [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/overview) with
23+
On Windows, OpenBLAS is required. It could be installed via [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/overview) with
2424

2525
```
2626
vcpkg install openblas[threads]
2727
```
2828
Note, that `[threads]` is required for HiPO.
2929

30+
To specify explicitly which BLAS vendor to look for, `BLA_VENDOR` coud be set in CMake, e.g. `-DBLA_VENDOR=Apple` or `-DBLA_VENDOR=OpenBLAS`. Alternatively, to specify which BLAS library to use, set `BLAS_LIBRARIES` to the full path of the library e.g. `-DBLAS_LIBRARIES=/path_to/libopenblas.so`.
31+
3032
#### Metis
31-
There are some known issues with Metis so the recommented version is in [this fork](https://github.com/galabovaa/METIS/tree/510-ts), branch 510-ts. This is version 5.10 with several patches for more reliable build and execution. Clone the repository with
33+
There are some known issues with Metis so the recommented version is in [this fork](https://github.com/galabovaa/METIS/tree/510-ts), branch 510-ts. This is version 5.10 with several patches for more reliable build and execution. Clone the repository with
3234
```
3335
git clone https://github.com/galabovaa/METIS.git
3436
cd METIS
3537
git checkout 510-ts
3638
```
3739

38-
Then build with
40+
Then build with
3941
```
4042
cmake -S. -B build
4143
-DGKLIB_PATH=/path_to_METIS_repo/GKlib
42-
-DCMAKE_INSTALL_PREFIX=path_to_installs_dir
44+
-DCMAKE_INSTALL_PREFIX=path_to_installs_dir
4345
cmake --build build
44-
cmake --install build
46+
cmake --install build
4547
```
4648

47-
On Windows, do not forget to specify configuration type
49+
On Windows, do not forget to specify configuration type
4850
```
4951
cmake --build build --config Release
5052
```
5153

52-
### HiPO
54+
### HiPO
5355

54-
To install HiPO, on Linux and MacOS, run
56+
To install HiPO, on Linux and MacOS, run
5557
```
56-
cmake -S. -B build -DHIPO=ON -DMETIS_ROOT=path_to_installs_dir
58+
cmake -S. -B build -DHIPO=ON -DMETIS_ROOT=path_to_installs_dir
5759
```
5860
On Windows, you also need to specify the path to OpenBLAS. If it was installed with vcpkg as suggested above, add the path to `vcpkg.cmake` to the CMake flags, e.g.
5961
```
6062
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
6163
```
6264

63-
## Bazel build
65+
## Bazel build
6466

65-
Alternatively, building with Bazel is supported for Bazel-based projects. To build HiGHS, from the root directory, run
67+
Alternatively, building with Bazel is supported for Bazel-based projects. To build HiGHS, from the root directory, run
6668

6769
```
6870
bazel build //...
69-
```
71+
```
7072

7173
## Install via a package manager
7274

@@ -105,7 +107,7 @@ filename.
105107

106108
## [Building HiGHS with NVidia GPU support](@id gpu-build)
107109

108-
HiGHS must be built, from the root directory, with
110+
HiGHS must be built, from the root directory, with
109111

110112
```
111113
cmake -S. -Bbuild -DCUPDLP_GPU=ON
@@ -117,21 +119,21 @@ This uses [FindCUDAToolkit](https://cmake.org/cmake/help/latest/module/FindCUDAT
117119

118120
#### Find CUDA
119121

120-
If CUDA is not found automatically, there is an extra option `-DCUPDLP_FIND_CUDA=ON`, to be used with `-DCUPDLP_GPU=ON`, which instead uses `cuPDLP-C`'s `FindCUDAConf.cmake`.
122+
If CUDA is not found automatically, there is an extra option `-DCUPDLP_FIND_CUDA=ON`, to be used with `-DCUPDLP_GPU=ON`, which instead uses `cuPDLP-C`'s `FindCUDAConf.cmake`.
121123

122-
This requires the environment variable `CUDA_HOME` to be set to the directory with the CUDA installation. Having set this, run
124+
This requires the environment variable `CUDA_HOME` to be set to the directory with the CUDA installation. Having set this, run
123125

124126
```
125127
cmake -S. -Bbuild -DCUPDLP_GPU=ON -DCUPDLP_FIND_CUDA=ON
126128
cmake --build build --parallel
127129
```
128130

129-
to build HiGHS.
131+
to build HiGHS.
130132

131133
### Bazel build with Cuda
132134

133-
Alternatively, for Bazel run
135+
Alternatively, for Bazel run
134136

135137
```
136138
bazel build //... --//:cupdlp_gpu
137-
```
139+
```

highs/HConfig.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#cmakedefine HIGHS_HAVE_MM_PAUSE
1313
#cmakedefine HIGHS_HAVE_BUILTIN_CLZ
1414
#cmakedefine HIGHS_HAVE_BITSCAN_REVERSE
15+
#cmakedefine BLAS_LIBRARIES "@BLAS_LIBRARIES@"
1516

1617
#define HIGHS_GITHASH "@GITHASH@"
1718
#define HIGHS_VERSION_MAJOR @HIGHS_VERSION_MAJOR@

highs/ipm/hipo/ipm/Solver.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,11 +1421,21 @@ void Solver::printOutput() const {
14211421
void Solver::printInfo() const {
14221422
std::stringstream log_stream;
14231423
log_stream << "\nRunning HiPO\n";
1424+
1425+
// Print blas path
1426+
#ifdef BLAS_LIBRARIES
1427+
log_stream << textline("BLAS:") << BLAS_LIBRARIES << '\n';
1428+
#else
1429+
log_stream << textline("BLAS:") << "Unknown\n";
1430+
#endif
1431+
1432+
// Print number of threads
14241433
if (options_.parallel == kOptionParallelOff)
14251434
log_stream << textline("Threads:") << 1 << '\n';
14261435
else
14271436
log_stream << textline("Threads:") << highs::parallel::num_threads()
14281437
<< '\n';
1438+
14291439
logH_.print(log_stream);
14301440

14311441
// print information about model

0 commit comments

Comments
 (0)