From f54f5bac9e9b0127052a23aaa7c9cfc4170b1f00 Mon Sep 17 00:00:00 2001 From: Zhang Xianyi Date: Tue, 9 Jul 2013 15:38:03 +0800 Subject: [PATCH] Refs #248. Fixed the LSB compatiable issue for BLAS only. For example, make CC=lsbcc NO_LAPACK=1. --- Makefile.system | 2 ++ common_linux.h | 15 ++++++++++++++- driver/others/init.c | 4 +++- driver/others/memory.c | 2 +- getarch.c | 4 +++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Makefile.system b/Makefile.system index 196d005fb..d439d5001 100644 --- a/Makefile.system +++ b/Makefile.system @@ -447,7 +447,9 @@ endif ifeq ($(F_COMPILER), GFORTRAN) CCOMMON_OPT += -DF_INTERFACE_GFORT FCOMMON_OPT += -Wall +ifneq ($(NO_LAPACK), 1) EXTRALIB += -lgfortran +endif ifdef NO_BINARY_MODE ifeq ($(ARCH), mips64) ifdef BINARY64 diff --git a/common_linux.h b/common_linux.h index 6766ff37c..afc77b4a2 100644 --- a/common_linux.h +++ b/common_linux.h @@ -65,9 +65,16 @@ extern long int syscall (long int __sysno, ...); #endif #endif + + static inline int my_mbind(void *addr, unsigned long len, int mode, unsigned long *nodemask, unsigned long maxnode, unsigned flags) { +#if defined (__LSB_VERSION__) +// So far, LSB (Linux Standard Base) don't support syscall(). +// https://lsbbugs.linuxfoundation.org/show_bug.cgi?id=3482 + return 0; +#else #if defined (LOONGSON3B) #if defined (__64BIT__) return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags); @@ -79,11 +86,17 @@ static inline int my_mbind(void *addr, unsigned long len, int mode, // unsigned long null_nodemask=0; return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags); #endif +#endif } static inline int my_set_mempolicy(int mode, const unsigned long *addr, unsigned long flag) { - +#if defined (__LSB_VERSION__) +// So far, LSB (Linux Standard Base) don't support syscall(). +// https://lsbbugs.linuxfoundation.org/show_bug.cgi?id=3482 + return 0; +#else return syscall(SYS_set_mempolicy, mode, addr, flag); +#endif } static inline int my_gettid(void) { diff --git a/driver/others/init.c b/driver/others/init.c index f6924d5f4..4efc2816a 100644 --- a/driver/others/init.c +++ b/driver/others/init.c @@ -82,6 +82,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #define MAX_NODES 16 #define MAX_CPUS 256 @@ -735,7 +736,8 @@ void gotoblas_affinity_init(void) { fprintf(stderr, "Shared Memory Initialization.\n"); #endif - common -> num_procs = get_nprocs(); + //returns the number of processors which are currently online + common -> num_procs = sysconf(_SC_NPROCESSORS_ONLN);; if(common -> num_procs > MAX_CPUS) { fprintf(stderr, "\nOpenBLAS Warining : The number of CPU/Cores(%d) is beyond the limit(%d). Terminated.\n", common->num_procs, MAX_CPUS); diff --git a/driver/others/memory.c b/driver/others/memory.c index d8046d7bd..4f35691ff 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -126,7 +126,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define NO_WARMUP #endif -#ifdef ALLOC_HUGETLB +#ifndef SHM_HUGETLB #define SHM_HUGETLB 04000 #endif diff --git a/getarch.c b/getarch.c index 7f62e5401..b4573d3ea 100644 --- a/getarch.c +++ b/getarch.c @@ -83,6 +83,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #ifdef linux #include +#include #endif /* #define FORCE_P2 */ @@ -736,7 +737,8 @@ static int get_num_cores(void) { #endif #ifdef linux - return get_nprocs(); + //returns the number of processors which are currently online + return sysconf(_SC_NPROCESSORS_ONLN); #elif defined(OS_WINDOWS)