Skip to content

Commit b266dd3

Browse files
committed
Merge branch 'latest' into release-artefact
2 parents 4777221 + 37adc63 commit b266dd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3149
-770
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,7 @@ result
289289
highs-unit-tests
290290
highs-problem-set
291291

292+
# Generated HiGHS options file
293+
Options.md
294+
292295
build-latest

CMakeLists.txt

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,47 @@ set(DEBUG_MEMORY "Off" CACHE STRING "Sanitizers")
114114
# emscripten
115115
option(EMSCRIPTEN_HTML "Emscripten HTML output" OFF)
116116

117+
# option(CUPDLP_GPU "Build pdlp with CPU" ON)
118+
# message(STATUS "Build pdlp with CPU: ${CUPDLP_CPU}")
119+
120+
option(CUPDLP_GPU "Build pdlp with GPU" OFF)
121+
122+
message(STATUS "Build pdlp with GPU: ${CUPDLP_GPU}")
123+
124+
# if (NOT LINUX)
125+
# set (CUPDLP_GPU OFF)
126+
# message(STATUS "CUPLDP with Nvidia is only supported on Linux at the moment. Using CPU version.")
127+
# endif()
128+
129+
if (CUPDLP_GPU)
130+
if (WIN32)
131+
set(BUILD_SHARED_LIBS ON)
132+
endif()
133+
134+
set (CUPDLP_CPU OFF)
135+
136+
# With FindCUDAConf.cmake
137+
# default cuda_home on linux
138+
# set(CUDA_HOME "/usr/local/cuda" CACHE STRING "Cuda path to install")
139+
# message(NOTICE "Set build cuPDLP with CUDA")
140+
# list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
141+
# include(FindCUDAConf.cmake)
142+
143+
# With deleted FindCUDAConf.cmake
144+
find_package(CUDAToolkit REQUIRED)
145+
set(CUDA_LIBRARY-NOTFOUND, OFF)
146+
set(CUDA_LIBRARY CUDA::cudart CUDA::cublas CUDA::cusparse)
147+
148+
message(NOTICE "Set build cuPDLP with CUDA")
149+
else()
150+
set (CUPDLP_CPU ON)
151+
set(CUDA_LIBRARY-NOTFOUND true)
152+
endif()
153+
154+
# option to force native termination, mostly for testing new GPU code
155+
# in comparison with the CPU
156+
option(CUPDLP_FORCE_NATIVE "Build pdlp with native termination" OFF)
157+
117158
if (BUILD_CXX)
118159
# Default Build Type to be Release
119160
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
@@ -193,8 +234,9 @@ if (BUILD_CXX)
193234
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
194235
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
195236
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
196-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
197-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
237+
# elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
238+
# not recognised by cl
239+
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
198240
endif()
199241

200242
# Basic type
@@ -273,8 +315,14 @@ if (BUILD_CXX)
273315
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
274316
message(STATUS "IPO / LTO: enabled")
275317
endif()
318+
if (CUPDLP_GPU AND CMAKE_INTERPROCEDURAL_OPTIMIZATION)
319+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
320+
message(STATUS "IPO / LTO is not supported at the moment when PDLP is using GPU: LTO disabled.")
321+
endif()
322+
276323
endif()
277324

325+
278326
include(CheckCXXSourceCompiles)
279327
check_cxx_source_compiles(
280328
"#include <immintrin.h>
@@ -363,6 +411,25 @@ if(NOT(${HIGHS_NO_DEFAULT_THREADS} STREQUAL "OFF"))
363411
message(STATUS "Default multithreading: disabled")
364412
endif()
365413

414+
# For debug of cuda locally
415+
416+
# does not work with older CMake
417+
# add_compile_options("$<$<AND:$<CONFIG:Debug,RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-G>")
418+
419+
# add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:-G>")
420+
421+
if (CUPDLP_GPU AND UNIX)
422+
add_compile_options("-Wno-deprecated-declarations")
423+
endif()
424+
# add_compile_options("-Wno-implicit-function-declaration")
425+
426+
# set(CMAKE_C_FLAGS "-Wno-deprecated-declarations")
427+
if (UNIX)
428+
set(CMAKE_C_FLAGS "-Wno-implicit-function-declaration")
429+
endif()
430+
431+
432+
366433
# If Visual Studio targets are being built.
367434
if(MSVC)
368435
# add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/W0>")
@@ -373,8 +440,15 @@ if(MSVC)
373440

374441
# Try to split large pdb files into objects.
375442
# https://github.com/tensorflow/tensorflow/issues/31610
376-
add_compile_options("/Z7")
377-
add_link_options("/DEBUG:FASTLINK")
443+
# add_compile_options("/Z7")
444+
# add_link_options("/DEBUG:FASTLINK")
445+
446+
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/Z7>")
447+
448+
if (NOT CUPDLP_GPU)
449+
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/DEBUG:FASTLINK>")
450+
endif()
451+
378452
if(STDCALL)
379453
# /Gz - stdcall calling convention
380454
add_definitions(/Gz)

check/CMakeLists.txt

Lines changed: 127 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ if (FORTRAN AND NOT BUILD_EXTRA_UNIT_ONLY)
1313
${HIGHS_SOURCE_DIR}/check)
1414
endif()
1515

