From 08a1b94987bebacaf8c5d7c42f08c83e25daa6f6 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sun, 12 Feb 2017 21:12:55 +1300 Subject: Give test.cl a more meaningful name --- fractal-gen.c | 2 +- mandelbrot.cl | 25 +++++++++++++++++++++++++ test.cl | 25 ------------------------- 3 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 mandelbrot.cl delete mode 100644 test.cl diff --git a/fractal-gen.c b/fractal-gen.c index bfe151d..a5937cf 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -14,7 +14,7 @@ int run(unsigned int size, unsigned int iterations) fprintf(stderr, "Done.\n"); fprintf(stderr, "Loading kernel source from file... "); - if (tramp_load_kernel("test.cl")) { + if (tramp_load_kernel("mandelbrot.cl")) { fprintf(stderr, "Failed.\n"); return 1; } diff --git a/mandelbrot.cl b/mandelbrot.cl new file mode 100644 index 0000000..2652108 --- /dev/null +++ b/mandelbrot.cl @@ -0,0 +1,25 @@ +__kernel void fractal_gen( + __global unsigned char *buffer, + const unsigned int size, + const unsigned int iterations) +{ + unsigned int x = get_global_id(0); + unsigned int y = get_global_id(1); + unsigned int i = 0; + + float a = -2.5+(((float)x)/(float)size)*3.5; + float b = -1.75+(((float)y)/(float)size)*3.5; + + float2 z = (0.0, 0.0); + + for (i = 0; i < iterations; i++) { + // if abs(z) > 2 + if (z.x*z.x + z.y*z.y > 4) + break; + + float oldx = z.x; + z.x = z.x*z.x - z.y*z.y + a; + z.y = 2*oldx*z.y + b; + } + buffer[(size*y)+x] = (i*255)/iterations; +} diff --git a/test.cl b/test.cl deleted file mode 100644 index 2652108..0000000 --- a/test.cl +++ /dev/null @@ -1,25 +0,0 @@ -__kernel void fractal_gen( - __global unsigned char *buffer, - const unsigned int size, - const unsigned int iterations) -{ - unsigned int x = get_global_id(0); - unsigned int y = get_global_id(1); - unsigned int i = 0; - - float a = -2.5+(((float)x)/(float)size)*3.5; - float b = -1.75+(((float)y)/(float)size)*3.5; - - float2 z = (0.0, 0.0); - - for (i = 0; i < iterations; i++) { - // if abs(z) > 2 - if (z.x*z.x + z.y*z.y > 4) - break; - - float oldx = z.x; - z.x = z.x*z.x - z.y*z.y + a; - z.y = 2*oldx*z.y + b; - } - buffer[(size*y)+x] = (i*255)/iterations; -} -- cgit v1.1