Merge pull request #1090 from dimforge/cust-0.3

Update to cust 0.3
This commit is contained in:
Sébastien Crozet 2022-03-23 22:54:21 +01:00 committed by GitHub
commit f081cea504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 37 additions and 88 deletions

View File

@ -124,6 +124,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: Jimver/cuda-toolkit@v0.2.4 - uses: Jimver/cuda-toolkit@v0.2.4
with:
cuda: '11.2.2'
- name: Install nightly-2021-12-04 - name: Install nightly-2021-12-04
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -132,4 +134,6 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: rustup target add nvptx64-nvidia-cuda - run: rustup target add nvptx64-nvidia-cuda
- run: cargo build --no-default-features --features cuda - run: cargo build --no-default-features --features cuda
- run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda - run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda
env:
CUDA_ARCH: "350"

View File

@ -32,7 +32,7 @@ compare = [ "matrixcompare-core" ]
libm = [ "simba/libm" ] libm = [ "simba/libm" ]
libm-force = [ "simba/libm_force" ] libm-force = [ "simba/libm_force" ]
macros = [ "nalgebra-macros" ] macros = [ "nalgebra-macros" ]
cuda = [ "cust", "simba/cuda" ] cuda = [ "cust_core", "simba/cuda" ]
# Conversion # Conversion
convert-mint = [ "mint" ] convert-mint = [ "mint" ]
@ -96,9 +96,7 @@ glam017 = { package = "glam", version = "0.17", optional = true }
glam018 = { package = "glam", version = "0.18", optional = true } glam018 = { package = "glam", version = "0.18", optional = true }
glam019 = { package = "glam", version = "0.19", optional = true } glam019 = { package = "glam", version = "0.19", optional = true }
glam020 = { package = "glam", version = "0.20", optional = true } glam020 = { package = "glam", version = "0.20", optional = true }
cust_core = { version = "0.1", optional = true }
[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.2", optional = true }
[dev-dependencies] [dev-dependencies]

View File

@ -27,10 +27,7 @@ use std::mem;
/// A array-based statically sized matrix data storage. /// A array-based statically sized matrix data storage.
#[repr(transparent)] #[repr(transparent)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]); pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
impl<T, const R: usize, const C: usize> ArrayStorage<T, R, C> { impl<T, const R: usize, const C: usize> ArrayStorage<T, R, C> {

View File

@ -13,10 +13,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// Dim of dynamically-sized algebraic entities. /// Dim of dynamically-sized algebraic entities.
#[derive(Clone, Copy, Eq, PartialEq, Debug)] #[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct Dynamic { pub struct Dynamic {
value: usize, value: usize,
} }
@ -201,10 +198,7 @@ dim_ops!(
); );
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct Const<const R: usize>; pub struct Const<const R: usize>;
/// Trait implemented exclusively by type-level integers. /// Trait implemented exclusively by type-level integers.

View File

@ -150,10 +150,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
/// some concrete types for `T` and a compatible data storage type `S`). /// some concrete types for `T` and a compatible data storage type `S`).
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct Matrix<T, R, C, S> { pub struct Matrix<T, R, C, S> {
/// The data storage that contains all the matrix components. Disappointed? /// The data storage that contains all the matrix components. Disappointed?
/// ///

View File

@ -21,10 +21,7 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
/// in their documentation, read their dedicated pages directly. /// in their documentation, read their dedicated pages directly.
#[repr(transparent)] #[repr(transparent)]
#[derive(Clone, Hash, Copy)] #[derive(Clone, Hash, Copy)]
// #[cfg_attr( // #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
// all(not(target_os = "cuda"), feature = "cuda"),
// derive(cust::DeviceCopy)
// )]
pub struct Unit<T> { pub struct Unit<T> {
pub(crate) value: T, pub(crate) value: T,
} }
@ -102,9 +99,8 @@ mod rkyv_impl {
} }
} }
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] #[cfg(feature = "cuda")]
unsafe impl<T: cust::memory::DeviceCopy, R, C, S> cust::memory::DeviceCopy unsafe impl<T: cust_core::DeviceCopy, R, C, S> cust_core::DeviceCopy for Unit<Matrix<T, R, C, S>>
for Unit<Matrix<T, R, C, S>>
where where
T: Scalar, T: Scalar,
R: Dim, R: Dim,

View File

@ -39,10 +39,7 @@ use simba::scalar::{ClosedNeg, RealField};
/// See <https://github.com/dimforge/nalgebra/issues/487> /// See <https://github.com/dimforge/nalgebra/issues/487>
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct DualQuaternion<T> { pub struct DualQuaternion<T> {
/// The real component of the quaternion /// The real component of the quaternion
pub real: Quaternion<T>, pub real: Quaternion<T>,

View File

@ -50,10 +50,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
/// ///
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))]
#[cfg_attr( #[cfg_attr(
feature = "serde-serialize-no-std", feature = "serde-serialize-no-std",

View File

@ -19,10 +19,7 @@ use crate::geometry::{Point3, Projective3};
/// A 3D orthographic projection stored as a homogeneous 4x4 matrix. /// A 3D orthographic projection stored as a homogeneous 4x4 matrix.
#[repr(C)] #[repr(C)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Orthographic3<T> { pub struct Orthographic3<T> {
matrix: Matrix4<T>, matrix: Matrix4<T>,

View File

@ -20,10 +20,7 @@ use crate::geometry::{Point3, Projective3};
/// A 3D perspective projection stored as a homogeneous 4x4 matrix. /// A 3D perspective projection stored as a homogeneous 4x4 matrix.
#[repr(C)] #[repr(C)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Perspective3<T> { pub struct Perspective3<T> {
matrix: Matrix4<T>, matrix: Matrix4<T>,

View File

