Skip to content

Commit

Permalink
LAPACK build flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dance858 committed Nov 17, 2024
1 parent 443d99a commit c22d5d2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
44 changes: 31 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,21 @@ set(${PROJECT_NAME}_PUBLIC_HDR include/scs_types.h include/scs.h)

# Common source files
set(${PROJECT_NAME}_SRC
src/aa.c
src/cones.c
src/ctrlc.c
src/exp_cone.c
src/linalg.c
src/normalize.c
src/rw.c
src/scs.c
src/scs_version.c
src/util.c
src/aa.c
src/cones.c
src/ctrlc.c
src/exp_cone.c
src/linalg.c
src/normalize.c
src/rw.c
src/scs.c
src/scs_version.c
src/util.c
${LINSYS}/csparse.c
${LINSYS}/scs_matrix.c)

# Spectral source files
set(SPECTRAL_SRC
src/spectral_cones/logdeterminant/log_cone_Newton.c
src/spectral_cones/logdeterminant/log_cone_IPM.c
src/spectral_cones/logdeterminant/log_cone_wrapper.c
Expand All @@ -202,9 +207,13 @@ set(${PROJECT_NAME}_SRC
src/spectral_cones/nuclear/nuclear_cone.c
src/spectral_cones/sum-largest/sum_largest_cone.c
src/spectral_cones/sum-largest/sum_largest_eval_cone.c
src/spectral_cones/util_spectral_cones.c
${LINSYS}/csparse.c
${LINSYS}/scs_matrix.c)
src/spectral_cones/util_spectral_cones.c)

# Conditionally add spectral files
if(USE_LAPACK)
list(APPEND ${PROJECT_NAME}_SRC ${SPECTRAL_SRC})
endif()


# Common header files
set(${PROJECT_NAME}_HDR
Expand All @@ -225,6 +234,15 @@ set(${PROJECT_NAME}_HDR
${LINSYS}/csparse.h
${LINSYS}/scs_matrix.h)

# Spectral header files
set(SPECTRAL_HDR
include/util_spectral_cones.h)

if(USE_LAPACK)
list(APPEND ${PROJECT_NAME}_HDR ${SPECTRAL_HDR})
endif()


# get all the c file in amd/external
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC ${EXTERNAL}/amd/*.c)

Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# MAKEFILE for scs
include scs.mk

SCS_OBJECTS = src/util.o src/cones.o src/exp_cone.o src/aa.o src/rw.o src/linalg.o src/ctrlc.o src/scs_version.o src/normalize.o \
src/spectral_cones/logdeterminant/log_cone_Newton.o src/spectral_cones/logdeterminant/log_cone_IPM.o \
src/spectral_cones/logdeterminant/log_cone_wrapper.o src/spectral_cones/logdeterminant/logdet_cone.o \
src/spectral_cones/nuclear/ell1_cone.o src/spectral_cones/nuclear/nuclear_cone.o \
src/spectral_cones/sum-largest/sum_largest_cone.o src/spectral_cones/sum-largest/sum_largest_eval_cone.o \
src/spectral_cones/util_spectral_cones.o
ifneq ($(USE_LAPACK), 0)
SCS_OBJECTS = src/util.o src/cones.o src/exp_cone.o src/aa.o src/rw.o src/linalg.o src/ctrlc.o src/scs_version.o src/normalize.o \
src/spectral_cones/logdeterminant/log_cone_Newton.o src/spectral_cones/logdeterminant/log_cone_IPM.o \
src/spectral_cones/logdeterminant/log_cone_wrapper.o src/spectral_cones/logdeterminant/logdet_cone.o \
src/spectral_cones/nuclear/ell1_cone.o src/spectral_cones/nuclear/nuclear_cone.o \
src/spectral_cones/sum-largest/sum_largest_cone.o src/spectral_cones/sum-largest/sum_largest_eval_cone.o \
src/spectral_cones/util_spectral_cones.o
else
SCS_OBJECTS = src/util.o src/cones.o src/exp_cone.o src/aa.o src/rw.o src/linalg.o src/ctrlc.o src/scs_version.o src/normalize.o
endif

SCS_O = src/scs.o
SCS_INDIR_O = src/scs_indir.o

Expand Down
5 changes: 4 additions & 1 deletion src/cones.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ static scs_int proj_cone(scs_float *x, const ScsCone *k, ScsConeWork *c,
scs_int normalize, scs_float *r_y) {
scs_int i, status;
scs_int count = 0;
scs_int offset_log_cone = 0; /* used for warmstarting log-cone projections */
scs_float *r_box = SCS_NULL;
SPECTRAL_TIMING(SCS(timer) spec_mat_proj_timer;)

Expand Down Expand Up @@ -1093,6 +1092,8 @@ static scs_int proj_cone(scs_float *x, const ScsCone *k, ScsConeWork *c,
count += 3 * k->psize;
}

#ifdef USE_LAPACK
scs_int offset_log_cone = 0; /* used for warmstarting log-cone projections */
/* project onto logdet cones */
if (k->dsize && k->d) {
for (i = 0; i < k->dsize; ++i) {
Expand Down Expand Up @@ -1138,6 +1139,8 @@ static scs_int proj_cone(scs_float *x, const ScsCone *k, ScsConeWork *c,
count += (get_sd_cone_size(k->sl_n[i]) + 1);
}
}

#endif
/* project onto OTHER cones */

return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,13 @@ void SCS(log_data_to_csv)(const ScsCone *k, const ScsSettings *stgs,
"accepted_accel_steps,"
"rejected_accel_steps,"
"time,"
#ifdef USE_LAPACK
"spectral_Newton_iter,"
"plain_Newton_success,"
"res_dual_spectral,"
"res_pri_spectral,"
"comp_spectral,"
#endif
"\n");
}
fprintf(fout, "%li,", (long)iter);
Expand Down Expand Up @@ -417,11 +419,13 @@ void SCS(log_data_to_csv)(const ScsCone *k, const ScsSettings *stgs,
fprintf(fout, "%li,", (long)w->accepted_accel_steps);
fprintf(fout, "%li,", (long)w->rejected_accel_steps);
fprintf(fout, "%.16e,", SCS(tocq)(solve_timer) / 1e3);
#ifdef USE_LAPACK
fprintf(fout, "%li,", (long)w->cone_work->newton_stats.iter);
fprintf(fout, "%li,", (long)w->cone_work->newton_stats.newton_success);
fprintf(fout, "%.16e,", w->cone_work->newton_stats.residuals[0]);
fprintf(fout, "%.16e,", w->cone_work->newton_stats.residuals[1]);
fprintf(fout, "%.16e,", w->cone_work->newton_stats.residuals[2]);
#endif
fprintf(fout, "\n");
fclose(fout);
}
Expand Down

0 comments on commit c22d5d2

Please sign in to comment.