Skip to content

Instantly share code, notes, and snippets.

@mganeko
Last active August 29, 2015 14:26
Show Gist options
  • Save mganeko/d893d51158e0aff443d4 to your computer and use it in GitHub Desktop.
Save mganeko/d893d51158e0aff443d4 to your computer and use it in GitHub Desktop.
function logSIMD(arg1, arg2, opt, res) {
console.log(opt + '( ' + arg1.toSource() + ' , ' + arg2.toSource() + ' ) ==> ' + res.toSource());
}
var a = SIMD.Float32x4(1.0,2.0,3.0,4.0);
var b = SIMD.Float32x4(5.0,6.0,7.0,8.0);
var c = SIMD.Float32x4.add(a,b);
//console.log(c.toSource());
logSIMD(a, b, "add", c);
var ar = new Float32Array(4);
SIMD.Float32x4.store(ar, 0, c);
console.log(ar);
c = SIMD.Float32x4.max(a,b);
logSIMD(a, b, "max", c);
c = SIMD.Float32x4.maxNum(a,b);
logSIMD(a, b, "maxNum", c);
var x = SIMD.Int32x4(1, 2, 4, 8);
var y = SIMD.Int32x4(128, 64, 32, 16);
var z = SIMD.Int32x4.mul(x, y);
logSIMD(x, y, "mul", z);
c = SIMD.Float32x4.div(a,b);
logSIMD(a, b, "div", c);
x = SIMD.Int32x4(1, 2, 4, 8);
y = SIMD.Int32x4(128, 64, 32, 16);
// ERROR for Int: not a function
//z = SIMD.Int32x4.div(y, x);
//logSIMD(y, x, "div", z);
// ERROR for Int: not a function
//z = SIMD.Int32x4.max(x, y);
//logSIMD(x, y, "max", z);
// ERROR for Int: not a function
//z = SIMD.Int32x4.maxNum(x, y);
//logSIMD(x, y, "maxNum", z);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment