make、gcc、openmpi、lapack和scalapack编译安装

地址:https://www.jianshu.com/p/ac42a44d5c7f
编译安装至用户指定目录。


升级make

wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz
tar -zxvf make-4.2.1.tar.gz
cd make-4.2.1
./configure --prefix=$HOME/dirname/make-4.2.1
make && make install

make可执行文件位于dirname/make-4.2.1/bin目录中,添加该目录至PATH环境变量。

gcc

wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar -zxvf gcc-7.3.0.tar.gz
cd gcc-7.3.0
./contrib/download_prerequisites
./configure --prefix=$HOME/dirname/gcc-7.3.0 --disable-multilib
make -j 8 && make install

./contrib/download_prerequisites这步命令需联网下载gmp-6.1.0.tar.bz2mpfr-3.1.4.tar.bz2mpc-1.0.3.tar.gzisl-0.16.1.tar.bz2四个文件,服务器联网方法可见服务器SSH隧道联网设置,也可在ftp://gcc.gnu.org/pub/gcc/infrastructure地址下载,上传至gcc-7.3.0目录执行编译安装。make -j 8为开启8线程加快编译进程,编译完成后添加dirname/gcc-7.3.0/bin至PATH环境变量,dirname/gcc-7.3.0/lib64至LD_LIBRARY_PATH

openmpi

wget https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.2.tar.gz
tar -zxvf openmpi-3.1.2.tar.gz
cd openmpi-3.1.2
./configure --prefix=$HOME/dirname/openmpi-3.1.2
make -j 8 && make install

编译完成后添加dirname/openmpi-3.1.2/bin目录至PATH环境变量,dirname/openmpi-3.1.2/lib目录至LD_LIBRARY_PATH

lapack

wget https://github.com/Reference-LAPACK/lapack/archive/v3.9.0.tar.gz
tar -zxvf lapack-3.9.0.tar.gz
cd lapack-3.9.0
cp INSTALL/make.inc.gfortran ./make.inc

make.inc文件中FFLAGS = -O2 -frecursive改为FFLAGS = -O2 -frecursive -fPIC -m64FFLAGS_NOOPT = -O0 -frecursive改为FFLAGS_NOOPT = -O0 -frecursive -fPIC -m64BLASLIB = $(TOPSRCDIR)/librefblas.a改为BLASLIB = $(TOPSRCDIR)/libblas.a。执行make lapack_install lib blaslib编译,在目录下得到libblas.a liblapack.a libtmglib.a库文件。再将这三个文件复制或ln -s链接至所需位置。

scalapack

wget http://www.netlib.org/scalapack/scalapack-2.1.0.tgz
tar -zxvf scalapack-2.1.0.tgz
cd scalapack-2.1.0
cp SLmake.inc.example SLmake.inc

修改SLmake.inc文件中的下述内容,-lblas-llapacklibblas.aliblapack.a文件。

FC            = mpifort
CC            = mpifort
NOOPT         = -O0 -fPIC
FCFLAGS       = -O3 -fPIC
CCFLAGS       = -O3 -fPIC
CFLAGS        = -O3 -fPIC
BLASLIB       = -L/dirname/lib -lblas
LAPACKLIB     = -L/dirname/lib -llapack

执行如下命令后make,得到libscalapack.a库文件,再将libscalapack.a复制或链接至所需位置。

sed -i '0,/int   n/! s/int   n/int long n/' REDIST/SRC/pgemraux.c
sed -i 's|MPI_Comm_create(tcomm, tgrp|MPI_Comm_create_group(tcomm, tgrp, 0|g' BLACS/SRC/blacs_map_.c
sed -i 's|MPI_Comm_create(ucomm, bgrp|MPI_Comm_create_group(ucomm, bgrp, 0|g' BLACS/SRC/BI_TransUserComm.c

你可能感兴趣的:(make、gcc、openmpi、lapack和scalapack编译安装)