Skip to content

Commit e0e87bc

Browse files
committed
Merge branch 'cuda-wip-win-latest' into cuda-test
2 parents eeab11d + ab2f19c commit e0e87bc

File tree

10 files changed

+57
-51
lines changed

10 files changed

+57
-51
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,5 @@ highs-problem-set
291291

292292
# Generated HiGHS options file
293293
Options.md
294+
295+
build-latest

src/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ else()
130130
# No interfaces (apart from c); No ipx; New (short) ctest instances.
131131
add_library(highs)
132132

133-
target_compile_definitions(highs
134-
PUBLIC
135-
# If the debug configuration pass the DEBUG define to the compiler
136-
$<$<CONFIG:Debug>:CUPDLP_DEBUG>
137-
)
138-
139133
add_library(${PROJECT_NAMESPACE}::highs ALIAS highs)
140134

141135
if(${BUILD_SHARED_LIBS})

src/lp_data/Highs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ HighsStatus Highs::solve() {
15291529
if (have_unknown_reduced_solution)
15301530
highsLogUser(
15311531
options_.log_options, HighsLogType::kWarning,
1532-
"Running postsolve on non-optimal solution of reduced LP\n");
1532+
"Running postsolve on non-optimal solution of reduced LP\n\n");
15331533
// If presolve is nontrivial, extract the optimal solution
15341534
// and basis for the presolved problem in order to generate
15351535
// the solution and basis for postsolve to use to generate a

src/pdlp/CupdlpWrapper.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
110110
if (local_log_level) cupdlp_printf("Solving with cuPDLP-C\n");
111111

112112
// H_Init_Scaling(local_log_level, scaling, nCols, nRows, cost, rhs);
113-
Init_Scaling(scaling, nCols, nRows, cost, rhs);
113+
Init_Scaling(local_log_level, scaling, nCols, nRows, cost, rhs);
114114

115115
cupdlp_int ifScaling = 1;
116116

@@ -154,7 +154,7 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
154154

155155
cupdlp_float scaling_time = getTimeStamp();
156156

157-
PDHG_Scale_Data(csc_cpu, ifScaling, scaling, cost, lower, upper, rhs);
157+
PDHG_Scale_Data(local_log_level, csc_cpu, ifScaling, scaling, cost, lower, upper, rhs);
158158

159159
scaling_time = getTimeStamp() - scaling_time;
160160

