@@ -32,13 +32,7 @@ cupdlp_int csc_clear(CUPDLPcsc *csc) {
3232 if (csc ) {
3333#ifndef CUPDLP_CPU
3434 if (csc -> cuda_csc != NULL ) {
35- // CHECK_CUSPARSE(cusparseDestroySpMat(csc->cuda_csc))
36- cusparseStatus_t status = (cusparseDestroySpMat (csc -> cuda_csc ));
37- if (status != CUSPARSE_STATUS_SUCCESS ) {
38- printf ("CUSPARSE API failed at line %d of %s with error: %s (%d)\n" ,
39- __LINE__ , __FILE__ , cusparseGetErrorString (status ), status );
40- return EXIT_FAILURE ;
41- }
35+ CHECK_CUSPARSE (cusparseDestroySpMat (csc -> cuda_csc ))
4236 }
4337#endif
4438 if (csc -> colMatBeg ) {
@@ -216,7 +210,7 @@ void iterates_clear(CUPDLPiterates *iterates) {
216210 if (iterates -> yLastRestart ) {
217211 CUPDLP_FREE_VEC (iterates -> yLastRestart );
218212 }
219- if (iterates -> ax [0 ]) {
213+ if (iterates -> ax [0 ]) {
220214 // CUPDLP_FREE_VEC(iterates->ax[0]);
221215 vec_clear (iterates -> ax [0 ]);
222216 }
@@ -241,7 +235,6 @@ void iterates_clear(CUPDLPiterates *iterates) {
241235 vec_clear (iterates -> atyAverage );
242236 }
243237 cupdlp_free (iterates );
244-
245238 }
246239}
247240
@@ -342,81 +335,79 @@ cupdlp_int PDHG_Clear(CUPDLPwork *w) {
342335 CUPDLPtimers * timers = w -> timers ;
343336 CUPDLPscaling * scaling = w -> scaling ;
344337
345- cupdlp_float begin = getTimeStamp ();
338+ cupdlp_float begin = getTimeStamp ();
346339#ifndef CUPDLP_CPU
347340
348- // CUDAmv *MV = w->MV;
349- // if (MV)
350- // {
351- // cupdlp_float begin = getTimeStamp();
352- // cuda_free_mv(MV);
353- // timers->FreeDeviceMemTime += getTimeStamp() - begin;
354- // }
355- CHECK_CUBLAS (cublasDestroy (w -> cublashandle ))
356- CHECK_CUSPARSE (cusparseDestroy (w -> cusparsehandle ))
357- CHECK_CUDA (cudaFree (w -> dBuffer_csc_ATy ))
358- CHECK_CUDA (cudaFree (w -> dBuffer_csr_Ax ))
359- if (w -> buffer2 ) CUPDLP_FREE_VEC (w -> buffer2 );
360- if (w -> buffer3 ) CUPDLP_FREE_VEC (w -> buffer3 );
341+ // CUDAmv *MV = w->MV;
342+ // if (MV)
343+ // {
344+ // cupdlp_float begin = getTimeStamp();
345+ // cuda_free_mv(MV);
346+ // timers->FreeDeviceMemTime += getTimeStamp() - begin;
347+ // }
348+ CHECK_CUBLAS (cublasDestroy (w -> cublashandle ))
349+ CHECK_CUSPARSE (cusparseDestroy (w -> cusparsehandle ))
350+ CHECK_CUDA (cudaFree (w -> dBuffer_csc_ATy ))
351+ CHECK_CUDA (cudaFree (w -> dBuffer_csr_Ax ))
352+ if (w -> buffer2 ) CUPDLP_FREE_VEC (w -> buffer2 );
353+ if (w -> buffer3 ) CUPDLP_FREE_VEC (w -> buffer3 );
361354#endif
362- if (w -> colScale ) CUPDLP_FREE_VEC (w -> colScale );
363- if (w -> rowScale ) CUPDLP_FREE_VEC (w -> rowScale );
355+ if (w -> colScale ) CUPDLP_FREE_VEC (w -> colScale );
356+ if (w -> rowScale ) CUPDLP_FREE_VEC (w -> rowScale );
364357
365- if (w -> buffer ) {
366- // CUPDLP_FREE_VEC(w->buffer);
367- vec_clear (w -> buffer );
368- }
358+ if (w -> buffer ) {
359+ // CUPDLP_FREE_VEC(w->buffer);
360+ vec_clear (w -> buffer );
361+ }
369362
370- if (w -> buffer2 != NULL ) {
371- // CUPDLP_FREE_VEC(w->buffer);
372- free (w -> buffer2 );
373- }
363+ if (w -> buffer2 != NULL ) {
364+ // CUPDLP_FREE_VEC(w->buffer);
365+ free (w -> buffer2 );
366+ }
374367
375- if (w -> buffer3 ) {
376- // CUPDLP_FREE_VEC(w->buffer);
377- free (w -> buffer3 );
378- }
368+ if (w -> buffer3 ) {
369+ // CUPDLP_FREE_VEC(w->buffer);
370+ free (w -> buffer3 );
371+ }
379372
380- if (problem ) {
381- // problem_clear(problem);
382- problem = cupdlp_NULL ;
383- }
373+ if (problem ) {
374+ // problem_clear(problem);
375+ problem = cupdlp_NULL ;
376+ }
384377
385- if (iterates ) {
386- iterates_clear (iterates );
387- }
378+ if (iterates ) {
379+ iterates_clear (iterates );
380+ }
388381
389- if (resobj ) {
390- resobj_clear (resobj );
391- }
382+ if (resobj ) {
383+ resobj_clear (resobj );
384+ }
392385
393386#ifndef CUPDLP_CPU
394- timers -> FreeDeviceMemTime += getTimeStamp () - begin ;
387+ timers -> FreeDeviceMemTime += getTimeStamp () - begin ;
395388#endif
396389
397- if (settings ) {
398- settings_clear (settings );
399- }
400- if (stepsize ) {
401- stepsize_clear (stepsize );
402- }
403- if (timers ) {
404- timers_clear (timers );
405- }
406- if (scaling ) {
407- // scaling_clear(scaling);
408- if (scaling -> colScale ) {
409- // cupdlp_free(scaling->colScale);
410- CUPDLP_FREE_VEC (scaling -> colScale ); // now on gpu
411- }
412- if (scaling -> rowScale ) {
413- // cupdlp_free(scaling->rowScale);
414- CUPDLP_FREE_VEC (scaling -> rowScale ); // now on gpu
415- }
416- // cupdlp_free(scaling);
417- scaling = cupdlp_NULL ;
418- }
419- cupdlp_free (w );
390+ if (settings ) {
391+ settings_clear (settings );
392+ }
393+ if (stepsize ) {
394+ stepsize_clear (stepsize );
395+ }
396+ if (timers ) {
397+ timers_clear (timers );
398+ }
399+ if (scaling ) {
400+ // scaling_clear(scaling);
401+ // if (scaling->colScale) {
402+ // cupdlp_free(scaling->colScale);
403+ // }
404+ // if (scaling->rowScale) {
405+ // cupdlp_free(scaling->rowScale);
406+ // }
407+ // cupdlp_free(scaling);
408+ scaling = cupdlp_NULL ;
409+ }
410+ cupdlp_free (w );
420411
421412 return 0 ;
422413}
@@ -641,14 +632,14 @@ cupdlp_retcode getUserParam(int argc, char **argv,
641632 }
642633 }
643634
644- if (argc > 0 ) {
645- if (strcmp (argv [argc - 1 ], "-h" ) == 0 ) {
646- PDHG_PrintUserParamHelper ();
635+ // if (argc>0) {
636+ // if (strcmp(argv[argc - 1], "-h") == 0) {
637+ // PDHG_PrintUserParamHelper();
647638
648- retcode = RETCODE_FAILED ;
649- goto exit_cleanup ;
650- }
651- }
639+ // retcode = RETCODE_FAILED;
640+ // goto exit_cleanup;
641+ // }
642+ // }
652643
653644exit_cleanup :
654645 return retcode ;
@@ -893,14 +884,6 @@ cupdlp_retcode resobj_Alloc(CUPDLPresobj *resobj, CUPDLPproblem *problem,
893884
894885 // CUPDLP_INIT_DOUBLE_ZERO_VEC(resobj->dualInfeasBound, nrows);
895886
896- // need to translate to cuda type
897- // for (int i = 0; i < ncols; i++)
898- // {
899- // resobj->dLowerFiltered[i] = problem->lower[i] > -INFINITY ?
900- // problem->lower[i] : 0.0; resobj->dUpperFiltered[i] = problem->upper[i]
901- // < +INFINITY ? problem->upper[i] : 0.0;
902- // }
903-
904887 cupdlp_filterlb (resobj -> dLowerFiltered , problem -> lower , - INFINITY , ncols );
905888 cupdlp_filterub (resobj -> dUpperFiltered , problem -> upper , + INFINITY , ncols );
906889
@@ -1120,13 +1103,12 @@ cupdlp_retcode PDHG_Alloc(CUPDLPwork *w) {
11201103#ifndef CUPDLP_CPU
11211104 // CHECK_CUSPARSE(cusparseCreate(&w->cusparsehandle));
11221105 // CHECK_CUBLAS(cublasCreate(&w->cublashandle));
1123- CUPDLP_CALL (cuda_alloc_MVbuffer (
1106+ CUPDLP_CALL (cuda_alloc_MVbuffer (
11241107 // w->problem->data->matrix_format,
11251108 w -> cusparsehandle , w -> problem -> data -> csc_matrix -> cuda_csc ,
11261109 w -> iterates -> x [0 ]-> cuda_vec , w -> iterates -> ax [0 ]-> cuda_vec ,
11271110 w -> problem -> data -> csr_matrix -> cuda_csr , w -> iterates -> y [0 ]-> cuda_vec ,
11281111 w -> iterates -> aty [0 ]-> cuda_vec , & w -> dBuffer_csc_ATy , & w -> dBuffer_csr_Ax ))
1129-
11301112 w -> timers -> AllocMem_CopyMatToDeviceTime += getTimeStamp () - begin ;
11311113#endif
11321114
@@ -1226,20 +1208,10 @@ cupdlp_int csc_copy(CUPDLPcsc *dst, CUPDLPcsc *src) {
12261208
12271209#ifndef CUPDLP_CPU
12281210 // Pointer to GPU csc matrix
1229- // CHECK_CUSPARSE(cusparseCreateCsc(
1230- // &dst->cuda_csc, src->nRows, src->nCols, src->nMatElem, dst->colMatBeg,
1231- // dst->colMatIdx, dst->colMatElem, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
1232- // CUSPARSE_INDEX_BASE_ZERO, CudaComputeType));
1233-
1234- cusparseStatus_t status = cusparseCreateCsc (
1211+ CHECK_CUSPARSE (cusparseCreateCsc (
12351212 & dst -> cuda_csc , src -> nRows , src -> nCols , src -> nMatElem , dst -> colMatBeg ,
12361213 dst -> colMatIdx , dst -> colMatElem , CUSPARSE_INDEX_32I , CUSPARSE_INDEX_32I ,
1237- CUSPARSE_INDEX_BASE_ZERO , CudaComputeType );
1238- if (status != CUSPARSE_STATUS_SUCCESS ) {
1239- printf ("CUSPARSE API failed at line %d of %s with error: %s (%d)\n" ,
1240- __LINE__ , __FILE__ , cusparseGetErrorString (status ), status );
1241- return 1 ;
1242- }
1214+ CUSPARSE_INDEX_BASE_ZERO , CudaComputeType ));
12431215#endif
12441216
12451217 return 0 ;
@@ -1410,12 +1382,6 @@ cupdlp_retcode csc_create(CUPDLPcsc **csc) {
14101382
14111383 CUPDLP_INIT_CSC_MATRIX (* csc , 1 );
14121384
1413- // #ifdef CUPDLP_CPU
1414- // CUPDLP_INIT_CSC_MATRIX(*csc, 1);
1415- // #else
1416- // CUPDLP_INIT(*csc, 1);
1417- // #endif
1418-
14191385exit_cleanup :
14201386 return retcode ;
14211387}
@@ -1502,21 +1468,9 @@ cupdlp_retcode csc_alloc_matrix(CUPDLPcsc *csc, cupdlp_int nRows,
15021468 break ;
15031469 }
15041470
1505- #ifndef CUPDLP_CPU
1506- cusparseStatus_t status = cudaMalloc ((void * * )& (csc -> colMatBeg ), (nCols + 1 ) * sizeof (int ));
1507- cusparseStatus_t status2 = cudaMalloc ((void * * )& (csc -> colMatIdx ), (nnz ) * sizeof (int ));
1508- cusparseStatus_t status3 = cudaMalloc ((void * * )& (csc -> colMatElem ), (nnz ) * sizeof (double ));
1509- if (status || status2 || status3 ) return 2 ;
1510-
1511- status = cudaMemset (csc -> colMatBeg , 0 , (nCols + 1 ) * sizeof (int ));
1512- status2 = cudaMemset (csc -> colMatIdx , 0 , (nnz ) * sizeof (int ));
1513- status3 = cudaMemset (csc -> colMatElem , 0 , (nnz ) * sizeof (double ));
1514- if (status || status2 || status3 ) return 2 ;
1515- #else
15161471 cupdlp_init_zero_vec_int (csc -> colMatBeg , nCols + 1 );
15171472 cupdlp_init_zero_vec_int (csc -> colMatIdx , nnz );
15181473 cupdlp_init_zero_vec_double (csc -> colMatElem , nnz );
1519- #endif
15201474
15211475 switch (src_matrix_format ) {
15221476 case DENSE :
@@ -1616,7 +1570,6 @@ void PDHG_Dump_Stats(CUPDLPwork *w) {
16161570 cupdlp_printf ("------------------------------------------------\n" );
16171571 cupdlp_printf ("Iteration % 3d\n" , w -> timers -> nIter );
16181572#if CUPDLP_DUMP_ITERATES
1619-
16201573 cupdlp_int iter = w -> timers -> nIter ;
16211574 CUPDLPvec * x = iterates -> x [iter % 2 ];
16221575 CUPDLPvec * y = iterates -> y [iter % 2 ];
@@ -1630,7 +1583,6 @@ void PDHG_Dump_Stats(CUPDLPwork *w) {
16301583 vecPrint ("A'y" , aty -> data , nCols );
16311584 vecPrint ("xLastRestart" , iterates -> xLastRestart , nCols );
16321585 vecPrint ("yLastRestart" , iterates -> yLastRestart , nRows );
1633-
16341586#endif
16351587 cupdlp_printf (
16361588 "PrimalStep: %e, SumPrimalStep: %e, DualStep: %e, SumDualStep: %e\n" ,
0 commit comments