Skip to content
Snippets Groups Projects
Commit d71ec87a authored by Russel Arbore's avatar Russel Arbore
Browse files

increase alignment of AlignedSlice

parent 5cee37ad
No related branches found
No related tags found
1 merge request!199Fix type layout
Pipeline #201867 failed
This commit is part of merge request !199. Comments created here will be created in the context of that merge request.
......@@ -20,11 +20,11 @@ pub const VAR_DENSITY_ENERGY: usize = VAR_MOMENTUM + NDIM;
pub const NVAR: usize = VAR_DENSITY_ENERGY + 1;
pub const deg_angle_of_attack: f32 = 0.0;
#[repr(align(32))]
struct Alignment([u8; 32]);
#[repr(align(64))]
struct Alignment([u8; 64]);
// An aligned slice is stored as a boxed slice and an offset number of elements
// that we skip over to get the desired alignment (of 32 bytes)
// that we skip over to get the desired alignment (of 64 bytes)
pub struct AlignedSlice<T> {
slice: Box<[T]>,
offset: usize,
......@@ -37,8 +37,8 @@ where
{
pub fn of_len(len: usize) -> Self {
// The maximum number of elements that may be waisted in getting the alignment we need is
// (32 - alignment of T) / size of T
let extra_elements = (32 - std::mem::align_of::<T>()) / std::mem::size_of::<T>();
// (64 - alignment of T) / size of T
let extra_elements = (64 - std::mem::align_of::<T>()) / std::mem::size_of::<T>();
let slice: Box<[T]> = (0..len + extra_elements)
.map(|_| Default::default())
.collect();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment