Skip to content

Commit d442555

Browse files
committed
Add build instructions for multiprecision backend
1 parent 380ffd1 commit d442555

File tree

3 files changed

+92
-49
lines changed

3 files changed

+92
-49
lines changed

docs/installation/linux.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ mumps_url: https://mumps-solver.org
1111

1212
SDPA for Python (`sdpa-python`) is a wrapper on top of the SDPA package. We will go over building SDPA first, followed by SDPA for Python.
1313

14-
## Obtaining and building SDPA
14+
## Obtaining and building the backend
1515

16-
The primary software package containing SDPA is named simply `sdpa` and the source can be obtained from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}.
16+
As a backend, we can use either the regular SDPA package, or the SDPA Multiprecision variant. SDPA Multiprecision is a fork of SDPA-GMP.
1717

18-
Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
18+
If you choose to use **SDPA Multiprecision**, please follow the instructions in the README of its [GitHub repository](https://github.com/sdpa-python/sdpa-multiprecision), and then skip directly to the [next section](#obtaining-and-installing-sdpa-python-wrapper) on building the Python wrapper.
19+
20+
If you choose to use the **regular SDPA package**, please download it from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}. Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
1921

2022
Once downloaded, unzip it using:
2123

@@ -88,22 +90,42 @@ This should complete a test run the `sdpa` binary using one of the provided exam
8890

8991
## Obtaining and installing SDPA Python wrapper
9092

91-
Once you have built and done a test run on `sdpa`, you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
93+
Once you have built and done a test run on `sdpa` (or `sdpa_gmp` if using the Multiprecision backend), you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
9294

9395
We need SPOOLES for building `sdpa-python`.
9496

95-
### Obtaining SPOOLES headers
97+
### Obtaining and building the SPOOLES library and headers
98+
99+
If you are using the **SDPA Multiprecision** backend, it contains SPOOLES and will build it as part of the buildsystem. In that case, you can skip directly to the next subsection.
96100

97-
On Linux, `libspooles` is provided by your distribution (as `libspooles` or `libspooles-dev`) and installed system wide (so you need not provide the library path for it in `setupcfg.py`). The best way to check if you have it is to compile a very basic Hello World program with `g++ hello.c -lspooles`. If it throws an error, you can refer to instructions for installing them for your distribution.
101+
If you are using the regular SDPA backend, you will have to download as well as build the SPOOLES library.
98102

