Skip to content

Commit 5eab332

Browse files
mlubinclaude
andcommitted
refactor: remove using-namespace directives from headers
Header-scope 'using namespace' leaks into every including TU. Replace with explicit qualification in the affected barrier/branch_and_bound/cuts headers (and grpc_server_types.hpp). TU-local directives in .cpp/.cu are left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Miles Lubin <mlubin@nvidia.com>
1 parent 59336da commit 5eab332

22 files changed

Lines changed: 346 additions & 379 deletions

cpp/src/barrier/barrier.hpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,25 @@
1818
#include <rmm/device_uvector.hpp>
1919
namespace cuopt::math_optimization::barrier {
2020

21-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
22-
// etc.)
23-
24-
/** Validates SOC layout on an lp_problem_t before barrier presolve/solve. */
21+
/** Validates SOC layout on an simplex::lp_problem_t before barrier presolve/solve. */
2522
template <typename i_t, typename f_t>
26-
bool validate_barrier_cone_layout(const lp_problem_t<i_t, f_t>& problem,
27-
const simplex_solver_settings_t<i_t, f_t>& settings);
23+
bool validate_barrier_cone_layout(const simplex::lp_problem_t<i_t, f_t>& problem,
24+
const simplex::simplex_solver_settings_t<i_t, f_t>& settings);
2825

2926
template <typename i_t, typename f_t>
3027
class iteration_data_t; // Forward declare
3128

3229
template <typename i_t, typename f_t>
3330
class barrier_solver_t {
3431
public:
35-
barrier_solver_t(const lp_problem_t<i_t, f_t>& lp,
36-
const presolve_info_t<i_t, f_t>& presolve,
37-
const simplex_solver_settings_t<i_t, f_t>& settings);
38-
lp_status_t solve(f_t start_time, lp_solution_t<i_t, f_t>& solution);
32+
barrier_solver_t(const simplex::lp_problem_t<i_t, f_t>& lp,
33+
const simplex::presolve_info_t<i_t, f_t>& presolve,
34+
const simplex::simplex_solver_settings_t<i_t, f_t>& settings);
35+
simplex::lp_status_t solve(f_t start_time, simplex::lp_solution_t<i_t, f_t>& solution);
3936

4037
private:
4138
void my_pop_range(bool debug) const;
42-
void create_Q(const lp_problem_t<i_t, f_t>& lp, csc_matrix_t<i_t, f_t>& Q);
39+
void create_Q(const simplex::lp_problem_t<i_t, f_t>& lp, simplex::csc_matrix_t<i_t, f_t>& Q);
4340
int initial_point(iteration_data_t<i_t, f_t>& data);
4441
void compute_residual_norms(const dense_vector_t<i_t, f_t>& w,
4542
const dense_vector_t<i_t, f_t>& x,
@@ -101,21 +98,21 @@ class barrier_solver_t {
10198
f_t& max_residual);
10299

103100
private:
104-
lp_status_t check_for_suboptimal_solution(iteration_data_t<i_t, f_t>& data,
105-
f_t start_time,
106-
i_t iter,
107-
f_t& primal_objective,
108-
f_t& primal_residual_norm,
109-
f_t& dual_residual_norm,
110-
f_t& complementarity_residual_norm,
111-
f_t& relative_primal_residual,
112-
f_t& relative_dual_residual,
113-
f_t& relative_complementarity_residual,
114-
lp_solution_t<i_t, f_t>& solution);
101+
simplex::lp_status_t check_for_suboptimal_solution(iteration_data_t<i_t, f_t>& data,
102+
f_t start_time,
103+
i_t iter,
104+
f_t& primal_objective,
105+
f_t& primal_residual_norm,
106+
f_t& dual_residual_norm,
107+
f_t& complementarity_residual_norm,
108+
f_t& relative_primal_residual,
109+
f_t& relative_dual_residual,
110+
f_t& relative_complementarity_residual,
111+
simplex::lp_solution_t<i_t, f_t>& solution);
115112

116-
const lp_problem_t<i_t, f_t>& lp;
117-
const simplex_solver_settings_t<i_t, f_t>& settings;
118-
const presolve_info_t<i_t, f_t>& presolve_info;
113+
const simplex::lp_problem_t<i_t, f_t>& lp;
114+
const simplex::simplex_solver_settings_t<i_t, f_t>& settings;
115+
const simplex::presolve_info_t<i_t, f_t>& presolve_info;
119116
rmm::cuda_stream_view stream_view_;
120117
};
121118

cpp/src/barrier/conjugate_gradient.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818

1919
namespace cuopt::math_optimization::barrier {
2020

21-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
22-
// etc.)
23-
2421
template <typename i_t, typename f_t, typename T>
2522
i_t preconditioned_conjugate_gradient(const T& op,
26-
const simplex_solver_settings_t<i_t, f_t>& settings,
23+
const simplex::simplex_solver_settings_t<i_t, f_t>& settings,
2724
const dense_vector_t<i_t, f_t>& b,
2825
f_t tolerance,
2926
dense_vector_t<i_t, f_t>& xinout)

cpp/src/barrier/cusparse_view.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323
// This allows handling many different X Y vector along with one common matrix
2424
namespace cuopt::math_optimization::barrier {
2525

26-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
27-
// etc.)
2826
template <typename i_t, typename f_t>
2927
class cusparse_view_t {
3028
public:
3129
// TMP matrix data should already be on the GPU and in CSR not CSC
32-
cusparse_view_t(raft::handle_t const* handle_ptr, const csc_matrix_t<i_t, f_t>& A);
30+
cusparse_view_t(raft::handle_t const* handle_ptr, const simplex::csc_matrix_t<i_t, f_t>& A);
3331
~cusparse_view_t();
3432

3533
pdlp::cusparse_dn_vec_descr_wrapper_t<f_t> create_vector(rmm::device_uvector<f_t> const& vec);

cpp/src/barrier/dense_matrix.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
namespace cuopt::math_optimization::barrier {
1616

17-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
18-
// etc.)
19-
2017
template <typename i_t, typename f_t>
2118
class dense_matrix_t {
2219
public:
@@ -35,7 +32,7 @@ class dense_matrix_t {
3532

3633
f_t operator()(i_t row, i_t col) const { return values[col * m + row]; }
3734

38-
void from_sparse(const csc_matrix_t<i_t, f_t>& A, i_t sparse_column, i_t dense_column)
35+
void from_sparse(const simplex::csc_matrix_t<i_t, f_t>& A, i_t sparse_column, i_t dense_column)
3936
{
4037
for (i_t i = 0; i < m; i++) {
4138
this->operator()(i, dense_column) = 0.0;

cpp/src/barrier/dense_vector.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
namespace cuopt::math_optimization::barrier {
1616

17-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
18-
// etc.)
19-
2017
template <typename i_t, typename f_t, typename Allocator = std::allocator<f_t>>
2118
class dense_vector_t : public std::vector<f_t, Allocator> {
2219
public:
@@ -59,7 +56,7 @@ class dense_vector_t : public std::vector<f_t, Allocator> {
5956
f_t minimum() const
6057
{
6158
const i_t n = this->size();
62-
f_t min_x = inf;
59+
f_t min_x = simplex::inf;
6360
for (i_t i = 0; i < n; i++) {
6461
min_x = std::min(min_x, (*this)[i]);
6562
}
@@ -69,7 +66,7 @@ class dense_vector_t : public std::vector<f_t, Allocator> {
6966
f_t maximum() const
7067
{
7168
const i_t n = this->size();
72-
f_t max_x = -inf;
69+
f_t max_x = -simplex::inf;
7370
for (i_t i = 0; i < n; i++) {
7471
max_x = std::max(max_x, (*this)[i]);
7572
}
@@ -189,7 +186,7 @@ class dense_vector_t : public std::vector<f_t, Allocator> {
189186

190187
void ensure_positive(f_t epsilon_adjust, const std::vector<i_t>& mask)
191188
{
192-
f_t min_x = inf;
189+
f_t min_x = simplex::inf;
193190
const i_t n = this->size();
194191
for (i_t i = 0; i < n; i++) {
195192
if (mask[i]) { min_x = std::min(min_x, (*this)[i]); }

cpp/src/barrier/device_sparse_matrix.cuh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
namespace cuopt::math_optimization::barrier {
2727

28-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
29-
// etc.)
30-
3128
template <typename IndexType, typename ValueType>
3229
class device_csr_matrix_t;
3330

@@ -128,7 +125,7 @@ class device_csc_matrix_t {
128125
{
129126
}
130127

131-
device_csc_matrix_t(const csc_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
128+
device_csc_matrix_t(const simplex::csc_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
132129
: m(A.m),
133130
n(A.n),
134131
nz_max(A.col_start[A.n]),
@@ -149,16 +146,16 @@ class device_csc_matrix_t {
149146
nz_max = nnz;
150147
}
151148

152-
csc_matrix_t<i_t, f_t> to_host(rmm::cuda_stream_view stream)
149+
simplex::csc_matrix_t<i_t, f_t> to_host(rmm::cuda_stream_view stream)
153150
{
154-
csc_matrix_t<i_t, f_t> A(m, n, nz_max);
151+
simplex::csc_matrix_t<i_t, f_t> A(m, n, nz_max);
155152
A.col_start = cuopt::host_copy(col_start, stream);
156153
A.i = cuopt::host_copy(i, stream);
157154
A.x = cuopt::host_copy(x, stream);
158155
return A;
159156
}
160157

161-
void copy(csc_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
158+
void copy(simplex::csc_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
162159
{
163160
m = A.m;
164161
n = A.n;
@@ -171,7 +168,7 @@ class device_csc_matrix_t {
171168
raft::copy(x.data(), A.x.data(), A.x.size(), stream);
172169
}
173170

174-
/** Same semantics as csc_matrix_t::to_compressed_row, entirely on device. */
171+
/** Same semantics as simplex::csc_matrix_t::to_compressed_row, entirely on device. */
175172
void to_compressed_row(device_csr_matrix_t<i_t, f_t>& Arow, rmm::cuda_stream_view stream) const;
176173

177174
void form_col_index(rmm::cuda_stream_view stream)
@@ -255,7 +252,7 @@ class device_csr_matrix_t {
255252
{
256253
}
257254

258-
device_csr_matrix_t(const csr_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
255+
device_csr_matrix_t(const simplex::csr_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
259256
: m(A.m),
260257
n(A.n),
261258
nz_max(A.row_start[A.m]),
@@ -276,16 +273,16 @@ class device_csr_matrix_t {
276273
nz_max = nnz;
277274
}
278275

279-
csr_matrix_t<i_t, f_t> to_host(rmm::cuda_stream_view stream)
276+
simplex::csr_matrix_t<i_t, f_t> to_host(rmm::cuda_stream_view stream)
280277
{
281-
csr_matrix_t<i_t, f_t> A(m, n, nz_max);
278+
simplex::csr_matrix_t<i_t, f_t> A(m, n, nz_max);
282279
A.row_start = cuopt::host_copy(row_start, stream);
283280
A.j = cuopt::host_copy(j, stream);
284281
A.x = cuopt::host_copy(x, stream);
285282
return A;
286283
}
287284

288-
void copy(csr_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
285+
void copy(simplex::csr_matrix_t<i_t, f_t>& A, rmm::cuda_stream_view stream)
289286
{
290287
m = A.m;
291288
n = A.n;

cpp/src/barrier/iterative_refinement.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030

3131
namespace cuopt::math_optimization::barrier {
3232

33-
using namespace cuopt::math_optimization::simplex; // shared simplex types (lp_problem_t, inf,
34-
// etc.)
35-
3633
// Functors for device operations (defined at namespace scope to avoid CUDA lambda restrictions)
3734
template <typename T>
3835
struct scale_op {

0 commit comments

Comments
 (0)