Skip to content

Commit 89b58cd

Browse files
committed
delete unnecessary data transfer
1 parent 18b75f9 commit 89b58cd

File tree

3 files changed

+34
-87
lines changed

3 files changed

+34
-87
lines changed

check/TestPdlp.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ void pdlpRestart(const std::string& model) {
265265

266266
TEST_CASE("pdlp-restart", "[pdlp]") {
267267
pdlpRestart("adlittle");
268-
// pdlpRestart("shell");
269-
// pdlpRestart("25fv47");
268+
// pdlpRestart("shell");
269+
// pdlpRestart("25fv47");
270270
}
271271

272272
TEST_CASE("pdlp-restart-lp", "[pdlp]") {
@@ -342,11 +342,10 @@ TEST_CASE("pdlp-restart-add-row", "[pdlp]") {
342342
}
343343

344344
TEST_CASE("hi-pdlp", "[pdlp]") {
345-
std::string model =
346-
"afiro"; //"adlittle";//"afiro";// shell// stair
347-
////25fv47 //fit2p //avgas //neso-2245 //neso-2005
345+
std::string model = "neso-2005"; //"adlittle";//"afiro";// shell// stair
346+
////25fv47 //fit2p //avgas //neso-2245 //neso-2005
348347
std::string model_file =
349-
// std::string(HIGHS_DIR) + "/srv/" + model + ".mps.gz";
348+
//std::string(HIGHS_DIR) + "/srv/" + model + ".mps.gz";
350349
"/srv/mps_da/" + model + ".mps.gz";
351350
Highs h;
352351
// h.setOptionValue("output_flag", dev_run);
@@ -356,21 +355,22 @@ TEST_CASE("hi-pdlp", "[pdlp]") {
356355
h.setOptionValue("presolve", "off");
357356

358357
HighsInt pdlp_features_off = 0
359-
//+kPdlpScalingOff
360-
//+kPdlpRestartOff
361-
+ kPdlpAdaptiveStepSizeOff;
358+
//+kPdlpScalingOff
359+
//+kPdlpRestartOff
360+
//+kPdlpAdaptiveStepSizeOff
361+
;
362362
h.setOptionValue("pdlp_features_off", pdlp_features_off);
363363

364364
HighsInt pdlp_scaling = // 0;
365365
kPdlpScalingRuiz
366-
//+ kPdlpScalingL2
366+
//+ kPdlpScalingL2cm
367367
+ kPdlpScalingPC;
368368
h.setOptionValue("pdlp_scaling_mode", pdlp_scaling);
369-
h.setOptionValue("pdlp_step_size_strategy", 0);
369+
h.setOptionValue("pdlp_step_size_strategy", 1);
370370
h.setOptionValue("pdlp_restart_strategy", 2);
371-
h.setOptionValue("pdlp_iteration_limit", 20);
372-
// h.setOptionValue("pdlp_time_limit", 60);
373-
// h.setOptionValue("log_dev_level", kHighsLogDevLevelVerbose);
371+
h.setOptionValue("pdlp_iteration_limit", 8000);
372+
//h.setOptionValue("pdlp_time_limit", 60);
373+
// h.setOptionValue("log_dev_level", kHighsLogDevLevelVerbose);
374374
auto start_hipdlp = std::chrono::high_resolution_clock::now();
375375
HighsStatus run_status = h.run();
376376
auto end_hipdlp = std::chrono::high_resolution_clock::now();

highs/pdlp/cupdlp/cupdlp_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" {
4141
#define CUPDLP_DUMP_LINESEARCH_STATS (1)
4242
#define CUPDLP_INEXACT_EPS (1e-4)
4343

44-
#define PDLP_DEBUG_LOG (0)
44+
#define PDLP_DEBUG_LOG (1)
4545

4646
typedef struct CUPDLP_CUDA_DENSE_VEC CUPDLPvec;
4747
typedef struct CUPDLP_DENSE_MATRIX CUPDLPdense;

highs/pdlp/hipdlp/pdhg.cc

Lines changed: 19 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
582582
restart_scheme_.getBeta(), stepsize_.primal_step,
583583
stepsize_.dual_step);
584584
#endif
585-
586585
// Check time limit
587586
if (solver_timer.read() > params_.time_limit) {
588587
logger_.info("Time limit reached.");
@@ -596,17 +595,6 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
596595
bool_checking = (bool_checking || iter % PDHG_CHECK_INTERVAL == 0);
597596
if (bool_checking) {
598597
#ifdef CUPDLP_GPU
599-
// **VERIFICATION**: Before checking, copy GPU state to host
600-
/*
601-
CUDA_CHECK(cudaMemcpy(x_current_.data(), d_x_current_, a_num_cols_ *
602-
sizeof(double), cudaMemcpyDeviceToHost));
603-
CUDA_CHECK(cudaMemcpy(y_current_.data(), d_y_current_, a_num_rows_ *
604-
sizeof(double), cudaMemcpyDeviceToHost));
605-
CUDA_CHECK(cudaMemcpy(Ax_cache_.data(), d_ax_current_, a_num_rows_ *
606-
sizeof(double), cudaMemcpyDeviceToHost));
607-
CUDA_CHECK(cudaMemcpy(ATy_cache_.data(), d_aty_current_, a_num_cols_
608-
* sizeof(double), cudaMemcpyDeviceToHost));
609-
*/
610598
computeAverageIterateGpu();
611599
#else
612600
#if PDLP_PROFILE
@@ -636,9 +624,9 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
636624
params_.tolerance, average_results, "[A-GPU]");
637625
#else
638626
// === CPU Convergence Check ===//
639-
#if PDLP_PROFILE
640-
hipdlpTimerStart(kHipdlpClockConvergenceCheck);
641-
#endif
627+
#if PDLP_PROFILE
628+
hipdlpTimerStart(kHipdlpClockConvergenceCheck);
629+
#endif
642630
// Compute residuals for current iterate
643631
bool current_converged = checkConvergence(
644632
iter, x_current_, y_current_, Ax_cache_, ATy_cache_,
@@ -648,10 +636,11 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
648636
bool average_converged = checkConvergence(
649637
iter, x_avg_, y_avg_, Ax_avg, ATy_avg, params_.tolerance,
650638
average_results, "[A]", dSlackPosAvg_, dSlackNegAvg_);
651-
#if PDLP_PROFILE
652-
hipdlpTimerStop(kHipdlpClockConvergenceCheck);
653-
#endif
639+
#if PDLP_PROFILE
640+
hipdlpTimerStop(kHipdlpClockConvergenceCheck);
641+
#endif
654642
#endif
643+
655644
#if PDLP_DEBUG_LOG
656645
debugPdlpIterHeaderLog(debug_pdlp_log_file_);
657646
#endif
@@ -799,38 +788,21 @@ void PDLPSolver::solve(std::vector<double>& x, std::vector<double>& y) {
799788
linalgGpuAx(d_x_next_, d_ax_next_);
800789
launchKernelUpdateY(stepsize_.dual_step);
801790
linalgGpuATy(d_y_next_, d_aty_next_);
802-
803-
std::vector<double> x_next_gpu(a_num_cols_);
804-
std::vector<double> y_next_gpu(a_num_rows_);
805-
std::vector<double> ax_next_gpu(a_num_rows_);
806-
std::vector<double> aty_next_gpu(a_num_cols_);
807-
CUDA_CHECK(cudaMemcpy(x_next_gpu.data(), d_x_next_,
808-
a_num_cols_ * sizeof(double),
809-
cudaMemcpyDeviceToHost));
810-
CUDA_CHECK(cudaMemcpy(y_next_gpu.data(), d_y_next_,
811-
a_num_rows_ * sizeof(double),
812-
cudaMemcpyDeviceToHost));
813-
CUDA_CHECK(cudaMemcpy(ax_next_gpu.data(), d_ax_next_,
814-
a_num_rows_ * sizeof(double),
815-
cudaMemcpyDeviceToHost));
816-
CUDA_CHECK(cudaMemcpy(aty_next_gpu.data(), d_aty_next_,
817-
a_num_cols_ * sizeof(double),
818-
cudaMemcpyDeviceToHost));
819791
#else
820-
#if PDLP_PROFILE
821-
hipdlpTimerStart(kHipdlpClockMatrixMultiply);
822-
#endif
792+
#if PDLP_PROFILE
793+
hipdlpTimerStart(kHipdlpClockMatrixMultiply);
794+
#endif
823795
linalg::Ax(lp, x_current_, Ax_cache_);
824-
#if PDLP_PROFILE
825-
hipdlpTimerStop(kHipdlpClockMatrixMultiply);
826-
#endif
827-
#if PDLP_PROFILE
828-
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
829-
#endif
796+
#if PDLP_PROFILE
797+
hipdlpTimerStop(kHipdlpClockMatrixMultiply);
798+
#endif
799+
#if PDLP_PROFILE
800+
hipdlpTimerStart(kHipdlpClockMatrixTransposeMultiply);
801+
#endif
830802
linalg::ATy(lp, y_current_, ATy_cache_);
831-
#if PDLP_PROFILE
832-
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
833-
#endif
803+
#if PDLP_PROFILE
804+
hipdlpTimerStop(kHipdlpClockMatrixTransposeMultiply);
805+
#endif
834806
#endif
835807
restart_scheme_.SetLastRestartIter(iter);
836808
}
@@ -1753,31 +1725,6 @@ void PDLPSolver::updateIteratesFixed() {
17531725
std::cerr << "Error2: d_x_next_ is null!" << std::endl;
17541726
return;
17551727
}
1756-
1757-
std::vector<double> x_next_gpu(a_num_cols_);
1758-
std::vector<double> y_next_gpu(a_num_rows_);
1759-
std::vector<double> ax_next_gpu(a_num_rows_);
1760-
std::vector<double> aty_next_gpu(a_num_cols_);
1761-
CUDA_CHECK(cudaMemcpy(x_next_gpu.data(), d_x_next_,
1762-
a_num_cols_ * sizeof(double), cudaMemcpyDeviceToHost));
1763-
CUDA_CHECK(cudaMemcpy(y_next_gpu.data(), d_y_next_,
1764-
a_num_rows_ * sizeof(double), cudaMemcpyDeviceToHost));
1765-
CUDA_CHECK(cudaMemcpy(ax_next_gpu.data(), d_ax_next_,
1766-
a_num_rows_ * sizeof(double), cudaMemcpyDeviceToHost));
1767-
CUDA_CHECK(cudaMemcpy(aty_next_gpu.data(), d_aty_next_,
1768-
a_num_cols_ * sizeof(double), cudaMemcpyDeviceToHost));
1769-
1770-
#if PDLP_DEBUG_LOG
1771-
bool x_match = vecDiff(x_next_gpu, x_next_, 1e-10, "UpdateIteratesFixed x");
1772-
bool y_match = vecDiff(y_next_gpu, y_next_, 1e-10, "UpdateIteratesFixed y");
1773-
bool ax_match =
1774-
vecDiff(ax_next_gpu, Ax_next_, 1e-10, "UpdateIteratesFixed Ax");
1775-
bool aty_match =
1776-
vecDiff(aty_next_gpu, ATy_next_, 1e-10, "UpdateIteratesFixed ATy");
1777-
#endif
1778-
1779-
#else
1780-
17811728
#endif
17821729
}
17831730

0 commit comments

Comments
 (0)