Skip to content

Commit 001b1df

Browse files
committed
Merge branch 'latest' into fix-col-stuffing
2 parents 75489fd + 586c324 commit 001b1df

11 files changed

Lines changed: 111 additions & 47 deletions

File tree

.github/workflows/build-nuget-package.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: build-nuget-package
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Package version (e.g. 1.14.0-preview.1)'
8+
required: true
9+
default: '1.14.0-preview.1'
10+
push_package:
11+
description: 'Push package to NuGet.org'
12+
type: boolean
13+
default: false
514
pull_request:
615
release:
716
types:
@@ -75,7 +84,7 @@ jobs:
7584
- name: Configure CMake win32
7685
shell: bash
7786
working-directory: ${{github.workspace}}/build32
78-
run: cmake $GITHUB_WORKSPACE -DCSHARP=ON -DBUILD_DOTNET=ON -A Win32
87+
run: cmake $GITHUB_WORKSPACE -DCSHARP=ON -DBUILD_DOTNET=ON -A Win32 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
7988

8089
- name: Build win32
8190
shell: bash
@@ -84,8 +93,8 @@ jobs:
8493

8594
- uses: actions/upload-artifact@v7
8695
with:
87-
name: win-x32
88-
path: ${{github.workspace}}/build32/dotnet/Highs.Native/runtimes/win-x64/
96+
name: win-x86
97+
path: ${{github.workspace}}/build32/dotnet/Highs.Native/runtimes/win-x86/
8998

9099
build_linux:
91100
runs-on: ubuntu-latest
@@ -145,7 +154,7 @@ jobs:
145154
- name: Configure CMake
146155
working-directory: ${{github.workspace}}/build
147156
shell: bash
148-
run: cmake $GITHUB_WORKSPACE -DCSHARP=ON -DBUILD_DOTNET=ON
157+
run: cmake $GITHUB_WORKSPACE -DCSHARP=ON -DBUILD_DOTNET=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
149158

150159
- name: Build
151160
working-directory: ${{github.workspace}}/build
@@ -169,11 +178,11 @@ jobs:
169178
name: macos-arm64
170179
path: ${{github.workspace}}/build/dotnet/Highs.Native/runtimes
171180

172-
- name: Download runtimes win-x32
181+
- name: Download runtimes win-x86
173182
uses: actions/download-artifact@v8
174183
with:
175-
name: win-x32
176-
path: ${{github.workspace}}/build/dotnet/Highs.Native/runtimes/win-x32
184+
name: win-x86
185+
path: ${{github.workspace}}/build/dotnet/Highs.Native/runtimes/win-x86
177186

178187
- name: Download runtimes
179188
uses: actions/download-artifact@v8
@@ -196,7 +205,7 @@ jobs:
196205

197206
- name: Dotnet pack
198207
working-directory: ${{github.workspace}}/build/dotnet/Highs.Native
199-
run: dotnet pack -c Release /p:Version=1.14.0
208+
run: dotnet pack -c Release /p:Version=${{ inputs.version || '1.14.0' }}
200209

201210
- uses: actions/upload-artifact@v7
202211
with:
@@ -211,7 +220,7 @@ jobs:
211220
permissions:
212221
id-token: write # enable GitHub OIDC token issuance for this job
213222

214-
if: github.event_name == 'release'
223+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.push_package)
215224
steps:
216225
- uses: actions/checkout@v6
217226
- uses: actions/setup-dotnet@v5

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ dotnet add package Highs.Native --version 1.14.0
262262
The nuget package contains runtime libraries for
263263

264264
* `win-x64`
265-
* `win-x32`
265+
* `win-x86`
266266
* `linux-x64`
267267
* `linux-arm64`
268268
* `macos-x64`

