Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Jan 13, 2025
1 parent 59cf2d6 commit e0b5713
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ else()
# No interfaces (apart from c); No ipx; New (short) ctest instances.
add_library(highs)

# target_compile_definitions(highs
# PUBLIC
# # If the debug configuration pass the DEBUG define to the compiler
# $<$<CONFIG:Debug>:CUPDLP_DEBUG>
# )
target_compile_definitions(highs
PUBLIC
# If the debug configuration pass the DEBUG define to the compiler
$<$<CONFIG:Debug>:CUPDLP_DEBUG>
)

add_library(${PROJECT_NAMESPACE}::highs ALIAS highs)

Expand Down
12 changes: 12 additions & 0 deletions src/pdlp/cupdlp/cuda/cupdlp_cuda_kernels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ typedef double cupdlp_float;

dim3 cuda_gridsize(cupdlp_int n);

#define get_gpu_vec(vec_ptr, index, result, success) \
{ \
cublasStatus_t stat = \
cublasGetVector(N, sizeof(*vec_ptr), vec_ptr, 1, result, 1); \
if (stat != CUBLAS_STATUS_SUCCESS) { \
printf("data upload failed"); \
*success = 0; \
} else { \
*success = 1; \
} \
}

#define get_gpu_vec_element(vec_ptr, index, result, success) \
{ \
cublasStatus_t stat = \
Expand Down
18 changes: 14 additions & 4 deletions src/pdlp/cupdlp/cupdlp_linalg.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,25 @@ 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) {
double get_fabs_value(double* vec, int index, int N) {
#ifdef CUPDLP_CPU
return vec[index];
#else
double result = 0;
int success = -1;
get_gpu_vec_element(vec, index, &result, &success);

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

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

if (!success)
return 0;
return result;

// return result;

return b[index];

#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,6 +182,7 @@ void cupdlp_compute_interaction_and_movement(CUPDLPwork *w,
cupdlp_float *dMovement,
cupdlp_float *dIteraction);

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

#endif // CUPDLP_CUPDLP_LINALG_H
4 changes: 2 additions & 2 deletions src/pdlp/cupdlp/cupdlp_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void PDHG_Compute_Primal_Feasibility(CUPDLPwork *work, double *primalResidual,
#ifdef CUPDLP_CPU
*dPrimalFeasibility = fabs(primalResidual[index]);
#else
double res_value = get_fabs_value(primalResidual, index);
double res_value = get_fabs_value(primalResidual, index, lp->nRows);
*dPrimalFeasibility = fabs(res_value);
#endif
} else {
Expand Down Expand Up @@ -171,7 +171,7 @@ void PDHG_Compute_Dual_Feasibility(CUPDLPwork *work, double *dualResidual,
#ifdef CUPDLP_CPU
*dDualFeasibility = fabs(dualResidual[index]);
#else
double res_value = get_fabs_value(dualResidual, index);
double res_value = get_fabs_value(dualResidual, index, lp->nCols);
*dDualFeasibility = fabs(res_value);
#endif
} else {
Expand Down

0 comments on commit e0b5713

Please sign in to comment.