Code Monkey home page Code Monkey logo

Comments (5)

PeterJensen avatar PeterJensen commented on July 16, 2024

This can be accomplished with a Float32x4Array overlay, for example:

  var f32Array   = new Float32Array(100);
  var f32x4Array = new Float32x4Array(f32Array.buffer)
  var f32x4      = f32x4Array.getAt(1)

the .getAt(1) will load 4 float32 values into f32x4 from f32Array starting at index 4.

If a second parameter is given to the Float32x4Array constructor it indicates the byte offset into the data buffer. Right now, it must be a multiple of 16, so it's not possible to get to elements that doesn't start at a multiple of 4 index. Is that really needed, you think?

from ecmascript_simd.

fenghaitao avatar fenghaitao commented on July 16, 2024

It seems that DataView(buffer, byteOffset, byteLength) could accomplish what you want. Currently we have not implemented DataView API for float32x4 and int32x4.

from ecmascript_simd.

johnmccutchan avatar johnmccutchan commented on July 16, 2024

Peter and Haitao are correct. The expectation is that the specification will include new typed array views for each SIMD-128 type. For example, Float32x4Array and Int32x4Array. These arrays will have the same alignment (natural byte alignment) restrictions that existing typed arrays have. To complement the arrays and fully extend the Typed Array specification, the DataView class is extended with a getter and a setter for each SIMD-128 type. For example:

float32x4 getFloat32x4(unsigned long byteOffset, optional boolean littleEndian);
void setFloat32x4(unsigned long byteOffset, float32x4 value, optional boolean littleEndian);

Setters and getters on DataView have no alignment restrictions for byteOffsets.

from ecmascript_simd.

johnmccutchan avatar johnmccutchan commented on July 16, 2024

https://www.khronos.org/registry/typedarray/specs/latest/

from ecmascript_simd.

sunfishcode avatar sunfishcode commented on July 16, 2024

We now have load and store which perform this task.

from ecmascript_simd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.