diff --git a/.github/workflows/hipo-fetch.yml b/.github/workflows/hipo-fetch.yml index 7a3791138b9..be2afe055e6 100644 --- a/.github/workflows/hipo-fetch.yml +++ b/.github/workflows/hipo-fetch.yml @@ -115,7 +115,8 @@ jobs: -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_C_FLAGS="-m32" \ -DCMAKE_CXX_FLAGS="-m32" \ - -DCMAKE_SHARED_LINKER_FLAGS="-m32" + -DCMAKE_SHARED_LINKER_FLAGS="-m32" \ + -DALL_TESTS=${{ matrix.all_tests }} - name: Build working-directory: ${{runner.workspace}}/build @@ -207,7 +208,8 @@ jobs: run: | export CC=arm-linux-gnueabihf-gcc export CXX=arm-linux-gnueabihf-g++ - cmake $GITHUB_WORKSPACE + cmake $GITHUB_WORKSPACE \ + -DALL_TESTS=${{ matrix.all_tests }} - name: Build working-directory: ${{runner.workspace}}/build diff --git a/.github/workflows/hipo.yml b/.github/workflows/hipo.yml index 84727731ec5..46819971d31 100644 --- a/.github/workflows/hipo.yml +++ b/.github/workflows/hipo.yml @@ -264,7 +264,8 @@ jobs: working-directory: ${{runner.workspace}}/build run: | cmake $GITHUB_WORKSPACE -DHIPO=ON -DBUILD_OPENBLAS=ON \ - -DALL_TESTS=${{ matrix.all_tests }} + -DALL_TESTS=${{ matrix.all_tests }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.config }} - name: Build working-directory: ${{runner.workspace}}/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ee58fd8d7..25fdc73071d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") find_package(IntelSYCL REQUIRED) endif() +# MSVC +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") message(STATUS "Git hash: " ${GITHASH}) # By default only build the C++ library. diff --git a/README.md b/README.md index deb1644baed..494ae0674c7 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ - [Fortran](#fortran) - [Reference](#reference) + + ## About HiGHS HiGHS is a high performance serial and parallel solver for large scale sparse @@ -54,12 +56,18 @@ Find out more about HiGHS at https://www.highs.dev. Although HiGHS is freely available under the MIT license, we would be pleased to learn about users' experience and give advice via email sent to highsopt@gmail.com. + + ## Documentation Documentation is available at https://ergo-code.github.io/HiGHS/. + + ## Installation + + ### Build from source using CMake HiGHS uses CMake as build system, and requires at least version 3.15. To generate build files in a new subdirectory called 'build', run: @@ -77,6 +85,8 @@ To test whether the compilation was successful, change into the build directory ``` More details on building with CMake can be found in `HiGHS/cmake/README.md`. + + #### Build with Meson As an alternative, HiGHS can be installed using the `meson` build interface: @@ -86,6 +96,8 @@ meson test -C bbdir ``` _The meson build files are provided by the community and are not officially supported by the HiGHS development team._ **If you use this method and encounter issues, please consider contributing fixes or updates by checking the [HiGHS Contribution Guide](https://github.com/ERGO-Code/HiGHS/blob/master/CONTRIBUTING.md).** + + #### Build with Nix There is a nix flake that provides the `highs` binary: @@ -120,14 +132,20 @@ python _The nix build files are provided by the community and are not officially supported by the HiGHS development team._ + + ### Precompiled binaries -Precompiled static executables are available for a variety of platforms at -https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases +From v1.13.0 onwards, precompiled static binaries are available at https://github.com/ERGO-Code/HiGHS/releases. + +Additionally, there is one package containing shared libraries for Windows x64. -_These binaries are provided by the Julia community and are not officially supported by the HiGHS development team. If you have trouble using these libraries, please open a GitHub issue and tag `@odow` in your question._ +The `*-mit` binary packages contain HiGHS and are MIT-licenced. +The `*-apache` binary packages contain HiGHS with HiPO and are Apache-licenced, due to the licensing of the dependencies of HiPO. For more information, see [THIRD_PARTY_NOTICES.md](https://github.com/ERGO-Code/HiGHS/blob/master/THIRD_PARTY_NOTICES.md). -See https://ergo-code.github.io/HiGHS/stable/installation/#Precompiled-Binaries. +If you have any questions or requests for more platforms and binaries, please get in touch with us at hello@highs.dev. + + ## Running HiGHS @@ -185,12 +203,16 @@ options: ``` For a full list of options, see the [options page](https://ergo-code.github.io/HiGHS/stable/options/definitions/) of the documentation website. + + ## Interfaces There are HiGHS interfaces for C, C#, FORTRAN, and Python in `HiGHS/highs/interfaces`, with example driver files in `HiGHS/examples/`. More on language and modelling interfaces can be found at https://ergo-code.github.io/HiGHS/stable/interfaces/other/. We are happy to give a reasonable level of support via email sent to highsopt@gmail.com. + + ### Python The python package `highspy` is a thin wrapper around HiGHS and is available on [PyPi](https://pypi.org/project/highspy/). It can be easily installed via `pip` by running @@ -212,9 +234,13 @@ The installation can be tested using the small example `HiGHS/examples/call_high The [Google Colab Example Notebook](https://colab.research.google.com/drive/1JmHF53OYfU-0Sp9bzLw-D2TQyRABSjHb?usp=sharing) also demonstrates how to call `highspy`. + + ### C The C API is in `HiGHS/highs/interfaces/highs_c_api.h`. It is included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/. + + ### CSharp The nuget package Highs.Native is on https://www.nuget.org, at https://www.nuget.org/packages/Highs.Native/. @@ -236,11 +262,15 @@ The nuget package contains runtime libraries for Details for building locally can be found in `nuget/README.md`. + + ### Fortran The Fortran API is in `HiGHS/highs/interfaces/highs_fortran_api.f90`. It is *not* included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/. + + ## Reference If you use HiGHS in an academic context, please acknowledge this and cite the following article. diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt index c35dd4cb550..73a39286809 100644 --- a/check/CMakeLists.txt +++ b/check/CMakeLists.txt @@ -286,9 +286,17 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY)) # "--parallel=on" ) + if ((CMAKE_SIZEOF_VOID_P EQUAL 4) OR + (CMAKE_C_FLAGS MATCHES "-m32" OR CMAKE_CXX_FLAGS MATCHES "-m32")) + set(IS_32 ON) + else() + set(IS_32 OFF) + endif() + if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" - AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64") + AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64" + AND NOT IS_32) if (CUPDLP_GPU) set(pdlpInstances "25fv47\; 5.501847\;" @@ -442,7 +450,7 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY)) add_instancetests(successRiscVInstances "Optimal") endif() elseif(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64") AND - NOT (CMAKE_SIZEOF_VOID_P EQUAL 4)) + NOT IS_32) add_instancetests(successInstances "Optimal") endif() diff --git a/cmake/FindHipoDeps.cmake b/cmake/FindHipoDeps.cmake index 5519d4326d7..50aae66c4d2 100644 --- a/cmake/FindHipoDeps.cmake +++ b/cmake/FindHipoDeps.cmake @@ -98,9 +98,10 @@ if (BUILD_OPENBLAS) endif() # Crucial for static linking: Force OpenBLAS to use the static runtime - if (NOT BUILD_SHARED_LIBS) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") - endif() + # if (NOT BUILD_SHARED_LIBS) + # set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + # endif() + # now global # list(APPEND OPENBLAS_MINIMAL_FLAGS -DUSE_THREAD=OFF) list(APPEND OPENBLAS_MINIMAL_FLAGS -DINTERFACE64=0) @@ -110,6 +111,30 @@ if (BUILD_OPENBLAS) # list(APPEND OPENBLAS_MINIMAL_FLAGS -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL) endif() + if(UNIX AND NOT APPLE) + execute_process( + COMMAND bash -c "grep -m1 'model name' /proc/cpuinfo | grep -i skylake" + RESULT_VARIABLE SKYLAKE_CHECK + OUTPUT_QUIET + ERROR_QUIET + ) + + if(SKYLAKE_CHECK EQUAL 0) + message(STATUS "Skylake detected - adjusting OpenBLAS target to avoid register spills") + set(OPENBLAS_TARGET "HASWELL" CACHE STRING "OpenBLAS target architecture" FORCE) + set(NO_AVX512 ON CACHE BOOL "Disable AVX512" FORCE) + # set(CMAKE_C_FLAGS_OPENBLAS "-DTARGET=HASWELL -DNO_AVX512=1") + else() + message(STATUS " NOT Skylake") + endif() + endif() + + set(OPENBLAS_BUILD_TYPE "Release" CACHE STRING "Build type for OpenBLAS" FORCE) + + # Override CMAKE_BUILD_TYPE for OpenBLAS subdirectory + set(CMAKE_BUILD_TYPE_BACKUP ${CMAKE_BUILD_TYPE}) + set(CMAKE_BUILD_TYPE Release) + message(CHECK_START "Fetching OpenBLAS") list(APPEND CMAKE_MESSAGE_INDENT " ") FetchContent_Declare( @@ -118,7 +143,16 @@ if (BUILD_OPENBLAS) GIT_TAG "v0.3.30" GIT_SHALLOW TRUE UPDATE_COMMAND git reset --hard - CMAKE_ARGS ${OPENBLAS_MINIMAL_FLAGS} + CMAKE_ARGS + ${OPENBLAS_MINIMAL_FLAGS} + # Force optimization even in Debug builds to avoid register spills + # Force high optimization and strip debug symbols for the kernels + # -DCMAKE_BUILD_TYPE=Release + # -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS_OPENBLAS} + # -DCMAKE_C_FLAGS="-O3 -fomit-frame-pointer" + # -DCMAKE_C_FLAGS_RELEASE="-O3 -fomit-frame-pointer" + # -DCMAKE_C_FLAGS_DEBUG="-O2 -fomit-frame-pointer" + # -DCORE_OPTIMIZATION="-O3" ) FetchContent_MakeAvailable(openblas) @@ -126,6 +160,8 @@ if (BUILD_OPENBLAS) set(BUILD_TESTING ON) endif() + set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_BACKUP}) + list(POP_BACK CMAKE_MESSAGE_INDENT) message(CHECK_PASS "fetched") diff --git a/docs/src/installation.md b/docs/src/installation.md index 7dd4c35d6c7..04e9817cb83 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -7,43 +7,63 @@ HiGHS uses CMake as build system, and requires at least version ## HiGHS with HiPO -HiGHS does not have any external dependencies, however, the new interior point solver HiPO uses BLAS. At the moment HiPO is optional and can be enabled via CMake. To build HiPO, you need to have BLAS installed on your machine. Please follow the instructions below. +HiGHS does not have any external dependencies, however, the new interior point solver HiPO uses BLAS. At the moment HiPO is optional and can be enabled via CMake. -#### BLAS +### External ordering heuristics -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 +HiPO also relies on a fill-reducing ordering heuristic. HiGHS includes the source code of Metis, AMD and RCM, three open-source ordering heuristics. Their source code is already part of the HiGHS library, so there is no need to link them. In particular, there is no need to have Metis installed separately, as in previous versions of HiPO. These source codes can be found in extern/metis, extern/amd, extern/rcm, together with the respective license files. Notice that the HiGHS source code is MIT licensed. However, if you build HiGHS with HiPO support, then libhighs and the HiGHS executables are licensed Apache 2.0, due to the presence of Metis and AMD. -``` -sudo apt update -sudo apt install libopenblas-dev -``` +### BLAS On MacOS no BLAS installation is required because HiPO uses [Apple Accelerate](https://developer.apple.com/accelerate/) by default. -On Windows, OpenBLAS is required. It could be installed via [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/overview) with +On Windows and Linux, you can either compile OpenBLAS at configure time using the option `-DBUILD_OPENBLAS=ON` (`OFF` by default) or compile BLAS using the instructions below. +#### MacOS + +To build HiPO on MacOS, run ``` -vcpkg install openblas[threads] +cmake -S. -B build -DHIPO=ON ``` -Note, that `[threads]` is required for HiPO. -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`. +#### Linux and Windows: Compile OpenBLAS at configure time + +``` +cmake -S. -B build -DHIPO=ON -DBUILD_OPENBLAS=ON +``` -#### External ordering heuristics +#### Linux and Windows: Link with BLAS installatied on your machine -HiPO also relies on a fill-reducing ordering heuristic. HiGHS includes the source code of Metis, AMD and RCM, three open-source ordering heuristics. Their source code is already part of the HiGHS library, so there is no need to link them. In particular, there is no need to have Metis installed separately, as in previous versions of HiPO. These source codes can be found in extern/metis, extern/amd, extern/rcm, together with the respective license files. Notice that the HiGHS source code is MIT licensed. However, if you build HiGHS with HiPO support, then libhighs and the HiGHS executables are licensed Apache 2.0, due to the presence of Metis and AMD. +On Linux, libblas and libopenblas are supported. We recommend libopenblas for its better performance, and it is found by default if available on the system. Install with -### HiPO +``` +sudo apt update +sudo apt install libopenblas-dev +``` -To install HiPO, on Linux and MacOS, run +To build HiPO, run ``` cmake -S. -B build -DHIPO=ON ``` + +On Windows, OpenBLAS is required. It could be installed via [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/overview) with + +``` +vcpkg install openblas[threads] +``` + +Note, that `[threads]` is required for HiPO. + 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. ``` --DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" +cmake -S. -B build -DHIPO=ON -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ``` +##### Path to BLAS + +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`. + + ## Bazel build Alternatively, building with Bazel is supported for Bazel-based projects. To build HiGHS, from the root directory, run @@ -59,33 +79,16 @@ HiGHS can be installed using a package manager in the cases of ## Precompiled Binaries -_These binaries are provided by the Julia community and are not officially -supported by the HiGHS development team. If you have trouble using these -libraries, please open a GitHub issue and tag `@odow` in your question._ - -Precompiled static executables are available for a variety of platforms at - - * [https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases](https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases) - -Multiple versions are available. Each version has the form `vX.Y.Z`. In -general, you should choose the most recent version. - -To install a precompiled binary, download the appropriate `HiGHSstatic.vX.Y.Z.[platform-string].tar.gz` -file and extract the executable located at `/bin/highs`. +From v1.13.0 onwards, precompiled static binaries are available at https://github.com/ERGO-Code/HiGHS/releases. -Do not download the file starting with `HiGHSstatic-logs`. These files contain -information from the automated compilation system. Click "Show all N assets" -to see more files. +Additionally, there is one package containing shared libraries for Windows x64. -### Platform strings +The `*-mit` binary packages contain HiGHS and are MIT-licenced. +The `*-apache` binary packages contain HiGHS with HiPO and are Apache-licenced, due to the licensing of the dependencies of HiPO. For more information, see [THIRD_PARTY_NOTICES.md](https://github.com/ERGO-Code/HiGHS/blob/master/THIRD_PARTY_NOTICES.md). -The GitHub releases contain precompiled binaries for a number of different -platforms. These are indicated by the platform-specific string in each -filename. +If you have any questions or requests for more platforms and binaries, please get in touch with us at hello@highs.dev. - * For Windows users: choose the file ending in `x86_64-w64-mingw32-cxx11.tar.gz` - * For M1 macOS users: choose the file ending in `aarch64-apple-darwin.tar.gz` - * For Intel macOS users: choose the file ending in `x86_64-apple-darwin.tar.gz` +To install a precompiled binary, download and extract the archive corresponding to your Operating System and architecture, the executable is located at `/bin/highs`. ## [Building HiGHS with NVidia GPU support](@id gpu-build)