Skip to content

Commit

Permalink
make 'simd' an optional feature (sophus-vision#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat authored Jun 22, 2024
1 parent 237ee0a commit d3ccd87
Show file tree
Hide file tree
Showing 65 changed files with 3,115 additions and 2,648 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: clippy
on:
push:
branches: [main]
pull_request:

workflow_dispatch:
jobs:
clippy:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Run sccache stat for check before
shell: bash
run: ${SCCACHE_PATH} --show-stats
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: cargo clippy
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
rustup default nightly
rustup component add clippy
cargo clippy --all-targets --all-features
- name: Run sccache stat for check after
shell: bash
run: ${SCCACHE_PATH} --show-stats
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: docs
on:
push:
branches: [main]
pull_request:

workflow_dispatch:
jobs:
docs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Run sccache stat for check before
shell: bash
run: ${SCCACHE_PATH} --show-stats
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: cargo
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
rustup default nightly
cargo doc --no-deps --all-features
- name: Run sccache stat for check after
shell: bash
run: ${SCCACHE_PATH} --show-stats
28 changes: 28 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: format
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-22.04
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Install pre-commit and install
run: |
pip install pre-commit
pre-commit install
- name: Run pre-commit checks
run: pre-commit run --all-files
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: cargo doc
run: |
rustup default nightly
cargo doc --no-deps --all-features
40 changes: 40 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: nightly
on:
push:
branches: [main]
pull_request:

workflow_dispatch:
jobs:
nightly:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Run sccache stat for check before
shell: bash
run: ${SCCACHE_PATH} --show-stats
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: cargo build
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
rustup default nightly
cargo build --release --all-targets --all-features
- name: cargo test
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
rustup default nightly
cargo test --release --all-features
- name: Run sccache stat for check after
shell: bash
run: ${SCCACHE_PATH} --show-stats
22 changes: 11 additions & 11 deletions .github/workflows/main.yml → .github/workflows/stable.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: main
name: stable
on:
push:
branches: [main]
pull_request:

workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
stable:
runs-on: ubuntu-22.04

steps:
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
Expand All @@ -21,18 +21,18 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: cargo
- name: cargo build
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
cargo build --release --all-targets
- name: cargo test
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
run: |
sudo apt-get update -y
sudo apt-get install -y nasm
cargo doc --no-deps
cargo fmt --check
cargo test --release
- name: Run sccache stat for check after
shell: bash
run: ${SCCACHE_PATH} --show-stats


17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: (thirdparty/.*)|(SOPHUS_VERSION)|(.txt)$
- id: check-yaml
args: ["--unsafe"]
- id: check-json
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
args:
- --ignore-words-list
- "te,tring,crate"
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ edition = "2021"
include = [
"**/*.rs",
"**/*.wgsl",
"Cargo.toml",
"**/*.md",
"**/Cargo.toml",
]
keywords = ["robotics", "optimization"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/farm-ng/sophus-rs/"
version = "0.6.1"
version = "0.7.0"

[workspace.dependencies]
sophus = {path = "crates/sophus", version = "0.6.1"}
sophus_core = {path = "crates/sophus_core", version = "0.6.1"}
sophus_image = {path = "crates/sophus_image", version = "0.6.1"}
sophus_lie = {path = "crates/sophus_lie", version = "0.6.1"}
sophus_opt = {path = "crates/sophus_opt", version = "0.6.1"}
sophus_pyo3 = {path = "crates/sophus_pyo3", version = "0.6.1"}
sophus_sensor = {path = "crates/sophus_sensor", version = "0.6.1"}
sophus_viewer = {path = "crates/sophus_viewer", version = "0.6.1"}
sophus = {path = "crates/sophus", version = "0.7.0"}
sophus_core = {path = "crates/sophus_core", version = "0.7.0"}
sophus_image = {path = "crates/sophus_image", version = "0.7.0"}
sophus_lie = {path = "crates/sophus_lie", version = "0.7.0"}
sophus_opt = {path = "crates/sophus_opt", version = "0.7.0"}
sophus_pyo3 = {path = "crates/sophus_pyo3", version = "0.7.0"}
sophus_sensor = {path = "crates/sophus_sensor", version = "0.7.0"}
sophus_viewer = {path = "crates/sophus_viewer", version = "0.7.0"}

approx = "0.5"
as-any = "0.3"
Expand All @@ -58,7 +59,6 @@ num-traits = "0.2"
numpy = "0.21"
png = "0.17"
rand = "0.8"
sleef = "0.3"
tokio = {version = "1", features = ["full"]}
typenum = {version = "1.17", features = ["const-generics"]}
wgpu = "0.19"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
DEALINGS IN THE SOFTWARE.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
# sophus-rs

This library is in an early development stage - hence API is highly unstable.
sophus-rs is a Rust library for 2d and 3d geometry for Computer Vision and Robotics applications.
It is a spin-off of the [Sophus](https://github.com/strasdat/Sophus) C++ library which
focuses on **Lie groups** (e.g. rotations and transformations in 2d and 3d).

Sophus-rs currently requires rust nightly. The only nightly feature it uses is `portable-simd`.
It is the intention to move to rust stable once `portable-simd` is stabilized. There is no current
plan to depend on other nightly features.
In addition to Lie groups, sophus-rs also includes other geometric/maths concepts such unit vector,
splines, image classes, camera models as well as a other utilities such as a non-linear least
squares optimization.

## Status

This library is in an early development stage - hence API is highly unstable. It is likely that
existing features will be removed or changed in the future.

However, the intend is to stride for correctness, facilitated using a comprehensive test suite.

## Building

sophus-rs builds on stable.

```toml
[dependencies]
sophus = "0.7.0"
```

To allow for batch types, such as BatchScalarF64, the 'simd' feature is required. This feature
depends on [`portable-simd`](https://doc.rust-lang.org/std/simd/index.html), which is currently
only available on [nightly](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html). There
are plans to use any other nightly features.

```toml
[dependencies]
sophus = { version = "0.7.0", features = ["simd"] }
```
10 changes: 10 additions & 0 deletions crates/sophus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ nalgebra.workspace = true
ndarray.workspace = true
tokio.workspace = true
wgpu.workspace = true

[features]
simd = [
"sophus_core/simd",
"sophus_image/simd",
"sophus_lie/simd",
"sophus_opt/simd",
"sophus_sensor/simd",
"sophus_viewer/simd",
]
5 changes: 4 additions & 1 deletion crates/sophus/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![feature(portable_simd)]
#![cfg_attr(feature = "simd", feature(portable_simd))]
#![allow(clippy::needless_range_loop)]

#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]


pub mod examples;

#[doc(inline)]
Expand Down
7 changes: 6 additions & 1 deletion crates/sophus_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ concat-arrays.workspace = true
nalgebra.workspace = true
ndarray.workspace = true
num-traits.workspace = true
sleef.workspace = true
typenum.workspace = true

sleef = { version = "0.3", optional = true }


[features]
simd = ["sleef"]
27 changes: 21 additions & 6 deletions crates/sophus_core/src/calculus/dual.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
/// DualScalar matrix.
/// Dual matrix.
pub mod dual_matrix;
pub use crate::calculus::dual::dual_matrix::DualBatchMatrix;
pub use crate::calculus::dual::dual_matrix::DualMatrix;

/// DualScalar scalar.
#[cfg(feature = "simd")]
/// Dual batch matrix.
pub mod dual_batch_matrix;
#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_matrix::DualBatchMatrix;

/// Dual scalar.
pub mod dual_scalar;
pub use crate::calculus::dual::dual_scalar::DualBatchScalar;
pub use crate::calculus::dual::dual_scalar::DualScalar;

/// DualScalar vector.
#[cfg(feature = "simd")]
/// Dual batch scalar.
pub mod dual_batch_scalar;
#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_scalar::DualBatchScalar;

/// Dual vector.
pub mod dual_vector;
pub use crate::calculus::dual::dual_vector::DualBatchVector;
pub use crate::calculus::dual::dual_vector::DualVector;

#[cfg(feature = "simd")]
/// Dual batch vector.
pub mod dual_batch_vector;
#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_vector::DualBatchVector;
Loading

0 comments on commit d3ccd87

Please sign in to comment.