# there are so many cores

Just another WordPress.com site

## The PeakStream DSL supports stencil kernels

February 18, 2012

Posted by on The PeakStream DSL supports stencil kernels with the gather1_floor() and gather2_floor() operations.

From the PeakStream Kirchoff migration example:

float dx = LX / float(N); float dt = LT / float(NT); float factor = 1./ (velhalf * velhalf); float idt = 1./ dt; Arrayf32 modl = zeros_f32(NT, N); { Arrayf32 x = dx * index_f32(1, NT, N); Arrayf32 z = dt * index_f32(0, NT, N); Arrayf32 data = Arrayf32::make2(NT, N, datagpu); for (int iy = 0; iy < N; iy++) { float y = float(iy) * dx; Arrayf32 index1 = float(iy) * ones_f32(NT, N); Arrayf32 it = 0.5 + sqrt(z * z + (x - y) * (x - y) * factor) * idt; modl += gather2_floor(data, it, index1); } }

Choose convenient values for the constants (just to show what is going on).

LX = N = 10; LT = NT = 5; velhalf = 1;

The statement

modl+= gather2_floor(data, it, index1);

accumulates **data** in this pattern to **modl**:

I begin to see the genius in PeakStream’s DSL. It is an imperative language for specifying functional kernels.

I did not understand how the PeakStream gather operations really worked until this morning. This is cliché – it became obvious while taking a shower.

Some significant changes in the JIT will be required to support this. This is a good thing as it forces me to refactor some of the mess I’ve made.

Advertisements

## Recent Comments