Skip to content
Snippets Groups Projects

Set up cava benchmark

Merged rarbore2 requested to merge cava_opt_3 into main
3 files
+ 12
32
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 22
1
#![feature(once_cell_try)]
use std::alloc::{alloc, dealloc, Layout};
use std::alloc::{alloc, dealloc, GlobalAlloc, Layout, System};
use std::marker::PhantomData;
use std::ptr::{copy_nonoverlapping, write_bytes, NonNull};
use std::slice::{from_raw_parts, from_raw_parts_mut};
@@ -867,3 +867,24 @@ impl<'a, T> HerculesRefInto<'a> for Box<[T]> {
HerculesCPURef::from_slice(self)
}
}
/*
* We need all allocations to be aligned to LARGEST_ALIGNMENT bytes for
* vectorization. This is the easiest way to do that.
*/
pub struct AlignedAlloc;
unsafe impl GlobalAlloc for AlignedAlloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
let layout = layout.align_to(LARGEST_ALIGNMENT).unwrap();
System.alloc(layout)
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
let layout = layout.align_to(LARGEST_ALIGNMENT).unwrap();
System.dealloc(ptr, layout)
}
}
#[global_allocator]
static A: AlignedAlloc = AlignedAlloc;
Loading