99-
You will however, still need to download it because SPOOLES headers are imported by `sdpa-python` (and you will need to provide the include path for it in `setupcfg.py`). It can be obtained from the official [SPOOLES webpage](http://www.netlib.org/linalg/spooles/spooles.2.2.html) or the [Debian package sources](http://ftp.de.debian.org/debian/pool/main/s/spooles/spooles_2.2.orig.tar.gz).
103+
SPOOLES can be obtained from the official [SPOOLES webpage](http://www.netlib.org/linalg/spooles/spooles.2.2.html) or the [Debian package sources](http://ftp.de.debian.org/debian/pool/main/s/spooles/spooles_2.2.orig.tar.gz).
100104

101105
```bash
102-
wget http://www.netlib.org/linalg/spooles/spooles.2.2.tgz
106+
wget http://ftp.de.debian.org/debian/pool/main/s/spooles/spooles_2.2.orig.tar.gz
103107
mkdir spooles
104-
tar -zxf spooles.2.2.tgz -C spooles # (OR spooles_2.2.orig.tar.gz if from Debian Sources)
108+
tar -zxf spooles_2.2.orig.tar.gz -C spooles
105109
```
106110

111+
Open `Make.inc` (located in the root of the extracted `spooles` folder) in a text editor and remove the line `CC = /usr/lang-4.0/bin/cc`. This will let it use the default compiler on your system (otherwise it will throw an error).
112+
113+
To build it, cd to the directory where you extracted SPOOLES and do `make lib`.
114+
115+
```bash
116+
cd spooles
117+
make lib
118+
```
119+
120+
By default, the `Makefile` will load the code into `spooles.a` and this may cause the library to be not locatable (despite providing the search path in `setupcfg.py`). To avoid this issue, please rename this file to `libspooles.a`.
121+
122+
```bash
123+
mv spooles.a libspooles.a
124+
```
125+
126+
{: .warning }
127+
SPOOLES may clash with GLIBC on some distributions. If that happens when you run `python setup.py install` later, you will need to rebuild SPOOLES with the `-fPIC` flag. This flag can be added to `CFLAGS` in the same `Make.inc` file.
128+
107129
### Obtain and prepare `sdpa-python` for build
108130

109131
You can obtain it by
@@ -120,25 +142,33 @@ cd sdpa-python
120142

121143
There is a file `setupcfg.py` in the root of `sdpa-python`. We need to edit it and provide
122144

123-
1. The link to the `make.inc` in the `sdpa` folder (so it can find `libsdpa.a`). Assuming you extracted it in your home folder:
145+
1. The location of SDPA headers and static library (i.e. `libsdpa.a` or `libsdpa_gmp.a`):
146+
147+
```python
148+
SDPA_DIR = '/path/to/sdpa_package_name'
149+
```
150+
151+
2. Only if using the **regular SDPA** backend, the location of SPOOLES library and headers (for Multiprecision backend these variables need not be changed):
124152

125153
```python
126-
SDPA_MAKEINC = '/home/yourusername/sdpa-{{page.sdpa_latest_version}}/etc/make.inc'
154+
SPOOLES_DIR = '/path/to/spooles/'
155+
SPOOLES_INCLUDE = SPOOLES_DIR
127156
```
128157

129-
2. The location of SPOOLES library and headers. Assuming you extracted it in your home folder:
158+
3. Only if using the **regular SDPA** backend, the names of the BLAS/LAPACK implementation(s) that you intend to use. Please use the same one as you did while building the SDPA (backend) package. Assuming you used OpenBLAS:
130159

131160
```python
132-
SPOOLES_INCLUDE = '/home/yourusername/spooles/'
161+
BLAS_LAPACK_LIBS = ['openblas']
133162
```
134163

135-
3. Names of BLAS/LAPACK if you did not use the reference BLAS. Please use the same BLAS/LAPACK that you used while building `sdpa`. Assuming you used OpenBLAS:
164+
4. Only if using the **SDPA Multiprecision** backend, the location of GMP library and headers:
136165

137166
```python
138-
LAPACK_NAME = 'openblas'
139-
BLAS_NAME = 'openblas'
167+
GMP_DIR = '/path/to/gmp-version'
140168
```
141169

170+
5. Lastly, if you are using the **SDPA Multiprecision** backend, please set `USEGMP = True` in this file.
171+
142172
### Install `sdpa-python` Package
143173

144174
Finally, build and install `sdpa-python` package. While still in the `sdpa-python` directory, do:

docs/installation/macos.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ mumps_url: https://mumps-solver.org
1111

1212
SDPA for Python (`sdpa-python`) is a wrapper on top of the SDPA package. We will go over building SDPA first, followed by SDPA for Python.
1313

14-
## Obtaining and building SDPA
14+
## Obtaining and building the backend
1515

16-
The primary software package containing SDPA is named simply `sdpa` and the source can be obtained from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}.
16+
As a backend, we can use either the regular SDPA package, or the SDPA Multiprecision variant. SDPA Multiprecision is a fork of SDPA-GMP.
1717

18-
Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
18+
If you choose to use **SDPA Multiprecision**, please follow the instructions in the README of its [GitHub repository](https://github.com/sdpa-python/sdpa-multiprecision), and then skip directly to the [next section](#obtaining-and-installing-sdpa-python-wrapper) on building the Python wrapper.
19+
20+
If you choose to use the **regular SDPA package**, please download it from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}. Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
1921

2022
Once downloaded, unzip it using:
2123

@@ -92,13 +94,15 @@ This should complete a test run the `sdpa` binary using one of the provided exam
9294
9395
## Obtaining and installing SDPA Python wrapper
9496
95-
Once you have built and done a test run on `sdpa`, you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
97+
Once you have built and done a test run on `sdpa` (or `sdpa_gmp` if using the Multiprecision backend), you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
9698

9799
We need SPOOLES for building `sdpa-python`.
98100

99-
### Obtaining SPOOLES library and headers
101+
### Obtaining and building the SPOOLES library and headers
102+
103+
If you are using the **SDPA Multiprecision** backend, it contains SPOOLES and will build it as part of the buildsystem. In that case, you can skip directly to the next subsection.
100104

101-
On macOS we have to download as well as build the SPOOLES library.
105+
If you are using the regular SDPA backend, you will have to download as well as build the SPOOLES library.
102106

103107
SPOOLES can be obtained from the official [SPOOLES webpage](http://www.netlib.org/linalg/spooles/spooles.2.2.html) or the [Debian package sources](http://ftp.de.debian.org/debian/pool/main/s/spooles/spooles_2.2.orig.tar.gz).
104108

@@ -140,18 +144,17 @@ cd sdpa-python
140144
There is a file `setupcfg.py` in the root of `sdpa-python`. We need to edit it and provide
141145

142146

143-
1. The link to the `make.inc` in the `sdpa` folder (so it can find `libsdpa.a`). Assuming you extracted it on your Desktop:
144-
145-
Assuming you extracted it on your Desktop:
147+
1. The location of SDPA headers and static library (i.e. `libsdpa.a` or `libsdpa_gmp.a`):
146148

147149
```python
148-
SDPA_MAKEINC = '/Users/yourusername/Desktop/sdpa-{{page.sdpa_latest_version}}/etc/make.inc'
150+
SDPA_DIR = '/path/to/sdpa_package_name'
149151
```
150152

151-
2. The location of SPOOLES library and headers. Assuming you extracted it on your Desktop:
153+
2. Only if using the **regular SDPA** backend, the location of SPOOLES library and headers (for Multiprecision backend these variables need not be changed):
152154

153155
```python
154-
SPOOLES_INCLUDE = '/Users/yourusername/Desktop/spooles/'
156+
SPOOLES_DIR = '/path/to/spooles/'
157+
SPOOLES_INCLUDE = SPOOLES_DIR
155158
```
156159

157160
3. The location of `libgfortran.a` and `libquadmath.a`. Assuming you installed it from [this GitHub repository](https://github.com/fxcoudert/gfortran-for-macOS) with the default options:
@@ -160,6 +163,14 @@ There is a file `setupcfg.py` in the root of `sdpa-python`. We need to edit it a
160163
GFORTRAN_LIBS ='/usr/local/gfortran/lib'
161164
```
162165

166+
4. Only if using the **SDPA Multiprecision** backend, the location of GMP library and headers:
167+
168+
```python
169+
GMP_DIR = '/path/to/gmp-version'
170+
```
171+
172+
5. Lastly, if you are using the **SDPA Multiprecision** backend, please set `USEGMP = True` in this file.
173+
163174
### Install `sdpa-python` Package
164175

165176
Finally, build and install `sdpa-python` package. While still in the `sdpa-python` directory, do:

docs/installation/windows.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ This will give us the basic build tools, i.e. `make` and `gcc`/`g++`.
3939

4040
We will remain on the **MSYS2 MSYS** shell until the build step (when we will switch to **MSYS2 MinGW x64**).
4141

42-
## Obtaining and building SDPA
42+
## Obtaining and building the backend
4343

44-
The primary software package containing SDPA is named simply `sdpa` and the source can be obtained from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}.
44+
As a backend, we can use either the regular SDPA package, or the SDPA Multiprecision variant. SDPA Multiprecision is a fork of SDPA-GMP.
4545

46-
Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
46+
If you choose to use **SDPA Multiprecision**, please follow the instructions in the README of its [GitHub repository](https://github.com/sdpa-python/sdpa-multiprecision), and then skip directly to the [next section](#obtaining-and-installing-sdpa-python-wrapper) on building the Python wrapper.
47+
48+
If you choose to use the **regular SDPA package**, please download it from the [official website](http://sdpa.sourceforge.net/download.html). Currently, the latest version is {{page.sdpa_latest_version}}. Sourceforge does not allow a direct download link, however, the specific file required is [sdpa_{{page.sdpa_latest_version}}.tar.gz](https://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_{{page.sdpa_latest_version}}.tar.gz).
4749

4850
Once downloaded, unzip it using:
4951

@@ -129,27 +131,21 @@ This should complete a test run the `sdpa` binary using one of the provided exam
129131

130132
## Obtaining and installing SDPA Python wrapper
131133

132-
Once you have built and done a test run on `sdpa`, you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
134+
Once you have built and done a test run on `sdpa` (or `sdpa_gmp` if using the Multiprecision backend), you have a working SDPA binary, it's finally time to build and install `sdpa-python`.
133135
134136
We need SPOOLES for building `sdpa-python`.
135137
136-
### Obtaining SPOOLES headers
138+
### Obtaining SPOOLES library and headers
137139
138140
On MSYS2, `libspooles` can be installed (from the **MSYS2 MSYS** shell) using
139141
140142
```bash
141143
pacman -S mingw-w64-x86_64-spooles
142144
```
143145
144-
The best way to verify installation is to compile a very basic Hello World program with `g++ hello.c -lspooles`.
145-
146-
You will however, still need to download it because SPOOLES headers are imported by `sdpa-python` (and you will need to provide the include path for it in `setupcfg.py`). It can be obtained from the official [SPOOLES webpage](http://www.netlib.org/linalg/spooles/spooles.2.2.html) or the [Debian package sources](http://ftp.de.debian.org/debian/pool/main/s/spooles/spooles_2.2.orig.tar.gz).
146+
**Note**: SDPA Multiprecision also uses SPOOLES. If you successfully built SDPA Multiprecision, you should already have SPOOLES on your system.
147147
148-
```bash
149-
wget http://www.netlib.org/linalg/spooles/spooles.2.2.tgz
150-
mkdir spooles
151-
tar -zxf spooles.2.2.tgz -C spooles # (OR spooles_2.2.orig.tar.gz if from Debian Sources)
152-
```
148+
The best way to verify installation is to compile a very basic Hello World program with `g++ hello.c -lspooles`.
153149
154150
**Before proceeding to the next section, we now need to switch to whatever shell has our desired Python (e.g. Anaconda shell, PowerShell, etc).**
155151
@@ -187,31 +183,37 @@ There is a file `setupcfg.py` in the root of `sdpa-python`. We need to edit it a
187183
188184
We need to edit it and provide
189185
190-
1. The link to the `make.inc` in the `sdpa` folder (so it can find `libsdpa.a`). Assuming you extracted it in `C:\sdpa`:
186+
1. The location of SDPA headers and static library (i.e. `libsdpa.a` or `libsdpa_gmp.a`):
191187
192188
```python
193-
SDPA_DIR = os.path.join("C:\\", "sdpa", "sdpa-{{page.sdpa_latest_version}}")
189+
SDPA_DIR = os.path.join("C:\\", "path", "to", "sdpa_package_name")
194190
```
195191
196-
2. The location of SPOOLES library and headers. Assuming you extracted it in `C:\sdpa`:
192+
2. The location of SPOOLES headers. Assuming MSYS2 was installed in the default location:
197193
198194
```python
199-
SPOOLES_INCLUDE = os.path.join("C:\\", "sdpa", "spooles")
195+
SPOOLES_INCLUDE = os.path.join("C:\\", "msys64", "mingw64", "include", "spooles")
200196
```
201197
202-
3. The location of MinGW static libraries. Assuming it was installed with the default options:
198+
3. The location of other common static libraries. Assuming MSYS2 was installed in the default location:
203199
204200
```python
205201
MINGW_LIBS = os.path.join("C:\\", "msys64", "mingw64", "lib")
206202
```
207203
208-
4. Names of BLAS/LAPACK if you did not use the reference BLAS. Please use the same BLAS/LAPACK that you used while building `sdpa`. Assuming you used OpenBLAS:
204+
4. Only if using the **regular SDPA** backend, the names of the BLAS/LAPACK implementation(s) that you intend to use. Please use the same one as you did while building the SDPA (backend) package. Assuming you used OpenBLAS:
209205
210206
```python
211-
LAPACK_NAME = 'openblas'
212-
BLAS_NAME = 'openblas'
207+
BLAS_LAPACK_LIBS = ['openblas', 'gomp']
208+
209+
5. Only if using the **SDPA Multiprecision** backend, the location of GMP library and headers:
210+
211+
```python
212+
GMP_DIR = os.path.join("C:\\", "path", "to", "gmp-version")
213213
```
214214
215+
6. Lastly, if you are using the **SDPA Multiprecision** backend, please set `USEGMP = True` in this file.
216+
215217
### Build `sdpa-python` Package
216218
217219
```bash

0 commit comments

Comments
 (0)