Skip to content

Commit

Permalink
Add partial support for rust-cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Jan 2, 2022
1 parent f996d64 commit 8ff9f84
Show file tree
Hide file tree
Showing 55 changed files with 525 additions and 213 deletions.
5 changes: 5 additions & 0 deletions .github/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-unknown-linux-gnu.dependencies]
alloc = {}

[target.thumbv7em-none-eabihf.dependencies]
alloc = {}
29 changes: 29 additions & 0 deletions .github/workflows/parry-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,32 @@ jobs:
run: cd build/parry2d && cargo build --verbose --target wasm32-unknown-unknown;
- name: build parry3d
run: cd build/parry3d && cargo build --verbose --target wasm32-unknown-unknown;
build-no-std:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt
- name: install xargo
run: cp .github/Xargo.toml .; rustup component add rust-src; cargo install -f xargo;
- name: build x86_64-unknown-linux-gnu
run: xargo build --verbose --no-default-features --features required-features --target=x86_64-unknown-linux-gnu;
- name: build thumbv7em-none-eabihf
run: xargo build --verbose --no-default-features --features required-features --target=thumbv7em-none-eabihf;
build-cuda:
runs-on: ubuntu-latest
steps:
- uses: Jimver/[email protected]
- name: Install nightly-2021-10-17
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-10-17
override: true
- uses: actions/checkout@v2
- run: rustup target add nvptx64-nvidia-cuda
- run: cargo build --no-default-features --features required-features,cuda
- run: cargo build --no-default-features --features required-features,cuda --target=nvptx64-nvidia-cuda
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[workspace]
members = ["build/parry2d", "build/parry3d", "build/parry2d-f64", "build/parry3d-f64"]
resolver = "2"

[patch.crates-io]
parry2d = { path = "build/parry2d" }
parry3d = { path = "build/parry3d" }
parry2d-f64 = { path = "build/parry2d-f64" }
parry3d-f64 = { path = "build/parry3d-f64" }
simba = { git = "https://github.com/dimforge/simba" }
nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "rust-cuda" }
29 changes: 18 additions & 11 deletions build/parry2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,45 @@ edition = "2018"
maintenance = { status = "actively-developed" }

[features]
default = [ "dim2", "f64" ]
default = [ "required-features", "std" ]
required-features = [ "dim2", "f64" ]
std = [ "nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec" ]
dim2 = [ ]
f64 = [ ]
serde-serialize = [ "serde", "nalgebra/serde-serialize", "arrayvec/serde" ]
simd-stable = [ "simba/wide", "simd-is-enabled" ]
simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ]
enhanced-determinism = [ "simba/libm_force", "indexmap" ]
cuda = [ "cust", "nalgebra/cuda" ]

# Do not enable this feature directly. It is automatically
# enabled with the "simd-stable" or "simd-nightly" feature.
simd-is-enabled = [ ]

[lib]
name = "parry2d_f64"
path = "../../src/lib.rs"
required-features = [ "dim2", "f64" ]
required-features = [ "required-features" ]

