mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
18 lines
492 B
JavaScript
18 lines
492 B
JavaScript
const { GPU } = require('../src');
|
|
const gpu1 = new GPU();
|
|
|
|
const kernel1 = gpu1.createKernel(function(value) {
|
|
return value * 100;
|
|
}, { output: [1] });
|
|
|
|
const resultFromRegularKernel = kernel1(42);
|
|
const json = kernel1.toJSON();
|
|
console.log(resultFromRegularKernel);
|
|
|
|
// Use bin/gpu-browser-core.js to get "CORE" mode, which works only with JSON
|
|
const gpu2 = new GPU();
|
|
const kernel2 = gpu2.createKernel(json);
|
|
const resultFromJsonKernel = kernel2(42);
|
|
console.log(resultFromJsonKernel);
|
|
|