OpenBLASのコンパイルにはこのページで参照していたXuantiue向けのRISC-V GCCが必要となる。
このリポジトリに格納されているGCCを使って、OpenBLASのLinux版は一応コンパイルできる。
make HOSTCC=gcc TARGET=C910V CC=riscv64-unknown-linux-gnu-gcc FC=riscv64-unknown-linux-gnu-gfortran
とりあえずやってみたが、Fortran向けのバイナリコンパイルの所でこけてしまう。これは大丈夫なのか?
make[2]: Leaving directory '/home/msyksphinz/work/riscv/openblas/OpenBLAS/lapack-netlib/LAPACKE' make[1]: Leaving directory '/home/msyksphinz/work/riscv/openblas/OpenBLAS/lapack-netlib' touch libopenblas_c910vp-r0.3.12.dev.a make -j 8 -C test all make[1]: Entering directory '/home/msyksphinz/work/riscv/openblas/OpenBLAS/test' riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o sblat1 sblat1.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o dblat1 dblat1.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o cblat1 cblat1.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o zblat1 zblat1.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o sblat2 sblat2.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o dblat2 dblat2.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o cblat2 cblat2.o ../libopenblas_c910vp-r0.3.12.dev.a riscv64-unknown-linux-gnu-gfortran -O2 -Wall -march=rv64gcvxthead -mabi=lp64v -static -o zblat2 zblat2.o ../libopenblas_c910vp-r0.3.12.dev.a /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/.. /lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/lib/libgfortran.a(fpu.o): in function `.L42': (.text._gfortrani_set_fpu_trap_exceptions+0x74): warning: fedisableexcept is not implemented and will always fail /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/.. /lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/lib/libgfortran.a(fpu.o): in function `.L41': (.text._gfortrani_set_fpu_trap_exceptions+0x64): warning: feenableexcept is not implemented and will always fail /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/.. /lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/lib/libgfortran.a(fpu.o): in function `_gfortrani_get_fpu_trap_exceptions': (.text._gfortrani_get_fpu_trap_exceptions+0x12): warning: fegetexcept is not implemented and will always fail /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(caxpy.o): can't link double-float modules with soft-floa t modules /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ../libopenblas_c910vp-r0.3.12.dev.a(caxpy.o) /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(cswap.o): can't link double-float modules with soft-floa t modules /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ../libopenblas_c910vp-r0.3.12.dev.a(cswap.o) /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(ccopy.o): can't link double-float modules with soft-floa t modules /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ../libopenblas_c910vp-r0.3.12.dev.a(ccopy.o) /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(cscal.o): can't link double-float modules with soft-floa t modules /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ../libopenblas_c910vp-r0.3.12.dev.a(cscal.o) /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(csscal.o): can't link double-float modules with soft-flo at modules /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ../libopenblas_c910vp-r0.3.12.dev.a(csscal.o) /home/msyksphinz/work3/work/riscv/xuantie-vector-demos/toolchain/riscv64-linux-x86_64/bin/../lib/gcc/riscv64-unknown-linux-gnu/8.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: ../libopenblas_c910vp-r0.3.12.dev.a(cdotc.o): can't link double-float modules with soft-floa t modules
benchmark ディレクトリのコンパイルもこのままでは通らなかった。Fortranのコンパイルがどうもおかしい気がするので、これをスキップしてみる。
make HOSTCC=gcc TARGET=C910V CC=riscv64-unknown-linux-gnu-gcc
これだと上手く行った。
-Wl,--whole-archive ../libopenblas_c910vp-r0.3.12.dev.a -Wl,--no-whole-archive \ -Wl,-soname,libopenblas.so.0 -lm -lpthread -lm -lpthread riscv64-unknown-linux-gnu-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.12.dev\" -march=rv64gcvxthead -mabi=lp64v -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I.. -w -o linktest linktest.c ../libopenblas_c910vp-r0.3.12.dev.so && echo OK. OK. rm -f linktest make[1]: Leaving directory '/home/msyksphinz/work/riscv/openblas/OpenBLAS/exports' OpenBLAS build complete. (BLAS CBLAS) OS ... Linux Architecture ... riscv64 BINARY ... 64bit C compiler ... GCC (cmd & version : riscv64-unknown-linux-gnu-gcc (C-SKY RISCV Tools V1.9.1-910v B20200521) 8.1.0) Library Name ... libopenblas_c910vp-r0.3.12.dev.a (Multi-threading; Max num-threads is 8) To install the library, you can run "make PREFIX=/path/to/your/installation install".
benchmarkをコンパイルしてみる。これも上手く行った。ただしこの段階ではLinux向けのバイナリなので上手くシミュレーションできない。いくつか修正が必要だろう。
cd benchmark make HOSTCC=gcc TARGET=C910V CC=riscv64-unknown-linux-gnu-gcc