@ -69,12 +69,11 @@ where
{ {
} }
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] #[cfg(feature = "cuda")]
unsafe impl<T: Scalar + cust::memory::DeviceCopy, D: DimName> cust::memory::DeviceCopy unsafe impl<T: Scalar + cust_core::DeviceCopy, D: DimName> cust_core::DeviceCopy for OPoint<T, D>
for OPoint<T, D>
where where
DefaultAllocator: Allocator<T, D>, DefaultAllocator: Allocator<T, D>,
OVector<T, D>: cust::memory::DeviceCopy, OVector<T, D>: cust_core::DeviceCopy,
{ {
} }

View File

@ -23,10 +23,7 @@ use crate::geometry::{Point3, Rotation};
/// that may be used as a rotation. /// that may be used as a rotation.
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub struct Quaternion<T> { pub struct Quaternion<T> {
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order. /// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
pub coords: Vector4<T>, pub coords: Vector4<T>,
@ -1045,8 +1042,8 @@ impl<T: RealField + fmt::Display> fmt::Display for Quaternion<T> {
/// A unit quaternions. May be used to represent a rotation. /// A unit quaternions. May be used to represent a rotation.
pub type UnitQuaternion<T> = Unit<Quaternion<T>>; pub type UnitQuaternion<T> = Unit<Quaternion<T>>;
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] #[cfg(feature = "cuda")]
unsafe impl<T: cust::memory::DeviceCopy> cust::memory::DeviceCopy for UnitQuaternion<T> {} unsafe impl<T: cust_core::DeviceCopy> cust_core::DeviceCopy for UnitQuaternion<T> {}
impl<T: Scalar + ClosedNeg + PartialEq> PartialEq for UnitQuaternion<T> { impl<T: Scalar + ClosedNeg + PartialEq> PartialEq for UnitQuaternion<T> {
#[inline] #[inline]

View File

@ -49,10 +49,7 @@ use crate::geometry::Point;
/// * [Conversion to a matrix <span style="float:right;">`matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix) /// * [Conversion to a matrix <span style="float:right;">`matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
/// ///
#[repr(C)] #[repr(C)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Rotation<T, const D: usize> { pub struct Rotation<T, const D: usize> {
matrix: SMatrix<T, D, D>, matrix: SMatrix<T, D, D>,

View File

@ -17,10 +17,7 @@ use crate::geometry::Point;
/// A scale which supports non-uniform scaling. /// A scale which supports non-uniform scaling.
#[repr(C)] #[repr(C)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Scale<T, const D: usize> { pub struct Scale<T, const D: usize> {
/// The scale coordinates, i.e., how much is multiplied to a point's coordinates when it is /// The scale coordinates, i.e., how much is multiplied to a point's coordinates when it is

View File

@ -18,10 +18,7 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation};
/// A similarity, i.e., an uniform scaling, followed by a rotation, followed by a translation. /// A similarity, i.e., an uniform scaling, followed by a rotation, followed by a translation.
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))]
#[cfg_attr( #[cfg_attr(
feature = "serde-serialize-no-std", feature = "serde-serialize-no-std",

View File

@ -60,26 +60,17 @@ where
/// Tag representing the most general (not necessarily inversible) `Transform` type. /// Tag representing the most general (not necessarily inversible) `Transform` type.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub enum TGeneral {} pub enum TGeneral {}
/// Tag representing the most general inversible `Transform` type. /// Tag representing the most general inversible `Transform` type.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub enum TProjective {} pub enum TProjective {}
/// Tag representing an affine `Transform`. Its bottom-row is equal to `(0, 0 ... 0, 1)`. /// Tag representing an affine `Transform`. Its bottom-row is equal to `(0, 0 ... 0, 1)`.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
pub enum TAffine {} pub enum TAffine {}
impl TCategory for TGeneral { impl TCategory for TGeneral {
@ -207,13 +198,13 @@ where
{ {
} }
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] #[cfg(feature = "cuda")]
unsafe impl<T: RealField + cust::memory::DeviceCopy, C: TCategory, const D: usize> unsafe impl<T: RealField + cust_core::DeviceCopy, C: TCategory, const D: usize>
cust::memory::DeviceCopy for Transform<T, C, D> cust_core::DeviceCopy for Transform<T, C, D>
where where
Const<D>: DimNameAdd<U1>, Const<D>: DimNameAdd<U1>,
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>, DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: cust::memory::DeviceCopy, Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: cust_core::DeviceCopy,
{ {
} }

View File

@ -17,10 +17,7 @@ use crate::geometry::Point;
/// A translation. /// A translation.
#[repr(C)] #[repr(C)]
#[cfg_attr( #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
all(not(target_os = "cuda"), feature = "cuda"),
derive(cust::DeviceCopy)
)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Translation<T, const D: usize> { pub struct Translation<T, const D: usize> {
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is /// The translation coordinates, i.e., how much is added to a point's coordinates when it is

View File

@ -31,8 +31,8 @@ use std::cmp::{Eq, PartialEq};
/// * [Conversion to a matrix <span style="float:right;">`to_rotation_matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix) /// * [Conversion to a matrix <span style="float:right;">`to_rotation_matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
pub type UnitComplex<T> = Unit<Complex<T>>; pub type UnitComplex<T> = Unit<Complex<T>>;
#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] #[cfg(feature = "cuda")]
unsafe impl<T: cust::memory::DeviceCopy> cust::memory::DeviceCopy for UnitComplex<T> {} unsafe impl<T: cust_core::DeviceCopy> cust_core::DeviceCopy for UnitComplex<T> {}
impl<T: Scalar + PartialEq> PartialEq for UnitComplex<T> { impl<T: Scalar + PartialEq> PartialEq for UnitComplex<T> {
#[inline] #[inline]