diff --git a/Cargo.toml b/Cargo.toml index 0adc5729..8a3fea5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ compare = [ "matrixcompare-core" ] libm = [ "simba/libm" ] libm-force = [ "simba/libm_force" ] macros = [ "nalgebra-macros" ] -cuda = [ "cust", "simba/cuda" ] +cuda = [ "cust_core", "simba/cuda" ] # Conversion convert-mint = [ "mint" ] @@ -96,9 +96,7 @@ glam017 = { package = "glam", version = "0.17", optional = true } glam018 = { package = "glam", version = "0.18", optional = true } glam019 = { package = "glam", version = "0.19", optional = true } glam020 = { package = "glam", version = "0.20", optional = true } - -[target.'cfg(not(target_os = "cuda"))'.dependencies] -cust = { version = "0.3", optional = true } +cust_core = { version = "0.1", optional = true } [dev-dependencies] diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 6851c381..b6bd236a 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -27,10 +27,7 @@ use std::mem; /// A array-based statically sized matrix data storage. #[repr(transparent)] #[derive(Copy, Clone, PartialEq, Eq, Hash)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct ArrayStorage(pub [[T; R]; C]); impl ArrayStorage { diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 86006f3d..e43cb734 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -13,10 +13,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Dim of dynamically-sized algebraic entities. #[derive(Clone, Copy, Eq, PartialEq, Debug)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Dynamic { value: usize, } @@ -201,10 +198,7 @@ dim_ops!( ); #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Const; /// Trait implemented exclusively by type-level integers. diff --git a/src/base/matrix.rs b/src/base/matrix.rs index bdf3a8c7..cc69c9a1 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -150,10 +150,7 @@ pub type MatrixCross = /// some concrete types for `T` and a compatible data storage type `S`). #[repr(C)] #[derive(Clone, Copy)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Matrix { /// The data storage that contains all the matrix components. Disappointed? /// diff --git a/src/base/unit.rs b/src/base/unit.rs index 9336a5e5..bb8b56a1 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -21,10 +21,7 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF /// in their documentation, read their dedicated pages directly. #[repr(transparent)] #[derive(Clone, Hash, Copy)] -// #[cfg_attr( -// all(not(target_os = "cuda"), feature = "cuda"), -// derive(cust::DeviceCopy) -// )] +// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Unit { pub(crate) value: T, } @@ -102,9 +99,8 @@ mod rkyv_impl { } } -#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] -unsafe impl cust::memory::DeviceCopy - for Unit> +#[cfg(feature = "cuda")] +unsafe impl cust_core::DeviceCopy for Unit> where T: Scalar, R: Dim, diff --git a/src/geometry/dual_quaternion.rs b/src/geometry/dual_quaternion.rs index 4280668a..509b359a 100644 --- a/src/geometry/dual_quaternion.rs +++ b/src/geometry/dual_quaternion.rs @@ -39,10 +39,7 @@ use simba::scalar::{ClosedNeg, RealField}; /// See #[repr(C)] #[derive(Debug, Copy, Clone)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct DualQuaternion { /// The real component of the quaternion pub real: Quaternion, diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 8cdd1bfc..0179f1ff 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -50,10 +50,7 @@ use crate::geometry::{AbstractRotation, Point, Translation}; /// #[repr(C)] #[derive(Debug, Copy, Clone)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", diff --git a/src/geometry/orthographic.rs b/src/geometry/orthographic.rs index 18a7852d..085ba61b 100644 --- a/src/geometry/orthographic.rs +++ b/src/geometry/orthographic.rs @@ -19,10 +19,7 @@ use crate::geometry::{Point3, Projective3}; /// A 3D orthographic projection stored as a homogeneous 4x4 matrix. #[repr(C)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone)] pub struct Orthographic3 { matrix: Matrix4, diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index 59b7f9f2..8ebab3e4 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -20,10 +20,7 @@ use crate::geometry::{Point3, Projective3}; /// A 3D perspective projection stored as a homogeneous 4x4 matrix. #[repr(C)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone)] pub struct Perspective3 { matrix: Matrix4, diff --git a/src/geometry/point.rs b/src/geometry/point.rs index b62998c3..a8d7684b 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -69,12 +69,11 @@ where { } -#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] -unsafe impl cust::memory::DeviceCopy - for OPoint +#[cfg(feature = "cuda")] +unsafe impl cust_core::DeviceCopy for OPoint where DefaultAllocator: Allocator, - OVector: cust::memory::DeviceCopy, + OVector: cust_core::DeviceCopy, { } diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 0aa7f3d3..6d29f34f 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -23,10 +23,7 @@ use crate::geometry::{Point3, Rotation}; /// that may be used as a rotation. #[repr(C)] #[derive(Copy, Clone)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct Quaternion { /// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order. pub coords: Vector4, @@ -1045,8 +1042,8 @@ impl fmt::Display for Quaternion { /// A unit quaternions. May be used to represent a rotation. pub type UnitQuaternion = Unit>; -#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] -unsafe impl cust::memory::DeviceCopy for UnitQuaternion {} +#[cfg(feature = "cuda")] +unsafe impl cust_core::DeviceCopy for UnitQuaternion {} impl PartialEq for UnitQuaternion { #[inline] diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 69c4a355..4dbcfb43 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -49,10 +49,7 @@ use crate::geometry::Point; /// * [Conversion to a matrix `matrix`, `to_homogeneous`…](#conversion-to-a-matrix) /// #[repr(C)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone)] pub struct Rotation { matrix: SMatrix, diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index 064e0075..abaeeccc 100755 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -17,10 +17,7 @@ use crate::geometry::Point; /// A scale which supports non-uniform scaling. #[repr(C)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone)] pub struct Scale { /// The scale coordinates, i.e., how much is multiplied to a point's coordinates when it is diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index 46c86f5d..9658685e 100755 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -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. #[repr(C)] #[derive(Debug, Copy, Clone)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde-serialize-no-std", diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index b0b5cced..2a7ca112 100755 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -60,26 +60,17 @@ where /// Tag representing the most general (not necessarily inversible) `Transform` type. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub enum TGeneral {} /// Tag representing the most general inversible `Transform` type. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub enum TProjective {} /// Tag representing an affine `Transform`. Its bottom-row is equal to `(0, 0 ... 0, 1)`. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub enum TAffine {} impl TCategory for TGeneral { @@ -207,13 +198,13 @@ where { } -#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] -unsafe impl - cust::memory::DeviceCopy for Transform +#[cfg(feature = "cuda")] +unsafe impl + cust_core::DeviceCopy for Transform where Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, - Owned, U1>, DimNameSum, U1>>: cust::memory::DeviceCopy, + Owned, U1>, DimNameSum, U1>>: cust_core::DeviceCopy, { } diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index b07cce20..5db46e82 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -17,10 +17,7 @@ use crate::geometry::Point; /// A translation. #[repr(C)] -#[cfg_attr( - all(not(target_os = "cuda"), feature = "cuda"), - derive(cust::DeviceCopy) -)] +#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone)] pub struct Translation { /// The translation coordinates, i.e., how much is added to a point's coordinates when it is diff --git a/src/geometry/unit_complex.rs b/src/geometry/unit_complex.rs index 48405dd4..caf25493 100755 --- a/src/geometry/unit_complex.rs +++ b/src/geometry/unit_complex.rs @@ -31,8 +31,8 @@ use std::cmp::{Eq, PartialEq}; /// * [Conversion to a matrix `to_rotation_matrix`, `to_homogeneous`…](#conversion-to-a-matrix) pub type UnitComplex = Unit>; -#[cfg(all(not(target_os = "cuda"), feature = "cuda"))] -unsafe impl cust::memory::DeviceCopy for UnitComplex {} +#[cfg(feature = "cuda")] +unsafe impl cust_core::DeviceCopy for UnitComplex {} impl PartialEq for UnitComplex { #[inline]