Part of each iteration of the solver is solving a system of linear equations. Scs provides some freedom in this respect. i.e. one can choose one of the following provided methods:
- Direct Solver using
- Indirect Solver using conjugated gradient
- Indirect Solver on gpu using sparse conjugated gradient through CUDA
(You may also implement your own solver.)
On the julia side only the Direct and Indirect solvers are available
The main problem with providing the gpu solver is that
cusparse works only with
scs has to be compiled with
while other software (including
It means, that when user asks for the gpu solver we need not only cast our data appropriately, but also alternate the objects we’re passing to e.g.
scs_solve, by changing the storage type, struct alignment etc. In
julia we have a simple method for making this happen: parametrize the mirrored
c-structs by the type of integer. Long story short: by checking out enh/gpu_solver branch you can enjoy the gpu solver even from julia.
Well not quite, You need to compile
We start with a tiny patch to (a patch for using
CUDA_PATH has been already merged, no need for it anymore).
Then define env variables:
CUDA_PATHpointing to cuda installation
./lib/juliainside your julia installation
make purge make -j4 CFLAGS="-march=native" DLONG=1 USE_OPENMP=1 BLASLDFLAGS="-L$JULIA_LIBRARY_PATH -lopenblas64_" BLAS64=1 BLASSUFFIX=_64_ LD_LIBRARY_PATH=$JULIA_LIBRARY_PATH ./out/demo_socp_direct 1000 0.5 0.5 1 LD_LIBRARY_PATH=$JULIA_LIBRARY_PATH ./out/demo_socp_indirect 1000 0.5 0.5 1 make clean # note DLONG=0 below! make -j4 CFLAGS="-march=native" DLONG=0 USE_OPENMP=1 BLASLDFLAGS="-L$JULIA_LIBRARY_PATH -lopenblas64_" BLAS64=1 BLASSUFFIX=_64_ gpu LD_LIBRARY_PATH=$JULIA_LIBRARY_PATH ./out/demo_socp_gpu 1000 0.5 0.5 1 make clean
make purgeat the beginning and
make cleanin the middle to get rid of partial products (as these were produced with
DLONG=1). In addition we also run demos to make sure
scsproduced working libraries.
At this moment there should be three libraries in
libscsgpuindir. (The first two are compiled with
scs_int = long implied by
DLONG=1, the last with
scs_int = int. Assuming you’re on a sane platform.) Finally we need to set
ENV["JULIA_SCS_LIBRARY_PATH"]=/path/to/source/of/scs/out and issue
Pkg.build("SCS") (don’t forget to
dev SCS first).
If You want to be sure, check
SCS.available_solvers and observe the output of