Skip to content
Snippets Groups Projects

Set up cava benchmark

Merged rarbore2 requested to merge cava_opt_3 into main
Files
6
+ 22
1
#![feature(once_cell_try)]
#![feature(once_cell_try)]
use std::alloc::{alloc, dealloc, Layout};
use std::alloc::{alloc, dealloc, GlobalAlloc, Layout, System};
use std::marker::PhantomData;
use std::marker::PhantomData;
use std::ptr::{copy_nonoverlapping, write_bytes, NonNull};
use std::ptr::{copy_nonoverlapping, write_bytes, NonNull};
use std::slice::{from_raw_parts, from_raw_parts_mut};
use std::slice::{from_raw_parts, from_raw_parts_mut};
@@ -867,3 +867,24 @@ impl<'a, T> HerculesRefInto<'a> for Box<[T]> {
@@ -867,3 +867,24 @@ impl<'a, T> HerculesRefInto<'a> for Box<[T]> {
HerculesCPURef::from_slice(self)
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