13.07.2015 Views

Paper - IDAV: Institute for Data Analysis and Visualization

Paper - IDAV: Institute for Data Analysis and Visualization

Paper - IDAV: Institute for Data Analysis and Visualization

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

20 · Lefohn, Kniss, Strzodka, Sengupta, <strong>and</strong> Owensnn(a)(b)Fig. 3: The Glift n-stack container stores a stack of n-length arrays (a) to support n-way parallel push <strong>and</strong> pop operations. We implement thestructure in Glift as a 1D virtual array stored in 2D physical memory (b).int maxNumN = 10000;StackType stack( maxNumN );✝The stack can store at most maxNumN number of n-sized arrays. Users may push either CPU-based or GPU-baseddata onto the stack. The following code demonstrates a GPU stack push:✞typedef ArrayGpu ArrayType;ArrayType data( 1000 );✆☎// ... initialize data array ...ArrayType::gpu_in_range r = data.gpu_in_single_range( 0, 1000 );stack.push( r );✝Push writes a stream of n input values into the physical memory locations from stack.top() to stack.top()+ n - 1 (see Figure 4). Note that the input to push is specified as a range of element iterators rather than a specificdata structure. This makes push compatible with any Glift data structure rather than just dense, 1D arrays.Pop removes the top n elements from the stack <strong>and</strong> returns a GPU input range iterator (Figure 4). This iterator canbe bound as input to a GPU computation over the specified range. Example C++ source code that pops two streamsfrom the stack, combines them in a subsequent kernel, <strong>and</strong> writes them to an array looks like:✞StackType::gpu_in_range result1 = stack.pop();StackType::gpu_in_range result2 = stack.pop();// ... Create Cg shader <strong>and</strong> instantiate Glift typesCGparameter result1Param = cgGetNamedParameter( prog, "result1" );result1.bind_<strong>for</strong>_read( result1Param );CGparameter result2Param = cgGetNamedParameter( prog, "result2" );ACM Transactions on Graphics, Vol. 25, No. 1, January 2006.✆☎

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!