GPUs and Array Operations

Don Clugston dac at nospam.com.au
Mon Jul 9 23:54:09 PDT 2007


Lutger wrote:
> Craig Black wrote:
>> Another idea.  What if this could be done using the recently added 
>> mixin feature?  Then you could use a shading language directly rather 
>> than trying to convert D code to a shading language.  I've never used 
>> mixins, so I can't even think of how the syntax would look.  Is this a 
>> practical idea?
>>
>> -Craig
> 
> A solution like Blade* should be possible, especially when D gets some 
> macro syntactic sugar, but somewhat involved probably.

It's certainly possible. It might not be too terrible, actually. I'm rewriting 
BLADE for the D conference; it now has syntax like:

import blade;

void main()
{
real result[]; double b[];
alias b c;
const x = 8.9884;
real y = 234543;
mixin(VEC("result+=b*3.5645 - x*43645*3124.543 +c[2..18]*y"));
}

By analyzing the complexity of the expression, it's possible to determine if
it can easily be done with SSE1, SSE2, or x87, and if not, just do it with 
straight D instead. This is nice, because it means you don't have to worry about 
  tricky cases. Using a mixin instead of operator overloading means you can 
detect aliasing. The same thing could be done for a GPU.
In fact, the examples in NVIDIA's CUDA programming guide are perfect for BLADE, 
except that they aren't in C!

Do you know where I could find some examples of using a GPU to do calculations 
(using standard C)?
I think it would be easy to get BLADE to do it for a few simple cases.



More information about the Digitalmars-d mailing list