Vectorize.js is a javascript library for automatically vectorizing javascript using Mozilla's SIMD.js. Vectorize.js works by converting a function to a string, parsing it with Esprima, transforming it to use SIMD vectors, and regenerating the code using Escodegen.
Have a function you want to vectorize? It's as easy as this:
vectorFunction = vectorize.me(scalarFunction);
Currently Vectorize.js supports the following language features for operating on vectors:
- Binary Operators: +, -, *, /, <, <=, ==, >=, >
- Unary Operators: ++, --
- Reductions: +, -, *, /
- Nested loops
We are currently in the process of adding support for:
- Conditionals and Conditional Expressions.
- Inlining and vectorizing function calls.
- min/max operators/reductions.
Vectorize.js relies on the following libraries to process and transform the Javascript:
Javascript is a complicated language with lots of features and hence lots of edge cases! Vectorize.js tries its best to not break your functions but we make no guarantees.