Browse Source

Merge pull request #9889 from Michael-Gardner/hpcc-17228

HPCC-17228 Add TBB as submodule

Reviewed-By: Mark Kelly <mark.kelly@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 năm trước cách đây
mục cha
commit
d31564b55d

+ 3 - 0
.gitmodules

@@ -46,3 +46,6 @@
 [submodule "plugins/redis/hiredis"]
 	path = plugins/redis/hiredis
 	url = https://github.com/hpcc-systems/hiredis.git
+[submodule "system/tbb_sm/tbb"]
+    path = system/tbb_sm/tbb
+    url = https://github.com/hpcc-systems/tbb.git

+ 0 - 59
cmake_modules/FindTBB.cmake

@@ -1,59 +0,0 @@
-################################################################################
-#    HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-################################################################################
-
-
-# - Try to find the TBB library
-# Once done this will define
-#
-#  TBB_FOUND - system has the TBB library
-#  TBB_INCLUDE_DIR - the TBB include directory
-#  TBB_LIBRARIES - The libraries needed to use TBB
-
-IF (NOT TBB_FOUND)
-  SET (tbb_lib "tbb")
-
-  IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
-    IF (WIN32)
-      IF (${ARCH64BIT} EQUAL 1)
-        SET (osdir "Win64")
-      ELSE()
-        SET (osdir "Win32")
-      ENDIF()
-      SET (tbbver "1.2.8")
-    ELSE()
-      SET (osdir "unknown")
-      SET (tbbver "unknown")
-    ENDIF()
-    IF (NOT ("${osdir}" STREQUAL "unknown"))
-      FIND_PATH (TBB_INCLUDE_DIR NAMES tbb/tbb.h PATHS "${EXTERNALS_DIRECTORY}/tbb/${tbbver}/include" NO_DEFAULT_PATH)
-      FIND_LIBRARY (TBB_LIBRARIES NAMES ${tbb_lib} PATHS "${EXTERNALS_DIRECTORY}/tbb/${tbbver}/lib/${osdir}" NO_DEFAULT_PATH)
-    ENDIF()
-  ENDIF()
-
-  if (USE_NATIVE_LIBRARIES)
-    # if we didn't find in externals, look in system include path
-    FIND_PATH (TBB_INCLUDE_DIR NAMES tbb/tbb.h)
-    FIND_LIBRARY (TBB_LIBRARIES NAMES ${tbb_lib})
-  endif()
-
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(TBB DEFAULT_MSG
-    TBB_LIBRARIES
-    TBB_INCLUDE_DIR
-  )
-
-  MARK_AS_ADVANCED(TBB_INCLUDE_DIR TBB_LIBRARIES)
-ENDIF()

+ 0 - 55
cmake_modules/FindTBBMALLOC.cmake

@@ -1,55 +0,0 @@
-################################################################################
-#    HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-################################################################################
-
-
-# - Try to find the TBB malloc proxy library
-# Once done this will define
-#
-#  TBBMALLOC_FOUND - system has the TBBMALLOC library
-#  TBBMALLOC_LIBRARIES - The libraries needed to use TBBMALLOC
-
-IF (NOT TBBMALLOC_FOUND)
-  SET (tbbmalloc_lib "tbbmalloc_proxy")
-
-  IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
-    IF (WIN32)
-      IF (${ARCH64BIT} EQUAL 1)
-        SET (osdir "Win64")
-      ELSE()
-        SET (osdir "Win32")
-      ENDIF()
-      SET (tbbver "1.2.8")
-    ELSE()
-      SET (osdir "unknown")
-      SET (tbbver "unknown")
-    ENDIF()
-    IF (NOT ("${osdir}" STREQUAL "unknown"))
-      FIND_LIBRARY (TBBMALLOC_LIBRARIES NAMES ${tbbmalloc_lib} PATHS "${EXTERNALS_DIRECTORY}/tbb/${tbbver}/lib/${osdir}" NO_DEFAULT_PATH)
-    ENDIF()
-  ENDIF()
-
-  if (USE_NATIVE_LIBRARIES)
-    # if we didn't find in externals, look in system include path
-    FIND_LIBRARY (TBBMALLOC_LIBRARIES NAMES ${tbbmalloc_lib})
-  endif()
-
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(TBBMALLOC DEFAULT_MSG
-    TBBMALLOC_LIBRARIES
-  )
-
-  MARK_AS_ADVANCED(TBBMALLOC_LIBRARIES)
-ENDIF()

