Skip to content

Commit

Permalink
Merge pull request #81 from encounter/inline
Browse files Browse the repository at this point in the history
More #[inline] in HalfFloatSliceExt, leading_zeros
  • Loading branch information
starkat99 committed Mar 28, 2023
2 parents 846d0fa + 807f00f commit bec7d30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/leading_zeros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
target_feature = "SPV_INTEL_shader_integer_functions2"
))
))))]
#[inline]
pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
x.leading_zeros()
}
Expand All @@ -18,6 +19,7 @@ pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
target_feature = "SPV_INTEL_shader_integer_functions2"
))
))]
#[inline]
pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
leading_zeros_u16_fallback(x)
}
Expand All @@ -32,6 +34,7 @@ pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
))
)
))]
#[inline]
const fn leading_zeros_u16_fallback(mut x: u16) -> u32 {
use crunchy::unroll;
let mut c = 0;
Expand Down
8 changes: 8 additions & 0 deletions src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ impl HalfFloatSliceExt for [f16] {
unsafe { slice::from_raw_parts_mut(pointer, length) }
}

#[inline]
fn convert_from_f32_slice(&mut self, src: &[f32]) {
assert_eq!(
self.len(),
Expand All @@ -328,6 +329,7 @@ impl HalfFloatSliceExt for [f16] {
arch::f32_to_f16_slice(src, self.reinterpret_cast_mut())
}

#[inline]
fn convert_from_f64_slice(&mut self, src: &[f64]) {
assert_eq!(
self.len(),
Expand All @@ -338,6 +340,7 @@ impl HalfFloatSliceExt for [f16] {
arch::f64_to_f16_slice(src, self.reinterpret_cast_mut())
}

#[inline]
fn convert_to_f32_slice(&self, dst: &mut [f32]) {
assert_eq!(
self.len(),
Expand All @@ -348,6 +351,7 @@ impl HalfFloatSliceExt for [f16] {
arch::f16_to_f32_slice(self.reinterpret_cast(), dst)
}

#[inline]
fn convert_to_f64_slice(&self, dst: &mut [f64]) {
assert_eq!(
self.len(),
Expand Down Expand Up @@ -404,6 +408,7 @@ impl HalfFloatSliceExt for [bf16] {
unsafe { slice::from_raw_parts_mut(pointer, length) }
}

#[inline]
fn convert_from_f32_slice(&mut self, src: &[f32]) {
assert_eq!(
self.len(),
Expand All @@ -417,6 +422,7 @@ impl HalfFloatSliceExt for [bf16] {
}
}

#[inline]
fn convert_from_f64_slice(&mut self, src: &[f64]) {
assert_eq!(
self.len(),
Expand All @@ -430,6 +436,7 @@ impl HalfFloatSliceExt for [bf16] {
}
}

#[inline]
fn convert_to_f32_slice(&self, dst: &mut [f32]) {
assert_eq!(
self.len(),
Expand All @@ -443,6 +450,7 @@ impl HalfFloatSliceExt for [bf16] {
}
}

#[inline]
fn convert_to_f64_slice(&self, dst: &mut [f64]) {
assert_eq!(
self.len(),
Expand Down

0 comments on commit bec7d30

Please sign in to comment.