aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime
diff options
context:
space:
mode:
authornihui <shuizhuyuanluo@126.com>2024-04-02 23:38:40 +0800
committerGitHub <noreply@github.com>2024-04-02 11:38:40 -0400
commit31880df9947d58c160b691160c4714277be7c31e (patch)
tree4dbb041aa35fcd8ef242d6b5ad2d56212e355a5f /openmp/runtime
parentc5bbdb64940d75e7702d1d450e77534d908fc9f1 (diff)
downloadllvm-31880df9947d58c160b691160c4714277be7c31e.zip
llvm-31880df9947d58c160b691160c4714277be7c31e.tar.gz
llvm-31880df9947d58c160b691160c4714277be7c31e.tar.bz2
[OpenMP] get logical core count on modern apple platform (#87231)
`hw.logicalcpu` returns the available logical core count Fix build error for watchOS ``` runtime/src/z_Linux_util.cpp:1821:8: error: 'host_info' is unavailable: not available on watchOS rc = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&info, &num); ^ /Applications/Xcode_15.2.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.2.sdk/usr/include/mach/mach_host.h:82:15: note: 'host_info' has been explicitly marked unavailable here kern_return_t host_info ^ 1 warning and 1 error generated. make[2]: *** [runtime/src/CMakeFiles/omp.dir/z_Linux_util.cpp.o] Error 1 ```
Diffstat (limited to 'openmp/runtime')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index ee5e6e1..be47be0 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1889,21 +1889,8 @@ static int __kmp_get_xproc(void) {
#elif KMP_OS_DARWIN
- // Bug C77011 High "OpenMP Threads and number of active cores".
-
- // Find the number of available CPUs.
- kern_return_t rc;
- host_basic_info_data_t info;
- mach_msg_type_number_t num = HOST_BASIC_INFO_COUNT;
- rc = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&info, &num);
- if (rc == 0 && num == HOST_BASIC_INFO_COUNT) {
- // Cannot use KA_TRACE() here because this code works before trace support
- // is initialized.
- r = info.avail_cpus;
- } else {
- KMP_WARNING(CantGetNumAvailCPU);
- KMP_INFORM(AssumedNumCPU);
- }
+ size_t len = sizeof(r);
+ sysctlbyname("hw.logicalcpu", &r, &len, NULL, 0);
#else