MENU

GPU JS

GPU.JS is a library which allows you to run JS functions on the GPU instead of the CPU. This library converts the code to shader functions which run in parallel so very very quickly indeed. There are a few rules for writing the code, but these are not onerous. See here. Integers, floats, booleans, arrays, and graphics are supported. Up to 3 threads.

Use this for large and/or complex mathematical tasks. The overheads will actually slow down small and trivial tasks. The overhead on my PC is 16-17ms. Click run to generate 10 million random numbers and perform an arithmetic operation on each of them. Clicking run repeatedly shows the GPU pulling ahead of the CPU for this task.

Run