Skip to content

Commit a939cf1

Browse files
committed
Merge branch 'branch-25.08' into hypersparsity2
2 parents be60ae7 + e33e73c commit a939cf1

File tree

30 files changed

+828
-217
lines changed

30 files changed

+828
-217
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ cd $CUOPT_HOME
143143
./build.sh --help
144144
```
145145

146+
#### Deb package
147+
148+
`libcuopt.so` can be packaged as a deb package with option deb. This is a beta-feature and dependecies of libcuopt needs to be installed manually while installing it using deb package.
149+
This is only available to be built through source code and libcuopt is not being released as deb package in any official space.
150+
151+
```bash
152+
./build.sh libmps_parser libcuopt deb
153+
```
154+
146155
#### Building for development
147156

148157
To build all libraries and tests, simply run

build.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ REPODIR=$(cd "$(dirname "$0")"; pwd)
2727
LIBCUOPT_BUILD_DIR=${LIBCUOPT_BUILD_DIR:=${REPODIR}/cpp/build}
2828
LIBMPS_PARSER_BUILD_DIR=${LIBMPS_PARSER_BUILD_DIR:=${REPODIR}/cpp/libmps_parser/build}
2929

30-
VALIDARGS="clean libcuopt libmps_parser cuopt_mps_parser cuopt cuopt_server cuopt_sh_client docs -a -b -g -v -l= --verbose-pdlp [--cmake-args=\\\"<args>\\\"] [--cache-tool=<tool>] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help"
30+
VALIDARGS="clean libcuopt libmps_parser cuopt_mps_parser cuopt cuopt_server cuopt_sh_client docs deb -a -b -g -v -l= --verbose-pdlp [--cmake-args=\\\"<args>\\\"] [--cache-tool=<tool>] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help"
3131
HELP="$0 [<target> ...] [<flag> ...]
3232
where <target> is:
3333
clean - remove all existing build artifacts and configuration (start over)
@@ -38,6 +38,7 @@ HELP="$0 [<target> ...] [<flag> ...]
3838
cuopt_server - build the cuopt_server Python package
3939
cuopt_sh_client - build cuopt self host client
4040
docs - build the docs
41+
deb - build deb package (requires libcuopt to be built first)
4142
and <flag> is:
4243
-v - verbose build mode
4344
-g - build for debug
@@ -316,6 +317,21 @@ if buildAll || hasArg libcuopt; then
316317
fi
317318
fi
318319

320+
################################################################################
321+
# Build deb package
322+
if hasArg deb; then
323+
# Check if libcuopt has been built
324+
if [ ! -d "${LIBCUOPT_BUILD_DIR}" ]; then
325+
echo "Error: libcuopt must be built before creating deb package. Run with 'libcuopt' target first."
326+
exit 1
327+
fi
328+
329+
echo "Building deb package..."
330+
cd "${LIBCUOPT_BUILD_DIR}"
331+
cpack -G DEB
332+
echo "Deb package created in ${LIBCUOPT_BUILD_DIR}"
333+
fi
334+
319335

320336
# Build and install the cuopt Python package
321337
if buildAll || hasArg cuopt; then

ci/test_self_hosted_service.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ if [ "$doservertest" -eq 1 ]; then
217217
# Test for message on absolute path, bad directory
218218
run_cli_test "Absolute path '/nohay' does not exist" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -f /nohay/nada
219219

220+
# Set all current and deprecated solver_config values and make sure the service does not reject the dataset
221+
# This is a smoketest against parameter name misalignment
222+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c $CLIENT_CERT -p $CUOPT_SERVER_PORT ../../datasets/cuopt_service_data/lpmip_configs.json
223+
220224
rapids-logger "Running cuopt_self_hosted Python tests"
221225
pytest tests
222226

conda/recipes/libcuopt/recipe.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cache:
2929
export CXXFLAGS=$(echo $CXXFLAGS | sed -E 's@\-fdebug\-prefix\-map[^ ]*@@g')
3030
set +x
3131
32-
./build.sh -n -v -a libmps_parser libcuopt --ci-only-arch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\"
32+
./build.sh -n -v -a libmps_parser libcuopt deb --allgpuarch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\"
3333
secrets:
3434
- AWS_ACCESS_KEY_ID
3535
- AWS_SECRET_ACCESS_KEY

cpp/CMakeLists.txt

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ elseif(CMAKE_CUDA_LINEINFO)
134134
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -lineinfo")
135135
endif(CMAKE_BUILD_TYPE MATCHES Debug)
136136

137+
# Undefine NDEBUG if assert mode is on
138+
if(DEFINE_ASSERT)
139+
message(STATUS "Undefining NDEBUG with assert mode enabled")
140+
add_definitions(-UNDEBUG)
141+
endif()
142+
137143

138144
# ##################################################################################################
139145
# - find CPM based dependencies ------------------------------------------------------------------
@@ -245,16 +251,49 @@ endif(BUILD_TESTS)
245251

246252
# ##################################################################################################
247253
# - install targets -------------------------------------------------------------------------------
254+
255+
# allows for CPack component builds and install location
256+
set(CPACK_DEB_COMPONENT_INSTALL ON)
257+
set(CPACK_COMPONENTS_ALL runtime dev)
258+
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
259+
260+
#If using cpack to create a deb package
261+
if(CPACK_GENERATOR STREQUAL "DEB")
262+
set(_BIN_DEST "bin")
263+
set(_LIB_DEST "lib")
264+
set(_INCLUDE_DEST "lib/cuopt")
265+
266+
#If building locally use the Default install paths(e.g. for local development or other package types)
267+
else()
268+
set(_BIN_DEST "${CMAKE_INSTALL_BINDIR}")
269+
set(_LIB_DEST "${lib_dir}")
270+
set(_INCLUDE_DEST include/cuopt/)
271+
endif()
272+
273+
# adds the .so files to the runtime deb package
274+
install(TARGETS cuopt mps_parser
275+
DESTINATION ${_LIB_DEST}
276+
COMPONENT runtime
277+
EXPORT cuopt-exports
278+
)
279+
280+
# adds the .so files to the development deb package
248281
install(TARGETS cuopt mps_parser
249-
DESTINATION ${lib_dir}
250-
EXPORT cuopt-exports)
282+
DESTINATION ${_LIB_DEST}
283+
COMPONENT dev
284+
)
251285

286+
# adds the header files to the development deb package
252287
install(DIRECTORY include/cuopt/
253-
DESTINATION include/cuopt)
288+
DESTINATION ${_INCLUDE_DEST}
289+
COMPONENT dev
290+
)
254291

292+
# adds the version header file to the development deb package
255293
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cuopt/version_config.hpp
256-
DESTINATION include/cuopt)
257-
294+
DESTINATION ${_INCLUDE_DEST}
295+
COMPONENT dev
296+
)
258297
# ###############################################################################################
259298
# - install export -------------------------------------------------------------------------------
260299
set(doc_string
@@ -299,8 +338,6 @@ if(Doxygen_FOUND)
299338
endif()
300339

301340

302-
303-
list(APPEND CUOPT_CXX_FLAGS -g -O0)
304341
add_executable(cuopt_cli cuopt_cli.cpp)
305342
target_compile_options(cuopt_cli
306343
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
@@ -323,10 +360,11 @@ target_link_libraries(cuopt_cli
323360
)
324361
set_property(TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir}")
325362

326-
# FIXME:: Is this the right way?
363+
# adds the cuopt_cli executable to the runtime deb package
327364
install(TARGETS cuopt_cli
328-
DESTINATION ${CMAKE_INSTALL_BINDIR})
329-
365+
COMPONENT runtime
366+
RUNTIME DESTINATION ${_BIN_DEST}
367+
)
330368

331369
option(BUILD_BENCHMARKS "Build benchmarks" ON)
332370
if(BUILD_BENCHMARKS)
@@ -341,3 +379,38 @@ if(BUILD_BENCHMARKS)
341379
OpenMP::OpenMP_CXX
342380
)
343381
endif()
382+
383+
384+
# ##################################################################################################
385+
# - CPack has to be the last item in the cmake file-------------------------------------------------
386+
# Used to create an installable deb package for cuOpt
387+
388+
set(CPACK_GENERATOR "DEB")
389+
390+
# Runtime package metadata
391+
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE DEB_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
392+
393+
# general package metadata
394+
set(CPACK_DEBIAN_PACKAGE_NAME "cuOpt")
395+
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
396+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nvidia")
397+
set(CPACK_PACKAGE_FILE_NAME "cuOpt_${CPACK_PACKAGE_VERSION}_${DEB_ARCH}")
398+
399+
# runtime package metadata
400+
set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "cuOpt runtime components (binaries and shared libraries)")
401+
set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "cuOpt Runtime")
402+
set(CPACK_COMPONENT_RUNTIME_GROUP "Runtime")
403+
set(CPACK_DEBIAN_RUNTIME_PACKAGE_MAINTAINER "NVIDIA")
404+
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "cuopt")
405+
set(CPACK_DEBIAN_RUNTIME_PACKAGE_FILE_NAME "cuopt_${PROJECT_VERSION}_${DEB_ARCH}")
406+
407+
# Dev package metadata
408+
set(CPACK_COMPONENT_DEV_DESCRIPTION "cuOpt development files (headers, symlinks, etc.)")
409+
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "cuOpt Development")
410+
set(CPACK_COMPONENT_DEV_GROUP "Development")
411+
set(CPACK_DEBIAN_DEV_PACKAGE_MAINTAINER "NVIDIA")
412+
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "cuopt-dev")
413+
set(CPACK_DEBIAN_DEV_PACKAGE_FILE_NAME "cuopt-dev_${PROJECT_VERSION}_${DEB_ARCH}")
414+
415+
# MUST BE THE LAST ITEM IN THE CMAKE FILE!!!
416+
include(CPack)

cpp/src/linear_programming/solve.cu

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void run_dual_simplex_thread(
467467

468468
template <typename i_t, typename f_t>
469469
optimization_problem_solution_t<i_t, f_t> run_concurrent(
470-
optimization_problem_t<i_t, f_t>& op_problem,
470+
const optimization_problem_t<i_t, f_t>& op_problem,
471471
detail::problem_t<i_t, f_t>& problem,
472472
pdlp_solver_settings_t<i_t, f_t> const& settings,
473473
bool is_batch_mode)
@@ -540,7 +540,7 @@ optimization_problem_solution_t<i_t, f_t> run_concurrent(
540540

541541
template <typename i_t, typename f_t>
542542
optimization_problem_solution_t<i_t, f_t> solve_lp_with_method(
543-
optimization_problem_t<i_t, f_t>& op_problem,
543+
const optimization_problem_t<i_t, f_t>& op_problem,
544544
detail::problem_t<i_t, f_t>& problem,
545545
pdlp_solver_settings_t<i_t, f_t> const& settings,
546546
bool is_batch_mode)
@@ -714,6 +714,12 @@ optimization_problem_solution_t<i_t, f_t> solve_lp(
714714
bool problem_checking, \
715715
bool use_pdlp_solver_mode); \
716716
\
717+
template optimization_problem_solution_t<int, F_TYPE> solve_lp_with_method( \
718+
const optimization_problem_t<int, F_TYPE>& op_problem, \
719+
detail::problem_t<int, F_TYPE>& problem, \
720+
pdlp_solver_settings_t<int, F_TYPE> const& settings, \
721+
bool is_batch_mode = false); \
722+
\
717723
template optimization_problem_t<int, F_TYPE> mps_data_model_to_optimization_problem( \
718724
raft::handle_t const* handle_ptr, \
719725
const cuopt::mps_parser::mps_data_model_t<int, F_TYPE>& data_model);

cpp/src/linear_programming/solve.cuh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@ cuopt::linear_programming::optimization_problem_t<i_t, f_t> mps_data_model_to_op
3030
raft::handle_t const* handle_ptr,
3131
const cuopt::mps_parser::mps_data_model_t<i_t, f_t>& data_model);
3232

33+
template <typename i_t, typename f_t>
34+
cuopt::linear_programming::optimization_problem_solution_t<i_t, f_t> solve_lp_with_method(
35+
const optimization_problem_t<i_t, f_t>& op_problem,
36+
detail::problem_t<i_t, f_t>& problem,
37+
pdlp_solver_settings_t<i_t, f_t> const& settings,
38+
bool is_batch_mode = false);
39+
3340
} // namespace cuopt::linear_programming

cpp/src/mip/diversity/assignment_hash_map.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ size_t assignment_hash_map_t<i_t, f_t>::hash_solution(solution_t<i_t, f_t>& solu
9797
hash_solution_kernel<i_t, f_t, TPB>
9898
<<<(integer_assignment.size() + TPB - 1) / TPB, TPB, 0, solution.handle_ptr->get_stream()>>>(
9999
cuopt::make_span(integer_assignment), cuopt::make_span(reduction_buffer));
100-
RAFT_CHECK_CUDA(handle_ptr->get_stream());
100+
RAFT_CHECK_CUDA(solution.handle_ptr->get_stream());
101101
// Get the number of blocks used in the hash_solution_kernel
102102
int num_blocks = (integer_assignment.size() + TPB - 1) / TPB;
103103

cpp/src/mip/solution/solution.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ f_t solution_t<i_t, f_t>::compute_max_int_violation()
541541
template <typename i_t, typename f_t>
542542
f_t solution_t<i_t, f_t>::compute_max_variable_violation()
543543
{
544+
cuopt_assert(problem_ptr->n_variables == assignment.size(), "Size mismatch");
545+
cuopt_assert(problem_ptr->n_variables == problem_ptr->variable_lower_bounds.size(),
546+
"Size mismatch");
547+
cuopt_assert(problem_ptr->n_variables == problem_ptr->variable_upper_bounds.size(),
548+
"Size mismatch");
544549
return thrust::transform_reduce(
545550
handle_ptr->get_thrust_policy(),
546551
thrust::make_counting_iterator(0),

cpp/src/mip/solve.cu

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ mip_solution_t<i_t, f_t> run_mip(detail::problem_t<i_t, f_t>& problem,
125125
running_mip);
126126

127127
cuopt_func_call(auto saved_problem = scaled_problem);
128-
if (settings.mip_scaling) { scaling.scale_problem(); }
129-
if (settings.initial_solutions.size() > 0) {
130-
for (const auto& initial_solution : settings.initial_solutions) {
131-
scaling.scale_primal(*initial_solution);
128+
if (settings.mip_scaling) {
129+
scaling.scale_problem();
130+
if (settings.initial_solutions.size() > 0) {
131+
for (const auto& initial_solution : settings.initial_solutions) {
132+
scaling.scale_primal(*initial_solution);
133+
}
132134
}
133135
}
134136
// only call preprocess on scaled problem, so we can compute feasibility on the original problem

0 commit comments

Comments
 (0)