[Openmp-commits] [openmp] [OpenMP] get logical core count on modern apple platform (PR #87231)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Apr 2 04:32:07 PDT 2024
https://github.com/nihui updated https://github.com/llvm/llvm-project/pull/87231
>From 8f4b6b3c0744feebc3d4591fb6e9facc8e1a6e84 Mon Sep 17 00:00:00 2001
From: nihui <shuizhuyuanluo at 126.com>
Date: Mon, 1 Apr 2024 19:42:50 +0800
Subject: [PATCH] get logical cpu count on modern apple platform
---
openmp/runtime/src/z_Linux_util.cpp | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 29db9d008a49b3..fe07f1bded5aa2 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
More information about the Openmp-commits
mailing list