summaryrefslogtreecommitdiff
path: root/utests
diff options
context:
space:
mode:
authorGrigore Lupescu <grigore.lupescu at intel.com>2016-04-11 17:39:34 +0300
committerYang Rong <rong.r.yang@intel.com>2016-05-18 15:10:36 +0800
commit4bf8346d24970ba5d950f7e04131a8b633ff1fda (patch)
tree6caede4b0e4f08db297ba960c3e6255d7ccc465d /utests
parentb714f3cf56cde049c9687984d1a05c833d80a70e (diff)
downloadbeignet-4bf8346d24970ba5d950f7e04131a8b633ff1fda.tar.gz
Utest: Add workgroup reduce any/all tests
Added the following unit tests: compiler_workgroup_any compiler_workgroup_all compiler_workgroup_reduce_add_int compiler_workgroup_reduce_add_uint compiler_workgroup_reduce_add_long compiler_workgroup_reduce_add_ulong compiler_workgroup_reduce_add_float compiler_workgroup_reduce_max_int compiler_workgroup_reduce_max_uint compiler_workgroup_reduce_max_long compiler_workgroup_reduce_max_ulong compiler_workgroup_reduce_max_float compiler_workgroup_reduce_min_int compiler_workgroup_reduce_min_uint compiler_workgroup_reduce_min_long compiler_workgroup_reduce_min_ulong compiler_workgroup_reduce_min_float Signed-off-by: Grigore Lupescu <grigore.lupescu at intel.com> Reviewed-by: Pan Xiuli <xiuli.pan@intel.com>
Diffstat (limited to 'utests')
-rw-r--r--utests/compiler_workgroup_reduce.cpp538
1 files changed, 339 insertions, 199 deletions
diff --git a/utests/compiler_workgroup_reduce.cpp b/utests/compiler_workgroup_reduce.cpp
index 40978435..f185666f 100644
--- a/utests/compiler_workgroup_reduce.cpp
+++ b/utests/compiler_workgroup_reduce.cpp
@@ -1,243 +1,383 @@
#include <cstdint>
#include <cstring>
#include <iostream>
+#include <cstdlib>
+#include <iomanip>
+#include <algorithm>
+
#include "utest_helper.hpp"
-void compiler_workgroup_reduce_min_uniform(void)
-{
- const size_t n = 17;
- uint32_t src = 253;
+using namespace std;
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_min_uniform");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
- OCL_SET_ARG(0, sizeof(uint32_t), &src);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[0]);
- globals[0] = n;
- locals[0] = n;
+/* set to 1 for debug, output of input-expected data */
+#define DEBUG_STDOUT 0
- // Run the kernel on GPU
- OCL_NDRANGE(1);
+/* NDRANGE */
+#define WG_GLOBAL_SIZE 60
+#define WG_LOCAL_SIZE 30
- // Compare
- OCL_MAP_BUFFER(0);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%u ", ((uint32_t *)buf_data[0])[i]);
- OCL_ASSERT(((uint32_t *)buf_data[0])[i] == 253);
+enum WG_FUNCTION
+{
+ WG_ANY,
+ WG_ALL,
+ WG_REDUCE_ADD,
+ WG_REDUCE_MIN,
+ WG_REDUCE_MAX
+};
+
+/*
+ * Generic compute-expected function for op REDUCE/ANY/ALL
+ * and any variable type
+ */
+template<class T>
+static void compute_expected(WG_FUNCTION wg_func,
+ T* input,
+ T* expected)
+{
+ if(wg_func == WG_ANY)
+ {
+ T wg_predicate = input[0];
+ for(uint32_t i = 1; i < WG_LOCAL_SIZE; i++)
+ wg_predicate = (int)wg_predicate | (int)input[i];
+ for(uint32_t i = 0; i < WG_LOCAL_SIZE; i++)
+ expected[i] = wg_predicate;
+ }
+ else if(wg_func == WG_ALL)
+ {
+ T wg_predicate = input[0];
+ for(uint32_t i = 1; i < WG_LOCAL_SIZE; i++)
+ wg_predicate = (int)wg_predicate & (int)input[i];
+ for(uint32_t i = 0; i < WG_LOCAL_SIZE; i++)
+ expected[i] = wg_predicate;
+ }
+ else if(wg_func == WG_REDUCE_ADD)
+ {
+ T wg_sum = input[0];
+ for(uint32_t i = 1; i < WG_LOCAL_SIZE; i++)
+ wg_sum += input[i];
+ for(uint32_t i = 0; i < WG_LOCAL_SIZE; i++)
+ expected[i] = wg_sum;
+ }
+ else if(wg_func == WG_REDUCE_MAX)
+ {
+ T wg_max = input[0];
+ for(uint32_t i = 1; i < WG_LOCAL_SIZE; i++)
+ wg_max = max(input[i], wg_max);
+ for(uint32_t i = 0; i < WG_LOCAL_SIZE; i++)
+ expected[i] = wg_max;
+ }
+ else if(wg_func == WG_REDUCE_MIN)
+ {
+ T wg_min = input[0];
+ for(uint32_t i = 1; i < WG_LOCAL_SIZE; i++)
+ wg_min = min(input[i], wg_min);
+ for(uint32_t i = 0; i < WG_LOCAL_SIZE; i++)
+ expected[i] = wg_min;
}
- OCL_UNMAP_BUFFER(0);
}
-MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_uniform);
-
-static uint32_t test_array_uint[64] = {23, 34, 16, 91, 25, 133, 7787, 134, 987, 9853, 33, 21, 865, 1441, 9083, 812,
- 10, 43435, 63, 445, 253, 65, 24, 30, 76, 989, 120 ,113 ,133, 41, 18, 91,
- 8321, 6712, 881, 911, 5, 788, 8991, 88, 19, 1110, 1231, 1341, 1983, 1983, 91, 212,
- 712, 31, 881, 963, 6801, 651, 9810, 77, 98, 5, 16, 1888, 141, 1613, 1771, 16};
-
-void compiler_workgroup_reduce_min_uint(void)
+/*
+ * Generic input-expected generate function for op REDUCE/ANY/ALL
+ * and any variable type
+ */
+template<class T>
+static void generate_data(WG_FUNCTION wg_func,
+ T* &input,
+ T* &expected)
{
- const size_t n = 60;
- uint32_t* src = test_array_uint;
+ input = new T[WG_GLOBAL_SIZE];
+ expected = new T[WG_GLOBAL_SIZE];
+
+ /* base value for all data types */
+ T base_val = (long)7 << (sizeof(T) * 5 - 3);
+
+ /* seed for random inputs */
+ srand (time(NULL));
+
+ /* generate inputs and expected values */
+ for(uint32_t gid = 0; gid < WG_GLOBAL_SIZE; gid += WG_LOCAL_SIZE)
+ {
+#if DEBUG_STDOUT
+ cout << endl << "IN: " << endl;
+#endif
+
+ /* input values */
+ for (uint32_t lid = 0; lid < WG_LOCAL_SIZE; lid++) {
+ /* initially 0, augment after */
+ input[gid + lid] = 0;
+
+ if (numeric_limits<T>::is_integer) {
+ /* check all data types, test ideal for QWORD types */
+ input[gid + lid] += ((rand() % 2 - 1) * base_val);
+ /* add trailing random bits, tests GENERAL cases */
+ input[gid + lid] += (rand() % 112);
+ /* always last bit is 1, ideal test ALL/ANY */
+ input[gid + lid] = (T)((long)input[gid + lid] | (long)1);
+ } else {
+ input[gid + lid] += rand();
+ input[gid + lid] += rand() / ((float)RAND_MAX + 1);
+ }
+
+#if DEBUG_STDOUT
+ /* output generated input */
+ cout << setw(4) << input[gid + lid] << ", " ;
+ if((lid + 1) % 8 == 0)
+ cout << endl;
+#endif
+ }
+
+ /* expected values */
+ compute_expected(wg_func, input + gid, expected + gid);
+
+#if DEBUG_STDOUT
+ /* output expected input */
+ cout << endl << "EXP: " << endl;
+ for(uint32_t lid = 0; lid < WG_LOCAL_SIZE; lid++) {
+ cout << setw(4) << expected[gid + lid] << ", " ;
+ if((lid + 1) % 8 == 0)
+ cout << endl;
+ }
+#endif
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_min_uint");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(uint32_t), NULL);
- OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
-
- OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(uint32_t));
- OCL_UNMAP_BUFFER(0);
-
- // Run the kernel on GPU
- OCL_NDRANGE(1);
-
- // Compare
- OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%u ", ((uint32_t *)buf_data[1])[i]);
- OCL_ASSERT(((uint32_t *)buf_data[1])[i] == 5);
}
- OCL_UNMAP_BUFFER(1);
}
-MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_uint);
-void compiler_workgroup_reduce_max_uint(void)
+/*
+ * Generic workgroup utest function for op REDUCE/ANY/ALL
+ * and any variable type
+ */
+template<class T>
+static void workgroup_generic(WG_FUNCTION wg_func,
+ T* input,
+ T* expected)
{
- const size_t n = 60;
- uint32_t* src = test_array_uint;
+ /* input and expected data */
+ generate_data(wg_func, input, expected);
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_max_uint");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(uint32_t), NULL);
+ /* prepare input for data type */
+ OCL_CREATE_BUFFER(buf[0], 0, WG_GLOBAL_SIZE * sizeof(T), NULL);
+ OCL_CREATE_BUFFER(buf[1], 0, WG_GLOBAL_SIZE * sizeof(T), NULL);
OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
+ /* set input data for GPU */
OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(uint32_t));
+ memcpy(buf_data[0], input, WG_GLOBAL_SIZE * sizeof(T));
OCL_UNMAP_BUFFER(0);
- // Run the kernel on GPU
+ /* run the kernel on GPU */
+ globals[0] = WG_GLOBAL_SIZE;
+ locals[0] = WG_LOCAL_SIZE;
OCL_NDRANGE(1);
- // Compare
+ /* check if mismatch */
OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%u ", ((uint32_t *)buf_data[1])[i]);
- OCL_ASSERT(((uint32_t *)buf_data[1])[i] == 43435);
- }
+ uint32_t mismatches = 0;
+
+ for (uint32_t i = 0; i < WG_GLOBAL_SIZE; i++)
+ if(((T *)buf_data[1])[i] != *(expected + i))
+ {
+ /* found mismatch on integer, increment */
+ if (numeric_limits<T>::is_integer) {
+ mismatches++;
+
+#if DEBUG_STDOUT
+ /* output mismatch */
+ cout << "Err at " << i << ", " << ((T *)buf_data[1])[i]
+ << " != " << *(expected + i) << endl;
+#endif
+ }
+ /* float error is tolerable though */
+ else {
+ float num_computed = ((T *)buf_data[1])[i];
+ float num_expected = *(expected + i);
+ float num_diff = abs(num_computed - num_expected) / abs(num_expected);
+ if (num_diff > 0.01f) {
+ mismatches++;
+
+#if DEBUG_STDOUT
+ /* output mismatch */
+ cout << "Err at " << i << ", " << ((T *)buf_data[1])[i]
+ << " != " << *(expected + i) << endl;
+#endif
+ }
+ }
+ }
+
+#if DEBUG_STDOUT
+ /* output mismatch count */
+ cout << "mismatches " << mismatches << endl;
+#endif
+
OCL_UNMAP_BUFFER(1);
+
+ OCL_ASSERT(mismatches == 0);
}
-MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_uint);
+/*
+ * Workgroup any/all utest functions
+ */
+void compiler_workgroup_any(void)
+{
+ cl_int *input = NULL;
+ cl_int *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_any");
+ workgroup_generic(WG_ANY, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_any);
+void compiler_workgroup_all(void)
+{
+ cl_int *input = NULL;
+ cl_int *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_all");
+ workgroup_generic(WG_ALL, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_all);
+/*
+ * Workgroup reduce add utest functions
+ */
+void compiler_workgroup_reduce_add_int(void)
+{
+ cl_int *input = NULL;
+ cl_int *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_add_int");
+ workgroup_generic(WG_REDUCE_ADD, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_int);
void compiler_workgroup_reduce_add_uint(void)
{
- const size_t n = 50;
- uint32_t* src = test_array_uint;
-
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_add_uint");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(uint32_t), NULL);
- OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
-
- uint32_t cpu_res = 0;
- for (size_t i = 0; i < n; i++)
- cpu_res += src[i];
-
- OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(uint32_t));
- OCL_UNMAP_BUFFER(0);
-
- // Run the kernel on GPU
- OCL_NDRANGE(1);
-
- // Compare
- OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%u ", ((uint32_t *)buf_data[1])[i]);
- OCL_ASSERT(((uint32_t *)buf_data[1])[i] == cpu_res);
- }
- OCL_UNMAP_BUFFER(1);
+ cl_uint *input = NULL;
+ cl_uint *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_add_uint");
+ workgroup_generic(WG_REDUCE_ADD, input, expected);
}
MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_uint);
-
-static float test_array_float[64] =
- {1.0234f, 0.34e32f, -13441.4334f, 1893.21f, -9999.0f, -88.00f, 1.3f, 1.0f,
- 2.33f, 134.44f, 263.0f, 1.0f, 0.0f, 344.900043f, 0.1e30f, 1.0e10f,
-
- 10.0f, 43.435f, 6.3f, 44.545f, 0.253f, 6.5f, 0.24f, 10.30f,
- 1312.76f, -0.00989f, 124213.120f, 1.13f, 1.33f, 4.1f, 1.8f, 3234.91f,
-
- 3.21e38f, 6.712f, 0.881f, 12.91f, 5.0f, 7.88f, 128991.0f, 8.8f,
- 0.0019f, -0.1110f, 12.0e31f, -3.3E38f, 1.983f, 1.983f, 10091.0f, 2.12f,
-
- 0.88712, 1e31f, -881.0f, -196e3f, 68.01f, -651.121f, 9.810f, -0.77f,
- 100.98f, 50.0f, 1000.16f, -18e18f, 0.141f, 1613.0f, 1.771f, -16.13f};
-
-void compiler_workgroup_reduce_min_float(void)
+void compiler_workgroup_reduce_add_long(void)
{
- const size_t n = 60;
- float* src = test_array_float;
-
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_min_float");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(float), NULL);
- OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
-
- OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(float));
- OCL_UNMAP_BUFFER(0);
-
- // Run the kernel on GPU
- OCL_NDRANGE(1);
-
- // Compare
- OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%f ", ((float *)buf_data[1])[i]);
- OCL_ASSERT(((float *)buf_data[1])[i] == -3.3E38f);
- }
- OCL_UNMAP_BUFFER(1);
+ cl_long *input = NULL;
+ cl_long *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_add_long");
+ workgroup_generic(WG_REDUCE_ADD, input, expected);
}
-MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_float);
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_long);
+void compiler_workgroup_reduce_add_ulong(void)
+{
+ cl_ulong *input = NULL;
+ cl_ulong *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_add_ulong");
+ workgroup_generic(WG_REDUCE_ADD, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_ulong);
+void compiler_workgroup_reduce_add_float(void)
+{
+ cl_float *input = NULL;
+ cl_float *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_add_float");
+ workgroup_generic(WG_REDUCE_ADD, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_float);
+/*
+ * Workgroup reduce max utest functions
+ */
+void compiler_workgroup_reduce_max_int(void)
+{
+ cl_int *input = NULL;
+ cl_int *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_max_int");
+ workgroup_generic(WG_REDUCE_MAX, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_int);
+void compiler_workgroup_reduce_max_uint(void)
+{
+ cl_uint *input = NULL;
+ cl_uint *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_max_uint");
+ workgroup_generic(WG_REDUCE_MAX, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_uint);
+void compiler_workgroup_reduce_max_long(void)
+{
+ cl_long *input = NULL;
+ cl_long *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_max_long");
+ workgroup_generic(WG_REDUCE_MAX, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_long);
+void compiler_workgroup_reduce_max_ulong(void)
+{
+ cl_ulong *input = NULL;
+ cl_ulong *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_max_ulong");
+ workgroup_generic(WG_REDUCE_MAX, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_ulong);
void compiler_workgroup_reduce_max_float(void)
{
- const size_t n = 60;
- float* src = test_array_float;
-
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_max_float");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(float), NULL);
- OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
-
- OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(float));
- OCL_UNMAP_BUFFER(0);
-
- // Run the kernel on GPU
- OCL_NDRANGE(1);
-
- // Compare
- OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%f ", ((float *)buf_data[1])[i]);
- OCL_ASSERT(((float *)buf_data[1])[i] == 3.21e38f);
- }
- OCL_UNMAP_BUFFER(1);
+ cl_float *input = NULL;
+ cl_float *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_max_float");
+ workgroup_generic(WG_REDUCE_MAX, input, expected);
}
MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_max_float);
-void compiler_workgroup_reduce_add_float(void)
+/*
+ * Workgroup reduce min utest functions
+ */
+void compiler_workgroup_reduce_min_int(void)
{
- const size_t n = 42;
- float* src = test_array_float;
-
- // Setup kernel and buffers
- OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce", "compiler_workgroup_reduce_add_float");
- OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);
- OCL_CREATE_BUFFER(buf[1], 0, n * sizeof(float), NULL);
- OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
- OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
- globals[0] = n;
- locals[0] = n;
-
- float cpu_res = 0;
- for (size_t i = 0; i < n; i++)
- cpu_res += src[i];
-
- OCL_MAP_BUFFER(0);
- memcpy(buf_data[0], src, n * sizeof(float));
- OCL_UNMAP_BUFFER(0);
-
- // Run the kernel on GPU
- OCL_NDRANGE(1);
-
- // Compare
- OCL_MAP_BUFFER(1);
- for (int32_t i = 0; i < (int32_t) n; ++i) {
- //printf("%f ", ((float *)buf_data[1])[i]);
- OCL_ASSERT(((float *)buf_data[1])[i] == cpu_res);
- }
- OCL_UNMAP_BUFFER(1);
+ cl_int *input = NULL;
+ cl_int *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_min_int");
+ workgroup_generic(WG_REDUCE_MIN, input, expected);
}
-MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_add_float);
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_int);
+void compiler_workgroup_reduce_min_uint(void)
+{
+ cl_uint *input = NULL;
+ cl_uint *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_min_uint");
+ workgroup_generic(WG_REDUCE_MIN, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_uint);
+void compiler_workgroup_reduce_min_long(void)
+{
+ cl_long *input = NULL;
+ cl_long *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_min_long");
+ workgroup_generic(WG_REDUCE_MIN, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_long);
+void compiler_workgroup_reduce_min_ulong(void)
+{
+ cl_ulong *input = NULL;
+ cl_ulong *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_min_ulong");
+ workgroup_generic(WG_REDUCE_MIN, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_ulong);
+void compiler_workgroup_reduce_min_float(void)
+{
+ cl_float *input = NULL;
+ cl_float *expected = NULL;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_workgroup_reduce",
+ "compiler_workgroup_reduce_min_float");
+ workgroup_generic(WG_REDUCE_MIN, input, expected);
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_workgroup_reduce_min_float);