Skip to content

Commit bebf3f2

Browse files
authored
Merge pull request #2347 from borglab/feature/parrallelUpdate
Parallel separator update in MFSolver
2 parents 6dd0ee8 + 752608f commit bebf3f2

File tree

6 files changed

+251
-90
lines changed

6 files changed

+251
-90
lines changed

.github/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# GTSAM GitHub Configuration
2+
3+
This directory contains GitHub-specific configuration, including issue templates and CI workflows.
4+
5+
## Workflows Overview
6+
7+
The `.github/workflows` directory contains definitions for the various CI/CD processes:
8+
9+
- **`build-linux.yml`**: Main Linux CI. Runs inside the pre-built Docker containers mentioned above to compile and test GTSAM with various compilers (GCC, Clang) and configurations.
10+
- **`build-macos.yml`**: Compiles and tests GTSAM on macOS runners.
11+
- **`build-windows.yml`**: Compiles and tests GTSAM on Windows runners using MSVC.
12+
- **`build-python.yml`**: Verifies the Python wrapper compilation across Linux, macOS, and Windows.
13+
- **`build-cibw.yml`**: Builds distributable Python wheels using `cibuildwheel`. It builds dependencies (like Boost) from source to ensure ABI compatibility.
14+
- **`prod-cibw.yml`**: Used for production wheel builds (often triggered on release).
15+
- **`deploy.yml`**: Handles deployment tasks (e.g., docs, release artifacts).
16+
17+
## Docker CI Images (Linux Only)
18+
19+
The **Linux CI** workflow (`build-linux.yml`) relies on pre-built Docker images to ensure consistency and speed up build times. These images are hosted in the [borglab/docker-images](https://github.com/borglab/docker-images) repository.
20+
21+
*Note: macOS and Windows workflows use standard GitHub Actions runners and install dependencies (like Boost) via package managers (Homebrew, Chocolatey) or from source.*
22+
23+
### Building and Updating Images
24+
25+
If you need to update an existing CI image or add a new one (e.g., for a new Ubuntu version or compiler):
26+
27+
1. **Navigate to the `docker-images` repository:**
28+
```bash
29+
cd ../docker-images/gtsam-ci
30+
```
31+
2. **Add or modify a Dockerfile:**
32+
- Follow the naming convention: `ubuntu-<version>-<compiler>-<version>.Dockerfile`.
33+
- Base images are defined in `*-base.Dockerfile`.
34+
3. **Build and Push:**
35+
Use the provided script to build and push to Docker Hub (requires `borglab` permissions):
36+
```bash
37+
./build_and_push.sh <dockerhub-username>
38+
```
39+
40+
For more details, see the [README in the docker-images repository](https://github.com/borglab/docker-images/blob/main/gtsam-ci/README.md).

containers/README.md

Lines changed: 82 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,131 @@
1-
# GTSAM Containers
1+
# GTSAM Docker Images
22

3-
- container files to build images
4-
- script to push images to a registry
5-
- instructions to pull images and run containers
3+
The official Docker images for GTSAM are maintained in the [borglab/docker-images](https://github.com/borglab/docker-images) repository.
64

7-
## Dependencies
5+
## Available Images
86

9-
- a container engine such as [`Docker Engine`](https://docs.docker.com/engine/install/)
7+
The following images are available on Docker Hub, primarily under the `borglab` namespace:
108

11-
## Pull from Docker Hub
9+
- **[borglab/gtsam](https://hub.docker.com/r/borglab/gtsam)**:
10+
A pre-compiled environment containing the latest `develop` branch of GTSAM. Useful for quick testing or as a base for downstream applications.
11+
- *Source:* [`docker-images/gtsam`](https://github.com/borglab/docker-images/tree/main/gtsam)
1212

13-
Various GTSAM image configurations are available at [`docker.io/borglab/gtsam`](https://hub.docker.com/r/borglab/gtsam). Determine which [tag](https://hub.docker.com/r/borglab/gtsam/tags) you want and pull the image.
13+
- **[borglab/gtsam-manylinux](https://hub.docker.com/r/borglab/gtsam-manylinux)**:
14+
An environment based on `manylinux2014` tailored for building Python wheels for GTSAM.
15+
- *Source:* [`docker-images/gtsam-manylinux`](https://github.com/borglab/docker-images/tree/main/gtsam-manylinux)
1416

15-
Example for pulling an image with GTSAM compiled with TBB and Python support on top of a base Ubuntu 22.04 image.
17+
- **[borglab/ubuntu-boost-tbb](https://hub.docker.com/r/borglab/ubuntu-boost-tbb)**:
18+
Base image (Ubuntu 24.04) with Boost and TBB libraries pre-installed.
19+
- *Source:* [`docker-images/ubuntu-boost-tbb`](https://github.com/borglab/docker-images/tree/main/ubuntu-boost-tbb)
20+
21+
- **CI Images**:
22+
Various images used for Continuous Integration, covering different Ubuntu versions (22.04, 24.04) and compilers (Clang, GCC).
23+
- *Source:* [`docker-images/gtsam-ci`](https://github.com/borglab/docker-images/tree/main/gtsam-ci)
24+
25+
## Usage
26+
27+
### Running GTSAM
28+
29+
To start an interactive shell in a container with GTSAM pre-installed:
1630

1731
```bash
18-
docker pull docker.io/borglab/gtsam:4.2.0-tbb-ON-python-ON_22.04
32+
docker run -it borglab/gtsam:latest
1933
```
2034

21-
[`docker.io/borglab/gtsam-vnc`](https://hub.docker.com/r/borglab/gtsam-vnc) is also provided as an image with GTSAM that will run a VNC server to connect to.
35+
### Using the Python Wrapper
2236

23-
## Using the images
37+
The `borglab/gtsam` image typically includes Python bindings. To use them:
2438

25-
### Just GTSAM
39+
1. Start the container:
40+
```bash
41+
docker run -it borglab/gtsam:latest
42+
```
43+
2. Launch Python:
44+
```bash
45+
python3
46+
```
47+
3. Import GTSAM:
48+
```python
49+
import gtsam
50+
print(gtsam.Pose3())
51+
```
2652

27-
To start the image, execute
53+
## Building Images
2854

29-
```bash
30-
docker run -it borglab/gtsam:4.2.0-tbb-ON-python-OFF_22.04
31-
```
55+
To build these images locally or contribute changes, please refer to the **[borglab/docker-images](https://github.com/borglab/docker-images)** repository. It contains the Dockerfiles and build scripts for all the images listed above.
3256

33-
after you will find yourself in a bash shell.
57+
### Legacy Configuration
3458

35-
### GTSAM with Python wrapper
3659

37-
To use GTSAM via the python wrapper, similarly execute
3860

39-
```bash
40-
docker run -it borglab/gtsam:4.2.0-tbb-ON-python-ON_22.04
41-
```
61+
The following files in this directory are legacy artifacts and are **no longer actively maintained**:
4262

43-
and then launch `python3`:
4463

45-
```bash
46-
python3
47-
>>> import gtsam
48-
>>> gtsam.Pose2(1,2,3)
49-
(1, 2, 3)
50-
```
5164

52-
### GTSAM with Python wrapper and VNC
65+
- **`Containerfile`**: Build instructions for a standalone GTSAM image (cloning from git and building from source).
5366

54-
First, start the image, which will run a VNC server on port 5900:
67+
- **`compose.yaml`**: A Docker Compose wrapper used for configurable builds (via `.env` variables like `GTSAM_WITH_TBB`, `GTSAM_BUILD_PYTHON`) and standardized image tagging.
5568

56-
```bash
57-
docker run -p 5900:5900 borglab/gtsam-vnc:4.2.0-tbb-ON-python-ON_22.04
58-
```
69+
- **`hub_push.sh`**: A utility script to iterate through configuration matrices and push multiple image variants to Docker Hub.
5970

60-
Then open a remote VNC X client, for example:
6171

62-
#### Linux
6372

64-
```bash
65-
sudo apt-get install tigervnc-viewer
66-
xtigervncviewer :5900
67-
```
73+
For official builds and the most up-to-date configurations, please refer to the **[borglab/docker-images](https://github.com/borglab/docker-images)** repository.
6874

69-
#### Mac
7075

71-
The Finder's "Connect to Server..." with `vnc://127.0.0.1` does not work, for some reason. Using the free [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/), enter `0.0.0.0:5900` as the server.
7276

73-
## Build images locally
77+
> **TODO**: Consider migrating the configurable build and matrix-pushing functionality from these legacy files into the `docker-images` repository to support more flexible local builds.
7478

75-
### Build Dependencies
7679

77-
- a [Compose Spec](https://compose-spec.io/) implementation such as [docker-compose](https://docs.docker.com/compose/install/)
7880

79-
### `gtsam` image
81+
## VNC Support (`gtsam-vnc`)
8082

81-
#### `.env` file
8283

83-
- `GTSAM_GIT_TAG`: [git tag from the gtsam repo](https://github.com/borglab/gtsam/tags)
84-
- `UBUNTU_TAG`: image tag provided by [ubuntu](https://hub.docker.com/_/ubuntu/tags) to base the image off of
85-
- `GTSAM_WITH_TBB`: to build GTSAM with TBB, set to `ON`
86-
- `GTSAM_BUILD_PYTHON`: to build python bindings, set to `ON`
87-
- `CORES`: number of cores to compile with
8884

89-
#### Build `gtsam` image
85+
The **gtsam-vnc** image configuration is available locally in the [`gtsam-vnc`](./gtsam-vnc) subdirectory. This image extends the official `borglab/gtsam` image by adding a VNC server, allowing you to view GUI applications (like Matplotlib plots) running inside the container.
9086

91-
```bash
92-
docker compose build
93-
```
9487

95-
### `gtsam-vnc` image
9688

97-
#### `gtsam-vnc/.env` file
89+
### Building and Running VNC Image
9890

99-
- `GTSAM_TAG`: image tag provided by [gtsam](https://hub.docker.com/r/borglab/gtsam/tags)
10091

101-
#### Build `gtsam-vnc` image
10292

103-
```bash
104-
docker compose --file gtsam-vnc/compose.yaml build
105-
```
93+
1. **Navigate to the directory:**
10694

107-
## Push to Docker Hub
95+
```bash
10896
109-
Make sure you are logged in via: `docker login docker.io`.
97+
cd gtsam-vnc
11098
111-
### `gtsam` images
99+
```
112100

113-
Specify the variables described in the `.env` file in the `hub_push.sh` script.
114-
To push images to Docker Hub, run as follows:
115101

116-
```bash
117-
./hub_push.sh
118-
```
119102

120-
### `gtsam-vnc` images
103+
2. **Build the image:**
121104

122-
Specify the variables described in the `gtsam-vnc/.env` file in the `gtsam-vnc/hub_push.sh` script.
123-
To push images to Docker Hub, run as follows:
105+
You can build it using Docker Compose or directly with Docker.
124106

125-
```bash
126-
./gtsam-vnc/hub_push.sh
127-
```
107+
```bash
108+
109+
# Example using docker build
110+
111+
docker build -t gtsam-vnc .
112+
113+
```
114+
115+
116+
117+
3. **Run with Port Forwarding:**
118+
119+
Map port 5900 to access the VNC server.
120+
121+
```bash
122+
123+
docker run -p 5900:5900 gtsam-vnc
124+
125+
```
126+
127+
128+
129+
4. **Connect:**
130+
131+
Use a VNC client to connect to `localhost:5900`.

gtsam/base/SymmetricBlockMatrix.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ namespace gtsam {
270270
void updateFromOuterProductBlocks(const VerticalBlockMatrix& other,
271271
const std::vector<DenseIndex>& blockIndices);
272272

273+
/// Add the upper-triangular part of another symmetric block matrix.
274+
void addUpperTriangular(const SymmetricBlockMatrix& other) {
275+
assert(nBlocks() == other.nBlocks());
276+
full().triangularView<Eigen::Upper>() += other.full();
277+
}
278+
273279
/// @}
274280
/// @name Accessing the full matrix.
275281
/// @{

gtsam/base/tests/testPriorityScheduler.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,19 @@ TEST(PriorityScheduler, VoidPriorityOrderingSingleWorker) {
6262
scheduler.waitForAllTasks();
6363
EXPECT_LONGS_EQUAL(3, executionOrder.size());
6464
// With a single worker, tasks are not preempted: the first scheduled task may
65-
// start running before later (higher-priority) tasks are submitted. Once all
66-
// tasks are enqueued, remaining work should respect priority order.
65+
// start running before later (higher-priority) tasks are submitted. Also,
66+
// since the third task is submitted last, the worker may run the first two
67+
// tasks before the third is enqueued.
6768
const bool strictPriority =
6869
(executionOrder.at(0) == 1 && executionOrder.at(1) == 3 &&
6970
executionOrder.at(2) == 5);
7071
const bool firstTaskRanImmediately =
7172
(executionOrder.at(0) == 5 && executionOrder.at(1) == 1 &&
7273
executionOrder.at(2) == 3);
73-
EXPECT(strictPriority || firstTaskRanImmediately);
74+
const bool thirdTaskEnqueuedLate =
75+
(executionOrder.at(0) == 1 && executionOrder.at(1) == 5 &&
76+
executionOrder.at(2) == 3);
77+
EXPECT(strictPriority || firstTaskRanImmediately || thirdTaskEnqueuedLate);
7478
}
7579

7680
/* ************************************************************************* */

0 commit comments

Comments
 (0)