Skip to content

Commit

Permalink
Merge pull request #1773 from ERGO-Code/fix-1694
Browse files Browse the repository at this point in the history
Fix 1694
  • Loading branch information
jajhall committed May 23, 2024
2 parents ecef70a + f378107 commit 65fc061
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 27 deletions.
3 changes: 2 additions & 1 deletion check/TestMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ TEST_CASE("IP-with-fract-bounds-no-presolve", "[highs_test_mip_solver]") {
lp.col_cost_ = {1, -2, 3};
lp.col_lower_ = {2.5, 2.5, 2.5};
lp.col_upper_ = {6.5, 5.5, 7.5};
lp.integrality_ = {HighsVarType::kInteger, HighsVarType::kInteger, HighsVarType::kInteger};
lp.integrality_ = {HighsVarType::kInteger, HighsVarType::kInteger,
HighsVarType::kInteger};

// Solve
highs.passModel(lp);
Expand Down
16 changes: 13 additions & 3 deletions src/pdlp/CupdlpWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
void* presolvedmodel = NULL;
void* model2solve = NULL;

// WIP on zbook?
//
// HighsInt size_of_CUPDLPscaling = sizeof(CUPDLPscaling);
//
CUPDLPscaling* scaling = (CUPDLPscaling*)cupdlp_malloc(sizeof(CUPDLPscaling));

// WIP on zbook?
//
// printf("size_of_CUPDLPscaling = %d\n", size_of_CUPDLPscaling);
// scaling->ifRuizScaling = 1;
// printf("scaling->ifRuizScaling = %d\n", scaling->ifRuizScaling);

// claim solvers variables
// prepare pointers
CUPDLP_MATRIX_FORMAT src_matrix_format = CSC;
Expand Down Expand Up @@ -103,7 +113,7 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
const cupdlp_int local_log_level = getCupdlpLogLevel(options);
if (local_log_level) cupdlp_printf("Solving with cuPDLP-C\n");

Init_Scaling(local_log_level, scaling, nCols, nRows, cost, rhs);
H_Init_Scaling(local_log_level, scaling, nCols, nRows, cost, rhs);
cupdlp_int ifScaling = 1;

CUPDLPwork* w = cupdlp_NULL;
Expand All @@ -125,8 +135,8 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
memcpy(csc_cpu->colMatElem, csc_val, nnz * sizeof(double));

cupdlp_float scaling_time = getTimeStamp();
PDHG_Scale_Data_cuda(local_log_level, csc_cpu, ifScaling, scaling, cost,
lower, upper, rhs);
H_PDHG_Scale_Data_cuda(local_log_level, csc_cpu, ifScaling, scaling, cost,
lower, upper, rhs);
scaling_time = getTimeStamp() - scaling_time;

cupdlp_float alloc_matrix_time = 0.0;
Expand Down
22 changes: 18 additions & 4 deletions src/pdlp/cupdlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,21 @@ The `cuPDLP-c` iteration count is held in `pdhg->timers->nIter`, but `pdhg` is d

- Make CupldlpWrapper.cpp look more like C++ than C





+## Using a GPU
+
+### Install CUDA
+
+* sudo apt update && sudo apt upgrade
+* sudo apt autoremove nvidia* --purge
+* sudo apt update && sudo apt upgrade
+* nvcc --version
+* sudo apt install nvidia-cuda-toolkit
+
+### Building PDLP
+
+export HIGHS_HOME=/home/jajhall/install
+export CUDA_HOME=/usr/lib/cuda
+
+
+
+
18 changes: 9 additions & 9 deletions src/pdlp/cupdlp/cupdlp_scaling_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ cupdlp_retcode cupdlp_pc_scaling_cuda(CUPDLPcsc *csc, cupdlp_float *cost,
return retcode;
}

cupdlp_retcode PDHG_Scale_Data_cuda(cupdlp_int log_level,
CUPDLPcsc *csc, cupdlp_int ifScaling,
CUPDLPscaling *scaling, cupdlp_float *cost,
cupdlp_float *lower, cupdlp_float *upper,
cupdlp_float *rhs) {
cupdlp_retcode H_PDHG_Scale_Data_cuda(cupdlp_int log_level,
CUPDLPcsc *csc, cupdlp_int ifScaling,
CUPDLPscaling *scaling, cupdlp_float *cost,
cupdlp_float *lower, cupdlp_float *upper,
cupdlp_float *rhs) {
cupdlp_retcode retcode = RETCODE_OK;
// scaling->dObjScale = 1.0;

Expand Down Expand Up @@ -395,10 +395,10 @@ cupdlp_retcode PDHG_Scale_Data_cuda(cupdlp_int log_level,
return retcode;
}

cupdlp_retcode Init_Scaling(cupdlp_int log_level,
CUPDLPscaling *scaling, cupdlp_int ncols,
cupdlp_int nrows, cupdlp_float *cost,
cupdlp_float *rhs) {
cupdlp_retcode H_Init_Scaling(cupdlp_int log_level,
CUPDLPscaling *scaling, cupdlp_int ncols,
cupdlp_int nrows, cupdlp_float *cost,
cupdlp_float *rhs) {
cupdlp_retcode retcode = RETCODE_OK;

scaling->ifRuizScaling = 1;
Expand Down
20 changes: 10 additions & 10 deletions src/pdlp/cupdlp/cupdlp_scaling_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
extern "C" {
#endif

cupdlp_retcode PDHG_Scale_Data_cuda(cupdlp_int log_level,
CUPDLPcsc *csc, cupdlp_int ifScaling,
CUPDLPscaling *scaling, cupdlp_float *cost,
cupdlp_float *lower, cupdlp_float *upper,
cupdlp_float *rhs);

cupdlp_retcode Init_Scaling(cupdlp_int log_level,
CUPDLPscaling *scaling, cupdlp_int ncols,
cupdlp_int nrows, cupdlp_float *cost,
cupdlp_float *rhs);
cupdlp_retcode H_PDHG_Scale_Data_cuda(cupdlp_int log_level,
CUPDLPcsc *csc, cupdlp_int ifScaling,
CUPDLPscaling *scaling, cupdlp_float *cost,
cupdlp_float *lower, cupdlp_float *upper,
cupdlp_float *rhs);

cupdlp_retcode H_Init_Scaling(cupdlp_int log_level,
CUPDLPscaling *scaling, cupdlp_int ncols,
cupdlp_int nrows, cupdlp_float *cost,
cupdlp_float *rhs);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 65fc061

Please sign in to comment.