All about Graphics Cards
 Latest Graphics Cards articles
All Graphics Cards articles

Newsletters


  • Ask your question about IT issues
  • Post

Partners

The Games selection

crazy : Interactive Boogy Pick one of the 3 songs, hit on the correct keys matching this boy's dance moves.
crazy : Xiao Xiao 7 A great fight scene from the animation movies Xiao Xiao.
Ads

Sponsored links

The Theory: CUDA from the Software Point of View

Previous Next
9:40 AM - 06/18/2008 by Fedy Abi-Chahla

From a software point of view, CUDA consists of a set of extensions to the C language, which of course recalls BrookGPU, and a few specific API calls. Among the extensions are type qualifiers that apply to functions and variables. The keyword to remember here is __global__, which when prefixed to a function indicates that the latter is a kernel – that is, a function that will be called by the CPU and executed by the GPU. The __device__ keyword designates a function that will be executed by the GPU (which CUDA refers to as the “device”) but can only be called from the GPU (in other words, from another __device__ function or from a __global__ function). Finally, the __host__ keyword is optional, and designates a function that’s called by the CPU and executed by the CPU – in other words, a traditional function.

There are a few restrictions associated with __device__ and __global__ functions: They can’t be recursive (that is, they can’t call themselves) and they can’t have a variable number of arguments. Finally, regarding __device__ functions resident in the GPU’s memory space, logically enough it’s impossible to obtain their address. Variables also have new qualifiers that allow control of the memory area where they’ll be stored. A variable preceded by the keyword __shared__ indicates that it will be stored in the streaming multiprocessors’ shared memory. The way a __global__ function is called is also a little different. That’s because the execution configuration has to be defined at the time of the call – more concretely, the size of the grid to which the kernel is applied and the size of each block. Take the example of a kernel with the following signature:

__global__ void Func(float* parameter);

which will be called as follows:

Func<<< Dg, Db >>>(parameter);

where Dg is the grid dimension and Db the dimension of a block. These two variables are of a new vector type introduced by CUDA.

The CUDA API essentially comprises functions for memory manipulation in VRAM: cudaMalloc to allocate memory, cudaFree to free it and cudaMemcpy to copy data between RAM and VRAM and vice-versa.

We’ll end this overview with the way a CUDA program is compiled, which is interesting: Compiling is done in several phases – first of all the code dedicated to the CPU is extracted from the file and passed to the standard compiler. The code dedicated to the GPU is first converted into an intermediate language, PTX. This intermediate language is like an assembler, and so enables the generated source code to be studied for potential inefficiencies. Finally, the last phase translates this intermediate language into commands that are specific to the GPU and encapsulates them in binary form in the executable.

nvidia CUDA

Talkback
mr roboto 06/18/2008 7:01 AM
Hide
-4+

Very interesting. I'm anxiously awaiting the RapiHD video encoder. Everyone knows how long it takes to encode a standard definition video, let alone an HD or multiple HD videos. If a 10x speedup can materialize from the CUDA API, lets just say it's more than welcome.

I understand from the launch if the GTX280 and GTX260 that Nvidia has a broader outlook for the use of these GPU's. However I don't buy it fully especially when they cost so much to manufacture and use so much power. The GTX 280 has been reported as using upwards of 300w. That doesn't translate to that much money in electrical bills over a span of a year but never the less it's still moving backwards. Also don't expect the GTX series to come down in price anytime soon. The 8800GTX and it's 384 Bit bus is a prime example of how much these devices cost to make. Unless CUDA becomes standardized it's just another niche product fighting against other niche products from ATI and Intel.

On the other hand though, I was reading on Anand Tech that Nvidia is sticking 4 of these cards (each with 4GB RAM) in a 1U formfactor using CUDA to create ultra cheap Super Computers. For the scientific community this may be just what they're looking for. Maybe I was misled into believing that these cards were for gaming and anything else would be an added benefit. With the price and power consumption this makes much more sense now.

pulasky 06/18/2008 10:11 AM
Show
Anonymous 06/18/2008 10:31 AM
Hide
-8+

Well if the technology was used just to play games yes, it would be crap tech, spending billions just so we can play quake doesnt make much sense ;)

MTLance 06/18/2008 11:14 AM
Show
dariushro 06/18/2008 11:59 AM
Show
dmuir 06/18/2008 12:44 PM
Hide
-0+

And no mention of OpenCL? I guess there's not a lot of details about it yet, but I find it surprising that you look to M$ for a unified API (who have no plans to do so that we know of), when Apple has already announced that they'll be releasing one next year. (unless I've totally misunderstood things...)

NeoDude007 06/18/2008 2:56 PM
Hide
-1+

Im not gonna bother reading this article, I just thought the title was funny seeing as how Nvidia claims CUDA in NO way replaces the CPU and that is simply not their goal.

LazyGarfield 06/18/2008 3:44 PM
Hide
--3+

I´d like it better if DirectX wouldnt be used.

Anyways, NV wants to sell cuda, so why would they change to DX ,-)

Anonymous 06/18/2008 3:57 PM
Hide
--3+

I think the best way to go for MS is announce to support OpenCL like Apple. That way it will make things a lot easier for the developers and it makes MS look good to support the oen standard.

shadow703793 06/18/2008 3:58 PM
Hide
-1+

