diff options
author | Pan Xiuli <xiuli.pan@intel.com> | 2016-10-19 14:37:23 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-11-03 12:24:10 +0800 |
commit | 45544098d5253c37bca03aaf860c3e91816821dd (patch) | |
tree | 65ff13b2b3098ae558fac575f4f867a1dd1173c3 /utests | |
parent | 24f8f5dcd6306b0662bc3d7fdd70988c35646748 (diff) |
Utest: Add subgroup block read/write ushort test case
Add ushort block read/write for buffer and image.
Refine uint block read/write with suffix _ui.
Signed-off-by: Pan Xiuli <xiuli.pan@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests')
-rw-r--r-- | utests/compiler_subgroup_buffer_block_read.cpp | 73 | ||||
-rw-r--r-- | utests/compiler_subgroup_buffer_block_write.cpp | 74 | ||||
-rw-r--r-- | utests/compiler_subgroup_image_block_read.cpp | 98 | ||||
-rw-r--r-- | utests/compiler_subgroup_image_block_write.cpp | 73 |
4 files changed, 259 insertions, 59 deletions
diff --git a/utests/compiler_subgroup_buffer_block_read.cpp b/utests/compiler_subgroup_buffer_block_read.cpp index 9707f195..74bc899e 100644 --- a/utests/compiler_subgroup_buffer_block_read.cpp +++ b/utests/compiler_subgroup_buffer_block_read.cpp @@ -64,6 +64,7 @@ static void generate_data(T* &input, input[(gid + lid)*VEC_SIZE + vsz] += ((rand() % 2 - 1) * base_val); /* add trailing random bits, tests GENERAL cases */ input[(gid + lid)*VEC_SIZE + vsz] += (rand() % 112); + //input[(gid + lid)*VEC_SIZE + vsz] = (gid + lid)*VEC_SIZE + vsz; #if DEBUG_STDOUT /* output generated input */ @@ -156,47 +157,95 @@ static void subgroup_generic(T* input, /* * subgroup buffer block read */ -void compiler_subgroup_buffer_block_read1(void) +void compiler_subgroup_buffer_block_read_ui1(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_read", - "compiler_subgroup_buffer_block_read1"); + "compiler_subgroup_buffer_block_read_ui1"); subgroup_generic(input, expected, 1); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read1); -void compiler_subgroup_buffer_block_read2(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_ui1); +void compiler_subgroup_buffer_block_read_ui2(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_read", - "compiler_subgroup_buffer_block_read2"); + "compiler_subgroup_buffer_block_read_ui2"); subgroup_generic(input, expected, 2); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read2); -void compiler_subgroup_buffer_block_read4(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_ui2); +void compiler_subgroup_buffer_block_read_ui4(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_read", - "compiler_subgroup_buffer_block_read4"); + "compiler_subgroup_buffer_block_read_ui4"); subgroup_generic(input, expected, 4); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read4); -void compiler_subgroup_buffer_block_read8(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_ui4); +void compiler_subgroup_buffer_block_read_ui8(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_read", - "compiler_subgroup_buffer_block_read8"); + "compiler_subgroup_buffer_block_read_ui8"); subgroup_generic(input, expected, 8); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read8); +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_ui8); +void compiler_subgroup_buffer_block_read_us1(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_read.cl", + "compiler_subgroup_buffer_block_read_us1", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 1); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_us1); +void compiler_subgroup_buffer_block_read_us2(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_read.cl", + "compiler_subgroup_buffer_block_read_us2", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 2); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_us2); +void compiler_subgroup_buffer_block_read_us4(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_read.cl", + "compiler_subgroup_buffer_block_read_us4", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 4); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_us4); +void compiler_subgroup_buffer_block_read_us8(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_read.cl", + "compiler_subgroup_buffer_block_read_us8", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 8); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_read_us8); diff --git a/utests/compiler_subgroup_buffer_block_write.cpp b/utests/compiler_subgroup_buffer_block_write.cpp index 6b257c5f..3b538da3 100644 --- a/utests/compiler_subgroup_buffer_block_write.cpp +++ b/utests/compiler_subgroup_buffer_block_write.cpp @@ -64,6 +64,7 @@ static void generate_data(T* &input, input[(gid + lid)*VEC_SIZE + vsz] += ((rand() % 2 - 1) * base_val); /* add trailing random bits, tests GENERAL cases */ input[(gid + lid)*VEC_SIZE + vsz] += (rand() % 112); + //input[(gid + lid)*VEC_SIZE + vsz] = (gid + lid)*VEC_SIZE + vsz; #if DEBUG_STDOUT /* output generated input */ @@ -156,47 +157,96 @@ static void subgroup_generic(T* input, /* * subgroup buffer block write */ -void compiler_subgroup_buffer_block_write1(void) +void compiler_subgroup_buffer_block_write_ui1(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_write", - "compiler_subgroup_buffer_block_write1"); + "compiler_subgroup_buffer_block_write_ui1"); subgroup_generic(input, expected, 1); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write1); -void compiler_subgroup_buffer_block_write2(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_ui1); +void compiler_subgroup_buffer_block_write_ui2(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_write", - "compiler_subgroup_buffer_block_write2"); + "compiler_subgroup_buffer_block_write_ui2"); subgroup_generic(input, expected, 2); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write2); -void compiler_subgroup_buffer_block_write4(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_ui2); +void compiler_subgroup_buffer_block_write_ui4(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_write", - "compiler_subgroup_buffer_block_write4"); + "compiler_subgroup_buffer_block_write_ui4"); subgroup_generic(input, expected, 4); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write4); -void compiler_subgroup_buffer_block_write8(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_ui4); +void compiler_subgroup_buffer_block_write_ui8(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_buffer_block_write", - "compiler_subgroup_buffer_block_write8"); + "compiler_subgroup_buffer_block_write_ui8"); subgroup_generic(input, expected, 8); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write8); +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_ui8); + +void compiler_subgroup_buffer_block_write_us1(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_write.cl", + "compiler_subgroup_buffer_block_write_us1", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 1); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_us1); +void compiler_subgroup_buffer_block_write_us2(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_write.cl", + "compiler_subgroup_buffer_block_write_us2", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 2); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_us2); +void compiler_subgroup_buffer_block_write_us4(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_write.cl", + "compiler_subgroup_buffer_block_write_us4", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 4); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_us4); +void compiler_subgroup_buffer_block_write_us8(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_buffer_block_write.cl", + "compiler_subgroup_buffer_block_write_us8", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 8); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_buffer_block_write_us8); diff --git a/utests/compiler_subgroup_image_block_read.cpp b/utests/compiler_subgroup_image_block_read.cpp index 02c8f07d..879d6222 100644 --- a/utests/compiler_subgroup_image_block_read.cpp +++ b/utests/compiler_subgroup_image_block_read.cpp @@ -21,7 +21,7 @@ static void compute_expected(T* input, { for(uint32_t i = 0; i < WG_GLOBAL_SIZE; i++) for(uint32_t j = 0; j < VEC_SIZE; j++) - expected[i * VEC_SIZE + j] = input[WG_GLOBAL_SIZE * j + i]; + expected[i * VEC_SIZE + j] = input[WG_GLOBAL_SIZE * 4 / sizeof(T) * j + i]; } /* @@ -33,7 +33,8 @@ static void generate_data(T* &input, size_t VEC_SIZE) { /* allocate input and expected arrays */ - input = new T[WG_GLOBAL_SIZE * VEC_SIZE]; + int* input_ui = new int[WG_GLOBAL_SIZE * VEC_SIZE]; + input = (T*)input_ui; expected = new T[WG_GLOBAL_SIZE * VEC_SIZE]; /* base value for all data types */ @@ -45,19 +46,22 @@ static void generate_data(T* &input, #if DEBUG_STDOUT cout << endl << "IN: " << endl; #endif + uint32_t rpitch = sizeof(uint32_t) * WG_GLOBAL_SIZE / sizeof(T); /* generate inputs and expected values */ - for(uint32_t gid = 0; gid < WG_GLOBAL_SIZE * VEC_SIZE; gid++) - { - /* initially 0, augment after */ - input[gid] = ((rand() % 2 - 1) * base_val) + (rand() % 112); + for(uint32_t h = 0; h < VEC_SIZE; ++h) { + for(uint32_t w = 0; w < WG_GLOBAL_SIZE; ++w) + { + /* initially 0, augment after */ + input[w + h * rpitch] = ((rand() % 2 - 1) * base_val) + (rand() % 112); + //input[w + h * rpitch] = w + h * WG_GLOBAL_SIZE; #if DEBUG_STDOUT - /* output generated input */ - cout << setw(4) << input[gid] << ", " ; - if((gid + 1) % 8 == 0) - cout << endl; + /* output generated input */ + cout << setw(4) << input[w + h * rpitch] << ", " ; + if((w+ 1) % 8 == 0) + cout << endl; #endif - + } } /* expected values */ compute_expected(input, expected, VEC_SIZE); @@ -151,47 +155,95 @@ static void subgroup_generic(T* input, /* * sub_group image block read functions */ -void compiler_subgroup_image_block_read1(void) +void compiler_subgroup_image_block_read_ui1(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_read", - "compiler_subgroup_image_block_read1"); + "compiler_subgroup_image_block_read_ui1"); subgroup_generic(input, expected, 1); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read1); -void compiler_subgroup_image_block_read2(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_ui1); +void compiler_subgroup_image_block_read_ui2(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_read", - "compiler_subgroup_image_block_read2"); + "compiler_subgroup_image_block_read_ui2"); subgroup_generic(input, expected, 2); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read2); -void compiler_subgroup_image_block_read4(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_ui2); +void compiler_subgroup_image_block_read_ui4(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_read", - "compiler_subgroup_image_block_read4"); + "compiler_subgroup_image_block_read_ui4"); subgroup_generic(input, expected, 4); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read4); -void compiler_subgroup_image_block_read8(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_ui4); +void compiler_subgroup_image_block_read_ui8(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_read", - "compiler_subgroup_image_block_read8"); + "compiler_subgroup_image_block_read_ui8"); + subgroup_generic(input, expected, 8); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_ui8); +void compiler_subgroup_image_block_read_us1(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_read.cl", + "compiler_subgroup_image_block_read_us1", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 1); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_us1); +void compiler_subgroup_image_block_read_us2(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_read.cl", + "compiler_subgroup_image_block_read_us2", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 2); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_us2); +void compiler_subgroup_image_block_read_us4(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_read.cl", + "compiler_subgroup_image_block_read_us4", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 4); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_us4); +void compiler_subgroup_image_block_read_us8(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_read.cl", + "compiler_subgroup_image_block_read_us8", + SOURCE, "-DSHORT"); subgroup_generic(input, expected, 8); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read8); +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_read_us8); diff --git a/utests/compiler_subgroup_image_block_write.cpp b/utests/compiler_subgroup_image_block_write.cpp index 2b85167c..98cbb0f7 100644 --- a/utests/compiler_subgroup_image_block_write.cpp +++ b/utests/compiler_subgroup_image_block_write.cpp @@ -50,6 +50,7 @@ static void generate_data(T* &input, { /* initially 0, augment after */ input[gid] = ((rand() % 2 - 1) * base_val) + (rand() % 112); + //input[gid] = gid; #if DEBUG_STDOUT /* output generated input */ @@ -155,47 +156,95 @@ static void subgroup_generic(T* input, /* * sub_group image block write functions */ -void compiler_subgroup_image_block_write1(void) +void compiler_subgroup_image_block_write_ui1(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_write", - "compiler_subgroup_image_block_write1"); + "compiler_subgroup_image_block_write_ui1"); subgroup_generic(input, expected, 1); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write1); -void compiler_subgroup_image_block_write2(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_ui1); +void compiler_subgroup_image_block_write_ui2(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_write", - "compiler_subgroup_image_block_write2"); + "compiler_subgroup_image_block_write_ui2"); subgroup_generic(input, expected, 2); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write2); -void compiler_subgroup_image_block_write4(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_ui2); +void compiler_subgroup_image_block_write_ui4(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_write", - "compiler_subgroup_image_block_write4"); + "compiler_subgroup_image_block_write_ui4"); subgroup_generic(input, expected, 4); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write4); -void compiler_subgroup_image_block_write8(void) +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_ui4); +void compiler_subgroup_image_block_write_ui8(void) { if(!cl_check_subgroups()) return; cl_uint *input = NULL; cl_uint *expected = NULL; OCL_CREATE_KERNEL_FROM_FILE("compiler_subgroup_image_block_write", - "compiler_subgroup_image_block_write8"); + "compiler_subgroup_image_block_write_ui8"); subgroup_generic(input, expected, 8); } -MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write8); +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_ui8); +void compiler_subgroup_image_block_write_us1(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_write.cl", + "compiler_subgroup_image_block_write_us1", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 1); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_us1); +void compiler_subgroup_image_block_write_us2(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_write.cl", + "compiler_subgroup_image_block_write_us2", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 2); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_us2); +void compiler_subgroup_image_block_write_us4(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_write.cl", + "compiler_subgroup_image_block_write_us4", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 4); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_us4); +void compiler_subgroup_image_block_write_us8(void) +{ + if(!cl_check_subgroups_short()) + return; + cl_ushort *input = NULL; + cl_ushort *expected = NULL; + OCL_CALL(cl_kernel_init, "compiler_subgroup_image_block_write.cl", + "compiler_subgroup_image_block_write_us8", + SOURCE, "-DSHORT"); + subgroup_generic(input, expected, 8); +} +MAKE_UTEST_FROM_FUNCTION(compiler_subgroup_image_block_write_us8); |