1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* 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.1 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 = 256;
static const size_t h = 256;
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 rcpWidth = 1.f / float(w);
const float rcpHeight = 1.f / float(h);
OCL_CREATE_KERNEL("compiler_mandelbrot_alternate");
OCL_CREATE_BUFFER(buf[0], 0, sz, NULL);
OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &buf[0]);
OCL_CALL (clSetKernelArg, kernel, 1, sizeof(float), &rcpWidth);
OCL_CALL (clSetKernelArg, kernel, 2, sizeof(float), &rcpHeight);
OCL_CALL (clSetKernelArg, kernel, 3, sizeof(float), &criterium);
OCL_CALL (clEnqueueNDRangeKernel, queue, kernel, 2, NULL, global, local, 0, NULL, NULL);
OCL_MAP_BUFFER(0);
dst = (int *) buf_data[0];
/* Save the image (for debug purpose) */
cl_write_bmp(dst, w, h, "compiler_mandelbrot_alternate.bmp");
/* Compare with the golden image */
OCL_CHECK_IMAGE(dst, w, h, "compiler_mandelbrot_alternate_ref.bmp");
}
MAKE_UTEST_FROM_FUNCTION(compiler_mandelbrot_alternate);
|