Skip to content

Commit

Permalink
clean up diff with latest
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Jan 17, 2025
1 parent 7826c30 commit 61daaa5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 45 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ if(NOT(${HIGHS_NO_DEFAULT_THREADS} STREQUAL "OFF"))
message(STATUS "Default multithreading: disabled")
endif()

add_compile_options("$<$<AND:$<CONFIG:Debug,RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-G>")
add_compile_options("-g3")
# For debug of cuda locally
# add_compile_options("$<$<AND:$<CONFIG:Debug,RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-G>")
# add_compile_options("-g3")

# If Visual Studio targets are being built.
if(MSVC)
Expand Down
1 change: 1 addition & 0 deletions src/HConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#cmakedefine ZLIB_FOUND
#cmakedefine CUPDLP_CPU
#cmakedefine CUPDLP_GPU
#cmakedefine CUPDLP_FORCE_NATIVE
#cmakedefine CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#cmakedefine CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#cmakedefine HIGHSINT64
Expand Down
3 changes: 0 additions & 3 deletions src/pdlp/CupdlpWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ typedef enum CONSTRAINT_TYPE { EQ = 0, LEQ, GEQ, BOUND } constraint_type;
#define cupdlp_init_vec_double(var, size) \
{ (var) = (double*)malloc((size) * sizeof(double)); }

// #define cupdlp_init_zero_vec_double(var, size) \
// { (var) = (double*)calloc(size, sizeof(double)); }

#define cupdlp_copy_vec(dst, src, type, size) \
memcpy(dst, src, sizeof(type) * (size))

Expand Down
16 changes: 4 additions & 12 deletions src/pdlp/cupdlp/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,10 @@ add_library(cudalin SHARED
target_compile_options(cudalin PRIVATE
"$<$<AND:$<CONFIG:Debug,RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-G>")

# target_compile_options(cudalin PRIVATE "-G")
# target_compile_options(cudalin
# PUBLIC
# $<$<CONFIG:Debug>: "-g")
# target_compile_options(cudalin
# PUBLIC
# $<$<CONFIG:Debug>: "-G")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(cudalin PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-G>)

endif()
# Just testing locally
# if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# target_compile_options(cudalin PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-G>)
# endif()

set_target_properties(cudalin PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# target_include_directories(cudalin PUBLIC "/usr/local/cuda/include")
Expand Down
33 changes: 17 additions & 16 deletions src/pdlp/cupdlp/cupdlp_linalg.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,25 +789,26 @@ void cupdlp_compute_interaction_and_movement(CUPDLPwork *w,
cupdlp_dot(w, nCols, w->buffer2, w->buffer3, dInteraction);
}

double get_fabs_value(double* vec, int index, int N) {
#ifdef CUPDLP_CPU
return vec[index];
#else
int success = -1;
// WIP iinfnormabslocaltermination
// double get_fabs_value(double* vec, int index, int N) {
// #ifdef CUPDLP_CPU
// return vec[index];
// #else
// int success = -1;

// double result = 0;
// get_gpu_vec_element(vec, index, &result, &success);
// // double result = 0;
// // get_gpu_vec_element(vec, index, &result, &success);

double * b;
b = (double *)malloc (N * sizeof (*b));
get_gpu_vec(vec, index, b, &success);
// double * b;
// b = (double *)malloc (N * sizeof (*b));
// get_gpu_vec(vec, index, b, &success);

if (!success)
return 0;
// if (!success)
// return 0;

// return result;
// // return result;

return b[index];
// return b[index];

#endif
}
// #endif
// }
3 changes: 2 additions & 1 deletion src/pdlp/cupdlp/cupdlp_linalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ void cupdlp_compute_interaction_and_movement(CUPDLPwork *w,
cupdlp_float *dMovement,
cupdlp_float *dIteraction);

// WIP
// double get_fabs_value(double* vec, int index);
double get_fabs_value(double* vec, int index, int N);
// double get_fabs_value(double* vec, int index, int N);

#endif // CUPDLP_CUPDLP_LINALG_H
28 changes: 18 additions & 10 deletions src/pdlp/cupdlp/cupdlp_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ void PDHG_Compute_Primal_Feasibility(CUPDLPwork *work, double *primalResidual,
if (work->settings->iInfNormAbsLocalTermination) {
cupdlp_int index;
cupdlp_infNormIndex(work, lp->nRows, primalResidual, &index);
#ifdef CUPDLP_CPU
*dPrimalFeasibility = fabs(primalResidual[index]);
#else
double res_value = get_fabs_value(primalResidual, index, lp->nRows);
*dPrimalFeasibility = fabs(res_value);
#endif

// WIP only allow native for the moment
// #ifdef CUPDLP_CPU
// *dPrimalFeasibility = fabs(primalResidual[index]);
// #else
// double res_value = get_fabs_value(primalResidual, index, lp->nRows);
// *dPrimalFeasibility = fabs(res_value);
// #endif

} else {
cupdlp_twoNorm(work, lp->nRows, primalResidual, dPrimalFeasibility);
}
Expand Down Expand Up @@ -168,12 +172,16 @@ void PDHG_Compute_Dual_Feasibility(CUPDLPwork *work, double *dualResidual,
if (work->settings->iInfNormAbsLocalTermination) {
cupdlp_int index;
cupdlp_infNormIndex(work, lp->nCols, dualResidual, &index);
#ifdef CUPDLP_CPU
*dDualFeasibility = fabs(dualResidual[index]);
#else
double res_value = get_fabs_value(dualResidual, index, lp->nCols);
*dDualFeasibility = fabs(res_value);
#endif

// WIP only allow native for the moment
// #ifdef CUPDLP_CPU
// *dDualFeasibility = fabs(dualResidual[index]);
// #else
// double res_value = get_fabs_value(dualResidual, index, lp->nCols);
// *dDualFeasibility = fabs(res_value);
// #endif

} else {
cupdlp_twoNorm(work, lp->nCols, dualResidual, dDualFeasibility);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pdlp/cupdlp/glbopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "HConfig.h"

// #ifdef CUPDLP_GPU
// #ifndef CUPDLP_CPU
// #include <cublas_v2.h> // cublas
// #include <cuda_runtime_api.h> // cudaMalloc, cudaMemcpy, etc.
// #include <cusparse.h> // cusparseSpMV
Expand Down

0 comments on commit 61daaa5

Please sign in to comment.