16+
# if (CUPLDP_GPU AND BUILD_CXX)
17+
# # add a test
18+
# add_executable(testcudalin ${HIGHS_SOURCE_DIR}/src/pdlp/cupdlp/cuda/test_cuda_linalg.c)
19+
# add_executable(testcublas ${HIGHS_SOURCE_DIR}/src/pdlp/cupdlp/cuda/test_cublas.c)
20+
21+
# set_target_properties(testcudalin PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
22+
# #target_include_directories(cudalinalg PRIVATE ${CUPDLP_INCLUDE_DIR}/cuda)
23+
# target_link_libraries(testcudalin PRIVATE highs ${CUDA_LIBRARY})
24+
25+
# set_target_properties(testcublas PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
26+
# target_link_libraries(testcublas PRIVATE highs ${CUDA_LIBRARY})
27+
# endif()
28+
1629
if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
1730
# prepare Catch library
1831
set(CATCH_INCLUDE_DIR ${HIGHS_SOURCE_DIR}/extern)
@@ -98,6 +111,16 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
98111

99112
if (FAST_BUILD)
100113
target_link_libraries(unit_tests highs Catch)
114+
115+
if (CUPDLP_GPU)
116+
if (WIN32)
117+
target_link_libraries(unit_tests cudalin ${CUDA_LIBRARY})
118+
else()
119+
target_link_libraries(unit_tests cudalin ${CUDA_LIBRARY} m)
120+
endif()
121+
target_include_directories(unit_tests PRIVATE ${HIGHS_SOURCE_DIR}/src/pdlp/cupdlp/cuda)
122+
set_target_properties(unit_tests PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
123+
endif()
101124
else()
102125
target_link_libraries(unit_tests libhighs Catch)
103126
endif()
@@ -239,48 +262,106 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
239262
)
240263

