W3cubDocs

/JavaScript

SIMD.load

SIMD.js has been taken out of active development in TC39 and removed from Stage 3. It is not being pursued by web browsers for implementation anymore. SIMD operations exposed to the web are under active development within WebAssembly, with operations based on the SIMD.js operations.

The static SIMD.%type%.load() methods create a new SIMD data type with the lane values loaded from a typed array.

Syntax

SIMD.Float64x2.load(tarray, index)
SIMD.Float64x2.load1(tarray, index)

SIMD.Float32x4.load(tarray, index)
SIMD.Float32x4.load1(tarray, index)
SIMD.Float32x4.load2(tarray, index)
SIMD.Float32x4.load3(tarray, index)

SIMD.Int32x4.load(tarray, index)
SIMD.Int32x4.load1(tarray, index)
SIMD.Int32x4.load2(tarray, index)
SIMD.Int32x4.load3(tarray, index)

SIMD.Uint32x4.load(tarray, index)
SIMD.Uint32x4.load1(tarray, index)
SIMD.Uint32x4.load2(tarray, index)
SIMD.Uint32x4.load3(tarray, index) 

SIMD.Int8x16.load(tarray, index)
SIMD.Int16x8.load(tarray, index)

SIMD.Uint8x16.load(tarray, index) 
SIMD.Uint16x8.load(tarray, index)

Parameters

tarray
An instance of a typed array. This can be one of:
index
A number for the index from where to start loading in the typed array.

Return value

A new SIMD data type.

Exceptions

  • If index is out of range, for example SIMD.Int32x4.load(tarray, -1) or bigger than the size of tarray, a RangeError is thrown.
  • If tarray is not one of the typed array types, for example SIMD.Int32x4.load(tarray.buffer, 0) (an array buffer is not valid), a TypeError is thrown.

Description

The SIMD load and store methods intermix with typed arrays. With load, you can pass in typed arrays into SIMD types and with store, SIMD data can be stored into typed arrays.

You can either load all lane values using load(), or only load one, two or three lane values with the methods load1(), load2() or load3().

Examples

The following examples use an Int32Array loaded into a SIMD.Int32x4 data type.

Loading all values

var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load(a, 0);
// Int32x4[1,2,3,4]

var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load(a, 2);
// Int32x4[3,4,5,6]

Loading a single value

var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load1(a, 0);
// Int32x4[1,0,0,0]

var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load1(a, 2);
// Int32x4[3,0,0,0]

Loading two values

var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load2(a, 0);
// Int32x4[1,2,0,0]

var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load2(a, 2);
// Int32x4[3,4,0,0]

Loading three values

var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load3(a, 0);
// Int32x4[1,2,3,0]

var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load3(a, 2);
// Int32x4[3,4,5,0]

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.load' in that specification.
Obsolete Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build No support No support No support

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD/load