Skip to content

Commit ed429b8

Browse files
committed
added BLA_VENDOR for blas trampoline
1 parent 95bd12f commit ed429b8

File tree

4 files changed

+119
-83
lines changed

4 files changed

+119
-83
lines changed

.github/workflows/hipo-macos.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
ls
3636
3737
- name: Install GKlib Release
38-
working-directory: GKlib
3938
if: ${{ matrix.config == 'Release' }}
4039
run: |
4140
cd GKlib
@@ -44,7 +43,6 @@ jobs:
4443
make install
4544
4645
- name: Install GKlib Debug
47-
working-directory: GKlib
4846
if: ${{ matrix.config == 'Debug' }}
4947
run: |
5048
cd GKlib

.github/workflows/hipo-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
cd METIS
9797
pwd
9898
cmake -S. -B build `
99-
-DGKLIB_PATH="$env:$GITHUB_WORKSPACE/METIS/GKlib"
99+
-DGKLIB_PATH="$env:GITHUB_WORKSPACE/METIS/GKlib"
100100
-DCMAKE_INSTALL_PREFIX="${{ runner.workspace }}/installs" `
101101
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
102102
cmake --build build --parallel --config ${{ matrix.config }}

cmake/FindHipoDeps.cmake

Lines changed: 81 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,110 @@
22
set(BLAS_ROOT "" CACHE STRING "Root directory of BLAS or OpenBLAS")
33
message(STATUS "BLAS_ROOT is " ${BLAS_ROOT})
44

5-
if (WIN32)
6-
if (NOT (BLAS_ROOT STREQUAL ""))
7-
message(STATUS "Looking for blas in " ${BLAS_ROOT})
8-
set(OpenBLAS_ROOT ${BLAS_ROOT})
9-
message(STATUS "OpenBLAS_ROOT is ${OpenBLAS_ROOT} ")
10-
find_package(OpenBLAS CONFIG NO_DEFAULT_PATH)
11-
12-
if(OpenBLAS_FOUND)
13-
message(STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR}")
14-
else()
15-
message(STATUS "OpenBLAS not found in ${BLAS_ROOT}")
16-
endif()
5+
set(BLA_VENDOR "" CACHE STRING "For blas trampoline")
176

18-
endif()
19-
if ((BLAS_ROOT STREQUAL "") OR (NOT OpenBLAS_FOUND))
20-
message(STATUS "Looking for blas")
7+
# Optionally set the vendor:
8+
# set(BLA_VENDOR libblastrampoline)
219

22-
find_package(OpenBLAS REQUIRED)
10+
if (BLA_VENDOR STREQUAL "")
11+
if (WIN32)
12+
if (NOT (BLAS_ROOT STREQUAL ""))
13+
message(STATUS "Looking for blas in " ${BLAS_ROOT})
14+
set(OpenBLAS_ROOT ${BLAS_ROOT})
15+
message(STATUS "OpenBLAS_ROOT is ${OpenBLAS_ROOT} ")
16+
find_package(OpenBLAS CONFIG NO_DEFAULT_PATH)
2317

24-
if(OpenBLAS_FOUND)
25-
if(TARGET OpenBLAS::OpenBLAS)
18+
if(OpenBLAS_FOUND)
2619
message(STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR}")
27-
elseif(OPENBLAS_LIB)
28-
message(STATUS "Linking against OpenBLAS via raw library: ${OPENBLAS_LIB}")
2920
else()
30-
message(STATUS "OpenBLAS found but no target?")
21+
message(STATUS "OpenBLAS not found in ${BLAS_ROOT}")
3122
endif()
32-
else()
33-
message(FATAL_ERROR "No BLAS library found")
3423
endif()
35-
endif()
36-
elseif(NOT APPLE)
37-
# LINUX
3824

