diff options
author | David Phillips <david@sighup.nz> | 2017-02-12 00:08:10 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-02-12 00:08:10 +1300 |
commit | 11b1f27f9d27b3f497c20205a77f00272fe8f332 (patch) | |
tree | 4a5eee2cfd70885b18103f9349e2c70ac0dcab16 /fractal-gen.c | |
parent | e169d7aa8585ebb5f4fab3eccc8df92a43add4f5 (diff) | |
download | fractal-gen-opencl-11b1f27f9d27b3f497c20205a77f00272fe8f332.tar.xz |
Add rough, hard-coded mock-up to prove trampoline
This needs the hard-coded constants taken out of it asap to merge
with master. The code is strictly temporary as a measure to prove that
the CL trampoline works and we are actually able to get images from
the device.
Diffstat (limited to 'fractal-gen.c')
-rw-r--r-- | fractal-gen.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fractal-gen.c b/fractal-gen.c index 117e2ca..075858a 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include "trampoline.h" @@ -24,8 +25,41 @@ int main() { } fprintf(stderr, "Compiled.\n"); + fprintf(stderr, "Setting kernel arguments... "); + if (tramp_set_kernel_args()) { + fprintf(stderr, "Failed.\n"); + return 1; + } + fprintf(stderr, "Done.\n"); + + fprintf(stderr, "Running kernel... "); + if (tramp_run_kernel()) { + fprintf(stderr, "Failed.\n"); + return 1; + } + fprintf(stderr, "Done.\n"); + + + unsigned int *buffer = calloc(sizeof(unsigned int), 1024*1024); + if (!buffer) { + perror("malloc"); + return 1; + } + fprintf(stderr, "Reading data from device... "); + if (tramp_copy_data(&buffer)) { + fprintf(stderr, "Failed.\n"); + return 1; + } + fprintf(stderr, "Done.\n"); + fprintf(stderr, "Destroying CL trampoline... "); tramp_destroy(); fprintf(stderr, "Blown to smitherines.\n"); + + printf("P5\n1024\n1024\n255\n"); + unsigned int i; + for (i = 0; i < 1024*1024; i++) + fputc(buffer[i], stdout); + return 0; } |