diff --git a/driver/others/init.c b/driver/others/init.c index f6924d5f4..ab83f1203 100644 --- a/driver/others/init.c +++ b/driver/others/init.c @@ -82,6 +82,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include + +#ifdef __APPLE__ +#include +#endif #define MAX_NODES 16 #define MAX_CPUS 256 @@ -844,7 +848,15 @@ void gotoblas_set_affinity2(int threads) {}; void gotoblas_affinity_reschedule(void) {}; -int get_num_procs(void) { return get_nprocs(); } +int get_num_procs(void) { +#ifdef __APPLE__ + int physicalCores; + sysctlbyname("hw.physicalcpu", &physicalCores, sizeof(physicalCores), NULL, 0); + return physicalCores; +#else + return get_nprocs(); +#endif +} int get_num_nodes(void) { return 1; }