39-
# If a BLAS install was specified try to use it first.
40-
if (NOT (BLAS_ROOT STREQUAL ""))
41-
message(STATUS "Looking for blas in " ${BLAS_ROOT})
25+
if ((BLAS_ROOT STREQUAL "") OR (NOT OpenBLAS_FOUND))
26+
# (NOT OpenBLAS_FOUND AND NOT BLAS_FOUND))
27+
message(STATUS "Looking for blas")
28+
29+
find_package(OpenBLAS REQUIRED)
30+
31+
if(OpenBLAS_FOUND)
32+
if(TARGET OpenBLAS::OpenBLAS)
33+
message(STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR}")
34+
elseif(OPENBLAS_LIB)
35+
message(STATUS "Linking against OpenBLAS via raw library: ${OPENBLAS_LIB}")
36+
else()
37+
# try blas
38+
# find_package(BLAS)
39+
# if (BLAS_FOUND)
40+
# message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
41+
# message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
42+
# else()
43+
# message(STATUS "OpenBLAS found but no target?")
44+
# endif()
45+
endif()
46+
else()
47+
message(FATAL_ERROR "No BLAS library found")
48+
endif()
49+
endif()
4250

43-
find_library(OPENBLAS_LIB
44-
NAMES openblas
45-
HINTS "${BLAS_ROOT}/lib"
46-
NO_DEFAULT_PATH)
51+
elseif(NOT APPLE)
52+
# LINUX
4753

