summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--get_global_id_2d.c15
-rw-r--r--global_id2d.cl3
2 files changed, 10 insertions, 8 deletions
diff --git a/get_global_id_2d.c b/get_global_id_2d.c
index ae940e7..be16038 100644
--- a/get_global_id_2d.c
+++ b/get_global_id_2d.c
@@ -5,6 +5,8 @@
#include "util.h"
+#define GLOBAL_DIM_X 10
+#define GLOBAL_DIM_Y 10
int main (int argc, char ** argv)
{
@@ -12,8 +14,9 @@ int main (int argc, char ** argv)
cl_int error;
cl_mem out_buffer;
- int out_data[10][10];
- size_t global_work_size[2] = {10, 10};
+ int out_data[GLOBAL_DIM_X * GLOBAL_DIM_Y];
+ size_t global_work_size[2] = {GLOBAL_DIM_X, GLOBAL_DIM_Y};
+ size_t local_work_size[2] = {5, 5};
struct clu_context context;
@@ -36,7 +39,7 @@ int main (int argc, char ** argv)
2, /* dimensions */
NULL,
global_work_size,
- global_work_size,
+ local_work_size,
0, NULL, NULL);
assert(error == CL_SUCCESS);
@@ -51,9 +54,9 @@ int main (int argc, char ** argv)
assert(error == CL_SUCCESS);
- for (i = 0; i < 10; i++) {
- for (j = 0; j < 10; j++) {
- fprintf(stderr, "%2u ", out_data[i][j]);
+ for (i = 0; i < GLOBAL_DIM_X; i++) {
+ for (j = 0; j < GLOBAL_DIM_Y; j++) {
+ fprintf(stderr, "%2u ", out_data[i * GLOBAL_DIM_Y + j]);
}
fprintf(stderr, "\n");
}
diff --git a/global_id2d.cl b/global_id2d.cl
index 08f9fd8..b5519c6 100644
--- a/global_id2d.cl
+++ b/global_id2d.cl
@@ -2,8 +2,7 @@ __kernel void global_id2d(__global int * out)
{
unsigned x = get_global_id(0);
unsigned y = get_global_id(1);
- unsigned id = (y * 10) + x;
+ unsigned id = (y * get_global_size(1)) + x;
out[id] = id;
-
}