diff --git a/ci/check_symbols.sh b/ci/check_symbols.sh new file mode 100755 index 0000000000..ba3da7429b --- /dev/null +++ b/ci/check_symbols.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -eEuo pipefail + +echo "checking for symbol visibility issues" + +LIBRARY="${1}" + +echo "" +echo "Checking exported symbols in '${LIBRARY}'" +symbol_file="$(mktemp)" +match_file="$(mktemp)" +trap 'rm -f "${symbol_file}" "${match_file}"' EXIT + +# Ignore WEAK and UNIQUE symbols since UNIQUE symbols should be exported and +# WEAK symbols may come from template instantiations. +# Ignore symbols containing "_error" since these are likely exception types +# and should be exported. + +readelf --dyn-syms --wide "${LIBRARY}" \ + | awk '$7 != "UND" && $5 != "WEAK" && $5 != "UNIQUE"' \ + | c++filt --no-params \ + | awk '$0 !~ /_error/' \ + > "${symbol_file}" + +patterns=( + 'cub::' + 'thrust::' + 'raft::' + 'rmm::' + 'cuopt::mathematical_optimization::detail' + 'cuopt::routing::detail' + 'grpc::' + 'google::protobuf' + 'tbb::' + 'absl::' + 'dejavu::' + 'papilo::' + 'boost::' + 'pslp_' +) + +failed=0 + +for pattern in "${patterns[@]}"; do + echo "Checking for '${pattern}' symbols..." + + awk -v pattern="${pattern}" ' + BEGIN { has_trailing_scope = (substr(pattern, length(pattern) - 1) == "::") } + $1 ~ /^[0-9]+:/ { + symbol = "" + for (i = 8; i <= NF; ++i) { + symbol = symbol (i == 8 ? "" : " ") $i + } + + sub(/<.*/, "", symbol) + sub(/^.*[[:space:]](for|to)[[:space:]]+/, "", symbol) + + if (has_trailing_scope) { + matched = (index(symbol, pattern) == 1) + } else { + matched = (symbol == pattern || index(symbol, pattern "::") == 1) + } + + if (matched) { print } + } + ' "${symbol_file}" > "${match_file}" + + matches=$(awk 'END { print NR }' "${match_file}") + if [[ "${matches}" -ne 0 ]]; then + sed -n '1,20p' "${match_file}" + echo "ERROR: Found exported symbols in ${LIBRARY} matching the pattern ${pattern}." + echo "ERROR: Total matching symbols: ${matches}" + failed=1 + fi +done + +if [[ "${failed}" -ne 0 ]]; then + exit 1 +fi + +echo "No symbol visibility issues found in ${LIBRARY}" diff --git a/conda/recipes/libcuopt/recipe.yaml b/conda/recipes/libcuopt/recipe.yaml index 77c957eade..ab89215e13 100644 --- a/conda/recipes/libcuopt/recipe.yaml +++ b/conda/recipes/libcuopt/recipe.yaml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 schema_version: 1 @@ -107,6 +107,7 @@ outputs: script: content: | cmake --install cpp/build + ./ci/check_symbols.sh cpp/build/libcuopt.so dynamic_linking: overlinking_behavior: "error" prefix_detection: @@ -118,6 +119,7 @@ outputs: build: - cmake ${{ cmake_version }} - ${{ stdlib("c") }} + - binutils host: - libboost-devel - cuda-version =${{ cuda_version }} diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 67412162c2..79b5a0e6eb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -481,58 +481,48 @@ if (NOT SKIP_GRPC_BUILD) # at runtime with "undefined symbol: absl::…::Mutex::Dtor". set_property(SOURCE ${GRPC_INFRA_FILES} DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_OPTIONS "-DNDEBUG") + set_property(SOURCE ${PROTO_SRCS} ${GRPC_PROTO_SRCS} ${GRPC_SERVICE_SRCS} ${DATA_PROTO_SRCS} DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + APPEND PROPERTY COMPILE_OPTIONS "$<$:-fvisibility=default>") endif (NOT SKIP_GRPC_BUILD) -add_library(cuopt SHARED +add_library(cuopt_objs OBJECT ${CUOPT_SRC_FILES} ) -set_target_properties(cuopt - PROPERTIES BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN" - INTERFACE_POSITION_INDEPENDENT_CODE ON +set_target_properties(cuopt_objs + PROPERTIES POSITION_INDEPENDENT_CODE ON + CXX_VISIBILITY_PRESET hidden + CUDA_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON CXX_SCAN_FOR_MODULES OFF ) -target_compile_definitions(cuopt +target_compile_definitions(cuopt_objs PUBLIC "CUOPT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${LIBCUOPT_LOGGING_LEVEL}" PUBLIC CUSPARSE_ENABLE_EXPERIMENTAL_API ) -target_compile_options(cuopt +target_compile_options(cuopt_objs PRIVATE "$<$:${CUOPT_CXX_FLAGS}>" "$<$:${CUOPT_CUDA_FLAGS}>" ) -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) # ################################################################################################## # - include paths --------------------------------------------------------------------------------- message(STATUS "target include directories CUDSS_INCLUDES = ${CUDSS_INCLUDE}") # Adding Papilo as a system include messes up clang's include resolution if papilo is already installed as a conda package -target_include_directories(cuopt PRIVATE +target_include_directories(cuopt_objs PRIVATE "${papilo_SOURCE_DIR}/src" "${papilo_BINARY_DIR}" ) -target_include_directories(cuopt SYSTEM PRIVATE +target_include_directories(cuopt_objs SYSTEM PRIVATE "${pslp_SOURCE_DIR}/include" "${dejavu_SOURCE_DIR}" ) -target_include_directories(cuopt +target_include_directories(cuopt_objs PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty" "${CMAKE_CURRENT_SOURCE_DIR}/src" @@ -547,13 +537,12 @@ target_include_directories(cuopt PUBLIC "$" "$" - INTERFACE "$" ) # Link PSLP by file to avoid export dependency tracking -target_link_libraries(cuopt PRIVATE $) -add_dependencies(cuopt PSLP) +target_link_libraries(cuopt_objs PRIVATE $) +add_dependencies(cuopt_objs PSLP) # ################################################################################################## # - link libraries -------------------------------------------------------------------------------- @@ -568,7 +557,7 @@ list(PREPEND CUOPT_PRIVATE_CUDA_LIBS CUDA::cublasLt) # Pass CUDSS_MT_LIB_FILE_NAME as a compile definition get_filename_component(CUDSS_MT_LIB_FILE_NAME "${CUDSS_MT_LIB_FILE}" NAME) -target_compile_definitions(cuopt PRIVATE CUDSS_MT_LIB_FILE_NAME="${CUDSS_MT_LIB_FILE_NAME}") +target_compile_definitions(cuopt_objs PRIVATE CUDSS_MT_LIB_FILE_NAME="${CUDSS_MT_LIB_FILE_NAME}") execute_process( COMMAND git rev-parse --short HEAD @@ -587,13 +576,101 @@ configure_file( ) # Add the generated include directory -target_include_directories(cuopt PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) +target_include_directories(cuopt_objs PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) list(JOIN CMAKE_CUDA_ARCHITECTURES "," JOINED_CUDA_ARCHITECTURES) -target_compile_definitions(cuopt PUBLIC +target_compile_definitions(cuopt_objs PUBLIC CUOPT_CUDA_ARCHITECTURES="${JOINED_CUDA_ARCHITECTURES}" CUOPT_CPU_ARCHITECTURE="${CMAKE_SYSTEM_PROCESSOR}") +target_link_libraries(cuopt_objs + PUBLIC + CUDA::cublas + CUDA::cusparse + rmm::rmm + rapids_logger::rapids_logger + CCCL::CCCL + raft::raft + ${CUDSS_LIB_FILE} + PRIVATE + ${CUOPT_PRIVATE_CUDA_LIBS} + $<$:protobuf::libprotobuf> + $<$:gRPC::grpc++> +) + +if (BUILD_TESTS) + add_library(cuopt_static STATIC $) + + target_link_libraries(cuopt_static + PUBLIC + CUDA::cublas + CUDA::cusparse + rmm::rmm + rapids_logger::rapids_logger + CCCL::CCCL + raft::raft + ${CUDSS_LIB_FILE} + PRIVATE + ${CUOPT_PRIVATE_CUDA_LIBS} + $<$:protobuf::libprotobuf> + $<$:gRPC::grpc++> + ) + + target_include_directories(cuopt_static + PUBLIC + "$" + "$" + "$" + ) + + target_compile_options(cuopt_static + PRIVATE "$<$:${CUOPT_CXX_FLAGS}>" + "$<$:${CUOPT_CUDA_FLAGS}>" + ) + + target_compile_definitions(cuopt_static PUBLIC + CUOPT_CUDA_ARCHITECTURES="${JOINED_CUDA_ARCHITECTURES}" + CUOPT_CPU_ARCHITECTURE="${CMAKE_SYSTEM_PROCESSOR}" + "CUOPT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${LIBCUOPT_LOGGING_LEVEL}" + CUSPARSE_ENABLE_EXPERIMENTAL_API + ) + + target_link_libraries(cuopt_static PRIVATE $) + add_dependencies(cuopt_static PSLP) +endif () + +add_library(cuopt SHARED $) +add_library(cuopt::cuopt ALIAS cuopt) + +set_target_properties(cuopt + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + INTERFACE_POSITION_INDEPENDENT_CODE ON + CXX_SCAN_FOR_MODULES OFF + LINKER_LANGUAGE CUDA +) + +target_include_directories(cuopt + PUBLIC + "$" + "$" + "$" +) + +target_compile_options(cuopt + PRIVATE "$<$:${CUOPT_CXX_FLAGS}>" + "$<$:${CUOPT_CUDA_FLAGS}>" +) + +target_compile_definitions(cuopt PUBLIC + CUOPT_CUDA_ARCHITECTURES="${JOINED_CUDA_ARCHITECTURES}" + CUOPT_CPU_ARCHITECTURE="${CMAKE_SYSTEM_PROCESSOR}" + "CUOPT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${LIBCUOPT_LOGGING_LEVEL}" + CUSPARSE_ENABLE_EXPERIMENTAL_API +) + +target_link_options(cuopt PRIVATE "LINKER:--exclude-libs=ALL") + target_link_libraries(cuopt PUBLIC CUDA::cublas @@ -609,6 +686,21 @@ target_link_libraries(cuopt $<$:gRPC::grpc++> ) +target_link_libraries(cuopt PRIVATE $) +add_dependencies(cuopt PSLP) + +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 () + # ################################################################################################## # - generate tests -------------------------------------------------------------------------------- diff --git a/cpp/include/cuopt/error.hpp b/cpp/include/cuopt/error.hpp index 95179c5ec4..40be060c5b 100644 --- a/cpp/include/cuopt/error.hpp +++ b/cpp/include/cuopt/error.hpp @@ -6,13 +6,14 @@ /* clang-format on */ #pragma once +#include #include "cuopt/mathematical_optimization/constants.h" #include #include -namespace cuopt { +namespace CUOPT_EXPORT cuopt { /** * @brief Indicates different type of exceptions which cuOpt might throw @@ -168,4 +169,4 @@ void execute_cuopt_fail(Args... args) throw cuopt::logic_error(msg, error_type_t::RuntimeError); } -} // namespace cuopt +} // namespace CUOPT_EXPORT cuopt diff --git a/cpp/include/cuopt/export.hpp b/cpp/include/cuopt/export.hpp new file mode 100644 index 0000000000..14e0161a15 --- /dev/null +++ b/cpp/include/cuopt/export.hpp @@ -0,0 +1,18 @@ +/* clang-format off */ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +/* clang-format on */ + +#pragma once + +#if defined(__GNUC__) || defined(__clang__) +#define CUOPT_EXPORT __attribute__((visibility("default"))) +// Marks internal symbols that are exported solely for test access. +// These are NOT part of the stable public API and may change without notice. +#define CUOPT_INTERNAL_EXPORT __attribute__((visibility("default"))) +#else +#define CUOPT_EXPORT +#define CUOPT_INTERNAL_EXPORT +#endif diff --git a/cpp/include/cuopt/grpc/cython_grpc_client.hpp b/cpp/include/cuopt/grpc/cython_grpc_client.hpp index 593014cedc..3f6db62269 100644 --- a/cpp/include/cuopt/grpc/cython_grpc_client.hpp +++ b/cpp/include/cuopt/grpc/cython_grpc_client.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include @@ -22,7 +23,8 @@ class data_model_view_t; } // namespace io } // namespace cuopt::mathematical_optimization -namespace cuopt::cython { +namespace cuopt { +namespace CUOPT_EXPORT cython { /** Mirrors cuopt::mathematical_optimization::job_status_t for the Python bindings. */ enum class grpc_job_status_t : int { @@ -166,4 +168,5 @@ class grpc_python_client_t { std::unique_ptr impl_; }; -} // namespace cuopt::cython +} // namespace CUOPT_EXPORT cython +} // namespace cuopt diff --git a/cpp/include/cuopt/grpc/grpc_client_env.hpp b/cpp/include/cuopt/grpc/grpc_client_env.hpp index dab3dbe531..d8f88b7273 100644 --- a/cpp/include/cuopt/grpc/grpc_client_env.hpp +++ b/cpp/include/cuopt/grpc/grpc_client_env.hpp @@ -5,9 +5,11 @@ #pragma once +#include #include "grpc_client.hpp" -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { /** How TLS is chosen when building a grpc_client_config_t. */ enum class grpc_tls_mode_t { @@ -49,4 +51,5 @@ grpc_client_config_t make_grpc_client_config(const std::string& host, grpc_tls_mode_t tls_mode, const grpc_explicit_tls_t* explicit_tls = nullptr); -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/backend_selection.hpp b/cpp/include/cuopt/mathematical_optimization/backend_selection.hpp index f36b1d2bff..8c6bfeb73f 100644 --- a/cpp/include/cuopt/mathematical_optimization/backend_selection.hpp +++ b/cpp/include/cuopt/mathematical_optimization/backend_selection.hpp @@ -7,7 +7,10 @@ #pragma once -namespace cuopt::mathematical_optimization { +#include + +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { /** * @brief Enum for execution mode (local vs remote solve) @@ -51,4 +54,5 @@ execution_mode_t get_execution_mode(); */ memory_backend_t get_memory_backend_type(); -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem.hpp b/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem.hpp index fd4c50fa75..ff410480a9 100644 --- a/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem.hpp +++ b/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -18,7 +19,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // Forward declarations template @@ -226,4 +228,5 @@ class cpu_optimization_problem_t : public optimization_problem_interface_t row_names_{}; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem_solution.hpp b/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem_solution.hpp index b4e5edec44..5e04e3bbd4 100644 --- a/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem_solution.hpp +++ b/cpp/include/cuopt/mathematical_optimization/cpu_optimization_problem_solution.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -18,7 +19,8 @@ #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { /** * @brief CPU-backed LP solution (uses std::vector instead of rmm::device_uvector) @@ -389,4 +391,5 @@ class cpu_mip_solution_t : public mip_solution_interface_t { i_t num_simplex_iterations_; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/cpu_pdlp_warm_start_data.hpp b/cpp/include/cuopt/mathematical_optimization/cpu_pdlp_warm_start_data.hpp index 9cf4740c96..1a76da0fa3 100644 --- a/cpp/include/cuopt/mathematical_optimization/cpu_pdlp_warm_start_data.hpp +++ b/cpp/include/cuopt/mathematical_optimization/cpu_pdlp_warm_start_data.hpp @@ -7,10 +7,13 @@ #pragma once +#include #include + #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // CPU version of pdlp_warm_start_data_t using std::vector for remote execution template @@ -118,4 +121,5 @@ template pdlp_warm_start_data_t convert_to_gpu_warmstart( const cpu_pdlp_warm_start_data_t& cpu_data, rmm::cuda_stream_view stream); -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/cuopt_c.h b/cpp/include/cuopt/mathematical_optimization/cuopt_c.h index 218402a7ef..7efa160924 100644 --- a/cpp/include/cuopt/mathematical_optimization/cuopt_c.h +++ b/cpp/include/cuopt/mathematical_optimization/cuopt_c.h @@ -9,6 +9,7 @@ #define CUOPT_C_API_H #include +#include #include @@ -17,6 +18,10 @@ extern "C" { #endif +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC visibility push(default) +#endif + /** * @brief A ``cuOptOptimizationProblem`` object contains a representation of * an LP, MIP, QP, or QCQP. It is created by ``cuOptCreateProblem``, @@ -1055,6 +1060,10 @@ cuopt_int_t cuOptGetDualObjectiveValue(cuOptSolution solution, */ cuopt_int_t cuOptGetReducedCosts(cuOptSolution solution, cuopt_float_t* reduced_cost_ptr); +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/cpp/include/cuopt/mathematical_optimization/io/data_model_view.hpp b/cpp/include/cuopt/mathematical_optimization/io/data_model_view.hpp index 7cf4511eb9..41e1a98920 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/data_model_view.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/data_model_view.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -15,7 +16,9 @@ #include #include -namespace cuopt::mathematical_optimization::io { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { +namespace io { /** * @brief A representation of a linear programming (LP) optimization problem @@ -482,4 +485,6 @@ class data_model_view_t { std::vector::quadratic_constraint_t> quadratic_constraints_; }; // class data_model_view_t -} // namespace cuopt::mathematical_optimization::io +} // namespace io +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/io/mps_data_model.hpp b/cpp/include/cuopt/mathematical_optimization/io/mps_data_model.hpp index 4ed1d7244f..7557327c29 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/mps_data_model.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/mps_data_model.hpp @@ -7,13 +7,17 @@ #pragma once +#include + #include #include #include #include #include -namespace cuopt::mathematical_optimization::io { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { +namespace io { /** * @brief A representation of a linear programming (LP) optimization problem @@ -401,4 +405,6 @@ template void canonicalize_quadratic_constraints( std::vector::quadratic_constraint_t>& constraints); -} // namespace cuopt::mathematical_optimization::io +} // namespace io +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/io/mps_writer.hpp b/cpp/include/cuopt/mathematical_optimization/io/mps_writer.hpp index 6184ce56b6..9de061bbc9 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/mps_writer.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/mps_writer.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -18,7 +19,9 @@ #include #include -namespace cuopt::mathematical_optimization::io { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { +namespace io { /** * @brief Main writer class for MPS files @@ -60,4 +63,6 @@ class mps_writer_t { static data_model_view_t create_view(const mps_data_model_t& model); }; // class mps_writer_t -} // namespace cuopt::mathematical_optimization::io +} // namespace io +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/io/parser.hpp b/cpp/include/cuopt/mathematical_optimization/io/parser.hpp index bbfe3e8c38..8647a4852f 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/parser.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/parser.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -15,7 +16,9 @@ #include #include -namespace cuopt::mathematical_optimization::io { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { +namespace io { /** * @brief Reads the equation from an MPS or QPS file. @@ -145,4 +148,6 @@ inline mps_data_model_t read(const std::string& path, bool fixed_mps_f path); } -} // namespace cuopt::mathematical_optimization::io +} // namespace io +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/io/utilities/cython_parser.hpp b/cpp/include/cuopt/mathematical_optimization/io/utilities/cython_parser.hpp index a7863199df..e561325456 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/utilities/cython_parser.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/utilities/cython_parser.hpp @@ -7,12 +7,13 @@ #pragma once +#include #include #include namespace cuopt { -namespace cython { +namespace CUOPT_EXPORT cython { std::unique_ptr> call_read( const std::string& file_path, bool fixed_mps_format); @@ -20,5 +21,5 @@ std::unique_ptr> call_parse_mps( const std::string& mps_file_path, bool fixed_mps_format); -} // namespace cython +} // namespace CUOPT_EXPORT cython } // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/io/writer.hpp b/cpp/include/cuopt/mathematical_optimization/io/writer.hpp index 032865220e..f1a9514d5a 100644 --- a/cpp/include/cuopt/mathematical_optimization/io/writer.hpp +++ b/cpp/include/cuopt/mathematical_optimization/io/writer.hpp @@ -7,9 +7,12 @@ #pragma once +#include #include -namespace cuopt::mathematical_optimization::io { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { +namespace io { /** * @brief Writes the problem to an MPS formatted file @@ -23,4 +26,6 @@ namespace cuopt::mathematical_optimization::io { template void write_mps(const data_model_view_t& problem, const std::string& mps_file_path); -} // namespace cuopt::mathematical_optimization::io +} // namespace io +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/mip/solver_settings.hpp b/cpp/include/cuopt/mathematical_optimization/mip/solver_settings.hpp index 6d2dc8e694..dd65cbae74 100644 --- a/cpp/include/cuopt/mathematical_optimization/mip/solver_settings.hpp +++ b/cpp/include/cuopt/mathematical_optimization/mip/solver_settings.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,8 @@ #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { struct benchmark_info_t { double last_improvement_of_best_feasible = 0; @@ -230,4 +232,5 @@ struct mip_solver_settings_accessor { } }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/mip/solver_solution.hpp b/cpp/include/cuopt/mathematical_optimization/mip/solver_solution.hpp index 19a8e5e531..1ad58b9e10 100644 --- a/cpp/include/cuopt/mathematical_optimization/mip/solver_solution.hpp +++ b/cpp/include/cuopt/mathematical_optimization/mip/solver_solution.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -21,7 +22,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { enum class mip_termination_status_t : int8_t { NoTermination = CUOPT_TERMINATION_STATUS_NO_TERMINATION, @@ -92,4 +94,5 @@ class mip_solution_t : public base_solution_t { std::vector> solution_pool_; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/optimization_problem.hpp b/cpp/include/cuopt/mathematical_optimization/optimization_problem.hpp index 5c755281ca..bdfc2ffbd4 100644 --- a/cpp/include/cuopt/mathematical_optimization/optimization_problem.hpp +++ b/cpp/include/cuopt/mathematical_optimization/optimization_problem.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -20,7 +21,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // Forward declarations template @@ -425,4 +427,5 @@ class optimization_problem_t : public optimization_problem_interface_t std::vector row_names_{}; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/optimization_problem_solution.hpp b/cpp/include/cuopt/mathematical_optimization/optimization_problem_solution.hpp index 822bd54de3..577d5727ec 100644 --- a/cpp/include/cuopt/mathematical_optimization/optimization_problem_solution.hpp +++ b/cpp/include/cuopt/mathematical_optimization/optimization_problem_solution.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -16,7 +17,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { /** * @brief GPU-backed LP solution (wraps optimization_problem_solution_t) @@ -476,4 +478,5 @@ class gpu_mip_solution_t : public mip_solution_interface_t { mip_solution_t solution_; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/pdlp/pdlp_warm_start_data.hpp b/cpp/include/cuopt/mathematical_optimization/pdlp/pdlp_warm_start_data.hpp index 07f54672f2..52a800c3c2 100644 --- a/cpp/include/cuopt/mathematical_optimization/pdlp/pdlp_warm_start_data.hpp +++ b/cpp/include/cuopt/mathematical_optimization/pdlp/pdlp_warm_start_data.hpp @@ -7,11 +7,14 @@ #pragma once +#include + #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { template struct pdlp_warm_start_data_view_t; @@ -99,4 +102,5 @@ struct pdlp_warm_start_data_view_t { i_t iterations_since_last_restart_{-1}; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/pdlp/solver_settings.hpp b/cpp/include/cuopt/mathematical_optimization/pdlp/solver_settings.hpp index 96f548ec32..c6558369ab 100644 --- a/cpp/include/cuopt/mathematical_optimization/pdlp/solver_settings.hpp +++ b/cpp/include/cuopt/mathematical_optimization/pdlp/solver_settings.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -21,7 +22,8 @@ #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // Forward declare solver_settings_t for friend class template @@ -351,4 +353,5 @@ class pdlp_solver_settings_t { friend class solver_settings_t; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/pdlp/solver_solution.hpp b/cpp/include/cuopt/mathematical_optimization/pdlp/solver_solution.hpp index 5bacff1101..be48ea4baf 100644 --- a/cpp/include/cuopt/mathematical_optimization/pdlp/solver_solution.hpp +++ b/cpp/include/cuopt/mathematical_optimization/pdlp/solver_solution.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // Possible reasons for terminating enum class pdlp_termination_status_t : int8_t { @@ -310,4 +312,5 @@ class optimization_problem_solution_t : public base_solution_t { /** error struct */ cuopt::logic_error error_status_; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/solve.hpp b/cpp/include/cuopt/mathematical_optimization/solve.hpp index 961fcd29b6..abc30aa0d7 100644 --- a/cpp/include/cuopt/mathematical_optimization/solve.hpp +++ b/cpp/include/cuopt/mathematical_optimization/solve.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -23,7 +24,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { /** * @brief Linear programming solve function. @@ -213,4 +215,5 @@ std::unique_ptr> solve_mip( // Remote execution functions are declared in solve_remote.hpp (included above) -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/solve_remote.hpp b/cpp/include/cuopt/mathematical_optimization/solve_remote.hpp index 3636195660..bdb19f9c9d 100644 --- a/cpp/include/cuopt/mathematical_optimization/solve_remote.hpp +++ b/cpp/include/cuopt/mathematical_optimization/solve_remote.hpp @@ -7,12 +7,14 @@ #pragma once +#include // Include the solution interface definitions so unique_ptr can properly delete them #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { // Forward declarations (only declaration needed, not definition) template @@ -44,4 +46,5 @@ std::unique_ptr> solve_mip_remote( cpu_optimization_problem_t const& cpu_problem, mip_solver_settings_t const& settings); -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/solver_settings.hpp b/cpp/include/cuopt/mathematical_optimization/solver_settings.hpp index df373b209d..6b47805702 100644 --- a/cpp/include/cuopt/mathematical_optimization/solver_settings.hpp +++ b/cpp/include/cuopt/mathematical_optimization/solver_settings.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -22,7 +23,8 @@ #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +namespace CUOPT_EXPORT mathematical_optimization { template class solver_settings_t { @@ -109,4 +111,5 @@ class solver_settings_t { std::vector> string_parameters; }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/utilities/cython_solve.hpp b/cpp/include/cuopt/mathematical_optimization/utilities/cython_solve.hpp index 79ef572d9c..f84119a8dc 100644 --- a/cpp/include/cuopt/mathematical_optimization/utilities/cython_solve.hpp +++ b/cpp/include/cuopt/mathematical_optimization/utilities/cython_solve.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -20,7 +21,7 @@ #include namespace cuopt { -namespace cython { +namespace CUOPT_EXPORT cython { // Type definitions moved to cython_types.hpp to avoid circular dependencies // The types linear_programming_ret_t and mip_ret_t are defined in cython_types.hpp. @@ -65,5 +66,5 @@ std::pair>, double> call_batch_solve( std::vector*>, mathematical_optimization::solver_settings_t*); -} // namespace cython +} // namespace CUOPT_EXPORT cython } // namespace cuopt diff --git a/cpp/include/cuopt/mathematical_optimization/utilities/cython_types.hpp b/cpp/include/cuopt/mathematical_optimization/utilities/cython_types.hpp index 966018bd9f..69d6f91604 100644 --- a/cpp/include/cuopt/mathematical_optimization/utilities/cython_types.hpp +++ b/cpp/include/cuopt/mathematical_optimization/utilities/cython_types.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -19,7 +20,7 @@ #include namespace cuopt { -namespace cython { +namespace CUOPT_EXPORT cython { using gpu_buffer = std::unique_ptr; using cpu_buffer = std::vector; @@ -112,5 +113,5 @@ struct mip_ret_t { bool is_gpu() const { return std::holds_alternative(solution_); } }; -} // namespace cython +} // namespace CUOPT_EXPORT cython } // namespace cuopt diff --git a/cpp/include/cuopt/routing/assignment.hpp b/cpp/include/cuopt/routing/assignment.hpp index f6fcc3d7b4..b138382d6d 100644 --- a/cpp/include/cuopt/routing/assignment.hpp +++ b/cpp/include/cuopt/routing/assignment.hpp @@ -1,6 +1,6 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -16,7 +17,7 @@ #include namespace cuopt { -namespace routing { +namespace CUOPT_EXPORT routing { /*! Routing assignment default strings */ class solution_string_t { @@ -264,5 +265,5 @@ struct host_assignment_t { std::vector accepted{}; }; -} // namespace routing +} // namespace CUOPT_EXPORT routing } // namespace cuopt diff --git a/cpp/include/cuopt/routing/cython/cython.hpp b/cpp/include/cuopt/routing/cython/cython.hpp index c1ac4e1dd6..76b0de7d2e 100644 --- a/cpp/include/cuopt/routing/cython/cython.hpp +++ b/cpp/include/cuopt/routing/cython/cython.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -19,7 +20,7 @@ #include namespace cuopt { -namespace cython { +namespace CUOPT_EXPORT cython { template void populate_dataset_params(routing::generator::dataset_params_t& params, @@ -91,5 +92,5 @@ std::vector> call_batch_solve( std::unique_ptr call_generate_dataset( raft::handle_t& handle, routing::generator::dataset_params_t const& params); -} // namespace cython +} // namespace CUOPT_EXPORT cython } // namespace cuopt diff --git a/cpp/include/cuopt/routing/data_model_view.hpp b/cpp/include/cuopt/routing/data_model_view.hpp index fa7aec73ec..b025469144 100644 --- a/cpp/include/cuopt/routing/data_model_view.hpp +++ b/cpp/include/cuopt/routing/data_model_view.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include @@ -14,7 +15,7 @@ #include namespace cuopt { -namespace routing { +namespace CUOPT_EXPORT routing { /** * @brief A container of vehicle routing solver input @@ -663,5 +664,5 @@ class data_model_view_t { raft::device_span initial_sol_offsets_{}; std::map>> vehicle_breaks_{}; }; -} // namespace routing +} // namespace CUOPT_EXPORT routing } // namespace cuopt diff --git a/cpp/include/cuopt/routing/routing_structures.hpp b/cpp/include/cuopt/routing/routing_structures.hpp index 807ef6d880..64bcc22ce5 100644 --- a/cpp/include/cuopt/routing/routing_structures.hpp +++ b/cpp/include/cuopt/routing/routing_structures.hpp @@ -1,12 +1,14 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ #pragma once +#include + #include #include diff --git a/cpp/include/cuopt/routing/solve.hpp b/cpp/include/cuopt/routing/solve.hpp index 82b36dd483..41a8cf932a 100644 --- a/cpp/include/cuopt/routing/solve.hpp +++ b/cpp/include/cuopt/routing/solve.hpp @@ -1,17 +1,18 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ #pragma once +#include #include #include #include namespace cuopt { -namespace routing { +namespace CUOPT_EXPORT routing { /** * @brief Routing solve function @@ -26,5 +27,5 @@ template assignment_t solve( data_model_view_t const& data_model, solver_settings_t const& settings = solver_settings_t{}); -} // namespace routing +} // namespace CUOPT_EXPORT routing } // namespace cuopt diff --git a/cpp/include/cuopt/routing/solver_settings.hpp b/cpp/include/cuopt/routing/solver_settings.hpp index 36f301276d..3aae7ff0ef 100644 --- a/cpp/include/cuopt/routing/solver_settings.hpp +++ b/cpp/include/cuopt/routing/solver_settings.hpp @@ -1,19 +1,20 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ #pragma once +#include #include #include #include #include namespace cuopt { -namespace routing { +namespace CUOPT_EXPORT routing { template class solver_settings_t { @@ -94,5 +95,5 @@ class solver_settings_t { std::string best_result_file_name_; }; -} // namespace routing +} // namespace CUOPT_EXPORT routing } // namespace cuopt diff --git a/cpp/src/cuts/cuts.cpp b/cpp/src/cuts/cuts.cpp index 598d4e3f70..d978a6350a 100644 --- a/cpp/src/cuts/cuts.cpp +++ b/cpp/src/cuts/cuts.cpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -6437,13 +6438,13 @@ void verify_cuts_against_saved_solution(const csr_matrix_t& cuts, } #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template class cut_pool_t; +template class CUOPT_INTERNAL_EXPORT cut_pool_t; template class cut_generation_t; template class knapsack_generation_t; -template class flow_cover_generation_t; +template class CUOPT_INTERNAL_EXPORT flow_cover_generation_t; template class tableau_equality_t; template class complemented_mixed_integer_rounding_cut_t; -template class variable_bounds_t; +template class CUOPT_INTERNAL_EXPORT variable_bounds_t; template int add_cuts(const simplex_solver_settings_t& settings, const csr_matrix_t& cuts, diff --git a/cpp/src/dual_simplex/presolve.cpp b/cpp/src/dual_simplex/presolve.cpp index 9adf5bf0e9..69661a83c5 100644 --- a/cpp/src/dual_simplex/presolve.cpp +++ b/cpp/src/dual_simplex/presolve.cpp @@ -15,6 +15,7 @@ #include #include +#include #include namespace cuopt::mathematical_optimization::simplex { @@ -1885,60 +1886,66 @@ void uncrush_solution(const presolve_info_t& presolve_info, #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template void convert_user_problem( +template CUOPT_INTERNAL_EXPORT void convert_user_problem( const user_problem_t& user_problem, const simplex_solver_settings_t& settings, lp_problem_t& problem, std::vector& new_slacks, dualize_info_t& dualize_info); -template void convert_user_lp_with_guess( +template CUOPT_INTERNAL_EXPORT void convert_user_lp_with_guess( const user_problem_t& user_problem, const lp_solution_t& initial_solution, const std::vector& initial_slack, lp_problem_t& lp, lp_solution_t& converted_solution); -template int presolve(const lp_problem_t& original, - const simplex_solver_settings_t& settings, - lp_problem_t& presolved, - presolve_info_t& presolve_info); - -template void crush_primal_solution(const user_problem_t& user_problem, - const lp_problem_t& problem, - const std::vector& user_solution, - const std::vector& new_slacks, - std::vector& solution); - -template double crush_dual_solution(const user_problem_t& user_problem, - const lp_problem_t& problem, - const std::vector& new_slacks, - const std::vector& user_y, - const std::vector& user_z, - std::vector& y, - std::vector& z); - -template void uncrush_primal_solution(const user_problem_t& user_problem, - const lp_problem_t& problem, - const std::vector& solution, - std::vector& user_solution); - -template void uncrush_dual_solution(const user_problem_t& user_problem, - const lp_problem_t& problem, - const std::vector& y, - const std::vector& z, - std::vector& user_y, - std::vector& user_z); - -template void uncrush_solution(const presolve_info_t& presolve_info, - const simplex_solver_settings_t& settings, - const lp_problem_t& original_problem, - const std::vector& crushed_x, - const std::vector& crushed_y, - const std::vector& crushed_z, - std::vector& uncrushed_x, - std::vector& uncrushed_y, - std::vector& uncrushed_z); +template CUOPT_INTERNAL_EXPORT int presolve( + const lp_problem_t& original, + const simplex_solver_settings_t& settings, + lp_problem_t& presolved, + presolve_info_t& presolve_info); + +template CUOPT_INTERNAL_EXPORT void crush_primal_solution( + const user_problem_t& user_problem, + const lp_problem_t& problem, + const std::vector& user_solution, + const std::vector& new_slacks, + std::vector& solution); + +template CUOPT_INTERNAL_EXPORT double crush_dual_solution( + const user_problem_t& user_problem, + const lp_problem_t& problem, + const std::vector& new_slacks, + const std::vector& user_y, + const std::vector& user_z, + std::vector& y, + std::vector& z); + +template CUOPT_INTERNAL_EXPORT void uncrush_primal_solution( + const user_problem_t& user_problem, + const lp_problem_t& problem, + const std::vector& solution, + std::vector& user_solution); + +template CUOPT_INTERNAL_EXPORT void uncrush_dual_solution( + const user_problem_t& user_problem, + const lp_problem_t& problem, + const std::vector& y, + const std::vector& z, + std::vector& user_y, + std::vector& user_z); + +template CUOPT_INTERNAL_EXPORT void uncrush_solution( + const presolve_info_t& presolve_info, + const simplex_solver_settings_t& settings, + const lp_problem_t& original_problem, + const std::vector& crushed_x, + const std::vector& crushed_y, + const std::vector& crushed_z, + std::vector& uncrushed_x, + std::vector& uncrushed_y, + std::vector& uncrushed_z); #endif diff --git a/cpp/src/dual_simplex/right_looking_lu.cpp b/cpp/src/dual_simplex/right_looking_lu.cpp index 6a717cd257..f366fae329 100644 --- a/cpp/src/dual_simplex/right_looking_lu.cpp +++ b/cpp/src/dual_simplex/right_looking_lu.cpp @@ -13,6 +13,7 @@ #include #include +#include using cuopt::ins_vector; @@ -1808,14 +1809,15 @@ template int right_looking_lu_row_permutation_only( std::vector& q, std::vector& pinv); -template int right_looking_ldlt(const csc_matrix_t& A, - const simplex_solver_settings_t& settings, - double pivot_tol, - double start_time, - std::vector& perm, - csc_matrix_t& L, - std::vector& D, - double& work_estimate); +template CUOPT_INTERNAL_EXPORT int right_looking_ldlt( + const csc_matrix_t& A, + const simplex_solver_settings_t& settings, + double pivot_tol, + double start_time, + std::vector& perm, + csc_matrix_t& L, + std::vector& D, + double& work_estimate); #endif } // namespace cuopt::mathematical_optimization::simplex diff --git a/cpp/src/dual_simplex/scaling.cpp b/cpp/src/dual_simplex/scaling.cpp index 21f42a29dd..5daa7abb58 100644 --- a/cpp/src/dual_simplex/scaling.cpp +++ b/cpp/src/dual_simplex/scaling.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace cuopt::mathematical_optimization::simplex { @@ -269,20 +270,22 @@ void unscale_solution(const std::vector& column_scaling, #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template int scaling(const lp_problem_t& unscaled, - const simplex_solver_settings_t& settings, - lp_problem_t& scaled, - std::vector& column_scaling, - std::vector& row_scaling); +template CUOPT_INTERNAL_EXPORT int scaling( + const lp_problem_t& unscaled, + const simplex_solver_settings_t& settings, + lp_problem_t& scaled, + std::vector& column_scaling, + std::vector& row_scaling); -template void unscale_solution(const std::vector& column_scaling, - const std::vector& row_scaling, - const std::vector& scaled_x, - const std::vector& scaled_y, - const std::vector& scaled_z, - std::vector& unscaled_x, - std::vector& unscaled_y, - std::vector& unscaled_z); +template CUOPT_INTERNAL_EXPORT void unscale_solution( + const std::vector& column_scaling, + const std::vector& row_scaling, + const std::vector& scaled_x, + const std::vector& scaled_y, + const std::vector& scaled_z, + std::vector& unscaled_x, + std::vector& unscaled_y, + std::vector& unscaled_z); #endif diff --git a/cpp/src/dual_simplex/solve.cpp b/cpp/src/dual_simplex/solve.cpp index 697af9e869..7452280b05 100644 --- a/cpp/src/dual_simplex/solve.cpp +++ b/cpp/src/dual_simplex/solve.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -783,62 +784,66 @@ i_t solve_mip_with_guess(const user_problem_t& problem, #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template bool is_mip(const user_problem_t& problem); - -template double compute_objective(const lp_problem_t& problem, - const std::vector& x); - -template double compute_user_objective(const lp_problem_t& lp, - const std::vector& x); - -template double compute_user_objective(const lp_problem_t& lp, double obj); - -template lp_status_t solve_linear_program_advanced( - const lp_problem_t& original_lp, - const double start_time, - const simplex_solver_settings_t& settings, - lp_solution_t& original_solution, - std::vector& vstatus, - std::vector& edge_norms, - work_limit_context_t* work_unit_context); - -template lp_status_t solve_linear_program_with_advanced_basis( - const lp_problem_t& original_lp, - const double start_time, - const simplex_solver_settings_t& settings, - lp_solution_t& original_solution, - basis_update_mpf_t& ft, - std::vector& basic_list, - std::vector& nonbasic_list, - std::vector& vstatus, - std::vector& edge_norms, - work_limit_context_t* work_unit_context); - -template lp_status_t solve_linear_program_with_barrier( - const user_problem_t& user_problem, - const simplex_solver_settings_t& settings, - lp_solution_t& solution); - -template lp_status_t solve_linear_program_with_barrier( +template CUOPT_INTERNAL_EXPORT bool is_mip(const user_problem_t& problem); + +template CUOPT_INTERNAL_EXPORT double compute_objective( + const lp_problem_t& problem, const std::vector& x); + +template CUOPT_INTERNAL_EXPORT double compute_user_objective( + const lp_problem_t& lp, const std::vector& x); + +template CUOPT_INTERNAL_EXPORT double compute_user_objective(const lp_problem_t& lp, + double obj); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program_advanced(const lp_problem_t& original_lp, + const double start_time, + const simplex_solver_settings_t& settings, + lp_solution_t& original_solution, + std::vector& vstatus, + std::vector& edge_norms, + work_limit_context_t* work_unit_context); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program_with_advanced_basis(const lp_problem_t& original_lp, + const double start_time, + const simplex_solver_settings_t& settings, + lp_solution_t& original_solution, + basis_update_mpf_t& ft, + std::vector& basic_list, + std::vector& nonbasic_list, + std::vector& vstatus, + std::vector& edge_norms, + work_limit_context_t* work_unit_context); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program_with_barrier(const user_problem_t& user_problem, + const simplex_solver_settings_t& settings, + lp_solution_t& solution); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program_with_barrier(const user_problem_t& user_problem, + const simplex_solver_settings_t& settings, + double start_time, + lp_solution_t& solution); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program(const user_problem_t& user_problem, + const simplex_solver_settings_t& settings, + lp_solution_t& solution); + +template CUOPT_INTERNAL_EXPORT lp_status_t +solve_linear_program(const user_problem_t& user_problem, + const simplex_solver_settings_t& settings, + double start_time, + lp_solution_t& solution); + +template CUOPT_INTERNAL_EXPORT int solve( const user_problem_t& user_problem, const simplex_solver_settings_t& settings, - double start_time, - lp_solution_t& solution); - -template lp_status_t solve_linear_program(const user_problem_t& user_problem, - const simplex_solver_settings_t& settings, - lp_solution_t& solution); - -template lp_status_t solve_linear_program(const user_problem_t& user_problem, - const simplex_solver_settings_t& settings, - double start_time, - lp_solution_t& solution); - -template int solve(const user_problem_t& user_problem, - const simplex_solver_settings_t& settings, - std::vector& primal_solution); + std::vector& primal_solution); -template int solve_mip_with_guess( +template CUOPT_INTERNAL_EXPORT int solve_mip_with_guess( const user_problem_t& problem, const simplex_solver_settings_t& settings, const std::vector& guess, diff --git a/cpp/src/grpc/client/solve_remote.cpp b/cpp/src/grpc/client/solve_remote.cpp index e8fbdf7139..eabea39e05 100644 --- a/cpp/src/grpc/client/solve_remote.cpp +++ b/cpp/src/grpc/client/solve_remote.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -218,10 +219,10 @@ std::unique_ptr> solve_mip_remote( } // Explicit template instantiations for remote execution stubs -template std::unique_ptr> solve_lp_remote( +template CUOPT_EXPORT std::unique_ptr> solve_lp_remote( cpu_optimization_problem_t const&, pdlp_solver_settings_t const&); -template std::unique_ptr> solve_mip_remote( +template CUOPT_EXPORT std::unique_ptr> solve_mip_remote( cpu_optimization_problem_t const&, mip_solver_settings_t const&); } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/grpc/grpc_problem_mapper.cpp b/cpp/src/grpc/grpc_problem_mapper.cpp index c9698b7976..e330bca6f6 100644 --- a/cpp/src/grpc/grpc_problem_mapper.cpp +++ b/cpp/src/grpc/grpc_problem_mapper.cpp @@ -5,6 +5,8 @@ #include "grpc_problem_mapper.hpp" +#include + #include #include #include @@ -214,60 +216,64 @@ std::vector build_array_chunk_requests( // Explicit template instantiations #if CUOPT_INSTANTIATE_FLOAT -template void map_problem_to_proto(const cpu_optimization_problem_t& cpu_problem, - cuopt::remote::OptimizationProblem* pb_problem); -template void map_proto_to_problem(const cuopt::remote::OptimizationProblem& pb_problem, - cpu_optimization_problem_t& cpu_problem); -template size_t estimate_problem_proto_size( - const cpu_optimization_problem_t& cpu_problem); -template void populate_chunked_header_lp( +template CUOPT_EXPORT void map_problem_to_proto( + const cpu_optimization_problem_t& cpu_problem, + cuopt::remote::OptimizationProblem* pb_problem); +template CUOPT_EXPORT void map_proto_to_problem( + const cuopt::remote::OptimizationProblem& pb_problem, + cpu_optimization_problem_t& cpu_problem); +template CUOPT_EXPORT size_t +estimate_problem_proto_size(const cpu_optimization_problem_t& cpu_problem); +template CUOPT_EXPORT void populate_chunked_header_lp( const cpu_optimization_problem_t& cpu_problem, const pdlp_solver_settings_t& settings, cuopt::remote::ChunkedProblemHeader* header); -template void populate_chunked_header_mip( +template CUOPT_EXPORT void populate_chunked_header_mip( const cpu_optimization_problem_t& cpu_problem, const mip_solver_settings_t& settings, bool enable_incumbents, cuopt::remote::ChunkedProblemHeader* header); -template void map_chunked_header_to_problem( +template CUOPT_EXPORT void map_chunked_header_to_problem( const cuopt::remote::ChunkedProblemHeader& header, cpu_optimization_problem_t& cpu_problem); -template void map_chunked_arrays_to_problem( +template CUOPT_EXPORT void map_chunked_arrays_to_problem( const cuopt::remote::ChunkedProblemHeader& header, const std::map>& arrays, const std::map>& container_arrays, cpu_optimization_problem_t& cpu_problem); -template std::vector build_array_chunk_requests( +template CUOPT_EXPORT std::vector build_array_chunk_requests( const cpu_optimization_problem_t& problem, const std::string& upload_id, int64_t chunk_size_bytes); #endif #if CUOPT_INSTANTIATE_DOUBLE -template void map_problem_to_proto(const cpu_optimization_problem_t& cpu_problem, - cuopt::remote::OptimizationProblem* pb_problem); -template void map_proto_to_problem(const cuopt::remote::OptimizationProblem& pb_problem, - cpu_optimization_problem_t& cpu_problem); -template size_t estimate_problem_proto_size( - const cpu_optimization_problem_t& cpu_problem); -template void populate_chunked_header_lp( +template CUOPT_EXPORT void map_problem_to_proto( + const cpu_optimization_problem_t& cpu_problem, + cuopt::remote::OptimizationProblem* pb_problem); +template CUOPT_EXPORT void map_proto_to_problem( + const cuopt::remote::OptimizationProblem& pb_problem, + cpu_optimization_problem_t& cpu_problem); +template CUOPT_EXPORT size_t +estimate_problem_proto_size(const cpu_optimization_problem_t& cpu_problem); +template CUOPT_EXPORT void populate_chunked_header_lp( const cpu_optimization_problem_t& cpu_problem, const pdlp_solver_settings_t& settings, cuopt::remote::ChunkedProblemHeader* header); -template void populate_chunked_header_mip( +template CUOPT_EXPORT void populate_chunked_header_mip( const cpu_optimization_problem_t& cpu_problem, const mip_solver_settings_t& settings, bool enable_incumbents, cuopt::remote::ChunkedProblemHeader* header); -template void map_chunked_header_to_problem( +template CUOPT_EXPORT void map_chunked_header_to_problem( const cuopt::remote::ChunkedProblemHeader& header, cpu_optimization_problem_t& cpu_problem); -template void map_chunked_arrays_to_problem( +template CUOPT_EXPORT void map_chunked_arrays_to_problem( const cuopt::remote::ChunkedProblemHeader& header, const std::map>& arrays, const std::map>& container_arrays, cpu_optimization_problem_t& cpu_problem); -template std::vector build_array_chunk_requests( +template CUOPT_EXPORT std::vector build_array_chunk_requests( const cpu_optimization_problem_t& problem, const std::string& upload_id, int64_t chunk_size_bytes); diff --git a/cpp/src/grpc/grpc_settings_mapper.cpp b/cpp/src/grpc/grpc_settings_mapper.cpp index 34926f89e2..5c076c5e3d 100644 --- a/cpp/src/grpc/grpc_settings_mapper.cpp +++ b/cpp/src/grpc/grpc_settings_mapper.cpp @@ -5,6 +5,8 @@ #include "grpc_settings_mapper.hpp" +#include + #include #include #include @@ -92,25 +94,33 @@ void map_proto_to_mip_settings(const cuopt::remote::MIPSolverSettings& pb_settin // Explicit template instantiations #if CUOPT_INSTANTIATE_FLOAT -template void map_pdlp_settings_to_proto(const pdlp_solver_settings_t& settings, - cuopt::remote::PDLPSolverSettings* pb_settings); -template void map_proto_to_pdlp_settings(const cuopt::remote::PDLPSolverSettings& pb_settings, - pdlp_solver_settings_t& settings); -template void map_mip_settings_to_proto(const mip_solver_settings_t& settings, - cuopt::remote::MIPSolverSettings* pb_settings); -template void map_proto_to_mip_settings(const cuopt::remote::MIPSolverSettings& pb_settings, - mip_solver_settings_t& settings); +template CUOPT_EXPORT void map_pdlp_settings_to_proto( + const pdlp_solver_settings_t& settings, + cuopt::remote::PDLPSolverSettings* pb_settings); +template CUOPT_EXPORT void map_proto_to_pdlp_settings( + const cuopt::remote::PDLPSolverSettings& pb_settings, + pdlp_solver_settings_t& settings); +template CUOPT_EXPORT void map_mip_settings_to_proto( + const mip_solver_settings_t& settings, + cuopt::remote::MIPSolverSettings* pb_settings); +template CUOPT_EXPORT void map_proto_to_mip_settings( + const cuopt::remote::MIPSolverSettings& pb_settings, + mip_solver_settings_t& settings); #endif #if CUOPT_INSTANTIATE_DOUBLE -template void map_pdlp_settings_to_proto(const pdlp_solver_settings_t& settings, - cuopt::remote::PDLPSolverSettings* pb_settings); -template void map_proto_to_pdlp_settings(const cuopt::remote::PDLPSolverSettings& pb_settings, - pdlp_solver_settings_t& settings); -template void map_mip_settings_to_proto(const mip_solver_settings_t& settings, - cuopt::remote::MIPSolverSettings* pb_settings); -template void map_proto_to_mip_settings(const cuopt::remote::MIPSolverSettings& pb_settings, - mip_solver_settings_t& settings); +template CUOPT_EXPORT void map_pdlp_settings_to_proto( + const pdlp_solver_settings_t& settings, + cuopt::remote::PDLPSolverSettings* pb_settings); +template CUOPT_EXPORT void map_proto_to_pdlp_settings( + const cuopt::remote::PDLPSolverSettings& pb_settings, + pdlp_solver_settings_t& settings); +template CUOPT_EXPORT void map_mip_settings_to_proto( + const mip_solver_settings_t& settings, + cuopt::remote::MIPSolverSettings* pb_settings); +template CUOPT_EXPORT void map_proto_to_mip_settings( + const cuopt::remote::MIPSolverSettings& pb_settings, + mip_solver_settings_t& settings); #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/grpc/grpc_solution_mapper.cpp b/cpp/src/grpc/grpc_solution_mapper.cpp index 5a823986d6..7b71614628 100644 --- a/cpp/src/grpc/grpc_solution_mapper.cpp +++ b/cpp/src/grpc/grpc_solution_mapper.cpp @@ -5,6 +5,8 @@ #include "grpc_solution_mapper.hpp" +#include + #include #include #include @@ -193,66 +195,66 @@ void build_mip_solution_proto(const cuopt::remote::ChunkedResultHeader& header, // Explicit template instantiations #if CUOPT_INSTANTIATE_FLOAT -template void map_lp_solution_to_proto(const cpu_lp_solution_t& solution, - cuopt::remote::LPSolution* pb_solution); -template cpu_lp_solution_t map_proto_to_lp_solution( +template CUOPT_EXPORT void map_lp_solution_to_proto( + const cpu_lp_solution_t& solution, cuopt::remote::LPSolution* pb_solution); +template CUOPT_EXPORT cpu_lp_solution_t map_proto_to_lp_solution( const cuopt::remote::LPSolution& pb_solution); -template void map_mip_solution_to_proto(const cpu_mip_solution_t& solution, - cuopt::remote::MIPSolution* pb_solution); -template cpu_mip_solution_t map_proto_to_mip_solution( +template CUOPT_EXPORT void map_mip_solution_to_proto( + const cpu_mip_solution_t& solution, cuopt::remote::MIPSolution* pb_solution); +template CUOPT_EXPORT cpu_mip_solution_t map_proto_to_mip_solution( const cuopt::remote::MIPSolution& pb_solution); -template void populate_chunked_result_header_lp(const cpu_lp_solution_t& solution, - cuopt::remote::ChunkedResultHeader* header); -template void populate_chunked_result_header_mip(const cpu_mip_solution_t& solution, - cuopt::remote::ChunkedResultHeader* header); -template std::map> collect_lp_solution_arrays( +template CUOPT_EXPORT void populate_chunked_result_header_lp( + const cpu_lp_solution_t& solution, cuopt::remote::ChunkedResultHeader* header); +template CUOPT_EXPORT void populate_chunked_result_header_mip( + const cpu_mip_solution_t& solution, cuopt::remote::ChunkedResultHeader* header); +template CUOPT_EXPORT std::map> collect_lp_solution_arrays( const cpu_lp_solution_t& solution); -template std::map> collect_mip_solution_arrays( +template CUOPT_EXPORT std::map> collect_mip_solution_arrays( const cpu_mip_solution_t& solution); -template cpu_lp_solution_t chunked_result_to_lp_solution( +template CUOPT_EXPORT cpu_lp_solution_t chunked_result_to_lp_solution( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays); -template cpu_mip_solution_t chunked_result_to_mip_solution( +template CUOPT_EXPORT cpu_mip_solution_t chunked_result_to_mip_solution( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays); -template void build_lp_solution_proto( +template CUOPT_EXPORT void build_lp_solution_proto( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays, cuopt::remote::LPSolution* proto); -template void build_mip_solution_proto( +template CUOPT_EXPORT void build_mip_solution_proto( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays, cuopt::remote::MIPSolution* proto); #endif #if CUOPT_INSTANTIATE_DOUBLE -template void map_lp_solution_to_proto(const cpu_lp_solution_t& solution, - cuopt::remote::LPSolution* pb_solution); -template cpu_lp_solution_t map_proto_to_lp_solution( +template CUOPT_EXPORT void map_lp_solution_to_proto( + const cpu_lp_solution_t& solution, cuopt::remote::LPSolution* pb_solution); +template CUOPT_EXPORT cpu_lp_solution_t map_proto_to_lp_solution( const cuopt::remote::LPSolution& pb_solution); -template void map_mip_solution_to_proto(const cpu_mip_solution_t& solution, - cuopt::remote::MIPSolution* pb_solution); -template cpu_mip_solution_t map_proto_to_mip_solution( +template CUOPT_EXPORT void map_mip_solution_to_proto( + const cpu_mip_solution_t& solution, cuopt::remote::MIPSolution* pb_solution); +template CUOPT_EXPORT cpu_mip_solution_t map_proto_to_mip_solution( const cuopt::remote::MIPSolution& pb_solution); -template void populate_chunked_result_header_lp(const cpu_lp_solution_t& solution, - cuopt::remote::ChunkedResultHeader* header); -template void populate_chunked_result_header_mip( +template CUOPT_EXPORT void populate_chunked_result_header_lp( + const cpu_lp_solution_t& solution, cuopt::remote::ChunkedResultHeader* header); +template CUOPT_EXPORT void populate_chunked_result_header_mip( const cpu_mip_solution_t& solution, cuopt::remote::ChunkedResultHeader* header); -template std::map> collect_lp_solution_arrays( +template CUOPT_EXPORT std::map> collect_lp_solution_arrays( const cpu_lp_solution_t& solution); -template std::map> collect_mip_solution_arrays( +template CUOPT_EXPORT std::map> collect_mip_solution_arrays( const cpu_mip_solution_t& solution); -template cpu_lp_solution_t chunked_result_to_lp_solution( +template CUOPT_EXPORT cpu_lp_solution_t chunked_result_to_lp_solution( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays); -template cpu_mip_solution_t chunked_result_to_mip_solution( +template CUOPT_EXPORT cpu_mip_solution_t chunked_result_to_mip_solution( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays); -template void build_lp_solution_proto( +template CUOPT_EXPORT void build_lp_solution_proto( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays, cuopt::remote::LPSolution* proto); -template void build_mip_solution_proto( +template CUOPT_EXPORT void build_mip_solution_proto( const cuopt::remote::ChunkedResultHeader& header, const std::map>& arrays, cuopt::remote::MIPSolution* proto); diff --git a/cpp/src/io/data_model_view.cpp b/cpp/src/io/data_model_view.cpp index 132d87b866..df1efcd52f 100644 --- a/cpp/src/io/data_model_view.cpp +++ b/cpp/src/io/data_model_view.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -377,8 +378,8 @@ data_model_view_t::get_quadratic_constraints() const noexcept } // NOTE: Explicitly instantiate all types here in order to avoid linker error -template class data_model_view_t; +template class CUOPT_EXPORT data_model_view_t; -template class data_model_view_t; +template class CUOPT_EXPORT data_model_view_t; } // namespace cuopt::mathematical_optimization::io diff --git a/cpp/src/io/lp_parser.cpp b/cpp/src/io/lp_parser.cpp index cf9d8d6538..5de0565801 100644 --- a/cpp/src/io/lp_parser.cpp +++ b/cpp/src/io/lp_parser.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -1526,9 +1527,11 @@ mps_data_model_t read_lp_from_string(std::string_view lp_contents) return problem; } -template mps_data_model_t read_lp(const std::string&); -template mps_data_model_t read_lp(const std::string&); -template mps_data_model_t read_lp_from_string(std::string_view); -template mps_data_model_t read_lp_from_string(std::string_view); +template CUOPT_EXPORT mps_data_model_t read_lp(const std::string&); +template CUOPT_EXPORT mps_data_model_t read_lp(const std::string&); +template CUOPT_EXPORT mps_data_model_t read_lp_from_string( + std::string_view); +template CUOPT_EXPORT mps_data_model_t read_lp_from_string( + std::string_view); } // namespace cuopt::mathematical_optimization::io diff --git a/cpp/src/io/mps_data_model.cpp b/cpp/src/io/mps_data_model.cpp index 941f16a96a..f3444fe12f 100644 --- a/cpp/src/io/mps_data_model.cpp +++ b/cpp/src/io/mps_data_model.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -469,13 +470,13 @@ void canonicalize_quadratic_constraints( } // NOTE: Explicitly instantiate all types here in order to avoid linker error -template class mps_data_model_t; +template class CUOPT_EXPORT mps_data_model_t; -template class mps_data_model_t; +template class CUOPT_EXPORT mps_data_model_t; -template void canonicalize_quadratic_constraints( +template CUOPT_EXPORT void canonicalize_quadratic_constraints( std::vector::quadratic_constraint_t>&); -template void canonicalize_quadratic_constraints( +template CUOPT_EXPORT void canonicalize_quadratic_constraints( std::vector::quadratic_constraint_t>&); // TODO current raft to cusparse wrappers only support int64_t // can be CUSPARSE_INDEX_16U, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_64I diff --git a/cpp/src/io/mps_parser.cpp b/cpp/src/io/mps_parser.cpp index be8717806b..1f9c725aa2 100644 --- a/cpp/src/io/mps_parser.cpp +++ b/cpp/src/io/mps_parser.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1709,7 +1710,7 @@ void mps_parser_t::read_bound_and_value(std::string_view line, // NOTE: Explicitly instantiate all types here in order to avoid linker error template class mps_parser_t; -template class mps_parser_t; +template class CUOPT_INTERNAL_EXPORT mps_parser_t; template void canonicalize_coo_matrix(std::vector&, std::vector&, diff --git a/cpp/src/io/mps_writer.cpp b/cpp/src/io/mps_writer.cpp index d269d6ec8a..31a0bbc25c 100644 --- a/cpp/src/io/mps_writer.cpp +++ b/cpp/src/io/mps_writer.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -530,7 +531,7 @@ void mps_writer_t::write(const std::string& mps_file_path) mps_file.close(); } -template class mps_writer_t; -template class mps_writer_t; +template class CUOPT_EXPORT mps_writer_t; +template class CUOPT_EXPORT mps_writer_t; } // namespace cuopt::mathematical_optimization::io diff --git a/cpp/src/io/parser.cpp b/cpp/src/io/parser.cpp index 20e80185b3..b0d3833c4c 100644 --- a/cpp/src/io/parser.cpp +++ b/cpp/src/io/parser.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -28,11 +29,13 @@ mps_data_model_t read_mps_from_string(std::string_view mps_contents, return problem; } -template mps_data_model_t read_mps(const std::string& mps_file, bool fixed_mps_format); -template mps_data_model_t read_mps(const std::string& mps_file, bool fixed_mps_format); -template mps_data_model_t read_mps_from_string(std::string_view mps_contents, - bool fixed_mps_format); -template mps_data_model_t read_mps_from_string(std::string_view mps_contents, +template CUOPT_EXPORT mps_data_model_t read_mps(const std::string& mps_file, bool fixed_mps_format); +template CUOPT_EXPORT mps_data_model_t read_mps(const std::string& mps_file, + bool fixed_mps_format); +template CUOPT_EXPORT mps_data_model_t read_mps_from_string( + std::string_view mps_contents, bool fixed_mps_format); +template CUOPT_EXPORT mps_data_model_t read_mps_from_string( + std::string_view mps_contents, bool fixed_mps_format); } // namespace cuopt::mathematical_optimization::io diff --git a/cpp/src/io/writer.cpp b/cpp/src/io/writer.cpp index c67a1aac4b..eeb11b7dc0 100644 --- a/cpp/src/io/writer.cpp +++ b/cpp/src/io/writer.cpp @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -18,9 +19,9 @@ void write_mps(const data_model_view_t& problem, const std::string& mp writer.write(mps_file_path); } -template void write_mps(const data_model_view_t& problem, - const std::string& mps_file_path); -template void write_mps(const data_model_view_t& problem, - const std::string& mps_file_path); +template CUOPT_EXPORT void write_mps(const data_model_view_t& problem, + const std::string& mps_file_path); +template CUOPT_EXPORT void write_mps(const data_model_view_t& problem, + const std::string& mps_file_path); } // namespace cuopt::mathematical_optimization::io diff --git a/cpp/src/linear_algebra/sparse_matrix.cpp b/cpp/src/linear_algebra/sparse_matrix.cpp index 158fecefcf..37a82968ba 100644 --- a/cpp/src/linear_algebra/sparse_matrix.cpp +++ b/cpp/src/linear_algebra/sparse_matrix.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace cuopt::mathematical_optimization { @@ -941,14 +942,14 @@ f_t sparse_dot(const std::vector& xind, #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT // Minimal float instantiation for LP usage -template class csc_matrix_t; -template class csr_matrix_t; +template class CUOPT_INTERNAL_EXPORT csc_matrix_t; +template class CUOPT_INTERNAL_EXPORT csr_matrix_t; #endif #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template class csc_matrix_t; +template class CUOPT_INTERNAL_EXPORT csc_matrix_t; -template class csr_matrix_t; +template class CUOPT_INTERNAL_EXPORT csr_matrix_t; template void cumulative_sum(std::vector& inout, std::vector& output); @@ -988,15 +989,15 @@ template int add(const csc_matrix_t& A, double beta, csc_matrix_t& C); -template double sparse_dot(const std::vector& xind, - const std::vector& xval, - const csc_matrix_t& Y, - int y_col); +template CUOPT_INTERNAL_EXPORT double sparse_dot(const std::vector& xind, + const std::vector& xval, + const csc_matrix_t& Y, + int y_col); // NOTE: matrix_vector_multiply is now templated on VectorX and VectorY. // Since it's defined inline in the header, no explicit instantiation is needed here. -template int +template CUOPT_INTERNAL_EXPORT int matrix_transpose_vector_multiply, std::allocator>( const csc_matrix_t& A, double alpha, diff --git a/cpp/src/linear_algebra/sparse_vector.cpp b/cpp/src/linear_algebra/sparse_vector.cpp index 17839b342f..6f973d3c01 100644 --- a/cpp/src/linear_algebra/sparse_vector.cpp +++ b/cpp/src/linear_algebra/sparse_vector.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace cuopt::mathematical_optimization { @@ -282,7 +283,7 @@ void sparse_vector_t::squeeze(sparse_vector_t& y) const } #ifdef DUAL_SIMPLEX_INSTANTIATE_DOUBLE -template class sparse_vector_t; +template class CUOPT_INTERNAL_EXPORT sparse_vector_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/math_optimization/solution_reader.hpp b/cpp/src/math_optimization/solution_reader.hpp index dd0976028a..18d065dc9b 100644 --- a/cpp/src/math_optimization/solution_reader.hpp +++ b/cpp/src/math_optimization/solution_reader.hpp @@ -7,10 +7,14 @@ #pragma once +#include + #include #include -namespace cuopt::mathematical_optimization { +namespace cuopt { +// Ideally internal symbol should not be exported, but cuopt_cli uses it +namespace CUOPT_EXPORT mathematical_optimization { /** * @brief Reads a solution file and returns the values of specified variables @@ -24,4 +28,5 @@ class solution_reader_t { static std::vector get_variable_values_from_sol_file( const std::string& sol_file_path, const std::vector& variable_names); }; -} // namespace cuopt::mathematical_optimization +} // namespace CUOPT_EXPORT mathematical_optimization +} // namespace cuopt diff --git a/cpp/src/math_optimization/solver_settings.cu b/cpp/src/math_optimization/solver_settings.cu index 8bfd7cd8ba..4164e634b2 100644 --- a/cpp/src/math_optimization/solver_settings.cu +++ b/cpp/src/math_optimization/solver_settings.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -652,25 +653,39 @@ bool solver_settings_t::dump_parameters_to_file(const std::string& pat } #if MIP_INSTANTIATE_FLOAT -template class solver_settings_t; -template void solver_settings_t::set_parameter(const std::string& name, int value); -template void solver_settings_t::set_parameter(const std::string& name, float value); -template void solver_settings_t::set_parameter(const std::string& name, bool value); -template int solver_settings_t::get_parameter(const std::string& name) const; -template float solver_settings_t::get_parameter(const std::string& name) const; -template bool solver_settings_t::get_parameter(const std::string& name) const; -template std::string solver_settings_t::get_parameter(const std::string& name) const; +template class CUOPT_EXPORT solver_settings_t; +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + int value); +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + float value); +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + bool value); +template CUOPT_EXPORT int solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT float solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT bool solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT std::string solver_settings_t::get_parameter( + const std::string& name) const; #endif #if MIP_INSTANTIATE_DOUBLE -template class solver_settings_t; -template void solver_settings_t::set_parameter(const std::string& name, int value); -template void solver_settings_t::set_parameter(const std::string& name, double value); -template void solver_settings_t::set_parameter(const std::string& name, bool value); -template int solver_settings_t::get_parameter(const std::string& name) const; -template double solver_settings_t::get_parameter(const std::string& name) const; -template bool solver_settings_t::get_parameter(const std::string& name) const; -template std::string solver_settings_t::get_parameter(const std::string& name) const; +template class CUOPT_EXPORT solver_settings_t; +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + int value); +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + double value); +template CUOPT_EXPORT void solver_settings_t::set_parameter(const std::string& name, + bool value); +template CUOPT_EXPORT int solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT double solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT bool solver_settings_t::get_parameter( + const std::string& name) const; +template CUOPT_EXPORT std::string solver_settings_t::get_parameter( + const std::string& name) const; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/math_optimization/tic_toc.hpp b/cpp/src/math_optimization/tic_toc.hpp index e5ce719c74..7ea7723b68 100644 --- a/cpp/src/math_optimization/tic_toc.hpp +++ b/cpp/src/math_optimization/tic_toc.hpp @@ -7,10 +7,11 @@ #pragma once +#include #include namespace cuopt::mathematical_optimization { -double tic(); -double toc(double start); +CUOPT_INTERNAL_EXPORT double tic(); +CUOPT_INTERNAL_EXPORT double toc(double start); } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu index a6665e57e1..ff1947e0b8 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu +++ b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include "feasibility_jump.cuh" #include "feasibility_jump_kernels.cuh" @@ -1153,7 +1154,7 @@ template class fj_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class fj_t; +template class CUOPT_INTERNAL_EXPORT fj_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/bounds_presolve.cu b/cpp/src/mip_heuristics/presolve/bounds_presolve.cu index e5a7f249f1..4a0861e596 100644 --- a/cpp/src/mip_heuristics/presolve/bounds_presolve.cu +++ b/cpp/src/mip_heuristics/presolve/bounds_presolve.cu @@ -19,6 +19,7 @@ #include #include +#include #include "bounds_presolve.cuh" #include "bounds_presolve_helpers.cuh" #include "bounds_update_helpers.cuh" @@ -363,7 +364,7 @@ template class bound_presolve_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class bound_presolve_t; +template class CUOPT_INTERNAL_EXPORT bound_presolve_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/load_balanced_bounds_presolve.cu b/cpp/src/mip_heuristics/presolve/load_balanced_bounds_presolve.cu index 017bf32e91..e854800b0f 100644 --- a/cpp/src/mip_heuristics/presolve/load_balanced_bounds_presolve.cu +++ b/cpp/src/mip_heuristics/presolve/load_balanced_bounds_presolve.cu @@ -24,6 +24,7 @@ #include "load_balanced_bounds_presolve.cuh" #include "load_balanced_bounds_presolve_helpers.cuh" +#include #include namespace cuopt::mathematical_optimization::mip { @@ -694,7 +695,7 @@ template class load_balanced_bounds_presolve_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class load_balanced_bounds_presolve_t; +template class CUOPT_INTERNAL_EXPORT load_balanced_bounds_presolve_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/multi_probe.cu b/cpp/src/mip_heuristics/presolve/multi_probe.cu index f1adf28650..81e9a5c753 100644 --- a/cpp/src/mip_heuristics/presolve/multi_probe.cu +++ b/cpp/src/mip_heuristics/presolve/multi_probe.cu @@ -16,6 +16,7 @@ #include #include +#include #include "bounds_presolve_helpers.cuh" #include "bounds_update_helpers.cuh" #include "multi_probe.cuh" @@ -493,7 +494,7 @@ template class multi_probe_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class multi_probe_t; +template class CUOPT_INTERNAL_EXPORT multi_probe_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp b/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp index 64a25ff556..8a6d0ebf2a 100644 --- a/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp +++ b/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #if defined(__clang__) #pragma clang diagnostic push @@ -1149,7 +1150,7 @@ template class third_party_presolve_t; #if MIP_INSTANTIATE_DOUBLE template struct papilo_postsolve_deleter; -template class third_party_presolve_t; +template class CUOPT_INTERNAL_EXPORT third_party_presolve_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/problem/load_balanced_problem.cu b/cpp/src/mip_heuristics/problem/load_balanced_problem.cu index 3199750679..5c38c3de87 100644 --- a/cpp/src/mip_heuristics/problem/load_balanced_problem.cu +++ b/cpp/src/mip_heuristics/problem/load_balanced_problem.cu @@ -16,6 +16,7 @@ #include +#include #include "load_balanced_problem.cuh" namespace cuopt::mathematical_optimization::mip { @@ -403,7 +404,7 @@ template class load_balanced_problem_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class load_balanced_problem_t; +template class CUOPT_INTERNAL_EXPORT load_balanced_problem_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/problem/problem.cu b/cpp/src/mip_heuristics/problem/problem.cu index e38e889495..5e13cbc63c 100644 --- a/cpp/src/mip_heuristics/problem/problem.cu +++ b/cpp/src/mip_heuristics/problem/problem.cu @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -2490,11 +2491,11 @@ void problem_t::update_variable_bounds(const std::vector& var_ind } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class problem_t; +template class CUOPT_INTERNAL_EXPORT problem_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class problem_t; +template class CUOPT_INTERNAL_EXPORT problem_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/solution/solution.cu b/cpp/src/mip_heuristics/solution/solution.cu index 3b00fca7a8..091b066cc9 100644 --- a/cpp/src/mip_heuristics/solution/solution.cu +++ b/cpp/src/mip_heuristics/solution/solution.cu @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace cuopt::mathematical_optimization::mip { @@ -649,7 +650,7 @@ template class solution_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class solution_t; +template class CUOPT_INTERNAL_EXPORT solution_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/solve.cu b/cpp/src/mip_heuristics/solve.cu index 59b582188f..27242e7f0c 100644 --- a/cpp/src/mip_heuristics/solve.cu +++ b/cpp/src/mip_heuristics/solve.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include @@ -945,19 +946,19 @@ std::unique_ptr> solve_mip( } #define INSTANTIATE(F_TYPE) \ - template mip_solution_t solve_mip( \ + template CUOPT_EXPORT mip_solution_t solve_mip( \ optimization_problem_t& op_problem, \ mip_solver_settings_t const& settings); \ \ - template mip_solution_t solve_mip( \ + template CUOPT_EXPORT mip_solution_t solve_mip( \ raft::handle_t const* handle_ptr, \ const cuopt::mathematical_optimization::io::mps_data_model_t& mps_data_model, \ mip_solver_settings_t const& settings); \ \ - template std::unique_ptr> solve_mip( \ + template CUOPT_EXPORT std::unique_ptr> solve_mip( \ cpu_optimization_problem_t&, mip_solver_settings_t const&); \ \ - template std::unique_ptr> solve_mip( \ + template CUOPT_EXPORT std::unique_ptr> solve_mip( \ optimization_problem_interface_t*, mip_solver_settings_t const&); #if MIP_INSTANTIATE_FLOAT diff --git a/cpp/src/mip_heuristics/solver.cu b/cpp/src/mip_heuristics/solver.cu index 5f136cbf43..085e129480 100644 --- a/cpp/src/mip_heuristics/solver.cu +++ b/cpp/src/mip_heuristics/solver.cu @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -552,7 +553,7 @@ template class mip_solver_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class mip_solver_t; +template class CUOPT_INTERNAL_EXPORT mip_solver_t; #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/solver_settings.cu b/cpp/src/mip_heuristics/solver_settings.cu index 645b8c8b6e..8b454c949b 100644 --- a/cpp/src/mip_heuristics/solver_settings.cu +++ b/cpp/src/mip_heuristics/solver_settings.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -48,11 +49,11 @@ mip_solver_settings_t::get_tolerances() const noexcept // Explicit template instantiations for common types #if MIP_INSTANTIATE_FLOAT -template class mip_solver_settings_t; +template class CUOPT_EXPORT mip_solver_settings_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class mip_solver_settings_t; +template class CUOPT_EXPORT mip_solver_settings_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/mip_heuristics/solver_solution.cu b/cpp/src/mip_heuristics/solver_solution.cu index 5b59e9a0fa..1997d684dc 100644 --- a/cpp/src/mip_heuristics/solver_solution.cu +++ b/cpp/src/mip_heuristics/solver_solution.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -274,10 +275,10 @@ void mip_solution_t::log_detailed_summary() const } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class mip_solution_t; +template class CUOPT_EXPORT mip_solution_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class mip_solution_t; +template class CUOPT_EXPORT mip_solution_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/pdlp/cpu_optimization_problem.cpp b/cpp/src/pdlp/cpu_optimization_problem.cpp index 84f03b5e85..28d1ce1032 100644 --- a/cpp/src/pdlp/cpu_optimization_problem.cpp +++ b/cpp/src/pdlp/cpu_optimization_problem.cpp @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -1100,10 +1101,10 @@ void cpu_optimization_problem_t::copy_variable_types_to_host(var_t* ou // ============================================================================== #if MIP_INSTANTIATE_FLOAT -template class cpu_optimization_problem_t; +template class CUOPT_EXPORT cpu_optimization_problem_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class cpu_optimization_problem_t; +template class CUOPT_EXPORT cpu_optimization_problem_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/pdlp/cpu_pdlp_warm_start_data.cu b/cpp/src/pdlp/cpu_pdlp_warm_start_data.cu index 94c8ed5466..f2af28ba51 100644 --- a/cpp/src/pdlp/cpu_pdlp_warm_start_data.cu +++ b/cpp/src/pdlp/cpu_pdlp_warm_start_data.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -109,17 +110,17 @@ pdlp_warm_start_data_t convert_to_gpu_warmstart( } #if MIP_INSTANTIATE_DOUBLE -template cpu_pdlp_warm_start_data_t convert_to_cpu_warmstart( +template CUOPT_EXPORT cpu_pdlp_warm_start_data_t convert_to_cpu_warmstart( const pdlp_warm_start_data_t&, rmm::cuda_stream_view); -template pdlp_warm_start_data_t convert_to_gpu_warmstart( +template CUOPT_EXPORT pdlp_warm_start_data_t convert_to_gpu_warmstart( const cpu_pdlp_warm_start_data_t&, rmm::cuda_stream_view); #endif #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template cpu_pdlp_warm_start_data_t convert_to_cpu_warmstart( +template CUOPT_EXPORT cpu_pdlp_warm_start_data_t convert_to_cpu_warmstart( const pdlp_warm_start_data_t&, rmm::cuda_stream_view); -template pdlp_warm_start_data_t convert_to_gpu_warmstart( +template CUOPT_EXPORT pdlp_warm_start_data_t convert_to_gpu_warmstart( const cpu_pdlp_warm_start_data_t&, rmm::cuda_stream_view); #endif diff --git a/cpp/src/pdlp/cusparse_view.cu b/cpp/src/pdlp/cusparse_view.cu index 0974a49c82..f1ccf57425 100644 --- a/cpp/src/pdlp/cusparse_view.cu +++ b/cpp/src/pdlp/cusparse_view.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include @@ -1416,7 +1417,7 @@ void mixed_precision_spmv_preprocess(cusparseHandle_t handle, } #endif -bool is_cusparse_runtime_mixed_precision_supported() +CUOPT_INTERNAL_EXPORT bool is_cusparse_runtime_mixed_precision_supported() { int major = 0, minor = 0; auto status = cusparseGetProperty(libraryPropertyType_t::MAJOR_VERSION, &major); diff --git a/cpp/src/pdlp/optimization_problem.cu b/cpp/src/pdlp/optimization_problem.cu index 85d3ef4df4..95457e2556 100644 --- a/cpp/src/pdlp/optimization_problem.cu +++ b/cpp/src/pdlp/optimization_problem.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -1632,14 +1633,14 @@ optimization_problem_t optimization_problem_t::convert // ============================================================================== // Explicit template instantiations matching MIP constants #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class optimization_problem_t; +template class CUOPT_EXPORT optimization_problem_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class optimization_problem_t; +template class CUOPT_EXPORT optimization_problem_t; #endif #if PDLP_INSTANTIATE_FLOAT || MIP_INSTANTIATE_FLOAT -template optimization_problem_t +template CUOPT_EXPORT optimization_problem_t optimization_problem_t::convert_to_other_prec( rmm::cuda_stream_view) const; #endif diff --git a/cpp/src/pdlp/pdlp.cu b/cpp/src/pdlp/pdlp.cu index a936763fd4..b9552e80ca 100644 --- a/cpp/src/pdlp/pdlp.cu +++ b/cpp/src/pdlp/pdlp.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -3202,7 +3203,7 @@ pdlp_solver_t::get_current_termination_strategy() } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class pdlp_solver_t; +template class CUOPT_INTERNAL_EXPORT pdlp_solver_t; template __global__ void compute_weights_initial_primal_weight_from_squared_norms( const float* b_vec_norm, @@ -3214,7 +3215,7 @@ template __global__ void compute_weights_initial_primal_weight_from_squared_norm #endif #if MIP_INSTANTIATE_DOUBLE -template class pdlp_solver_t; +template class CUOPT_INTERNAL_EXPORT pdlp_solver_t; template __global__ void compute_weights_initial_primal_weight_from_squared_norms( const double* b_vec_norm, diff --git a/cpp/src/pdlp/pdlp_warm_start_data.cu b/cpp/src/pdlp/pdlp_warm_start_data.cu index 6039710423..a214f1a165 100644 --- a/cpp/src/pdlp/pdlp_warm_start_data.cu +++ b/cpp/src/pdlp/pdlp_warm_start_data.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -179,10 +180,10 @@ void pdlp_warm_start_data_t::check_sizes() } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class pdlp_warm_start_data_t; +template class CUOPT_EXPORT pdlp_warm_start_data_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class pdlp_warm_start_data_t; +template class CUOPT_EXPORT pdlp_warm_start_data_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/pdlp/solution_conversion.cu b/cpp/src/pdlp/solution_conversion.cu index 4e7336ea93..8293629e6f 100644 --- a/cpp/src/pdlp/solution_conversion.cu +++ b/cpp/src/pdlp/solution_conversion.cu @@ -10,6 +10,7 @@ * @brief Implementations of conversion methods from solution classes to Cython ret structs */ +#include #include #include #include @@ -215,11 +216,11 @@ cuopt::cython::mip_ret_t cpu_mip_solution_t::to_cpu_mip_ret_t() } // Explicit template instantiations -template cuopt::cython::linear_programming_ret_t +template CUOPT_EXPORT cuopt::cython::linear_programming_ret_t gpu_lp_solution_t::to_linear_programming_ret_t(); -template cuopt::cython::mip_ret_t gpu_mip_solution_t::to_mip_ret_t(); -template cuopt::cython::linear_programming_ret_t +template CUOPT_EXPORT cuopt::cython::mip_ret_t gpu_mip_solution_t::to_mip_ret_t(); +template CUOPT_EXPORT cuopt::cython::linear_programming_ret_t cpu_lp_solution_t::to_cpu_linear_programming_ret_t(); -template cuopt::cython::mip_ret_t cpu_mip_solution_t::to_cpu_mip_ret_t(); +template CUOPT_EXPORT cuopt::cython::mip_ret_t cpu_mip_solution_t::to_cpu_mip_ret_t(); } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/pdlp/solve.cu b/cpp/src/pdlp/solve.cu index 25b427fa9a..c68707c7c0 100644 --- a/cpp/src/pdlp/solve.cu +++ b/cpp/src/pdlp/solve.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -2306,28 +2307,28 @@ std::unique_ptr> solve_lp( } #define INSTANTIATE(F_TYPE) \ - template optimization_problem_solution_t solve_lp( \ + template CUOPT_EXPORT optimization_problem_solution_t solve_lp( \ optimization_problem_t& op_problem, \ pdlp_solver_settings_t const& settings, \ bool problem_checking, \ bool use_pdlp_solver_mode, \ bool is_batch_mode); \ \ - template optimization_problem_solution_t solve_lp( \ + template CUOPT_EXPORT optimization_problem_solution_t solve_lp( \ raft::handle_t const* handle_ptr, \ const cuopt::mathematical_optimization::io::mps_data_model_t& mps_data_model, \ pdlp_solver_settings_t const& settings, \ bool problem_checking, \ bool use_pdlp_solver_mode); \ \ - template std::unique_ptr> solve_lp( \ + template CUOPT_EXPORT std::unique_ptr> solve_lp( \ cpu_optimization_problem_t&, \ pdlp_solver_settings_t const&, \ bool, \ bool, \ bool); \ \ - template std::unique_ptr> solve_lp( \ + template CUOPT_EXPORT std::unique_ptr> solve_lp( \ optimization_problem_interface_t*, \ pdlp_solver_settings_t const&, \ bool, \ @@ -2340,7 +2341,7 @@ std::unique_ptr> solve_lp( const timer_t& timer, \ bool is_batch_mode); \ \ - template optimization_problem_solution_t batch_pdlp_solve( \ + template CUOPT_EXPORT optimization_problem_solution_t batch_pdlp_solve( \ raft::handle_t const* handle_ptr, \ const cuopt::mathematical_optimization::io::mps_data_model_t& mps_data_model, \ const std::vector& fractional, \ @@ -2356,7 +2357,8 @@ std::unique_ptr> solve_lp( bool per_climber_constraint_bounds, \ bool collect_solutions); \ \ - template optimization_problem_t mps_data_model_to_optimization_problem( \ + template CUOPT_EXPORT optimization_problem_t \ + mps_data_model_to_optimization_problem( \ raft::handle_t const* handle_ptr, \ const cuopt::mathematical_optimization::io::mps_data_model_t& data_model); \ template void set_pdlp_solver_mode(pdlp_solver_settings_t& settings); diff --git a/cpp/src/pdlp/solver_settings.cu b/cpp/src/pdlp/solver_settings.cu index 3b8e34ce5b..33d8f1a64b 100644 --- a/cpp/src/pdlp/solver_settings.cu +++ b/cpp/src/pdlp/solver_settings.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include #include @@ -415,11 +416,11 @@ pdlp_solver_settings_t::get_pdlp_warm_start_data_view() const noexcept } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class pdlp_solver_settings_t; +template class CUOPT_EXPORT pdlp_solver_settings_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class pdlp_solver_settings_t; +template class CUOPT_EXPORT pdlp_solver_settings_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/pdlp/solver_solution.cu b/cpp/src/pdlp/solver_solution.cu index 0da8649dc4..08e5ee00a8 100644 --- a/cpp/src/pdlp/solver_solution.cu +++ b/cpp/src/pdlp/solver_solution.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include @@ -453,10 +454,10 @@ void optimization_problem_solution_t::write_to_sol_file( } #if MIP_INSTANTIATE_FLOAT || PDLP_INSTANTIATE_FLOAT -template class optimization_problem_solution_t; +template class CUOPT_EXPORT optimization_problem_solution_t; #endif #if MIP_INSTANTIATE_DOUBLE -template class optimization_problem_solution_t; +template class CUOPT_EXPORT optimization_problem_solution_t; #endif } // namespace cuopt::mathematical_optimization diff --git a/cpp/src/routing/assignment.cu b/cpp/src/routing/assignment.cu index 4636fa7359..be40bda183 100644 --- a/cpp/src/routing/assignment.cu +++ b/cpp/src/routing/assignment.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -272,8 +273,8 @@ void host_assignment_t::print() const noexcept } } -template class assignment_t; -template class host_assignment_t; +template class CUOPT_EXPORT assignment_t; +template class CUOPT_EXPORT host_assignment_t; } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/data_model_view.cu b/cpp/src/routing/data_model_view.cu index f5865cdad6..392c7a10fb 100644 --- a/cpp/src/routing/data_model_view.cu +++ b/cpp/src/routing/data_model_view.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -743,6 +744,6 @@ raft::handle_t const* data_model_view_t::get_handle_ptr() const noexce return handle_ptr_; } -template class data_model_view_t; +template class CUOPT_EXPORT data_model_view_t; } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/distance_engine/waypoint_matrix.cpp b/cpp/src/routing/distance_engine/waypoint_matrix.cpp index f31d1130d3..030c8790ea 100644 --- a/cpp/src/routing/distance_engine/waypoint_matrix.cpp +++ b/cpp/src/routing/distance_engine/waypoint_matrix.cpp @@ -1,11 +1,12 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ #include +#include #include #include @@ -408,7 +409,7 @@ void waypoint_matrix_t::compute_shortest_path_costs(f_t* d_custom_matr stream_view_.synchronize(); } -template class waypoint_matrix_t; +template class CUOPT_EXPORT waypoint_matrix_t; } // namespace distance_engine } // namespace cuopt diff --git a/cpp/src/routing/generator/generator.hpp b/cpp/src/routing/generator/generator.hpp index 07b7e8a2b5..75773ee4f6 100644 --- a/cpp/src/routing/generator/generator.hpp +++ b/cpp/src/routing/generator/generator.hpp @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -36,7 +37,7 @@ using vehicle_time_window_t = std::tuple, rmm::device_u * @tparam f_t Floating point type. Needs to be float (32bit) at the moment. */ template -class dataset_t { +class CUOPT_INTERNAL_EXPORT dataset_t { public: dataset_t(rmm::device_uvector& x_pos, rmm::device_uvector& y_pos, @@ -130,8 +131,8 @@ rmm::device_uvector generate_vehicle_types(raft::handle_t& handle, * @return dataset_t holding matrices, orders and vehicle info. */ template -dataset_t generate_dataset(raft::handle_t& handle, - dataset_params_t const& params); +CUOPT_INTERNAL_EXPORT dataset_t generate_dataset( + raft::handle_t& handle, dataset_params_t const& params); } // namespace generator } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/ges_solver.cu b/cpp/src/routing/ges_solver.cu index a660f84909..1ec267fb9a 100644 --- a/cpp/src/routing/ges_solver.cu +++ b/cpp/src/routing/ges_solver.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include "ges_solver.cuh" #include "routing_helpers.cuh" @@ -74,8 +75,8 @@ assignment_t ges_solver_t::compute_ges_solution( } } -template class ges_solver_t; -template class ges_solver_t; +template class CUOPT_INTERNAL_EXPORT ges_solver_t; +template class CUOPT_INTERNAL_EXPORT ges_solver_t; } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/local_search/local_search.cu b/cpp/src/routing/local_search/local_search.cu index a774e3f82f..127208021e 100644 --- a/cpp/src/routing/local_search/local_search.cu +++ b/cpp/src/routing/local_search/local_search.cu @@ -19,6 +19,7 @@ #include #include +#include #include namespace cuopt { @@ -383,8 +384,8 @@ void local_search_t::perturb_solution(solution_t; -template class local_search_t; +template class CUOPT_INTERNAL_EXPORT local_search_t; +template class CUOPT_INTERNAL_EXPORT local_search_t; } // namespace detail } // namespace routing diff --git a/cpp/src/routing/problem/problem.cu b/cpp/src/routing/problem/problem.cu index 4335b93734..030537480a 100644 --- a/cpp/src/routing/problem/problem.cu +++ b/cpp/src/routing/problem/problem.cu @@ -11,6 +11,7 @@ #include +#include #include namespace cuopt { namespace routing { @@ -772,7 +773,7 @@ bool problem_t::is_cvrp() const return is_cvrp_; } -template class problem_t; +template class CUOPT_INTERNAL_EXPORT problem_t; } // namespace detail } // namespace routing diff --git a/cpp/src/routing/solution/solution.cu b/cpp/src/routing/solution/solution.cu index edd3bef9a4..46140e72fa 100644 --- a/cpp/src/routing/solution/solution.cu +++ b/cpp/src/routing/solution/solution.cu @@ -6,6 +6,7 @@ /* clang-format on */ #include +#include #include #include "solution.cuh" #include "solution_kernels.cuh" @@ -746,8 +747,8 @@ std::vector solution_t::get_unserviced_nodes() const return unserviced_nodes; } -template class solution_t; -template class solution_t; +template class CUOPT_INTERNAL_EXPORT solution_t; +template class CUOPT_INTERNAL_EXPORT solution_t; } // namespace detail } // namespace routing diff --git a/cpp/src/routing/solve.cu b/cpp/src/routing/solve.cu index abac614633..a7caf88ad9 100644 --- a/cpp/src/routing/solve.cu +++ b/cpp/src/routing/solve.cu @@ -1,10 +1,11 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ +#include #include #include #include @@ -29,7 +30,7 @@ assignment_t solve(data_model_view_t const& data_model, } } -template assignment_t solve(data_model_view_t const& data_model, - solver_settings_t const& settings); +template CUOPT_EXPORT assignment_t solve(data_model_view_t const& data_model, + solver_settings_t const& settings); } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/solver.cu b/cpp/src/routing/solver.cu index b160a2d140..a887eae056 100644 --- a/cpp/src/routing/solver.cu +++ b/cpp/src/routing/solver.cu @@ -1,6 +1,6 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ @@ -13,6 +13,7 @@ #include "routing/utilities/env_utils.hpp" #include +#include #include #include #include @@ -90,7 +91,7 @@ assignment_t solver_t::run_ges_solver(i_t target_vehicles) return a; } -template class solver_t; +template class CUOPT_INTERNAL_EXPORT solver_t; } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/solver_settings.cu b/cpp/src/routing/solver_settings.cu index a9025cc08f..6267f39698 100644 --- a/cpp/src/routing/solver_settings.cu +++ b/cpp/src/routing/solver_settings.cu @@ -1,11 +1,12 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ #include +#include #include namespace cuopt { @@ -62,6 +63,6 @@ std::tuple solver_settings_t::get_dump_best_re return std::make_tuple(dump_interval_, dump_best_results_, best_result_file_name_); } -template class solver_settings_t; +template class CUOPT_EXPORT solver_settings_t; } // namespace routing } // namespace cuopt diff --git a/cpp/src/routing/utilities/cython.cu b/cpp/src/routing/utilities/cython.cu index cf9e8ab73b..5a0b9bf6b2 100644 --- a/cpp/src/routing/utilities/cython.cu +++ b/cpp/src/routing/utilities/cython.cu @@ -5,6 +5,7 @@ */ /* clang-format on */ +#include #include #include #include @@ -187,7 +188,7 @@ std::unique_ptr call_generate_dataset( return std::make_unique(std::move(gen_ret)); } -template void populate_dataset_params( +template CUOPT_EXPORT void populate_dataset_params( routing::generator::dataset_params_t& params, int n_locations, bool asymmetric, diff --git a/cpp/src/utilities/logger.hpp b/cpp/src/utilities/logger.hpp index f3a5bf6f2f..d328da9454 100644 --- a/cpp/src/utilities/logger.hpp +++ b/cpp/src/utilities/logger.hpp @@ -7,6 +7,8 @@ #pragma once +#include + #include #include @@ -20,7 +22,7 @@ #include #include -namespace cuopt { +namespace CUOPT_EXPORT cuopt { /** * @brief Get the default logger. @@ -71,7 +73,7 @@ inline bool log_every_n_should_emit(std::atomic& counter) } // namespace detail -} // namespace cuopt +} // namespace CUOPT_EXPORT cuopt // Rate-limited logging built on the generated CUOPT_LOG_ macros. `level` is one of // TRACE/DEBUG/INFO/WARN/ERROR/CRITICAL; `n` must be a positive compile-time constant. Each diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 19bb27d593..19182d3c65 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -22,9 +22,10 @@ if(BUILD_TESTS) target_link_libraries(cuopttestutils PUBLIC - cuopt GTest::gmock GTest::gtest + PRIVATE + cuopt ) if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(cuopttestutils PRIVATE -Wl,--enable-new-dtags) @@ -39,7 +40,7 @@ set(CUOPT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # # LABELS sets CTest labels for selective local test execution via `ctest -L