PDA

View Full Version : What is faster?



alexei_shk
11-15-2005, 02:37 AM
Hi,

I am using the ortho -1,-1,1,1 and use the numbers between -1 and 1.
I can change my drawing to using integer values. What is faster to work with opengl: integer values or double values?

Thank's
Alexei

jide
11-15-2005, 02:57 AM
The Ortho function is expecting doubles. And generally, it is faster to use floating points than integers.

alexei_shk
11-15-2005, 03:21 AM
Hi,

My teacher in the univer. told me that the integers are fater than float point numbers. But I need to know he is right or not?

Thank's
Alexei

jide
11-15-2005, 04:24 AM
Rencent hardware of graphic cards generally compute floating point faster than integers. This is true for all vertex attributes (vertex positions, normals, texture coordinates...). But this is generally false for the index arrays of elements. This turns out because attributes are generally floating points (for best precision and ease) and they are millions of them in use during an application.

What you teacher is saying is really logical. For a cpu (not a gpu) it is faster to add, multiply... two integers because this is an operation directly on all the bits representing the values. But for floating points, you must do other calculations (mantisse and exponent).
Also, on some C/C++ compilers (generally old ones) plain integers are 16 bits whereas float are 32 bits and double are 64 bits. Calculations, and then also memory manipulation is then faster for those integers. However on recent compilers (like the GNU C compiler), int is 4 bytes, so 32 bits.

Hope that helps.

11-15-2005, 06:00 AM
Originally posted by jide:

What you teacher is saying is really logical. For a cpu (not a gpu) it is faster to add, multiply... two integers because this is an operation directly on all the bits representing the values. But for floating points, you must do other calculations (mantisse and exponent).
This isnt entirely true, older Pentium 4 CPUs (Willamette & Northwood core) actually used the floating point multiplier unit to multiply integers (imul) including the required conversion steps.

Nowadays you simply cant say integers are faster then floats (or vice versa) because it highly depends on the underlying technology you are talking about.

Obli
11-15-2005, 06:06 AM
Just as a confirmation, I also heard floating point to be faster than integers even on CPUs.
I must say however, I was not able to proof this myself. My CPU is probably too old to show this behaviour.

alexei_shk
11-15-2005, 06:11 AM
Hi,

Thank's
Alexei

jide
11-15-2005, 09:21 AM
Originally posted by <Whocares>:

Originally posted by jide:

What you teacher is saying is really logical. For a cpu (not a gpu) it is faster to add, multiply... two integers because this is an operation directly on all the bits representing the values. But for floating points, you must do other calculations (mantisse and exponent).
This isnt entirely true, older Pentium 4 CPUs (Willamette & Northwood core) actually used the floating point multiplier unit to multiply integers (imul) including the required conversion steps.

Nowadays you simply cant say integers are faster then floats (or vice versa) because it highly depends on the underlying technology you are talking about.This doesn't mean FPU implies that float computations and memory management is faster than integers. This accelerates things, that's all what we can say.