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
85c97f77
Commit
85c97f77
authored
Feb 26, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16675 from alalek:fix_js_build_getNumberOfCPUs
parents
c13a62ce
af9ded89
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
23 deletions
+32
-23
parallel.cpp
modules/core/src/parallel.cpp
+32
-23
No files found.
modules/core/src/parallel.cpp
View file @
85c97f77
...
...
@@ -747,7 +747,7 @@ int cv::getThreadNum(void)
}
#if defined __linux__ || defined __GLIBC__ || defined __
EMSCRIPTEN__ || defined __
HAIKU__ || defined __ANDROID__
#if defined __linux__ || defined __GLIBC__ || defined __HAIKU__ || defined __ANDROID__
#define CV_CPU_GROUPS_1
#endif
...
...
@@ -861,6 +861,7 @@ int cv::getNumberOfCPUs(void)
#endif
#if defined _WIN32
SYSTEM_INFO
sysinfo
;
#if (defined(_M_ARM) || defined(_M_ARM64) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501
GetNativeSystemInfo
(
&
sysinfo
);
...
...
@@ -870,6 +871,30 @@ int cv::getNumberOfCPUs(void)
unsigned
ncpus_sysinfo
=
sysinfo
.
dwNumberOfProcessors
<
0
?
1
:
sysinfo
.
dwNumberOfProcessors
;
/* Just a fail safe */
ncpus
=
minNonZero
(
ncpus
,
ncpus_sysinfo
);
#elif defined __APPLE__
int
numCPU
=
0
;
int
mib
[
4
];
size_t
len
=
sizeof
(
numCPU
);
/* set the mib for hw.ncpu */
mib
[
0
]
=
CTL_HW
;
mib
[
1
]
=
HW_AVAILCPU
;
// alternatively, try HW_NCPU;
/* get the number of CPUs from the system */
sysctl
(
mib
,
2
,
&
numCPU
,
&
len
,
NULL
,
0
);
if
(
numCPU
<
1
)
{
mib
[
1
]
=
HW_NCPU
;
sysctl
(
mib
,
2
,
&
numCPU
,
&
len
,
NULL
,
0
);
if
(
numCPU
<
1
)
numCPU
=
1
;
}
ncpus
=
minNonZero
(
ncpus
,
(
unsigned
)
numCPU
);
#elif defined CV_CPU_GROUPS_1
#if defined CV_HAVE_CGROUPS
...
...
@@ -883,7 +908,10 @@ int cv::getNumberOfCPUs(void)
static
unsigned
ncpus_impl_devices
=
(
unsigned
)
getNumberOfCPUsImpl
(
"/sys/devices/system/cpu/online"
);
ncpus
=
minNonZero
(
ncpus
,
ncpus_impl_devices
);
#endif
#if defined _GNU_SOURCE \
&& !defined(__EMSCRIPTEN__) \
&& !defined(__ANDROID__) // TODO: add check for modern Android NDK
cpu_set_t
cpu_set
;
...
...
@@ -895,32 +923,13 @@ int cv::getNumberOfCPUs(void)
#endif
#if !defined(_WIN32) && !defined(__APPLE__)
static
unsigned
cpu_count_sysconf
=
(
unsigned
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
ncpus
=
minNonZero
(
ncpus
,
cpu_count_sysconf
);
#elif defined __APPLE__
int
numCPU
=
0
;
int
mib
[
4
];
size_t
len
=
sizeof
(
numCPU
);
/* set the mib for hw.ncpu */
mib
[
0
]
=
CTL_HW
;
mib
[
1
]
=
HW_AVAILCPU
;
// alternatively, try HW_NCPU;
/* get the number of CPUs from the system */
sysctl
(
mib
,
2
,
&
numCPU
,
&
len
,
NULL
,
0
);
if
(
numCPU
<
1
)
{
mib
[
1
]
=
HW_NCPU
;
sysctl
(
mib
,
2
,
&
numCPU
,
&
len
,
NULL
,
0
);
if
(
numCPU
<
1
)
numCPU
=
1
;
}
ncpus
=
minNonZero
(
ncpus
,
(
unsigned
)
numCPU
);
#endif
return
ncpus
!=
0
?
ncpus
:
1
;
}
...
...
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