Skip to content

Commit dc05141

Browse files
authored
Merge pull request #8 from pv/blas64_
ENH: build also openblas64_ 64-bit symbol-suffixed library
2 parents 223f248 + e1dedfb commit dc05141

12 files changed

+329
-19
lines changed

.travis.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ matrix:
3030
language: objective-c
3131
env:
3232
- PLAT=i686
33+
- os: linux
34+
env:
35+
- INTERFACE64=1
36+
- os: osx
37+
language: objective-c
38+
env:
39+
- INTERFACE64=1
3340

3441
before_install:
3542
- source travis-ci/build_steps.sh
@@ -41,7 +48,7 @@ install:
4148

4249
script:
4350
# Build library and collect into libs subdirectory
44-
- build_lib $PLAT
51+
- build_lib "$PLAT" "$INTERFACE64"
4552

4653
after_success:
4754
# Upload libraries to Rackspace container

appveyor.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ environment:
1717
# Downloads via https://sourceforge.net/projects/mingw-w64/files
1818
# Note spaces instead of %20 in URL, to avoid Windows env var expansion
1919
matrix:
20+
- BUILD_BITS: 64
21+
INTERFACE64: 1
22+
MINGW_URL: "https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/7.1.0/threads-posix/seh/x86_64-7.1.0-release-posix-seh-rt_v5-rev0.7z/download"
23+
2024
- BUILD_BITS: 32
2125
MINGW_URL: "https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/7.1.0/threads-posix/dwarf/i686-7.1.0-release-posix-dwarf-rt_v5-rev0.7z/download"
2226

@@ -43,14 +47,17 @@ build_script:
4347
- set SCRIPT_DIR=%START_DIR%appveyor\
4448
# Need --login to process MSYSTEM variable
4549
- bash --login %SCRIPT_DIR%build_openblas.sh
46-
- bash --login %SCRIPT_DIR%build_gfortran.sh
4750

4851
test_script:
49-
- bash --login -c "$(cygpath $START_DIR)test.exe"
52+
- bash --login %SCRIPT_DIR%build_gfortran.sh
5053
- copy test.exe builds
54+
- copy test_dyn.exe builds
55+
- bash --login -c "$(cygpath $START_DIR)test.exe"
56+
- copy %OPENBLAS_ROOT%\%BUILD_BITS%\bin\*.dll .
57+
- bash --login -c "$(cygpath $START_DIR)test_dyn.exe"
5158

52-
artifacts:
53-
- path: builds\*.*
59+
on_finish:
60+
- ps: Get-ChildItem builds\*.* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
5461

5562
on_success:
5663
# Upload the generated package to Rackspace

appveyor/build_gfortran.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Build gfortran binary against OpenBLAS
22
cd $(cygpath "$START_DIR")
33
OBP=$(cygpath $OPENBLAS_ROOT\\$BUILD_BITS)
4-
gfortran -I $OBP/include -o test.exe test.f90 \
5-
$OBP/lib/libopenblas_*.a
6-
./test
4+
5+
static_libname=`find $OBP/lib -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a'`
6+
dynamic_libname=`find $OBP/lib -maxdepth 1 -type f -name '*.dll.a'`
7+
8+
if [ "$INTERFACE64" == "1" ]; then
9+
gfortran -I $OBP/include -fdefault-integer-8 -o test.exe test64_.f90 $static_libname
10+
gfortran -I $OBP/include -fdefault-integer-8 -o test_dyn.exe test64_.f90 $dynamic_libname
11+
else
12+
gfortran -I $OBP/include -o test.exe test.f90 $static_libname
13+
gfortran -I $OBP/include -o test_dyn.exe test.f90 $dynamic_libname
14+
fi

appveyor/build_openblas.sh

+32-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ fi
4646
cflags="-O2 -march=$march -mtune=generic $extra"
4747
fflags="$cflags -frecursive -ffpe-summary=invalid,zero"
4848

