diff --git a/benchmarks/linear_programming/utils/get_datasets.py b/benchmarks/linear_programming/utils/get_datasets.py index 01ed86dc9..39e79ff32 100644 --- a/benchmarks/linear_programming/utils/get_datasets.py +++ b/benchmarks/linear_programming/utils/get_datasets.py @@ -693,7 +693,7 @@ def extract(file, dir, type): raise Exception(f"Unknown file extension found for extraction {file}") # download emps and compile # Disable emps for now - if type == "netlib": + if type == "netlib" and False: url = MittelmannInstances["emps"] file = os.path.join(dir, "emps.c") download(url, file) diff --git a/cpp/src/dual_simplex/barrier.cu b/cpp/src/dual_simplex/barrier.cu index 47f1218f3..40daf1696 100644 --- a/cpp/src/dual_simplex/barrier.cu +++ b/cpp/src/dual_simplex/barrier.cu @@ -3575,6 +3575,9 @@ lp_status_t barrier_solver_t::solve(f_t start_time, } catch (const raft::cuda_error& e) { settings.log.debug("Error in barrier_solver_t: %s\n", e.what()); return lp_status_t::NUMERICAL_ISSUES; + } catch (const rmm::out_of_memory& e) { + settings.log.debug("Out of memory in barrier_solver_t: %s\n", e.what()); + return lp_status_t::NUMERICAL_ISSUES; } } diff --git a/cpp/src/dual_simplex/cusparse_view.cu b/cpp/src/dual_simplex/cusparse_view.cu index 8d2260473..0ae9ea9bc 100644 --- a/cpp/src/dual_simplex/cusparse_view.cu +++ b/cpp/src/dual_simplex/cusparse_view.cu @@ -138,6 +138,10 @@ cusparse_view_t::cusparse_view_t(raft::handle_t const* handle_ptr, d_minus_one_(f_t(-1), handle_ptr->get_stream()), d_zero_(f_t(0), handle_ptr->get_stream()) { + RAFT_CUBLAS_TRY(raft::linalg::detail::cublassetpointermode( + handle_ptr->get_cublas_handle(), CUBLAS_POINTER_MODE_DEVICE, handle_ptr->get_stream())); + RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsesetpointermode( + handle_ptr->get_cusparse_handle(), CUSPARSE_POINTER_MODE_DEVICE, handle_ptr->get_stream())); // TMP matrix data should already be on the GPU constexpr bool debug = false; if (debug) { printf("A hash: %zu\n", A.hash()); } diff --git a/cpp/src/linear_programming/solve.cu b/cpp/src/linear_programming/solve.cu index f8f88f8f8..5f310bd73 100644 --- a/cpp/src/linear_programming/solve.cu +++ b/cpp/src/linear_programming/solve.cu @@ -444,7 +444,7 @@ optimization_problem_solution_t run_barrier( { // Convert data structures to dual simplex format and back dual_simplex::user_problem_t dual_simplex_problem = - cuopt_problem_to_simplex_problem(problem); + cuopt_problem_to_simplex_problem(problem.handle_ptr, problem); auto sol_dual_simplex = run_barrier(dual_simplex_problem, settings, timer); return convert_dual_simplex_sol(problem, std::get<0>(sol_dual_simplex), @@ -515,7 +515,7 @@ optimization_problem_solution_t run_dual_simplex( { // Convert data structures to dual simplex format and back dual_simplex::user_problem_t dual_simplex_problem = - cuopt_problem_to_simplex_problem(problem); + cuopt_problem_to_simplex_problem(problem.handle_ptr, problem); auto sol_dual_simplex = run_dual_simplex(dual_simplex_problem, settings, timer); return convert_dual_simplex_sol(problem, std::get<0>(sol_dual_simplex), @@ -671,16 +671,13 @@ optimization_problem_solution_t run_concurrent( // Initialize the dual simplex structures before we run PDLP. // Otherwise, CUDA API calls to the problem stream may occur in both threads and throw graph // capture off - auto barrier_handle = raft::handle_t(*op_problem.get_handle_ptr()); - detail::problem_t d_barrier_problem(problem); rmm::cuda_stream_view barrier_stream = rmm::cuda_stream_per_thread; - d_barrier_problem.handle_ptr = &barrier_handle; - raft::resource::set_cuda_stream(barrier_handle, barrier_stream); + auto barrier_handle = raft::handle_t(barrier_stream); // Make sure allocations are done on the original stream problem.handle_ptr->sync_stream(); dual_simplex::user_problem_t dual_simplex_problem = - cuopt_problem_to_simplex_problem(d_barrier_problem); + cuopt_problem_to_simplex_problem(&barrier_handle, problem); // Create a thread for dual simplex std::unique_ptr< std::tuple, dual_simplex::lp_status_t, f_t, f_t, f_t>> diff --git a/cpp/src/linear_programming/translate.hpp b/cpp/src/linear_programming/translate.hpp index 227a4375c..556b6d424 100644 --- a/cpp/src/linear_programming/translate.hpp +++ b/cpp/src/linear_programming/translate.hpp @@ -28,21 +28,21 @@ namespace cuopt::linear_programming { template static dual_simplex::user_problem_t cuopt_problem_to_simplex_problem( - detail::problem_t& model) + raft::handle_t const* handle_ptr, detail::problem_t& model) { - dual_simplex::user_problem_t user_problem(model.handle_ptr); + dual_simplex::user_problem_t user_problem(handle_ptr); int m = model.n_constraints; int n = model.n_variables; int nz = model.nnz; user_problem.num_rows = m; user_problem.num_cols = n; - user_problem.objective = cuopt::host_copy(model.objective_coefficients); + user_problem.objective = cuopt::host_copy(model.objective_coefficients, handle_ptr->get_stream()); dual_simplex::csr_matrix_t csr_A(m, n, nz); - csr_A.x = cuopt::host_copy(model.coefficients); - csr_A.j = cuopt::host_copy(model.variables); - csr_A.row_start = cuopt::host_copy(model.offsets); + csr_A.x = cuopt::host_copy(model.coefficients, handle_ptr->get_stream()); + csr_A.j = cuopt::host_copy(model.variables, handle_ptr->get_stream()); + csr_A.row_start = cuopt::host_copy(model.offsets, handle_ptr->get_stream()); csr_A.to_compressed_col(user_problem.A); @@ -51,8 +51,10 @@ static dual_simplex::user_problem_t cuopt_problem_to_simplex_problem( user_problem.range_rows.clear(); user_problem.range_value.clear(); - auto model_constraint_lower_bounds = cuopt::host_copy(model.constraint_lower_bounds); - auto model_constraint_upper_bounds = cuopt::host_copy(model.constraint_upper_bounds); + auto model_constraint_lower_bounds = + cuopt::host_copy(model.constraint_lower_bounds, handle_ptr->get_stream()); + auto model_constraint_upper_bounds = + cuopt::host_copy(model.constraint_upper_bounds, handle_ptr->get_stream()); // All constraints have lower and upper bounds // lr <= a_i^T x <= ur @@ -79,7 +81,7 @@ static dual_simplex::user_problem_t cuopt_problem_to_simplex_problem( } user_problem.num_range_rows = user_problem.range_rows.size(); std::tie(user_problem.lower, user_problem.upper) = - extract_host_bounds(model.variable_bounds, model.handle_ptr); + extract_host_bounds(model.variable_bounds, handle_ptr); user_problem.problem_name = model.original_problem_ptr->get_problem_name(); if (model.row_names.size() > 0) { user_problem.row_names.resize(m); @@ -97,7 +99,7 @@ static dual_simplex::user_problem_t cuopt_problem_to_simplex_problem( user_problem.obj_scale = model.presolve_data.objective_scaling_factor; user_problem.var_types.resize(n); - auto model_variable_types = cuopt::host_copy(model.variable_types); + auto model_variable_types = cuopt::host_copy(model.variable_types, handle_ptr->get_stream()); for (int j = 0; j < n; ++j) { user_problem.var_types[j] = model_variable_types[j] == var_t::CONTINUOUS