[dependencies]
either = "1"
either = { version = "1", default-features = false }
bitflags = "1"
downcast-rs = "1"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = "0.4"
arrayvec = "0.7"
simba = "0.6"
nalgebra = "0.29"
slab = { version = "0.4", optional = true }
arrayvec = { version = "0.7", optional = true }
simba = { version = "0.6", default-features = false }
nalgebra = { version = "0.29", default-features = false, features = [ "libm" ] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"]}
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = "1"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = { version = "1", optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.1", optional = true }

[dev-dependencies]
simba = { version = "0.6", features = [ "partial_fixed_point_support" ] }
simba = { version = "0.6", default-features = false, features = [ "partial_fixed_point_support" ] }
oorandom = "11"
27 changes: 17 additions & 10 deletions build/parry2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,45 @@ edition = "2018"
maintenance = { status = "actively-developed" }

[features]
default = [ "dim2", "f32" ]
default = [ "required-features", "std" ]
required-features = [ "dim2", "f32" ]
std = [ "nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec" ]
dim2 = [ ]
f32 = [ ]
serde-serialize = [ "serde", "nalgebra/serde-serialize", "arrayvec/serde" ]
simd-stable = [ "simba/wide", "simd-is-enabled" ]
simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ]
enhanced-determinism = [ "simba/libm_force", "indexmap" ]
cuda = [ "cust", "nalgebra/cuda" ]

# Do not enable this feature directly. It is automatically
# enabled with the "simd-stable" or "simd-nightly" feature.
simd-is-enabled = [ ]

[lib]
name = "parry2d"
path = "../../src/lib.rs"
required-features = [ "dim2", "f32" ]
required-features = [ "required-features" ]

[dependencies]
either = "1"
either = { version = "1", default-features = false }
bitflags = "1"
downcast-rs = "1"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = "0.4"
arrayvec = "0.7"
simba = "0.6"
nalgebra = "0.29"
slab = { version = "0.4", optional = true }
arrayvec = { version = "0.7", optional = true }
simba = { version = "0.6", default-features = false }
nalgebra = { version = "0.29", default-features = false, features = [ "libm" ] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"]}
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = "1"
rustc-hash = { version = "1", optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.1", optional = true }

[dev-dependencies]
simba = { version = "0.6", features = [ "partial_fixed_point_support" ] }
simba = { version = "0.6", default-features = false, features = [ "partial_fixed_point_support" ] }
oorandom = "11"
26 changes: 16 additions & 10 deletions build/parry3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,43 @@ edition = "2018"
maintenance = { status = "actively-developed" }

[features]
default = [ "dim3", "f64" ]
default = [ "required-features", "std" ]
required-features = [ "dim3", "f64" ]
std = [ "nalgebra/std", "slab", "rustc-hash", "simba/std" ]
dim3 = [ ]
f64 = [ ]
serde-serialize = [ "serde", "nalgebra/serde-serialize" ]
simd-stable = [ "simba/wide", "simd-is-enabled" ]
simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ]
enhanced-determinism = [ "simba/libm_force", "indexmap" ]
cuda = [ "cust", "nalgebra/cuda" ]

# Do not enable this feature directly. It is automatically
# enabled with the "simd-stable" or "simd-nightly" feature.
simd-is-enabled = [ ]

[lib]
name = "parry3d_f64"
path = "../../src/lib.rs"
required-features = [ "dim3", "f64" ]
required-features = [ "required-features" ]

[dependencies]
either = "1"
either = { version = "1", default-features = false }
bitflags = "1"
downcast-rs = "1"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = "0.4"
simba = "0.6"
nalgebra = "0.29"
slab = { version = "0.4", optional = true }
simba = { version = "0.6", default-features = false }
nalgebra = { version = "0.29", default-features = false, features = [ "libm" ] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive", "rc"]}
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = "1"
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = { version = "1", optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.1", optional = true }

[dev-dependencies]
oorandom = "11"
26 changes: 16 additions & 10 deletions build/parry3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,43 @@ edition = "2018"
maintenance = { status = "actively-developed" }

[features]
default = [ "dim3", "f32" ]
default = [ "required-features", "std" ]
required-features = [ "dim3", "f32" ]
std = [ "nalgebra/std", "slab", "rustc-hash", "simba/std" ]
dim3 = [ ]
f32 = [ ]
serde-serialize = [ "serde", "nalgebra/serde-serialize" ]
simd-stable = [ "simba/wide", "simd-is-enabled" ]
simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ]
enhanced-determinism = [ "simba/libm_force", "indexmap" ]
cuda = [ "cust", "nalgebra/cuda" ]

# Do not enable this feature directly. It is automatically
# enabled with the "simd-stable" or "simd-nightly" feature.
simd-is-enabled = [ ]

[lib]
name = "parry3d"
path = "../../src/lib.rs"
required-features = [ "dim3", "f32" ]
required-features = [ "required-features" ]

[dependencies]
either = "1"
either = { version = "1", default-features = false }
bitflags = "1"
downcast-rs = "1"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = "0.4"
simba = "0.6"
nalgebra = "0.29"
slab = { version = "0.4", optional = true }
simba = { version = "0.6", default-features = false }
nalgebra = { version = "0.29", default-features = false, features = [ "libm" ] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive", "rc"]}
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = "1"
num-derive = "0.3"
indexmap = { version = "1", features = [ "serde-1" ], optional = true }
rustc-hash = { version = "1", optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.1", optional = true }

[dev-dependencies]
oorandom = "11"
4 changes: 4 additions & 0 deletions src/bounding_volume/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use crate::utils::IsometryOps;
use na;
use num::Bounded;

#[cfg(not(feature = "std"))]
use na::ComplexField; // for .abs()

/// An Axis Aligned Bounding Box.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Copy, Clone)]
Expand Down Expand Up @@ -270,6 +273,7 @@ impl AABB {
}

#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
pub fn intersects_spiral(
&self,
point: &Point<Real>,
Expand Down
8 changes: 8 additions & 0 deletions src/bounding_volume/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ pub mod bounding_volume;
pub mod aabb;
mod aabb_ball;
#[cfg(feature = "dim2")]
#[cfg(feature = "std")]
mod aabb_convex_polygon;
#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
mod aabb_convex_polyhedron;
mod aabb_cuboid;
mod aabb_halfspace;
#[cfg(feature = "std")]
mod aabb_heightfield;
mod aabb_support_map;
mod aabb_triangle;
Expand All @@ -34,17 +37,22 @@ mod bounding_sphere_capsule;
#[cfg(feature = "dim3")]
mod bounding_sphere_cone;
#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
mod bounding_sphere_convex;
#[cfg(feature = "dim2")]
#[cfg(feature = "std")]
mod bounding_sphere_convex_polygon;
mod bounding_sphere_cuboid;
#[cfg(feature = "dim3")]
mod bounding_sphere_cylinder;
mod bounding_sphere_halfspace;
#[cfg(feature = "std")]
mod bounding_sphere_heightfield;
#[cfg(feature = "std")]
mod bounding_sphere_polyline;
mod bounding_sphere_segment;
mod bounding_sphere_triangle;
#[cfg(feature = "std")]
mod bounding_sphere_trimesh;
mod bounding_sphere_utils;
mod simd_aabb;
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ the rust programming language.
#![warn(unused_imports)]
#![allow(missing_copy_implementations)]
#![doc(html_root_url = "http://docs.rs/parry/0.1.1")]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(all(
feature = "simd-is-enabled",
Expand Down Expand Up @@ -46,6 +47,13 @@ macro_rules! array(
}
);

#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg_attr(test, macro_use)]
extern crate alloc;

#[cfg(not(feature = "std"))]
extern crate core as std;

#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
Expand All @@ -61,9 +69,11 @@ pub extern crate simba;

pub mod bounding_volume;
pub mod mass_properties;
#[cfg(feature = "std")]
pub mod partitioning;
pub mod query;
pub mod shape;
#[cfg(feature = "std")]
pub mod transformation;
pub mod utils;

Expand Down
4 changes: 2 additions & 2 deletions src/mass_properties/mass_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::math::{AngVector, AngularInertia, Isometry, Point, Real, Rotation, Ve
use crate::utils;
use na::ComplexField;
use num::Zero;
use std::iter::Sum;
use std::ops::{Add, AddAssign, Sub, SubAssign};
#[cfg(feature = "dim3")]
use {na::Matrix3, std::ops::MulAssign};
Expand Down Expand Up @@ -350,7 +349,8 @@ impl AddAssign<MassProperties> for MassProperties {
}
}

impl Sum<MassProperties> for MassProperties {
#[cfg(feature = "std")]
impl std::iter::Sum<MassProperties> for MassProperties {
#[cfg(feature = "dim2")]
fn sum<I>(iter: I) -> Self
where
Expand Down
Loading

0 comments on commit 8ff9f84

Please sign in to comment.