Argument startup Initialiser

//
// Argument Startup code
//
var _length = 2048;
var set_a = [];
var set_b = [];
for(var n = 0; n < _length; n++) {
	var randA = Math.random()*100.0;
	var randB = Math.random()*100.0;
	set_a.push(randA);
	set_b.push(randB);
}

GPU.JS benchmarkCode

//
// GPU.JS setup code
//
// mode = "auto" / "gpu" / "cpu".
// For automatic detection, GPU only mode, or CPU only mode
//
function benchmarkCode(mode) {
	var runFunction = GPU(function(a, b) {
		var res = 0.0;
		var i = 0.0;
		for(i = 0.0; i < 500000; ++i) {
			res += Math.sqrt( a[this.thread.x] * b[this.thread.x] );
		}
		 
		return res;
	}, {
		dimensions : [2048],
		mode : mode
	});
	
	// Execute the compiled GPU.JS script
	c = runFunction(set_a, set_b);
}

GPU.JS benchmark run

bench(function(){
	setupBenchCode('gpu');
}, 10, [], this);

GPU.JS (CPU fallback) benchmark run

bench(function(){
	setupBenchCode('cpu');
}, 10, [], this);