Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2019-11-13 06:55:39 +0300
committerRay Molenkamp <github@lazydodo.com>2019-11-13 06:55:39 +0300
commitd60a60f0cb85087ddebcb47910847f1a0c4b916c (patch)
treeced2886d1048b56e2b02c4a24744f4d18b6d079d
parentc69872bd2ff31690156ca5c15a54de850d8e17a7 (diff)
Add support for the TBB allocator on windows.
The heap on windows is single threaded causing it to lag behind linux in performance in allocation heavy multithreaded scenarios, BVH building is a prime example. See https://developer.blender.org/D6218 for benchmark results for testing with the allocator enabled/disabled you can set the environment variable TBB_MALLOC_DISABLE_REPLACEMENT=1 to disable the TBB allocator. Reviewed By: @sergey Differential Revision: https://developer.blender.org/D6218
-rw-r--r--CMakeLists.txt9
-rw-r--r--build_files/build_environment/cmake/tbb.cmake25
-rw-r--r--build_files/build_environment/cmake/versions.cmake4
-rw-r--r--build_files/cmake/platform/platform_win32.cmake3
-rw-r--r--source/creator/CMakeLists.txt15
-rw-r--r--source/creator/creator.c5
6 files changed, 53 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e468ae36906..1fda1be608b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,6 +170,14 @@ option_defaults_init(
_init_OPENSUBDIV
)
+# TBB malloc is only supported on for windows currently
+if(WIN32)
+ set(_init_TBB_MALLOC_PROXY ON)
+else()
+ set(_init_TBB_MALLOC_PROXY OFF)
+endif()
+
+
# customize...
if(UNIX AND NOT APPLE)
# some of these libraries are problematic on Linux
@@ -463,6 +471,7 @@ mark_as_advanced(WITH_ASSERT_ABORT)
option(WITH_BOOST "Enable features depending on boost" ON)
option(WITH_TBB "Enable features depending on TBB (OpenVDB, OpenImageDenoise, sculpt multithreading)" ON)
+option(WITH_TBB_MALLOC_PROXY "Enable the TBB malloc replacement" ${_init_TBB_MALLOC_PROXY})
# Unit testsing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake
index 26c52e00c76..597c1bfe00c 100644
--- a/build_files/build_environment/cmake/tbb.cmake
+++ b/build_files/build_environment/cmake/tbb.cmake
@@ -15,13 +15,21 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
-
-set(TBB_EXTRA_ARGS
- -DTBB_BUILD_SHARED=Off
- -DTBB_BUILD_TBBMALLOC=On
- -DTBB_BUILD_TBBMALLOC_PROXY=Off
- -DTBB_BUILD_STATIC=On
+if(WIN32)
+ set(TBB_EXTRA_ARGS
+ -DTBB_BUILD_SHARED=On
+ -DTBB_BUILD_TBBMALLOC=On
+ -DTBB_BUILD_TBBMALLOC_PROXY=On
+ -DTBB_BUILD_STATIC=On
)
+else()
+ set(TBB_EXTRA_ARGS
+ -DTBB_BUILD_SHARED=Off
+ -DTBB_BUILD_TBBMALLOC=On
+ -DTBB_BUILD_TBBMALLOC_PROXY=Off
+ -DTBB_BUILD_STATIC=On
+ )
+endif()
# CMake script for TBB from https://github.com/wjakob/tbb/blob/master/CMakeLists.txt
ExternalProject_Add(external_tbb
@@ -39,6 +47,10 @@ if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_tbb after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc.dll
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.dll
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/
DEPENDEES install
)
@@ -46,6 +58,7 @@ if(WIN32)
if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_tbb after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib
DEPENDEES install
)
endif()
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index af071fbb019..fb3b96a5da7 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -149,9 +149,9 @@ set(PYTHON_SHORT_VERSION_NO_DOTS 37)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH d33e4aae66097051c2eca45ee3604803)
-set(TBB_VERSION 2018_U5)
+set(TBB_VERSION 2019_U9)
set(TBB_URI https://github.com/01org/tbb/archive/${TBB_VERSION}.tar.gz)
-set(TBB_HASH ff3ae09f8c23892fbc3008c39f78288f)
+set(TBB_HASH 584edbec127c508f2cd5b6e79ad200fc)
set(OPENVDB_VERSION 5.1.0)
set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 9fe5359c5bd..c378a41fdcf 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -573,6 +573,9 @@ if(WITH_TBB)
set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
+ if(WITH_TBB_MALLOC_PROXY)
+ add_definitions(-DWITH_TBB_MALLOC)
+ endif()
else()
if(WITH_OPENIMAGEDENOISE)
message(STATUS "TBB disabled, also disabling OpenImageDenoise")
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 50b4f3edfa9..8a85c75cade 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -81,6 +81,12 @@ if(WITH_CODEC_FFMPEG)
add_definitions(-DWITH_FFMPEG)
endif()
+if(WITH_TBB)
+ blender_include_dirs(${TBB_INCLUDE_DIRS})
+ link_directories(${LIBDIR}/tbb/lib)
+endif()
+
+
if(WITH_PYTHON)
blender_include_dirs(../blender/python)
add_definitions(-DWITH_PYTHON)
@@ -806,6 +812,15 @@ elseif(WIN32)
)
endif()
+ if(WITH_TBB_MALLOC_PROXY)
+ install(
+ FILES
+ ${LIBDIR}/tbb/lib/tbbmalloc.dll
+ ${LIBDIR}/tbb/lib/tbbmalloc_proxy.dll
+ DESTINATION "."
+ )
+ endif()
+
if(WITH_CODEC_SNDFILE)
install(
FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 3632eb9eb9a..f6c2b707c8f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -29,6 +29,11 @@
# include "utfconv.h"
#endif
+#if defined(WITH_TBB_MALLOC) && defined(_MSC_VER)
+# pragma comment(lib, "tbbmalloc_proxy.lib")
+# pragma comment(linker, "/include:__TBB_malloc_proxy")
+#endif
+
#include "MEM_guardedalloc.h"
#include "CLG_log.h"