Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
4b5d04f4
Commit
4b5d04f4
authored
Feb 29, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed tbb hang in Android apps
parent
d05b788d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
26 deletions
+40
-26
CMakeLists.txt
3rdparty/tbb/CMakeLists.txt
+4
-4
android_additional.h
3rdparty/tbb/android_additional.h
+35
-21
OpenCVCompilerOptions.cmake
cmake/OpenCVCompilerOptions.cmake
+1
-1
No files found.
3rdparty/tbb/CMakeLists.txt
View file @
4b5d04f4
...
@@ -92,16 +92,16 @@ list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
...
@@ -92,16 +92,16 @@ list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
add_definitions
(
-D__TBB_DYNAMIC_LOAD_ENABLED=0
#required
add_definitions
(
-D__TBB_DYNAMIC_LOAD_ENABLED=0
#required
-D__TBB_BUILD=1
#required
-D__TBB_BUILD=1
#required
-D__TBB_USE_GENERIC_DWORD_LOAD_STORE=1
#needed by TBB 4.0 update 1,2
-D__TBB_SURVIVE_THREAD_SWITCH=0
#no cilk on Android
-D__TBB_TASK_CPP_DIRECTLY_INCLUDED=1
#needed by TBB 4.0 update 3
-D__TBB_USE_GENERIC_DWORD_LOAD_STORE=1
#needed by TBB 4.0 update 1,2; fixed in TBB 4.0 update 3 but it has 2 new problems
-DUSE_PTHREAD
#required
-DTBB_USE_GCC_BUILTINS=1
#required
-DTBB_USE_GCC_BUILTINS=1
#required
-DTBB_USE_DEBUG=0
#just ot be sure
-DTBB_USE_DEBUG=0
#just ot be sure
-DTBB_NO_LEGACY=1
#don't need backward compatibility
-DTBB_NO_LEGACY=1
#don't need backward compatibility
-DUSE_PTHREAD
#required
-DDO_ITT_NOTIFY=0
#it seems that we don't need these notifications
-DDO_ITT_NOTIFY=0
#it seems that we don't need these notifications
)
)
add_library
(
tbb STATIC
${
lib_srcs
}
${
lib_hdrs
}
)
add_library
(
tbb STATIC
${
lib_srcs
}
${
lib_hdrs
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/android_additional.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/version_string.tmp"
)
target_link_libraries
(
tbb c m dl
)
target_link_libraries
(
tbb c m dl
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-w -include
\"
${
CMAKE_CURRENT_SOURCE_DIR
}
/android_additional.h
\"
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-w -include
\"
${
CMAKE_CURRENT_SOURCE_DIR
}
/android_additional.h
\"
"
)
...
...
3rdparty/tbb/android_additional.h
View file @
4b5d04f4
#include <sys/syscall.h>
#include <cstdio>
#include <pthread.h>
typedef
unsigned
long
cpu_set_t
;
static
inline
int
getPossibleCPUs
()
#define __NCPUBITS (8 * sizeof (unsigned long))
{
FILE
*
cpuPossible
=
fopen
(
"/sys/devices/system/cpu/possible"
,
"r"
);
if
(
!
cpuPossible
)
#define CPU_SET(cpu, cpusetp) \
return
1
;
((*(cpusetp)) |= (1UL << ((cpu) % __NCPUBITS)))
#define CPU_ISSET(cpu, cpusetp) \
char
buf
[
2000
];
//big enough for 1000 CPUs in worst possible configuration
((*(cpusetp)) & (1UL << ((cpu) % __NCPUBITS)))
char
*
pbuf
=
fgets
(
buf
,
sizeof
(
buf
),
cpuPossible
);
fclose
(
cpuPossible
);
if
(
!
pbuf
)
return
1
;
#define CPU_ZERO(cpusetp) \
//parse string of form "0-1,3,5-7,10,13-15"
memset((cpusetp), 0, sizeof(cpu_set_t))
int
cpusAvailable
=
0
;
inline
static
int
while
(
*
pbuf
)
sched_setaffinity
(
pid_t
pid
,
size_t
len
,
cpu_set_t
const
*
cpusetp
)
{
{
const
char
*
pos
=
pbuf
;
return
syscall
(
__NR_sched_setaffinity
,
pid
,
len
,
cpusetp
);
bool
range
=
false
;
while
(
*
pbuf
&&
*
pbuf
!=
','
)
{
if
(
*
pbuf
==
'-'
)
range
=
true
;
++
pbuf
;
}
if
(
*
pbuf
)
*
pbuf
++
=
0
;
if
(
!
range
)
++
cpusAvailable
;
else
{
int
rstart
=
0
,
rend
=
0
;
sscanf
(
pos
,
"%d-%d"
,
&
rstart
,
&
rend
);
cpusAvailable
+=
rend
-
rstart
+
1
;
}
}
return
cpusAvailable
?
cpusAvailable
:
1
;
}
}
inline
static
int
#define __TBB_HardwareConcurrency() getPossibleCPUs()
sched_getaffinity
(
pid_t
pid
,
size_t
len
,
cpu_set_t
const
*
cpusetp
)
{
return
syscall
(
__NR_sched_getaffinity
,
pid
,
len
,
cpusetp
);
}
cmake/OpenCVCompilerOptions.cmake
View file @
4b5d04f4
...
@@ -108,7 +108,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
...
@@ -108,7 +108,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# Profiling?
# Profiling?
if
(
ENABLE_PROFILING
)
if
(
ENABLE_PROFILING
)
set
(
OPENCV_EXTRA_C_FLAGS_RELEASE
"
${
OPENCV_EXTRA_C_FLAGS_RELEASE
}
-pg -g"
)
set
(
OPENCV_EXTRA_C_FLAGS_RELEASE
"
${
OPENCV_EXTRA_C_FLAGS_RELEASE
}
-pg -g"
)
elseif
(
NOT APPLE
)
elseif
(
NOT APPLE
AND NOT ANDROID
)
# Remove unreferenced functions: function level linking
# Remove unreferenced functions: function level linking
set
(
OPENCV_EXTRA_C_FLAGS
"
${
OPENCV_EXTRA_C_FLAGS
}
-ffunction-sections"
)
set
(
OPENCV_EXTRA_C_FLAGS
"
${
OPENCV_EXTRA_C_FLAGS
}
-ffunction-sections"
)
endif
()
endif
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment