From 109f24fb2045a92ed0a61e3238a81003c8520c0c Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 12 Nov 2012 16:29:53 -0800 Subject: [PATCH] Possible fix for hyperthreading on OSX --- driver/others/init.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; }