summaryrefslogtreecommitdiff
path: root/utests/compiler_mandelbrot_alternate.cpp
diff options
context:
space:
mode:
authorBenjamin Segovia <bsegovia@bsegovia-i70.sc.intel.com>2012-10-09 21:25:24 +0000
committerBenjamin Segovia <bsegovia@bsegovia-i70.sc.intel.com>2012-10-09 21:25:24 +0000
commit1a77b1a5aa13ba18635845b837bc26cf5aff859a (patch)
tree6f2e4ef8d088afb4bc43b356c94d7a636f9d8cdf /utests/compiler_mandelbrot_alternate.cpp
parent05af153d375c6c539e6359ce21b28c5bd1a3ca4c (diff)
downloadbeignet-1a77b1a5aa13ba18635845b837bc26cf5aff859a.tar.gz
Fixed select OCL builtin
Added a new mandelbrot (more efficient) still to improve regression and funtionality coverage
Diffstat (limited to 'utests/compiler_mandelbrot_alternate.cpp')
-rw-r--r--utests/compiler_mandelbrot_alternate.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/utests/compiler_mandelbrot_alternate.cpp b/utests/compiler_mandelbrot_alternate.cpp
new file mode 100644
index 00000000..f1c2960b
--- /dev/null
+++ b/utests/compiler_mandelbrot_alternate.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+#include "utest_helper.hpp"
+
+static int *dst = NULL;
+static const size_t w = 16;
+static const size_t h = 16;
+static const size_t iter = 4;
+static const float criterium = 4.f;
+
+static void compiler_mandelbrot_alternate(void)
+{
+ const size_t global[2] = {w, h};
+ const size_t local[2] = {16, 1};
+ const size_t sz = w * h * sizeof(char[4]);
+ const float rcpW = 1.f / float(w);
+ const float rcpH = 1.f / float(h);
+
+ OCL_CREATE_KERNEL("compiler_mandelbrot_alternate");
+
+ cl_mem cl_dst = clCreateBuffer(ctx, 0, sz, NULL, NULL);
+ OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &cl_dst);
+ OCL_CALL (clSetKernelArg, kernel, 1, sizeof(float), &rcpW);
+ OCL_CALL (clSetKernelArg, kernel, 2, sizeof(float), &rcpH);
+ OCL_CALL (clSetKernelArg, kernel, 3, sizeof(float), &criterium);
+ OCL_CALL (clEnqueueNDRangeKernel, queue, kernel, 2, NULL, global, local, 0, NULL, NULL);
+ dst = (int *) clIntelMapBuffer(cl_dst, NULL);
+
+ cl_write_bmp(dst, w, h, "mandelbrot.bmp");
+ OCL_CALL (clIntelUnmapBuffer, cl_dst);
+ OCL_CALL (clReleaseMemObject, cl_dst);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_mandelbrot_alternate);
+