48-
if(OPENBLAS_LIB)
49-
message("Found OpenBLAS library at ${OPENBLAS_LIB}")
50-
else()
51-
find_library(BLAS_LIB
52-
NAMES blas
54+
# If a BLAS install was specified try to use it first.
55+
if (NOT (BLAS_ROOT STREQUAL ""))
56+
message(STATUS "Looking for blas in " ${BLAS_ROOT})
57+
58+
find_library(OPENBLAS_LIB
59+
NAMES openblas
5360
HINTS "${BLAS_ROOT}/lib"
5461
NO_DEFAULT_PATH)
5562

56-
if(BLAS_LIB)
57-
message("Found BLAS library at ${BLAS_LIB}")
63+
if(OPENBLAS_LIB)
64+
message("Found OpenBLAS library at ${OPENBLAS_LIB}")
5865
else()
59-
message("Did not find blas library at ${BLAS_ROOT}")
60-
message("Attempting default locations search")
66+
find_library(BLAS_LIB
67+
NAMES blas
68+
HINTS "${BLAS_ROOT}/lib"
69+
NO_DEFAULT_PATH)
70+
71+
if(BLAS_LIB)
72+
message("Found BLAS library at ${BLAS_LIB}")
73+
else()
74+
message("Did not find blas library at ${BLAS_ROOT}")
75+
message("Attempting default locations search")
76+
endif()
6177
endif()
6278
endif()
63-
endif()
64-
if ((BLAS_ROOT STREQUAL "") OR (NOT OPENBLAS_LIB AND NOT BLAS_LIB))
79+
if ((BLAS_ROOT STREQUAL "") OR (NOT OPENBLAS_LIB AND NOT BLAS_LIB))
6580

66-
find_library(OPENBLAS_LIB
67-
NAMES openblas
68-
HINTS "${BLAS_ROOT}/lib")
69-
70-
if(OPENBLAS_LIB)
71-
message("Found OpenBLAS library at ${OPENBLAS_LIB}")
72-
else()
73-
find_library(BLAS_LIB
74-
NAMES blas
81+
find_library(OPENBLAS_LIB
82+
NAMES openblas
7583
HINTS "${BLAS_ROOT}/lib")
7684

77-
if(BLAS_LIB)
78-
message("Found BLAS library at ${BLAS_LIB}")
85+
if(OPENBLAS_LIB)
86+
message("Found OpenBLAS library at ${OPENBLAS_LIB}")
7987
else()
80-
message(FATAL_ERROR "No BLAS library found")
88+
find_library(BLAS_LIB
89+
NAMES blas
90+
HINTS "${BLAS_ROOT}/lib")
91+
92+
if(BLAS_LIB)
93+
message("Found BLAS library at ${BLAS_LIB}")
94+
else()
95+
message(FATAL_ERROR "No BLAS library found")
96+
endif()
8197
endif()
8298
endif()
8399
endif()
100+
else()
101+
# if (NOT BLA_VENDOR STREQUALS "")
102+
find_package(BLAS REQUIRED)
103+
if (BLAS_FOUND)
104+
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
105+
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
106+
else()
107+
message(FATAL_ERROR "No BLAS library found!")
108+
endif()
84109
endif()
85110

86111
# METIS

highs/CMakeLists.txt

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -186,33 +186,46 @@ else()
186186
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/highs/hipo/ipm>
187187
)
188188

189-
if(APPLE)
190-
target_link_libraries(highs PRIVATE "-framework Accelerate")
191-
target_compile_definitions(highs PRIVATE HIPO_USES_APPLE_BLAS)
192-
elseif(WIN32)
193-
194-
if(TARGET OpenBLAS::OpenBLAS)
195-
target_link_libraries(highs PRIVATE OpenBLAS::OpenBLAS)
196-
elseif(OPENBLAS_LIB)
197-
message(STATUS "Linking against OpenBLAS via raw library: ${OPENBLAS_LIB}")
198-
target_link_libraries(highs PRIVATE ${OPENBLAS_LIB})
199-
target_include_directories(highs PRIVATE ${OPENBLAS_INCLUDE_DIR})
200-
else()
201-
message(FATAL_ERROR "OpenBLAS not found on Windows.")
202-
endif()
203-
204-
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
205-
else()
206-
# LINUX
207-
if(BLAS_LIB)
208-
target_link_libraries(highs PRIVATE "${BLAS_LIB}")
189+
if (BLA_VENDOR STREQUAL "")
190+
if(APPLE)
191+
target_link_libraries(highs PRIVATE "-framework Accelerate")
192+
target_compile_definitions(highs PRIVATE HIPO_USES_APPLE_BLAS)
193+
elseif(WIN32)
194+
if(TARGET OpenBLAS::OpenBLAS)
195+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
196+
target_link_libraries(highs PRIVATE OpenBLAS::OpenBLAS)
209197
elseif(OPENBLAS_LIB)
210-
target_link_libraries(highs PRIVATE "${OPENBLAS_LIB}")
211198
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
199+
message(STATUS "Linking against OpenBLAS via raw library: ${OPENBLAS_LIB}")
200+
target_link_libraries(highs PRIVATE ${OPENBLAS_LIB})
201+
target_include_directories(highs PRIVATE ${OPENBLAS_INCLUDE_DIR})
212202
else()
213-
message(FATAL_ERROR "No BLAS library available")
214-
endif(BLAS_LIB)
215-
endif(APPLE)
203+
message(FATAL_ERROR "OpenBLAS not found on Windows.")
204+
endif()
205+
206+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
207+
else()
208+
# LINUX
209+
if(BLAS_LIB)
210+
target_link_libraries(highs PRIVATE "${BLAS_LIB}")
211+
elseif(OPENBLAS_LIB)
212+
target_link_libraries(highs PRIVATE "${OPENBLAS_LIB}")
213+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
214+
else()
215+
message(FATAL_ERROR "No BLAS library available")
216+
endif(BLAS_LIB)
217+
endif(APPLE)
218+
else()
219+
# BLA_VENDOR Specified
220+
target_link_libraries(highs BLAS::BLAS)
221+
222+
string(TOLOWER "${BLAS_LIBRARIES}" blas_lower)
223+
if(blas_lower MATCHES "openblas")
224+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
225+
elseif(blas_lower MATCHES "accelerate")
226+
target_compile_definitions(highs PRIVATE HIPO_USES_APPLE_BLAS)
227+
endif()
228+
endif()
216229

217230
if(metis_FOUND)
218231
target_link_libraries(highs PRIVATE metis)

0 commit comments

Comments
 (0)