liebharc / basic_dsp

Basic DSP vector operations for Rust.
Apache License 2.0
43 stars 5 forks source link

Investigate GPU support #11

Closed liebharc closed 8 years ago

liebharc commented 8 years ago

Well it would be nice to profit from the GPU. However I don't know what is realistically possible to achieve with a GPU (in terms of performance). And what's the break even point, so at which point does the more parallel GPU make up the time we spent to transform data over the bus? And finally is it possible to detect if a GPU is present and decide at runtime if it should/can be used or not and how implement all of that in Rust since the GPU uses an instruction set which is different from the CPU instructions (which the Rust compiler produces). So if all of that can be answered and assuming that I will spent enough work on this library then we might have GPU support at some point in future.

liebharc commented 8 years ago

This might be interesting things to check out: https://github.com/luqmana/rust-opencl https://github.com/fkaa/sparv

liebharc commented 8 years ago

Quick overview of first results:

  1. Intel Haswell GPUs don't have f64/double support. So this library would need a NVIDIA GPU (or AMD).
  2. The GPU driver might kill a calculation if it takes too much time. This results in an ugly screen blackening for the fraction of a second too. Convolving a 100000 element vector with a 100 element vector showed this effect on the test GPU. Not sure if there is a way around that.
  3. Running the same OpenCL code on a NVIDIA GPU (K1100M) vs. an Intel CPU (4810MQ Haswell) shows that the GPU calculation is about 20 to 40 times slower. Tested for vector addition and convolution. This could perhaps be explained by the PCIe bus speed. If we would execute more operations in parallel (starting from 20 to 40 times as complex as the test code) it might get worth to use the CPU. However this threshold is rather high and I don't see that this library should support this edge case for now.
liebharc commented 8 years ago

GPU support is right now the least promising way to improve performance -> Closing.