diff options
author | Junyan He <junyan.he@linux.intel.com> | 2014-10-22 15:50:59 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-10-23 09:43:11 +0800 |
commit | 99f2a4ebf288c93a9ed244beccb3ab94a9d246f9 (patch) | |
tree | 21ef2d65039a1c3ed129f4dd386b5230ecfc61f0 /utests/compiler_fill_image_1d_array.cpp | |
parent | 33bbe06cc67a034d66bf419c242f6d0cb8ac9248 (diff) | |
download | beignet-99f2a4ebf288c93a9ed244beccb3ab94a9d246f9.tar.gz |
Add the test case for image 1d array fill
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests/compiler_fill_image_1d_array.cpp')
-rw-r--r-- | utests/compiler_fill_image_1d_array.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/utests/compiler_fill_image_1d_array.cpp b/utests/compiler_fill_image_1d_array.cpp new file mode 100644 index 00000000..cc7cf0a0 --- /dev/null +++ b/utests/compiler_fill_image_1d_array.cpp @@ -0,0 +1,73 @@ +#include <string.h> +#include "utest_helper.hpp" + +static void compiler_fill_image_1d_array(void) +{ + const size_t w = 64; + const size_t array = 8; + cl_image_format format; + cl_image_desc desc; + size_t origin[3] = { }; + size_t region[3]; + uint32_t* dst; + + memset(&desc, 0x0, sizeof(cl_image_desc)); + memset(&format, 0x0, sizeof(cl_image_format)); + + format.image_channel_order = CL_RGBA; + format.image_channel_data_type = CL_UNSIGNED_INT8; + desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY; + desc.image_width = w; + desc.image_row_pitch = 0;//w * sizeof(uint32_t); + desc.image_array_size = array; + + // Setup kernel and images + OCL_CREATE_KERNEL("test_fill_image_1d_array"); + + OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL); + + OCL_MAP_BUFFER_GTT(0); + memset(buf_data[0], 0, sizeof(uint32_t) * w * array); + OCL_UNMAP_BUFFER_GTT(0); + + // Run the kernel + OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]); + globals[0] = w/2; + locals[0] = 16; + globals[1] = 8; + locals[1] = 8; + OCL_NDRANGE(2); + + // Check result + region[0] = w; + region[1] = array; + region[2] = 1; + dst = (uint32_t*)malloc(w*array*sizeof(uint32_t)); + OCL_READ_IMAGE(buf[0], origin, region, dst); + +#if 0 + printf("------ The image result is: -------\n"); + for (uint32_t j = 0; j < array; j++) { + for (uint32_t i = 0; i < w; i++) { + printf(" %2x", dst[j*w + i]); + } + printf("\n"); + } +#endif + + for (uint32_t j = 0; j < array - 1; j++) { + for (uint32_t i = 0; i < w/2; i++) { + OCL_ASSERT(dst[j*w + i] == 0x03020100); + } + for (uint32_t i = w/2; i < w; i++) { + OCL_ASSERT(dst[j*w + i] == 0); + } + } + + for (uint32_t i = 0; i < w; i++) { + OCL_ASSERT(dst[(array - 1)*w + i] == 0x0); + } + free(dst); +} + +MAKE_UTEST_FROM_FUNCTION(compiler_fill_image_1d_array); |