PDA

View Full Version : xeon quad cores



M//Hax
11-27-2010, 09:24 AM
Hi, each time i run an opengl program, only 1/4 core are used (25% cpu). Is there a way in opengl to make use of all 4 cores?
Thanks

aqnuep
11-27-2010, 10:00 AM
If you are searching for an EnableOpenGLMulticore-like function, you won't find any.
OpenGL itself is implemented by your graphics driver vendor. Both NVIDIA and ATI drivers do use multithreading in their drivers but the fact that your applciation is limited by your single core means that your application is CPU limited, it is most probably not an issue with OpenGL or the driver.
You are most probably CPU limited because you issue too many OpenGL function calls (e.g. because you use immediate rendering) or some other CPU intensive task.

In fact, you can use several threads in your application to do some rendering in parallel with separate OpenGL rendering contexts, however you cannot render to the same framebuffer even that way.

AFAIK (based on your previous questions) you use immediate mode for rendering. That's why you are CPU bound. Switch to VBOs and you'll get much better frame rates.

M//Hax
11-29-2010, 07:15 AM
I really thought there was a parallel "for" loop, like the one in matlab (parfor function). Do you know any simple code i could run to see if i'm able to use more than 25% of the cpu?

aqnuep
11-29-2010, 07:30 AM
As I already mentioned, you cannot execute rendering commands that render to the same framebuffer from multiple threads. There are very serious reasons not to allow such thing.
At least move to display lists from immediate mode if you are not comfortable with VBOs. Otherwise you'll always have the CPU bottleneck as one API call takes more time than for the GPU to render several (possibly hundreds) of triangles. So actually a glVertex*-like call in your app and the driver will cost you much more than the actual rendering.

About parallel "for". Actually OpenMP provides you such functionality but that means that the for cycle block will be executed in separate threads and *only* one thread can render to the framebuffer so this won't work anyway.

mhagain
11-29-2010, 07:32 AM
This is really very little to do with OpenGL at all. On a quad-core machine, a single-threaded app will only ever use 25% CPU max. OpenGL commands will (for the most part) run on your GPU, not your CPU, so what you're talking about is 2 entirely different things.

M//Hax
11-29-2010, 07:57 AM
Ok i understand. For now i'm trying to understand VBO's...i'm in a hurry to see how much it helps for the fps.

BionicBytes
11-29-2010, 08:32 AM
I think that's half the problem. Your in too much of a hurry to consider what the real issue is.
What are you measuring and how are you taking that measurement. Simply counting howmany times you've executed the draw function is not a reliable FPS measurement.
Similarly, just creating VBO objects may not necessarily help you either becuase it does not sound like you have even began the task of performance monitoring where the bottlenecks are: drawing? scene management? some post processing effect?

aqnuep
11-29-2010, 09:10 AM
He is rendering millions of spheres using point sprites in immediate mode and/or using glutSolidSphere that is also immediate mode (see the topic: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=286571#Post2865 71).

Thus I'm pretty sure he has a CPU bottleneck because of the number of immediate draw calls.

M//Hax
11-29-2010, 09:34 AM
I think that's half the problem. Your in too much of a hurry to consider what the real issue is.
What are you measuring and how are you taking that measurement. Simply counting howmany times you've executed the draw function is not a reliable FPS measurement.
Similarly, just creating VBO objects may not necessarily help you either becuase it does not sound like you have even began the task of performance monitoring where the bottlenecks are: drawing? scene management? some post processing effect?
Getting cpu bottlenecks with drawing.

M//Hax
11-29-2010, 09:35 AM
He is rendering millions of spheres using point sprites in immediate mode and/or using glutSolidSphere that is also immediate mode (see the topic: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=286571#Post2865 71).

Thus I'm pretty sure he has a CPU bottleneck because of the number of immediate draw calls.

I wrote a vbo, following some tutorials, the code is compiling, but automaticaly crash, giving no error code or something. I posted the code in my other thread.

M//Hax
12-01-2010, 07:35 AM
Even with a vbo, i'm still getting a 25% cpu usage. How can i use the 3 other cores?

nickels
12-01-2010, 08:29 AM
Even with a vbo, i'm still getting a 25% cpu usage. How can i use the 3 other cores?

Running windows should max out a core or two ;) And definitely should use several Gig of memory !!

M. Bially
12-01-2010, 06:11 PM
If you would pay attention you would know there is no quick fix easy solution to multiple thread rendering because OpenGL is NOT THREAD SAFE. If you want to do what DirectX does and have command queues write it yourself, it's not too hard.

If you want some pointers on how to speed up rendering with multiple threads check these guys out:
http://www.equalizergraphics.com/

ugluk
12-01-2010, 07:54 PM
Yeah, you can also try Hackingt0sh and you'll see CPU consumption skyrocket and you'll be limited to GL 2.1.

nickels
12-02-2010, 10:31 AM
Yeah, you can also try Hackingt0sh and you'll see CPU consumption skyrocket and you'll be limited to GL 2.1.

:D

V-man
12-02-2010, 06:51 PM
Even with a vbo, i'm still getting a 25% cpu usage. How can i use the 3 other cores?

It sounds like you don't understand what the CPU is for and what the GPU is for in terms of GL.
The CPU is for running the GL driver. Whenever you make a function call, the driver does some work and from time to time, it will shoot the command buffer to the GPU where the actual work gets done. The CPU usage by the GL driver is minimal. That's why games can run their physics and AI and such.

If you want your physics and AI and such to run on another CPU core, then it is possible. Personally, I have used the WinAPI : CreateThread. I'm sure all modern action games do multithreading for their physics and AI since their minimal requirement is a Core Duo or Athlon X2.

M. Bially
12-04-2010, 09:10 AM
Or, if you can find concurrent physics, AI simulation, and culling techniques, you can use many threads to do your game processing and one to do your rendering of whats on the screen.