@@ -492,7 +492,9 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
492492 }
493493
494494 // --- 0. Using PowerMethod to estimate the largest eigenvalue ---
495+ #ifdef CUPDLP_GPU
495496 setupGpu ();
497+ #endif
496498 initializeStepSizes ();
497499 PrimalDualParams working_params = params_;
498500 working_params.omega = std::sqrt (stepsize_.dual_step / stepsize_.primal_step );
@@ -521,7 +523,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
521523 CUDA_CHECK (cudaMemcpy (d_x_avg_, d_x_current_, a_num_cols_ * sizeof (double ), cudaMemcpyDeviceToDevice));
522524 linalgGpuAx (d_x_current_, d_ax_current_);
523525#endif
524-
526+ linalg::project_bounds (lp_, x_current_);
525527 linalg::project_bounds (lp_, x_sum_);
526528 linalg::project_bounds (lp_, x_avg_);
527529 linalg::Ax (lp, x_current_, Ax_cache_);
@@ -597,7 +599,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
597599 SolverResults current_results;
598600 SolverResults average_results;
599601
600-
602+ # ifdef CUPDLP_GPU
601603 // === GPU Convergence Check ===//
602604 bool current_converged_gpu = checkConvergenceGpu (
603605 iter, d_x_current_, d_y_current_,
@@ -634,7 +636,7 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
634636 results_ = average_results;
635637 return solveReturn (TerminationStatus::OPTIMAL);
636638 }
637-
639+ # endif
638640 // === CPU Convergence Check ===//
639641 hipdlpTimerStart (kHipdlpClockConvergenceCheck );
640642 // Compute residuals for current iterate
@@ -849,7 +851,9 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
849851}
850852
851853void PDLPSolver::solveReturn (const TerminationStatus term_code) {
854+ #ifdef CUPDLP_GPU
852855 cleanupGpu ();
856+ #endif
853857 results_.term_code = term_code;
854858 hipdlpTimerStop (kHipdlpClockSolve );
855859}
@@ -1810,7 +1814,7 @@ void PDLPSolver::closeDebugLog() {
18101814// =============================================================================
18111815// SECTION 5: GPU Part
18121816// =============================================================================
1813-
1817+ # ifdef CUPDLP_GPU
18141818void PDLPSolver::setupGpu (){
18151819 // 1. Initialize cuSPARSE
18161820 CUSPARSE_CHECK (cusparseCreate (&cusparse_handle_));
@@ -2179,4 +2183,5 @@ void PDLPSolver::computeAverageIterateGpu() {
21792183 // Recompute Ax_avg and ATy_avg on GPU
21802184 linalgGpuAx (d_x_avg_, d_ax_avg_);
21812185 linalgGpuATy (d_y_avg_, d_aty_avg_);
2182- }
2186+ }
2187+ #endif
0 commit comments