[Beignet] [PATCH] CMAKE: Add standalone benchmark build
Xiuli Pan
xiuli.pan at intel.com
Wed Mar 22 03:08:10 UTC 2017
From: Pan Xiuli <xiuli.pan at intel.com>
Now we can stadnalone build benchmark to test with other drivers.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
benchmark/CMakeLists.txt | 67 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 59 insertions(+), 8 deletions(-)
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
index f9b246b..f2b3a63 100644
--- a/benchmark/CMakeLists.txt
+++ b/benchmark/CMakeLists.txt
@@ -1,16 +1,62 @@
+###################################################################################
+# these configurations are copied from beignet root directory cmake for stand alone build.
+# do NOT set the NOT_BUILD_STAND_ALONE_UTEST if build the utest alone.
+if (NOT NOT_BUILD_STAND_ALONE_UTEST)
+ message(STATUS "Building Stand Alone Benchmark")
+
+ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+
+ INCLUDE (FindPkgConfig)
+ Find_Package(PythonInterp)
+
+ # OpenCL
+ pkg_check_modules(OPENCL REQUIRED OpenCL)
+ IF(OPENCL_FOUND)
+ INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})
+ ENDIF(OPENCL_FOUND)
+
+ # Force Release with debug info
+ if (NOT CMAKE_BUILD_TYPE)
+ set (CMAKE_BUILD_TYPE RelWithDebInfo)
+ endif (NOT CMAKE_BUILD_TYPE)
+ message(STATUS "Building mode: " ${CMAKE_BUILD_TYPE})
+
+ set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "assure config" FORCE)
+
+ # Threads
+ Find_Package(Threads)
+
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_CXX_FLAGS}")
+ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DGBE_DEBUG=1")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DGBE_DEBUG=0")
+ set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DGBE_DEBUG=0")
+ set (CMAKE_C_FLAGS_DEBUG "-O0 -g -DGBE_DEBUG=1")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
+ set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -DGBE_DEBUG=0")
+ set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DGBE_DEBUG=0")
+endif (NOT NOT_BUILD_STAND_ALONE_UTEST)
+###################################################################################
+
+configure_file (
+ "setenv.sh.in"
+ "setenv.sh"
+ )
+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../utests
${CMAKE_CURRENT_SOURCE_DIR}/../include)
-
link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR})
set (benchmark_sources
- ../utests/utest_error.c
- ../utests/utest_assert.cpp
- ../utests/utest.cpp
- ../utests/utest_file_map.cpp
- ../utests/utest_helper.cpp
- ../utests/vload_bench.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/utest_error.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/utest_assert.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/utest.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/utest_file_map.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/utest_helper.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../utests/vload_bench.cpp
benchmark_copy_buf.cpp
benchmark_use_host_ptr_buffer.cpp
benchmark_read_buffer.cpp
@@ -29,7 +75,12 @@ SET(CMAKE_C_FLAGS "-DBUILD_BENCHMARK ${CMAKE_C_FLAGS}")
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)
+#TARGET_LINK_LIBRARIES(benchmarks cl m)
+if (NOT_BUILD_STAND_ALONE_UTEST)
+ TARGET_LINK_LIBRARIES(benchmarks cl m ${UTESTS_REQUIRED_GL_EGL_X11_LIB} ${CMAKE_THREAD_LIBS_INIT} ${UTESTS_REQUIRED_X11_LIB})
+else()
+ TARGET_LINK_LIBRARIES(benchmarks ${OPENCL_LIBRARIES} m ${UTESTS_REQUIRED_GL_EGL_X11_LIB} ${CMAKE_THREAD_LIBS_INIT} ${UTESTS_REQUIRED_X11_LIB})
+endif()
ADD_EXECUTABLE(benchmark_run benchmark_run.cpp)
TARGET_LINK_LIBRARIES(benchmark_run benchmarks)
--
2.7.4
More information about the Beignet
mailing list