@@ -727,8 +727,11 @@ void getUserParamsFromOptions(const HighsOptions& options,
727727
#endif
728728
#else
729729
ifChangeIntParam[I_INF_NORM_ABS_LOCAL_TERMINATION] = false;
730-
if (!options.pdlp_native_termination) {
731-
printf("Warning: GPU only supports pdlp_native_termination=on. Forcing pdlp_native_termination=on.\n");
730+
731+
if (intParam[N_LOG_LEVEL]) {
732+
if (!options.pdlp_native_termination) {
733+
printf("GPU only supports pdlp_native_termination=on. Forcing pdlp_native_termination=on.\n");
734+
}
732735
}
733736
#endif
734737
}

src/pdlp/cupdlp/cuda/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ target_include_directories(cudalin PUBLIC "${CMAKE_CUDA_PATH}/include")
1616
if (WIN32)
1717
target_link_libraries(cudalin ${CUDA_LIBRARY})
1818
else()
19-
target_compile_definitions(cudalin
20-
PUBLIC
21-
# If the debug configuration pass the DEBUG define to the compiler
22-
$<$<CONFIG:Debug>:-DCUPDLP_DEBUG=1>
23-
)
19+
# target_compile_definitions(cudalin
20+
# PUBLIC
21+
# # If the debug configuration pass the DEBUG define to the compiler
22+
# $<$<CONFIG:Debug>:-DCUPDLP_DEBUG=1>
23+
# )
2424
target_link_libraries(cudalin ${CUDA_LIBRARY} m)
2525
endif()
2626

src/pdlp/cupdlp/cupdlp_scaling.c

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ cupdlp_retcode cupdlp_pc_scaling(CUPDLPcsc *csc, cupdlp_float *cost,
229229
return retcode;
230230
}
231231

232-
cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
233-
CUPDLPscaling *scaling, cupdlp_float *cost,
234-
cupdlp_float *lower, cupdlp_float *upper,
235-
cupdlp_float *rhs) {
232+
cupdlp_retcode PDHG_Scale_Data(cupdlp_int log_level, CUPDLPcsc *csc,
233+
cupdlp_int ifScaling, CUPDLPscaling *scaling,
234+
cupdlp_float *cost, cupdlp_float *lower,
235+
cupdlp_float *upper, cupdlp_float *rhs) {
236236
cupdlp_retcode retcode = RETCODE_OK;
237237
// scaling->dObjScale = 1.0;
238238

@@ -255,11 +255,13 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
255255
}
256256
dAvgElem /= csc->colMatBeg[nCols];
257257

258-
cupdlp_printf("Problem before rescaling:\n");
259-
cupdlp_printf(
260-
"Absolute value of nonzero constraint matrix elements: largest=%f, "
261-
"smallest=%f, avg=%f\n",
262-
dMaxElem, dMinElem, dAvgElem);
258+
if (log_level) {
259+
cupdlp_printf("Problem before rescaling:\n");
260+
cupdlp_printf(
261+
"Absolute value of nonzero constraint matrix elements: largest=%f, "
262+
"smallest=%f, avg=%f\n",
263+
dMaxElem, dMinElem, dAvgElem);
264+
}
263265

264266
// calculate the three statistics of objective vector
265267
dMinElem = OUR_DBL_MAX;
@@ -274,6 +276,8 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
274276
dAvgElem += dAbsElem;
275277
}
276278
dAvgElem /= nCols;
279+
280+
// if (log_level) {}
277281
cupdlp_printf(
278282
"Absolute value of objective vector elements: largest=%f, smallest=%f, "
279283
"avg=%f\n",
@@ -299,26 +303,26 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
299303
#endif
300304

301305
if (ifScaling) {
302-
cupdlp_printf("--------------------------------------------------\n");
303-
cupdlp_printf("running scaling\n");
306+
if (log_level) cupdlp_printf("--------------------------------------------------\n");
307+
if (log_level) cupdlp_printf("running scaling\n");
304308

305309
if (scaling->ifRuizScaling) {
306-
cupdlp_printf("- use Ruiz scaling\n");
310+
if (log_level) cupdlp_printf("- use Ruiz scaling\n");
307311
CUPDLP_CALL(cupdlp_ruiz_scaling(csc, cost, lower, upper, rhs, scaling))
308312
scaling->ifScaled = 1;
309313
}
310314
if (scaling->ifL2Scaling) {
311-
cupdlp_printf("- use L2 scaling\n");
315+
if (log_level) cupdlp_printf("- use L2 scaling\n");
312316
CUPDLP_CALL(cupdlp_l2norm_scaling(csc, cost, lower, upper, rhs, scaling))
313317
scaling->ifScaled = 1;
314318
}
315319
if (scaling->ifPcScaling) {
316-
cupdlp_printf("- use PC scaling\n");
320+
if (log_level) cupdlp_printf("- use PC scaling\n");
317321
CUPDLP_CALL(cupdlp_pc_scaling(csc, cost, lower, upper, rhs, scaling))
318322
scaling->ifScaled = 1;
319323
}
320324

321-
cupdlp_printf("--------------------------------------------------\n");
325+
if (log_level) cupdlp_printf("--------------------------------------------------\n");
322326
}
323327

324328
/* make sure the csr matrix is also scaled*/
@@ -339,8 +343,8 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
339343
}
340344
dAvgElem /= csc->colMatBeg[nCols];
341345

342-
cupdlp_printf("Problem after rescaling:\n");
343-
cupdlp_printf(
346+
if (log_level) cupdlp_printf("Problem after rescaling:\n");
347+
if (log_level) cupdlp_printf(
344348
"Absolute value of nonzero constraint matrix elements: largest=%f, "
345349
"smallest=%f, avg=%f\n",
346350
dMaxElem, dMinElem, dAvgElem);
@@ -358,7 +362,7 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
358362
dAvgElem += dAbsElem;
359363
}
360364
dAvgElem /= nCols;
361-
cupdlp_printf(
365+
if (log_level) cupdlp_printf(
362366
"Absolute value of objective vector elements: largest=%f, smallest=%f, "
363367
"avg=%f\n",
364368
dMaxElem, dMinElem, dAvgElem);
@@ -375,7 +379,7 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
375379
dAvgElem += dAbsElem;
376380
}
377381
dAvgElem /= nRows;
378-
cupdlp_printf(
382+
if (log_level) cupdlp_printf(
379383
"Absolute value of rhs vector elements: largest=%f, smallest=%f, "
380384
"avg=%f\n",
381385
dMaxElem, dMinElem, dAvgElem);
@@ -387,9 +391,9 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
387391
return retcode;
388392
}
389393