Mr Roboto :
Very interesting. I'm anxiously awaiting the RapiHD video encoder. Everyone knows how long it takes to encode a standard definition video, let alone an HD or multiple HD videos. If a 10x speedup can materialize from the CUDA API, lets just say it's more than welcome.I understand from the launch if the GTX280 and GTX260 that Nvidia has a broader outlook for the use of these GPU's. However I don't buy it fully especially when they cost so much to manufacture and use so much power. The GTX http://en.wikipedia.org/wiki/Gore-Tex 280 has been reported as using upwards of 300w. That doesn't translate to that much money in electrical bills over a span of a year but never the less it's still moving backwards. Also don't expect the GTX series to come down in price anytime soon. The 8800GTX and it's 384 Bit bus is a prime example of how much these devices cost to make. Unless CUDA becomes standardized it's just another niche product fighting against other niche products from ATI and Intel.On the other hand though, I was reading on Anand Tech that Nvidia is sticking 4 of these cards (each with 4GB RAM) in a 1U formfactor using CUDA to create ultra cheap Super Computers. For the scientific community this may be just what they're looking for. Maybe I was misled into believing that these cards were for gaming and anything else would be an added benefit. With the price and power consumption this makes much more sense now.


Agreed. Also I predict in a few years we will have a Linux distro that will run mostly on a GPU.

kelfen 06/18/2008 4:40 PM
Hide
-0+

Well this is a huge step, hope to see it successful.

LogicalError 06/18/2008 4:48 PM
Hide
-0+

FYI: Apple has been working with the Khronos group (the people behind OpenGL at the moment) to make an API called OpenCL which should do all the things that Cuda et al can do. Since it's not just Apple that's behind it, but also the Khronos group, it should be cross platform. So who knows.. maybe this is going to be the unifying API for this.. well, until Microsoft comes up with 'DirectC' ofcourse

Anonymous 06/18/2008 5:00 PM
Hide
--2+

the last page comments on how MS could come in and create a common API, this common API is already in process, its just that MS isn't part of it ;)
http://arstechnica.com/journals/ap [...] pencl-spec

Anonymous 06/18/2008 5:32 PM
Hide
--2+

I know that this is not too close to the article, but i hope that it is still not too OFF topic.
I just have a question, and someone might answer it (the TH is full with smart guys). My problem is that there are too many misconceptions floating around in the net regarding CUDA and overall the whole GPGU businnes.
I have seen somewhere, that these GPU's are able to do Double Precision floating point calculations, but personally i find this unlikely.
Others say that you can take directly your parallel code writen in C or Fortran90, and adopt it to CUDA, because the standard stuff can run serial on the CPU and the most computationally expensive part parallel on the GPU. On top of that you can 'adress' or cummunicate with your GPU directly from a Fortran code with sort of system calls (i think this is BS).
Quiet frankly, i have not found a site on which i can really rely on, where they show an example (source code and explanation) of how something like this could be done.

bf2gameplaya 06/18/2008 6:38 PM
Hide
-0+

I wish Intel and NVidia would get over themselves and co-operate and finally give total system performance that big ass boost it needs.

Intel is wasting time ray-tracing on a CPU and NVidia is wasting frames by folding proteins on their GPU.

"You're doing it wrong!"

Anonymous 06/18/2008 7:09 PM
Hide
--1+

No, the best would be if we got an open API, like OpenGL. I seriously do not want another DirectX locking me to MS >_

thr3ddy 06/18/2008 8:10 PM
Hide
-0+

@dariushro: That would quite possibly be the worst thing that could happen to GPGPU. Microsoft equals Windows and GPGPU and super computing is not Windows' strongest point (understatement).

It would be better for a neutral party composed of GPGPU experts from different IHVs to initiate something like what you propose, more like what the OpenGL ARB creates, a specification.

IHVs and other companies could then implement this standard on their own hardware, thus decentralizing development from the ISV. If you leave development of this type of technology up to Microsoft (or any other single developer) you'll end up with vendor lock-in, which is a Bad Thing, for all of us.

Anyway, CUDA is great but not cross-platform compatible (Intel, AMD/ATI, etc.) which makes it impossible to implement in commercial software, unless a CPU-bound alternative is provided, which would defeat the purpose of the architecture.

On a similar note: think of the choice between the PhysX SDK and Havok Physics. Do you want partial GPU accelerated physics supported by one brand (PhysX, NVIDIA G80+) or do you want to stay CPU-bound but have the same feature set regardless of the hardware (Havok)?

magnesious 06/18/2008 8:39 PM
Hide
-0+

If you had the patience to read this entire thing, I'd recommend you look at the CUDA programming guide(link) It's the same information, but less terse.

Tom's also forgot to point out that development is possible via emulation (emuDebug build setting, I think, with the .vcproj they give you), so anyone can get their hands dirty with the API. You don't get the satisfaction of seeing cool speedups, but it's just as educational, and easier to debug. No screen flickers :)

MxM 06/18/2008 9:21 PM
Hide
-0+

I wonder if a PC can be build today without processor at all? It probably requires different BIOS for mobo and some kind of x86 emulator for NVIDIA card, but is it possible in principle without any modifications in hardware?

godmodder 06/18/2008 10:55 PM
Hide
-0+

The end of the CPU is nowhere near. To think the GPU could be used for every task is just absurd. The GPU is only good for tasks which can be massively parallellized. Unfortunately, not that many tasks, apart from graphical processing, can be divided into smaller, completely independent parts.


Comments are closed on this page.

Sponsored links