My game need to loop through massive amount of data, and the amount of data can increase by a lot depending on world settings set by player. The data is too big for CPU so i need to use GPU for it using compute shader. The numerical range of the data is the same as int range so i can store it either as int or bigger (float, double, ect). I initially thought to store it as int because i tried benchmarking int vs float addition loop performance on CPU, int loop is averagely 16 times faster (at least on my computer).

However, after some googling, some said that some GPU is designed around float operation, so integer operation need to be simulated, which imply that integer operation could actually be slower than floats. Is this true to most GPU ? should i use floats instead of int to store my data when calculated using GPU ?

  • \$\begingroup\$ Does this answer your question? GLfloat vs GLfixed vs GLint performance in 2017 \$\endgroup\$
    – DMGregory
    Dec 11, 2023 at 0:26
  • \$\begingroup\$ Re: int vs double, this tweet from Sebastian Aaltonen mentions that most integer operations run at full rate on modern GPUs, while 64-bit floats might run 64x slower. 😱 \$\endgroup\$
    – LudoProf
    Dec 12, 2023 at 3:56
  • \$\begingroup\$ Bear in mind there's a performance hit for transferring massive amounts of data to and from the GPU. Also bear in mind that time your GPU spends on compute shaders is time it can't spend on rendering. \$\endgroup\$
    – Kevin
    Dec 12, 2023 at 21:35

1 Answer 1


When it comes to performance, nothing beats testing the data and algorithms that you're interested in on the hardware that you care about to find out what performs best. Performance almost always depends on the specifics of what you're actually doing.

Also, when doing any optimization investigations, make sure you're getting the correct results from each approach. For example, beware that 32-bit floats won't hold the full range of 32-bit integer values accurately. The biggest odd integer that they can store accurately is 16,777,215 - every value above that is even. 64-bit doubles can accurately store every 32-bit integer.

As a rough guideline, on a GPU, you should generally expect the smallest data type to be fastest. For maximum speed, that means using 8-bit integers where you can, followed by 16 bit (half-float / integer) data, and then 32-bit types. One reason for small size being important is that smaller types take the least amount of storage (and therefore memory bandwidth). In addition it's common for GPUs to be able to do calculations on smaller data types faster too.

Also note that just running code on a GPU doesn't automatically make it faster. It's only going to be faster if you can take advantage of the parallel nature of the GPU.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .