xeon quad cores

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

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.

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?

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.

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.

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.

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?

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#Post286571).

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

Getting cpu bottlenecks with drawing.

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.

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 :wink: And definitely should use several Gig of memory !!

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/

Yeah, you can also try Hackingt0sh and you’ll see CPU consumption skyrocket and you’ll be limited to GL 2.1.

:smiley:

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.

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.