diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2012-04-27 09:56:16 -0400 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2012-04-27 09:56:16 -0400 |
commit | 118b7b08a62a79cb8409cf619fb18a49feb7e04b (patch) | |
tree | 0008877d548496ac39deba0823d1018bc5a0182b | |
parent | 569da6c94c9aa21cd35ccd19a9614c8a658106ec (diff) |
Add get_global_id_3d.c
-rw-r--r-- | get_global_id_3d.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/get_global_id_3d.c b/get_global_id_3d.c new file mode 100644 index 0000000..df331b1 --- /dev/null +++ b/get_global_id_3d.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <CL/cl.h> + +#include "cl_simple.h" + +int main (int argc, char ** argv) +{ + size_t global_work_size[3]; + size_t local_work_size[3]; + + struct cl_simple_context context; + + unsigned i; + + int out[2]; + int out_size = 2 * sizeof(int); + + for (i = 0; i < 3; i++) { + global_work_size[i] = atoi(argv[i + 1]); + local_work_size[i] = atoi(argv[i + 4]); + } + + if (!clSimpleSimpleInit(&context, "global_id_3d")) { + return EXIT_FAILURE; + } + + if (!clSimpleSetOutputBuffer(&context, out_size)) { + return EXIT_FAILURE; + } + + if (!clSimpleEnqueueNDRangeKernel(context.command_queue, + context.kernel, + 3, &global_work_size, + &local_work_size)) { + return EXIT_FAILURE; + } + + if (!clSimpleReadOutput(&context, out, out_size)) { + return EXIT_FAILURE; + } + + fprintf(stderr, "out[0] = %u out[1] = %u\n", out[0], out[1]); + return EXIT_SUCCESS; +} |