Skip to content

Commit 8f4b6b3

Browse files
committed
get logical cpu count on modern apple platform
1 parent a88a4da commit 8f4b6b3

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

openmp/runtime/src/z_Linux_util.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,21 +1889,8 @@ static int __kmp_get_xproc(void) {
18891889

18901890
#elif KMP_OS_DARWIN
18911891

1892-
// Bug C77011 High "OpenMP Threads and number of active cores".
1893-
1894-
// Find the number of available CPUs.
1895-
kern_return_t rc;
1896-
host_basic_info_data_t info;
1897-
mach_msg_type_number_t num = HOST_BASIC_INFO_COUNT;
1898-
rc = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&info, &num);
1899-
if (rc == 0 && num == HOST_BASIC_INFO_COUNT) {
1900-
// Cannot use KA_TRACE() here because this code works before trace support
1901-
// is initialized.
1902-
r = info.avail_cpus;
1903-
} else {
1904-
KMP_WARNING(CantGetNumAvailCPU);
1905-
KMP_INFORM(AssumedNumCPU);
1906-
}
1892+
size_t len = sizeof(r);
1893+
sysctlbyname("hw.logicalcpu", &r, &len, NULL, 0);
19071894

19081895
#else
19091896

0 commit comments

Comments
 (0)