-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(simd): add clampn4_f32, sum4_f32
- Loading branch information
1 parent
80f1a0e
commit 0e0dfde
Showing
5 changed files
with
41 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 |
---|---|---|
|
@@ -25,3 +25,4 @@ export * from "./normalize"; | |
|
||
export * from "./sub"; | ||
export * from "./subn"; | ||
export * from "./sum"; |
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,10 @@ | ||
export function sum4_f32(a: usize, num: usize, sa: usize): f64 { | ||
sa <<= 2; | ||
let acc = f32x4.splat(0); | ||
for (; num-- > 0; ) { | ||
acc = f32x4.add(acc, v128.load(a)); | ||
a += sa; | ||
} | ||
acc = f32x4.add(acc, v128.shuffle<f32>(acc, acc, 2, 3, 0, 1)); | ||
return f32x4.extract_lane(acc, 0) + f32x4.extract_lane(acc, 1); | ||
} |
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