flint icon indicating copy to clipboard operation
flint copied to clipboard

Use a GPU to increase performance

Open Cyclopropinon opened this issue 1 year ago • 9 comments

I was thinking of, because it says that it can use multiple cores, that GPUs have lots of cores and so increase performance even further. How hard would that be to be implemented and how much would be the performance gain?

Cyclopropinon avatar Feb 11 '24 17:02 Cyclopropinon

Sure, can you pinpoint a routine for a generic GPU would outperform or have equal performance to a routine for a generic CPU? Moreover, how would you go about tuning for vastly different architechtures? What API would you use for the GPU?

albinahlback avatar Feb 11 '24 17:02 albinahlback

GPU parallelization comes from SIMD, and the range of algorithms that can take advantage of such a paradigm is limited. CPUs also make use of SIMD, but usually when one says multiple cores, one thinks of MIMD, each core is following its own set of instructions.

I think the most obvious place to take advantage of GPUs is linear algebra over small fields, as Magma does: https://magma.maths.usyd.edu.au/magma/handbook/text/61#611

edgarcosta avatar Feb 11 '24 18:02 edgarcosta

It should already be possible to do GPU-accelerated linear algebra by linking FLINT to a GPU-backed BLAS. I don't recall anyone reporting trying this.

fredrik-johansson avatar Feb 16 '24 04:02 fredrik-johansson

I'm just not comfortable trying this from a build-system perspective. Perhaps we should bring this up at the workshop?

albinahlback avatar Feb 16 '24 13:02 albinahlback

In theory, there shouldn't be anything for us to do, just the user specifying --with-blas with something like NVBLAS installed on the system.

fredrik-johansson avatar Feb 16 '24 14:02 fredrik-johansson

i've looked around on the internet and found arrayfire, wich does some interesting stuff. i dont really know tho if it has stuff like integer multiplication. ive heard of integer multiplication (of very large numbers) being able to be broken down into very many similar operations, so maybe it is possible also with SIMD.

Cyclopropinon avatar Feb 29 '24 17:02 Cyclopropinon

I forgot to bring this up during the workshop. However, my question is still:

  1. Which API?
  2. What GPUs would we support?
  3. Do we set threshold ourselves, or do we let the user decide whether computations with GPUs are worth it or not?

albinahlback avatar Mar 24 '24 19:03 albinahlback

idk very much about gpus and how to compute stuff on them but here is my suggestion:

  1. idk
  2. probably the most mainstream ones like nvidia amd and igpus
  3. i think a small guess could decide it for each computation

Cyclopropinon avatar Mar 25 '24 13:03 Cyclopropinon

  1. We are not a CAS, the user decides. GPUs are very heterogeneous in performance...

edgarcosta avatar Mar 25 '24 13:03 edgarcosta