ソースを参照

Merge pull request #8642 from jakesmith/hpcc-15533

HPCC-15533 Use TBB scalable memory allocator where available

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 年 前
コミット
e450e69dbe

+ 1 - 1
cmake_modules/FindTBB.cmake

@@ -15,7 +15,7 @@
 ################################################################################
 
 
-# - Try to find the TBB compression library
+# - Try to find the TBB library
 # Once done this will define
 #
 #  TBB_FOUND - system has the TBB library

+ 55 - 0
cmake_modules/FindTBBMALLOC.cmake

@@ -0,0 +1,55 @@
+################################################################################
+#    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()

+ 15 - 0
cmake_modules/commonSetup.cmake

@@ -114,6 +114,7 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
       option(USE_TBB "Enable Threading Building Block support" OFF)
   else()
       option(USE_TBB "Enable Threading Building Block support" ON)
+      option(USE_TBBMALLOC "Enable Threading Building Block scalable allocator proxy support" ON)
   endif()
 
   option(LOGGING_SERVICE "Configure use of logging service" ON)
@@ -853,6 +854,20 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
         set(TBB_INCLUDE_DIR "")
       endif(USE_TBB)
 
+      if(USE_TBBMALLOC)
+        find_package(TBBMALLOC)
+        if (TBBMALLOC_FOUND)
+          add_definitions (-D_USE_TBBMALLOC)
+        else()
+          if(USE_OPTIONAL)
+            message(WARNING "Optional TBBMALLOC requested, but missing")
+            set(USE_TBBMALLOC OFF)
+          else()
+            message(FATAL_ERROR "TBB malloc proxy requested but package not found")
+          endif()
+        endif()
+      endif(USE_TBBMALLOC)
+
   ENDIF()
   ###########################################################################
   ###

+ 4 - 0
system/jlib/CMakeLists.txt

@@ -198,6 +198,10 @@ target_link_libraries ( jlib
         lz4
        )
 
+if (USE_TBBMALLOC)
+   target_link_libraries ( jlib ${TBBMALLOC_LIBRARIES})
+endif()
+
 if ( ${HAVE_LIBDL} )
 target_link_libraries ( jlib dl)
 endif ( ${HAVE_LIBDL} )