diff options
author | Benjamin Segovia <segovia.benjamin@gmail.com> | 2012-05-03 17:25:24 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-08-10 16:17:00 -0700 |
commit | 89381fa7285c462521671c2e10712b9d5a7a8dcb (patch) | |
tree | 419b47bd6195aadbe7e06c9c4cca832657784588 /utests | |
parent | 7237f7fc9d49888b1b7b3412f38ec7b28977036b (diff) | |
download | beignet-89381fa7285c462521671c2e10712b9d5a7a8dcb.tar.gz |
Added flat_address_space tests
Diffstat (limited to 'utests')
-rw-r--r-- | utests/CMakeLists.txt | 27 | ||||
-rw-r--r-- | utests/compiler_eot.cpp | 55 | ||||
-rw-r--r-- | utests/runtime_flat_address_space.cpp | 32 | ||||
-rw-r--r-- | utests/utest_file_map.hpp | 2 | ||||
-rw-r--r-- | utests/utest_helper.cpp | 8 | ||||
-rw-r--r-- | utests/utest_helper.hpp | 12 |
6 files changed, 42 insertions, 94 deletions
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 29c753bb..4a54d2ab 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -1,15 +1,20 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include) -ADD_EXECUTABLE(run - utest_error.c - utest_helper.cpp - utest_file_map.cpp - utest_assert.cpp - utest.cpp - utest_run.cpp - compiler_write_only.cpp - compiler_copy_buffer.cpp - compiler_copy_buffer_row.cpp) -TARGET_LINK_LIBRARIES(run cl m) +ADD_LIBRARY(utests SHARED + utest_error.c + utest_helper.cpp + utest_file_map.cpp + utest_assert.cpp + utest.cpp + compiler_write_only.cpp + compiler_copy_buffer.cpp + compiler_copy_buffer_row.cpp) +TARGET_LINK_LIBRARIES(utests cl m) + +ADD_EXECUTABLE(run utest_run.cpp) +TARGET_LINK_LIBRARIES(run utests) + +ADD_EXECUTABLE(flat_address_space runtime_flat_address_space.cpp) +TARGET_LINK_LIBRARIES(flat_address_space utests) diff --git a/utests/compiler_eot.cpp b/utests/compiler_eot.cpp deleted file mode 100644 index b55bed46..00000000 --- a/utests/compiler_eot.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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[]) -{ - const size_t n = 1024; - const size_t global_work_size = n; - const size_t local_work_size = 16; - int status = 0; - - if ((status = cl_test_init("dummy.ll", "hop", LLVM)) != 0) goto error; - - /* Run the kernel */ - CALL (clEnqueueNDRangeKernel, queue, - kernel, - 1, - NULL, - &global_work_size, - &local_work_size, - 0, - NULL, - NULL); - - cl_test_destroy(); - printf("%i memory leaks\n", clIntelReportUnfreed()); - assert(clIntelReportUnfreed() == 0); - -error: - cl_report_error(status); - return status; -} - diff --git a/utests/runtime_flat_address_space.cpp b/utests/runtime_flat_address_space.cpp index 68aeef05..d2f4aefb 100644 --- a/utests/runtime_flat_address_space.cpp +++ b/utests/runtime_flat_address_space.cpp @@ -17,35 +17,32 @@ * Author: Benjamin Segovia <benjamin.segovia@intel.com> */ -#include "cl_test.h" - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> +#include "utest_helper.hpp" int -main (int argc, char *argv[]) +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; + int status = 0; 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 */ + for (uint32_t 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]); + // Set source and destination + OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &dst[j]); - /* Run the kernel */ - CALL (clEnqueueNDRangeKernel, queue, + // Run the kernel + OCL_CALL (clEnqueueNDRangeKernel, queue, kernel, 1, NULL, @@ -55,21 +52,20 @@ main (int argc, char *argv[]) NULL, NULL); - /* Be sure that everything run fine */ + // 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 (uint32_t i = 0; i < n; ++i) assert(dst_buffer[i] == int(i)); + OCL_CALL (clIntelUnmapBuffer, dst[j]); } - for (j = 0; j < 24; ++j) CALL (clReleaseMemObject, dst[j]); + for (uint32_t j = 0; j < 24; ++j) OCL_CALL (clReleaseMemObject, dst[j]); cl_test_destroy(); printf("%i memory leaks\n", clIntelReportUnfreed()); assert(clIntelReportUnfreed() == 0); error: - cl_report_error(status); return status; } diff --git a/utests/utest_file_map.hpp b/utests/utest_file_map.hpp index d01ca701..83d79ea5 100644 --- a/utests/utest_file_map.hpp +++ b/utests/utest_file_map.hpp @@ -27,7 +27,7 @@ #define __UTEST_FILE_MAP_HPP__ #include "CL/cl.h" -#include <stdlib.h> +#include <cstdlib> /* Map a file into memory for direct / cached / simple accesses */ typedef struct cl_file_map { diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 0083618f..d9979ae1 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -23,10 +23,10 @@ #include "CL/cl.h" #include "CL/cl_intel.h" -#include <stdio.h> -#include <stdint.h> -#include <string.h> -#include <assert.h> +#include <cstdio> +#include <cstdint> +#include <cstring> +#include <casserth> #define FATAL(...) \ do { \ diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp index bf0c3ab2..c17a1e71 100644 --- a/utests/utest_helper.hpp +++ b/utests/utest_helper.hpp @@ -30,9 +30,9 @@ #include "utest.hpp" #include "utest_assert.hpp" #include "utest_error.h" -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> +#include <cassert> +#include <cstdio> +#include <cstdlib> #define OCL_THROW_ERROR(FN, STATUS) \ do { \ @@ -68,8 +68,10 @@ #define OCL_UNMAP_BUFFER(ID) \ do { \ - OCL_CALL (clIntelUnmapBuffer, buf[ID]); \ - buf_data[ID] = NULL; \ + if (buf[ID] != NULL) { \ + OCL_CALL (clIntelUnmapBuffer, buf[ID]); \ + buf_data[ID] = NULL; \ + } \ } while (0) #define OCL_NDRANGE(DIM_N) \ |