Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit a1fdf33

Browse files
authored
Merge pull request #1185 from poojanilangekar/tbb
Modify CreateDropObjectSet to use tbb::concurrent_vector
2 parents 3b497b8 + 7f41dc2 commit a1fdf33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+767
-362
lines changed

cmake/Dependencies.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ include("cmake/External/gflags.cmake")
2121
include_directories(SYSTEM ${GFLAGS_INCLUDE_DIRS})
2222
list(APPEND Peloton_LINKER_LIBS ${GFLAGS_LIBRARIES})
2323

24+
# ---[ intel tbb
25+
find_package(TBB REQUIRED)
26+
include_directories(SYSTEM ${TBB_INCLUDE_DIRS})
27+
list(APPEND Peloton_LINKER_LIBS ${TBB_LIBRARIES})
28+
2429
# ---[ Cap'nProto
2530
include("cmake/External/capnproto.cmake")
2631
include_directories(SYSTEM ${CAPNP_INCLUDE_DIRS})

cmake/Modules/FindTBB.cmake

Lines changed: 359 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,359 @@
1+
# - Find ThreadingBuildingBlocks include dirs and libraries
2+
# Use this module by invoking find_package with the form:
3+
# find_package(TBB
4+
# [REQUIRED] # Fail with error if TBB is not found
5+
# ) #
6+
# Once done, this will define
7+
#
8+
# TBB_FOUND - system has TBB
9+
# TBB_INCLUDE_DIRS - the TBB include directories
10+
# TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or
11+
# malloc proxy
12+
#
13+
# TBB_VERSION_MAJOR - Major Product Version Number
14+
# TBB_VERSION_MINOR - Minor Product Version Number
15+
# TBB_INTERFACE_VERSION - Engineering Focused Version Number
16+
# TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version
17+
# still supported. This uses the engineering
18+
# focused interface version numbers.
19+
#
20+
# TBB_MALLOC_FOUND - system has TBB malloc library
21+
# TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories
22+
# TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined
23+
#
24+
# TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library
25+
# TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories
26+
# TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined
27+
#
28+
#
29+
# This module reads hints about search locations from variables:
30+
# ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds
31+
# ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation
32+
# ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb
33+
# libraries. Should be specified with ENV TBB_ROOT
34+
# and optionally...
35+
# ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build
36+
#
37+
#
38+
# Modified by Robert Maynard from the original OGRE source
39+
#
40+
#-------------------------------------------------------------------
41+
# This file is part of the CMake build system for OGRE
42+
# (Object-oriented Graphics Rendering Engine)
43+
# For the latest info, see http://www.ogre3d.org/
44+
#
45+
# The contents of this file are placed in the public domain. Feel
46+
# free to make use of it in any way you like.
47+
#-------------------------------------------------------------------
48+
#
49+
#=============================================================================
50+
# Copyright 2010-2012 Kitware, Inc.
51+
# Copyright 2012 Rolf Eike Beer <[email protected]>
52+
#
53+
# Distributed under the OSI-approved BSD License (the "License");
54+
# see accompanying file Copyright.txt for details.
55+
#
56+
# This software is distributed WITHOUT ANY WARRANTY; without even the
57+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
58+
# See the License for more information.
59+
#=============================================================================
60+
# (To distribute this file outside of CMake, substitute the full
61+
# License text for the above reference.)
62+
63+
64+
#=============================================================================
65+
# FindTBB helper functions and macros
66+
#
67+
68+
#===============================================
69+
# Do the final processing for the package find.
70+
#===============================================
71+
macro(findpkg_finish PREFIX)
72+
# skip if already processed during this run
73+
if (NOT ${PREFIX}_FOUND)
74+
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
75+
set(${PREFIX}_FOUND TRUE)
76+
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
77+
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
78+
else ()
79+
if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
80+
message(FATAL_ERROR "Required library ${PREFIX} not found.")
81+
endif ()
82+
endif ()
83+
84+
#mark the following variables as internal variables
85+
mark_as_advanced(${PREFIX}_INCLUDE_DIR
86+
${PREFIX}_LIBRARY
87+
${PREFIX}_LIBRARY_DEBUG
88+
${PREFIX}_LIBRARY_RELEASE)
89+
endif ()
90+
endmacro()
91+
92+
#===============================================
93+
# Generate debug names from given release names
94+
#===============================================
95+
macro(get_debug_names PREFIX)
96+
foreach(i ${${PREFIX}})
97+
set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
98+
endforeach()
99+
endmacro()
100+
101+
#===============================================
102+
# See if we have env vars to help us find tbb
103+
#===============================================
104+
macro(getenv_path VAR)
105+
set(ENV_${VAR} $ENV{${VAR}})
106+
# replace won't work if var is blank
107+
if (ENV_${VAR})
108+
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
109+
endif ()
110+
endmacro()
111+
112+
#===============================================
113+
# Couple a set of release AND debug libraries
114+
#===============================================
115+
macro(make_library_set PREFIX)
116+
if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG)
117+
set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG})
118+
elseif (${PREFIX}_RELEASE)
119+
set(${PREFIX} ${${PREFIX}_RELEASE})
120+
elseif (${PREFIX}_DEBUG)
121+
set(${PREFIX} ${${PREFIX}_DEBUG})
122+
endif ()
123+
endmacro()
124+
125+
126+
#=============================================================================
127+
# Now to actually find TBB
128+
#
129+
130+
# Get path, convert backslashes as ${ENV_${var}}
131+
getenv_path(TBB_ROOT)
132+
133+
# initialize search paths
134+
set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT})
135+
set(TBB_INC_SEARCH_PATH "")
136+
set(TBB_LIB_SEARCH_PATH "")
137+
138+
139+
# If user built from sources
140+
set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX})
141+
if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT)
142+
getenv_path(TBB_BUILD_DIR)
143+
if (NOT ENV_TBB_BUILD_DIR)
144+
set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build)
145+
endif ()
146+
147+
# include directory under ${ENV_TBB_ROOT}/include
148+
list(APPEND TBB_LIB_SEARCH_PATH
149+
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release
150+
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug)
151+
endif ()
152+
153+
154+
# For Windows, let's assume that the user might be using the precompiled
155+
# TBB packages from the main website. These use a rather awkward directory
156+
# structure (at least for automatically finding the right files) depending
157+
# on platform and compiler, but we'll do our best to accommodate it.
158+
# Not adding the same effort for the precompiled linux builds, though. Those
159+
# have different versions for CC compiler versions and linux kernels which
160+
# will never adequately match the user's setup, so there is no feasible way
161+
# to detect the "best" version to use. The user will have to manually
162+
# select the right files. (Chances are the distributions are shipping their
163+
# custom version of tbb, anyway, so the problem is probably nonexistent.)
164+
if (WIN32 AND MSVC)
165+
set(COMPILER_PREFIX "vc7.1")
166+
if (MSVC_VERSION EQUAL 1400)
167+
set(COMPILER_PREFIX "vc8")
168+
elseif(MSVC_VERSION EQUAL 1500)
169+
set(COMPILER_PREFIX "vc9")
170+
elseif(MSVC_VERSION EQUAL 1600)
171+
set(COMPILER_PREFIX "vc10")
172+
elseif(MSVC_VERSION EQUAL 1700)
173+
set(COMPILER_PREFIX "vc11")
174+
elseif(MSVC_VERSION EQUAL 1800)
175+
set(COMPILER_PREFIX "vc12")
176+
elseif(MSVC_VERSION EQUAL 1900)
177+
set(COMPILER_PREFIX "vc14")
178+
endif ()
179+
180+
# for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path
181+
foreach (dir IN LISTS TBB_PREFIX_PATH)
182+
if (CMAKE_CL_64)
183+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib)
184+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX})
185+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib)
186+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX})
187+
else ()
188+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib)
189+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX})
190+
endif ()
191+
endforeach ()
192+
endif ()
193+
194+
# For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9)
195+
# and above and AppleClang
196+
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
197+
NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0)
198+
set (USE_LIBCXX OFF)
199+
cmake_policy(GET CMP0025 POLICY_VAR)
200+
201+
if (POLICY_VAR STREQUAL "NEW")
202+
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
203+
set (USE_LIBCXX ON)
204+
endif ()
205+
else ()
206+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
207+
set (USE_LIBCXX ON)
208+
endif ()
209+
endif ()
210+
211+
if (USE_LIBCXX)
212+
foreach (dir IN LISTS TBB_PREFIX_PATH)
213+
list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib)
214+
endforeach ()
215+
endif ()
216+
endif ()
217+
218+
# check compiler ABI
219+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
220+
set(COMPILER_PREFIX)
221+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
222+
list(APPEND COMPILER_PREFIX "gcc4.7")
223+
endif()
224+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
225+
list(APPEND COMPILER_PREFIX "gcc4.4")
226+
endif()
227+
list(APPEND COMPILER_PREFIX "gcc4.1")
228+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
229+
set(COMPILER_PREFIX)
230+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
231+
list(APPEND COMPILER_PREFIX "gcc4.7")
232+
endif()
233+
list(APPEND COMPILER_PREFIX "gcc4.4")
234+
else() # Assume compatibility with 4.4 for other compilers
235+
list(APPEND COMPILER_PREFIX "gcc4.4")
236+
endif ()
237+
238+
# if platform architecture is explicitly specified
239+
set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM})
240+
if (TBB_ARCH_PLATFORM)
241+
foreach (dir IN LISTS TBB_PREFIX_PATH)
242+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib)
243+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM})
244+
endforeach ()
245+
endif ()
246+
247+
foreach (dir IN LISTS TBB_PREFIX_PATH)
248+
foreach (prefix IN LISTS COMPILER_PREFIX)
249+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
250+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64)
251+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix})
252+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib)
253+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib)
254+
else ()
255+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32)
256+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix})
257+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib)
258+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib)
259+
endif ()
260+
endforeach()
261+
endforeach ()
262+
263+
# add general search paths
264+
foreach (dir IN LISTS TBB_PREFIX_PATH)
265+
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb
266+
${dir}/Libs)
267+
list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include
268+
${dir}/include/tbb)
269+
endforeach ()
270+
271+
set(TBB_LIBRARY_NAMES tbb)
272+
get_debug_names(TBB_LIBRARY_NAMES)
273+
274+
275+
find_path(TBB_INCLUDE_DIR
276+
NAMES tbb/tbb.h
277+
PATHS ${TBB_INC_SEARCH_PATH})
278+
279+
find_library(TBB_LIBRARY_RELEASE
280+
NAMES ${TBB_LIBRARY_NAMES}
281+
PATHS ${TBB_LIB_SEARCH_PATH})
282+
find_library(TBB_LIBRARY_DEBUG
283+
NAMES ${TBB_LIBRARY_NAMES_DEBUG}
284+
PATHS ${TBB_LIB_SEARCH_PATH})
285+
make_library_set(TBB_LIBRARY)
286+
287+
findpkg_finish(TBB)
288+
289+
#if we haven't found TBB no point on going any further
290+
if (NOT TBB_FOUND)
291+
return()
292+
endif ()
293+
294+
#=============================================================================
295+
# Look for TBB's malloc package
296+
set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc)
297+
get_debug_names(TBB_MALLOC_LIBRARY_NAMES)
298+
299+
find_path(TBB_MALLOC_INCLUDE_DIR
300+
NAMES tbb/tbb.h
301+
PATHS ${TBB_INC_SEARCH_PATH})
302+
303+
find_library(TBB_MALLOC_LIBRARY_RELEASE
304+
NAMES ${TBB_MALLOC_LIBRARY_NAMES}
305+
PATHS ${TBB_LIB_SEARCH_PATH})
306+
find_library(TBB_MALLOC_LIBRARY_DEBUG
307+
NAMES ${TBB_MALLOC_LIBRARY_NAMES_DEBUG}
308+
PATHS ${TBB_LIB_SEARCH_PATH})
309+
make_library_set(TBB_MALLOC_LIBRARY)
310+
311+
findpkg_finish(TBB_MALLOC)
312+
313+
#=============================================================================
314+
# Look for TBB's malloc proxy package
315+
set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy)
316+
get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES)
317+
318+
find_path(TBB_MALLOC_PROXY_INCLUDE_DIR
319+
NAMES tbb/tbbmalloc_proxy.h
320+
PATHS ${TBB_INC_SEARCH_PATH})
321+
322+
find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE
323+
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES}
324+
PATHS ${TBB_LIB_SEARCH_PATH})
325+
find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG
326+
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DEBUG}
327+
PATHS ${TBB_LIB_SEARCH_PATH})
328+
make_library_set(TBB_MALLOC_PROXY_LIBRARY)
329+
330+
findpkg_finish(TBB_MALLOC_PROXY)
331+
332+
333+
#=============================================================================
334+
#parse all the version numbers from tbb
335+
if(NOT TBB_VERSION)
336+
337+
#only read the start of the file
338+
file(READ
339+
"${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h"
340+
TBB_VERSION_CONTENTS
341+
LIMIT 2048)
342+
343+
string(REGEX REPLACE
344+
".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
345+
TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}")
346+
347+
string(REGEX REPLACE
348+
".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
349+
TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}")
350+
351+
string(REGEX REPLACE
352+
".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
353+
TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
354+
355+
string(REGEX REPLACE
356+
".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
357+
TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
358+
359+
endif()

0 commit comments

Comments
 (0)