diff options
-rw-r--r-- | CMake/FindStandaloneGbeCompiler.cmake | 35 | ||||
-rw-r--r-- | CMakeLists.txt | 15 | ||||
-rwxr-xr-x | GetGenID.sh | 26 | ||||
-rw-r--r-- | backend/CMakeLists.txt | 20 | ||||
-rw-r--r-- | backend/src/CMakeLists.txt | 20 | ||||
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | utests/CMakeLists.txt | 5 |
7 files changed, 110 insertions, 16 deletions
diff --git a/CMake/FindStandaloneGbeCompiler.cmake b/CMake/FindStandaloneGbeCompiler.cmake new file mode 100644 index 00000000..c27980e1 --- /dev/null +++ b/CMake/FindStandaloneGbeCompiler.cmake @@ -0,0 +1,35 @@ +# Find the standalone gbe compiler +# +# STANDALONE_GBE_COMPILER_DIR - base path of standalone compiler +# STANDALONE_GBE_COMPILER - full file name of standalone compiler +# GEN_PCI_ID - Gen's PCI ID + +IF (STANDALONE_GBE_COMPILER_DIR) + FIND_PROGRAM(STANDALONE_GBE_COMPILER + NAMES gbe_bin_generater + DOC "standalone gbe compiler executable" + PATHS ${STANDALONE_GBE_COMPILER_DIR} NO_DEFAULT_PATH) +ELSE (STANDALONE_GBE_COMPILER_DIR) + FIND_PROGRAM(STANDALONE_GBE_COMPILER + NAMES gbe_bin_generater + DOC "standalone gbe compiler executable" + PATHS /usr/local/lib/beignet/) +ENDIF (STANDALONE_GBE_COMPILER_DIR) + +IF (STANDALONE_GBE_COMPILER) + MESSAGE(STATUS "Looking for standalone gbe compiler - found at ${STANDALONE_GBE_COMPILER}") + STRING(REGEX REPLACE "(.*)/.*" "\\1" STANDALONE_GBE_COMPILER_DIR ${STANDALONE_GBE_COMPILER}) + IF (NOT GEN_PCI_ID) + Find_Program(LSPCI lspci) + IF (LSPCI) + MESSAGE(STATUS "Looking for lspci - found") + ELSE (LSPCI) + MESSAGE(FATAL_ERROR "Looking for lspci - not found") + ENDIF (LSPCI) + EXECUTE_PROCESS(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/GetGenID.sh" + OUTPUT_VARIABLE GEN_PCI_ID) + MESSAGE(STATUS "Platform Gen PCI id is " ${GEN_PCI_ID}) + ENDIF (NOT GEN_PCI_ID) +ELSE (STANDALONE_GBE_COMPILER) + MESSAGE(FATAL_ERROR "Looking for standalone gbe compiler - not found") +ENDIF (STANDALONE_GBE_COMPILER)
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4da3561b..f929fbcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ elseif (COMPILER STREQUAL "CLANG") elseif (COMPILER STREQUAL "ICC") set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -wd2928 -Wall -fPIC -fstrict-aliasing -fp-model fast -msse4.1 -Wl,-E") endif () -set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof -fno-rtti") +set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof") set (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") @@ -76,9 +76,16 @@ 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") -# Front end stuff we need -#INCLUDE(CMake/FindLLVM.cmake) -Find_Package(LLVM 3.3) + +IF (USE_STANDALONE_GBE_COMPILER STREQUAL "true") + Find_Package(StandaloneGbeCompiler) +ELSE (USE_STANDALONE_GBE_COMPILER STREQUAL "true") + # Front end stuff we need + #INCLUDE(CMake/FindLLVM.cmake) + Find_Package(LLVM 3.3) + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") +ENDIF (USE_STANDALONE_GBE_COMPILER STREQUAL "true") + set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${LLVM_LDFLAGS}") diff --git a/GetGenID.sh b/GetGenID.sh new file mode 100755 index 00000000..7acf9bda --- /dev/null +++ b/GetGenID.sh @@ -0,0 +1,26 @@ +#!/bin/bash +genpciid=(0152 0162 0156 0166 015a 016a 0f31 0402 0412 0422 040a 041a 042a 0406 0416 0426 0c02 0c12 0c22 0c0a 0c1a 0c2a 0c06 0c16 0c26 0a02 0a12 0a22 0a0a 0a1a 0a2a 0a06 0a16 0a26 0d02 0d12 0d22 0d0a 0d1a 0d2a 0d06 0d16 0d26) +pciid=($(lspci -nn | grep "\[8086:.*\]" -o | awk -F : '{print $2}' | awk -F ] '{print $1}')) +n=${#pciid[*]} +i=0 +m=${#genpciid[*]} +j=0 +while [ $i -lt $n ] +do + id1=${pciid[$i]} + let j=0 + + while [ $j -lt $m ] + do + id2=${genpciid[$j]} + + if [ ${id1} == ${id2} ] + then + echo ${id1} + exit 0 + fi + let j=j+1 + done + + let i=i+1 +done diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index bf96baff..915d60fb 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -36,14 +36,28 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}) # Project source code ############################################################## add_subdirectory (src) + +if (USE_STANDALONE_GBE_COMPILER STREQUAL "true") +set(LOCAL_OCL_BITCODE_BIN ${STANDALONE_GBE_COMPILER_DIR}/beignet.bc) +set(LOCAL_OCL_HEADER_DIR ${STANDALONE_GBE_COMPILER_DIR}/include) +set(LOCAL_OCL_PCH_OBJECT ${STANDALONE_GBE_COMPILER_DIR}/beignet.pch) +endif (USE_STANDALONE_GBE_COMPILER STREQUAL "true") + set(LOCAL_OCL_BITCODE_BIN "${LOCAL_OCL_BITCODE_BIN}" PARENT_SCOPE) set(LOCAL_OCL_HEADER_DIR "${LOCAL_OCL_HEADER_DIR}" PARENT_SCOPE) set(LOCAL_OCL_PCH_OBJECT "${LOCAL_OCL_PCH_OBJECT}" PARENT_SCOPE) - set(LOCAL_GBE_OBJECT_DIR ${LOCAL_GBE_OBJECT_DIR} PARENT_SCOPE) set(LOCAL_INTERP_OBJECT_DIR ${LOCAL_INTERP_OBJECT_DIR} PARENT_SCOPE) set (GBE_BIN_GENERATER - env OCL_BITCODE_LIB_PATH=${LOCAL_OCL_BITCODE_BIN} OCL_HEADER_FILE_DIR=${LOCAL_OCL_HEADER_DIR} OCL_PCH_PATH=${LOCAL_OCL_PCH_OBJECT} LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src/gbe_bin_generater - PARENT_SCOPE) + env OCL_BITCODE_LIB_PATH=${LOCAL_OCL_BITCODE_BIN} OCL_HEADER_FILE_DIR=${LOCAL_OCL_HEADER_DIR} OCL_PCH_PATH=${LOCAL_OCL_PCH_OBJECT}) +if (USE_STANDALONE_GBE_COMPILER STREQUAL "true") +set (GBE_BIN_GENERATER + ${GBE_BIN_GENERATER} ${STANDALONE_GBE_COMPILER_DIR}/gbe_bin_generater + PARENT_SCOPE) +else (USE_STANDALONE_GBE_COMPILER STREQUAL "true") +set (GBE_BIN_GENERATER + ${GBE_BIN_GENERATER} LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src/gbe_bin_generater + PARENT_SCOPE) +endif (USE_STANDALONE_GBE_COMPILER STREQUAL "true") diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt index e6d84f98..ce83c62f 100644 --- a/backend/src/CMakeLists.txt +++ b/backend/src/CMakeLists.txt @@ -9,7 +9,12 @@ configure_file ( "GBEConfig.h" ) +#do not involve libocl if the standalone compiler is given, +if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true")) add_subdirectory(libocl) +add_dependencies(beignet_bitcode libocl) +endif () + set (LOCAL_GBE_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libgbe.so" PARENT_SCOPE) set (LOCAL_INTERP_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libgbeinterp.so" PARENT_SCOPE) set (LOCAL_OCL_BITCODE_BIN "${OCL_OBJECT_DIR}/beignet.bc" PARENT_SCOPE) @@ -128,14 +133,16 @@ set (GBE_LINK_LIBRARIES include_directories (.) link_directories (${LLVM_LIBRARY_DIRS} ${DRM_LIBDIR}) include_directories(${LLVM_INCLUDE_DIRS}) -add_library (gbe SHARED ${GBE_SRC}) +#do not build libgbe.so if the standalone compiler is given +if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true")) +add_library (gbe SHARED ${GBE_SRC}) target_link_libraries(gbe ${GBE_LINK_LIBRARIES}) +add_dependencies(gbe beignet_bitcode) +endif (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true")) add_library(gbeinterp SHARED gbe_bin_interpreter.cpp) -add_dependencies(gbe beignet_bitcode) - if (LLVM_VERSION_NODOT VERSION_EQUAL 34) find_library(TERMINFO NAMES tinfo ncurses) if (${TERMINFO} STREQUAL TERMINFO-NOTFOUND) @@ -148,6 +155,8 @@ endif(LLVM_VERSION_NODOT VERSION_EQUAL 34) link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR}) +#do not build nor install if the standalone compiler is given +if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true")) if (BUILD_STANDALONE_GBE_COMPILER STREQUAL "true") macro(remove_cxx_flag flag) string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -168,9 +177,10 @@ ADD_EXECUTABLE(gbe_bin_generater gbe_bin_generater.cpp) TARGET_LINK_LIBRARIES(gbe_bin_generater gbe) endif () - install (TARGETS gbe LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR}) -install (TARGETS gbeinterp LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR}) install (FILES ${OCL_OBJECT_DIR}/beignet.bc DESTINATION ${BEIGNET_INSTALL_DIR}) install (FILES ${OCL_OBJECT_DIR}/beignet.pch DESTINATION ${BEIGNET_INSTALL_DIR}) install (FILES ${OCL_HEADER_FILES} DESTINATION ${BEIGNET_INSTALL_DIR}/include) +endif (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true")) + +install (TARGETS gbeinterp LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7182bada..a55f84d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,18 +10,19 @@ foreach (KF ${KERNEL_FILES}) set (input_file ${KERNEL_PATH}/${KF}.cl) set (output_file ${KERNEL_PATH}/${KF}_str.c) list (APPEND KERNEL_STR_FILES ${output_file}) + list (GET GBE_BIN_GENERATER -1 GBE_BIN_FILE) if(GEN_PCI_ID) add_custom_command( OUTPUT ${output_file} COMMAND rm -rf ${output_file} COMMAND ${GBE_BIN_GENERATER} -s ${input_file} -o${output_file} -t${GEN_PCI_ID} - DEPENDS ${input_file} ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater) + DEPENDS ${input_file} ${GBE_BIN_FILE}) else(GEN_PCI_ID) add_custom_command( OUTPUT ${output_file} COMMAND rm -rf ${output_file} COMMAND ${GBE_BIN_GENERATER} -s ${input_file} -o${output_file} - DEPENDS ${input_file} ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater) + DEPENDS ${input_file} ${GBE_BIN_FILE}) endif(GEN_PCI_ID) endforeach (KF) endmacro (MakeKernelBinStr) diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 5b29c0b5..9623dc15 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -219,16 +219,17 @@ endif (X11_FOUND) SET (kernel_bin ${CMAKE_CURRENT_SOURCE_DIR}/../kernels/compiler_ceil) +list (GET GBE_BIN_GENERATER -1 GBE_BIN_FILE) if(GEN_PCI_ID) ADD_CUSTOM_COMMAND( OUTPUT ${kernel_bin}.bin COMMAND ${GBE_BIN_GENERATER} ${kernel_bin}.cl -o${kernel_bin}.bin -t${GEN_PCI_ID} - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater ${kernel_bin}.cl) + DEPENDS ${GBE_BIN_FILE} ${kernel_bin}.cl) else(GEN_PCI_ID) ADD_CUSTOM_COMMAND( OUTPUT ${kernel_bin}.bin COMMAND ${GBE_BIN_GENERATER} ${kernel_bin}.cl -o${kernel_bin}.bin - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater ${kernel_bin}.cl) + DEPENDS ${GBE_BIN_FILE} ${kernel_bin}.cl) endif(GEN_PCI_ID) ADD_CUSTOM_TARGET(kernel_bin.bin |