scs 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +18 -18
- data/README.md +1 -1
- data/lib/scs/version.rb +1 -1
- data/vendor/scs/CMakeLists.txt +273 -0
- data/vendor/scs/README.md +57 -9
- data/vendor/scs/include/glbopts.h +1 -1
- data/vendor/scs/linsys/amatrix.o +0 -0
- data/vendor/scs/linsys/cpu/direct/private.o +0 -0
- data/vendor/scs/linsys/cpu/indirect/private.o +0 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_1.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_2.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_aat.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_control.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_defaults.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_dump.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_global.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_info.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_order.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_post_tree.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_postorder.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_preprocess.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_valid.o +0 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.o +0 -0
- data/vendor/scs/linsys/gpu/gpu.c +50 -11
- data/vendor/scs/linsys/gpu/gpu.h +26 -5
- data/vendor/scs/linsys/gpu/indirect/private.c +124 -16
- data/vendor/scs/linsys/gpu/indirect/private.h +5 -0
- data/vendor/scs/src/aa.o +0 -0
- data/vendor/scs/src/cones.o +0 -0
- data/vendor/scs/src/ctrlc.o +0 -0
- data/vendor/scs/src/linalg.o +0 -0
- data/vendor/scs/src/normalize.o +0 -0
- data/vendor/scs/src/rw.c +1 -1
- data/vendor/scs/src/rw.o +0 -0
- data/vendor/scs/src/scs.o +0 -0
- data/vendor/scs/src/scs_version.o +0 -0
- data/vendor/scs/src/util.o +0 -0
- metadata +10 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0578a2b207262c394530743edb4943b8c1e17d8b56e890f7127bc1db29d74a39'
|
4
|
+
data.tar.gz: '099d565be542333322a4a7fad5fd5b45d6ce16f3c6bedd1335ed92c8f534842d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc5791159501b367a295502936c6696a0d170a86ecc07e1c4937d3e7030f8759cdf6df988dea2ccb14cb444e931cc390dcc4cecc7e31b5714f97dc62e3b2e40
|
7
|
+
data.tar.gz: da1556dc4a0430bf772955cf7e91da186d2df43f6a52765a13cba95c3b75a895bb76b8408ecb4f8ae77f427d3b026a5517fa8bbe81ed4e896286eea7ca4414bc
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2012 Brendan O'Donoghue (bodonoghue85@gmail.com)
|
4
|
+
Copyright (c) 2019-2021 Andrew Kane
|
4
5
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
12
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
15
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
:fire: Supports many different [problem types](https://www.cvxpy.org/tutorial/advanced/index.html#choosing-a-solver)
|
6
6
|
|
7
|
-
[![Build Status](https://
|
7
|
+
[![Build Status](https://github.com/ankane/scs/workflows/build/badge.svg?branch=master)](https://github.com/ankane/scs/actions)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
data/lib/scs/version.rb
CHANGED
@@ -0,0 +1,273 @@
|
|
1
|
+
# CMakeLists.txt file for scs
|
2
|
+
# This software may be modified and distributed under the terms of the MIT License
|
3
|
+
|
4
|
+
cmake_minimum_required(VERSION 3.5)
|
5
|
+
|
6
|
+
project(scs
|
7
|
+
LANGUAGES C
|
8
|
+
VERSION 2.1.4)
|
9
|
+
|
10
|
+
# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros.
|
11
|
+
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
|
12
|
+
include(GNUInstallDirs)
|
13
|
+
|
14
|
+
# Control where libraries and executables are placed during the build.
|
15
|
+
# With the following settings executables are placed in <the top level of the
|
16
|
+
# build tree>/bin and libraries/archives in <top level of the build tree>/lib.
|
17
|
+
# This is particularly useful to run ctests on libraries built on Windows
|
18
|
+
# machines: tests, which are executables, are placed in the same folders of
|
19
|
+
# dlls, which are treated as executables as well, so that they can properly
|
20
|
+
# find the libraries to run. This is a because of missing RPATH on Windows.
|
21
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
|
22
|
+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
23
|
+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
24
|
+
|
25
|
+
# To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE.
|
26
|
+
# See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
|
27
|
+
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
|
28
|
+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
29
|
+
|
30
|
+
# Under MSVC, we set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
|
31
|
+
# built in debug mode. In this Windows user can compile, build and install the
|
32
|
+
# library in both Release and Debug configuration avoiding naming clashes in the
|
33
|
+
# installation directories.
|
34
|
+
if(MSVC)
|
35
|
+
set(CMAKE_DEBUG_POSTFIX "d")
|
36
|
+
endif()
|
37
|
+
|
38
|
+
# Build position independent code.
|
39
|
+
# Position Independent Code (PIC) is commonly used for shared libraries so that
|
40
|
+
# the same shared library code can be loaded in each program address space in a
|
41
|
+
# location where it will not overlap with any other uses of such memory.
|
42
|
+
# In particular, this option avoids problems occurring when a process wants to
|
43
|
+
# load more than one shared library at the same virtual address.
|
44
|
+
# Since shared libraries cannot predict where other shared libraries could be
|
45
|
+
# loaded, this is an unavoidable problem with the traditional shared library
|
46
|
+
# concept.
|
47
|
+
# Generating position-independent code is often the default behavior for most
|
48
|
+
# modern compilers.
|
49
|
+
# Moreover linking a static library that is not built with PIC from a shared
|
50
|
+
# library will fail on some compiler/architecture combinations.
|
51
|
+
# Further details on PIC can be found here:
|
52
|
+
# https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
|
53
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
54
|
+
|
55
|
+
# Disable C and C++ compiler extensions.
|
56
|
+
# C/CXX_EXTENSIONS are ON by default to allow the compilers to use extended
|
57
|
+
# variants of the C/CXX language.
|
58
|
+
# However, this could expose cross-platform bugs in user code or in the headers
|
59
|
+
# of third-party dependencies and thus it is strongly suggested to turn
|
60
|
+
# extensions off.
|
61
|
+
set(CMAKE_C_EXTENSIONS OFF)
|
62
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
63
|
+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
64
|
+
|
65
|
+
### Options
|
66
|
+
# Shared/Dynamic or Static library?
|
67
|
+
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
|
68
|
+
|
69
|
+
# Enable RPATH support for installed binaries and libraries
|
70
|
+
include(AddInstallRPATHSupport)
|
71
|
+
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
|
72
|
+
LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
|
73
|
+
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
|
74
|
+
USE_LINK_PATH)
|
75
|
+
|
76
|
+
# Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise set it to Release.
|
77
|
+
if(NOT CMAKE_CONFIGURATION_TYPES)
|
78
|
+
if(NOT CMAKE_BUILD_TYPE)
|
79
|
+
message(STATUS "Setting build type to 'Release' as none was specified.")
|
80
|
+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
|
81
|
+
endif()
|
82
|
+
endif()
|
83
|
+
|
84
|
+
|
85
|
+
# Build test related commands?
|
86
|
+
option(BUILD_TESTING "Create tests using CMake" OFF)
|
87
|
+
if(BUILD_TESTING)
|
88
|
+
enable_testing()
|
89
|
+
endif()
|
90
|
+
|
91
|
+
### Some variables useful for sampling the building process
|
92
|
+
# Note that the GPU profile is not compiled.
|
93
|
+
set(LINSYS linsys)
|
94
|
+
set(DIRSRC ${LINSYS}/cpu/direct)
|
95
|
+
set(INDIRSRC ${LINSYS}/cpu/indirect)
|
96
|
+
set(EXTERNAL ${LINSYS}/external)
|
97
|
+
|
98
|
+
|
99
|
+
# Common source files
|
100
|
+
set(${PROJECT_NAME}_SRC
|
101
|
+
src/aa.c
|
102
|
+
src/cones.c
|
103
|
+
src/ctrlc.c
|
104
|
+
src/linalg.c
|
105
|
+
src/normalize.c
|
106
|
+
src/rw.c
|
107
|
+
src/scs.c
|
108
|
+
src/scs_version.c
|
109
|
+
src/util.c
|
110
|
+
${LINSYS}/amatrix.c)
|
111
|
+
|
112
|
+
# Common header files
|
113
|
+
set(${PROJECT_NAME}_HDR
|
114
|
+
include/aa.h
|
115
|
+
include/cones.h
|
116
|
+
include/ctrlc.h
|
117
|
+
include/glbopts.h
|
118
|
+
include/linalg.h
|
119
|
+
include/linsys.h
|
120
|
+
include/normalize.h
|
121
|
+
include/rw.h
|
122
|
+
include/scs.h
|
123
|
+
include/scs_blas.h
|
124
|
+
include/util.h
|
125
|
+
${LINSYS}/amatrix.h)
|
126
|
+
|
127
|
+
# get all the c file in amd/external
|
128
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC
|
129
|
+
${EXTERNAL}/amd/*.c
|
130
|
+
)
|
131
|
+
|
132
|
+
# get all the h file in amd/external
|
133
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR
|
134
|
+
${EXTERNAL}/amd/*.h
|
135
|
+
)
|
136
|
+
|
137
|
+
# get all the c file in amd/external
|
138
|
+
file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR
|
139
|
+
${EXTERNAL}/qdldl/*.h
|
140
|
+
)
|
141
|
+
|
142
|
+
### Direct method
|
143
|
+
# Here we compile the direct method library
|
144
|
+
set(${PROJECT_NAME}_DIRECT ${PROJECT_NAME}dir)
|
145
|
+
add_library(${${PROJECT_NAME}_DIRECT}
|
146
|
+
${${PROJECT_NAME}_HDR}
|
147
|
+
${${PROJECT_NAME}_SRC}
|
148
|
+
${DIRSRC}/private.c
|
149
|
+
${DIRSRC}/private.h
|
150
|
+
${EXTERNAL}/qdldl/qdldl.c
|
151
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_SRC}
|
152
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_HDR}
|
153
|
+
${${PROJECT_NAME}_LDL_EXTERNAL_HDR})
|
154
|
+
|
155
|
+
target_include_directories(${${PROJECT_NAME}_DIRECT} PRIVATE
|
156
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${DIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
157
|
+
|
158
|
+
target_include_directories(${${PROJECT_NAME}_DIRECT} PUBLIC
|
159
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
160
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
161
|
+
|
162
|
+
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
163
|
+
target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE -DUSE_LAPACK)
|
164
|
+
|
165
|
+
# The library depends on math (m) blas and lapack
|
166
|
+
target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE
|
167
|
+
m
|
168
|
+
blas
|
169
|
+
lapack)
|
170
|
+
|
171
|
+
# Set some properties
|
172
|
+
set_target_properties(${${PROJECT_NAME}_DIRECT} PROPERTIES
|
173
|
+
VERSION ${scs_VERSION}
|
174
|
+
PUBLIC_HEADER "${${PROJECT_NAME}_HDR}")
|
175
|
+
|
176
|
+
add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
|
177
|
+
|
178
|
+
# Install the library
|
179
|
+
install(TARGETS ${${PROJECT_NAME}_DIRECT}
|
180
|
+
EXPORT ${PROJECT_NAME}
|
181
|
+
COMPONENT runtime
|
182
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
183
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
184
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
185
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
186
|
+
|
187
|
+
# Add the direct method to the set of the compiled targets
|
188
|
+
set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_DIRECT})
|
189
|
+
|
190
|
+
### Indirect method
|
191
|
+
# Here we compile the indirect method library
|
192
|
+
set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
|
193
|
+
add_library(${${PROJECT_NAME}_INDIRECT}
|
194
|
+
${${PROJECT_NAME}_HDR}
|
195
|
+
${${PROJECT_NAME}_SRC}
|
196
|
+
${INDIRSRC}/private.c
|
197
|
+
${${${PROJECT_NAME}_INDIRECT}_HDR}
|
198
|
+
${EXTERNAL}/qdldl/qdldl.c
|
199
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_SRC}
|
200
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_HDR}
|
201
|
+
${${PROJECT_NAME}_LDL_EXTERNAL_SRC}
|
202
|
+
)
|
203
|
+
|
204
|
+
|
205
|
+
target_include_directories(${${PROJECT_NAME}_INDIRECT} PRIVATE
|
206
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${INDIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
207
|
+
|
208
|
+
target_include_directories(${${PROJECT_NAME}_INDIRECT} PUBLIC
|
209
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
210
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
211
|
+
|
212
|
+
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
213
|
+
target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE -DUSE_LAPACK)
|
214
|
+
|
215
|
+
# The library depends on math (m) blas and lapack
|
216
|
+
target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC
|
217
|
+
m
|
218
|
+
blas
|
219
|
+
lapack)
|
220
|
+
|
221
|
+
# Set some properties
|
222
|
+
set_target_properties(${${PROJECT_NAME}_INDIRECT} PROPERTIES
|
223
|
+
VERSION ${scs_VERSION}
|
224
|
+
PUBLIC_HEADER "${${${PROJECT_NAME}_INDIRECT}_HDR}")
|
225
|
+
|
226
|
+
add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
|
227
|
+
|
228
|
+
# Install the library
|
229
|
+
install(TARGETS ${${PROJECT_NAME}_INDIRECT}
|
230
|
+
EXPORT ${PROJECT_NAME}
|
231
|
+
COMPONENT runtime
|
232
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
233
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
234
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
235
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
236
|
+
|
237
|
+
# Add the indirect method to the set of the compiled targets
|
238
|
+
set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_INDIRECT})
|
239
|
+
|
240
|
+
### Install the .cmake file.
|
241
|
+
# Thanks to thanks file it will be possible to link scs to consumer libraries
|
242
|
+
include(InstallBasicPackageFiles)
|
243
|
+
install_basic_package_files(${PROJECT_NAME}
|
244
|
+
NAMESPACE scs::
|
245
|
+
VERSION ${${PROJECT_NAME}_VERSION}
|
246
|
+
TARGETS_PROPERTY scs_TARGETS
|
247
|
+
COMPATIBILITY SameMajorVersion
|
248
|
+
VARS_PREFIX ${PROJECT_NAME}
|
249
|
+
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
250
|
+
|
251
|
+
### Add the tests
|
252
|
+
if(BUILD_TESTING)
|
253
|
+
add_executable(run_tests_direct test/run_tests.c)
|
254
|
+
target_link_libraries(run_tests_direct PRIVATE
|
255
|
+
scs::scsdir)
|
256
|
+
target_include_directories(run_tests_direct PRIVATE
|
257
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
258
|
+
|
259
|
+
add_test(NAME run_tests_direct
|
260
|
+
COMMAND run_tests_direct
|
261
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
262
|
+
|
263
|
+
add_executable(run_tests_indirect test/run_tests.c)
|
264
|
+
target_link_libraries(run_tests_indirect PRIVATE
|
265
|
+
scs::scsindir)
|
266
|
+
target_include_directories(run_tests_indirect PRIVATE
|
267
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
268
|
+
|
269
|
+
add_test(NAME run_tests_indirect
|
270
|
+
COMMAND run_tests_indirect
|
271
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
272
|
+
|
273
|
+
endif()
|
data/vendor/scs/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<h1 align="center" margin=0px>
|
2
|
+
<img src="https://github.com/cvxgrp/scs/blob/master/docs/scs_logo.png" alt="Intersection of a cone and a polyhedron" width="450">
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
![Build Status](https://github.com/cvxgrp/scs/actions/workflows/build.yml/badge.svg)
|
3
6
|
|
4
|
-
[![Build Status](https://travis-ci.org/cvxgrp/scs.svg?branch=master)](https://travis-ci.org/cvxgrp/scs)
|
5
|
-
[![Build status](https://ci.appveyor.com/api/projects/status/4542u6kom5293qpm/branch/master?svg=true)](https://ci.appveyor.com/project/bodono/scs/branch/master)
|
6
7
|
|
7
8
|
SCS (`splitting conic solver`) is a numerical optimization package for solving
|
8
9
|
large-scale convex cone problems, based on our paper [Conic Optimization via
|
@@ -18,10 +19,11 @@ programs via the linked
|
|
18
19
|
interfaces. It can also be called as a solver from convex optimization
|
19
20
|
toolboxes [CVX](http://cvxr.com/cvx/) (3.0 or later),
|
20
21
|
[CVXPY](https://github.com/cvxgrp/cvxpy),
|
21
|
-
[Convex.jl](https://github.com/
|
22
|
+
[Convex.jl](https://github.com/jump-dev/Convex.jl),
|
23
|
+
[JuMP.jl](https://github.com/jump-dev/JuMP.jl), and
|
22
24
|
[Yalmip](https://github.com/johanlofberg/YALMIP).
|
23
25
|
|
24
|
-
The current version is `2.1.
|
26
|
+
The current version is `2.1.4`. If you wish to cite SCS, please use the
|
25
27
|
following:
|
26
28
|
```
|
27
29
|
@article{ocpb:16,
|
@@ -37,7 +39,7 @@ following:
|
|
37
39
|
}
|
38
40
|
@misc{scs,
|
39
41
|
author = {B. O'Donoghue and E. Chu and N. Parikh and S. Boyd},
|
40
|
-
title = {{SCS}: Splitting Conic Solver, version 2.1.
|
42
|
+
title = {{SCS}: Splitting Conic Solver, version 2.1.4},
|
41
43
|
howpublished = {\url{https://github.com/cvxgrp/scs}},
|
42
44
|
month = nov,
|
43
45
|
year = 2019
|
@@ -137,7 +139,7 @@ gpu.
|
|
137
139
|
|
138
140
|
The direct solver uses external numerical linear algebra packages:
|
139
141
|
* [QDLDL](https://github.com/oxfordcontrol/qdldl)
|
140
|
-
* [AMD](
|
142
|
+
* [AMD](https://github.com/DrTimothyAldenDavis/SuiteSparse).
|
141
143
|
|
142
144
|
### Using SCS in C
|
143
145
|
Typing `make` at the command line will compile the code and create SCS libraries
|
@@ -153,7 +155,7 @@ If `make` completes successfully, it will produce two static library files,
|
|
153
155
|
`libscsindir.ext` (where `.ext` extension is platform dependent) in the same
|
154
156
|
folder. It will also produce two demo binaries in the `out` folder named
|
155
157
|
`demo_socp_direct`, and `demo_socp_indirect`. If you have a GPU and have CUDA
|
156
|
-
installed, you can also
|
158
|
+
installed, you can also execute `make gpu` to compile SCS to run on the GPU
|
157
159
|
which will create additional libraries and demo binaries in the `out` folder
|
158
160
|
corresponding to the gpu version. Note that the GPU version requires 32 bit
|
159
161
|
ints, which can be enforced by compiling with `DLONG=0`.
|
@@ -220,3 +222,49 @@ two structs in `include/linsys.h` and plug it in.
|
|
220
222
|
If you get an error like `cannot find -lblas` or `cannot find -llapack`, then
|
221
223
|
you need to install blas and lapack and / or update your environment variables
|
222
224
|
to point to the install locations.
|
225
|
+
|
226
|
+
### Using SCS with cmake
|
227
|
+
|
228
|
+
Thanks to [`CMake`](http://cmake.org) buildsystem, scs can be easily compiled
|
229
|
+
and linked by other `CMake` projects. To use the `cmake` buld system please run
|
230
|
+
the following commands:
|
231
|
+
```
|
232
|
+
cd scs
|
233
|
+
mkdir build
|
234
|
+
cd build
|
235
|
+
cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> ../
|
236
|
+
make
|
237
|
+
make install
|
238
|
+
```
|
239
|
+
|
240
|
+
You may also want to compile the tests. In this case when you configure the project,
|
241
|
+
please call the following command
|
242
|
+
```
|
243
|
+
cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> -DBUILD_TESTING=ON ../
|
244
|
+
make
|
245
|
+
ctest
|
246
|
+
```
|
247
|
+
|
248
|
+
By default the build-system will compile the library as `shared`. If you want to
|
249
|
+
compile it as `static`, please call the following command when you configure the
|
250
|
+
project
|
251
|
+
```
|
252
|
+
cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> -BUILD_SHARED_LIBS=OFF ../
|
253
|
+
make
|
254
|
+
```
|
255
|
+
|
256
|
+
The `cmake` build-system exports two CMake targets called `scs::scsdir` and
|
257
|
+
`scs::scsindir` which can be imported using the `find_package` CMake command
|
258
|
+
and used by calling `target_link_libraries` as in the following example:
|
259
|
+
```cmake
|
260
|
+
cmake_minimum_required(VERSION 3.0)
|
261
|
+
project(myproject)
|
262
|
+
find_package(scs REQUIRED)
|
263
|
+
add_executable(example example.cpp)
|
264
|
+
|
265
|
+
# To use the direct method
|
266
|
+
target_link_libraries(example scs::scsdir)
|
267
|
+
|
268
|
+
# To use the indirect method
|
269
|
+
target_link_libraries(example scs::scsindir)
|
270
|
+
```
|
@@ -13,7 +13,7 @@ extern "C" {
|
|
13
13
|
|
14
14
|
/* SCS VERSION NUMBER ---------------------------------------------- */
|
15
15
|
#define SCS_VERSION \
|
16
|
-
("2.1.
|
16
|
+
("2.1.4") /* string literals automatically null-terminated */
|
17
17
|
|
18
18
|
/* SCS returns one of the following integers: */
|
19
19
|
#define SCS_INFEASIBLE_INACCURATE (-7)
|
data/vendor/scs/linsys/amatrix.o
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/scs/linsys/gpu/gpu.c
CHANGED
@@ -1,33 +1,72 @@
|
|
1
1
|
#include "gpu.h"
|
2
2
|
|
3
|
-
void SCS(_accum_by_atrans_gpu)(const ScsGpuMatrix *Ag, const
|
4
|
-
|
3
|
+
void SCS(_accum_by_atrans_gpu)(const ScsGpuMatrix *Ag, const cusparseDnVecDescr_t x,
|
4
|
+
cusparseDnVecDescr_t y, cusparseHandle_t cusparse_handle,
|
5
|
+
size_t *buffer_size, void **buffer) {
|
5
6
|
/* y += A'*x
|
6
7
|
x and y MUST be on GPU already
|
7
8
|
*/
|
8
9
|
const scs_float onef = 1.0;
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
size_t new_buffer_size = 0;
|
11
|
+
|
12
|
+
CUSPARSE_GEN(SpMV_bufferSize)
|
13
|
+
(cusparse_handle, CUSPARSE_OPERATION_NON_TRANSPOSE,
|
14
|
+
&onef, Ag->descr, x, &onef, y,
|
15
|
+
SCS_CUDA_FLOAT, SCS_CSRMV_ALG,
|
16
|
+
&new_buffer_size);
|
17
|
+
|
18
|
+
if (new_buffer_size > *buffer_size) {
|
19
|
+
if (*buffer != SCS_NULL) {
|
20
|
+
cudaFree(*buffer);
|
21
|
+
}
|
22
|
+
cudaMalloc(buffer, *buffer_size);
|
23
|
+
*buffer_size = new_buffer_size;
|
24
|
+
}
|
25
|
+
|
26
|
+
CUSPARSE_GEN(SpMV)
|
27
|
+
(cusparse_handle, CUSPARSE_OPERATION_NON_TRANSPOSE,
|
28
|
+
&onef, Ag->descr, x, &onef, y,
|
29
|
+
SCS_CUDA_FLOAT, SCS_CSRMV_ALG,
|
30
|
+
buffer);
|
12
31
|
}
|
13
32
|
|
14
|
-
void SCS(_accum_by_a_gpu)(const ScsGpuMatrix *Ag, const
|
15
|
-
|
33
|
+
void SCS(_accum_by_a_gpu)(const ScsGpuMatrix *Ag, const cusparseDnVecDescr_t x,
|
34
|
+
cusparseDnVecDescr_t y, cusparseHandle_t cusparse_handle,
|
35
|
+
size_t *buffer_size, void **buffer) {
|
16
36
|
/* y += A*x
|
17
37
|
x and y MUST be on GPU already
|
18
38
|
*/
|
19
39
|
const scs_float onef = 1.0;
|
40
|
+
size_t new_buffer_size = 0;
|
41
|
+
|
20
42
|
/* The A matrix idx pointers must be ORDERED */
|
21
|
-
|
22
|
-
(
|
23
|
-
|
43
|
+
|
44
|
+
CUSPARSE_GEN(SpMV_bufferSize)
|
45
|
+
(cusparse_handle, CUSPARSE_OPERATION_TRANSPOSE,
|
46
|
+
&onef, Ag->descr, x, &onef, y,
|
47
|
+
SCS_CUDA_FLOAT, SCS_CSRMV_ALG,
|
48
|
+
&new_buffer_size);
|
49
|
+
|
50
|
+
if (new_buffer_size > *buffer_size) {
|
51
|
+
if (*buffer != SCS_NULL) {
|
52
|
+
cudaFree(*buffer);
|
53
|
+
}
|
54
|
+
cudaMalloc(buffer, *buffer_size);
|
55
|
+
*buffer_size = new_buffer_size;
|
56
|
+
}
|
57
|
+
|
58
|
+
CUSPARSE_GEN(SpMV)
|
59
|
+
(cusparse_handle, CUSPARSE_OPERATION_TRANSPOSE,
|
60
|
+
&onef, Ag->descr, x, &onef, y,
|
61
|
+
SCS_CUDA_FLOAT, SCS_CSRMV_ALG,
|
62
|
+
buffer);
|
24
63
|
}
|
25
64
|
|
26
65
|
void SCS(free_gpu_matrix)(ScsGpuMatrix *A) {
|
27
66
|
cudaFree(A->x);
|
28
67
|
cudaFree(A->i);
|
29
68
|
cudaFree(A->p);
|
30
|
-
|
69
|
+
cusparseDestroySpMat(A->descr);
|
31
70
|
}
|
32
71
|
|
33
72
|
void SCS(normalize_a)(ScsMatrix *A, const ScsSettings *stgs, const ScsCone *k,
|
data/vendor/scs/linsys/gpu/gpu.h
CHANGED
@@ -34,6 +34,7 @@ extern "C" {
|
|
34
34
|
#define CUBLAS(x) cublasS##x
|
35
35
|
#define CUSPARSE(x) cusparseS##x
|
36
36
|
#endif
|
37
|
+
#define CUSPARSE_GEN(x) cusparse##x
|
37
38
|
#else
|
38
39
|
#ifndef SFLOAT
|
39
40
|
#define CUBLAS(x) \
|
@@ -50,8 +51,26 @@ extern "C" {
|
|
50
51
|
CUDA_CHECK_ERR; \
|
51
52
|
cusparseS##x
|
52
53
|
#endif
|
54
|
+
#define CUSPARSE_GEN(x) \
|
55
|
+
CUDA_CHECK_ERR; \
|
56
|
+
cusparse##x
|
53
57
|
#endif
|
54
58
|
|
59
|
+
#ifndef SFLOAT
|
60
|
+
#define SCS_CUDA_FLOAT CUDA_R_64F
|
61
|
+
#else
|
62
|
+
#define SCS_CUDA_FLOAT CUDA_R_32F
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#ifndef DLONG
|
66
|
+
#define SCS_CUSPARSE_INDEX CUSPARSE_INDEX_32I
|
67
|
+
#else
|
68
|
+
#define SCS_CUSPARSE_INDEX CUSPARSE_INDEX_64I
|
69
|
+
#endif
|
70
|
+
|
71
|
+
#define SCS_CSRMV_ALG CUSPARSE_CSRMV_ALG1
|
72
|
+
#define SCS_CSR2CSC_ALG CUSPARSE_CSR2CSC_ALG1
|
73
|
+
|
55
74
|
/*
|
56
75
|
CUDA matrix routines only for CSR, not CSC matrices:
|
57
76
|
CSC CSR GPU Mult
|
@@ -68,14 +87,16 @@ typedef struct SCS_GPU_A_DATA_MATRIX {
|
|
68
87
|
scs_int m, n; /* m rows, n cols */
|
69
88
|
scs_int Annz; /* num non-zeros in A matrix */
|
70
89
|
/* CUDA */
|
71
|
-
|
90
|
+
cusparseSpMatDescr_t descr;
|
72
91
|
} ScsGpuMatrix;
|
73
92
|
|
74
|
-
void SCS(_accum_by_atrans_gpu)(const ScsGpuMatrix *A, const
|
75
|
-
|
93
|
+
void SCS(_accum_by_atrans_gpu)(const ScsGpuMatrix *A, const cusparseDnVecDescr_t x,
|
94
|
+
cusparseDnVecDescr_t y, cusparseHandle_t cusparse_handle,
|
95
|
+
size_t *buffer_size, void **buffer);
|
76
96
|
|
77
|
-
void SCS(_accum_by_a_gpu)(const ScsGpuMatrix *A, const
|
78
|
-
|
97
|
+
void SCS(_accum_by_a_gpu)(const ScsGpuMatrix *A, const cusparseDnVecDescr_t x,
|
98
|
+
cusparseDnVecDescr_t y, cusparseHandle_t cusparse_handle,
|
99
|
+
size_t *buffer_size, void **buffer);
|
79
100
|
|
80
101
|
void SCS(free_gpu_matrix)(ScsGpuMatrix *A);
|
81
102
|
|
@@ -10,7 +10,14 @@ void SCS(accum_by_atrans)(const ScsMatrix *A, ScsLinSysWork *p,
|
|
10
10
|
scs_float *v_n = p->r;
|
11
11
|
cudaMemcpy(v_m, x, A->m * sizeof(scs_float), cudaMemcpyHostToDevice);
|
12
12
|
cudaMemcpy(v_n, y, A->n * sizeof(scs_float), cudaMemcpyHostToDevice);
|
13
|
-
|
13
|
+
|
14
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) v_m);
|
15
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) v_n);
|
16
|
+
SCS(_accum_by_atrans_gpu)(
|
17
|
+
p->Ag, p->dn_vec_m, p->dn_vec_n, p->cusparse_handle,
|
18
|
+
&p->buffer_size, &p->buffer
|
19
|
+
);
|
20
|
+
|
14
21
|
cudaMemcpy(y, v_n, A->n * sizeof(scs_float), cudaMemcpyDeviceToHost);
|
15
22
|
}
|
16
23
|
|
@@ -21,11 +28,21 @@ void SCS(accum_by_a)(const ScsMatrix *A, ScsLinSysWork *p, const scs_float *x,
|
|
21
28
|
scs_float *v_n = p->r;
|
22
29
|
cudaMemcpy(v_n, x, A->n * sizeof(scs_float), cudaMemcpyHostToDevice);
|
23
30
|
cudaMemcpy(v_m, y, A->m * sizeof(scs_float), cudaMemcpyHostToDevice);
|
31
|
+
|
32
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) v_m);
|
33
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) v_n);
|
24
34
|
#if GPU_TRANSPOSE_MAT > 0
|
25
|
-
SCS(_accum_by_atrans_gpu)(
|
35
|
+
SCS(_accum_by_atrans_gpu)(
|
36
|
+
p->Agt, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
37
|
+
&p->buffer_size, &p->buffer
|
38
|
+
);
|
26
39
|
#else
|
27
|
-
SCS(_accum_by_a_gpu)(
|
40
|
+
SCS(_accum_by_a_gpu)(
|
41
|
+
p->Ag, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
42
|
+
&p->buffer_size, &p->buffer
|
43
|
+
);
|
28
44
|
#endif
|
45
|
+
|
29
46
|
cudaMemcpy(y, v_m, A->m * sizeof(scs_float), cudaMemcpyDeviceToHost);
|
30
47
|
}
|
31
48
|
|
@@ -64,6 +81,11 @@ void SCS(free_lin_sys_work)(ScsLinSysWork *p) {
|
|
64
81
|
SCS(free_gpu_matrix)(p->Agt);
|
65
82
|
scs_free(p->Agt);
|
66
83
|
}
|
84
|
+
if (p->buffer != SCS_NULL) {
|
85
|
+
cudaFree(p->buffer);
|
86
|
+
}
|
87
|
+
cusparseDestroyDnVec(p->dn_vec_m);
|
88
|
+
cusparseDestroyDnVec(p->dn_vec_n);
|
67
89
|
cusparseDestroy(p->cusparse_handle);
|
68
90
|
cublasDestroy(p->cublas_handle);
|
69
91
|
/* Don't reset because it interferes with other GPU programs. */
|
@@ -78,9 +100,30 @@ static void mat_vec(const ScsGpuMatrix *A, const ScsSettings *s,
|
|
78
100
|
/* x and y MUST already be loaded to GPU */
|
79
101
|
scs_float *tmp_m = p->tmp_m; /* temp memory */
|
80
102
|
cudaMemset(tmp_m, 0, A->m * sizeof(scs_float));
|
81
|
-
|
103
|
+
|
104
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) tmp_m);
|
105
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) x);
|
106
|
+
#if GPU_TRANSPOSE_MAT > 0
|
107
|
+
SCS(_accum_by_atrans_gpu)(
|
108
|
+
p->Agt, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
109
|
+
&p->buffer_size, &p->buffer
|
110
|
+
);
|
111
|
+
#else
|
112
|
+
SCS(_accum_by_a_gpu)(
|
113
|
+
A, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
114
|
+
&p->buffer_size, &p->buffer
|
115
|
+
);
|
116
|
+
#endif
|
117
|
+
|
82
118
|
cudaMemset(y, 0, A->n * sizeof(scs_float));
|
83
|
-
|
119
|
+
|
120
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) tmp_m);
|
121
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) y);
|
122
|
+
SCS(_accum_by_atrans_gpu)(
|
123
|
+
A, p->dn_vec_m, p->dn_vec_n, p->cusparse_handle,
|
124
|
+
&p->buffer_size, &p->buffer
|
125
|
+
);
|
126
|
+
|
84
127
|
CUBLAS(axpy)(p->cublas_handle, A->n, &(s->rho_x), x, 1, y, 1);
|
85
128
|
}
|
86
129
|
|
@@ -112,6 +155,14 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A,
|
|
112
155
|
cudaError_t err;
|
113
156
|
ScsLinSysWork *p = (ScsLinSysWork *)scs_calloc(1, sizeof(ScsLinSysWork));
|
114
157
|
ScsGpuMatrix *Ag = (ScsGpuMatrix *)scs_malloc(sizeof(ScsGpuMatrix));
|
158
|
+
|
159
|
+
/* Used for initializing dense vectors */
|
160
|
+
scs_float *tmp_null_n = SCS_NULL;
|
161
|
+
scs_float *tmp_null_m = SCS_NULL;
|
162
|
+
|
163
|
+
#if GPU_TRANSPOSE_MAT > 0
|
164
|
+
size_t new_buffer_size = 0;
|
165
|
+
#endif
|
115
166
|
|
116
167
|
p->cublas_handle = 0;
|
117
168
|
p->cusparse_handle = 0;
|
@@ -119,6 +170,9 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A,
|
|
119
170
|
p->total_solve_time = 0;
|
120
171
|
p->tot_cg_its = 0;
|
121
172
|
|
173
|
+
p->buffer_size = 0;
|
174
|
+
p->buffer = SCS_NULL;
|
175
|
+
|
122
176
|
/* Get handle to the CUBLAS context */
|
123
177
|
cublasCreate(&p->cublas_handle);
|
124
178
|
|
@@ -130,9 +184,7 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A,
|
|
130
184
|
Ag->Annz = A->p[A->n];
|
131
185
|
Ag->descr = 0;
|
132
186
|
/* Matrix description */
|
133
|
-
|
134
|
-
cusparseSetMatType(Ag->descr, CUSPARSE_MATRIX_TYPE_GENERAL);
|
135
|
-
cusparseSetMatIndexBase(Ag->descr, CUSPARSE_INDEX_BASE_ZERO);
|
187
|
+
|
136
188
|
p->Ag = Ag;
|
137
189
|
p->Agt = SCS_NULL;
|
138
190
|
|
@@ -155,6 +207,18 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A,
|
|
155
207
|
cudaMemcpy(Ag->x, A->x, (A->p[A->n]) * sizeof(scs_float),
|
156
208
|
cudaMemcpyHostToDevice);
|
157
209
|
|
210
|
+
cusparseCreateCsr
|
211
|
+
(&Ag->descr, Ag->n, Ag->m, Ag->Annz, Ag->p, Ag->i, Ag->x,
|
212
|
+
SCS_CUSPARSE_INDEX, SCS_CUSPARSE_INDEX,
|
213
|
+
CUSPARSE_INDEX_BASE_ZERO, SCS_CUDA_FLOAT);
|
214
|
+
|
215
|
+
cudaMalloc((void **)&tmp_null_n, A->n * sizeof(scs_float));
|
216
|
+
cudaMalloc((void **)&tmp_null_m, A->m * sizeof(scs_float));
|
217
|
+
cusparseCreateDnVec(&p->dn_vec_n, Ag->n, tmp_null_n, SCS_CUDA_FLOAT);
|
218
|
+
cusparseCreateDnVec(&p->dn_vec_m, Ag->m, tmp_null_m, SCS_CUDA_FLOAT);
|
219
|
+
cudaFree(tmp_null_n);
|
220
|
+
cudaFree(tmp_null_m);
|
221
|
+
|
158
222
|
get_preconditioner(A, stgs, p);
|
159
223
|
|
160
224
|
#if GPU_TRANSPOSE_MAT > 0
|
@@ -164,18 +228,41 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A,
|
|
164
228
|
p->Agt->Annz = A->p[A->n];
|
165
229
|
p->Agt->descr = 0;
|
166
230
|
/* Matrix description */
|
167
|
-
cusparseCreateMatDescr(&p->Agt->descr);
|
168
|
-
cusparseSetMatType(p->Agt->descr, CUSPARSE_MATRIX_TYPE_GENERAL);
|
169
|
-
cusparseSetMatIndexBase(p->Agt->descr, CUSPARSE_INDEX_BASE_ZERO);
|
170
231
|
|
171
232
|
cudaMalloc((void **)&p->Agt->i, (A->p[A->n]) * sizeof(scs_int));
|
172
233
|
cudaMalloc((void **)&p->Agt->p, (A->m + 1) * sizeof(scs_int));
|
173
234
|
cudaMalloc((void **)&p->Agt->x, (A->p[A->n]) * sizeof(scs_float));
|
174
235
|
/* transpose Ag into Agt for faster multiplies */
|
175
236
|
/* TODO: memory intensive, could perform transpose in CPU and copy to GPU */
|
176
|
-
|
177
|
-
(p->cusparse_handle, A->n, A->m, A->p[A->n],
|
178
|
-
|
237
|
+
cusparseCsr2cscEx2_bufferSize
|
238
|
+
(p->cusparse_handle, A->n, A->m, A->p[A->n],
|
239
|
+
Ag->x, Ag->p, Ag->i,
|
240
|
+
p->Agt->x, p->Agt->p, p->Agt->i,
|
241
|
+
SCS_CUDA_FLOAT, CUSPARSE_ACTION_NUMERIC,
|
242
|
+
CUSPARSE_INDEX_BASE_ZERO, SCS_CSR2CSC_ALG,
|
243
|
+
&new_buffer_size);
|
244
|
+
|
245
|
+
if (new_buffer_size > p->buffer_size) {
|
246
|
+
if (p->buffer != SCS_NULL) {
|
247
|
+
cudaFree(p->buffer);
|
248
|
+
}
|
249
|
+
cudaMalloc(&p->buffer, new_buffer_size);
|
250
|
+
p->buffer_size = new_buffer_size;
|
251
|
+
}
|
252
|
+
|
253
|
+
cusparseCsr2cscEx2
|
254
|
+
(p->cusparse_handle, A->n, A->m, A->p[A->n],
|
255
|
+
Ag->x, Ag->p, Ag->i,
|
256
|
+
p->Agt->x, p->Agt->p, p->Agt->i,
|
257
|
+
SCS_CUDA_FLOAT, CUSPARSE_ACTION_NUMERIC,
|
258
|
+
CUSPARSE_INDEX_BASE_ZERO, SCS_CSR2CSC_ALG,
|
259
|
+
p->buffer);
|
260
|
+
|
261
|
+
cusparseCreateCsr
|
262
|
+
(&p->Agt->descr, p->Agt->n, p->Agt->m, p->Agt->Annz,
|
263
|
+
p->Agt->p, p->Agt->i, p->Agt->x,
|
264
|
+
SCS_CUSPARSE_INDEX, SCS_CUSPARSE_INDEX,
|
265
|
+
CUSPARSE_INDEX_BASE_ZERO, SCS_CUDA_FLOAT);
|
179
266
|
#endif
|
180
267
|
|
181
268
|
err = cudaGetLastError();
|
@@ -285,11 +372,32 @@ scs_int SCS(solve_lin_sys)(const ScsMatrix *A, const ScsSettings *stgs,
|
|
285
372
|
SCS(tic)(&linsys_timer);
|
286
373
|
/* all on GPU */
|
287
374
|
cudaMemcpy(bg, b, (Ag->n + Ag->m) * sizeof(scs_float), cudaMemcpyHostToDevice);
|
288
|
-
|
375
|
+
|
376
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) &(bg[Ag->n]));
|
377
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) bg);
|
378
|
+
SCS(_accum_by_atrans_gpu)(
|
379
|
+
Ag, p->dn_vec_m, p->dn_vec_n, p->cusparse_handle,
|
380
|
+
&p->buffer_size, &p->buffer
|
381
|
+
);
|
382
|
+
|
289
383
|
/* solves (I+A'A)x = b, s warm start, solution stored in b */
|
290
384
|
cg_its = pcg(p->Ag, stgs, p, s, bg, Ag->n, MAX(cg_tol, CG_BEST_TOL));
|
291
385
|
CUBLAS(scal)(p->cublas_handle, Ag->m, &neg_onef, &(bg[Ag->n]), 1);
|
292
|
-
|
386
|
+
|
387
|
+
cusparseDnVecSetValues(p->dn_vec_m, (void *) &(bg[Ag->n]));
|
388
|
+
cusparseDnVecSetValues(p->dn_vec_n, (void *) bg);
|
389
|
+
#if GPU_TRANSPOSE_MAT > 0
|
390
|
+
SCS(_accum_by_atrans_gpu)(
|
391
|
+
p->Agt, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
392
|
+
&p->buffer_size, &p->buffer
|
393
|
+
);
|
394
|
+
#else
|
395
|
+
SCS(_accum_by_a_gpu)(
|
396
|
+
Ag, p->dn_vec_n, p->dn_vec_m, p->cusparse_handle,
|
397
|
+
&p->buffer_size, &p->buffer
|
398
|
+
);
|
399
|
+
#endif
|
400
|
+
|
293
401
|
cudaMemcpy(b, bg, (Ag->n + Ag->m) * sizeof(scs_float), cudaMemcpyDeviceToHost);
|
294
402
|
|
295
403
|
if (iter >= 0) {
|
@@ -28,6 +28,11 @@ struct SCS_LIN_SYS_WORK {
|
|
28
28
|
/* CUDA */
|
29
29
|
cublasHandle_t cublas_handle;
|
30
30
|
cusparseHandle_t cusparse_handle;
|
31
|
+
/* CUSPARSE */
|
32
|
+
size_t buffer_size;
|
33
|
+
void *buffer;
|
34
|
+
cusparseDnVecDescr_t dn_vec_m; /* Dense vector of length m */
|
35
|
+
cusparseDnVecDescr_t dn_vec_n; /* Dense vector of length n */
|
31
36
|
};
|
32
37
|
|
33
38
|
#ifdef __cplusplus
|
data/vendor/scs/src/aa.o
CHANGED
Binary file
|
data/vendor/scs/src/cones.o
CHANGED
Binary file
|
data/vendor/scs/src/ctrlc.o
CHANGED
Binary file
|
data/vendor/scs/src/linalg.o
CHANGED
Binary file
|
data/vendor/scs/src/normalize.o
CHANGED
Binary file
|
data/vendor/scs/src/rw.c
CHANGED
@@ -37,7 +37,7 @@ static ScsCone *read_scs_cone(FILE *fin) {
|
|
37
37
|
fread(&(k->ep), sizeof(scs_int), 1, fin);
|
38
38
|
fread(&(k->ed), sizeof(scs_int), 1, fin);
|
39
39
|
fread(&(k->psize), sizeof(scs_int), 1, fin);
|
40
|
-
k->p = scs_calloc(k->psize, sizeof(
|
40
|
+
k->p = scs_calloc(k->psize, sizeof(scs_float));
|
41
41
|
fread(k->p, sizeof(scs_float), k->psize, fin);
|
42
42
|
return k;
|
43
43
|
}
|
data/vendor/scs/src/rw.o
CHANGED
Binary file
|
data/vendor/scs/src/scs.o
CHANGED
Binary file
|
Binary file
|
data/vendor/scs/src/util.o
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,73 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: numo-narray
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description:
|
70
|
-
email: andrew@chartkick.com
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: andrew@ankane.org
|
71
15
|
executables: []
|
72
16
|
extensions:
|
73
17
|
- ext/scs/extconf.rb
|
@@ -81,6 +25,7 @@ files:
|
|
81
25
|
- lib/scs/ffi.rb
|
82
26
|
- lib/scs/solver.rb
|
83
27
|
- lib/scs/version.rb
|
28
|
+
- vendor/scs/CMakeLists.txt
|
84
29
|
- vendor/scs/LICENSE.txt
|
85
30
|
- vendor/scs/Makefile
|
86
31
|
- vendor/scs/README.md
|
@@ -181,7 +126,7 @@ homepage: https://github.com/ankane/scs
|
|
181
126
|
licenses:
|
182
127
|
- MIT
|
183
128
|
metadata: {}
|
184
|
-
post_install_message:
|
129
|
+
post_install_message:
|
185
130
|
rdoc_options: []
|
186
131
|
require_paths:
|
187
132
|
- lib
|
@@ -196,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
141
|
- !ruby/object:Gem::Version
|
197
142
|
version: '0'
|
198
143
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
200
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.22
|
145
|
+
signing_key:
|
201
146
|
specification_version: 4
|
202
147
|
summary: SCS - the splitting conic solver - for Ruby
|
203
148
|
test_files: []
|