+ 2 - 14
cmake_modules/commonSetup.cmake

@@ -877,24 +877,12 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
       endif()
 
       if(USE_TBB)
-        find_package(TBB)
-        if (TBB_FOUND)
+          message(STATUS "Enabled use of TBB")
           add_definitions (-D_USE_TBB)
-        else()
-          message(FATAL_ERROR "TBB requested but package not found")
-        endif()
-      else()
-        set(TBB_INCLUDE_DIR "")
       endif(USE_TBB)
-
       if(USE_TBBMALLOC)
-        find_package(TBBMALLOC)
-        if (TBBMALLOC_FOUND)
+          message(STATUS "Enabled use of TBBMALLOC")
           add_definitions (-D_USE_TBBMALLOC)
-        else()
-            message(WARNING "Optional TBBMALLOC requested, but missing")
-            set(USE_TBBMALLOC OFF)
-        endif()
       endif(USE_TBBMALLOC)
 
   ENDIF()

+ 5 - 4
common/thorhelper/CMakeLists.txt

@@ -93,7 +93,7 @@ include_directories (
          ./../../rtl/include 
          ./../../roxie/roxiemem
          ./../../testing/unittests
-         ${TBB_INCLUDE_DIR}
+         ./../../system/tbb_sm/tbb/include
          ./../../system/security/shared
     )
 
@@ -114,8 +114,9 @@ if (USE_NUMA)
  target_link_libraries ( thorhelper numa )
 endif ()
 
-if (${USE_TBB} )
-   target_link_libraries ( thorhelper ${TBB_LIBRARIES})
+if (USE_TBB)
+   add_dependencies ( thorhelper tbb )
+   target_link_libraries ( thorhelper libtbb )
 endif()
 
 
@@ -130,4 +131,4 @@ IF (USE_ZLIB)
         ${ZLIB_LIBRARIES}
         zcrypt
     )
-ENDIF()
+ENDIF()

+ 2 - 1
roxie/ccd/CMakeLists.txt

@@ -123,7 +123,8 @@ IF (USE_OPENSSL)
 ENDIF()
 
 IF (USE_TBBMALLOC)
-   target_link_libraries ( ccd ${TBBMALLOC_LIBRARIES})
+   add_dependencies ( ccd tbb )
+   target_link_libraries ( ccd libtbbmalloc_proxy libtbbmalloc)
 ENDIF()
 
 

+ 4 - 2
roxie/roxiemem/CMakeLists.txt

@@ -38,6 +38,7 @@ include_directories (
          ./../../system/jlib
          ./../../rtl/include
          ./../../testing/unittests
+         ./../../system/tbb_sm/tbb/include
     )
 
 ADD_DEFINITIONS( -D_USRDLL -DROXIEMEM_EXPORTS)
@@ -47,8 +48,9 @@ if (NOT PLUGIN)
   install ( TARGETS roxiemem RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} )
 endif()
 
