1.0.0-alpha4 • Published 10 years ago

saltmine v1.0.0-alpha4

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

saltmine

Arbitrary computation on the GPU using WebGL.

Very experimental.

Installation

Usage

var saltmine = require('saltmine')
var multiline = require('multiline')

var input = [1,2,3]

var output = saltmine(input, multiline(function(){/*
  return a * 2.0; // double number
*/}))

// Result (Note float precision):
// [
//   2.0000001899999997,
//   4.0000003799999995,
//   6.00000044838664
// ]
var saltmine = require('saltmine')
var multiline = require('multiline')

var a = [1,2,3]
var b = [1,2,3]

var output = saltmine(a, b, multiline(function(){/*
  return a * b;
*/}))

// Result (Note float precision):
// [
//   1.0000000949999999,
//   4.0000003799999995,
//   9.00000042934544
// ]

Caveats

  • Overhead of setup/reading pixels generally makes calculations slower than just doing it on the CPU.

TODO

  • Support more datatypes. Everything is float now. Vectors and matrices possibly better candidates for parallel speedup.

Credit

Massive thanks to the talented @hughsk for pairing with me on this. Saved me from many wrong turns.

License

MIT