From 118b7b08a62a79cb8409cf619fb18a49feb7e04b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 27 Apr 2012 09:56:16 -0400 Subject: Add get_global_id_3d.c --- get_global_id_3d.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 get_global_id_3d.c 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 +#include + +#include + +#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; +} -- cgit v1.2.3