GPUs and Array Operations

Craig Black cblack at ara.com
Tue Jul 10 07:16:00 PDT 2007


"Knud Soerensen" <4tuu4k002 at sneakemail.com> wrote in message 
news:f6vb8r$2qad$4 at digitalmars.com...
> On Mon, 09 Jul 2007 19:43:27 -0500, Craig Black wrote:
>
>> Interesting syntax.  I like it, but in order to support GPU's there would
>> have to be some way that the programmer specified GPU or CPU computation.
>> Perhaps a new keyword or pragma?
>>
> The purpose of the syntax is to have a hardware independent way
> to specify large array calculations.
>
> If you specify in the code if it should be CPU or GPU the
> you have lost this Independence. so, I think it should be automatic by the
> compiler or a compiler switch so if you get new hardware you just
> recompile your code.

I do not believe a compiler switch would not provide enough granularity. 
The programmer should have complete control over what hardware would be used 
for each vectorized operation.  It is good practice to load the CPU/GPU 
equally, and this can't be achieved without benchmarking the code first. 
The compiler would be powerless to make the correct decision, and a compiler 
switch would make this balancing act very difficult.


>> I'm fuzzy on the details of how this could actually be done on the GPU. 
>> The
>> compiler would have to somehow generate either high-level or low-level
>> shading language routines for each statement.  That means each function
>> called would also have to be converted to GPU code.
>>
>> There would obviously be some restrictions as to what kinds of language
>> features could be used when the GPU option is enabled.  For example, no
>> function pointers, no heap allocations, etc, etc.  I'm sure there would 
>> end
>> up being a lot.
>
> Yes, that is why we need a special syntax and can not just use the foreach
> statement.

Yes but even functions that are called in this special syntax would have to 
be evaluated to ensure that the rules are being obeyed.

-Craig 





More information about the Digitalmars-d mailing list