-
-
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 new fns, switch to f32x4 namespaced ops, update readme
- Loading branch information
1 parent
8b7287e
commit 4023a8f
Showing
13 changed files
with
268 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function add4_f32( | ||
out: usize, | ||
a: usize, | ||
b: usize, | ||
num: usize, | ||
so: usize = 4, | ||
sa: usize = 4, | ||
sb: usize = 4 | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
sb <<= 2; | ||
const res = out; | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.add(v128.load(a), v128.load(b))); | ||
out += so; | ||
a += sa; | ||
b += sb; | ||
} | ||
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,21 @@ | ||
export function div4_f32( | ||
out: usize, | ||
a: usize, | ||
b: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize, | ||
sb: usize | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
sb <<= 2; | ||
const res = out; | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.div(v128.load(a), v128.load(b))); | ||
out += so; | ||
a += sa; | ||
b += sb; | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
export * from "./add"; | ||
|
||
// TODO waiting for native impl | ||
// export * from "./div"; | ||
|
||
export * from "./dot"; | ||
export * from "./madd"; | ||
export * from "./maddn"; | ||
export * from "./mul"; | ||
export * from "./mulv"; | ||
export * from "./sub"; | ||
|
||
// TODO waiting for native impl | ||
// export * from "./sqrt"; |
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,21 @@ | ||
export function mul4_f32( | ||
out: usize, | ||
a: usize, | ||
b: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize, | ||
sb: usize | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
sb <<= 2; | ||
const res = out; | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.mul(v128.load(a), v128.load(b))); | ||
out += so; | ||
a += sa; | ||
b += sb; | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export function sqrt4_f32( | ||
out: usize, | ||
a: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
const res = out; | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.sqrt(v128.load(a))); | ||
out += so; | ||
a += sa; | ||
} | ||
return res; | ||
} | ||
|
||
export function invsqrt4_f32( | ||
out: usize, | ||
a: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
const res = out; | ||
const one = f32x4.splat(1); | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.div(one, f32x4.sqrt(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,21 @@ | ||
export function sub4_f32( | ||
out: usize, | ||
a: usize, | ||
b: usize, | ||
num: usize, | ||
so: usize, | ||
sa: usize, | ||
sb: usize | ||
): usize { | ||
so <<= 2; | ||
sa <<= 2; | ||
sb <<= 2; | ||
const res = out; | ||
for (; num-- > 0; ) { | ||
v128.store(out, f32x4.sub(v128.load(a), v128.load(b))); | ||
out += so; | ||
a += sa; | ||
b += sb; | ||
} | ||
return res; | ||
} |
Oops, something went wrong.