Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
arrayfire_js
Advanced tools
The old arrayfire_js
module will be available on the npm for a while.
Please follow this issue for tracking the progress towards release of 1.0.0-beta.
"ArrayFire is a high performance software library for parallel computing with an easy-to-use API. Its array based function set makes parallel programming more accessible."
You can read its introduction int its documentation's index page. It's basically a math accelerator C++ library supporting CPU and GPU based backends on Windows, Linux and Mac. And it's just awesome. It's extremely simple to write the most complex mathematical, statistical, logical computations, image transformations and computer vision algorigthms with it, just a few lines of code. It has excellent batching capability that takes simple operations, make a big computation from them, and runs all at once on the GPU device.
ArrayFire.js is the Node.js bindings for ArrayFire, it uses CMake.js as of its build system. It takes Node.js' insane level of productivity and mix that with ArrayFire's insane level of performance and simplicity. You'll get something like Matlab just in familiar JavaScript with performance level of x100+ compared to V8 computation preformance (with a good GPU).
%AF_PATH%\lib
directory to PATH on Windows!Before installing location of the ArrayFire installation directory have to be configured for CMake.js. There are two options:
1. Using npm config
for current user:
npm config set cmake_af_path "path_to_arrayfire_installation_directory"
for all users (global)
npm config set cmake_af_path "path_to_arrayfire_installation_directory" --global
2. Setting AF_PATH environment variable
AF_PATH="path_to_arrayfire_installation_directory"
On Windows the installer do this for you, so there is nothing to do on this platform, though.
The above have to be done only once. After you can install ArrayFire.js from the npm:
npm install arrayfire_js --save
// CPU
var af = require("arrayfire_js")("CPU");
// OpenCL
var af = require("arrayfire_js")("OpenCL");
// CUDA
var af = require("arrayfire_js")("CUDA");
Port of the PI calculator from ArrayFire documentation:
C++
// sample 40 million points on the GPU
array x = randu(20e6), y = randu(20e6);
array dist = sqrt(x * x + y * y);
// pi is ratio of how many fell in the unit circle
float num_inside = sum<float>(dist < 1);
float pi = 4.0 * num_inside / 20e6;
af_print(pi);
JavaScript
Notice: Remember, in Node.js everything that blocks or might blocks should be asynchronous, so it is advised to call asynchronous variants of ArrayFire.js functions, however there are synchronous counterparts available too for supporting REPL scenarios. (I suggest use ES6 generators instead of callback hell or even instead of bare promises).
const numberOfPoints = 20000000;
// ...
let x = af.randu(numberOfPoints, af.dtype.f32);
let y = af.randu(numberOfPoints, af.dtype.f32);
let dist = af.sqrt(x.mul(x).add(y.mul(y)));
let numInside = yield af.sumAsync(dist.lt(1));
let piVal = (4.0 * numInside) / numberOfPoints;
console.log(`PI = ${piVal}`);
It's included in the examples folder. To run on:
iojs examples/es6/bechmarks/pi.js
node --harmony examples/es6/bechmarks/pi.js
node examples/es5/bechmarks/pi.js
There is an example of a neural network with batch backpropagation trained to learn the famous MNIST data set. It will run on the fastest device available.
It's in the examples folder. To run on:
iojs examples/es6/machine-learning/neuralNetwork.js
node --harmony examples/es6/machine-learning/neuralNetwork.js
node examples/es5/machine-learning/neuralNetwork.js
Performance on Linux Mint x64, i5 3570, Radeon R9:
http://arrayfire.github.io/arrayfire_js
PRs are welcome, but please read the Contributing Guide first.
Copyright (c) 2014-2015, ArrayFire
Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the ArrayFire nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FAQs
ArrayFire.js - ArrayFire for Node.js platform
We found that arrayfire_js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.