From b9d89f8aaa82845d09463f36829e189b0e28c15d Mon Sep 17 00:00:00 2001 From: Xianyi Zhang Date: Wed, 31 Aug 2011 18:21:37 +0800 Subject: [PATCH 01/10] Fixed the bug about installation. f77blas.h works OK now. --- Makefile | 7 +++++++ common_interface.h | 11 +++++++++++ openblas_config_template.h | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/Makefile b/Makefile index 6789272a3..d86fbadf3 100644 --- a/Makefile +++ b/Makefile @@ -118,6 +118,13 @@ endif #Save the config files for installation cp Makefile.conf Makefile.conf_last cp config.h config_last.h +ifdef QUAD_PRECISION + echo "#define QUAD_PRECISION">> config_last.h +endif +ifeq ($(EXPRECISION), 1) + echo "#define EXPRECISION">> config_last.h +endif +## ifdef DYNAMIC_ARCH $(MAKE) -C kernel commonlibs || exit 1 for d in $(DYNAMIC_CORE) ; \ diff --git a/common_interface.h b/common_interface.h index 36bf5aa48..898d91001 100644 --- a/common_interface.h +++ b/common_interface.h @@ -38,6 +38,11 @@ #ifndef ASSEMBLER +#ifdef __cplusplus +extern "C" { + /* Assume C declarations for C++ */ +#endif /* __cplusplus */ + int BLASFUNC(xerbla)(char *, blasint *info, blasint); FLOATRET BLASFUNC(sdot) (blasint *, float *, blasint *, float *, blasint *); @@ -733,4 +738,10 @@ xdouble BLASFUNC(qlamch)(char *); FLOATRET BLASFUNC(slamc3)(float *, float *); double BLASFUNC(dlamc3)(double *, double *); xdouble BLASFUNC(qlamc3)(xdouble *, xdouble *); + +#ifdef __cplusplus +} + +#endif /* __cplusplus */ + #endif diff --git a/openblas_config_template.h b/openblas_config_template.h index 9fb80aa4f..8bf972593 100644 --- a/openblas_config_template.h +++ b/openblas_config_template.h @@ -6,6 +6,16 @@ #define BLASFUNC(FUNC) FUNC #endif +#ifdef QUAD_PRECISION +typedef struct { + unsigned long x[2]; +} xdouble; +#elif defined EXPRECISION +#define xdouble long double +#else +#define xdouble double +#endif + #if defined(OS_WINDOWS) && defined(__64BIT__) typedef long long BLASLONG; typedef unsigned long long BLASULONG; @@ -19,3 +29,13 @@ typedef BLASLONG blasint; #else typedef int blasint; #endif + +#if defined(XDOUBLE) || defined(DOUBLE) +#define FLOATRET FLOAT +#else +#ifdef NEED_F2CCONV +#define FLOATRET double +#else +#define FLOATRET float +#endif +#endif From 7b410b7f0e94edde2a606593086694ae6bb17be8 Mon Sep 17 00:00:00 2001 From: Zhang Xiianyi Date: Wed, 14 Sep 2011 23:52:51 +0800 Subject: [PATCH 02/10] Fixed #58 zdot SEGFAULT bug with GCC-4.6. Thank Mr. John for this patch. In i386 calling convention, the caller put the address of return value of zdot into the first hidden parameter. Thus, the callee should delete this address before return. Actually, I have fixed the same bug on x86/zdot_sse2.S (issue #32). However, that is not a good implementation which uses 3 instructions. Mr. John told me used "ret $0x4" to skip the first hidden address (4 bytes). --- kernel/x86/xdot.S | 10 +++++++++- kernel/x86/zdot.S | 10 +++++++++- kernel/x86/zdot_sse2.S | 4 +--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/kernel/x86/xdot.S b/kernel/x86/xdot.S index 4a5af4642..929763271 100644 --- a/kernel/x86/xdot.S +++ b/kernel/x86/xdot.S @@ -307,7 +307,11 @@ popl %ebx popl %esi popl %edi +#if defined(F_INTERFACE) && defined(RETURN_BY_STACK) + ret $0x4 +#else ret +#endif ALIGN_3 .L88: @@ -326,6 +330,10 @@ popl %ebx popl %esi popl %edi - ret +#if defined(F_INTERFACE) && defined(RETURN_BY_STACK) + ret $0x4 +#else + ret +#endif EPILOGUE diff --git a/kernel/x86/zdot.S b/kernel/x86/zdot.S index aa4481f97..9d8866ad0 100644 --- a/kernel/x86/zdot.S +++ b/kernel/x86/zdot.S @@ -283,7 +283,11 @@ popl %ebx popl %esi popl %edi +#if defined(DOUBLE) || defined(XDOUBLE) + ret $0x4 +#else ret +#endif ALIGN_3 .L88: @@ -305,6 +309,10 @@ popl %ebx popl %esi popl %edi - ret +#if defined(DOUBLE) || defined(XDOUBLE) + ret $0x4 +#else + ret +#endif EPILOGUE diff --git a/kernel/x86/zdot_sse2.S b/kernel/x86/zdot_sse2.S index 2a174fb5d..efebe637b 100644 --- a/kernel/x86/zdot_sse2.S +++ b/kernel/x86/zdot_sse2.S @@ -1542,7 +1542,5 @@ popl %esi popl %edi /*remove the hidden return value address from the stack.*/ - popl %ecx - xchgl %ecx, 0(%esp) - ret + ret $0x4 EPILOGUE From d0152ec8caa77c5f122572302c8c9589b3eb2909 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sat, 17 Sep 2011 02:27:56 +0800 Subject: [PATCH 03/10] Fixed #61 a building bug about setting TARGET and DYNAMIC_ARCH at the same time. --- Makefile.system | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile.system b/Makefile.system index f0487ac50..84f41a78f 100644 --- a/Makefile.system +++ b/Makefile.system @@ -27,7 +27,13 @@ HOSTCC = $(CC) endif ifdef TARGET -GETARCH_FLAGS += -DFORCE_$(TARGET) +GETARCH_FLAGS := -DFORCE_$(TARGET) +endif + +#TARGET_CORE will override TARGET which is used in DYNAMIC_ARCH=1. +# +ifdef TARGET_CORE +GETARCH_FLAGS := -DFORCE_$(TARGET_CORE) endif ifdef INTERFACE64 From 68cae521dff0eb87a9de52685b8dee0f7b7e7418 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sat, 17 Sep 2011 02:58:01 +0800 Subject: [PATCH 04/10] Refs #57. The bug about absolute path of shared library on Mac OSX. OSX cann't use relative path in shared library. Thank Mr.Kane for this patch. The detail is in this link (https://github.com/xianyi/OpenBLAS/issues/57). --- Makefile | 5 +++++ Makefile.install | 1 + exports/Makefile | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6789272a3..90a3cda09 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,11 @@ ifndef SMP else @echo " (Multi threaded; Max num-threads is $(NUM_THREADS))" endif + +ifeq ($(OSNAME), Darwin) + @echo "Because absolute path issue, $(LIBDYNNAME) may not work under this directory." + @echo "Thus, you need run \"make PREFIX=/your_installation_path/ install\"." +endif @echo shared : diff --git a/Makefile.install b/Makefile.install index 80dafc9c6..1fbb2c430 100644 --- a/Makefile.install +++ b/Makefile.install @@ -50,6 +50,7 @@ ifeq ($(OSNAME), NetBSD) endif ifeq ($(OSNAME), Darwin) -cp $(LIBDYNNAME) $(PREFIX) + -install_name_tool -add_rpath $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/$(LIBDYNNAME) -ln -fs $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/libopenblas.dylib endif ifeq ($(OSNAME), WINNT) diff --git a/exports/Makefile b/exports/Makefile index f4c9314f9..0a2f3184f 100644 --- a/exports/Makefile +++ b/exports/Makefile @@ -85,7 +85,7 @@ libgoto_hpl.def : gensymbol perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) > $(@F) $(LIBDYNNAME) : ../$(LIBNAME) osx.def - $(PREFIX)gcc $(CFLAGS) -all_load -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB) + $(CC) $(CFLAGS) -all_load -headerpad_max_install_names -install_name `pwd`/../$(LIBDYNNAME) -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB) symbol.$(SUFFIX) : symbol.S $(CC) $(CFLAGS) -c -o $(@F) $^ From 864c68ffc5a4882c2a88e0c9f8f32ead96271fde Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sat, 17 Sep 2011 03:05:26 +0800 Subject: [PATCH 05/10] Bump the version number. --- Makefile.rule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.rule b/Makefile.rule index 3b32ded84..a7ba203fc 100644 --- a/Makefile.rule +++ b/Makefile.rule @@ -3,7 +3,7 @@ # # This library's version -VERSION = 0.1alpha2.3 +VERSION = 0.1alpha2.4 # You can specify the target architecture, otherwise it's # automatically detected. From 756477bfe3791f13ed270d1d75ad1dfccbf83bc1 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sat, 17 Sep 2011 07:21:11 +0800 Subject: [PATCH 06/10] Output the installation tip after building complete. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 90a3cda09..0c82d4a95 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,8 @@ ifeq ($(OSNAME), Darwin) @echo "Thus, you need run \"make PREFIX=/your_installation_path/ install\"." endif @echo + @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"." + @echo shared : ifeq ($(OSNAME), Linux) From 821cbb29958b15bff260d72553b5880bbddf704f Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sat, 17 Sep 2011 07:55:59 +0800 Subject: [PATCH 07/10] Updated the document for 0.1 alpha 2.4. --- Changelog.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 7d8a06edb..cd67f333d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,19 @@ OpenBLAS ChangeLog +==================================================================== +Version 0.1 alpha2.4 +16-Sep-2011 +common: + * Fixed a bug about installation. The header file "fblas77.h" + works fine now. + * Fixed #61 a building bug about setting TARGET and DYNAMIC_ARCH. + * Try to handle absolute path of shared library in OSX. (#57) + Thank Mr.Kane. + +x86/x86_64: + * Fixed #58 zdot/xdot SEGFAULT bug with GCC-4.6 on x86. According + to i386 calling convention, The callee should remove the first + hidden parameter.Thank Mr. John for this patch. + ==================================================================== Version 0.1 alpha2.3 5-Sep-2011 From bcc795621607b59c31fb7b59fc30d3eba15729b9 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sun, 18 Sep 2011 01:35:12 +0800 Subject: [PATCH 08/10] Refs #57. Continue to fix absolute path issue about shared library on Mac OSX. Used $(CURDIR) instead of pwd in generating shared library on Mac OSX. Add more tips about this issue. Thank Dr Kane O'Donnell. --- Makefile | 11 +++++++++-- Makefile.install | 4 ++-- exports/Makefile | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 573c44c33..56d491077 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,15 @@ else endif ifeq ($(OSNAME), Darwin) - @echo "Because absolute path issue, $(LIBDYNNAME) may not work under this directory." - @echo "Thus, you need run \"make PREFIX=/your_installation_path/ install\"." + @echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:" + @echo + @echo "\"make PREFIX=/your_installation_path/ install\"." + @echo + @echo "(or set PREFIX in Makefile.rule and run make install." + @echo "If you want to move the .dylib to a new location later, make sure you change" + @echo "the internal name of the dylib with:" + @echo + @echo "install_name_tool -id /new/absolute/path/to/$(LIBDYNNAME) $(LIBDYNNAME)" endif @echo @echo "To install the library, you can run \"make PREFIX=/path/to/your/installation install\"." diff --git a/Makefile.install b/Makefile.install index 1fbb2c430..5b5895c1c 100644 --- a/Makefile.install +++ b/Makefile.install @@ -48,9 +48,9 @@ ifeq ($(OSNAME), NetBSD) -cp $(LIBSONAME) $(PREFIX) -ln -fs $(PREFIX)/$(LIBSONAME) $(PREFIX)/libopenblas.so endif -ifeq ($(OSNAME), Darwin) +ifeq ($(OSNAME), Darwin) -cp $(LIBDYNNAME) $(PREFIX) - -install_name_tool -add_rpath $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/$(LIBDYNNAME) + -install_name_tool -id $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/$(LIBDYNNAME) -ln -fs $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/libopenblas.dylib endif ifeq ($(OSNAME), WINNT) diff --git a/exports/Makefile b/exports/Makefile index 0a2f3184f..08f496501 100644 --- a/exports/Makefile +++ b/exports/Makefile @@ -85,7 +85,7 @@ libgoto_hpl.def : gensymbol perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) > $(@F) $(LIBDYNNAME) : ../$(LIBNAME) osx.def - $(CC) $(CFLAGS) -all_load -headerpad_max_install_names -install_name `pwd`/../$(LIBDYNNAME) -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB) + $(CC) $(CFLAGS) -all_load -headerpad_max_install_names -install_name $(CURDIR)/../$(LIBDYNNAME) -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def $(FEXTRALIB) symbol.$(SUFFIX) : symbol.S $(CC) $(CFLAGS) -c -o $(@F) $^ From d40e5621e95f5633efbbe94b07c3309713ba6432 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sun, 18 Sep 2011 05:07:00 +0800 Subject: [PATCH 09/10] Change the installation folder into /include and /lib. --- Makefile.install | 69 ++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/Makefile.install b/Makefile.install index 5b5895c1c..2778a491f 100644 --- a/Makefile.install +++ b/Makefile.install @@ -3,6 +3,9 @@ export GOTOBLAS_MAKEFILE = 1 -include $(TOPDIR)/Makefile.conf_last include ./Makefile.system +OPENBLAS_INCLUDE_DIR:=$(PREFIX)/include +OPENBLAS_LIBRARY_DIR:=$(PREFIX)/lib + .PHONY : install .NOTPARALLEL : install @@ -11,55 +14,57 @@ lib.grd : install : lib.grd @-mkdir -p $(PREFIX) - @echo Generating openblas_config.h in $(PREFIX) + @-mkdir -p $(OPENBLAS_INCLUDE_DIR) + @-mkdir -p $(OPENBLAS_LIBRARY_DIR) + @echo Generating openblas_config.h in $(OPENBLAS_INCLUDE_DIR) #for inc - @echo \#ifndef OPENBLAS_CONFIG_H > $(PREFIX)/openblas_config.h - @echo \#define OPENBLAS_CONFIG_H >> $(PREFIX)/openblas_config.h - @cat config_last.h >> $(PREFIX)/openblas_config.h - @echo \#define VERSION \" OpenBLAS $(VERSION) \" >> $(PREFIX)/openblas_config.h - @cat openblas_config_template.h >> $(PREFIX)/openblas_config.h - @echo \#endif >> $(PREFIX)/openblas_config.h + @echo \#ifndef OPENBLAS_CONFIG_H > $(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @echo \#define OPENBLAS_CONFIG_H >> $(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @cat config_last.h >> $(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @echo \#define VERSION \" OpenBLAS $(VERSION) \" >> $(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @cat openblas_config_template.h >> $(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @echo \#endif >> $(OPENBLAS_INCLUDE_DIR)/openblas_config.h - @echo Generating f77blas.h in $(PREFIX) - @echo \#ifndef OPENBLAS_F77BLAS_H > $(PREFIX)/f77blas.h - @echo \#define OPENBLAS_F77BLAS_H >> $(PREFIX)/f77blas.h - @echo \#include \"openblas_config.h\" >> $(PREFIX)/f77blas.h - @cat common_interface.h >> $(PREFIX)/f77blas.h - @echo \#endif >> $(PREFIX)/f77blas.h + @echo Generating f77blas.h in $(OPENBLAS_INCLUDE_DIR) + @echo \#ifndef OPENBLAS_F77BLAS_H > $(OPENBLAS_INCLUDE_DIR)/f77blas.h + @echo \#define OPENBLAS_F77BLAS_H >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h + @echo \#include \"openblas_config.h\" >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h + @cat common_interface.h >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h + @echo \#endif >> $(OPENBLAS_INCLUDE_DIR)/f77blas.h - @echo Generating cblas.h in $(PREFIX) - @sed 's/common/openblas_config/g' cblas.h > $(PREFIX)/cblas.h + @echo Generating cblas.h in $(OPENBLAS_INCLUDE_DIR) + @sed 's/common/openblas_config/g' cblas.h > $(OPENBLAS_INCLUDE_DIR)/cblas.h #for install static library - @echo Copy the static library to $(PREFIX) - @cp $(LIBNAME) $(PREFIX) - @-ln -fs $(PREFIX)/$(LIBNAME) $(PREFIX)/libopenblas.$(LIBSUFFIX) + @echo Copy the static library to $(OPENBLAS_LIBRARY_DIR) + @cp $(LIBNAME) $(OPENBLAS_LIBRARY_DIR) + @-ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBNAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.$(LIBSUFFIX) #for install shared library - @echo Copy the shared library to $(PREFIX) + @echo Copy the shared library to $(OPENBLAS_LIBRARY_DIR) ifeq ($(OSNAME), Linux) - -cp $(LIBSONAME) $(PREFIX) - -ln -fs $(PREFIX)/$(LIBSONAME) $(PREFIX)/libopenblas.so + -cp $(LIBSONAME) $(OPENBLAS_LIBRARY_DIR) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBSONAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.so endif ifeq ($(OSNAME), FreeBSD) - -cp $(LIBSONAME) $(PREFIX) - -ln -fs $(PREFIX)/$(LIBSONAME) $(PREFIX)/libopenblas.so + -cp $(LIBSONAME) $(OPENBLAS_LIBRARY_DIR) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBSONAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.so endif ifeq ($(OSNAME), NetBSD) - -cp $(LIBSONAME) $(PREFIX) - -ln -fs $(PREFIX)/$(LIBSONAME) $(PREFIX)/libopenblas.so + -cp $(LIBSONAME) $(OPENBLAS_LIBRARY_DIR) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBSONAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.so endif ifeq ($(OSNAME), Darwin) - -cp $(LIBDYNNAME) $(PREFIX) - -install_name_tool -id $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/$(LIBDYNNAME) - -ln -fs $(PREFIX)/$(LIBDYNNAME) $(PREFIX)/libopenblas.dylib + -cp $(LIBDYNNAME) $(OPENBLAS_LIBRARY_DIR) + -install_name_tool -id $(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBDYNNAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.dylib endif ifeq ($(OSNAME), WINNT) - -cp $(LIBDLLNAME) $(PREFIX) - -ln -fs $(PREFIX)/$(LIBDLLNAME) $(PREFIX)/libopenblas.dll + -cp $(LIBDLLNAME) $(OPENBLAS_LIBRARY_DIR) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBDLLNAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.dll endif ifeq ($(OSNAME), CYGWIN_NT) - -cp $(LIBDLLNAME) $(PREFIX) - -ln -fs $(PREFIX)/$(LIBDLLNAME) $(PREFIX)/libopenblas.dll + -cp $(LIBDLLNAME) $(OPENBLAS_LIBRARY_DIR) + -ln -fs $(OPENBLAS_LIBRARY_DIR)/$(LIBDLLNAME) $(OPENBLAS_LIBRARY_DIR)/libopenblas.dll endif @echo Install OK! From 1d31c79dc938183203be5e16cc6851a0bfa1a5e6 Mon Sep 17 00:00:00 2001 From: Xianyi Date: Sun, 18 Sep 2011 05:46:08 +0800 Subject: [PATCH 10/10] Prepared the document for 0.1 alpha 2.4 version. --- Changelog.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index cd67f333d..48c5a727d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,13 +1,15 @@ OpenBLAS ChangeLog ==================================================================== Version 0.1 alpha2.4 -16-Sep-2011 +18-Sep-2011 common: * Fixed a bug about installation. The header file "fblas77.h" works fine now. * Fixed #61 a building bug about setting TARGET and DYNAMIC_ARCH. * Try to handle absolute path of shared library in OSX. (#57) - Thank Mr.Kane. + Thank Dr Kane O'Donnell. + * Changed the installation folder layout to $(PREFIX)/include and + $(PREFIX)/lib x86/x86_64: * Fixed #58 zdot/xdot SEGFAULT bug with GCC-4.6 on x86. According