49+
# Set suffixed-ILP64 flags
50+
if [ "$INTERFACE64" == "1" ]; then
51+
interface64_flags="INTERFACE64=1 SYMBOLSUFFIX=64_"
52+
SYMBOLSUFFIX=64_
53+
# We override FCOMMON_OPT, so we need to set default integer manually
54+
fflags="$fflags -fdefault-integer-8"
55+
else
56+
interface64_flags=""
57+
fi
58+
4959
# Build name for output library from gcc version and OpenBLAS commit.
5060
GCC_TAG="gcc_$(gcc -dumpversion | tr .- _)"
5161
OPENBLAS_VERSION=$(git describe --tags)
@@ -57,25 +67,41 @@ make BINARY=$BUILD_BITS DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \
5767
BUILD_LAPACK_DEPRECATED=1 \
5868
COMMON_OPT="$cflags" \
5969
FCOMMON_OPT="$fflags" \
60-
MAX_STACK_ALLOC=2048
61-
make PREFIX=$OPENBLAS_ROOT/$BUILD_BITS install
62-
DLL_BASENAME=libopenblas_${LIBNAMESUFFIX}
70+
MAX_STACK_ALLOC=2048 \
71+
$interface64_flags
72+
make PREFIX=$OPENBLAS_ROOT/$BUILD_BITS $interface64_flags install
73+
DLL_BASENAME=libopenblas${SYMBOLSUFFIX}_${LIBNAMESUFFIX}
74+
if [ "$INTERFACE64" == "1" ]; then
75+
# OpenBLAS does not build a symbol-suffixed static library on Windows:
76+
# do it ourselves
77+
static_libname=`find . -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a' -printf '%P\n'`
78+
set -x # echo commands
79+
make -C exports $interface64_flags objcopy.def
80+
objcopy --redefine-syms exports/objcopy.def "${static_libname}" "${static_libname}.renamed"
81+
cp -f "${static_libname}.renamed" "$OPENBLAS_ROOT/$BUILD_BITS/lib/${static_libname}"
82+
cp -f "${static_libname}.renamed" "$OPENBLAS_ROOT/$BUILD_BITS/lib/${DLL_BASENAME}.a"
83+
set +x
84+
fi
6385
cd $OPENBLAS_ROOT
6486
# Copy library link file for custom name
6587
cd $BUILD_BITS/lib
6688
# At least for the mingwpy wheel, we have to use the VC tools to build the
6789
# export library. Maybe fixed in later binutils by patch referred to in
6890
# https://sourceware.org/ml/binutils/2016-02/msg00002.html
69-
cp ${our_wd}/OpenBLAS/exports/libopenblas.def ${DLL_BASENAME}.def
91+
if [ "$INTERFACE64" == "1" ]; then
92+
cp ${our_wd}/OpenBLAS/exports/${DLL_BASENAME}.def ${DLL_BASENAME}.def
93+
else
94+
cp ${our_wd}/OpenBLAS/exports/libopenblas.def ${DLL_BASENAME}.def
95+
fi
7096
"$VC9_ROOT/bin/lib.exe" /machine:${vc_arch} /def:${DLL_BASENAME}.def
7197
cd ../..
7298
# Build template site.cfg for using this build
7399
cat > ${BUILD_BITS}/site.cfg.template << EOF
74-
[openblas]
100+
[openblas${SYMBOLSUFFIX}]
75101
libraries = $DLL_BASENAME
76102
library_dirs = {openblas_root}\\${BUILD_BITS}\\lib
77103
include_dirs = {openblas_root}\\${BUILD_BITS}\\include
78104
EOF
79-
ZIP_NAME="openblas-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip"
105+
ZIP_NAME="openblas${SYMBOLSUFFIX}-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip"
80106
zip -r $ZIP_NAME $BUILD_BITS
81107
cp $ZIP_NAME $our_wd/builds