390-
cupdlp_retcode Init_Scaling(CUPDLPscaling *scaling, cupdlp_int ncols,
391-
cupdlp_int nrows, cupdlp_float *cost,
392-
cupdlp_float *rhs) {
394+
cupdlp_retcode Init_Scaling(cupdlp_int log_level, CUPDLPscaling* scaling,
395+
cupdlp_int ncols, cupdlp_int nrows,
396+
cupdlp_float* cost, cupdlp_float* rhs) {
393397
cupdlp_retcode retcode = RETCODE_OK;
394398

395399
scaling->rowScale = NULL;

src/pdlp/cupdlp/cupdlp_scaling.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
extern "C" {
1212
#endif
1313

14-
cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
15-
CUPDLPscaling *scaling, cupdlp_float *cost,
16-
cupdlp_float *lower, cupdlp_float *upper,
17-
cupdlp_float *rhs);
14+
cupdlp_retcode PDHG_Scale_Data(cupdlp_int log_level, CUPDLPcsc* csc,
15+
cupdlp_int ifScaling, CUPDLPscaling* scaling,
16+
cupdlp_float* cost, cupdlp_float* lower,
17+
cupdlp_float* upper, cupdlp_float* rhs);
1818

19-
cupdlp_retcode Init_Scaling(CUPDLPscaling *scaling, cupdlp_int ncols,
20-
cupdlp_int nrows, cupdlp_float *cost,
21-
cupdlp_float *rhs);
19+
cupdlp_retcode Init_Scaling(cupdlp_int log_level, CUPDLPscaling* scaling,
20+
cupdlp_int ncols, cupdlp_int nrows,
21+
cupdlp_float* cost, cupdlp_float* rhs);
2222

2323
#ifdef __cplusplus
2424
}

src/pdlp/cupdlp/cupdlp_solver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,15 +1174,15 @@ cupdlp_retcode PDHG_Solve(CUPDLPwork *pdhg) {
11741174
#endif
11751175

11761176
#ifndef CUPDLP_CPU
1177-
if (pdhg->settings->nLogLevel>0) {
1177+
if (pdhg->settings->nLogLevel>1) {
11781178
cupdlp_printf("\n");
11791179
cupdlp_printf("GPU Timing information:\n");
11801180
cupdlp_printf("%21s %e\n", "CudaPrepare", timers->CudaPrepareTime);
11811181
cupdlp_printf("%21s %e\n", "Alloc&CopyMatToDevice",
11821182
timers->AllocMem_CopyMatToDeviceTime);
11831183
cupdlp_printf("%21s %e\n", "CopyVecToDevice", timers->CopyVecToDeviceTime);
11841184
cupdlp_printf("%21s %e\n", "DeviceMatVecProd", timers->DeviceMatVecProdTime);
1185-
cupdlp_printf("%21s %e\n", "CopyVecToHost", timers->CopyVecToHostTime);
1185+
cupdlp_printf("%21s %e\n\n", "CopyVecToHost", timers->CopyVecToHostTime);
11861186
}
11871187
#endif
11881188

src/pdlp/cupdlp/cupdlp_utils.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ void stepsize_clear(CUPDLPstepsize *stepsize) {
304304
}
305305
}
306306

307-
void timers_clear(CUPDLPtimers *timers) {
307+
void timers_clear(int log_level, CUPDLPtimers *timers) {
308308
#ifndef CUPDLP_CPU
309-
cupdlp_printf("%20s %e\n", "Free Device memory", timers->FreeDeviceMemTime);
309+
if (log_level)
310+
cupdlp_printf("%20s %e\n\n", "Free Device memory", timers->FreeDeviceMemTime);
310311
#endif
311312

313+
312314
if (timers) {
313315
cupdlp_free(timers);
314316
}
@@ -335,6 +337,7 @@ cupdlp_int PDHG_Clear(CUPDLPwork *w) {
335337
CUPDLPtimers *timers = w->timers;
336338
CUPDLPscaling *scaling = w->scaling;
337339

340+
338341
cupdlp_float begin = getTimeStamp();
339342
#ifndef CUPDLP_CPU
340343

@@ -394,7 +397,7 @@ cupdlp_int PDHG_Clear(CUPDLPwork *w) {
394397
stepsize_clear(stepsize);
395398
}
396399
if (timers) {
397-
timers_clear(timers);
400+
timers_clear(w->settings->nLogLevel, timers);
398401
}
399402
if (scaling) {
400403
// scaling_clear(scaling);

src/pdlp/cupdlp/cupdlp_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void resobj_clear(CUPDLPresobj *resobj);
3636

3737
void stepsize_clear(CUPDLPstepsize *stepsize);
3838

39-
void timers_clear(CUPDLPtimers *timers);
39+
void timers_clear(int log_level, CUPDLPtimers *timers);
4040

4141
void scaling_clear(CUPDLPscaling *scaling);
4242

0 commit comments

Comments
 (0)