Browse Source

Fixed #157. Only detect the number of physical CPU cores on Mac OSX.

tags/v0.2.5
Zhang Xianyi 13 years ago
parent
commit
6751f7b9a7
1 changed files with 13 additions and 1 deletions
  1. +13
    -1
      driver/others/memory.c

+ 13
- 1
driver/others/memory.c View File

@@ -185,7 +185,7 @@ int get_num_procs(void) {


#endif #endif


#if defined(OS_FREEBSD) || defined(OS_DARWIN)
#if defined(OS_FREEBSD)


int get_num_procs(void) { int get_num_procs(void) {
@@ -206,6 +206,18 @@ int get_num_procs(void) {


#endif #endif


#if defined(OS_DARWIN)
int get_num_procs(void) {
static int nums = 0;
size_t len;
if (nums == 0){
len = sizeof(int);
sysctlbyname("hw.physicalcpu", &nums, &len, NULL, 0);
}
return nums;
}
#endif

/* /*
OpenBLAS uses the numbers of CPU cores in multithreading. OpenBLAS uses the numbers of CPU cores in multithreading.
It can be set by openblas_set_num_threads(int num_threads); It can be set by openblas_set_num_threads(int num_threads);


Loading…
Cancel
Save