diff options
author | Benjamin Segovia <segovia.benjamin@gmail.com> | 2012-05-03 15:14:53 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-08-10 16:16:57 -0700 |
commit | 1a9bcd8ff623a0b96cb034df711e4b02bfab8c6e (patch) | |
tree | bb3085d39b10c5ca759466675f7c648cafd6fc4d /utests/runtime_flat_address_space.cpp | |
parent | 97c10d0a80665562cd4980fa9a8b4e5a52750f3a (diff) | |
download | beignet-1a9bcd8ff623a0b96cb034df711e4b02bfab8c6e.tar.gz |
tests -> utests
Diffstat (limited to 'utests/runtime_flat_address_space.cpp')
-rw-r--r-- | utests/runtime_flat_address_space.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/utests/runtime_flat_address_space.cpp b/utests/runtime_flat_address_space.cpp new file mode 100644 index 00000000..68aeef05 --- /dev/null +++ b/utests/runtime_flat_address_space.cpp @@ -0,0 +1,75 @@ +/* + * 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 "cl_test.h" + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int +main (int argc, char *argv[]) +{ + cl_mem dst[24]; + int *dst_buffer; + const size_t n = 32 * 1024 * 1024; + const size_t global_work_size = n; + const size_t local_work_size = 16; + int status = 0, i, j; + + if ((status = cl_test_init("test_write_only.cl", "test_write_only", SOURCE)) != 0) + goto error; + + for (j = 0; j < 24; ++j) { + /* Allocate the two buffers */ + dst[j] = clCreateBuffer(ctx, 0, n * sizeof(uint32_t), NULL, &status); + if (status != CL_SUCCESS) goto error; + + /* Set source and destination */ + CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &dst[j]); + + /* Run the kernel */ + CALL (clEnqueueNDRangeKernel, queue, + kernel, + 1, + NULL, + &global_work_size, + &local_work_size, + 0, + NULL, + NULL); + + /* Be sure that everything run fine */ + dst_buffer = (int *) clIntelMapBuffer(dst[j], &status); + if (status != CL_SUCCESS) + goto error; + for (i = 0; i < n; ++i) assert(dst_buffer[i] == i); + CALL (clIntelUnmapBuffer, dst[j]); + } + + for (j = 0; j < 24; ++j) CALL (clReleaseMemObject, dst[j]); + cl_test_destroy(); + printf("%i memory leaks\n", clIntelReportUnfreed()); + assert(clIntelReportUnfreed() == 0); + +error: + cl_report_error(status); + return status; +} + |