check/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test_array = [
3333
['test_TestHighsRbTree', 'TestHighsRbTree.cpp'],
3434
['test_TestHighsSparseMatrix', 'TestHighsSparseMatrix.cpp'],
3535
['test_TestHighsVersion', 'TestHighsVersion.cpp'],
36-
['test_TestHipo', 'TestHipo.cpp'],
36+
# ['test_TestHipo', 'TestHipo.cpp'],
3737
['test_TestHSet', 'TestHSet.cpp'],
3838
['test_TestICrash', 'TestICrash.cpp'],
3939
['test_TestIis', 'TestIis.cpp'],

cmake/dotnet.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ set(DOTNET_PACKAGES_DIR "${PROJECT_BINARY_DIR}/dotnet")
1313
# see: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
1414
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
1515
set(DOTNET_PLATFORM arm64)
16+
elseif(WIN32 AND (CMAKE_GENERATOR_PLATFORM STREQUAL "Win32" OR CMAKE_SIZEOF_VOID_P EQUAL 4))
17+
set(DOTNET_PLATFORM x86)
1618
else()
1719
set(DOTNET_PLATFORM x64)
1820
endif()

docs/src/interfaces/csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dotnet add package Highs.Native --version 1.14.0
2323
The nuget package contains runtime libraries for
2424

2525
* `win-x64`
26-
* `win-x32`
26+
* `win-x86`
2727
* `linux-x64`
2828
* `linux-arm64`
2929
* `macos-x64`

highs/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ else()
377377
# see: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
378378
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
379379
set(DOTNET_PLATFORM arm64)
380+
elseif(WIN32 AND (CMAKE_GENERATOR_PLATFORM STREQUAL "Win32" OR CMAKE_SIZEOF_VOID_P EQUAL 4))
381+
set(DOTNET_PLATFORM x86)
380382
else()
381383
set(DOTNET_PLATFORM x64)
382384
endif()

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "FactorHiGHSSolver.h"
22

3+
#include <cstring>
34
#include <limits>
45

56
#include "HighsExternalApi.h"
@@ -572,6 +573,10 @@ Int FactorHiGHSSolver::setNla() {
572573
return kStatusOk;
573574
}
574575

576+
static bool usingAppleBlas() {
577+
return strstr(HighsExtras::blas::getInfo()->provider, "Apple") != nullptr;
578+
}
579+
575580
void FactorHiGHSSolver::setParallel() {
576581
// Set parallel options
577582
bool parallel_tree = false;
@@ -597,35 +602,35 @@ void FactorHiGHSSolver::setParallel() {
597602
assert(1 == 0);
598603

599604
} else if (options_.parallel == kHighsChooseString) {
600-
#ifdef HIPO_USES_APPLE_BLAS
601-
// Blas on Apple do not work well with parallel_node, but parallel_tree
602-
// seems to always be beneficial.
603-
parallel_node = false;
604-
parallel_tree = true;
605-
#else
606-
// Otherwise, parallel_node is active because it is triggered only if the
607-
// frontal matrix is large enough anyway.
608-
parallel_node = true;
609-
610-
// parallel_tree instead is chosen with a heuristic
611-
612-
double tree_speedup = S_.flops() / S_.critops();
613-
double sn_size = (double)S_.size() / S_.sn();
614-
615-
bool enough_sn = S_.sn() > kMinNumberSn;
616-
bool enough_flops = S_.flops() > kLargeFlopsThresh;
617-
bool speedup_is_large = tree_speedup > kLargeSpeedupThresh;
618-
bool sn_are_large = sn_size > kLargeSnThresh;
619-
bool sn_are_not_small = sn_size > kSmallSnThresh;
620-
621-
// parallel_tree is active if the supernodes are large, or if there is a
622-
// large expected speedup and the supernodes are not too small, provided
623-
// that the number of flops and supernodes is not too small.
624-
if (enough_sn && enough_flops &&
625-
(sn_are_large || (speedup_is_large && sn_are_not_small))) {
605+
if (usingAppleBlas()) {
606+
// Blas on Apple do not work well with parallel_node, but parallel_tree
607+
// seems to always be beneficial.
608+
parallel_node = false;
626609
parallel_tree = true;
610+
} else {
611+
// Otherwise, parallel_node is active because it is triggered only if the
612+
// frontal matrix is large enough anyway.
613+
parallel_node = true;
614+
615+
// parallel_tree instead is chosen with a heuristic
616+
617+
double tree_speedup = S_.flops() / S_.critops();
618+
double sn_size = (double)S_.size() / S_.sn();
619+
620+
bool enough_sn = S_.sn() > kMinNumberSn;
621+
bool enough_flops = S_.flops() > kLargeFlopsThresh;
622+
bool speedup_is_large = tree_speedup > kLargeSpeedupThresh;
623+
bool sn_are_large = sn_size > kLargeSnThresh;
624+
bool sn_are_not_small = sn_size > kSmallSnThresh;
625+
626+
// parallel_tree is active if the supernodes are large, or if there is a
627+
// large expected speedup and the supernodes are not too small, provided
628+
// that the number of flops and supernodes is not too small.
629+
if (enough_sn && enough_flops &&
630+
(sn_are_large || (speedup_is_large && sn_are_not_small))) {
631+
parallel_tree = true;
632+
}
627633
}
628-
#endif
629634

630635
// If serial memory is too large, switch off tree parallelism to avoid
631636
// running out of memory

highspy/CMakeLists.txt

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,46 @@ if (NOT MSVC)
5454
target_compile_options(_core PRIVATE "-ftemplate-depth=2048")
5555
endif()
5656

57+
if(CUPDLP_GPU)
58+
target_link_libraries(_core PRIVATE cudalin ${CUDA_LIBRARY})
59+
endif()
60+
5761
# The install directory is the output (wheel) directory
5862
install(TARGETS _core
5963
RUNTIME DESTINATION highspy
6064
LIBRARY DESTINATION highspy
6165
COMPONENT python)
6266

63-
# Only needed if the wheel is built with a shared library, but can be left in for static linking as well.
64-
# Include highs library (but ignore .lib file)
65-
install(TARGETS highs
66-
RUNTIME DESTINATION highspy
67-
LIBRARY DESTINATION highspy
68-
NAMELINK_SKIP
69-
COMPONENT python)
67+
if (CUPDLP_GPU)
68+
# Use install(FILES) to avoid CMake 4.x cross-directory install(TARGETS)
69+
# restrictions (silently ignored for targets owned by other directories).
70+
if (WIN32)
71+
install(FILES $<TARGET_FILE:highs>
72+
DESTINATION highspy
73+
COMPONENT python)
74+
else()
75+
install(FILES $<TARGET_FILE:highs>
76+
DESTINATION highspy
77+
RENAME $<TARGET_SONAME_FILE_NAME:highs>
78+
COMPONENT python)
79+
# install(FILES) does not update RPATH (unlike install(TARGETS)).
80+
# Without this, the embedded build-tree RPATH prevents libhighs from
81+
# finding libcudalin at $ORIGIN after installation.
82+
install(CODE "
83+
file(RPATH_SET
84+
FILE \"\${CMAKE_INSTALL_PREFIX}/highspy/$<TARGET_SONAME_FILE_NAME:highs>\"
85+
NEW_RPATH \"\$ORIGIN\")
86+
" COMPONENT python)
87+
endif()
88+
if (NOT HIGHS_GPU_LIB)
89+
install(FILES $<TARGET_FILE:cudalin>
90+
DESTINATION highspy
91+
COMPONENT python)
92+
endif()
93+
else()
94+
install(TARGETS highs
95+
RUNTIME DESTINATION highspy
96+
LIBRARY DESTINATION highspy
97+
NAMELINK_SKIP
98+
COMPONENT python)
99+
endif()

highspy/highspy/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
import os as _os
2+
import sys as _sys
3+
4+
if _sys.platform == "win32" and _os.path.exists(_os.path.join(_os.path.dirname(__file__), "cudalin.dll")):
5+
# Python 3.8+ no longer searches PATH when loading extension DLLs.
6+
# cudalin.dll is present only in GPU builds; register the CUDA bin directory
7+
# so cuda*.dll etc. are found when _core is loaded.
8+
_cuda_path = _os.environ.get("CUDA_PATH") or _os.environ.get("CUDA_HOME")
9+
if _cuda_path:
10+
_cuda_bin = _os.path.join(_cuda_path, "bin")
11+
if _os.path.isdir(_cuda_bin):
12+
_os.add_dll_directory(_cuda_bin)
13+
del _cuda_path
14+
del _os, _sys
15+
116
from ._core import (
217
ObjSense,
318
MatrixFormat,

nuget/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dotnet add package Highs.Native --version 1.14.0
1313
The nuget package contains runtime libraries for
1414

1515
* `win-x64`
16-
* `win-x32`
16+
* `win-x86`
1717
* `linux-x64`
1818
* `linux-arm64`
1919
* `macos-x64`

0 commit comments

Comments
 (0)