Skip to content

Commit 6bb4cc7

Browse files
authored
Add GPU implementation of preconditioner - v2 (#31)
* New feat: GPU precondition * New feat: synchronized A/At scaling * Todo: infeasible is stucked * New feat: preconditioner prints * Bug fixed: objective & bound rescale * feat: add logging for precondition time * Bug fixed: numerical issue * Clean code: clang-format and align naming style * Clean code: rename variables * Refactor: move finite-bound computation * Numerical issue: back to old version * Code refactor: CUB DeviceReduce for bound norm * Bug fixed: typo * Clean code: Limit CUB headers to device_reduce to reduce compile time * Clean code * Bug fixed: warm start solution * Bug fixed: illegal memory access in bound * Bug fixed: norm computation on scaled bound * Revert "Bug fixed: norm computation on scaled bound" This reverts commit d372a20. * Bug fixed: unused sv params * New feat: add verbose logging * New ver: 0.2.4
1 parent 55fa198 commit 6bb4cc7

10 files changed

Lines changed: 877 additions & 580 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ test/*
6363
/_b
6464
*.whl
6565
*.pyc
66+
67+
68+
*.txt
69+
*.sh

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(cupdlpx LANGUAGES C CXX CUDA)
88

99
set(CUPDLPX_VERSION_MAJOR 0)
1010
set(CUPDLPX_VERSION_MINOR 2)
11-
set(CUPDLPX_VERSION_PATCH 3)
11+
set(CUPDLPX_VERSION_PATCH 4)
1212

1313
set(CUPDLPX_VERSION "${CUPDLPX_VERSION_MAJOR}.${CUPDLPX_VERSION_MINOR}.${CUPDLPX_VERSION_PATCH}")
1414
add_compile_definitions(CUPDLPX_VERSION="${CUPDLPX_VERSION}")

internal/internal_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ typedef struct
2828
int num_nonzeros;
2929
int *row_ptr;
3030
int *col_ind;
31+
int *row_ind;
3132
double *val;
33+
int *transpose_map;
3234
} cu_sparse_matrix_csr_t;
3335

3436
typedef struct
@@ -46,6 +48,7 @@ typedef struct
4648
int num_blocks_primal;
4749
int num_blocks_dual;
4850
int num_blocks_primal_dual;
51+
int num_blocks_nnz;
4952
double objective_vector_norm;
5053
double constraint_bound_norm;
5154
double *constraint_lower_bound_finite_val;
@@ -129,7 +132,6 @@ typedef struct
129132

130133
typedef struct
131134
{
132-
lp_problem_t *scaled_problem;
133135
double *con_rescale;
134136
double *var_rescale;
135137
double con_bound_rescale;

internal/preconditioner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C"
2525

2626
rescale_info_t *rescale_problem(
2727
const pdhg_parameters_t *params,
28-
const lp_problem_t *original_problem);
28+
pdhg_solver_state_t *state);
2929

3030
#ifdef __cplusplus
3131
}

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "cupdlpx"
7-
version = "0.2.2"
7+
version = "0.2.4"
88
description = "Python bindings for cuPDLPx (GPU-accelerated first-order LP solver)"
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }
@@ -25,7 +25,7 @@ wheel.packages = ["python/cupdlpx"]
2525
sdist.include = ["tests/**", "pyproject.toml", "README.md", "LICENSE"]
2626

2727
[tool.scikit-build.cmake.define]
28-
CMAKE_CUDA_ARCHITECTURES = "60;61;70;75;80;86;89;90;90-virtual"
28+
CMAKE_CUDA_ARCHITECTURES = "all"
2929
CMAKE_CUDA_STANDARD = "17"
3030
CUPDLPX_BUILD_PYTHON = "ON"
3131
CUPDLPX_BUILD_STATIC_LIB = "ON"

src/cli.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,6 @@ void save_solver_summary(const cupdlpx_result_t *result, const char *output_dir,
102102
}
103103
fprintf(outfile, "Termination Reason: %s\n",
104104
termination_reason_to_string(result->termination_reason));
105-
fprintf(outfile, "Runtime (sec): %e\n", result->cumulative_time_sec);
106-
fprintf(outfile, "Iterations Count: %d\n", result->total_count);
107-
fprintf(outfile, "Primal Objective Value: %e\n",
108-
result->primal_objective_value);
109-
fprintf(outfile, "Dual Objective Value: %e\n", result->dual_objective_value);
110-
fprintf(outfile, "Relative Primal Residual: %e\n",
111-
result->relative_primal_residual);
112-
fprintf(outfile, "Relative Dual Residual: %e\n",
113-
result->relative_dual_residual);
114-
fprintf(outfile, "Absolute Objective Gap: %e\n", result->objective_gap);
115-
fprintf(outfile, "Relative Objective Gap: %e\n",
116-
result->relative_objective_gap);
117-
fprintf(outfile, "Rows: %d\n", result->num_constraints);
118-
fprintf(outfile, "Columns: %d\n", result->num_variables);
119-
fprintf(outfile, "Nonzeros: %d\n", result->num_nonzeros);
120105
if (result->presolve_time > 0.0)
121106
{
122107
fprintf(outfile, "Presolve Status: %s\n", get_presolve_status_str(result->presolve_status));
@@ -142,6 +127,22 @@ void save_solver_summary(const cupdlpx_result_t *result, const char *output_dir,
142127
// fprintf(outfile, "Postsolve Time (sec): %e\n", result->presolve_stats.time_postsolve);
143128
// }
144129
}
130+
fprintf(outfile, "Precondition time (sec): %e\n", result->rescaling_time_sec);
131+
fprintf(outfile, "Runtime (sec): %e\n", result->cumulative_time_sec);
132+
fprintf(outfile, "Iterations Count: %d\n", result->total_count);
133+
fprintf(outfile, "Primal Objective Value: %e\n",
134+
result->primal_objective_value);
135+
fprintf(outfile, "Dual Objective Value: %e\n", result->dual_objective_value);
136+
fprintf(outfile, "Relative Primal Residual: %e\n",
137+
result->relative_primal_residual);
138+
fprintf(outfile, "Relative Dual Residual: %e\n",
139+
result->relative_dual_residual);
140+
fprintf(outfile, "Absolute Objective Gap: %e\n", result->objective_gap);
141+
fprintf(outfile, "Relative Objective Gap: %e\n",
142+
result->relative_objective_gap);
143+
fprintf(outfile, "Rows: %d\n", result->num_constraints);
144+
fprintf(outfile, "Columns: %d\n", result->num_variables);
145+
fprintf(outfile, "Nonzeros: %d\n", result->num_nonzeros);
145146
if (result->feasibility_polishing_time > 0.0)
146147
{
147148
fprintf(outfile, "Feasibility Polishing Time (sec): %e\n", result->feasibility_polishing_time);

0 commit comments

Comments
 (0)