Questions tagged [gpu.js]

JavaScript compiler into shading language

It is a form of writing shading language (which can be understand by GPU) with JavaScript. Form of JS Internal DSL

https://github.com/gpujs/gpu.js

25 questions
6
votes
1 answer

How do I know how many matrix operations a GPU can do in parallel?

I'm using a JS library called GPU.js. Used like so: const gpu = new GPU(); const multiplyMatrix = gpu.createKernel(function(a, b) { let sum = 0; for (let i = 0; i < 512; i++) { sum += a[this.thread.y][i] * b[i][this.thread.x]; } …
J.Todd
  • 707
  • 1
  • 12
  • 34
4
votes
3 answers

GPU Parallelism in Javascript going slower

This is kind of a specific problem. I have recently tested out gpu.js. This library is supposed to accelerate computations by using webgl to parallelize computations. I made a quick test: var gpu = new GPU(); function product(v, u) { return…
user5505266
  • 593
  • 5
  • 20
3
votes
1 answer

gpus.js (webgl?) float32 issue

I'm probably missing something obvious, but i'm experimenting with gpu.js and getting some strange results. I just want to make sure i'm not doing something obviously stupid (which is likely). Not sure if this is an issue with what i'm doing, or the…
llihp
  • 195
  • 1
  • 2
  • 10
2
votes
0 answers

gpu.js "Error: not enough arguments for kernel"

I have some heavily calculating canvas effects in a react app that I'm making. I have been trying to figure out how to do it for about 2 days, and It's almost working but I have this one error that I can't seem to figure out. Here is the code…
2
votes
0 answers

gpu.js in web worker

I'm trying to run gpu.js in a web worker, but can't seem to get it to work at all. I'm running importScripts to load the library within the worker, but I'm not getting the GPU object in the worker context.
llihp
  • 195
  • 1
  • 2
  • 10
1
vote
0 answers

How to implement a for loop inside a combineKernel in GPU.js

I'm new to gpu.js and I need help. Basically I want to access my two kernel functions but I don't know how without sacrificing the expense of calling createKernel each time. I know there is combineKernel but I haven't seen an example where it uses a…
anlo
  • 43
  • 3
1
vote
1 answer

How can I access the values given by gpu.js

I am learning to use gpu.js to do calculations in the GPU. I am able to do my calculations for two JavaScript matrices a and b and to display the result as a canvas image. Question: How can I access the calculated numerical values? The values are…
1
vote
0 answers

how can we use native methods of array in gpu js like length push pop. It gives me an error of unexpected expression

const A = [9, 2]; const test = gpu .createKernel(function (A) { return A.length; }) .setOutput([1]); console.log(test(A)); ERROR: throw this.astErrorOutput('Unexpected expression', ast); ^ Error: Unexpected expression on line 1, position…
1
vote
1 answer

GPU.js calculating distance between multi objects xyz?

I try to write some very fast logic to detect all collisions in game. So I using GPU.js for this and my code was crashing because I trying to create new array variable inside function? I need list of all objects from constant (loaded to GPU/CPU…
Patrick
  • 21
  • 3
1
vote
0 answers

How to efficiently feed the output of a GPU JS function back into it?

I am attempting to use GPU JS to accelerate the performance of a dynamic programming algorithm. Here is my current code: let pixels = new Uint32Array(5 * 5); for (let i = 0; i < pixels.length; i++) { pixels[i] = i; } function kFunction() { let…
Ryan Peschel
  • 11,087
  • 19
  • 74
  • 136
1
vote
0 answers

"Identifier is not defined" when using variable in gpu.js - why?

I am puzzled by an error I get with gpu.js. I am trying to do GPU-based calculations of nearest point on line, as I have to process hundreds of points against a line with thousands of segments. See in-progress code at…
simone
  • 4,667
  • 4
  • 25
  • 47
1
vote
0 answers

How does 'gpu.js' manipulate GPU threads?

I am working on an arbitrary-precision Mandelbrot fractal browser, and I want to take advantage of the GPU in order to do so. However; I don't really want to use anyone else's library for a few different reasons, and when i looked into gpu.js,…
0
votes
0 answers

GPU.js "Array buffer allocation failed" with large arrays

I just started using GPU.js. I'm doing some basic math on an array of numbers, and when I run smaller (~3,000,000 entries in the array) and medium (~65,000,000 entries in the array) datasets, everything works fine, but when I go to larger datasets…
0
votes
0 answers

execute a Javascript function on GPU

I want run a JavaScript function on GPU for fast calculation. I try use gpu.js https://gpu.rocks https://github.com/gpujs/gpu.js My goal is to be able to do some simple array function like "for" "if", or "create variable" to manipulate the pixels of…
wonderman
  • 1
  • 1
0
votes
1 answer

Calculations in GPU.js giving different results in CPU and GPU modes

I'm trying to use GPU.js to draw the Mandelbrot set. A problem I'm having though is math within the kernel function is giving different results when run in CPU mode vs GPU mode. Here's the kernel function and supporting code: function…
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
1
2