-
-
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 mag2/4, magsq2/4, move/extract inline fns, update tes…
…ts, readme
- Loading branch information
1 parent
d09f09e
commit 00ce05b
Showing
11 changed files
with
126 additions
and
10 deletions.
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
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,13 @@ | ||
import { __hadd2_f32, __hadd4_f32 } from "./hadd"; | ||
|
||
// @ts-ignore: decorator | ||
@inline | ||
export function __magsq2(v: v128): v128 { | ||
return __hadd2_f32(f32x4.mul(v, v)); | ||
} | ||
|
||
// @ts-ignore: decorator | ||
@inline | ||
export function __magsq4(v: v128): f32 { | ||
return __hadd4_f32(f32x4.mul(v, v)); | ||
} |
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,32 @@ | ||
import { __magsq2, __magsq4 } from "./inline/magsq"; | ||
|
||
export function mag2_f32_aos(out: usize, a: usize, num: usize): usize { | ||
const res = out; | ||
num >>= 1; | ||
for (; num-- > 0; ) { | ||
const v = __magsq2(v128.load(a)); | ||
f32.store(out, sqrt(f32x4.extract_lane(v, 0))); | ||
f32.store(out, sqrt(f32x4.extract_lane(v, 2)), 4); | ||
out += 8; | ||
a += 16; | ||
} | ||
return res; | ||
} | ||
|
||
export function mag4_f32_aos( | ||
out: usize, | ||
a: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize | ||
): usize { | ||
const res = out; | ||
so <<= 2; | ||
sa <<= 2; | ||
for (; num-- > 0; ) { | ||
f32.store(out, sqrt(__magsq4(v128.load(a)))); | ||
out += so; | ||
a += sa; | ||
} | ||
return res; | ||
} |
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,32 @@ | ||
import { __magsq2, __magsq4 } from "./inline/magsq"; | ||
|
||
export function magsq2_f32_aos(out: usize, a: usize, num: usize): usize { | ||
const res = out; | ||
num >>= 1; | ||
for (; num-- > 0; ) { | ||
const v = __magsq2(v128.load(a)); | ||
f32.store(out, f32x4.extract_lane(v, 0)); | ||
f32.store(out, f32x4.extract_lane(v, 2), 4); | ||
out += 8; | ||
a += 16; | ||
} | ||
return res; | ||
} | ||
|
||
export function magsq4_f32_aos( | ||
out: usize, | ||
a: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize | ||
): usize { | ||
const res = out; | ||
so <<= 2; | ||
sa <<= 2; | ||
for (; num-- > 0; ) { | ||
f32.store(out, __magsq4(v128.load(a))); | ||
out += so; | ||
a += sa; | ||
} | ||
return res; | ||
} |
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
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