[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 07:34:17 PDT 2024


nihui wrote:

> Did you try on macOS? I doubt it will cause any issue but be better on the safe side.

A simple test on github macos x86-64 and M1 machine

https://github.com/nihui/action-protobuf/actions/runs/8524611415/job/23349591784
https://github.com/nihui/action-protobuf/actions/runs/8524611415/job/23349592164

```c
#include <stdio.h>
#include <sys/sysctl.h>
#include <sys/types.h>

int main()
{
    int r = 0;
    size_t len = sizeof(r);
    sysctlbyname("hw.logicalcpu", &r, &len, NULL, 0);
    printf("core count = %d\n", r);
    return 0;
}
```

https://github.com/llvm/llvm-project/pull/87231


More information about the Openmp-commits mailing list