-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::f16; | ||
|
||
ew_impl_wrap!( | ||
f16, | ||
arm64fp16_mul_by_scalar_f16_32n, | ||
32, | ||
4, | ||
f16, | ||
fn run(buf: &mut [f16], s: f16) { | ||
assert!(buf.len() % 16 == 0); | ||
assert!(buf.len() > 0); | ||
#[target_feature(enable = "fp16")] | ||
unsafe fn run(buf: &mut[f16], s: f16) { | ||
let len = buf.len(); | ||
let ptr = buf.as_ptr(); | ||
std::arch::asm!(" | ||
dup v0.8h, v0.h[0] | ||
1: | ||
ld1 {{v4.8h, v5.8h, v6.8h, v7.8h}}, [{ptr}] | ||
fmul v4.8h, v4.8h, v0.8h | ||
fmul v5.8h, v5.8h, v0.8h | ||
fmul v6.8h, v6.8h, v0.8h | ||
fmul v7.8h, v7.8h, v0.8h | ||
st1 {{v4.8h, v5.8h, v6.8h, v7.8h}}, [{ptr}], 64 | ||
subs {len}, {len}, 32 | ||
bne 1b | ||
", | ||
len = inout(reg) len => _, | ||
ptr = inout(reg) ptr => _, | ||
in("v0") s.to_bits(), | ||
out("v4") _, out("v5") _, out("v6") _, out("v7") _,); | ||
} | ||
unsafe { run(buf, s) } | ||
} | ||
); | ||
|
||
#[cfg(test)] | ||
mod test_arm64fp16_mul_by_scalar_f16_32n { | ||
use super::*; | ||
mul_by_scalar_frame_tests!(crate::arm64::has_fp16(), f16, arm64fp16_mul_by_scalar_f16_32n); | ||
} |