summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--get_global_id_3d.c46
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;
+}