|
BRT: Brook Runtime Library |
Home Introduction Forums Getting Started Language Architecture BRCC BRT BRT C++ Current Issues Research Sponsors |
Code TransformationsThe brcc compiler transforms declarations of streams and iterators, as well as definitions of kernels into calls into the brook runtime API. The following examples demonstrate the transformations peformed on each language construct. Stream DeclarationsInput float<extent1, extent2, ...> s; Output __BRTStream s(__BRTFLOAT, extent1, extent2, ..., -1); Iterator DeclarationsInput iter float<extent> i = iter( min, max ); iter float2<extentY, extentX> i2 = iter( float2(minX, minY), float2(maxX, maxY) ); Output __BRTIter i(__BRTFLOAT, extent, -1, min, max, -1 ); __BRTIter i2(__BRTFLOAT2, extentY, extentX, -1, minX, minY, maxX, maxY, -1 ); Kernel DefinitionsInput kernel void foo( float2 a<>, // stream input float3 b[][], // gather input float4 c, // constant input iter float d<>, // iterator input out float2 e<> // stream output ) { ... } Output static void foo( const __BRTStream& a, const __BRTStream& b, const float4& c, const __BRTIter& d, const __BRTStream& e ) { static const void *__foo_fp[] = { "fp30", __foo_fp30, "ps20", __foo_ps30, "cpu", (void *) __foo_cpu, NULL, NULL }; static __BRTKernel k(__foo_fp); k->PushStream(a); k->PushGather(b); k->PushConstant(c); k->PushIter(d); k->PushOutput(e); k->Map(); } Reduction DefinitionsInput reduce void bar( float2 input<>, // stream input float3 g[][], // gather input float4 c, // constant input reduce float2 result<> // stream output ) { ... } Output // reduce to value version static void bar( const __BRTStream& input, const __BRTStream& g, const float4& c, const float2& result ) { static const void *__foo_fp[] = {...}; static __BRTKernel k(__foo_fp); k->PushStream(input); k->PushGather(g); k->PushConstant(c); k->PushIter(d); k->PushReduce(&result, __BRTReductionType(&result)); k->Reduce(); } // reduce to stream version static void bar( const __BRTStream& input, const __BRTStream& g, const float4& c, const __BRTStream& result ) { static const void *__foo_fp[] = {...}; static __BRTKernel k(__foo_fp); k->PushStream(input); k->PushGather(g); k->PushConstant(c); k->PushIter(d); k->PushReduce(&result, __BRTReductionType(&result)); k->Reduce(); } |
The fly fishing flies featured on this web site can be purchased at The English Fly Fishing Shop |