241264
if (UNIX AND NOT APPLE)
242-
set(pdlpInstances
243-
"25fv47\; 5.50184588\;"
244-
"adlittle\; 2.254949631\;"
245-
"afiro\;-4.64753142\;"
246-
"avgas\;-7.749999999\;"
247-
"blending\;-3.19999999\;"
248-
"chip\;-9.000000001\;"
249-
"e226\;-1.16389293\;"
250-
"scrs8\; 9.042969511\;"
251-
"sctest\; 5.749999936\;"
252-
"shell\; 1.2088253460\;"
253-
"stair\;-2.51266951\;"
254-
"standata\; 1.257699499\;"
255-
"standgub\; 1.25769949\;"
256-
)
265+
if (CUPDLP_CPU AND NOT CUPDLP_FORCE_NATIVE)
266+
set(pdlpInstances
267+
"25fv47\; 5.50184588\;"
268+
"adlittle\; 2.254949631\;"
269+
"afiro\;-4.64753142\;"
270+
"avgas\;-7.749999999\;"
271+
"blending\;-3.19999999\;"
272+
"chip\;-9.000000001\;"
273+
"e226\;-1.16389293\;"
274+
"scrs8\; 9.042969511\;"
275+
"sctest\; 5.749999936\;"
276+
"shell\; 1.2088253460\;"
277+
"stair\;-2.51266951\;"
278+
"standata\; 1.257699499\;"
279+
"standgub\; 1.25769949\;"
280+
)
281+
else()
282+
if (CUPDLP_GPU)
283+
set(pdlpInstances
284+
"25fv47\; 5.5018549\;"
285+
"adlittle\; 2.254950\;"
286+
"afiro\;-4.6475325\;"
287+
"avgas\;-7.75000038\;"
288+
"blending\;-3.19999999\;"
289+
"chip\;-9.0000000\;"
290+
"e226\;-1.16389258\;"
291+
"scrs8\; 9.0429623\;"
292+
"sctest\; 5.750000001\;"
293+
"shell\; 1.20882535\;"
294+
"stair\;-2.5126695\;"
295+
"standata\; 1.25769951\;"
296+
"standgub\; 1.2576993\;"
297+
)
298+
else()
299+
# CUPDLP_GPU or CPU with native termination.
300+
if (CUPDLP_FORCE_NATIVE)
301+
set(pdlpInstances
302+
"25fv47\; 5.5018360\;"
303+
"adlittle\; 2.254953\;"
304+
"afiro\;-4.64753126\;"
305+
"avgas\;-7.75000038\;"
306+
"blending\;-3.19999999\;"
307+
"chip\;-9.000000020\;"
308+
"e226\;-1.163892070\;"
309+
"scrs8\; 9.042970154\;"
310+
"sctest\; 5.750000001\;"
311+
"shell\; 1.2088253471\;"
312+
"stair\;-2.512669020\;"
313+
"standata\; 1.257699155\;"
314+
"standgub\; 1.257700132\;"
315+
)
316+
endif()
317+
endif()
318+
endif()
257319
elseif(WIN32)
258-
# on windows e226 model status is unknown
259-
# on windows 25fv47 model status can be unknown, with objective 5.5018458957e+03
260-
set(pdlpInstances
261-
"25fv47\; 5.5018458\;"
262-
"adlittle\; 2.25494963\;"
263-
"afiro\;-4.64753142\;"
264-
"avgas\;-7.749999999\;"
265-
"blending\;-3.19999999\;"
266-
"chip\;-9.000000001\;"
267-
"scrs8\; 9.0429695\;"
268-
"sctest\; 5.749999936\;"
269-
"shell\; 1.2088253460\;"
270-
"stair\;-2.51266951\;"
271-
"standata\; 1.2576995\;"
272-
"standgub\; 1.2576995\;"
273-
)
320+
if (CUPDLP_CPU AND NOT CUPDLP_FORCE_NATIVE)
321+
# on windows e226 model status is unknown
322+
# on windows 25fv47 model status can be unknown, with objective 5.5018458957e+03
323+
set(pdlpInstances
324+
"25fv47\; 5.5018458\;"
325+
"adlittle\; 2.25494963\;"
326+
"afiro\;-4.64753142\;"
327+
"avgas\;-7.749999999\;"
328+
"blending\;-3.19999999\;"
329+
"chip\;-9.000000001\;"
330+
"scrs8\; 9.0429695\;"
331+
"sctest\; 5.749999936\;"
332+
"shell\; 1.2088253460\;"
333+
"stair\;-2.51266951\;"
334+
"standata\; 1.2576995\;"
335+
"standgub\; 1.2576995\;"
336+
)
337+
else()
338+
if (CUPDLP_GPU)
339+
set(pdlpInstances
340+
"25fv47\; 5.50185\;" # 549 release 500 debug
341+
"adlittle\; 2.2549505\;"
342+
"afiro\;-4.6475325\;"
343+
"avgas\;-7.750000\;"
344+
"blending\;-3.19999999\;"
345+
"chip\;-9.0000000\;"
346+
"scrs8\; 9.0429693\;"
347+
"sctest\; 5.7500000\;"
348+
"shell\; 1.20882535\;"
349+
"stair\;-2.512669\;" # 96 release 95 debug
350+
"standata\; 1.2576995\;"
351+
"standgub\; 1.2576993\;"
352+
)
353+
endif()
354+
endif()
274355
elseif(APPLE)
275356
set(pdlpInstances
276357
"25fv47\; 5.5018458\;"
277358
"adlittle\; 2.25494963\;"
278359
"afiro\;-4.64753142\;"
279360
"avgas\;-7.749999999\;"
280361
"blending\;-3.19999999\;"
281-
"chip\;-8.9999988715\;"
362+
"chip\;-8.9999999\;"
282363
"e226\;-1.163892\;"
283-
"scrs8\; 9.04296953\;"
364+
"scrs8\; 9.0429695\;"
284365
"sctest\; 5.749999936\;"
285366
"shell\; 1.2088253460\;"
286367
"stair\;-2.5126695\;"
@@ -454,4 +535,17 @@ if (BUILD_EXTRA_UNIT_TESTS AND BUILD_EXTRA_UNIT_ONLY)
454535
DEPENDS unit-test-extra-build)
455536
set_tests_properties(unit_tests_extra PROPERTIES TIMEOUT 10000)
456537

538+
if (CUPDLP_GPU)
539+
set_target_properties(unit_tests_extra PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
540+
target_link_libraries(unit_tests_extra ${CUDA_LIBRARY})
541+
542+
add_executable(cublas_example cublas_example.cpp)
543+
set_target_properties(cublas_example PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
544+
target_link_libraries(cublas_example ${CUDA_LIBRARY})
545+
546+
add_executable(cublas_gpu_start cublas_gpu_start.cpp)
547+
set_target_properties(cublas_gpu_start PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
548+
target_link_libraries(cublas_gpu_start ${CUDA_LIBRARY})
549+
endif()
550+
457551
endif()

0 commit comments

Comments
 (0)