[Piglit] [PATCH] cl: Add opencv-calLUT test

Tom Stellard tom at stellard.net
Thu Oct 17 02:03:56 CEST 2013


From: Tom Stellard <thomas.stellard at amd.com>

---
 tests/cl/program/execute/opencv-calLUT.cl | 88 +++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 tests/cl/program/execute/opencv-calLUT.cl

diff --git a/tests/cl/program/execute/opencv-calLUT.cl b/tests/cl/program/execute/opencv-calLUT.cl
new file mode 100644
index 0000000..2680bb6
--- /dev/null
+++ b/tests/cl/program/execute/opencv-calLUT.cl
@@ -0,0 +1,88 @@
+
+/*!
+[config]
+dimensions: 1
+global_size: 65536 1 1
+local_size:  256 1 1
+kernel_name: calLUT
+
+[test]
+# These are trivial inputs and outputs.  The main purpose of this test is to
+# make sure the optimizer doesn't rearrange the barrier calls in a way that
+# will hang the GPU.
+arg_out: 0 buffer uchar[256] repeat 0
+arg_in:  1 buffer int[256] repeat 1
+arg_in:  2 int 65536
+
+!*/
+
+// This kernel was taken from the opencv library (http://opencv.org)
+// Filename: modules/ocl/src/opencl/imgproc_histogram.cl
+// 
+//                           License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
+// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
+// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// @Authors
+//    Niko Li, newlife20080214 at gmail.com
+//    Jia Haipeng, jiahaipeng95 at gmail.com
+//    Xu Pang, pangxu010 at 163.com
+//    Wenju He, wenju at multicorewareinc.com
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+//   * Redistribution's of source code must retain the above copyright notice,
+//     this list of conditions and the following disclaimer.
+//
+//   * Redistribution's in binary form must reproduce the above copyright notice,
+//     this list of conditions and the following disclaimer in the documentation
+//     and/or other GpuMaterials provided with the distribution.
+//
+//   * The name of the copyright holders may not be used to endorse or promote products
+//     derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors as is and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//
+
+#define HISTOGRAM256_BIN_COUNT         (256)
+
+__kernel __attribute__((reqd_work_group_size(256,1,1)))void calLUT(
+                            __global uchar * dst,
+                            __constant int * hist,
+                            int total)
+{
+    int lid = get_local_id(0);
+    __local int sumhist[HISTOGRAM256_BIN_COUNT+1];
+
+    sumhist[lid]=hist[lid];
+    barrier(CLK_LOCAL_MEM_FENCE);
+    if(lid==0)
+    {
+        int sum = 0;
+        int i = 0;
+        while (!sumhist[i]) ++i;
+        sumhist[HISTOGRAM256_BIN_COUNT] = sumhist[i];
+        for(sumhist[i++] = 0; i<HISTOGRAM256_BIN_COUNT; i++)
+        {
+            sum+=sumhist[i];
+            sumhist[i]=sum;
+        }
+    }
+    barrier(CLK_LOCAL_MEM_FENCE);
+    float scale = 255.f/(total - sumhist[HISTOGRAM256_BIN_COUNT]);
+    dst[lid]= lid == 0 ? 0 : convert_uchar_sat(convert_float(sumhist[lid])*scale);
+}
-- 
1.7.11.4



More information about the Piglit mailing list