Merge pull request #642 from egaburov/launch3d

concept of 3d tasking
This commit is contained in:
Dmitry Babokin
2013-12-17 08:40:07 -08:00
17 changed files with 386 additions and 69 deletions

View File

@@ -38,7 +38,8 @@
#pragma warning (disable: 4305)
#endif
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include "../timing.h"

View File

@@ -57,21 +57,26 @@ task void
mandelbrot_scanline(uniform float x0, uniform float dx,
uniform float y0, uniform float dy,
uniform int width, uniform int height,
uniform int span,
uniform int xspan, uniform int yspan,
uniform int maxIterations, uniform int output[]) {
uniform int ystart = taskIndex * span;
uniform int yend = min((taskIndex+1) * span, (unsigned int)height);
const uniform int xstart = taskIndex0 * xspan;
const uniform int xend = min(xstart + xspan, width);
foreach (yi = ystart ... yend, xi = 0 ... width) {
const uniform int ystart = taskIndex1 * yspan;
const uniform int yend = min(ystart + yspan, height);
foreach (yi = ystart ... yend, xi = xstart ... xend) {
float x = x0 + xi * dx;
float y = y0 + yi * dy;
int index = yi * width + xi;
output[index] = mandel(x, y, maxIterations);
}
}
#if 1
export void
mandelbrot_ispc(uniform float x0, uniform float y0,
uniform float x1, uniform float y1,
@@ -79,8 +84,16 @@ mandelbrot_ispc(uniform float x0, uniform float y0,
uniform int maxIterations, uniform int output[]) {
uniform float dx = (x1 - x0) / width;
uniform float dy = (y1 - y0) / height;
uniform int span = 4;
const uniform int xspan = max(32, programCount*2); /* make sure it is big enough to avoid false-sharing */
const uniform int yspan = 16;
launch[height/span] mandelbrot_scanline(x0, dx, y0, dy, width, height, span,
maxIterations, output);
#if 1
launch [width/xspan, height/yspan]
#else
launch [height/yspan][width/xspan]
#endif
mandelbrot_scanline(x0, dx, y0, dy, width, height, xspan, yspan,
maxIterations, output);
}
#endif