-if (${USE_TBB} )
-   target_link_libraries ( roxiemem ${TBB_LIBRARIES})
+if(USE_TBB)
+    add_dependencies(roxiemem tbb)
+    target_link_libraries(roxiemem libtbb)
 endif()
 
 target_link_libraries ( roxiemem

+ 1 - 0
system/CMakeLists.txt

@@ -20,6 +20,7 @@ HPCC_ADD_SUBDIRECTORY (jlib)
 
 if (NOT JLIB_ONLY)
    HPCC_ADD_SUBDIRECTORY (hrpc)
+   HPCC_ADD_SUBDIRECTORY (tbb_sm)
    HPCC_ADD_SUBDIRECTORY (mp)
    HPCC_ADD_SUBDIRECTORY (security)
    HPCC_ADD_SUBDIRECTORY (xmllib)

+ 92 - 0
system/tbb_sm/CMakeLists.txt

@@ -0,0 +1,92 @@
+################################################################################
+#    HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+################################################################################
+
+# Component: tbb
+
+#####################################################
+# Description:
+# ------------
+#    Cmake Input File for tbb, tbbmalloc, tbbproxy
+#####################################################
+
+project( tbb )
+
+if(USE_TBB OR USE_TBBMALLOC)
+    # tbb target
+    execute_process(
+        COMMAND /bin/bash -c "grep TBB_COMPATIBLE_INTERFACE_VERSION tbb_stddef.h | egrep -o [0-9.]+"
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tbb/include/tbb
+        OUTPUT_VARIABLE SONAME_VER
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
+    
+    execute_process(
+        COMMAND /bin/bash -c "${CMAKE_MAKE_PROGRAM} info | awk 'BEGIN{FS=\"=\";} /^tbb_build_prefix/{print $2;}'"
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tbb
+        OUTPUT_VARIABLE TBB_BUILD_NAME
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
+    set(TBB_BUILD_NAME "${TBB_BUILD_NAME}_release")
+    add_custom_command(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so.${SONAME_VER}
+               ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so
+               ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so.${SONAME_VER}
+               ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so
+               ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so.${SONAME_VER}
+               ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so
+        COMMAND ${CMAKE_MAKE_PROGRAM} tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR} cfg=release
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tbb
+        )
+    add_custom_target(tbb
+        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so.${SONAME_VER}
+                ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so
+                ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so.${SONAME_VER}
+                ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so
+                ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so.${SONAME_VER}
+                ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so
+        )
+
+    add_library(libtbb SHARED IMPORTED GLOBAL)
+    add_library(libtbbmalloc SHARED IMPORTED GLOBAL)
+    add_library(libtbbmalloc_proxy SHARED IMPORTED GLOBAL)
+    set_property(
+        TARGET libtbb
+        PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so)
+    set_property(
+        TARGET libtbbmalloc
+        PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so)
+    set_property(
+        TARGET libtbbmalloc_proxy
+        PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so)
+
+    install(CODE "set(ENV{LD_LIBRARY_PATH} \"\$ENV{LD_LIBRARY_PATH}:${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}/${TBB_BUILD_NAME}\")")
+    if(USE_TBB)
+        install(FILES
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so.${SONAME_VER}
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbb.so
+            DESTINATION lib)
+    endif()
+    if(USE_TBBMALLOC)
+        install(FILES
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so.${SONAME_VER}
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc.so
+            DESTINATION lib)
+        install(FILES
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so.${SONAME_VER}
+            ${CMAKE_CURRENT_BINARY_DIR}/${TBB_BUILD_NAME}/libtbbmalloc_proxy.so
+            DESTINATION lib)
+    endif()
+endif()

+ 1 - 0
system/tbb_sm/tbb

@@ -0,0 +1 @@
+Subproject commit 1d5d04ce101eaaadf8b57955366d7758c09e7950

+ 2 - 1
thorlcr/graph/graph_lcr.cmake

@@ -77,7 +77,8 @@ target_link_libraries ( graph_lcr
     )
 
 if (USE_TBBMALLOC)
-   target_link_libraries ( graph_lcr ${TBBMALLOC_LIBRARIES})
+   add_dependencies ( graph_lcr tbb)
+   target_link_libraries ( graph_lcr libtbbmalloc_proxy libtbbmalloc)
 endif()