From 16bdbabd91b69fc0c5d032293599ab7c5e72fbfe Mon Sep 17 00:00:00 2001 From: Russel Arbore <russel.jma@gmail.com> Date: Tue, 18 Feb 2025 18:04:51 -0600 Subject: [PATCH] bruh --- hercules_rt/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hercules_rt/src/lib.rs b/hercules_rt/src/lib.rs index a245a264..090a38a0 100644 --- a/hercules_rt/src/lib.rs +++ b/hercules_rt/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(once_cell_try, pointer_is_aligned_to)] +#![feature(once_cell_try)] use std::alloc::{alloc, dealloc, GlobalAlloc, Layout, System}; use std::marker::PhantomData; @@ -189,7 +189,6 @@ pub struct CUDABox { impl<'a> HerculesCPURef<'a> { pub fn from_slice<T>(slice: &'a [T]) -> Self { - assert!(slice.as_ptr().is_aligned_to(LARGEST_ALIGNMENT)); let ptr = unsafe { NonNull::new_unchecked(slice.as_ptr() as *mut u8) }; let size = slice.len() * size_of::<T>(); Self { @@ -202,6 +201,7 @@ impl<'a> HerculesCPURef<'a> { pub fn as_slice<T>(self) -> &'a [T] { let ptr = self.ptr.as_ptr() as *const T; assert_eq!(self.size % size_of::<T>(), 0); + assert!(ptr.is_aligned()); unsafe { from_raw_parts(ptr, self.size / size_of::<T>()) } } @@ -214,7 +214,6 @@ impl<'a> HerculesCPURef<'a> { } pub unsafe fn __from_parts(ptr: *mut u8, size: usize) -> Self { - assert!(ptr.is_aligned_to(LARGEST_ALIGNMENT)); Self { ptr: NonNull::new(ptr).unwrap(), size, @@ -225,7 +224,6 @@ impl<'a> HerculesCPURef<'a> { impl<'a> HerculesCPURefMut<'a> { pub fn from_slice<T>(slice: &'a mut [T]) -> Self { - assert!(slice.as_ptr().is_aligned_to(LARGEST_ALIGNMENT)); let ptr = unsafe { NonNull::new_unchecked(slice.as_ptr() as *mut u8) }; let size = slice.len() * size_of::<T>(); Self { @@ -259,7 +257,6 @@ impl<'a> HerculesCPURefMut<'a> { } pub unsafe fn __from_parts(ptr: *mut u8, size: usize) -> Self { - assert!(ptr.is_aligned_to(LARGEST_ALIGNMENT)); Self { ptr: NonNull::new(ptr).unwrap(), size, @@ -271,7 +268,6 @@ impl<'a> HerculesCPURefMut<'a> { #[cfg(feature = "cuda")] impl<'a> HerculesCUDARef<'a> { pub fn to_cpu_ref<'b, T>(self, dst: &'b mut [T]) -> HerculesCPURefMut<'b> { - assert!(dst.as_ptr().is_aligned_to(LARGEST_ALIGNMENT)); unsafe { let size = self.size; assert_eq!(size, dst.len() * size_of::<T>()); @@ -313,7 +309,6 @@ impl<'a> HerculesCUDARefMut<'a> { } pub fn to_cpu_ref<'b, T>(self, dst: &mut [T]) -> HerculesCPURefMut<'b> { - assert!(dst.as_ptr().is_aligned_to(LARGEST_ALIGNMENT)); unsafe { let size = self.size; let ptr = NonNull::new(dst.as_ptr() as *mut u8).unwrap(); -- GitLab