objconv/LICENSE.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
A utility for cross-platform development of function libraries, for converting
2+
and modifying object files and for dumping and disassembling object and
3+
executable files for all x86 and x86-64 platforms.
4+
5+
https://www.agner.org/optimize/#objconv
6+
7+
***
8+
9+
Version 2.49. By Agner Fog © 2018.
10+
GNU General Public License.
11+
12+
Legal notice
13+
14+
Objconv is an open source program published under the conditions of the GNU General
15+
Public License, as defined in www.gnu.org/licenses/. The program is provided without any
16+
warranty or support.
17+
It may in some cases be illegal to modify, convert or disassemble copyright protected
18+
software files without permission from the copyright owner. It is an open question whether it
19+
is legal to modify or convert a copyright protected function library and use it for other
20+
purposes than presupposed in the license conditions. It is recommended to ask the vendor
21+
for permission before developing and publishing any software that is built with the use of a
22+
converted copyright protected function library.
23+
Copyright law does not generally permit disassembly of copyright protected software for the
24+
purpose of circumventing a copy protection mechanism, for using part of the code in other
25+
contexts, or for extracting the algorithms behind the code.
26+
European, Australian and US copyright law does, however, under certain conditions permit
27+
reverse engineering of copyright protected software when the purpose is to extract the
28+
information necessary for establishing interoperability with other software, and only to the
29+
extent necessary for this purpose. However, I am not a legal expert. The user should seek
30+
legal advise before deciding whether it is legal to use objconv on copyrighted software for a
31+
specific purpose.

objconv/changelog.txt

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2018-10-08 version 2.51
2+
* fix bug in movq mm0,rax
3+
4+
2018-08-15 version 2.50
5+
* minor change in omf2cof
6+
7+
2018-01-29 version 2.49
8+
* fixed minor problem with disassembly of DLL
9+
10+
2017-10-18 version 2.48
11+
* minor changes
12+
13+
2017-07-27 version 2.47
14+
* fixed bug in library manager for long module names
15+
16+
2017-07-15 version 2.46
17+
* dump of ELF files improved
18+
* a new unnecessary warnings removed
19+
20+
2017-04-10 version 2.45
21+
* support disassembly of forthcoming Control-flow Enforcement instructions
22+
23+
2016-11-27 version 2.44
24+
* fixed bug when disassembling file generated by Tiny C compiler
25+
26+
2016-11-09 version 2.43
27+
* fixed "string table corrupt" message for ELF files
28+
* support for disassembly of AVX512_4VNNIW, AVX512_4FMAPS instructions
29+
30+
2016-01-16 version 2.42
31+
* fixed bugs with disassembly of some AVX512 and BMI2 instructions
32+
33+
2015-10-15 version 2.41
34+
* fixed bugs with disassembly of some AVX512 instructions
35+
* fixed missing "ptr" in masm syntax disassembly
36+
37+
2015-10-15 version 2.40
38+
* fixed bugs with disassembly of some AVX512 instructions
39+
40+
2015-09-14 version 2.39
41+
* fixed bugs with disassembly of some AVX512 instructions
42+
43+
2014-12-15 version 2.38
44+
* fixed bugs with disassembly of Knights Corner instruction set
45+
* exe file made compatible with Windows XP
46+
47+
2014-12-06 version 2.37
48+
* support for disassembly of AVX512BW/DQ, etc.
49+
* fixed disassembly bug of vpgatherdd on knights corner
50+
* fixed disassembly bug for FMA4 instructions
51+
* improved disassembly of switch/case tables for gcc and clang compilers
52+
53+
2014-07-21 version 2.36
54+
* improved execution times for disassembling very big files
55+
56+
2013-11-27 version 2.32
57+
* fix bug with .bss section in elf2elf.cpp and elf2coff.cpp
58+
59+
2013-08-23 version 2.31
60+
* support for disassembly of AVX512F
61+
* library operations were extremely slow on big libraries because of rebuilding and search for unique names. This problem is fixed.
62+
* long member names allowed in libraries
63+
* option -ls to make member names short. Perhaps good for compatibility with BSD. Member names are made unique just by adding a running hex number, not by comparing with all previous names, which was the cause of slow operations in previous versions.
64+
* option -ns to change symbol suffixes
65+
* options -ap and -as to change prefix or suffix and keep old name as alias
66+
* added missing relocation type in ELF to COFF conversion
67+
* fixed error that often occurred when disassembling .exe files
68+
* fixed minor errors
69+
70+
2012-08-31 version 2.16
71+
* support for disassembly of Knights Corner instruction set

