Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/linear_programming/utils/get_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/dual_simplex/barrier.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3575,6 +3575,9 @@ lp_status_t barrier_solver_t<i_t, f_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;
}
}

Expand Down
4 changes: 4 additions & 0 deletions cpp/src/dual_simplex/cusparse_view.cu
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ cusparse_view_t<i_t, f_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()); }
Expand Down
11 changes: 4 additions & 7 deletions cpp/src/linear_programming/solve.cu
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ optimization_problem_solution_t<i_t, f_t> run_barrier(
{
// Convert data structures to dual simplex format and back
dual_simplex::user_problem_t<i_t, f_t> dual_simplex_problem =
cuopt_problem_to_simplex_problem<i_t, f_t>(problem);
cuopt_problem_to_simplex_problem<i_t, f_t>(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),
Expand Down Expand Up @@ -515,7 +515,7 @@ optimization_problem_solution_t<i_t, f_t> run_dual_simplex(
{
// Convert data structures to dual simplex format and back
dual_simplex::user_problem_t<i_t, f_t> dual_simplex_problem =
cuopt_problem_to_simplex_problem<i_t, f_t>(problem);
cuopt_problem_to_simplex_problem<i_t, f_t>(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),
Expand Down Expand Up @@ -671,16 +671,13 @@ optimization_problem_solution_t<i_t, f_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<i_t, f_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<i_t, f_t> dual_simplex_problem =
cuopt_problem_to_simplex_problem<i_t, f_t>(d_barrier_problem);
cuopt_problem_to_simplex_problem<i_t, f_t>(&barrier_handle, problem);
// Create a thread for dual simplex
std::unique_ptr<
std::tuple<dual_simplex::lp_solution_t<i_t, f_t>, dual_simplex::lp_status_t, f_t, f_t, f_t>>
Expand Down
22 changes: 12 additions & 10 deletions cpp/src/linear_programming/translate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ namespace cuopt::linear_programming {

template <typename i_t, typename f_t>
static dual_simplex::user_problem_t<i_t, f_t> cuopt_problem_to_simplex_problem(
detail::problem_t<i_t, f_t>& model)
raft::handle_t const* handle_ptr, detail::problem_t<i_t, f_t>& model)
{
dual_simplex::user_problem_t<i_t, f_t> user_problem(model.handle_ptr);
dual_simplex::user_problem_t<i_t, f_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<i_t, f_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);

Expand All @@ -51,8 +51,10 @@ static dual_simplex::user_problem_t<i_t, f_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
Expand All @@ -79,7 +81,7 @@ static dual_simplex::user_problem_t<i_t, f_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<f_t>(model.variable_bounds, model.handle_ptr);
extract_host_bounds<f_t>(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);
Expand All @@ -97,7 +99,7 @@ static dual_simplex::user_problem_t<i_t, f_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
Expand Down
Loading