Add --scale command line argument to mandelbrot and rt examples.

This applies a floating-point scale factor to the image resolution;
it's useful for experiments with many-core systems where the 
base image resolution may not give enough work for good load-balancing
with tasks.
This commit is contained in:
Matt Pharr
2011-09-07 20:07:51 -07:00
parent 2ea6d249d5
commit 5dedb6f836
4 changed files with 88 additions and 31 deletions

View File

@@ -99,8 +99,12 @@ ensureTargetISAIsSupported() {
}
}
static void usage() {
fprintf(stderr, "usage: mandelbrot [--scale=<factor]\n");
exit(1);
}
int main() {
int main(int argc, char *argv[]) {
unsigned int width = 1536;
unsigned int height = 1024;
float x0 = -2;
@@ -108,6 +112,25 @@ int main() {
float y0 = -1;
float y1 = 1;
if (argc == 1)
;
else if (argc == 2) {
if (strncmp(argv[1], "--scale=", 8) == 0) {
float scale = atof(argv[1] + 8);
if (scale == 0.f)
usage();
width *= scale;
height *= scale;
// round up to multiples of 16
width = (width + 0xf) & ~0xf;
height = (height + 0xf) & ~0xf;
}
else
usage();
}
else
usage();
ensureTargetISAIsSupported();
int maxIterations = 512;