objconv/sort-zipfile.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
"""
3+
sort-zipfile.py FILENAME
4+
5+
Convert .zip file in-place to zero compression and sorted file names,
6+
suitable for storing in Git.
7+
"""
8+
import zipfile
9+
import os
10+
import sys
11+
import argparse
12+
import tempfile
13+
import shutil
14+
15+
def main():
16+
p = argparse.ArgumentParser(usage=__doc__)
17+
p.add_argument("filename", action="store", type=str)
18+
options = p.parse_args()
19+
20+
mode = zipfile.ZIP_STORED
21+
22+
fd, target_name = tempfile.mkstemp()
23+
try:
24+
os.close(fd)
25+
26+
with zipfile.ZipFile(options.filename) as source:
27+
with zipfile.ZipFile(target_name, "w", mode) as target:
28+
copy_zip_contents(source, target, mode)
29+
30+
shutil.move(target_name, options.filename)
31+
target_name = None
32+
finally:
33+
if target_name is not None:
34+
os.unlink(target_name)
35+
36+
def copy_zip_contents(source, target, mode):
37+
infolist = sorted(source.infolist(), key=lambda info: info.filename)
38+
for info in infolist:
39+
target.writestr(info, source.read(info.filename), mode)
40+
41+
if __name__ == "__main__":
42+
main()

objconv/source.zip

1.9 MB
Binary file not shown.

test64_.f90

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
!testdpotr_test_gh_2691.f90 with _64 suffix
2+
subroutine garbage(okflag)
3+
implicit none
4+
integer, intent(out) :: okflag
5+
double precision, dimension(3,3) :: a, a2
6+
integer, parameter :: lwork = 100
7+
double precision, dimension(lwork) :: work(lwork)
8+
integer, dimension(3) :: ipiv
9+
integer :: info, i, j
10+
11+
okflag = 1
12+
13+
! condition number =~ 19, well invertible
14+
a(1,1) = 0.68534241
15+
a(1,2) = 0.63723771
16+
a(2,1) = 0.63723771
17+
a(1,3) = 0.37423535
18+
a(3,1) = 0.37423535
19+
a(2,2) = 2.42926786
20+
a(2,3) = 2.33541214
21+
a(3,2) = 2.33541214
22+
a(3,3) = 3.30327538
23+
24+
a2 = a
25+
26+
call dpotrf_64('L', 3, a, 3, info)
27+
if (info.ne.0) then
28+
okflag = 0
29+
write(*,*) 'DPOTRF failed'
30+
return
31+
end if
32+
do i = 1, 3
33+
do j = 1, i
34+
write(*,*) 'DPOTRF result', i, j, a(i,j)
35+
end do
36+
end do
37+
do i = 1, 3
38+
do j = i+1, 3
39+
a(i,j) = 0
40+
end do
41+
end do
42+
call dpotri_64('L', 3, a, 3, info)
43+
if (info.ne.0) then
44+
okflag = 0
45+
write(*,*) 'DPOTRI failed'
46+
return
47+
end if
48+
49+
call dgetrf_64(3, 3, a2, 3, ipiv, info)
50+
if (info.ne.0) then
51+
okflag = 0
52+
write(*,*) 'DGETRF failed'
53+
return
54+
end if
55+
call dgetri_64(3, a2, 3, ipiv, work, lwork, info)
56+
if (info.ne.0) then
57+
okflag = 0
58+
write(*,*) 'DGETRI failed'
59+
return
60+
end if
61+
do i = 1, 3
62+
do j = 1, i
63+
write(*,*) i, j, a(i,j), a2(i,j)
64+
if (abs(a(i,j) - a2(i,j)) > 1e-3 + 1e-3*abs(a(i,j))) then
65+
okflag = 0
66+
write(*,*) '# po/ge mismatch!'
67+
end if
68+
end do
69+
end do
70+
end subroutine
71+
72+
program main
73+
integer :: okflag
74+
call garbage(okflag)
75+
if (okflag.eq.1) then
76+
write(*,*) 'OK'
77+
else
78+
write(*,*) 'FAIL'
79+
end if
80+
end program

travis-ci/build_objconv.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "Building objconv..."
2+
set -e -x
3+
unzip source.zip
4+
g++ -O1 -o objconv *.cpp

0 commit comments

Comments
 (0)