summaryrefslogtreecommitdiff
path: root/utests/app_mandelbrot.cpp
blob: 239b0b5dd7be77e722f6d96296d7784099e98b3b (plain)
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
/* 
 * 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 = 64;
static const size_t h = 64;
static const size_t iter = 4;

static void mandelbrot(void)
{
  const size_t global[2] = {w, h};
  const size_t local[2] = {16, 1};
  const size_t sz = w * h * sizeof(char[4]);

  OCL_CREATE_KERNEL("mandelbrot");

  cl_mem cl_dst = clCreateBuffer(ctx, 0, sz, NULL, NULL);
  OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &cl_dst);
  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(mandelbrot);