[Piglit] [PATCH] cl: Add test case from opencv's knn_find_nearest kernel

Tom Stellard thomas.stellard at amd.com
Wed Feb 4 07:49:44 PST 2015


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

diff --git a/tests/cl/program/execute/opencv-knearest.cl b/tests/cl/program/execute/opencv-knearest.cl
new file mode 100644
index 0000000..f394beb
--- /dev/null
+++ b/tests/cl/program/execute/opencv-knearest.cl
@@ -0,0 +1,77 @@
+//  This test case was extracted from the knn_find_nearest kernel in the OpenCV
+//  (opencv.org) project: 2.4 branch, modules/ocl/src/opencl/knearest.cl
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
+//                           License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
+// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// @Authors
+//    Jin Ma, jin 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 materials 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.
+//
+
+/*!
+[config]
+dimensions: 2
+global_size: 1 1 0
+kernel_name: test
+build_options: -DOPENCL
+
+[test]
+name: test
+arg_out: 0 buffer float[1]  1.0
+arg_in:  1 int              6
+arg_in:  2 buffer float[8] 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0
+!*/
+
+kernel void test(global float *out, int K1, global float *nr)
+{
+	int j;
+	int cur_count, best_count = 0, prev_start = 0;
+	float best_val = 50.0;
+	for(j = 1; j <= K1; j++)
+		if(j == K1 || nr[j] != nr[(j - 1)])
+		{
+			cur_count = j - prev_start;
+			if(best_count < cur_count)
+			{
+				best_count = cur_count;
+				best_val = nr[(j - 1)];
+			}
+			prev_start = j;
+		}
+	out[0] = best_val;
+}
-- 
1.8.5.5



More information about the Piglit mailing list