Add TCMalloc

This commit is contained in:
Roman Grundkiewicz 2017-11-02 10:33:47 +00:00
parent c31cb1e450
commit a3b72c2ffe
2 changed files with 51 additions and 4 deletions

View File

@ -49,12 +49,20 @@ if(USE_CUDNN)
endif(CUDNN_FOUND)
endif(USE_CUDNN)
find_package(Tcmalloc)
if(Tcmalloc_FOUND)
include_directories(${Tcmalloc_INCLUDE_DIR})
set(EXT_LIBS ${EXT_LIBS} ${Tcmalloc_LIBRARIES})
else(Tcmalloc_FOUND)
message(WARNING "Cannot find TCMalloc library. Continuing.")
endif(Tcmalloc_FOUND)
find_package(ZLIB)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
set(EXT_LIBS ${EXT_LIBS} ${ZLIB_LIBRARIES})
else(ZLIB_FOUND)
message(SEND_ERROR "Cannot find zlib" )
message(SEND_ERROR "Cannot find zlib.")
endif(ZLIB_FOUND)
set(BOOST_COMPONENTS system timer iostreams filesystem chrono program_options thread)

39
cmake/FindTcmalloc.cmake Normal file
View File

@ -0,0 +1,39 @@
# - Find Tcmalloc
# Find the native Tcmalloc includes and library
#
# Tcmalloc_INCLUDE_DIR - where to find Tcmalloc.h, etc.
# Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc.
# Tcmalloc_FOUND - True if Tcmalloc found.
find_path(Tcmalloc_INCLUDE_DIR google/tcmalloc.h)
if (USE_TCMALLOC)
set(Tcmalloc_NAMES tcmalloc)
else ()
set(Tcmalloc_NAMES tcmalloc_minimal tcmalloc)
endif ()
find_library(Tcmalloc_LIBRARY NAMES ${Tcmalloc_NAMES})
if (Tcmalloc_INCLUDE_DIR AND Tcmalloc_LIBRARY)
set(Tcmalloc_FOUND TRUE)
set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} )
else ()
set(Tcmalloc_FOUND FALSE)
set( Tcmalloc_LIBRARIES )
endif ()
if (Tcmalloc_FOUND)
message(STATUS "Found Tcmalloc: ${Tcmalloc_LIBRARY}")
else ()
message(STATUS "Not Found Tcmalloc")
if (Tcmalloc_FIND_REQUIRED)
message(STATUS "Looked for Tcmalloc libraries named ${Tcmalloc_NAMES}.")
message(FATAL_ERROR "Could NOT find Tcmalloc library")
endif ()
endif ()
mark_as_advanced(
Tcmalloc_LIBRARY
Tcmalloc_INCLUDE_DIR
)