Skip to content

Commit 41bffa5

Browse files
committed
Explicitly fitting Device[Const|Mut]Ref into device registers
1 parent 03db199 commit 41bffa5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/safety/register_fit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@ pub trait FitsIntoDeviceRegister: private::FitsIntoDeviceRegister {}
22
impl<T: private::FitsIntoDeviceRegister> FitsIntoDeviceRegister for T {}
33

44
mod private {
5+
#[marker]
56
pub trait FitsIntoDeviceRegister {}
67
impl<T> FitsIntoDeviceRegister for T where
78
AssertTypeFitsInto64Bits<{ TypeSize::check::<T>() }>: FitsInto64Bits
89
{
910
}
1011

12+
// Since T: Sized, the pointers are thin, and must thus fit into device
13+
// registers
14+
impl<'r, T: rustacuda_core::DeviceCopy + 'r> FitsIntoDeviceRegister
15+
for crate::common::DeviceConstRef<'r, T>
16+
{
17+
}
18+
impl<'r, T: rustacuda_core::DeviceCopy + 'r> FitsIntoDeviceRegister
19+
for crate::common::DeviceMutRef<'r, T>
20+
{
21+
}
22+
1123
#[derive(PartialEq, Eq)]
1224
pub enum TypeSize {
1325
TypeFitsInto64Bits,

0 commit comments

Comments
 (0)