From 3fa989b610844781bb3c0a1138659cf1bc54a06c Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Mon, 28 Apr 2014 13:31:05 +0800 Subject: [PATCH] Init Benchmark suite The first benchmark case is name enqueue_copy_buf. Signed-off-by: Yi Sun Reviewed-by: Zhigang Gong --- CMakeLists.txt | 1 + benchmark/CMakeLists.txt | 21 ++++++++ benchmark/benchmark_run.cpp | 117 +++++++++++++++++++++++++++++++++++++++++ benchmark/enqueue_copy_buf.cpp | 69 ++++++++++++++++++++++++ utests/utest.hpp | 16 ++++++ 5 files changed, 224 insertions(+) create mode 100644 benchmark/CMakeLists.txt create mode 100644 benchmark/benchmark_run.cpp create mode 100644 benchmark/enqueue_copy_buf.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 60e6358..ccfc443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,7 @@ ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(backend) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(utests) +ADD_SUBDIRECTORY(benchmark) SET(CPACK_PACKAGE_VERSION_MAJOR "${LIBCL_DRIVER_VERSION_MAJOR}") SET(CPACK_PACKAGE_VERSION_MINOR "${LIBCL_DRIVER_VERSION_MINOR}") diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt new file mode 100644 index 0000000..fb28023 --- /dev/null +++ b/benchmark/CMakeLists.txt @@ -0,0 +1,21 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../utests + ${CMAKE_CURRENT_SOURCE_DIR}/../include) + + +link_directories (${LLVM_LIBRARY_DIR}) +set (benchmark_sources + ../utests/utest_error.c + ../utests/utest_assert.cpp + ../utests/utest.cpp + ../utests/utest_file_map.cpp + ../utests/utest_helper.cpp + enqueue_copy_buf.cpp) + +ADD_LIBRARY(benchmarks SHARED ${ADDMATHFUNC} ${benchmark_sources}) + +#TARGET_LINK_LIBRARIES(benchmarks cl m ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +TARGET_LINK_LIBRARIES(benchmarks cl m) + +ADD_EXECUTABLE(benchmark_run benchmark_run.cpp) +TARGET_LINK_LIBRARIES(benchmark_run benchmarks) diff --git a/benchmark/benchmark_run.cpp b/benchmark/benchmark_run.cpp new file mode 100644 index 0000000..b29ccc3 --- /dev/null +++ b/benchmark/benchmark_run.cpp @@ -0,0 +1,117 @@ +/* + * 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 . + * + * Author: Benjamin Segovia + */ + +/** + * \file utest_run.cpp + * \author Benjamin Segovia + * + * Just run the unit tests. The user can possibly provides the subset of it + */ +#include "utest_helper.hpp" +#include "utest_exception.hpp" +#include +#include + +static const char *shortopts = "c:lanh"; +struct option longopts[] = { +{"casename", required_argument, NULL, 'c'}, +{"list", no_argument, NULL, 'l'}, +{"all", no_argument, NULL, 'a'}, +{"allnoissue", no_argument, NULL, 'n'}, +{"help", no_argument, NULL, 'h'}, +{0, 0, 0, 0}, +}; + +void usage() +{ + std::cout << "\ +Usage:\n\ + ./utest_run