there are so many cores

Just another WordPress.com site

The PeakStream DSL supports stencil kernels

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:

Kirchoff Migration stencil kernel

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: