summaryrefslogtreecommitdiff
path: root/get_global_id_3d.c
blob: df331b139e3d417e84ee2394b7dbdd7eff63dec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}