Published
Edited
Nov 1, 2018
3 stars
Insert cell
Insert cell
Insert cell
W = require("https://bundle.run/webclgl").then(_ => ({
WebCLGL: window.WebCLGL,
gpufor: window.gpufor,
WebCLGLBuffer: window.WebCLGLBuffer,
WebCLGLUtils: window.WebCLGLUtils,
WebCLGLKernel: window.WebCLGLKernel,
WebCLGLVertexFragmentProgram: window.WebCLGLVertexFragmentProgram,
WebCLGLFor: window.WebCLGLFor
}))
Insert cell
{
// TYPICAL A + B WITH CPU
var arrayResult = [];
for(var n = 0; n < _length; n++) {
var sum = arrayA[n]+arrayB[n];
arrayResult[n] = sum;
}
return arrayResult
}

Insert cell
{
// PERFORM A + B WITH GPU
var arrayResult = W.gpufor({"float* A": arrayA, "float* B": arrayB}, "n",
"float sum = A[n]+B[n];"+
"return sum;");
return arrayResult
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more