Skip to content
Merged
2 changes: 1 addition & 1 deletion benchmarks/linear_programming/cuopt/run_mip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void return_gpu_to_the_queue(std::unordered_map<pid_t, int>& pid_gpu_map,

int main(int argc, char* argv[])
{
argparse::ArgumentParser program("solve_mps_file");
argparse::ArgumentParser program("solve_MIP");

// Define all arguments with appropriate defaults and help messages
program.add_argument("--path").help("input path").required();
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/linear_programming/cuopt/run_pdlp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static cuopt::linear_programming::pdlp_solver_settings_t<int, double> create_sol
int main(int argc, char* argv[])
{
// Parse binary arguments
argparse::ArgumentParser program("solve_mps_file");
argparse::ArgumentParser program("solve_LP");
parse_arguments(program);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ echo "Download done"
# EAGER module loading to simulate real-life condition
export CUDA_MODULE_LOADING=EAGER

# Benchmark all instances (cuOpt needs to be compiled first)
# Benchmark all instances (cuOpt needs to be compiled first, you can compile in LP only mode and you should turn on BUILD_LP_BENCHMARKS)
for instance in ${CUOPT_HOME}/benchmarks/linear_programming/datasets/*/ ; do
# Will generate the solver log for each instance. Could addtionally generate the solution file by uncommenting the --solution-path
instance_name=$(basename $instance)
echo "Parsing ${instance_name}.mps then solving"
${CUOPT_HOME}/cpp/build/solve_MPS_file --path ${CUOPT_HOME}/benchmarks/linear_programming/datasets/${instance_name}/${instance_name}.mps --time-limit 3600 # --solution-path $CUOPT_HOME/benchmarks/linear_programming/datasets/$instance.sol
${CUOPT_HOME}/cpp/build/solve_LP --path ${CUOPT_HOME}/benchmarks/linear_programming/datasets/${instance_name}/${instance_name}.mps --time-limit 3600 # --solution-path $CUOPT_HOME/benchmarks/linear_programming/datasets/$instance.sol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start using cuopt_cli here? That's what Hans would be using as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you are not using any of those additional settings/options from run_pdlp right? We can still use run_pdlp for when benchmarking with those settings.

done

echo "Benchmark done"
44 changes: 43 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ REPODIR=$(cd "$(dirname "$0")"; pwd)
LIBCUOPT_BUILD_DIR=${LIBCUOPT_BUILD_DIR:=${REPODIR}/cpp/build}
LIBMPS_PARSER_BUILD_DIR=${LIBMPS_PARSER_BUILD_DIR:=${REPODIR}/cpp/libmps_parser/build}

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"
VALIDARGS="clean libcuopt libmps_parser cuopt_mps_parser cuopt cuopt_server cuopt_sh_client docs deb -a -b -g -v -l= --verbose-pdlp --build-lp-only --no-fetch-rapids --skip-c-python-adapters --skip-tests-build --skip-routing-build --skip-fatbin-write [--cmake-args=\\\"<args>\\\"] [--cache-tool=<tool>] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
Expand All @@ -45,8 +45,14 @@ HELP="$0 [<target> ...] [<flag> ...]
-a - Enable assertion (by default in debug mode)
-b - Build with benchmark settings
-n - no install step
--no-fetch-rapids - don't fetch rapids dependencies
-l= - log level. Options are: TRACE | DEBUG | INFO | WARN | ERROR | CRITICAL | OFF. Default=INFO
--verbose-pdlp - verbose mode for pdlp solver
--build-lp-only - build only linear programming components, excluding routing package and MIP-specific files
--skip-c-python-adapters - skip building C and Python adapter files (cython_solve.cu and cuopt_c.cpp)
--skip-tests-build - disable building of all tests
--skip-routing-build - skip building routing components
--skip-fatbin-write - skip the fatbin write
--cache-tool=<tool> - pass the build cache tool (eg: ccache, sccache, distcc) that will be used
to speedup the build process.
--cmake-args=\\\"<args>\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument)
Expand Down Expand Up @@ -78,6 +84,11 @@ INSTALL_TARGET=install
BUILD_DISABLE_DEPRECATION_WARNING=ON
BUILD_ALL_GPU_ARCH=0
BUILD_CI_ONLY=0
BUILD_LP_ONLY=0
SKIP_C_PYTHON_ADAPTERS=0
SKIP_TESTS_BUILD=0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dow we need to add option to skip BUILD_MIP_BENCHMARKS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep this for now and see if someone needs it

SKIP_ROUTING_BUILD=0
WRITE_FATBIN=1
CACHE_ARGS=()
PYTHON_ARGS_FOR_INSTALL=("-m" "pip" "install" "--no-build-isolation" "--no-deps")
LOGGING_ACTIVE_LEVEL="INFO"
Expand Down Expand Up @@ -208,6 +219,9 @@ fi
if hasArg -n; then
INSTALL_TARGET=""
fi
if hasArg --no-fetch-rapids; then
FETCH_RAPIDS=OFF
fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
fi
Expand All @@ -217,6 +231,22 @@ fi
if hasArg --show_depr_warn; then
BUILD_DISABLE_DEPRECATION_WARNING=OFF
fi
if hasArg --build-lp-only; then
BUILD_LP_ONLY=1
SKIP_ROUTING_BUILD=1 # Automatically skip routing when building LP-only
fi
if hasArg --skip-c-python-adapters; then
SKIP_C_PYTHON_ADAPTERS=1
fi
if hasArg --skip-tests-build; then
SKIP_TESTS_BUILD=1
fi
if hasArg --skip-routing-build; then
SKIP_ROUTING_BUILD=1
fi
if hasArg --skip-fatbin-write; then
WRITE_FATBIN=0
fi

function contains_string {
local search_string="$1"
Expand Down Expand Up @@ -264,6 +294,12 @@ if [ ${BUILD_CI_ONLY} -eq 1 ] && [ ${BUILD_ALL_GPU_ARCH} -eq 1 ]; then
exit 1
fi

if [ ${BUILD_LP_ONLY} -eq 1 ] && [ ${SKIP_C_PYTHON_ADAPTERS} -eq 0 ]; then
echo "ERROR: When using --build-lp-only, you must also specify --skip-c-python-adapters"
echo "The C and Python adapter files (cython_solve.cu and cuopt_c.cpp) are not compatible with LP-only builds"
exit 1
fi

if [ ${BUILD_ALL_GPU_ARCH} -eq 1 ]; then
CUOPT_CMAKE_CUDA_ARCHITECTURES="RAPIDS"
echo "Building for *ALL* supported GPU architectures..."
Expand Down Expand Up @@ -308,6 +344,12 @@ if buildAll || hasArg libcuopt; then
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DFETCH_RAPIDS=${FETCH_RAPIDS} \
-DBUILD_LP_ONLY=${BUILD_LP_ONLY} \
-DSKIP_C_PYTHON_ADAPTERS=${SKIP_C_PYTHON_ADAPTERS} \
-DBUILD_TESTS=$((1 - ${SKIP_TESTS_BUILD})) \
-DSKIP_ROUTING_BUILD=${SKIP_ROUTING_BUILD} \
-DWRITE_FATBIN=${WRITE_FATBIN} \
"${CACHE_ARGS[@]}" \
"${EXTRA_CMAKE_ARGS[@]}" \
"${REPODIR}"/cpp
if hasArg -n; then
Expand Down
109 changes: 69 additions & 40 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ option(CMAKE_CUDA_LINEINFO "Enable the -lineinfo option for nvcc useful for cuda
option(BUILD_TESTS "Configure CMake to build tests" ON)
option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)
option(BUILD_LP_ONLY "Build only linear programming components, exclude routing and MIP-specific files" OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing BUILD_TESTS
WRITE_FATBIN and BUILD_FATBIN is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build test is above. We had it already but it was not used and not working in practice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch for the BUILD_FATBIN!

option(SKIP_C_PYTHON_ADAPTERS "Skip building C and Python adapter files (cython_solve.cu and cuopt_c.cpp)" OFF)
option(SKIP_ROUTING_BUILD "Skip building routing components" OFF)
option(WRITE_FATBIN "Enable fatbin writing" ON)

message(VERBOSE "cuOpt: Enable nvcc -lineinfo: ${CMAKE_CUDA_LINEINFO}")
message(VERBOSE "cuOpt: Build cuOpt unit-tests: ${BUILD_TESTS}")
message(VERBOSE "cuOpt: Build cuOpt multigpu tests: ${BUILD_TESTS}")
message(VERBOSE "cuOpt: Disable OpenMP: ${DISABLE_OPENMP}")
message(VERBOSE "cuOpt: Build LP-only mode: ${BUILD_LP_ONLY}")
message(VERBOSE "cuOpt: Skip C/Python adapters: ${SKIP_C_PYTHON_ADAPTERS}")
message(VERBOSE "cuOpt: Skip routing build: ${SKIP_ROUTING_BUILD}")
message(VERBOSE "cuOpt: fatbin: ${WRITE_FATBIN}")

# ##################################################################################################
# - compiler options ------------------------------------------------------------------------------
Expand Down Expand Up @@ -209,15 +217,17 @@ target_compile_options(cuopt
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
)

file(WRITE "${CUOPT_BINARY_DIR}/fatbin.ld"
[=[
SECTIONS
{
.nvFatBinSegment : { *(.nvFatBinSegment) }
.nv_fatbin : { *(.nv_fatbin) }
}
]=])
target_link_options(cuopt PRIVATE "${CUOPT_BINARY_DIR}/fatbin.ld")
if(WRITE_FATBIN)
file(WRITE "${CUOPT_BINARY_DIR}/fatbin.ld"
[=[
SECTIONS
{
.nvFatBinSegment : { *(.nvFatBinSegment) }
.nv_fatbin : { *(.nv_fatbin) }
}
]=])
target_link_options(cuopt PRIVATE "${CUOPT_BINARY_DIR}/fatbin.ld")
endif()

add_library(cuopt::cuopt ALIAS cuopt)
# ##################################################################################################
Expand Down Expand Up @@ -361,44 +371,63 @@ if(Doxygen_FOUND)
endif()


add_executable(cuopt_cli cuopt_cli.cpp)
target_compile_options(cuopt_cli
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
)
if(NOT BUILD_LP_ONLY)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be

Suggested change
if(NOT BUILD_LP_ONLY)
if(BUILD_LP_ONLY)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I confirm we don't want to have cuopt_cli if we are in lp_only mode since there is a call to the MIP solver

add_executable(cuopt_cli cuopt_cli.cpp)
target_compile_options(cuopt_cli
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
)

target_include_directories(cuopt_cli
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_include_directories(cuopt_cli
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)

target_link_libraries(cuopt_cli
PUBLIC
cuopt
OpenMP::OpenMP_CXX
PRIVATE
papilo-core
)
set_property(TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir}")
target_link_libraries(cuopt_cli
PUBLIC
cuopt
OpenMP::OpenMP_CXX
PRIVATE
papilo-core
)
set_property(TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir}")

# adds the cuopt_cli executable to the runtime deb package
install(TARGETS cuopt_cli
COMPONENT runtime
RUNTIME DESTINATION ${_BIN_DEST}
)
# adds the cuopt_cli executable to the runtime deb package
install(TARGETS cuopt_cli
COMPONENT runtime
RUNTIME DESTINATION ${_BIN_DEST}
)
endif()


option(BUILD_MIP_BENCHMARKS "Build MIP benchmarks" OFF)
if(BUILD_MIP_BENCHMARKS AND NOT BUILD_LP_ONLY)
add_executable(solve_MIP ../benchmarks/linear_programming/cuopt/run_mip.cpp)
target_compile_options(solve_MIP
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
)
target_link_libraries(solve_MIP
PUBLIC
cuopt
OpenMP::OpenMP_CXX
PRIVATE
papilo-core
)
endif()

option(BUILD_BENCHMARKS "Build benchmarks" ON)
if(BUILD_BENCHMARKS)
add_executable(solve_MPS_file ../benchmarks/linear_programming/cuopt/run_mip.cpp)
target_compile_options(solve_MPS_file
option(BUILD_LP_BENCHMARKS "Build LP benchmarks" OFF)
if(BUILD_LP_BENCHMARKS)
add_executable(solve_LP ../benchmarks/linear_programming/cuopt/run_pdlp.cu)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For benchmarking, I think we should directly use the cuopt_cli, because that's what everyone will use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I have is run_pdlp has more options that cuopt_cli

target_compile_options(solve_LP
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUOPT_CUDA_FLAGS}>"
)
target_link_libraries(solve_MPS_file
target_link_libraries(solve_LP
PUBLIC
cuopt
OpenMP::OpenMP_CXX
Expand Down
20 changes: 11 additions & 9 deletions cpp/libmps_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ target_compile_options(mps_parser
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${MPS_PARSER_CXX_FLAGS}>"
)

file(WRITE "${MPS_PARSER_BINARY_DIR}/fatbin.ld"
[=[
SECTIONS
{
.nvFatBinSegment : { *(.nvFatBinSegment) }
.nv_fatbin : { *(.nv_fatbin) }
}
]=])
target_link_options(mps_parser PRIVATE "${MPS_PARSER_BINARY_DIR}/fatbin.ld")
if(WRITE_FATBIN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this always?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? Remove the fatbin writing completly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he is asking, by default currently this was disabled, so do we need to disable it by default might be the question. Think I also had asked this question.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you have changed it if I am not wrong.

file(WRITE "${MPS_PARSER_BINARY_DIR}/fatbin.ld"
[=[
SECTIONS
{
.nvFatBinSegment : { *(.nvFatBinSegment) }
.nv_fatbin : { *(.nv_fatbin) }
}
]=])
target_link_options(mps_parser PRIVATE "${MPS_PARSER_BINARY_DIR}/fatbin.ld")
endif()

add_library(cuopt::mps_parser ALIAS mps_parser)

Expand Down
7 changes: 6 additions & 1 deletion cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ set(UTIL_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/utilities/seed_generator.cu
add_subdirectory(linear_programming)
add_subdirectory(math_optimization)
add_subdirectory(mip)
add_subdirectory(routing)

# Only build routing for full builds, not LP-only builds
if(NOT SKIP_ROUTING_BUILD)
add_subdirectory(routing)
endif()

add_subdirectory(dual_simplex)

set(CUOPT_SRC_FILES ${CUOPT_SRC_FILES} ${UTIL_SRC_FILES} PARENT_SCOPE)
16 changes: 14 additions & 2 deletions cpp/src/linear_programming/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(LP_SRC_FILES
# Core LP files always included
set(LP_CORE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/solver_settings.cu
${CMAKE_CURRENT_SOURCE_DIR}/optimization_problem.cu
${CMAKE_CURRENT_SOURCE_DIR}/utilities/cython_solve.cu
${CMAKE_CURRENT_SOURCE_DIR}/utilities/problem_checking.cu
${CMAKE_CURRENT_SOURCE_DIR}/solve.cu
${CMAKE_CURRENT_SOURCE_DIR}/pdlp.cu
Expand All @@ -34,7 +34,19 @@ set(LP_SRC_FILES
${CMAKE_CURRENT_SOURCE_DIR}/termination_strategy/termination_strategy.cu
${CMAKE_CURRENT_SOURCE_DIR}/termination_strategy/infeasibility_information.cu
${CMAKE_CURRENT_SOURCE_DIR}/termination_strategy/convergence_information.cu
)

# C and Python adapter files
set(LP_ADAPTER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/utilities/cython_solve.cu
${CMAKE_CURRENT_SOURCE_DIR}/cuopt_c.cpp
)

# Choose which files to include based on build mode
if(SKIP_C_PYTHON_ADAPTERS)
set(LP_SRC_FILES ${LP_CORE_FILES})
else()
set(LP_SRC_FILES ${LP_CORE_FILES} ${LP_ADAPTER_FILES})
endif()

set(CUOPT_SRC_FILES ${CUOPT_SRC_FILES} ${LP_SRC_FILES} PARENT_SCOPE)
Loading