summaryrefslogtreecommitdiff
path: root/utests/compiler_load_bool_imm.cpp
blob: d060daf8e6919f3f3ff9be3855ab5a9a5c86e570 (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
#include "utest_helper.hpp"

static void compiler_load_bool_imm(void)
{
  const size_t n = 1024;
  const size_t local_size = 16;
  const int copiesPerWorkItem = 5;

  // Setup kernel and buffers
  OCL_CREATE_KERNEL("compiler_load_bool_imm");
  OCL_CREATE_BUFFER(buf[0], 0, n * copiesPerWorkItem * sizeof(uint32_t), NULL);
  OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
  OCL_SET_ARG(1, local_size*copiesPerWorkItem*sizeof(int), NULL); // 16 x int
  OCL_SET_ARG(2, sizeof(int), &copiesPerWorkItem); // 16 x int

  // Run the kernel
  globals[0] = n;
  locals[0] = local_size;
  OCL_NDRANGE(1);
  OCL_MAP_BUFFER(0);

  // Check results
  int *dst = (int*)buf_data[0];
  for (uint32_t i = 0; i < n * copiesPerWorkItem; i++)
    OCL_ASSERT(dst[i] == copiesPerWorkItem);
  OCL_UNMAP_BUFFER(0);
}

MAKE_UTEST_FROM_FUNCTION(compiler_load_bool_imm);