hi all,
compare to OpenGL/CG which advantages have CUDA?
i’m reading a paper in computer vison for robotic. The autor believes that the openGL/cg allows using older generation GPUs (e.g. G7) better as CUDA. I havent found any other referenc. Gernerally how can I decide using CUDA or CG?

The author is correct, but OpenGL and the Cg language are much more constrained than CUDA in the computations they can perform. In addition, all new NVIDIA GPUs released after December 2006 are CUDA capable. Given the general march forward of CPU technology in the last 3 years, I don’t know that there would be much benefit to supporting the GeForce 7 card anyway.

Now, if you want to support multiple vendors (like ATI and NVIDIA), then a shader language like GLSL would work, but again, is very awkward to use for pure computation. This is why OpenCL was invented. It is very new, but provides a multi-vendor framework for doing parallel calculations. I would encourage you to read up on OpenCL if you decide CUDA doesn’t meet your needs.

thx for ur reply.

can u tell me, why the CG language is much more constrained than CUDA? Is there some reference about it?
I wanted to use one of them (CG, CUDA or OpenCL) to parallelize an algorithm for pure computation. I have already used CUDA to beginn parallelism my method, beacuse there is less tutorials about OpenCL. For this purpose do u belive, the OpenCL can perform better as CUDA?

I don’t want to jack your thread, so it’s one post and then out for me…

But due to your interest in CG, I think you might like to see the best CG video man has yet produced in my opinion. :)

“CG” in this context is Cg, NVIDIA’s programmable graphics shader language. It is one of the ways people did gpgpu with before there were things like CUDA or OpenCL. Nothing to do with what you are imagining.

Sorry then…

Cg was designed for older cards that had fewer capabilities and less programmability than modern GPUs. If you are using CUDA now, you should stick with it unless you think you will need to run your code on something different than a recent NVIDIA graphics card.

The FAQ has a section on the advantages of CUDA/OpenCL over using OpenGL/Cg:

I guess that would be “advantages of CUDA over using OpenGL/Cg:” :)

My colleague is porting some of our code to OpenCL, he is not having a good time. In fact, he’s probably not sleeping well at night…

do you mean OpenCL not OpenGL/Cg?

And that’s the biggest tradeoff of Cuda vs. OpenCL right now - the OpenCL API is currently very painful to use, but Cuda doesn’t work on non-Nvidia hardware.

Same computation procedure implemented with CUDA is slightly faster than with OpenGL/Cg.

And many more are slower (lack of shared memory)

Can you explain ? Does using OPENGL give you more shared memory or something like that ? ( I am not familiar with opengl)

Oops, misread what iceberg wrote. I thought he meant “some Cg code is faster than CUDA”. While it’s possible that some Cg code ends up faster than equivalent CUDA code (weirder things have happened), in most cases CUDA will be just as fast or much faster (thanks to shared memory).

OpenGL/Cg doesn’t expose shared memory AFAIK.