Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created July 28, 2015 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edvakf/583f9b7b116f8982716d to your computer and use it in GitHub Desktop.
Save edvakf/583f9b7b116f8982716d to your computer and use it in GitHub Desktop.
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(SIMD.Float32x4.extractLane(c, 0));
console.log(SIMD.Float32x4.extractLane(c, 1));
console.log(SIMD.Float32x4.extractLane(c, 2));
console.log(SIMD.Float32x4.extractLane(c, 3));
var a = SIMD.Int32x4(1,2,3,4);
var b = SIMD.Int32x4(5,6,7,8);
var c = SIMD.Int32x4.add(a,b);
console.log(SIMD.Int32x4.extractLane(c, 0));
console.log(SIMD.Int32x4.extractLane(c, 1));
console.log(SIMD.Int32x4.extractLane(c, 2));
console.log(SIMD.Int32x4.extractLane(c, 3));
var a = SIMD.Float64x2(1.0,2.0);
var b = SIMD.Float64x2(5.0,6.0);
var c = SIMD.Float64x2.add(a,b);
console.log(SIMD.Float64x2.extractLane(c, 0));
console.log(SIMD.Float64x2.extractLane(c, 1));
var N = 16;
var ary = new Int32Array(N);
for (var i = 0; i < N; i++) {
ary[i] = i;
}
var a = SIMD.Int32x4.load(ary, 0);
var b = SIMD.Int32x4.load(ary, 4);
var c = SIMD.Int32x4.add(a, b);
SIMD.Int32x4.store(ary, 8, c);
console.log(ary);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment